Re: [PATCH 03/14] bcache: remove for_each_cache()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2020/8/17 14:13, Hannes Reinecke wrote:
> On 8/15/20 6:10 AM, Coly Li wrote:
>> Since now each cache_set explicitly has single cache, for_each_cache()
>> is unnecessary. This patch removes this macro, and update all locations
>> where it is used, and makes sure all code logic still being consistent.
>>
>> Signed-off-by: Coly Li <colyli@xxxxxxx>
>> ---
>>   drivers/md/bcache/alloc.c    |  17 ++-
>>   drivers/md/bcache/bcache.h   |   9 +-
>>   drivers/md/bcache/btree.c    | 103 +++++++---------
>>   drivers/md/bcache/journal.c  | 229 ++++++++++++++++-------------------
>>   drivers/md/bcache/movinggc.c |  58 +++++----
>>   drivers/md/bcache/super.c    | 114 +++++++----------
>>   6 files changed, 236 insertions(+), 294 deletions(-)
>>
>> diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
>> index 3385f6add6df..1b8310992dd0 100644
>> --- a/drivers/md/bcache/alloc.c
>> +++ b/drivers/md/bcache/alloc.c
>> @@ -88,7 +88,6 @@ void bch_rescale_priorities(struct cache_set *c, int
>> sectors)
>>       struct cache *ca;
>>       struct bucket *b;
>>       unsigned long next = c->nbuckets * c->sb.bucket_size / 1024;
>> -    unsigned int i;
>>       int r;
>>         atomic_sub(sectors, &c->rescale);
>> @@ -104,14 +103,14 @@ void bch_rescale_priorities(struct cache_set *c,
>> int sectors)
>>         c->min_prio = USHRT_MAX;
>>   -    for_each_cache(ca, c, i)
>> -        for_each_bucket(b, ca)
>> -            if (b->prio &&
>> -                b->prio != BTREE_PRIO &&
>> -                !atomic_read(&b->pin)) {
>> -                b->prio--;
>> -                c->min_prio = min(c->min_prio, b->prio);
>> -            }
>> +    ca = c->cache;
>> +    for_each_bucket(b, ca)
>> +        if (b->prio &&
>> +            b->prio != BTREE_PRIO &&
>> +            !atomic_read(&b->pin)) {
>> +            b->prio--;
>> +            c->min_prio = min(c->min_prio, b->prio);
>> +        }
>>         mutex_unlock(&c->bucket_lock);

[snipped]

>>  
> I guess one could remove the 'ca' variables above, but that's just a
> minor detail.

I was thinking of use a macro BCH_CACHE_SB() to reduce c->cache->sb, but
this macro is 12 characters, which does not make code shorter. I don't
make a dicision whether to make it or not. Let me keep it in current
shape, and make dicision later.

Thanks.

Coly Li



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux ARM Kernel]     [Linux Filesystem Development]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux