提交 c17af965 编写于 作者: D David Sterba

btrfs: raid56: simplify tracking of Q stripe presence

There are temporary variables tracking the index of P and Q stripes, but
none of them is really used as such, merely for determining if the Q
stripe is present. This leads to compiler warnings with
-Wunused-but-set-variable and has been reported several times.

fs/btrfs/raid56.c: In function ‘finish_rmw’:
fs/btrfs/raid56.c:1199:6: warning: variable ‘p_stripe’ set but not used [-Wunused-but-set-variable]
 1199 |  int p_stripe = -1;
      |      ^~~~~~~~
fs/btrfs/raid56.c: In function ‘finish_parity_scrub’:
fs/btrfs/raid56.c:2356:6: warning: variable ‘p_stripe’ set but not used [-Wunused-but-set-variable]
 2356 |  int p_stripe = -1;
      |      ^~~~~~~~

Replace the two variables with one that has a clear meaning and also get
rid of the warnings. The logic that verifies that there are only 2
valid cases is unchanged.
Reviewed-by: NJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 b25b0b87
...@@ -1196,22 +1196,19 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio) ...@@ -1196,22 +1196,19 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
int nr_data = rbio->nr_data; int nr_data = rbio->nr_data;
int stripe; int stripe;
int pagenr; int pagenr;
int p_stripe = -1; bool has_qstripe;
int q_stripe = -1;
struct bio_list bio_list; struct bio_list bio_list;
struct bio *bio; struct bio *bio;
int ret; int ret;
bio_list_init(&bio_list); bio_list_init(&bio_list);
if (rbio->real_stripes - rbio->nr_data == 1) { if (rbio->real_stripes - rbio->nr_data == 1)
p_stripe = rbio->real_stripes - 1; has_qstripe = false;
} else if (rbio->real_stripes - rbio->nr_data == 2) { else if (rbio->real_stripes - rbio->nr_data == 2)
p_stripe = rbio->real_stripes - 2; has_qstripe = true;
q_stripe = rbio->real_stripes - 1; else
} else {
BUG(); BUG();
}
/* at this point we either have a full stripe, /* at this point we either have a full stripe,
* or we've read the full stripe from the drive. * or we've read the full stripe from the drive.
...@@ -1255,7 +1252,7 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio) ...@@ -1255,7 +1252,7 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
SetPageUptodate(p); SetPageUptodate(p);
pointers[stripe++] = kmap(p); pointers[stripe++] = kmap(p);
if (q_stripe != -1) { if (has_qstripe) {
/* /*
* raid6, add the qstripe and call the * raid6, add the qstripe and call the
...@@ -2353,8 +2350,7 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio, ...@@ -2353,8 +2350,7 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
int nr_data = rbio->nr_data; int nr_data = rbio->nr_data;
int stripe; int stripe;
int pagenr; int pagenr;
int p_stripe = -1; bool has_qstripe;
int q_stripe = -1;
struct page *p_page = NULL; struct page *p_page = NULL;
struct page *q_page = NULL; struct page *q_page = NULL;
struct bio_list bio_list; struct bio_list bio_list;
...@@ -2364,14 +2360,12 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio, ...@@ -2364,14 +2360,12 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
bio_list_init(&bio_list); bio_list_init(&bio_list);
if (rbio->real_stripes - rbio->nr_data == 1) { if (rbio->real_stripes - rbio->nr_data == 1)
p_stripe = rbio->real_stripes - 1; has_qstripe = false;
} else if (rbio->real_stripes - rbio->nr_data == 2) { else if (rbio->real_stripes - rbio->nr_data == 2)
p_stripe = rbio->real_stripes - 2; has_qstripe = true;
q_stripe = rbio->real_stripes - 1; else
} else {
BUG(); BUG();
}
if (bbio->num_tgtdevs && bbio->tgtdev_map[rbio->scrubp]) { if (bbio->num_tgtdevs && bbio->tgtdev_map[rbio->scrubp]) {
is_replace = 1; is_replace = 1;
...@@ -2393,7 +2387,7 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio, ...@@ -2393,7 +2387,7 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
goto cleanup; goto cleanup;
SetPageUptodate(p_page); SetPageUptodate(p_page);
if (q_stripe != -1) { if (has_qstripe) {
q_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM); q_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
if (!q_page) { if (!q_page) {
__free_page(p_page); __free_page(p_page);
...@@ -2416,8 +2410,7 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio, ...@@ -2416,8 +2410,7 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
/* then add the parity stripe */ /* then add the parity stripe */
pointers[stripe++] = kmap(p_page); pointers[stripe++] = kmap(p_page);
if (q_stripe != -1) { if (has_qstripe) {
/* /*
* raid6, add the qstripe and call the * raid6, add the qstripe and call the
* library function to fill in our p/q * library function to fill in our p/q
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册