dm persistent data: eliminate unnecessary return values
authorMikulas Patocka <mpatocka@redhat.com>
Thu, 22 Oct 2015 20:46:59 +0000 (16:46 -0400)
committerMike Snitzer <snitzer@redhat.com>
Sat, 31 Oct 2015 23:06:02 +0000 (19:06 -0400)
dm_bm_unlock and dm_tm_unlock return an integer value but the returned
value is always 0.  The calling code sometimes checks the return value
and sometimes doesn't.

Eliminate these unnecessary return values and also the checks for them.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
13 files changed:
drivers/md/dm-cache-metadata.c
drivers/md/dm-era-target.c
drivers/md/dm-thin-metadata.c
drivers/md/persistent-data/dm-array.c
drivers/md/persistent-data/dm-block-manager.c
drivers/md/persistent-data/dm-block-manager.h
drivers/md/persistent-data/dm-btree-internal.h
drivers/md/persistent-data/dm-btree-remove.c
drivers/md/persistent-data/dm-btree-spine.c
drivers/md/persistent-data/dm-btree.c
drivers/md/persistent-data/dm-space-map-common.c
drivers/md/persistent-data/dm-transaction-manager.c
drivers/md/persistent-data/dm-transaction-manager.h

index 20cc36b01b77895625adbe82a14923148d688edb..4a6c83e5bc41ca5043681d2a61d324991d630447 100644 (file)
@@ -260,7 +260,9 @@ static int __superblock_all_zeroes(struct dm_block_manager *bm, bool *result)
                }
        }
 
-       return dm_bm_unlock(b);
+       dm_bm_unlock(b);
+
+       return 0;
 }
 
 static void __setup_mapping_info(struct dm_cache_metadata *cmd)
@@ -465,7 +467,9 @@ static int __open_metadata(struct dm_cache_metadata *cmd)
        dm_disk_bitset_init(cmd->tm, &cmd->discard_info);
        sb_flags = le32_to_cpu(disk_super->flags);
        cmd->clean_when_opened = test_bit(CLEAN_SHUTDOWN, &sb_flags);
-       return dm_bm_unlock(sblock);
+       dm_bm_unlock(sblock);
+
+       return 0;
 
 bad:
        dm_bm_unlock(sblock);
index 0119ebfb3d49b4652bd71548af42037aac22953a..665bf32856182e73bb390e3446b8280982bae020 100644 (file)
@@ -343,7 +343,9 @@ static int superblock_all_zeroes(struct dm_block_manager *bm, bool *result)
                }
        }
 
-       return dm_bm_unlock(b);
+       dm_bm_unlock(b);
+
+       return 0;
 }
 
 /*----------------------------------------------------------------*/
@@ -582,7 +584,9 @@ static int open_metadata(struct era_metadata *md)
        md->metadata_snap = le64_to_cpu(disk->metadata_snap);
        md->archived_writesets = true;
 
-       return dm_bm_unlock(sblock);
+       dm_bm_unlock(sblock);
+
+       return 0;
 
 bad:
        dm_bm_unlock(sblock);
@@ -1046,12 +1050,7 @@ static int metadata_take_snap(struct era_metadata *md)
 
        md->metadata_snap = dm_block_location(clone);
 
-       r = dm_tm_unlock(md->tm, clone);
-       if (r) {
-               DMERR("%s: couldn't unlock clone", __func__);
-               md->metadata_snap = SUPERBLOCK_LOCATION;
-               return r;
-       }
+       dm_tm_unlock(md->tm, clone);
 
        return 0;
 }
index 6ba47cfb1443748ccf092819a6a5ef160bb856fd..1fa45695b68a4eb6ed3db388d30f6e88f06fee21 100644 (file)
@@ -396,7 +396,9 @@ static int __superblock_all_zeroes(struct dm_block_manager *bm, int *result)
                }
        }
 
-       return dm_bm_unlock(b);
+       dm_bm_unlock(b);
+
+       return 0;
 }
 
 static void __setup_btree_details(struct dm_pool_metadata *pmd)
@@ -650,7 +652,9 @@ static int __open_metadata(struct dm_pool_metadata *pmd)
        }
 
        __setup_btree_details(pmd);
-       return dm_bm_unlock(sblock);
+       dm_bm_unlock(sblock);
+
+       return 0;
 
 bad_cleanup_data_sm:
        dm_sm_destroy(pmd->data_sm);
@@ -1297,7 +1301,9 @@ static int __release_metadata_snap(struct dm_pool_metadata *pmd)
        dm_btree_del(&pmd->details_info, le64_to_cpu(disk_super->device_details_root));
        dm_sm_dec_block(pmd->metadata_sm, held_root);
 
-       return dm_tm_unlock(pmd->tm, copy);
+       dm_tm_unlock(pmd->tm, copy);
+
+       return 0;
 }
 
 int dm_pool_release_metadata_snap(struct dm_pool_metadata *pmd)
@@ -1327,7 +1333,9 @@ static int __get_metadata_snap(struct dm_pool_metadata *pmd,
        disk_super = dm_block_data(sblock);
        *result = le64_to_cpu(disk_super->held_root);
 
-       return dm_bm_unlock(sblock);
+       dm_bm_unlock(sblock);
+
+       return 0;
 }
 
 int dm_pool_get_metadata_snap(struct dm_pool_metadata *pmd,
index e64b61ad0ef34fc42fdf8b8066bbe71965108493..431a03067d646e43a6fe8c5d99871321c5dba91e 100644 (file)
@@ -233,9 +233,9 @@ static int get_ablock(struct dm_array_info *info, dm_block_t b,
 /*
  * Unlocks an array block.
  */
-static int unlock_ablock(struct dm_array_info *info, struct dm_block *block)
+static void unlock_ablock(struct dm_array_info *info, struct dm_block *block)
 {
-       return dm_tm_unlock(info->btree_info.tm, block);
+       dm_tm_unlock(info->btree_info.tm, block);
 }
 
 /*----------------------------------------------------------------*/
index 88dbe7b97c2c3ca7ace7cbee4b75f80496a0c62a..f2393ba838eb57cfa977228da492814d7dda42af 100644 (file)
@@ -578,7 +578,7 @@ int dm_bm_write_lock_zero(struct dm_block_manager *bm,
 }
 EXPORT_SYMBOL_GPL(dm_bm_write_lock_zero);
 
-int dm_bm_unlock(struct dm_block *b)
+void dm_bm_unlock(struct dm_block *b)
 {
        struct buffer_aux *aux;
        aux = dm_bufio_get_aux_data(to_buffer(b));
@@ -590,8 +590,6 @@ int dm_bm_unlock(struct dm_block *b)
                bl_up_read(&aux->lock);
 
        dm_bufio_release(to_buffer(b));
-
-       return 0;
 }
 EXPORT_SYMBOL_GPL(dm_bm_unlock);
 
index 84330f59886dbc272e894e044e2236296a5119f7..3627d1b7667ad50a935faba440fc3fb62e81876c 100644 (file)
@@ -94,7 +94,7 @@ int dm_bm_write_lock_zero(struct dm_block_manager *bm, dm_block_t b,
                          struct dm_block_validator *v,
                          struct dm_block **result);
 
-int dm_bm_unlock(struct dm_block *b);
+void dm_bm_unlock(struct dm_block *b);
 
 /*
  * It's a common idiom to have a superblock that should be committed last.
index 8731b6ea026bd9b8cfbe2a21bbc06366e509181c..a240990a7f3339047e45a4b45087a8a3d0ca30fe 100644 (file)
@@ -52,7 +52,7 @@ void inc_children(struct dm_transaction_manager *tm, struct btree_node *n,
                  struct dm_btree_value_type *vt);
 
 int new_block(struct dm_btree_info *info, struct dm_block **result);
-int unlock_block(struct dm_btree_info *info, struct dm_block *b);
+void unlock_block(struct dm_btree_info *info, struct dm_block *b);
 
 /*
  * Spines keep track of the rolling locks.  There are 2 variants, read-only
index 421a36c593e3e7dedef785a5f78c12914c13d8b3..4d7617fc6dbbfa6251937c29af6c6f8f80032175 100644 (file)
@@ -165,9 +165,9 @@ static int init_child(struct dm_btree_info *info, struct dm_btree_value_type *vt
        return 0;
 }
 
-static int exit_child(struct dm_btree_info *info, struct child *c)
+static void exit_child(struct dm_btree_info *info, struct child *c)
 {
-       return dm_tm_unlock(info->tm, c->block);
+       dm_tm_unlock(info->tm, c->block);
 }
 
 static void shift(struct btree_node *left, struct btree_node *right, int count)
@@ -249,13 +249,10 @@ static int rebalance2(struct shadow_spine *s, struct dm_btree_info *info,
 
        __rebalance2(info, parent, &left, &right);
 
-       r = exit_child(info, &left);
-       if (r) {
-               exit_child(info, &right);
-               return r;
-       }
+       exit_child(info, &left);
+       exit_child(info, &right);
 
-       return exit_child(info, &right);
+       return 0;
 }
 
 /*
@@ -389,22 +386,9 @@ static int rebalance3(struct shadow_spine *s, struct dm_btree_info *info,
 
        __rebalance3(info, parent, &left, &center, &right);
 
-       r = exit_child(info, &left);
-       if (r) {
-               exit_child(info, &center);
-               exit_child(info, &right);
-               return r;
-       }
-
-       r = exit_child(info, &center);
-       if (r) {
-               exit_child(info, &right);
-               return r;
-       }
-
-       r = exit_child(info, &right);
-       if (r)
-               return r;
+       exit_child(info, &left);
+       exit_child(info, &center);
+       exit_child(info, &right);
 
        return 0;
 }
@@ -428,9 +412,7 @@ static int rebalance_children(struct shadow_spine *s,
 
                memcpy(n, dm_block_data(child),
                       dm_bm_block_size(dm_tm_get_bm(info->tm)));
-               r = dm_tm_unlock(info->tm, child);
-               if (r)
-                       return r;
+               dm_tm_unlock(info->tm, child);
 
                dm_tm_dec(info->tm, dm_block_location(child));
                return 0;
index 0dee514ba4c5f9e8d34d16e9d239ef333395c7d4..b27b8091a1ca4f649240e074a7bee564285dd30d 100644 (file)
@@ -117,9 +117,9 @@ int new_block(struct dm_btree_info *info, struct dm_block **result)
        return dm_tm_new_block(info->tm, &btree_node_validator, result);
 }
 
-int unlock_block(struct dm_btree_info *info, struct dm_block *b)
+void unlock_block(struct dm_btree_info *info, struct dm_block *b)
 {
-       return dm_tm_unlock(info->tm, b);
+       dm_tm_unlock(info->tm, b);
 }
 
 /*----------------------------------------------------------------*/
@@ -137,9 +137,7 @@ int exit_ro_spine(struct ro_spine *s)
        int r = 0, i;
 
        for (i = 0; i < s->count; i++) {
-               int r2 = unlock_block(s->info, s->nodes[i]);
-               if (r2 < 0)
-                       r = r2;
+               unlock_block(s->info, s->nodes[i]);
        }
 
        return r;
@@ -150,9 +148,7 @@ int ro_step(struct ro_spine *s, dm_block_t new_child)
        int r;
 
        if (s->count == 2) {
-               r = unlock_block(s->info, s->nodes[0]);
-               if (r < 0)
-                       return r;
+               unlock_block(s->info, s->nodes[0]);
                s->nodes[0] = s->nodes[1];
                s->count--;
        }
@@ -194,9 +190,7 @@ int exit_shadow_spine(struct shadow_spine *s)
        int r = 0, i;
 
        for (i = 0; i < s->count; i++) {
-               int r2 = unlock_block(s->info, s->nodes[i]);
-               if (r2 < 0)
-                       r = r2;
+               unlock_block(s->info, s->nodes[i]);
        }
 
        return r;
@@ -208,9 +202,7 @@ int shadow_step(struct shadow_spine *s, dm_block_t b,
        int r;
 
        if (s->count == 2) {
-               r = unlock_block(s->info, s->nodes[0]);
-               if (r < 0)
-                       return r;
+               unlock_block(s->info, s->nodes[0]);
                s->nodes[0] = s->nodes[1];
                s->count--;
        }
index b6cec258cc2138497b3c8875fc4defdb7523701f..25a62b73cfc0d1641b858c7b56278332d6554607 100644 (file)
@@ -141,7 +141,9 @@ int dm_btree_empty(struct dm_btree_info *info, dm_block_t *root)
        n->header.value_size = cpu_to_le32(info->value_type.size);
 
        *root = dm_block_location(b);
-       return unlock_block(info, b);
+       unlock_block(info, b);
+
+       return 0;
 }
 EXPORT_SYMBOL_GPL(dm_btree_empty);
 
index aacbe70c2c2eb64449bbb9a87264326258f49ac8..306d2e4502c480aef245224a5235c37dc8b94d0a 100644 (file)
@@ -259,9 +259,7 @@ int sm_ll_extend(struct ll_disk *ll, dm_block_t extra_blocks)
 
                idx.blocknr = cpu_to_le64(dm_block_location(b));
 
-               r = dm_tm_unlock(ll->tm, b);
-               if (r < 0)
-                       return r;
+               dm_tm_unlock(ll->tm, b);
 
                idx.nr_free = cpu_to_le32(ll->entries_per_block);
                idx.none_free_before = 0;
@@ -293,7 +291,9 @@ int sm_ll_lookup_bitmap(struct ll_disk *ll, dm_block_t b, uint32_t *result)
 
        *result = sm_lookup_bitmap(dm_bitmap_data(blk), b);
 
-       return dm_tm_unlock(ll->tm, blk);
+       dm_tm_unlock(ll->tm, blk);
+
+       return 0;
 }
 
 static int sm_ll_lookup_big_ref_count(struct ll_disk *ll, dm_block_t b,
@@ -373,9 +373,7 @@ int sm_ll_find_free_block(struct ll_disk *ll, dm_block_t begin,
                        return r;
                }
 
-               r = dm_tm_unlock(ll->tm, blk);
-               if (r < 0)
-                       return r;
+               dm_tm_unlock(ll->tm, blk);
 
                *result = i * ll->entries_per_block + (dm_block_t) position;
                return 0;
@@ -429,9 +427,7 @@ static int sm_ll_mutate(struct ll_disk *ll, dm_block_t b,
        if (ref_count <= 2) {
                sm_set_bitmap(bm_le, bit, ref_count);
 
-               r = dm_tm_unlock(ll->tm, nb);
-               if (r < 0)
-                       return r;
+               dm_tm_unlock(ll->tm, nb);
 
                if (old > 2) {
                        r = dm_btree_remove(&ll->ref_count_info,
@@ -445,9 +441,7 @@ static int sm_ll_mutate(struct ll_disk *ll, dm_block_t b,
                __le32 le_rc = cpu_to_le32(ref_count);
 
                sm_set_bitmap(bm_le, bit, 3);
-               r = dm_tm_unlock(ll->tm, nb);
-               if (r < 0)
-                       return r;
+               dm_tm_unlock(ll->tm, nb);
 
                __dm_bless_for_disk(&le_rc);
                r = dm_btree_insert(&ll->ref_count_info, ll->ref_count_root,
@@ -556,7 +550,9 @@ static int metadata_ll_init_index(struct ll_disk *ll)
        memcpy(dm_block_data(b), &ll->mi_le, sizeof(ll->mi_le));
        ll->bitmap_root = dm_block_location(b);
 
-       return dm_tm_unlock(ll->tm, b);
+       dm_tm_unlock(ll->tm, b);
+
+       return 0;
 }
 
 static int metadata_ll_open(struct ll_disk *ll)
@@ -570,7 +566,9 @@ static int metadata_ll_open(struct ll_disk *ll)
                return r;
 
        memcpy(&ll->mi_le, dm_block_data(block), sizeof(ll->mi_le));
-       return dm_tm_unlock(ll->tm, block);
+       dm_tm_unlock(ll->tm, block);
+
+       return 0;
 }
 
 static dm_block_t metadata_ll_max_entries(struct ll_disk *ll)
@@ -590,7 +588,9 @@ static int metadata_ll_commit(struct ll_disk *ll)
        memcpy(dm_block_data(b), &ll->mi_le, sizeof(ll->mi_le));
        ll->bitmap_root = dm_block_location(b);
 
-       return dm_tm_unlock(ll->tm, b);
+       dm_tm_unlock(ll->tm, b);
+
+       return 0;
 }
 
 int sm_ll_new_metadata(struct ll_disk *ll, struct dm_transaction_manager *tm)
index 9cb797d800cf8de36479130708a4a58e12e64a23..abe2c5dd0993b6083f2e9cebe54ebb1d8de541ac 100644 (file)
@@ -342,9 +342,9 @@ int dm_tm_read_lock(struct dm_transaction_manager *tm, dm_block_t b,
 }
 EXPORT_SYMBOL_GPL(dm_tm_read_lock);
 
-int dm_tm_unlock(struct dm_transaction_manager *tm, struct dm_block *b)
+void dm_tm_unlock(struct dm_transaction_manager *tm, struct dm_block *b)
 {
-       return dm_bm_unlock(b);
+       dm_bm_unlock(b);
 }
 EXPORT_SYMBOL_GPL(dm_tm_unlock);
 
index 2e0d4d66fb1bafe15d3d70e8d41635320cc36308..f3a18be68f305a58df3a0330409ce0e403c8499b 100644 (file)
@@ -94,7 +94,7 @@ int dm_tm_read_lock(struct dm_transaction_manager *tm, dm_block_t b,
                    struct dm_block_validator *v,
                    struct dm_block **result);
 
-int dm_tm_unlock(struct dm_transaction_manager *tm, struct dm_block *b);
+void dm_tm_unlock(struct dm_transaction_manager *tm, struct dm_block *b);
 
 /*
  * Functions for altering the reference count of a block directly.