Message ID | 1525682645-30510-2-git-send-email-dongsheng.yang@easystack.cn (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, May 7, 2018 at 10:43 AM, Dongsheng Yang <dongsheng.yang@easystack.cn> wrote: > We need to know the rbd options for a rbd device, such as whether lock_on_read > is true or false. then this patch introduce a rbd_options to show the rbd options in sysfs. I'm not convinced this is really needed. Once something is added to sysfs it is there to stay, and your solution only works for per mapping options (and not for per client, i.e. libceph) options. We don't have a good place for libceph options -- ideally it would be a per libceph instance directory (doesn't exist), linked to from per rbd instance directories (exist) and per ceph instance directories (doesn't exist). Getting those pieces that don't exist right and taking it through review is a significant effort and hasn't been high on the list. /sys/bus/rbd/devices/<id>/config_info shows an entire string written into sysfs by "rbd map". All options supplied to "rbd map" (including libceph options) are part of that string, so if you need to recall an option that was supplied to "rbd map", look at config_info. It doesn't list defaults, but they are documented in the man page. We haven't changed a single default in the past few years, so there shouldn't be any confusion there. Take lock_on_read as an example: if grep -q lock_on_read /sys/bus/rbd/devices/0/config_info; then echo "lock_on_read: true" else echo "lock_on_read: false (default)" fi Thanks, Ilya -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hmmm, okey, let's keep it simple as possible. Thanx On 05/07/2018 10:02 PM, Ilya Dryomov wrote: > On Mon, May 7, 2018 at 10:43 AM, Dongsheng Yang > <dongsheng.yang@easystack.cn> wrote: >> We need to know the rbd options for a rbd device, such as whether lock_on_read >> is true or false. then this patch introduce a rbd_options to show the rbd options in sysfs. > I'm not convinced this is really needed. Once something is added to > sysfs it is there to stay, and your solution only works for per mapping > options (and not for per client, i.e. libceph) options. We don't have > a good place for libceph options -- ideally it would be a per libceph > instance directory (doesn't exist), linked to from per rbd instance > directories (exist) and per ceph instance directories (doesn't exist). > Getting those pieces that don't exist right and taking it through > review is a significant effort and hasn't been high on the list. > > /sys/bus/rbd/devices/<id>/config_info shows an entire string written > into sysfs by "rbd map". All options supplied to "rbd map" (including > libceph options) are part of that string, so if you need to recall an > option that was supplied to "rbd map", look at config_info. > > It doesn't list defaults, but they are documented in the man page. > We haven't changed a single default in the past few years, so there > shouldn't be any confusion there. Take lock_on_read as an example: > > if grep -q lock_on_read /sys/bus/rbd/devices/0/config_info; then > echo "lock_on_read: true" > else > echo "lock_on_read: false (default)" > fi > > Thanks, > > Ilya > -- > To unsubscribe from this list: send the line "unsubscribe ceph-devel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 50b9d0f..d56c250 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -4205,6 +4205,26 @@ static ssize_t rbd_image_refresh(struct device *dev, return size; } +static ssize_t rbd_options_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); + unsigned long long lock_timeout = + jiffies_to_msecs(rbd_dev->opts->lock_timeout) / 1000; + ssize_t len = 0; + + len = sprintf(buf, "queue_depth=%llu", + (unsigned long long)rbd_dev->opts->queue_depth); + len += sprintf(buf + len, ",lock_timeout=%llu", lock_timeout); + len += sprintf(buf + len, ",read_only=%s", + rbd_dev->opts->read_only? "true" : "false"); + len += sprintf(buf + len, ",lock_on_read=%s", + rbd_dev->opts->lock_on_read? "true" : "false"); + len += sprintf(buf + len, ",exclusive=%s\n", + rbd_dev->opts->exclusive? "true" : "false"); + return len; +} + static DEVICE_ATTR(size, S_IRUGO, rbd_size_show, NULL); static DEVICE_ATTR(features, S_IRUGO, rbd_features_show, NULL); static DEVICE_ATTR(major, S_IRUGO, rbd_major_show, NULL); @@ -4221,6 +4241,7 @@ static ssize_t rbd_image_refresh(struct device *dev, static DEVICE_ATTR(current_snap, S_IRUGO, rbd_snap_show, NULL); static DEVICE_ATTR(snap_id, S_IRUGO, rbd_snap_id_show, NULL); static DEVICE_ATTR(parent, S_IRUGO, rbd_parent_show, NULL); +static DEVICE_ATTR(rbd_options, S_IRUGO, rbd_options_show, NULL); static struct attribute *rbd_attrs[] = { &dev_attr_size.attr, @@ -4239,6 +4260,7 @@ static ssize_t rbd_image_refresh(struct device *dev, &dev_attr_snap_id.attr, &dev_attr_parent.attr, &dev_attr_refresh.attr, + &dev_attr_rbd_options.attr, NULL };
We need to know the rbd options for a rbd device, such as whether lock_on_read is true or false. then this patch introduce a rbd_options to show the rbd options in sysfs. Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn> --- drivers/block/rbd.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)