Re: [PATCH 13/17] md: raid1: use bio_segments_all()

2017-02-16 Thread Ming Lei
On Thu, Feb 16, 2017 at 9:34 PM, Johannes Thumshirn  wrote:
> On 02/16/2017 02:32 PM, Ming Lei wrote:
>> On Thu, Feb 16, 2017 at 8:35 PM, Johannes Thumshirn  
>> wrote:
>>> On 02/16/2017 12:45 PM, Ming Lei wrote:
 @@ -998,7 +998,8 @@ static void alloc_behind_pages(struct bio *bio, struct 
 r1bio *r1_bio)
  {
   int i;
   struct bio_vec *bvec;
 - struct bio_vec *bvecs = kzalloc(bio->bi_vcnt * sizeof(struct 
 bio_vec),
 + unsigned vcnt = bio_segments_all(bio);
 + struct bio_vec *bvecs = kzalloc(vcnt * sizeof(struct bio_vec),
   GFP_NOIO);
>>>
>>> Maybe use kcalloc() instead of kzalloc() with a multiplication.
>>
>> That doesn't belong to this patch, which just wants to remove direct
>> access to .bi_vcnt.
>
> But you're touching it anyways, aren't you?

Don't you know the policy of 'do one thing, do it better' in one patch?

If you want to switch to kcalloc(), just post a patch, that is fine, but
please don't push me to do that in this patch.

Thanks,
Ming Lei


Re: [PATCH 13/17] md: raid1: use bio_segments_all()

2017-02-16 Thread Johannes Thumshirn
On 02/16/2017 02:32 PM, Ming Lei wrote:
> On Thu, Feb 16, 2017 at 8:35 PM, Johannes Thumshirn  
> wrote:
>> On 02/16/2017 12:45 PM, Ming Lei wrote:
>>> @@ -998,7 +998,8 @@ static void alloc_behind_pages(struct bio *bio, struct 
>>> r1bio *r1_bio)
>>>  {
>>>   int i;
>>>   struct bio_vec *bvec;
>>> - struct bio_vec *bvecs = kzalloc(bio->bi_vcnt * sizeof(struct bio_vec),
>>> + unsigned vcnt = bio_segments_all(bio);
>>> + struct bio_vec *bvecs = kzalloc(vcnt * sizeof(struct bio_vec),
>>>   GFP_NOIO);
>>
>> Maybe use kcalloc() instead of kzalloc() with a multiplication.
> 
> That doesn't belong to this patch, which just wants to remove direct
> access to .bi_vcnt.

But you're touching it anyways, aren't you?


-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


Re: [PATCH 13/17] md: raid1: use bio_segments_all()

2017-02-16 Thread Ming Lei
On Thu, Feb 16, 2017 at 8:35 PM, Johannes Thumshirn  wrote:
> On 02/16/2017 12:45 PM, Ming Lei wrote:
>> @@ -998,7 +998,8 @@ static void alloc_behind_pages(struct bio *bio, struct 
>> r1bio *r1_bio)
>>  {
>>   int i;
>>   struct bio_vec *bvec;
>> - struct bio_vec *bvecs = kzalloc(bio->bi_vcnt * sizeof(struct bio_vec),
>> + unsigned vcnt = bio_segments_all(bio);
>> + struct bio_vec *bvecs = kzalloc(vcnt * sizeof(struct bio_vec),
>>   GFP_NOIO);
>
> Maybe use kcalloc() instead of kzalloc() with a multiplication.

That doesn't belong to this patch, which just wants to remove direct
access to .bi_vcnt.


Thanks,
Ming Lei


Re: [PATCH 13/17] md: raid1: use bio_segments_all()

2017-02-16 Thread Johannes Thumshirn
On 02/16/2017 12:45 PM, Ming Lei wrote:
> @@ -998,7 +998,8 @@ static void alloc_behind_pages(struct bio *bio, struct 
> r1bio *r1_bio)
>  {
>   int i;
>   struct bio_vec *bvec;
> - struct bio_vec *bvecs = kzalloc(bio->bi_vcnt * sizeof(struct bio_vec),
> + unsigned vcnt = bio_segments_all(bio);
> + struct bio_vec *bvecs = kzalloc(vcnt * sizeof(struct bio_vec),
>   GFP_NOIO);

Maybe use kcalloc() instead of kzalloc() with a multiplication.

Byte,
Johannes
-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850