Linux-ext4 Archive mirror
 help / color / mirror / Atom feed
* [PATCHv3 0/4] submit_bh: Drop unnecessary return value
@ 2022-08-18  5:04 Ritesh Harjani (IBM)
  2022-08-18  5:04 ` [PATCHv3 1/4] jbd2: Drop useless return value of submit_bh Ritesh Harjani (IBM)
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Ritesh Harjani (IBM) @ 2022-08-18  5:04 UTC (permalink / raw
  To: linux-ext4, linux-fsdevel
  Cc: Jan Kara, Alexander Viro, Christoph Hellwig, linux-ntfs-dev,
	Ritesh Harjani (IBM)

submit_bh/submit_bh_wbc are non-blocking functions which just submits
the bio and returns. The caller of submit_bh/submit_bh_wbc needs to wait
on buffer till I/O completion and then check buffer head's b_state field
to know if there was any I/O error.

Hence there is no need for these functions to have any return type.
Even now they always returns 0. Hence drop the return value and make
their return type as void to avoid any confusion.

PATCHv2 -> PATCHv3
===================
1. Rebased on top of the latest 6.0-rc1 release.
   Recently REQ_OP_** req operations and REQ_** flags were combined as one
   parameter (blk_opf_t type) to submit_bh() API.
2. Since the patch series remains trivial on rebase, I have retained the
   reviewed-by from Jan and Christoph.

RFC -> PATCHv2
===============
1. Added Patch-2 to fix ntfs_submit_bh_for_read() caller.
2. Added Reviewed-by from Christoph.

Ritesh Harjani (IBM) (4):
  jbd2: Drop useless return value of submit_bh
  fs/ntfs: Drop useless return value of submit_bh from ntfs_submit_bh_for_read
  fs/buffer: Drop useless return value of submit_bh
  fs/buffer: Make submit_bh & submit_bh_wbc return type as void

 fs/buffer.c                 | 23 ++++++++++-------------
 fs/jbd2/commit.c            | 10 ++++------
 fs/jbd2/journal.c           |  9 ++++-----
 fs/ntfs/file.c              |  4 ++--
 include/linux/buffer_head.h |  2 +-
 5 files changed, 21 insertions(+), 27 deletions(-)

--
2.35.3


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCHv3 1/4] jbd2: Drop useless return value of submit_bh
  2022-08-18  5:04 [PATCHv3 0/4] submit_bh: Drop unnecessary return value Ritesh Harjani (IBM)
@ 2022-08-18  5:04 ` Ritesh Harjani (IBM)
  2022-08-18  5:04 ` [PATCHv3 2/4] fs/ntfs: Drop useless return value of submit_bh from ntfs_submit_bh_for_read Ritesh Harjani (IBM)
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Ritesh Harjani (IBM) @ 2022-08-18  5:04 UTC (permalink / raw
  To: linux-ext4, linux-fsdevel
  Cc: Jan Kara, Alexander Viro, Christoph Hellwig, linux-ntfs-dev,
	Ritesh Harjani (IBM), Jan Kara

submit_bh always returns 0. This patch cleans up 2 of it's caller
in jbd2 to drop submit_bh's useless return value.
Once all submit_bh callers are cleaned up, we can make it's return
type as void.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
 fs/jbd2/commit.c  | 10 ++++------
 fs/jbd2/journal.c |  9 ++++-----
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index b2b2bc9b88d9..6b51d2dc56e2 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -122,8 +122,8 @@ static int journal_submit_commit_record(journal_t *journal,
 {
 	struct commit_header *tmp;
 	struct buffer_head *bh;
-	int ret;
 	struct timespec64 now;
+	blk_opf_t write_flags = REQ_OP_WRITE | REQ_SYNC;
 
 	*cbh = NULL;
 
@@ -155,13 +155,11 @@ static int journal_submit_commit_record(journal_t *journal,
 
 	if (journal->j_flags & JBD2_BARRIER &&
 	    !jbd2_has_feature_async_commit(journal))
-		ret = submit_bh(REQ_OP_WRITE | REQ_SYNC | REQ_PREFLUSH |
-				REQ_FUA, bh);
-	else
-		ret = submit_bh(REQ_OP_WRITE | REQ_SYNC, bh);
+		write_flags |= REQ_PREFLUSH | REQ_FUA;
 
+	submit_bh(write_flags, bh);
 	*cbh = bh;
-	return ret;
+	return 0;
 }
 
 /*
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 6350d3857c89..f669ae1ff7a2 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -1606,7 +1606,7 @@ static int jbd2_write_superblock(journal_t *journal, blk_opf_t write_flags)
 {
 	struct buffer_head *bh = journal->j_sb_buffer;
 	journal_superblock_t *sb = journal->j_superblock;
-	int ret;
+	int ret = 0;
 
 	/* Buffer got discarded which means block device got invalidated */
 	if (!buffer_mapped(bh)) {
@@ -1636,7 +1636,7 @@ static int jbd2_write_superblock(journal_t *journal, blk_opf_t write_flags)
 		sb->s_checksum = jbd2_superblock_csum(journal, sb);
 	get_bh(bh);
 	bh->b_end_io = end_buffer_write_sync;
-	ret = submit_bh(REQ_OP_WRITE | write_flags, bh);
+	submit_bh(REQ_OP_WRITE | write_flags, bh);
 	wait_on_buffer(bh);
 	if (buffer_write_io_error(bh)) {
 		clear_buffer_write_io_error(bh);
@@ -1644,9 +1644,8 @@ static int jbd2_write_superblock(journal_t *journal, blk_opf_t write_flags)
 		ret = -EIO;
 	}
 	if (ret) {
-		printk(KERN_ERR "JBD2: Error %d detected when updating "
-		       "journal superblock for %s.\n", ret,
-		       journal->j_devname);
+		printk(KERN_ERR "JBD2: I/O error when updating journal superblock for %s.\n",
+				journal->j_devname);
 		if (!is_journal_aborted(journal))
 			jbd2_journal_abort(journal, ret);
 	}
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCHv3 2/4] fs/ntfs: Drop useless return value of submit_bh from ntfs_submit_bh_for_read
  2022-08-18  5:04 [PATCHv3 0/4] submit_bh: Drop unnecessary return value Ritesh Harjani (IBM)
  2022-08-18  5:04 ` [PATCHv3 1/4] jbd2: Drop useless return value of submit_bh Ritesh Harjani (IBM)
@ 2022-08-18  5:04 ` Ritesh Harjani (IBM)
  2022-08-18  5:04 ` [PATCHv3 3/4] fs/buffer: Drop useless return value of submit_bh Ritesh Harjani (IBM)
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Ritesh Harjani (IBM) @ 2022-08-18  5:04 UTC (permalink / raw
  To: linux-ext4, linux-fsdevel
  Cc: Jan Kara, Alexander Viro, Christoph Hellwig, linux-ntfs-dev,
	Ritesh Harjani (IBM), Jan Kara, kernel test robot

submit_bh always returns 0. This patch drops the useless return value of
submit_bh from ntfs_submit_bh_for_read(). Once all of submit_bh callers are
cleaned up, we can make it's return type as void.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Ritesh Harjani <ritesh.list@gmail.com>
---
 fs/ntfs/file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index 58b660dbbee9..c481b14e4fd9 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -527,12 +527,12 @@ static inline int __ntfs_grab_cache_pages(struct address_space *mapping,
 	goto out;
 }
 
-static inline int ntfs_submit_bh_for_read(struct buffer_head *bh)
+static inline void ntfs_submit_bh_for_read(struct buffer_head *bh)
 {
 	lock_buffer(bh);
 	get_bh(bh);
 	bh->b_end_io = end_buffer_read_sync;
-	return submit_bh(REQ_OP_READ, bh);
+	submit_bh(REQ_OP_READ, bh);
 }
 
 /**
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCHv3 3/4] fs/buffer: Drop useless return value of submit_bh
  2022-08-18  5:04 [PATCHv3 0/4] submit_bh: Drop unnecessary return value Ritesh Harjani (IBM)
  2022-08-18  5:04 ` [PATCHv3 1/4] jbd2: Drop useless return value of submit_bh Ritesh Harjani (IBM)
  2022-08-18  5:04 ` [PATCHv3 2/4] fs/ntfs: Drop useless return value of submit_bh from ntfs_submit_bh_for_read Ritesh Harjani (IBM)
@ 2022-08-18  5:04 ` Ritesh Harjani (IBM)
  2022-08-18 14:15   ` Jan Kara
  2022-08-18  5:04 ` [PATCHv3 4/4] fs/buffer: Make submit_bh & submit_bh_wbc return type as void Ritesh Harjani (IBM)
  2022-09-29 14:58 ` [PATCHv3 0/4] submit_bh: Drop unnecessary return value Theodore Ts'o
  4 siblings, 1 reply; 7+ messages in thread
From: Ritesh Harjani (IBM) @ 2022-08-18  5:04 UTC (permalink / raw
  To: linux-ext4, linux-fsdevel
  Cc: Jan Kara, Alexander Viro, Christoph Hellwig, linux-ntfs-dev,
	Ritesh Harjani (IBM)

submit_bh always returns 0. This patch drops the useless return value of
submit_bh from __sync_dirty_buffer(). Once all of submit_bh callers are
cleaned up, we can make it's return type as void.

Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
 fs/buffer.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/fs/buffer.c b/fs/buffer.c
index 55e762a58eb6..c21b72c06eb0 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2801,8 +2801,6 @@ EXPORT_SYMBOL(write_dirty_buffer);
  */
 int __sync_dirty_buffer(struct buffer_head *bh, blk_opf_t op_flags)
 {
-	int ret = 0;
-
 	WARN_ON(atomic_read(&bh->b_count) < 1);
 	lock_buffer(bh);
 	if (test_clear_buffer_dirty(bh)) {
@@ -2817,14 +2815,14 @@ int __sync_dirty_buffer(struct buffer_head *bh, blk_opf_t op_flags)
 
 		get_bh(bh);
 		bh->b_end_io = end_buffer_write_sync;
-		ret = submit_bh(REQ_OP_WRITE | op_flags, bh);
+		submit_bh(REQ_OP_WRITE | op_flags, bh);
 		wait_on_buffer(bh);
-		if (!ret && !buffer_uptodate(bh))
-			ret = -EIO;
+		if (!buffer_uptodate(bh))
+			return -EIO;
 	} else {
 		unlock_buffer(bh);
 	}
-	return ret;
+	return 0;
 }
 EXPORT_SYMBOL(__sync_dirty_buffer);
 
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCHv3 4/4] fs/buffer: Make submit_bh & submit_bh_wbc return type as void
  2022-08-18  5:04 [PATCHv3 0/4] submit_bh: Drop unnecessary return value Ritesh Harjani (IBM)
                   ` (2 preceding siblings ...)
  2022-08-18  5:04 ` [PATCHv3 3/4] fs/buffer: Drop useless return value of submit_bh Ritesh Harjani (IBM)
@ 2022-08-18  5:04 ` Ritesh Harjani (IBM)
  2022-09-29 14:58 ` [PATCHv3 0/4] submit_bh: Drop unnecessary return value Theodore Ts'o
  4 siblings, 0 replies; 7+ messages in thread
From: Ritesh Harjani (IBM) @ 2022-08-18  5:04 UTC (permalink / raw
  To: linux-ext4, linux-fsdevel
  Cc: Jan Kara, Alexander Viro, Christoph Hellwig, linux-ntfs-dev,
	Ritesh Harjani (IBM), Jan Kara

submit_bh/submit_bh_wbc are non-blocking functions which just submit
the bio and return. The caller of submit_bh/submit_bh_wbc needs to wait
on buffer till I/O completion and then check buffer head's b_state field
to know if there was any I/O error.

Hence there is no need for these functions to have any return type.
Even now they always returns 0. Hence drop the return value and make
their return type as void to avoid any confusion.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
 fs/buffer.c                 | 13 ++++++-------
 include/linux/buffer_head.h |  2 +-
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/fs/buffer.c b/fs/buffer.c
index c21b72c06eb0..0a7ba84c1905 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -52,8 +52,8 @@
 #include "internal.h"
 
 static int fsync_buffers_list(spinlock_t *lock, struct list_head *list);
-static int submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh,
-			 struct writeback_control *wbc);
+static void submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh,
+			  struct writeback_control *wbc);
 
 #define BH_ENTRY(list) list_entry((list), struct buffer_head, b_assoc_buffers)
 
@@ -2673,8 +2673,8 @@ static void end_bio_bh_io_sync(struct bio *bio)
 	bio_put(bio);
 }
 
-static int submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh,
-			 struct writeback_control *wbc)
+static void submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh,
+			  struct writeback_control *wbc)
 {
 	const enum req_op op = opf & REQ_OP_MASK;
 	struct bio *bio;
@@ -2717,12 +2717,11 @@ static int submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh,
 	}
 
 	submit_bio(bio);
-	return 0;
 }
 
-int submit_bh(blk_opf_t opf, struct buffer_head *bh)
+void submit_bh(blk_opf_t opf, struct buffer_head *bh)
 {
-	return submit_bh_wbc(opf, bh, NULL);
+	submit_bh_wbc(opf, bh, NULL);
 }
 EXPORT_SYMBOL(submit_bh);
 
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index def8b8d30ccc..b1373844c43d 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -229,7 +229,7 @@ void ll_rw_block(blk_opf_t, int, struct buffer_head * bh[]);
 int sync_dirty_buffer(struct buffer_head *bh);
 int __sync_dirty_buffer(struct buffer_head *bh, blk_opf_t op_flags);
 void write_dirty_buffer(struct buffer_head *bh, blk_opf_t op_flags);
-int submit_bh(blk_opf_t, struct buffer_head *);
+void submit_bh(blk_opf_t, struct buffer_head *);
 void write_boundary_block(struct block_device *bdev,
 			sector_t bblock, unsigned blocksize);
 int bh_uptodate_or_lock(struct buffer_head *bh);
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCHv3 3/4] fs/buffer: Drop useless return value of submit_bh
  2022-08-18  5:04 ` [PATCHv3 3/4] fs/buffer: Drop useless return value of submit_bh Ritesh Harjani (IBM)
@ 2022-08-18 14:15   ` Jan Kara
  0 siblings, 0 replies; 7+ messages in thread
From: Jan Kara @ 2022-08-18 14:15 UTC (permalink / raw
  To: Ritesh Harjani (IBM)
  Cc: linux-ext4, linux-fsdevel, Jan Kara, Alexander Viro,
	Christoph Hellwig, linux-ntfs-dev

On Thu 18-08-22 10:34:39, Ritesh Harjani (IBM) wrote:
> submit_bh always returns 0. This patch drops the useless return value of
> submit_bh from __sync_dirty_buffer(). Once all of submit_bh callers are
> cleaned up, we can make it's return type as void.
> 
> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/buffer.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/buffer.c b/fs/buffer.c
> index 55e762a58eb6..c21b72c06eb0 100644
> --- a/fs/buffer.c
> +++ b/fs/buffer.c
> @@ -2801,8 +2801,6 @@ EXPORT_SYMBOL(write_dirty_buffer);
>   */
>  int __sync_dirty_buffer(struct buffer_head *bh, blk_opf_t op_flags)
>  {
> -	int ret = 0;
> -
>  	WARN_ON(atomic_read(&bh->b_count) < 1);
>  	lock_buffer(bh);
>  	if (test_clear_buffer_dirty(bh)) {
> @@ -2817,14 +2815,14 @@ int __sync_dirty_buffer(struct buffer_head *bh, blk_opf_t op_flags)
>  
>  		get_bh(bh);
>  		bh->b_end_io = end_buffer_write_sync;
> -		ret = submit_bh(REQ_OP_WRITE | op_flags, bh);
> +		submit_bh(REQ_OP_WRITE | op_flags, bh);
>  		wait_on_buffer(bh);
> -		if (!ret && !buffer_uptodate(bh))
> -			ret = -EIO;
> +		if (!buffer_uptodate(bh))
> +			return -EIO;
>  	} else {
>  		unlock_buffer(bh);
>  	}
> -	return ret;
> +	return 0;
>  }
>  EXPORT_SYMBOL(__sync_dirty_buffer);
>  
> -- 
> 2.35.3
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCHv3 0/4] submit_bh: Drop unnecessary return value
  2022-08-18  5:04 [PATCHv3 0/4] submit_bh: Drop unnecessary return value Ritesh Harjani (IBM)
                   ` (3 preceding siblings ...)
  2022-08-18  5:04 ` [PATCHv3 4/4] fs/buffer: Make submit_bh & submit_bh_wbc return type as void Ritesh Harjani (IBM)
@ 2022-09-29 14:58 ` Theodore Ts'o
  4 siblings, 0 replies; 7+ messages in thread
From: Theodore Ts'o @ 2022-09-29 14:58 UTC (permalink / raw
  To: ritesh.list, linux-ext4, linux-fsdevel
  Cc: Theodore Ts'o, linux-ntfs-dev, Christoph Hellwig, jack,
	Al Viro

On Thu, 18 Aug 2022 10:34:36 +0530, Ritesh Harjani (IBM) wrote:
> submit_bh/submit_bh_wbc are non-blocking functions which just submits
> the bio and returns. The caller of submit_bh/submit_bh_wbc needs to wait
> on buffer till I/O completion and then check buffer head's b_state field
> to know if there was any I/O error.
> 
> Hence there is no need for these functions to have any return type.
> Even now they always returns 0. Hence drop the return value and make
> their return type as void to avoid any confusion.
> 
> [...]

Applied, thanks!

[1/4] jbd2: Drop useless return value of submit_bh
      commit: c2939da1fe8b25c82c1991eb983638463ed84a0c
[2/4] fs/ntfs: Drop useless return value of submit_bh from ntfs_submit_bh_for_read
      commit: f102f1ab784c91c559a3505d024008ff2decc77f
[3/4] fs/buffer: Drop useless return value of submit_bh
      commit: 7cb83d3c0c485b3b035cdcac4c6ef4937f920c59
[4/4] fs/buffer: Make submit_bh & submit_bh_wbc return type as void
      commit: 54a55bcabb92f7522e006ca38575159c41914c56

Best regards,
-- 
Theodore Ts'o <tytso@mit.edu>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-09-29 14:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-18  5:04 [PATCHv3 0/4] submit_bh: Drop unnecessary return value Ritesh Harjani (IBM)
2022-08-18  5:04 ` [PATCHv3 1/4] jbd2: Drop useless return value of submit_bh Ritesh Harjani (IBM)
2022-08-18  5:04 ` [PATCHv3 2/4] fs/ntfs: Drop useless return value of submit_bh from ntfs_submit_bh_for_read Ritesh Harjani (IBM)
2022-08-18  5:04 ` [PATCHv3 3/4] fs/buffer: Drop useless return value of submit_bh Ritesh Harjani (IBM)
2022-08-18 14:15   ` Jan Kara
2022-08-18  5:04 ` [PATCHv3 4/4] fs/buffer: Make submit_bh & submit_bh_wbc return type as void Ritesh Harjani (IBM)
2022-09-29 14:58 ` [PATCHv3 0/4] submit_bh: Drop unnecessary return value Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).