* [PATCH v2] dm: avoid filesystem lookup in dm_get_dev_t()
@ 2021-01-21 17:50 mwilck
2021-01-21 17:53 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: mwilck @ 2021-01-21 17:50 UTC (permalink / raw)
To: Christoph Hellwig, Mike Snitzer, Hannes Reinecke
Cc: Alasdair G Kergon, Jens Axboe, linux-block, dm-devel
From: Hannes Reinecke <hare@suse.de>
This reverts commit
644bda6f3460 ("dm table: fall back to getting device using name_to_dev_t()")
dm_get_dev_t() is just used to convert an arbitrary 'path' string
into a dev_t. It doesn't presume that the device is present; that
check will be done later, as the only caller is dm_get_device(),
which does a dm_get_table_device() later on, which will properly
open the device.
So if the path string already _is_ in major:minor representation
we can convert it directly, avoiding a recursion into the filesystem
to lookup the block device.
This avoids a hang in multipath_message() when the filesystem is
inaccessible.
Fixes: 644bda6f3460 ("dm table: fall back to getting device using name_to_dev_t()")
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
drivers/md/dm-table.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 188f41287f18..4acf2342f7ad 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -363,14 +363,23 @@ int dm_get_device(struct dm_target *ti, const char *path, fmode_t mode,
{
int r;
dev_t dev;
+ unsigned int major, minor;
+ char dummy;
struct dm_dev_internal *dd;
struct dm_table *t = ti->table;
BUG_ON(!t);
- dev = dm_get_dev_t(path);
- if (!dev)
- return -ENODEV;
+ if (sscanf(path, "%u:%u%c", &major, &minor, &dummy) == 2) {
+ /* Extract the major/minor numbers */
+ dev = MKDEV(major, minor);
+ if (MAJOR(dev) != major || MINOR(dev) != minor)
+ return -EOVERFLOW;
+ } else {
+ dev = dm_get_dev_t(path);
+ if (!dev)
+ return -ENODEV;
+ }
dd = find_device(&t->devices, dev);
if (!dd) {
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] dm: avoid filesystem lookup in dm_get_dev_t()
2021-01-21 17:50 [PATCH v2] dm: avoid filesystem lookup in dm_get_dev_t() mwilck
@ 2021-01-21 17:53 ` Christoph Hellwig
2021-01-21 17:57 ` Mike Snitzer
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2021-01-21 17:53 UTC (permalink / raw)
To: mwilck
Cc: Christoph Hellwig, Mike Snitzer, Hannes Reinecke,
Alasdair G Kergon, Jens Axboe, linux-block, dm-devel
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
Mike, Jens - can we make sure this goes in before branching off the
block branch for 5.12? I have some work pending that would otherwise
conflict.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] dm: avoid filesystem lookup in dm_get_dev_t()
2021-01-21 17:53 ` Christoph Hellwig
@ 2021-01-21 17:57 ` Mike Snitzer
0 siblings, 0 replies; 3+ messages in thread
From: Mike Snitzer @ 2021-01-21 17:57 UTC (permalink / raw)
To: Christoph Hellwig
Cc: mwilck, Hannes Reinecke, Alasdair G Kergon, Jens Axboe,
linux-block, dm-devel
On Thu, Jan 21 2021 at 12:53pm -0500,
Christoph Hellwig <hch@lst.de> wrote:
> Looks good,
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
>
> Mike, Jens - can we make sure this goes in before branching off the
> block branch for 5.12? I have some work pending that would otherwise
> conflict.
Sure, I'll do my part to get this fix staged now and sent to Linus
(likely tomorrow) for 5.11-rc5.
Thanks,
Mike
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-21 18:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-21 17:50 [PATCH v2] dm: avoid filesystem lookup in dm_get_dev_t() mwilck
2021-01-21 17:53 ` Christoph Hellwig
2021-01-21 17:57 ` Mike Snitzer
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).