diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index 3cbefa8da51e..1f97d6612648 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c @@ -630,11 +630,10 @@ static bool block_bitmap_op(struct dm_integrity_c *ic, struct page_list *bitmap, end_bit %= PAGE_SIZE * 8; repeat: - if (page < end_page) { + if (page < end_page) this_end_bit = PAGE_SIZE * 8 - 1; - } else { + else this_end_bit = end_bit; - } data = lowmem_page_address(bitmap[page].page); @@ -1251,13 +1250,12 @@ static bool add_new_range(struct dm_integrity_c *ic, struct dm_integrity_range * struct dm_integrity_range *range = container_of(*n, struct dm_integrity_range, node); parent = *n; - if (new_range->logical_sector + new_range->n_sectors <= range->logical_sector) { + if (new_range->logical_sector + new_range->n_sectors <= range->logical_sector) n = &range->node.rb_left; - } else if (new_range->logical_sector >= range->logical_sector + range->n_sectors) { + else if (new_range->logical_sector >= range->logical_sector + range->n_sectors) n = &range->node.rb_right; - } else { + else return false; - } } rb_link_node(&new_range->node, parent, n); @@ -1364,15 +1362,14 @@ static unsigned int find_journal_node(struct dm_integrity_c *ic, sector_t sector while (n) { struct journal_node *j = container_of(n, struct journal_node, node); - if (sector == j->sector) { + if (sector == j->sector) found = j - ic->journal_tree; - } + if (sector < j->sector) { *next_sector = j->sector; n = j->node.rb_left; - } else { + } else n = j->node.rb_right; - } } return found; @@ -1501,9 +1498,8 @@ thorough_test: *metadata_offset = 0; } - if (unlikely(!is_power_of_2(ic->tag_size))) { + if (unlikely(!is_power_of_2(ic->tag_size))) hash_offset = (hash_offset + to_copy) % ic->tag_size; - } total_size -= to_copy; } while (unlikely(total_size)); @@ -2104,14 +2100,12 @@ retry_kmap: smp_mb(); if (unlikely(waitqueue_active(&ic->copy_to_journal_wait))) wake_up(&ic->copy_to_journal_wait); - if (READ_ONCE(ic->free_sectors) <= ic->free_sectors_threshold) { + if (READ_ONCE(ic->free_sectors) <= ic->free_sectors_threshold) queue_work(ic->commit_wq, &ic->commit_work); - } else { + else schedule_autocommit(ic); - } - } else { + } else remove_range(ic, &dio->range); - } if (unlikely(bio->bi_iter.bi_size)) { sector_t area, offset; @@ -2569,9 +2563,8 @@ static void do_journal_write(struct dm_integrity_c *ic, unsigned int write_start mempool_free(io, &ic->journal_io_mempool); goto skip_io; } - for (l = j; l < k; l++) { + for (l = j; l < k; l++) remove_journal_node(ic, §ion_node[l]); - } } spin_unlock_irq(&ic->endio_wait.lock); @@ -2598,9 +2591,8 @@ static void do_journal_write(struct dm_integrity_c *ic, unsigned int write_start journal_entry_set_unused(je2); r = dm_integrity_rw_tag(ic, journal_entry_tag(ic, je2), &metadata_block, &metadata_offset, ic->tag_size, TAG_WRITE); - if (unlikely(r)) { + if (unlikely(r)) dm_integrity_io_error(ic, "reading tags", r); - } } atomic_inc(&comp.in_flight); @@ -2711,9 +2703,9 @@ next_chunk: n_sectors = range.n_sectors; if (ic->mode == 'B') { - if (block_bitmap_op(ic, ic->recalc_bitmap, logical_sector, n_sectors, BITMAP_OP_TEST_ALL_CLEAR)) { + if (block_bitmap_op(ic, ic->recalc_bitmap, logical_sector, n_sectors, BITMAP_OP_TEST_ALL_CLEAR)) goto advance_and_next; - } + while (block_bitmap_op(ic, ic->recalc_bitmap, logical_sector, ic->sectors_per_block, BITMAP_OP_TEST_ALL_CLEAR)) { logical_sector += ic->sectors_per_block; @@ -2732,9 +2724,9 @@ next_chunk: if (unlikely(++super_counter == RECALC_WRITE_SUPER)) { recalc_write_super(ic); - if (ic->mode == 'B') { + if (ic->mode == 'B') queue_delayed_work(ic->commit_wq, &ic->bitmap_flush_work, ic->bitmap_flush_interval); - } + super_counter = 0; } @@ -4417,9 +4409,9 @@ try_smaller_buffer: log2_blocks_per_bitmap_bit = log2_sectors_per_bitmap_bit - ic->sb->log2_sectors_per_block; ic->log2_blocks_per_bitmap_bit = log2_blocks_per_bitmap_bit; - if (should_write_sb) { + if (should_write_sb) ic->sb->log2_blocks_per_bitmap_bit = log2_blocks_per_bitmap_bit; - } + n_bitmap_bits = ((ic->provided_data_sectors >> ic->sb->log2_sectors_per_block) + (((sector_t)1 << log2_blocks_per_bitmap_bit) - 1)) >> log2_blocks_per_bitmap_bit; ic->n_bitmap_blocks = DIV_ROUND_UP(n_bitmap_bits, BITMAP_BLOCK_SIZE * 8); diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c index 6de2104181b6..128045de20f0 100644 --- a/drivers/md/dm-stats.c +++ b/drivers/md/dm-stats.c @@ -601,12 +601,10 @@ static void dm_stat_for_entry(struct dm_stat *s, size_t entry, while (lo + 1 < hi) { unsigned int mid = (lo + hi) / 2; - if (s->histogram_boundaries[mid - 1] > duration) { + if (s->histogram_boundaries[mid - 1] > duration) hi = mid; - } else { + else lo = mid; - } - } p->histogram[lo]++; } @@ -900,9 +898,8 @@ static int dm_stats_print(struct dm_stats *stats, int id, if (s->n_histogram_entries) { unsigned int i; - for (i = 0; i < s->n_histogram_entries + 1; i++) { + for (i = 0; i < s->n_histogram_entries + 1; i++) DMEMIT("%s%llu", !i ? " " : ":", shared->tmp.histogram[i]); - } } DMEMIT("\n"); diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c index 5ec4be4b978e..e71135af334a 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c @@ -369,14 +369,12 @@ static void stripe_status(struct dm_target *ti, status_type_t type, switch (type) { case STATUSTYPE_INFO: DMEMIT("%d ", sc->stripes); - for (i = 0; i < sc->stripes; i++) { + for (i = 0; i < sc->stripes; i++) DMEMIT("%s ", sc->stripe[i].dev->name); - } + DMEMIT("1 "); - for (i = 0; i < sc->stripes; i++) { - DMEMIT("%c", atomic_read(&(sc->stripe[i].error_count)) ? - 'D' : 'A'); - } + for (i = 0; i < sc->stripes; i++) + DMEMIT("%c", atomic_read(&(sc->stripe[i].error_count)) ? 'D' : 'A'); break; case STATUSTYPE_TABLE: diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c index 7f9b25ddc89c..98a75a97aa86 100644 --- a/drivers/md/dm-thin-metadata.c +++ b/drivers/md/dm-thin-metadata.c @@ -1536,9 +1536,9 @@ static int __find_block(struct dm_thin_device *td, dm_block_t block, dm_block_t keys[2] = { td->id, block }; struct dm_btree_info *info; - if (can_issue_io) { + if (can_issue_io) info = &pmd->info; - } else + else info = &pmd->nb_info; r = dm_btree_lookup(info, pmd->root, keys, &value); diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index f4288d70276e..2dfa612fa1ef 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -1984,9 +1984,8 @@ restart: goto restart; } - if (wc->overwrote_committed) { + if (wc->overwrote_committed) writecache_wait_for_ios(wc, WRITE); - } n_walked = 0; INIT_LIST_HEAD(&skipped); @@ -2015,9 +2014,9 @@ restart: } else e = container_of(wc->lru.prev, struct wc_entry, lru); BUG_ON(e->write_in_progress); - if (unlikely(!writecache_entry_is_committed(wc, e))) { + if (unlikely(!writecache_entry_is_committed(wc, e))) writecache_flush(wc); - } + node = rb_prev(&e->rb_node); if (node) { f = container_of(node, struct wc_entry, rb_node); diff --git a/drivers/md/persistent-data/dm-btree-spine.c b/drivers/md/persistent-data/dm-btree-spine.c index a04784bab21e..27f379c13809 100644 --- a/drivers/md/persistent-data/dm-btree-spine.c +++ b/drivers/md/persistent-data/dm-btree-spine.c @@ -133,9 +133,8 @@ void exit_ro_spine(struct ro_spine *s) { int i; - for (i = 0; i < s->count; i++) { + for (i = 0; i < s->count; i++) unlock_block(s->info, s->nodes[i]); - } } int ro_step(struct ro_spine *s, dm_block_t new_child) @@ -184,9 +183,8 @@ void exit_shadow_spine(struct shadow_spine *s) { int i; - for (i = 0; i < s->count; i++) { + for (i = 0; i < s->count; i++) unlock_block(s->info, s->nodes[i]); - } } int shadow_step(struct shadow_spine *s, dm_block_t b, diff --git a/drivers/md/persistent-data/dm-space-map-disk.c b/drivers/md/persistent-data/dm-space-map-disk.c index 4494fa503d47..f4241f54e20e 100644 --- a/drivers/md/persistent-data/dm-space-map-disk.c +++ b/drivers/md/persistent-data/dm-space-map-disk.c @@ -95,9 +95,8 @@ static int sm_disk_set_count(struct dm_space_map *sm, dm_block_t b, struct sm_disk *smd = container_of(sm, struct sm_disk, sm); r = sm_ll_insert(&smd->ll, b, count, &nr_allocations); - if (!r) { + if (!r) smd->nr_allocated_this_transaction += nr_allocations; - } return r; } @@ -138,22 +137,20 @@ static int sm_disk_new_block(struct dm_space_map *sm, dm_block_t *b) * Any block we allocate has to be free in both the old and current ll. */ r = sm_ll_find_common_free_block(&smd->old_ll, &smd->ll, smd->begin, smd->ll.nr_blocks, b); - if (r == -ENOSPC) { + if (r == -ENOSPC) /* * There's no free block between smd->begin and the end of the metadata device. * We search before smd->begin in case something has been freed. */ r = sm_ll_find_common_free_block(&smd->old_ll, &smd->ll, 0, smd->begin, b); - } if (r) return r; smd->begin = *b + 1; r = sm_ll_inc(&smd->ll, *b, *b + 1, &nr_allocations); - if (!r) { + if (!r) smd->nr_allocated_this_transaction += nr_allocations; - } return r; }