diff options
author | Xiao Ni <xni@redhat.com> | 2020-08-25 08:42:59 +0300 |
---|---|---|
committer | Song Liu <songliubraving@fb.com> | 2020-09-25 02:44:45 +0300 |
commit | 2628089b74d5a64bd0bcb5d247a18f78d7b6f4d0 (patch) | |
tree | 47ba9f41e75f0dfaa6fda2a52e37d491b54b00a8 /drivers/md/md.c | |
parent | e287308b8388590ad70e8e88d1cc70a4643bacd7 (diff) | |
download | linux-2628089b74d5a64bd0bcb5d247a18f78d7b6f4d0.tar.xz |
md: add md_submit_discard_bio() for submitting discard bio
Move these logic from raid0.c to md.c, so that we can also use it in
raid10.c.
Reviewed-by: Coly Li <colyli@suse.de>
Reviewed-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 64bc22d2b606..dfff4bb2bb20 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -8583,6 +8583,26 @@ void md_write_end(struct mddev *mddev) EXPORT_SYMBOL(md_write_end); +/* This is used by raid0 and raid10 */ +void md_submit_discard_bio(struct mddev *mddev, struct md_rdev *rdev, + struct bio *bio, sector_t start, sector_t size) +{ + struct bio *discard_bio = NULL; + + if (__blkdev_issue_discard(rdev->bdev, start, size, + GFP_NOIO, 0, &discard_bio) || !discard_bio) + return; + + bio_chain(discard_bio, bio); + bio_clone_blkg_association(discard_bio, bio); + if (mddev->gendisk) + trace_block_bio_remap(bdev_get_queue(rdev->bdev), + discard_bio, disk_devt(mddev->gendisk), + bio->bi_iter.bi_sector); + submit_bio_noacct(discard_bio); +} +EXPORT_SYMBOL(md_submit_discard_bio); + /* md_allow_write(mddev) * Calling this ensures that the array is marked 'active' so that writes * may proceed without blocking. It is important to call this before |