Skip to content

Commit 41743c1

Browse files
committed
md/raid1: skip data copy for behind io for discard request
discard request doesn't have data attached, so it's meaningless to allocate memory and copy from original bio for behind IO. And the copy is bogus because bio_copy_data_partial can't handle discard request. We don't support writesame/writezeros request so far. Reviewed-by: Ming Lei <tom.leiming@gmail.com> Signed-off-by: Shaohua Li <shli@fb.com>
1 parent f459587 commit 41743c1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/md/raid1.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,10 @@ static struct bio *alloc_behind_master_bio(struct r1bio *r1_bio,
11021102
if (!behind_bio)
11031103
goto fail;
11041104

1105+
/* discard op, we don't support writezero/writesame yet */
1106+
if (!bio_has_data(bio))
1107+
goto skip_copy;
1108+
11051109
while (i < vcnt && size) {
11061110
struct page *page;
11071111
int len = min_t(int, PAGE_SIZE, size);
@@ -1118,7 +1122,7 @@ static struct bio *alloc_behind_master_bio(struct r1bio *r1_bio,
11181122

11191123
bio_copy_data_partial(behind_bio, bio, offset,
11201124
behind_bio->bi_iter.bi_size);
1121-
1125+
skip_copy:
11221126
r1_bio->behind_master_bio = behind_bio;;
11231127
set_bit(R1BIO_BehindIO, &r1_bio->state);
11241128

0 commit comments

Comments
 (0)