diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2017-03-02 13:56:57 -0500 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2017-03-07 08:30:38 -0500 |
commit | 8767b293a4ab6632f9288f34bcf2ab9ba20dca3a (patch) | |
tree | 522fdfc7b64b40c716e1ec224533d98764bd5b02 | |
parent | b581a5854eee4b7851dedb0f8c2ceb54fb902c06 (diff) |
rbd: supported_features bus attribute
... so that userspace can generate meaningful error messages and spell
out unsupported features that need to be disabled.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Sage Weil <sage@redhat.com>
-rw-r--r-- | drivers/block/rbd.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 4d6807723798..517838b65964 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -120,10 +120,11 @@ static int atomic_dec_return_safe(atomic_t *v) | |||
120 | 120 | ||
121 | /* Feature bits */ | 121 | /* Feature bits */ |
122 | 122 | ||
123 | #define RBD_FEATURE_LAYERING (1<<0) | 123 | #define RBD_FEATURE_LAYERING (1ULL<<0) |
124 | #define RBD_FEATURE_STRIPINGV2 (1<<1) | 124 | #define RBD_FEATURE_STRIPINGV2 (1ULL<<1) |
125 | #define RBD_FEATURE_EXCLUSIVE_LOCK (1<<2) | 125 | #define RBD_FEATURE_EXCLUSIVE_LOCK (1ULL<<2) |
126 | #define RBD_FEATURE_DATA_POOL (1<<7) | 126 | #define RBD_FEATURE_DATA_POOL (1ULL<<7) |
127 | |||
127 | #define RBD_FEATURES_ALL (RBD_FEATURE_LAYERING | \ | 128 | #define RBD_FEATURES_ALL (RBD_FEATURE_LAYERING | \ |
128 | RBD_FEATURE_STRIPINGV2 | \ | 129 | RBD_FEATURE_STRIPINGV2 | \ |
129 | RBD_FEATURE_EXCLUSIVE_LOCK | \ | 130 | RBD_FEATURE_EXCLUSIVE_LOCK | \ |
@@ -499,16 +500,23 @@ static bool rbd_is_lock_owner(struct rbd_device *rbd_dev) | |||
499 | return is_lock_owner; | 500 | return is_lock_owner; |
500 | } | 501 | } |
501 | 502 | ||
503 | static ssize_t rbd_supported_features_show(struct bus_type *bus, char *buf) | ||
504 | { | ||
505 | return sprintf(buf, "0x%llx\n", RBD_FEATURES_SUPPORTED); | ||
506 | } | ||
507 | |||
502 | static BUS_ATTR(add, S_IWUSR, NULL, rbd_add); | 508 | static BUS_ATTR(add, S_IWUSR, NULL, rbd_add); |
503 | static BUS_ATTR(remove, S_IWUSR, NULL, rbd_remove); | 509 | static BUS_ATTR(remove, S_IWUSR, NULL, rbd_remove); |
504 | static BUS_ATTR(add_single_major, S_IWUSR, NULL, rbd_add_single_major); | 510 | static BUS_ATTR(add_single_major, S_IWUSR, NULL, rbd_add_single_major); |
505 | static BUS_ATTR(remove_single_major, S_IWUSR, NULL, rbd_remove_single_major); | 511 | static BUS_ATTR(remove_single_major, S_IWUSR, NULL, rbd_remove_single_major); |
512 | static BUS_ATTR(supported_features, S_IRUGO, rbd_supported_features_show, NULL); | ||
506 | 513 | ||
507 | static struct attribute *rbd_bus_attrs[] = { | 514 | static struct attribute *rbd_bus_attrs[] = { |
508 | &bus_attr_add.attr, | 515 | &bus_attr_add.attr, |
509 | &bus_attr_remove.attr, | 516 | &bus_attr_remove.attr, |
510 | &bus_attr_add_single_major.attr, | 517 | &bus_attr_add_single_major.attr, |
511 | &bus_attr_remove_single_major.attr, | 518 | &bus_attr_remove_single_major.attr, |
519 | &bus_attr_supported_features.attr, | ||
512 | NULL, | 520 | NULL, |
513 | }; | 521 | }; |
514 | 522 | ||