Skip to content

Commit 81fa152

Browse files
ming1shligit
authored andcommitted
md: raid10: refactor code of read reshape's .bi_end_io
reshape read request is a bit special and requires one extra bio which isn't allocated from r10buf_pool. Refactor the .bi_end_io for read reshape, so that we can use raid10's resync page mangement approach easily in the following patches. Signed-off-by: Ming Lei <tom.leiming@gmail.com> Signed-off-by: Shaohua Li <shli@fb.com>
1 parent 841c131 commit 81fa152

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

drivers/md/raid10.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,17 +1889,9 @@ static int raid10_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
18891889
return err;
18901890
}
18911891

1892-
static void end_sync_read(struct bio *bio)
1892+
static void __end_sync_read(struct r10bio *r10_bio, struct bio *bio, int d)
18931893
{
1894-
struct r10bio *r10_bio = bio->bi_private;
18951894
struct r10conf *conf = r10_bio->mddev->private;
1896-
int d;
1897-
1898-
if (bio == r10_bio->master_bio) {
1899-
/* this is a reshape read */
1900-
d = r10_bio->read_slot; /* really the read dev */
1901-
} else
1902-
d = find_bio_disk(conf, r10_bio, bio, NULL, NULL);
19031895

19041896
if (!bio->bi_error)
19051897
set_bit(R10BIO_Uptodate, &r10_bio->state);
@@ -1923,6 +1915,22 @@ static void end_sync_read(struct bio *bio)
19231915
}
19241916
}
19251917

1918+
static void end_sync_read(struct bio *bio)
1919+
{
1920+
struct r10bio *r10_bio = bio->bi_private;
1921+
struct r10conf *conf = r10_bio->mddev->private;
1922+
int d = find_bio_disk(conf, r10_bio, bio, NULL, NULL);
1923+
1924+
__end_sync_read(r10_bio, bio, d);
1925+
}
1926+
1927+
static void end_reshape_read(struct bio *bio)
1928+
{
1929+
struct r10bio *r10_bio = bio->bi_private;
1930+
1931+
__end_sync_read(r10_bio, bio, r10_bio->read_slot);
1932+
}
1933+
19261934
static void end_sync_request(struct r10bio *r10_bio)
19271935
{
19281936
struct mddev *mddev = r10_bio->mddev;
@@ -4438,7 +4446,7 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr,
44384446
read_bio->bi_iter.bi_sector = (r10_bio->devs[r10_bio->read_slot].addr
44394447
+ rdev->data_offset);
44404448
read_bio->bi_private = r10_bio;
4441-
read_bio->bi_end_io = end_sync_read;
4449+
read_bio->bi_end_io = end_reshape_read;
44424450
bio_set_op_attrs(read_bio, REQ_OP_READ, 0);
44434451
read_bio->bi_flags &= (~0UL << BIO_RESET_BITS);
44444452
read_bio->bi_error = 0;

0 commit comments

Comments
 (0)