From patchwork Mon Mar 26 06:04:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongsheng Yang X-Patchwork-Id: 10307209 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 573BC60212 for ; Mon, 26 Mar 2018 06:05:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4673E2946A for ; Mon, 26 Mar 2018 06:05:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3ABA6294D4; Mon, 26 Mar 2018 06:05:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1ECB72946A for ; Mon, 26 Mar 2018 06:05:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751083AbeCZGFu (ORCPT ); Mon, 26 Mar 2018 02:05:50 -0400 Received: from m97139.mail.qiye.163.com ([220.181.97.139]:29701 "EHLO m97139.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750885AbeCZGFt (ORCPT ); Mon, 26 Mar 2018 02:05:49 -0400 Received: from atest-guest.localdomain (unknown [218.94.118.90]) by smtp10 (Coremail) with SMTP id vOCowACXr6V9jbhaUGkXAA--.90S2; Mon, 26 Mar 2018 14:04:45 +0800 (CST) From: Dongsheng Yang To: idryomov@gmail.com, sage@redhat.com, elder@kernel.org, jdillama@redhat.com Cc: ceph-devel@vger.kernel.org, Dongsheng Yang Subject: [PATCH v2] rbd: show the rbd options in sysfs Date: Mon, 26 Mar 2018 02:04:40 -0400 Message-Id: <1522044280-27647-1-git-send-email-dongsheng.yang@easystack.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1521541996-16057-1-git-send-email-dongsheng.yang@easystack.cn> References: <1521541996-16057-1-git-send-email-dongsheng.yang@easystack.cn> X-CM-TRANSID: vOCowACXr6V9jbhaUGkXAA--.90S2 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjfUJm9aDUUUU X-Originating-IP: [218.94.118.90] X-CM-SenderInfo: 5grqw2pkhqwhp1dqwq5hdv52pwdfyhdfq/1tbiAwUVelilk1YUXQABsZ Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/block/rbd.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 49e227e..588b65a 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -4129,6 +4129,18 @@ 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); + + return sprintf(buf, "queue_depth=%llu,read_only=%s,lock_on_read=%s,exclusive=%s\n", + (unsigned long long)rbd_dev->opts->queue_depth, + rbd_dev->opts->read_only? "true" : "false", + rbd_dev->opts->lock_on_read? "true" : "false", + rbd_dev->opts->exclusive? "true" : "false"); +} + 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); @@ -4145,6 +4157,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, @@ -4163,6 +4176,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 };