From: Mike Snitzer <snitzer@redhat.com>
To: dm-devel@redhat.com
Subject: [PATCH v3 06/12] dm: split discard requests on target boundaries
Date: Mon, 26 Jul 2010 17:41:22 -0400 [thread overview]
Message-ID: <20100726214122.GC20849@redhat.com> (raw)
In-Reply-To: <1279987768-13275-7-git-send-email-snitzer@redhat.com>
Update __clone_and_map_discard to loop across all targets in a DM
device's table when it processes a discard bio. If a discard crosses a
target boundary it must be split accordingly.
Update __issue_target_requests and __issue_target_request to allow a
cloned discard bio to have a custom start sector and size.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
drivers/md/dm.c | 51 ++++++++++++++++++++++++++++-----------------------
1 file changed, 28 insertions(+), 23 deletions(-)
Index: linux-2.6-block/drivers/md/dm.c
===================================================================
--- linux-2.6-block.orig/drivers/md/dm.c
+++ linux-2.6-block/drivers/md/dm.c
@@ -1188,7 +1188,7 @@ static struct dm_target_io *alloc_tio(st
}
static void __issue_target_request(struct clone_info *ci, struct dm_target *ti,
- unsigned request_nr)
+ unsigned request_nr, sector_t len)
{
struct dm_target_io *tio = alloc_tio(ci, ti);
struct bio *clone;
@@ -1203,17 +1203,21 @@ static void __issue_target_request(struc
clone = bio_alloc_bioset(GFP_NOIO, ci->bio->bi_max_vecs, ci->md->bs);
__bio_clone(clone, ci->bio);
clone->bi_destructor = dm_bio_destructor;
+ if (len) {
+ clone->bi_sector = ci->sector;
+ clone->bi_size = to_bytes(len);
+ }
__map_bio(ti, clone, tio);
}
static void __issue_target_requests(struct clone_info *ci, struct dm_target *ti,
- unsigned num_requests)
+ unsigned num_requests, sector_t len)
{
unsigned request_nr;
for (request_nr = 0; request_nr < num_requests; request_nr++)
- __issue_target_request(ci, ti, request_nr);
+ __issue_target_request(ci, ti, request_nr, len);
}
static int __clone_and_map_empty_barrier(struct clone_info *ci)
@@ -1222,7 +1226,7 @@ static int __clone_and_map_empty_barrier
struct dm_target *ti;
while ((ti = dm_table_get_target(ci->map, target_nr++)))
- __issue_target_requests(ci, ti, ti->num_flush_requests);
+ __issue_target_requests(ci, ti, ti->num_flush_requests, 0);
ci->sector_count = 0;
@@ -1248,30 +1252,31 @@ static void __clone_and_map_simple(struc
static int __clone_and_map_discard(struct clone_info *ci)
{
struct dm_target *ti;
- sector_t max;
-
- ti = dm_table_find_target(ci->map, ci->sector);
- if (!dm_target_is_valid(ti))
- return -EIO;
-
- /*
- * Even though the device advertised discard support,
- * reconfiguration might have changed that since the
- * check was performed.
- */
-
- if (!ti->num_discard_requests)
- return -EOPNOTSUPP;
+ sector_t max, len, remaining = ci->sector_count;
+ unsigned offset = 0;
- max = max_io_len(ci->sector, ti);
+ do {
+ ti = dm_table_find_target(ci->map, ci->sector);
+ if (!dm_target_is_valid(ti))
+ return -EIO;
- if (ci->sector_count > max)
/*
- * FIXME: Handle a discard that spans two or more targets.
+ * Even though the device advertised discard support,
+ * reconfiguration might have changed that since the
+ * check was performed.
*/
- return -EOPNOTSUPP;
+ if (!ti->num_discard_requests)
+ return -EOPNOTSUPP;
+
+ max = max_io_len_target_boundary(ci->sector, ti);
+ len = min(remaining, max);
- __issue_target_requests(ci, ti, ti->num_discard_requests);
+ __issue_target_requests(ci, ti, ti->num_discard_requests, len);
+
+ ci->sector += len;
+ ci->sector_count -= len;
+ offset += to_bytes(len);
+ } while (remaining -= len);
ci->sector_count = 0;
next prev parent reply other threads:[~2010-07-26 21:41 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-24 16:09 [PATCH v2 00/12] dm: enable discard support for more targets Mike Snitzer
2010-07-24 16:09 ` [PATCH v2 01/12] dm: rename map_info flush_request to target_request_nr Mike Snitzer
2010-07-24 16:09 ` [PATCH v2 02/12] dm: introduce num_discard_requests in dm_target structure Mike Snitzer
2010-07-24 16:09 ` [PATCH v2 03/12] dm: remove the DM_TARGET_SUPPORTS_DISCARDS feature flag Mike Snitzer
2010-07-24 16:09 ` [PATCH v2 04/12] dm: use common __issue_target_request for flush and discard support Mike Snitzer
2010-07-24 16:09 ` [PATCH v2 05/12] dm: factor max_io_len for code reuse Mike Snitzer
2010-07-26 21:36 ` [PATCH v3 " Mike Snitzer
2010-07-24 16:09 ` [PATCH v2 06/12] dm: split discard requests on target boundaries Mike Snitzer
2010-07-26 21:41 ` Mike Snitzer [this message]
2010-07-24 16:09 ` [PATCH v2 07/12] dm zero: silently drop discards too Mike Snitzer
2010-07-24 16:09 ` [PATCH v2 08/12] dm error: return error for " Mike Snitzer
2010-07-24 16:09 ` [PATCH v2 09/12] dm delay: enable discard support Mike Snitzer
2010-07-24 16:09 ` [PATCH v2 10/12] block: update request stacking methods to support discards Mike Snitzer
2010-07-27 14:54 ` Christoph Hellwig
2010-07-24 16:09 ` [PATCH v2 11/12] dm mpath: enable discard support Mike Snitzer
2010-07-26 20:41 ` [PATCH v3 " Mike Snitzer
2010-07-24 16:09 ` [PATCH v2 12/12] dm stripe: enable efficient " Mike Snitzer
2010-07-27 20:32 ` [PATCH v3 " Mike Snitzer
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=20100726214122.GC20849@redhat.com \
--to=snitzer@redhat.com \
--cc=dm-devel@redhat.com \
/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).