diff mbox series

[01/11] md-bitmap: set BITMAP_WRITE_ERROR in write_sb_page

Message ID 20230615064840.629492-2-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [01/11] md-bitmap: set BITMAP_WRITE_ERROR in write_sb_page | expand

Commit Message

Christoph Hellwig June 15, 2023, 6:48 a.m. UTC
Set BITMAP_WRITE_ERROR directly in write_sb_page instead of propagating
the error to the caller and setting it there.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/md/md-bitmap.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

Comments

Hannes Reinecke June 15, 2023, 6:56 a.m. UTC | #1
On 6/15/23 08:48, Christoph Hellwig wrote:
> Set BITMAP_WRITE_ERROR directly in write_sb_page instead of propagating
> the error to the caller and setting it there.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   drivers/md/md-bitmap.c | 21 ++++++++-------------
>   1 file changed, 8 insertions(+), 13 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
Johannes Thumshirn June 15, 2023, 2:22 p.m. UTC | #2
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Himanshu Madhani June 15, 2023, 5:05 p.m. UTC | #3
> On Jun 14, 2023, at 11:48 PM, Christoph Hellwig <hch@lst.de> wrote:
> 
> Set BITMAP_WRITE_ERROR directly in write_sb_page instead of propagating
> the error to the caller and setting it there.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> drivers/md/md-bitmap.c | 21 ++++++++-------------
> 1 file changed, 8 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
> index 1ff712889a3b36..d8469720fac23f 100644
> --- a/drivers/md/md-bitmap.c
> +++ b/drivers/md/md-bitmap.c
> @@ -279,22 +279,20 @@ static int __write_sb_page(struct md_rdev *rdev, struct bitmap *bitmap,
> return 0;
> }
> 
> -static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
> +static void write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
> {
> - struct md_rdev *rdev;
> struct mddev *mddev = bitmap->mddev;
> - int ret;
> 
> do {
> - rdev = NULL;
> + struct md_rdev *rdev = NULL;
> +
> while ((rdev = next_active_rdev(rdev, mddev)) != NULL) {
> - ret = __write_sb_page(rdev, bitmap, page);
> - if (ret)
> - return ret;
> + if (__write_sb_page(rdev, bitmap, page) < 0) {
> + set_bit(BITMAP_WRITE_ERROR, &bitmap->flags);
> + return;
> + }
> }
> } while (wait && md_super_wait(mddev) < 0);
> -
> - return 0;
> }
> 
> static void md_bitmap_file_kick(struct bitmap *bitmap);
> @@ -306,10 +304,7 @@ static void write_page(struct bitmap *bitmap, struct page *page, int wait)
> struct buffer_head *bh;
> 
> if (bitmap->storage.file == NULL) {
> - switch (write_sb_page(bitmap, page, wait)) {
> - case -EINVAL:
> - set_bit(BITMAP_WRITE_ERROR, &bitmap->flags);
> - }
> + write_sb_page(bitmap, page, wait);
> } else {
> 
> bh = page_buffers(page);
> -- 
> 2.39.2
> 

Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
diff mbox series

Patch

diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 1ff712889a3b36..d8469720fac23f 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -279,22 +279,20 @@  static int __write_sb_page(struct md_rdev *rdev, struct bitmap *bitmap,
 	return 0;
 }
 
-static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
+static void write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
 {
-	struct md_rdev *rdev;
 	struct mddev *mddev = bitmap->mddev;
-	int ret;
 
 	do {
-		rdev = NULL;
+		struct md_rdev *rdev = NULL;
+
 		while ((rdev = next_active_rdev(rdev, mddev)) != NULL) {
-			ret = __write_sb_page(rdev, bitmap, page);
-			if (ret)
-				return ret;
+			if (__write_sb_page(rdev, bitmap, page) < 0) {
+				set_bit(BITMAP_WRITE_ERROR, &bitmap->flags);
+				return;
+			}
 		}
 	} while (wait && md_super_wait(mddev) < 0);
-
-	return 0;
 }
 
 static void md_bitmap_file_kick(struct bitmap *bitmap);
@@ -306,10 +304,7 @@  static void write_page(struct bitmap *bitmap, struct page *page, int wait)
 	struct buffer_head *bh;
 
 	if (bitmap->storage.file == NULL) {
-		switch (write_sb_page(bitmap, page, wait)) {
-		case -EINVAL:
-			set_bit(BITMAP_WRITE_ERROR, &bitmap->flags);
-		}
+		write_sb_page(bitmap, page, wait);
 	} else {
 
 		bh = page_buffers(page);