From: Christoph Hellwig <hch@infradead.org>
To: dm-devel@redhat.com
Cc: snitzer@redhat.com
Subject: [PATCH, RFC] dm: relax discard restrictions
Date: Wed, 27 Apr 2011 11:06:23 -0400 [thread overview]
Message-ID: <20110427150623.GC13487@infradead.org> (raw)
With targets like dm-thinp we might want to allow discard even if the
underlying devices don't support them natively. This patch is the
extreme variant of not restricting discard support at all, but maybe
there are other options. Or maybe we should keep the old
dm_table_supports_discards function as a helper for targets that
want simple discard passthrough?
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: linux-2.6/drivers/md/dm-table.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-table.c 2011-04-27 16:44:09.231032143 +0200
+++ linux-2.6/drivers/md/dm-table.c 2011-04-27 16:51:39.415259952 +0200
@@ -1136,10 +1136,10 @@ void dm_table_set_restrictions(struct dm
*/
q->limits = *limits;
- if (!dm_table_supports_discards(t))
- queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, q);
- else
+ if (t->discards_supported)
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
+ else
+ queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, q);
dm_table_set_integrity(t);
@@ -1303,39 +1303,6 @@ struct mapped_device *dm_table_get_md(st
return t->md;
}
-static int device_discard_capable(struct dm_target *ti, struct dm_dev *dev,
- sector_t start, sector_t len, void *data)
-{
- struct request_queue *q = bdev_get_queue(dev->bdev);
-
- return q && blk_queue_discard(q);
-}
-
-bool dm_table_supports_discards(struct dm_table *t)
-{
- struct dm_target *ti;
- unsigned i = 0;
-
- if (!t->discards_supported)
- return 0;
-
- /*
- * Ensure that at least one underlying device supports discards.
- * t->devices includes internal dm devices such as mirror logs
- * so we need to use iterate_devices here, which targets
- * supporting discard must provide.
- */
- while (i < dm_table_get_num_targets(t)) {
- ti = dm_table_get_target(t, i++);
-
- if (ti->type->iterate_devices &&
- ti->type->iterate_devices(ti, device_discard_capable, NULL))
- return 1;
- }
-
- return 0;
-}
-
EXPORT_SYMBOL(dm_vcalloc);
EXPORT_SYMBOL(dm_get_device);
EXPORT_SYMBOL(dm_put_device);
Index: linux-2.6/drivers/md/dm.h
===================================================================
--- linux-2.6.orig/drivers/md/dm.h 2011-04-27 16:50:32.992286464 +0200
+++ linux-2.6/drivers/md/dm.h 2011-04-27 16:50:34.898942802 +0200
@@ -61,7 +61,6 @@ int dm_table_any_congested(struct dm_tab
int dm_table_any_busy_target(struct dm_table *t);
unsigned dm_table_get_type(struct dm_table *t);
bool dm_table_request_based(struct dm_table *t);
-bool dm_table_supports_discards(struct dm_table *t);
int dm_table_alloc_md_mempools(struct dm_table *t);
void dm_table_free_md_mempools(struct dm_table *t);
struct dm_md_mempools *dm_table_get_md_mempools(struct dm_table *t);
next reply other threads:[~2011-04-27 15:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-27 15:06 Christoph Hellwig [this message]
2011-04-27 15:19 ` [PATCH, RFC] dm: relax discard restrictions Mike Snitzer
2011-04-27 21:55 ` [PATCH] dm: allow a target to " Mike Snitzer
2011-04-28 8:41 ` Christoph Hellwig
2011-04-28 15:04 ` 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=20110427150623.GC13487@infradead.org \
--to=hch@infradead.org \
--cc=dm-devel@redhat.com \
--cc=snitzer@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.