]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
dm: convert ffs to __ffs
authorMikulas Patocka <mpatocka@redhat.com>
Fri, 2 Oct 2015 15:21:24 +0000 (11:21 -0400)
committerMike Snitzer <snitzer@redhat.com>
Sat, 31 Oct 2015 23:06:01 +0000 (19:06 -0400)
ffs counts bit starting with 1 (for the least significant bit), __ffs
counts bits starting with 0. This patch changes various occurrences of ffs
to __ffs and removes subtraction of 1 from the result.

Note that __ffs (unlike ffs) is not defined when called with zero
argument, but it is not called with zero argument in any of these cases.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-bufio.c
drivers/md/dm-cache-policy-cleaner.c
drivers/md/dm-cache-policy-mq.c
drivers/md/dm-cache-policy-smq.c
drivers/md/dm-exception-store.c
drivers/md/dm-region-hash.c
drivers/md/dm-snap-persistent.c

index e1547d0dadfd476d79117e755ebb92978dff18ea..2dd33085b331da5bee79392dcf30f7e2c734f70b 100644 (file)
@@ -1598,11 +1598,11 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsign
 
        c->bdev = bdev;
        c->block_size = block_size;
-       c->sectors_per_block_bits = ffs(block_size) - 1 - SECTOR_SHIFT;
-       c->pages_per_block_bits = (ffs(block_size) - 1 >= PAGE_SHIFT) ?
-                                 ffs(block_size) - 1 - PAGE_SHIFT : 0;
-       c->blocks_per_page_bits = (ffs(block_size) - 1 < PAGE_SHIFT ?
-                                 PAGE_SHIFT - (ffs(block_size) - 1) : 0);
+       c->sectors_per_block_bits = __ffs(block_size) - SECTOR_SHIFT;
+       c->pages_per_block_bits = (__ffs(block_size) >= PAGE_SHIFT) ?
+                                 __ffs(block_size) - PAGE_SHIFT : 0;
+       c->blocks_per_page_bits = (__ffs(block_size) < PAGE_SHIFT ?
+                                 PAGE_SHIFT - __ffs(block_size) : 0);
 
        c->aux_size = aux_size;
        c->alloc_callback = alloc_callback;
index 240c9f0e85e74e864624f0cb972c5b4394eaf11f..c1612d43e601876ed7b9e850f137bd9fd3ef6fff 100644 (file)
@@ -83,7 +83,7 @@ static struct list_head *list_pop(struct list_head *q)
 static int alloc_hash(struct hash *hash, unsigned elts)
 {
        hash->nr_buckets = next_power(elts >> 4, 16);
-       hash->hash_bits = ffs(hash->nr_buckets) - 1;
+       hash->hash_bits = __ffs(hash->nr_buckets);
        hash->table = vzalloc(sizeof(*hash->table) * hash->nr_buckets);
 
        return hash->table ? 0 : -ENOMEM;
index aa1b41ca40f778dcb4e6c0e393ab4ee33d25d388..ddb26980cd669ec81bf00aa1370e71bd6e30e107 100644 (file)
@@ -1410,7 +1410,7 @@ static struct dm_cache_policy *mq_create(dm_cblock_t cache_size,
        mq->generation_period = max((unsigned) from_cblock(cache_size), 1024U);
 
        mq->nr_buckets = next_power(from_cblock(cache_size) / 2, 16);
-       mq->hash_bits = ffs(mq->nr_buckets) - 1;
+       mq->hash_bits = __ffs(mq->nr_buckets);
        mq->table = vzalloc(sizeof(*mq->table) * mq->nr_buckets);
        if (!mq->table)
                goto bad_alloc_table;
index 1ffbeb1b3ea6088fd07bed9c68352821223c0b84..28d4586748d0033e1a2940bd8688b72ba34e84e5 100644 (file)
@@ -566,7 +566,7 @@ static int h_init(struct hash_table *ht, struct entry_space *es, unsigned nr_ent
 
        ht->es = es;
        nr_buckets = roundup_pow_of_two(max(nr_entries / 4u, 16u));
-       ht->hash_bits = ffs(nr_buckets) - 1;
+       ht->hash_bits = __ffs(nr_buckets);
 
        ht->buckets = vmalloc(sizeof(*ht->buckets) * nr_buckets);
        if (!ht->buckets)
index ebaa4f803eec3a08a0cd9fcd9a9a1b933618c50c..3eef6d6f15cd1724098e6141fa60aa66682d6158 100644 (file)
@@ -183,7 +183,7 @@ int dm_exception_store_set_chunk_size(struct dm_exception_store *store,
 
        store->chunk_size = chunk_size;
        store->chunk_mask = chunk_size - 1;
-       store->chunk_shift = ffs(chunk_size) - 1;
+       store->chunk_shift = __ffs(chunk_size);
 
        return 0;
 }
index f3d608bedffe8c61c294601633073aee83fec0f4..74cb7b991d41d80384e3aaf34baf030579cc93d6 100644 (file)
@@ -193,7 +193,7 @@ struct dm_region_hash *dm_region_hash_create(
        rh->max_recovery = max_recovery;
        rh->log = log;
        rh->region_size = region_size;
-       rh->region_shift = ffs(region_size) - 1;
+       rh->region_shift = __ffs(region_size);
        rwlock_init(&rh->hash_lock);
        rh->mask = nr_buckets - 1;
        rh->nr_buckets = nr_buckets;
index bf71583296f732b6b78c71ae67dee5222824b2f8..046f6b81e6e6d7aff657e5a0ff1f977714b36be2 100644 (file)
@@ -321,7 +321,7 @@ static int read_header(struct pstore *ps, int *new_snapshot)
                    bdev_logical_block_size(dm_snap_cow(ps->store->snap)->
                                            bdev) >> 9);
                ps->store->chunk_mask = ps->store->chunk_size - 1;
-               ps->store->chunk_shift = ffs(ps->store->chunk_size) - 1;
+               ps->store->chunk_shift = __ffs(ps->store->chunk_size);
                chunk_size_supplied = 0;
        }