Skip to content

Commit c17af96

Browse files
committed
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: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent b25b0b8 commit c17af96

1 file changed

Lines changed: 15 additions & 22 deletions

File tree

fs/btrfs/raid56.c

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,22 +1196,19 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
11961196
int nr_data = rbio->nr_data;
11971197
int stripe;
11981198
int pagenr;
1199-
int p_stripe = -1;
1200-
int q_stripe = -1;
1199+
bool has_qstripe;
12011200
struct bio_list bio_list;
12021201
struct bio *bio;
12031202
int ret;
12041203

12051204
bio_list_init(&bio_list);
12061205

1207-
if (rbio->real_stripes - rbio->nr_data == 1) {
1208-
p_stripe = rbio->real_stripes - 1;
1209-
} else if (rbio->real_stripes - rbio->nr_data == 2) {
1210-
p_stripe = rbio->real_stripes - 2;
1211-
q_stripe = rbio->real_stripes - 1;
1212-
} else {
1206+
if (rbio->real_stripes - rbio->nr_data == 1)
1207+
has_qstripe = false;
1208+
else if (rbio->real_stripes - rbio->nr_data == 2)
1209+
has_qstripe = true;
1210+
else
12131211
BUG();
1214-
}
12151212

12161213
/* at this point we either have a full stripe,
12171214
* or we've read the full stripe from the drive.
@@ -1255,7 +1252,7 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
12551252
SetPageUptodate(p);
12561253
pointers[stripe++] = kmap(p);
12571254

1258-
if (q_stripe != -1) {
1255+
if (has_qstripe) {
12591256

12601257
/*
12611258
* raid6, add the qstripe and call the
@@ -2353,8 +2350,7 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
23532350
int nr_data = rbio->nr_data;
23542351
int stripe;
23552352
int pagenr;
2356-
int p_stripe = -1;
2357-
int q_stripe = -1;
2353+
bool has_qstripe;
23582354
struct page *p_page = NULL;
23592355
struct page *q_page = NULL;
23602356
struct bio_list bio_list;
@@ -2364,14 +2360,12 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
23642360

23652361
bio_list_init(&bio_list);
23662362

2367-
if (rbio->real_stripes - rbio->nr_data == 1) {
2368-
p_stripe = rbio->real_stripes - 1;
2369-
} else if (rbio->real_stripes - rbio->nr_data == 2) {
2370-
p_stripe = rbio->real_stripes - 2;
2371-
q_stripe = rbio->real_stripes - 1;
2372-
} else {
2363+
if (rbio->real_stripes - rbio->nr_data == 1)
2364+
has_qstripe = false;
2365+
else if (rbio->real_stripes - rbio->nr_data == 2)
2366+
has_qstripe = true;
2367+
else
23732368
BUG();
2374-
}
23752369

23762370
if (bbio->num_tgtdevs && bbio->tgtdev_map[rbio->scrubp]) {
23772371
is_replace = 1;
@@ -2393,7 +2387,7 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
23932387
goto cleanup;
23942388
SetPageUptodate(p_page);
23952389

2396-
if (q_stripe != -1) {
2390+
if (has_qstripe) {
23972391
q_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
23982392
if (!q_page) {
23992393
__free_page(p_page);
@@ -2416,8 +2410,7 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
24162410
/* then add the parity stripe */
24172411
pointers[stripe++] = kmap(p_page);
24182412

2419-
if (q_stripe != -1) {
2420-
2413+
if (has_qstripe) {
24212414
/*
24222415
* raid6, add the qstripe and call the
24232416
* library function to fill in our p/q

0 commit comments

Comments
 (0)