Set multipath disk attr groups, which includes delayed disk removal and
everything from mpath_attr_group.

Signed-off-by: John Garry <[email protected]>
---
 drivers/scsi/sd.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index ca20f9430b4ac..b1cf35194895e 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -4064,6 +4064,41 @@ static void sd_mpath_add_disk(struct scsi_disk *sdkp)
        mpath_device_set_live(mpath_device);
 }
 
+static ssize_t sd_mpath_device_delayed_removal_store(struct device *dev,
+               struct device_attribute *attr, const char *buf, size_t count)
+{
+       struct mpath_head *mpath_head = mpath_bd_device_to_head(dev);
+
+       return mpath_delayed_removal_secs_store(mpath_head, buf, count);
+}
+
+static ssize_t sd_mpath_device_delayed_removal_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       struct mpath_head *mpath_head = mpath_bd_device_to_head(dev);
+
+       return mpath_delayed_removal_secs_show(mpath_head, buf);
+}
+
+static DEVICE_ATTR(delayed_removal_secs, S_IRUGO | S_IWUSR,
+               sd_mpath_device_delayed_removal_show,
+               sd_mpath_device_delayed_removal_store);
+
+static struct attribute *sd_mpath_disk_attrs[] = {
+       &dev_attr_delayed_removal_secs.attr,
+       NULL
+};
+
+static const struct attribute_group sd_mpath_disk_attr_group = {
+       .attrs          = sd_mpath_disk_attrs,
+};
+
+const struct attribute_group *sd_mpath_disk_attr_groups[] = {
+       &sd_mpath_disk_attr_group,
+       &mpath_attr_group,
+       NULL
+};
+
 static int sd_mpath_probe(struct scsi_disk *sdkp)
 {
        struct scsi_device *sdp = sdkp->device;
@@ -4149,6 +4184,7 @@ static int sd_mpath_probe(struct scsi_disk *sdkp)
        /* undone in sd_mpath_disk_release() */
        scsi_mpath_get_head(scsi_mpath_head);
        scsi_mpath_head->mpath_head->drv_module = THIS_MODULE;
+       scsi_mpath_head->mpath_head->disk_groups = sd_mpath_disk_attr_groups;
 
        error = device_add(&sd_mpath_disk->dev);
        if (error) {
-- 
2.43.5


Reply via email to