nfs/blocklayout: support RH/Fedora dm-mpath device nodes
authorChristoph Hellwig <hch@lst.de>
Fri, 8 Jul 2016 09:41:30 +0000 (18:41 +0900)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Fri, 15 Jul 2016 19:46:08 +0000 (15:46 -0400)
Instead of reusing the wwn-* names for multipath devices nodes RHEL and
Fedora introduce new dm-mpath-uuid-* nodes with a slightly different
naming scheme.  Try these names first to ensure we always get a
multipath-capable device if it exists.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/blocklayout/dev.c

index ea70883a174a53a102d336ff1ccf24d023765360..436bb303d856a0d94661afd6330e147a56426874 100644 (file)
@@ -312,6 +312,28 @@ bl_open_udev_path(struct pnfs_block_volume *v)
        return bdev;
 }
 
+/*
+ * Try to open the RH/Fedora specific dm-mpath udev path for this WWN, as the
+ * wwn- links will only point to the first discovered SCSI device there.
+ */
+static struct block_device *
+bl_open_dm_mpath_udev_path(struct pnfs_block_volume *v)
+{
+       struct block_device *bdev;
+       const char *devname;
+
+       devname = kasprintf(GFP_KERNEL,
+                       "/dev/disk/by-id/dm-uuid-mpath-%d%*phN",
+                       v->scsi.designator_type,
+                       v->scsi.designator_len, v->scsi.designator);
+       if (!devname)
+               return ERR_PTR(-ENOMEM);
+
+       bdev = blkdev_get_by_path(devname, FMODE_READ | FMODE_WRITE, NULL);
+       kfree(devname);
+       return bdev;
+}
+
 static int
 bl_parse_scsi(struct nfs_server *server, struct pnfs_block_dev *d,
                struct pnfs_block_volume *volumes, int idx, gfp_t gfp_mask)
@@ -323,7 +345,9 @@ bl_parse_scsi(struct nfs_server *server, struct pnfs_block_dev *d,
        if (!bl_validate_designator(v))
                return -EINVAL;
 
-       d->bdev = bl_open_udev_path(v);
+       d->bdev = bl_open_dm_mpath_udev_path(v);
+       if (IS_ERR(d->bdev))
+               d->bdev = bl_open_udev_path(v);
        if (IS_ERR(d->bdev))
                return PTR_ERR(d->bdev);