Re: [RFC PATCH 4/5] md: introduce MAX_RAID_DISKS macro to replace magic number

"John Stoffel" <[email protected]>
Newsgroups gmane.linux.raid,gmane.linux.kernel
Message-ID <[email protected]>
>>>>> "Zheng" == Zheng Qixing <[email protected]> writes:

> From: Zheng Qixing <[email protected]>

> Define MAX_RAID_DISKS macro for the maximum number of RAID disks.
> No functional change.

> Signed-off-by: Zheng Qixing <[email protected]>
> ---
>  drivers/md/md.c | 4 ++--
>  drivers/md/md.h | 1 +
>  2 files changed, 3 insertions(+), 2 deletions(-)

> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 9eeab5258189..d2f136706f6c 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -1888,7 +1888,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
 
>  	if (sb->magic != cpu_to_le32(MD_SB_MAGIC) ||
sb-> major_version != cpu_to_le32(1) ||
> -	    le32_to_cpu(sb->max_dev) > (4096-256)/2 ||
> +	    le32_to_cpu(sb->max_dev) > MAX_RAID_DISKS ||
>  	    le64_to_cpu(sb->super_offset) != rdev->sb_start ||
>  	    (le32_to_cpu(sb->feature_map) & ~MD_FEATURE_ALL) != 0)
>  		return -EINVAL;
> @@ -2065,7 +2065,7 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *freshest, struc
mddev-> resync_offset = le64_to_cpu(sb->resync_offset);
>  		memcpy(mddev->uuid, sb->set_uuid, 16);
 
> -		mddev->max_disks =  (4096-256)/2;
> +		mddev->max_disks = MAX_RAID_DISKS;
 
>  		if (!mddev->logical_block_size)
mddev-> logical_block_size = le32_to_cpu(sb->logical_block_size);
> diff --git a/drivers/md/md.h b/drivers/md/md.h
> index a083f37374d0..6a4af4a1959c 100644
> --- a/drivers/md/md.h
> +++ b/drivers/md/md.h
> @@ -22,6 +22,7 @@
>  #include <trace/events/block.h>
 
>  #define MaxSector (~(sector_t)0)
> +#define MAX_RAID_DISKS ((4096-256)/2)

Looks fine to me, except there's no explanation for the magic numbers
here.  Sure, it's 1916 devices max, but WHY?  Other than that nit,
looks fine.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.