[PATCH 14/23] md/dm-raid: remove max_write_behind setting limit

Yu Kuai posted 23 patches 6 months, 4 weeks ago
There is a newer version of this series
[PATCH 14/23] md/dm-raid: remove max_write_behind setting limit
Posted by Yu Kuai 6 months, 4 weeks ago
From: Yu Kuai <yukuai3@huawei.com>

The comments said 'vaule in kB', while the value actually means the
number of write_behind IOs. And since md-bitmap will automatically
adjust the value to max COUNTER_MAX / 2, there is no need to fail
early.

Also move some macros that is only used md-bitmap.c.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 drivers/md/dm-raid.c   |  6 +-----
 drivers/md/md-bitmap.c | 10 ++++++++++
 drivers/md/md-bitmap.h |  9 ---------
 3 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 088cfe6e0f98..9757c32ea1f5 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -1356,11 +1356,7 @@ static int parse_raid_params(struct raid_set *rs, struct dm_arg_set *as,
 				return -EINVAL;
 			}
 
-			/*
-			 * In device-mapper, we specify things in sectors, but
-			 * MD records this value in kB
-			 */
-			if (value < 0 || value / 2 > COUNTER_MAX) {
+			if (value < 0) {
 				rs->ti->error = "Max write-behind limit out of range";
 				return -EINVAL;
 			}
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 535bc1888e8c..098e7b6cd187 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -98,9 +98,19 @@
  *
  */
 
+typedef __u16 bitmap_counter_t;
+
 #define PAGE_BITS (PAGE_SIZE << 3)
 #define PAGE_BIT_SHIFT (PAGE_SHIFT + 3)
 
+#define COUNTER_BITS 16
+#define COUNTER_BIT_SHIFT 4
+#define COUNTER_BYTE_SHIFT (COUNTER_BIT_SHIFT - 3)
+
+#define NEEDED_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 1)))
+#define RESYNC_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 2)))
+#define COUNTER_MAX ((bitmap_counter_t) RESYNC_MASK - 1)
+
 #define NEEDED(x) (((bitmap_counter_t) x) & NEEDED_MASK)
 #define RESYNC(x) (((bitmap_counter_t) x) & RESYNC_MASK)
 #define COUNTER(x) (((bitmap_counter_t) x) & COUNTER_MAX)
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index d2cdf831ef1a..a9a0f6a8d96d 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -9,15 +9,6 @@
 
 #define BITMAP_MAGIC 0x6d746962
 
-typedef __u16 bitmap_counter_t;
-#define COUNTER_BITS 16
-#define COUNTER_BIT_SHIFT 4
-#define COUNTER_BYTE_SHIFT (COUNTER_BIT_SHIFT - 3)
-
-#define NEEDED_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 1)))
-#define RESYNC_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 2)))
-#define COUNTER_MAX ((bitmap_counter_t) RESYNC_MASK - 1)
-
 /*
  * version 3 is host-endian order, this is deprecated and not used for new
  * array
-- 
2.39.2
Re: [PATCH 14/23] md/dm-raid: remove max_write_behind setting limit
Posted by Xiao Ni 6 months, 3 weeks ago
On Sat, May 24, 2025 at 2:18 PM Yu Kuai <yukuai1@huaweicloud.com> wrote:
>
> From: Yu Kuai <yukuai3@huawei.com>
>
> The comments said 'vaule in kB', while the value actually means the
> number of write_behind IOs. And since md-bitmap will automatically
> adjust the value to max COUNTER_MAX / 2, there is no need to fail
> early.
>
> Also move some macros that is only used md-bitmap.c.
>
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
>  drivers/md/dm-raid.c   |  6 +-----
>  drivers/md/md-bitmap.c | 10 ++++++++++
>  drivers/md/md-bitmap.h |  9 ---------
>  3 files changed, 11 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
> index 088cfe6e0f98..9757c32ea1f5 100644
> --- a/drivers/md/dm-raid.c
> +++ b/drivers/md/dm-raid.c
> @@ -1356,11 +1356,7 @@ static int parse_raid_params(struct raid_set *rs, struct dm_arg_set *as,
>                                 return -EINVAL;
>                         }
>
> -                       /*
> -                        * In device-mapper, we specify things in sectors, but
> -                        * MD records this value in kB
> -                        */
> -                       if (value < 0 || value / 2 > COUNTER_MAX) {
> +                       if (value < 0) {
>                                 rs->ti->error = "Max write-behind limit out of range";
>                                 return -EINVAL;
>                         }
> diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
> index 535bc1888e8c..098e7b6cd187 100644
> --- a/drivers/md/md-bitmap.c
> +++ b/drivers/md/md-bitmap.c
> @@ -98,9 +98,19 @@
>   *
>   */
>
> +typedef __u16 bitmap_counter_t;
> +
>  #define PAGE_BITS (PAGE_SIZE << 3)
>  #define PAGE_BIT_SHIFT (PAGE_SHIFT + 3)
>
> +#define COUNTER_BITS 16
> +#define COUNTER_BIT_SHIFT 4
> +#define COUNTER_BYTE_SHIFT (COUNTER_BIT_SHIFT - 3)
> +
> +#define NEEDED_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 1)))
> +#define RESYNC_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 2)))
> +#define COUNTER_MAX ((bitmap_counter_t) RESYNC_MASK - 1)
> +
>  #define NEEDED(x) (((bitmap_counter_t) x) & NEEDED_MASK)
>  #define RESYNC(x) (((bitmap_counter_t) x) & RESYNC_MASK)
>  #define COUNTER(x) (((bitmap_counter_t) x) & COUNTER_MAX)
> diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
> index d2cdf831ef1a..a9a0f6a8d96d 100644
> --- a/drivers/md/md-bitmap.h
> +++ b/drivers/md/md-bitmap.h
> @@ -9,15 +9,6 @@
>
>  #define BITMAP_MAGIC 0x6d746962
>
> -typedef __u16 bitmap_counter_t;
> -#define COUNTER_BITS 16
> -#define COUNTER_BIT_SHIFT 4
> -#define COUNTER_BYTE_SHIFT (COUNTER_BIT_SHIFT - 3)
> -
> -#define NEEDED_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 1)))
> -#define RESYNC_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 2)))
> -#define COUNTER_MAX ((bitmap_counter_t) RESYNC_MASK - 1)
> -
>  /*
>   * version 3 is host-endian order, this is deprecated and not used for new
>   * array
> --
> 2.39.2
>

Reviewed-by: Xiao Ni <xni@redhat.com>
Re: [PATCH 14/23] md/dm-raid: remove max_write_behind setting limit
Posted by Hannes Reinecke 6 months, 3 weeks ago
On 5/24/25 08:13, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> The comments said 'vaule in kB', while the value actually means the
> number of write_behind IOs. And since md-bitmap will automatically
> adjust the value to max COUNTER_MAX / 2, there is no need to fail
> early.
> 
> Also move some macros that is only used md-bitmap.c.
> 
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
>   drivers/md/dm-raid.c   |  6 +-----
>   drivers/md/md-bitmap.c | 10 ++++++++++
>   drivers/md/md-bitmap.h |  9 ---------
>   3 files changed, 11 insertions(+), 14 deletions(-)
> 

Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare@suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Re: [PATCH 14/23] md/dm-raid: remove max_write_behind setting limit
Posted by Christoph Hellwig 6 months, 3 weeks ago
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>