Skip to content

Commit 9626d5b

Browse files
johnpgarrykawasaki
authored andcommitted
libmultipath: Add mpath_bdev_get_unique_id()
Add mpath_bdev_get_unique_id() as a multipath block device .get_unique_id handler. Signed-off-by: John Garry <john.g.garry@oracle.com>
1 parent 841ded9 commit 9626d5b

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

include/linux/multipath.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ struct mpath_head_template {
8686
unsigned int poll_flags);
8787
enum mpath_iopolicy_e (*get_iopolicy)(struct mpath_head *);
8888
struct bio *(*clone_bio)(struct bio *);
89+
int (*get_unique_id)(struct mpath_device *, u8 id[16],
90+
enum blk_unique_id type);
8991
const struct mpath_pr_ops *pr_ops;
9092
const struct attribute_group **device_groups;
9193
};

lib/multipath.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,22 @@ static void mpath_bdev_release(struct gendisk *disk)
496496
mpath_put_disk(mpath_disk);
497497
}
498498

499+
static int mpath_bdev_get_unique_id(struct gendisk *disk, u8 id[16],
500+
enum blk_unique_id type)
501+
{
502+
struct mpath_disk *mpath_disk = mpath_gendisk_to_disk(disk);
503+
struct mpath_head *mpath_head = mpath_disk->mpath_head;
504+
int srcu_idx, ret = -EWOULDBLOCK;
505+
struct mpath_device *mpath_device;
506+
507+
srcu_idx = srcu_read_lock(&mpath_head->srcu);
508+
mpath_device = mpath_find_path(mpath_head);
509+
if (mpath_device)
510+
ret = mpath_head->mpdt->get_unique_id(mpath_device, id, type);
511+
srcu_read_unlock(&mpath_head->srcu, srcu_idx);
512+
513+
return ret;
514+
}
499515
static int mpath_bdev_ioctl(struct block_device *bdev, blk_mode_t mode,
500516
unsigned int cmd, unsigned long arg)
501517
{
@@ -704,6 +720,7 @@ const struct block_device_operations mpath_ops = {
704720
.submit_bio = mpath_bdev_submit_bio,
705721
.ioctl = mpath_bdev_ioctl,
706722
.compat_ioctl = blkdev_compat_ptr_ioctl,
723+
.get_unique_id = mpath_bdev_get_unique_id,
707724
.report_zones = mpath_bdev_report_zones,
708725
.getgeo = mpath_bdev_getgeo,
709726
.pr_ops = &mpath_pr_ops,

0 commit comments

Comments
 (0)