summaryrefslogtreecommitdiff
path: root/drivers/md/md.c
diff options
context:
space:
mode:
authorXiao Ni <xni@redhat.com>2021-02-04 10:50:43 +0300
committerSong Liu <songliubraving@fb.com>2021-03-25 02:29:06 +0300
commitcf78408f937a67f59f5e90ee8e6cadeed7c128a8 (patch)
treee6c6fccc278c744c2f0763ff073088e7ebda7daa /drivers/md/md.c
parent14d97622448acbea0348be62f62e25d9a361e16b (diff)
downloadlinux-cf78408f937a67f59f5e90ee8e6cadeed7c128a8.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> Tested-by: Adrian Huang <ahuang12@lenovo.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.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 21da0c48f6c2..498a1c2e95e9 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -8575,6 +8575,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(discard_bio,
+ disk_devt(mddev->gendisk),
+ bio->bi_iter.bi_sector);
+ submit_bio_noacct(discard_bio);
+}
+EXPORT_SYMBOL_GPL(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