From: Xiao Ni <xni@redhat.com>
To: song@kernel.org, linux-raid@vger.kernel.org
Cc: colyli@suse.de, guoqing.jiang@cloud.ionos.com, heinzm@redhat.com,
ncroxon@redhat.com
Subject: [md PATCH V3 1/4] Move codes related with submitting discard bio into one function
Date: Thu, 13 Aug 2020 14:44:44 +0800 [thread overview]
Message-ID: <1597301087-6565-2-git-send-email-xni@redhat.com> (raw)
In-Reply-To: <1597301087-6565-1-git-send-email-xni@redhat.com>
These codes can be used in raid10. So we can move these codes into
md.c. raid0 and raid10 can share these codes.
Reviewed-by: Coly Li <colyli@suse.de>
Reviewed-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
Signed-off-by: Xiao Ni <xni@redhat.com>
---
drivers/md/md.c | 23 +++++++++++++++++++++++
drivers/md/md.h | 3 +++
drivers/md/raid0.c | 15 ++-------------
3 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 9c69084..e70f19c 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -8622,6 +8622,29 @@ 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 dev_start, sector_t dev_end)
+{
+ struct bio *discard_bio = NULL;
+
+ if (__blkdev_issue_discard(rdev->bdev,
+ dev_start + rdev->data_offset,
+ dev_end - dev_start, 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
diff --git a/drivers/md/md.h b/drivers/md/md.h
index 1e172b3..64c1a18 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -716,6 +716,9 @@ extern void md_write_end(struct mddev *mddev);
extern void md_done_sync(struct mddev *mddev, int blocks, int ok);
extern void md_error(struct mddev *mddev, struct md_rdev *rdev);
extern void md_finish_reshape(struct mddev *mddev);
+extern void md_submit_discard_bio(struct mddev *mddev, struct md_rdev *rdev,
+ struct bio *bio,
+ sector_t dev_start, sector_t dev_end);
extern int mddev_congested(struct mddev *mddev, int bits);
extern bool __must_check md_flush_request(struct mddev *mddev, struct bio *bio);
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index e9e91c8..e37fe8a 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -525,7 +525,6 @@ static void raid0_handle_discard(struct mddev *mddev, struct bio *bio)
for (disk = 0; disk < zone->nb_dev; disk++) {
sector_t dev_start, dev_end;
- struct bio *discard_bio = NULL;
struct md_rdev *rdev;
if (disk < start_disk_index)
@@ -548,18 +547,8 @@ static void raid0_handle_discard(struct mddev *mddev, struct bio *bio)
rdev = conf->devlist[(zone - conf->strip_zone) *
conf->strip_zone[0].nb_dev + disk];
- if (__blkdev_issue_discard(rdev->bdev,
- dev_start + zone->dev_start + rdev->data_offset,
- dev_end - dev_start, GFP_NOIO, 0, &discard_bio) ||
- !discard_bio)
- continue;
- 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);
+ dev_start += zone->dev_start;
+ md_submit_discard_bio(mddev, rdev, bio, dev_start, dev_end);
}
bio_endio(bio);
}
--
2.7.5
next prev parent reply other threads:[~2020-08-13 6:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-13 6:44 [md PATCH V3 0/4] Improve handling raid10 discard request Xiao Ni
2020-08-13 6:44 ` Xiao Ni [this message]
2020-08-13 6:44 ` [md PATCH V3 2/4] extend r10bio devs to raid disks Xiao Ni
2020-08-13 6:44 ` [md PATCH V3 3/4] improve raid10 discard request Xiao Ni
2020-08-13 6:44 ` [md PATCH V3 4/4] Improve discard request for far layout Xiao Ni
2020-08-13 8:16 ` [md PATCH V3 0/4] Improve handling raid10 discard request Xiao Ni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1597301087-6565-2-git-send-email-xni@redhat.com \
--to=xni@redhat.com \
--cc=colyli@suse.de \
--cc=guoqing.jiang@cloud.ionos.com \
--cc=heinzm@redhat.com \
--cc=linux-raid@vger.kernel.org \
--cc=ncroxon@redhat.com \
--cc=song@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).