Message ID | 20210121175056.20078-1-mwilck@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2] dm: avoid filesystem lookup in dm_get_dev_t() | expand |
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.
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
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) {