diff options
author | Stefan Haberland <sth@linux.ibm.com> | 2022-09-20 21:26:16 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-09-21 08:32:51 -0600 |
commit | 32ff8ce08b47a5fe64ef9827443ba6cc49a659c8 (patch) | |
tree | 343760d0880b01dbab1e205d1f74f306fb3a78ce /drivers/s390/block/dasd_devmap.c | |
parent | s390/dasd: suppress generic error messages for PPRC secondary devices (diff) | |
download | linux-dev-32ff8ce08b47a5fe64ef9827443ba6cc49a659c8.tar.xz linux-dev-32ff8ce08b47a5fe64ef9827443ba6cc49a659c8.zip |
s390/dasd: add device ping attribute
Add a function to check if a device is accessible.
This makes mostly sense for copy pair secondary devices but it will work
for all devices.
The sysfs attribute ping is a write only attribute and will issue a NOP
CCW to the device.
In case of success it will return zero. If the device is not accessible
it will return an error code.
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Link: https://lore.kernel.org/r/20220920192616.808070-8-sth@linux.ibm.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/s390/block/dasd_devmap.c')
-rw-r--r-- | drivers/s390/block/dasd_devmap.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c index ca5c9e963662..2f7341412ea9 100644 --- a/drivers/s390/block/dasd_devmap.c +++ b/drivers/s390/block/dasd_devmap.c @@ -2234,6 +2234,40 @@ out: } static DEVICE_ATTR(copy_role, 0444, dasd_copy_role_show, NULL); +static ssize_t dasd_device_ping(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct dasd_device *device; + size_t rc; + + device = dasd_device_from_cdev(to_ccwdev(dev)); + if (IS_ERR(device)) + return -ENODEV; + + /* + * do not try during offline processing + * early check only + * the sleep_on function itself checks for offline + * processing again + */ + if (test_bit(DASD_FLAG_OFFLINE, &device->flags)) { + rc = -EBUSY; + goto out; + } + if (!device->discipline || !device->discipline->device_ping) { + rc = -EOPNOTSUPP; + goto out; + } + rc = device->discipline->device_ping(device); + if (!rc) + rc = count; +out: + dasd_put_device(device); + return rc; +} +static DEVICE_ATTR(ping, 0200, NULL, dasd_device_ping); + #define DASD_DEFINE_ATTR(_name, _func) \ static ssize_t dasd_##_name##_show(struct device *dev, \ struct device_attribute *attr, \ @@ -2292,6 +2326,7 @@ static struct attribute * dasd_attrs[] = { &dev_attr_fc_security.attr, &dev_attr_copy_pair.attr, &dev_attr_copy_role.attr, + &dev_attr_ping.attr, NULL, }; |