Linux block layer
 help / color / mirror / Atom feed
From: Yu Kuai <yukuai1@huaweicloud.com>
To: Zheng Qixing <zhengqixing@huaweicloud.com>,
	axboe@kernel.dk, song@kernel.org, dan.j.williams@intel.com,
	vishal.l.verma@intel.com, dave.jiang@intel.com,
	ira.weiny@intel.com, dlemoal@kernel.org, kch@nvidia.com,
	yanjun.zhu@linux.dev, hare@suse.de, zhengqixing@huawei.com,
	colyli@kernel.org, geliang@kernel.org, xni@redhat.com
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-raid@vger.kernel.org, nvdimm@lists.linux.dev,
	yi.zhang@huawei.com, yangerkun@huawei.com,
	"yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH V2 11/12] md: improve return types of badblocks handling functions
Date: Thu, 27 Feb 2025 19:48:08 +0800	[thread overview]
Message-ID: <25cce813-7e4e-b82b-48fa-b0ff0b3f3bb2@huaweicloud.com> (raw)
In-Reply-To: <20250227075507.151331-12-zhengqixing@huaweicloud.com>

在 2025/02/27 15:55, Zheng Qixing 写道:
> From: Zheng Qixing <zhengqixing@huawei.com>
> 
> rdev_set_badblocks() only indicates success/failure, so convert its return
> type from int to boolean for better semantic clarity.
> 
> rdev_clear_badblocks() return value is never used by any caller, convert it
> to void. This removes unnecessary value returns.
> 
> Also update narrow_write_error() in both raid1 and raid10 to use boolean
> return type to match rdev_set_badblocks().
> 
> Signed-off-by: Zheng Qixing <zhengqixing@huawei.com>
> ---
>   drivers/md/md.c     | 19 +++++++++----------
>   drivers/md/md.h     |  8 ++++----
>   drivers/md/raid1.c  |  6 +++---
>   drivers/md/raid10.c |  6 +++---
>   4 files changed, 19 insertions(+), 20 deletions(-)
> 
LGTM
Reviewed-by: Yu Kuai <yukuai3@huawei.com>

> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 49d826e475cb..9b9b2b4131d0 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -9841,9 +9841,9 @@ EXPORT_SYMBOL(md_finish_reshape);
>   
>   /* Bad block management */
>   
> -/* Returns 1 on success, 0 on failure */
> -int rdev_set_badblocks(struct md_rdev *rdev, sector_t s, int sectors,
> -		       int is_new)
> +/* Returns true on success, false on failure */
> +bool rdev_set_badblocks(struct md_rdev *rdev, sector_t s, int sectors,
> +			int is_new)
>   {
>   	struct mddev *mddev = rdev->mddev;
>   
> @@ -9855,7 +9855,7 @@ int rdev_set_badblocks(struct md_rdev *rdev, sector_t s, int sectors,
>   	 * avoid it.
>   	 */
>   	if (test_bit(Faulty, &rdev->flags))
> -		return 1;
> +		return true;
>   
>   	if (is_new)
>   		s += rdev->new_data_offset;
> @@ -9863,7 +9863,7 @@ int rdev_set_badblocks(struct md_rdev *rdev, sector_t s, int sectors,
>   		s += rdev->data_offset;
>   
>   	if (!badblocks_set(&rdev->badblocks, s, sectors, 0))
> -		return 0;
> +		return false;
>   
>   	/* Make sure they get written out promptly */
>   	if (test_bit(ExternalBbl, &rdev->flags))
> @@ -9872,12 +9872,12 @@ int rdev_set_badblocks(struct md_rdev *rdev, sector_t s, int sectors,
>   	set_mask_bits(&mddev->sb_flags, 0,
>   		      BIT(MD_SB_CHANGE_CLEAN) | BIT(MD_SB_CHANGE_PENDING));
>   	md_wakeup_thread(rdev->mddev->thread);
> -	return 1;
> +	return true;
>   }
>   EXPORT_SYMBOL_GPL(rdev_set_badblocks);
>   
> -int rdev_clear_badblocks(struct md_rdev *rdev, sector_t s, int sectors,
> -			 int is_new)
> +void rdev_clear_badblocks(struct md_rdev *rdev, sector_t s, int sectors,
> +			  int is_new)
>   {
>   	if (is_new)
>   		s += rdev->new_data_offset;
> @@ -9885,11 +9885,10 @@ int rdev_clear_badblocks(struct md_rdev *rdev, sector_t s, int sectors,
>   		s += rdev->data_offset;
>   
>   	if (!badblocks_clear(&rdev->badblocks, s, sectors))
> -		return 0;
> +		return;
>   
>   	if (test_bit(ExternalBbl, &rdev->flags))
>   		sysfs_notify_dirent_safe(rdev->sysfs_badblocks);
> -	return 1;
>   }
>   EXPORT_SYMBOL_GPL(rdev_clear_badblocks);
>   
> diff --git a/drivers/md/md.h b/drivers/md/md.h
> index def808064ad8..923a0ef51efe 100644
> --- a/drivers/md/md.h
> +++ b/drivers/md/md.h
> @@ -289,10 +289,10 @@ static inline int rdev_has_badblock(struct md_rdev *rdev, sector_t s,
>   	return is_badblock(rdev, s, sectors, &first_bad, &bad_sectors);
>   }
>   
> -extern int rdev_set_badblocks(struct md_rdev *rdev, sector_t s, int sectors,
> -			      int is_new);
> -extern int rdev_clear_badblocks(struct md_rdev *rdev, sector_t s, int sectors,
> -				int is_new);
> +extern bool rdev_set_badblocks(struct md_rdev *rdev, sector_t s, int sectors,
> +			       int is_new);
> +extern void rdev_clear_badblocks(struct md_rdev *rdev, sector_t s, int sectors,
> +				 int is_new);
>   struct md_cluster_info;
>   
>   /**
> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> index 10ea3af40991..8e9f303c5603 100644
> --- a/drivers/md/raid1.c
> +++ b/drivers/md/raid1.c
> @@ -2486,7 +2486,7 @@ static void fix_read_error(struct r1conf *conf, struct r1bio *r1_bio)
>   	}
>   }
>   
> -static int narrow_write_error(struct r1bio *r1_bio, int i)
> +static bool narrow_write_error(struct r1bio *r1_bio, int i)
>   {
>   	struct mddev *mddev = r1_bio->mddev;
>   	struct r1conf *conf = mddev->private;
> @@ -2507,10 +2507,10 @@ static int narrow_write_error(struct r1bio *r1_bio, int i)
>   	sector_t sector;
>   	int sectors;
>   	int sect_to_write = r1_bio->sectors;
> -	int ok = 1;
> +	bool ok = true;
>   
>   	if (rdev->badblocks.shift < 0)
> -		return 0;
> +		return false;
>   
>   	block_sectors = roundup(1 << rdev->badblocks.shift,
>   				bdev_logical_block_size(rdev->bdev) >> 9);
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 15b9ae5bf84d..45faa34f0be8 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -2786,7 +2786,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
>   	}
>   }
>   
> -static int narrow_write_error(struct r10bio *r10_bio, int i)
> +static bool narrow_write_error(struct r10bio *r10_bio, int i)
>   {
>   	struct bio *bio = r10_bio->master_bio;
>   	struct mddev *mddev = r10_bio->mddev;
> @@ -2807,10 +2807,10 @@ static int narrow_write_error(struct r10bio *r10_bio, int i)
>   	sector_t sector;
>   	int sectors;
>   	int sect_to_write = r10_bio->sectors;
> -	int ok = 1;
> +	bool ok = true;
>   
>   	if (rdev->badblocks.shift < 0)
> -		return 0;
> +		return false;
>   
>   	block_sectors = roundup(1 << rdev->badblocks.shift,
>   				bdev_logical_block_size(rdev->bdev) >> 9);
> 


  reply	other threads:[~2025-02-27 11:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-27  7:54 [PATCH V2 00/12] badblocks: bugfix and cleanup for badblocks Zheng Qixing
2025-02-27  7:54 ` [PATCH V2 01/12] badblocks: Fix error shitf ops Zheng Qixing
2025-02-27  7:54 ` [PATCH V2 02/12] badblocks: factor out a helper try_adjacent_combine Zheng Qixing
2025-02-27  7:54 ` [PATCH V2 03/12] badblocks: attempt to merge adjacent badblocks during ack_all_badblocks Zheng Qixing
2025-02-27  7:54 ` [PATCH V2 04/12] badblocks: return error directly when setting badblocks exceeds 512 Zheng Qixing
2025-02-27  7:55 ` [PATCH V2 05/12] badblocks: return error if any badblock set fails Zheng Qixing
2025-02-27  7:55 ` [PATCH V2 06/12] badblocks: fix the using of MAX_BADBLOCKS Zheng Qixing
2025-02-27  7:55 ` [PATCH V2 07/12] badblocks: try can_merge_front before overlap_front Zheng Qixing
2025-02-27  7:55 ` [PATCH V2 08/12] badblocks: fix merge issue when new badblocks align with pre+1 Zheng Qixing
2025-02-27  7:55 ` [PATCH V2 09/12] badblocks: fix missing bad blocks on retry in _badblocks_check() Zheng Qixing
2025-02-27  7:55 ` [PATCH V2 10/12] badblocks: return boolean from badblocks_set() and badblocks_clear() Zheng Qixing
2025-02-27 15:08   ` Ira Weiny
2025-02-27  7:55 ` [PATCH V2 11/12] md: improve return types of badblocks handling functions Zheng Qixing
2025-02-27 11:48   ` Yu Kuai [this message]
2025-02-27  7:55 ` [PATCH V2 12/12] badblocks: use sector_t instead of int to avoid truncation of badblocks length Zheng Qixing
2025-02-27 15:27   ` Ira Weiny
2025-03-05  1:29     ` Yu Kuai
2025-03-05  1:41 ` [PATCH V2 00/12] badblocks: bugfix and cleanup for badblocks Yu Kuai
2025-03-06 15:05 ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=25cce813-7e4e-b82b-48fa-b0ff0b3f3bb2@huaweicloud.com \
    --to=yukuai1@huaweicloud.com \
    --cc=axboe@kernel.dk \
    --cc=colyli@kernel.org \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dlemoal@kernel.org \
    --cc=geliang@kernel.org \
    --cc=hare@suse.de \
    --cc=ira.weiny@intel.com \
    --cc=kch@nvidia.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    --cc=song@kernel.org \
    --cc=vishal.l.verma@intel.com \
    --cc=xni@redhat.com \
    --cc=yangerkun@huawei.com \
    --cc=yanjun.zhu@linux.dev \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@huawei.com \
    --cc=zhengqixing@huawei.com \
    --cc=zhengqixing@huaweicloud.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox