public inbox for linux-raid@vger.kernel.org
 help / color / mirror / Atom feed
From: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
To: Yufen Yu <yuyufen@huawei.com>, song@kernel.org
Cc: linux-raid@vger.kernel.org, neilb@suse.com, houtao1@huawei.com
Subject: Re: [PATCH v5 01/16] md/raid456: covert macro define of STRIPE_* as members of struct r5conf
Date: Mon, 6 Jul 2020 13:34:07 +0200	[thread overview]
Message-ID: <0f99d3f6-ae4e-548d-93c1-32ef4b9d2473@cloud.ionos.com> (raw)
In-Reply-To: <84277307-fc0a-44e2-8564-699651a7ff47@cloud.ionos.com>

On 7/6/20 11:09 AM, Guoqing Jiang wrote:
> On 7/2/20 2:06 PM, Yufen Yu wrote:
>> @@ -2509,10 +2532,11 @@ static void raid5_end_read_request(struct bio 
>> * bi)
>>                */
>>               pr_info_ratelimited(
>>                   "md/raid:%s: read error corrected (%lu sectors at 
>> %llu on %s)\n",
>> -                mdname(conf->mddev), STRIPE_SECTORS,
>> +                mdname(conf->mddev),
>> +                conf->stripe_sectors,
>
> The conf->stripe_sectors is printed with %lu format.
>
>> ot allow a suitable chunk size */
>>           return ERR_PTR(-EINVAL);
>>   diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h
>> index f90e0704bed9..e36cf71e8465 100644
>> --- a/drivers/md/raid5.h
>> +++ b/drivers/md/raid5.h
>> @@ -472,32 +472,12 @@ struct disk_info {
>>    */
>>     #define NR_STRIPES        256
>> -#define STRIPE_SIZE        PAGE_SIZE
>> -#define STRIPE_SHIFT        (PAGE_SHIFT - 9)
>> -#define STRIPE_SECTORS        (STRIPE_SIZE>>9)
>>   #define    IO_THRESHOLD        1
>>   #define BYPASS_THRESHOLD    1
>>   #define NR_HASH            (PAGE_SIZE / sizeof(struct hlist_head))
>>   #define HASH_MASK        (NR_HASH - 1)
>>   #define MAX_STRIPE_BATCH    8
>
> [...]
>
>>     return NULL;
>> -}
>> -
>>   /* NOTE NR_STRIPE_HASH_LOCKS must remain below 64.
>>    * This is because we sometimes take all the spinlocks
>>    * and creating that much locking depth can cause
>> @@ -574,6 +554,9 @@ struct r5conf {
>>       int            raid_disks;
>>       int            max_nr_stripes;
>>       int            min_nr_stripes;
>> +    unsigned int    stripe_size;
>> +    unsigned int    stripe_shift;
>> +    unsigned int    stripe_sectors;
>
> So you need to define it with "unsigned long".
>
> Also, I am wondering if it is cleaner with something like below.
>
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index 8dea4398b191..984eea97e77c 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -6918,6 +6918,7 @@ static struct r5conf *setup_conf(struct mddev 
> *mddev)
>         conf = kzalloc(sizeof(struct r5conf), GFP_KERNEL);
>         if (conf == NULL)
>                 goto abort;
> +       r5conf_set_size(conf, PAGE_SIZE);
>         INIT_LIST_HEAD(&conf->free_list);
>         INIT_LIST_HEAD(&conf->pending_list);
>         conf->pending_data = kcalloc(PENDING_IO_MAX,
> diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h
> index f90e0704bed9..04fc4c514d54 100644
> --- a/drivers/md/raid5.h
> +++ b/drivers/md/raid5.h
> @@ -471,10 +471,13 @@ struct disk_info {
>   * Stripe cache
>   */
>
> +static unsigned long stripe_size = PAGE_SIZE;
> +static unsigned long stripe_shift = PAGE_SHIFT - 9;
> +static unsigned long stripe_sectors = PAGE_SIZE>>9;
>  #define NR_STRIPES             256
> -#define STRIPE_SIZE            PAGE_SIZE
> -#define STRIPE_SHIFT           (PAGE_SHIFT - 9)
> -#define STRIPE_SECTORS         (STRIPE_SIZE>>9)
> +#define STRIPE_SIZE            stripe_size
> +#define STRIPE_SHIFT           stripe_shift
> +#define STRIPE_SECTORS         stripe_sectors
>  #define        IO_THRESHOLD            1
>  #define BYPASS_THRESHOLD       1
>  #define NR_HASH                        (PAGE_SIZE / sizeof(struct 
> hlist_head))
> @@ -574,6 +577,9 @@ struct r5conf {
>         int                     raid_disks;
>         int                     max_nr_stripes;
>         int                     min_nr_stripes;
> +       unsigned long           stripe_size;
> +       unsigned long           stripe_shift;
> +       unsigned long           stripe_sectors;
>
>         /* reshape_progress is the leading edge of a 'reshape'
>          * It has value MaxSector when no reshape is happening
> @@ -690,6 +696,12 @@ struct r5conf {
>         struct r5pending_data   *next_pending_data;
>  };
>
> +static inline void r5conf_set_size(struct r5conf *conf, unsigned long 
> size)
> +{
> +       stripe_size = conf->stripe_size = size;
> +       stripe_shift = conf->stripe_shift = ilog2(size) - 9;
> +       stripe_sectors = conf->stripe_sectors = size >> 9;
> +}
>
>  /*
>   * Our supported algorithms

Hmm, I guess it can't support multiple raid5 with different sizes.

Thanks,
Guoqing

  reply	other threads:[~2020-07-06 11:34 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-02 12:06 [PATCH v5 00/16] md/raid5: set STRIPE_SIZE as a configurable value Yufen Yu
2020-07-02 12:06 ` [PATCH v5 01/16] md/raid456: covert macro define of STRIPE_* as members of struct r5conf Yufen Yu
2020-07-02 14:51   ` kernel test robot
2020-07-02 15:44   ` kernel test robot
2020-07-02 18:15   ` Song Liu
2020-07-02 18:23     ` Paul Menzel
2020-07-12 22:55       ` antlists
2020-07-06  9:09   ` Guoqing Jiang
2020-07-06 11:34     ` Guoqing Jiang [this message]
2020-07-08  2:22     ` Yufen Yu
2020-07-02 12:06 ` [PATCH v5 02/16] md/raid5: add sysfs entry to set and show stripe_size Yufen Yu
2020-07-02 22:14   ` Song Liu
2020-07-02 12:06 ` [PATCH v5 03/16] md/raid5: set default stripe_size as 4096 Yufen Yu
2020-07-02 12:06 ` [PATCH v5 04/16] md/raid5: add a member of r5pages for struct stripe_head Yufen Yu
2020-07-02 22:56   ` Song Liu
2020-07-03  1:22     ` Jason Yan
2020-07-02 12:06 ` [PATCH v5 05/16] md/raid5: allocate and free shared pages of r5pages Yufen Yu
2020-07-02 12:06 ` [PATCH v5 06/16] md/raid5: set correct page offset for bi_io_vec in ops_run_io() Yufen Yu
2020-07-02 12:06 ` [PATCH v5 07/16] md/raid5: set correct page offset for async_copy_data() Yufen Yu
2020-07-02 12:06 ` [PATCH v5 08/16] md/raid5: resize stripes and set correct offset when reshape array Yufen Yu
2020-07-02 12:06 ` [PATCH v5 09/16] md/raid5: add new xor function to support different page offset Yufen Yu
2020-07-02 12:06 ` [PATCH v5 10/16] md/raid5: add offset array in scribble buffer Yufen Yu
2020-07-02 12:06 ` [PATCH v5 11/16] md/raid5: compute xor with correct page offset Yufen Yu
2020-07-02 12:06 ` [PATCH v5 12/16] md/raid5: support config stripe_size by sysfs entry Yufen Yu
2020-07-02 22:38   ` Song Liu
2020-07-04 12:25     ` Yufen Yu
2020-07-02 12:06 ` [PATCH v5 13/16] md/raid6: let syndrome computor support different page offset Yufen Yu
2020-07-02 12:06 ` [PATCH v5 14/16] md/raid6: let async recovery function " Yufen Yu
2020-07-02 12:06 ` [PATCH v5 15/16] md/raid6: compute syndrome with correct " Yufen Yu
2020-07-02 12:06 ` [PATCH v5 16/16] raid6test: adaptation with syndrome function Yufen Yu
2020-07-02 23:00 ` [PATCH v5 00/16] md/raid5: set STRIPE_SIZE as a configurable value Song Liu
2020-07-08 13:14   ` Yufen Yu
2020-07-08 23:55     ` Song Liu
2020-07-09 13:27       ` Yufen Yu
2020-07-10 16:09         ` Song Liu

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=0f99d3f6-ae4e-548d-93c1-32ef4b9d2473@cloud.ionos.com \
    --to=guoqing.jiang@cloud.ionos.com \
    --cc=houtao1@huawei.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.com \
    --cc=song@kernel.org \
    --cc=yuyufen@huawei.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