From patchwork Mon May 7 08:43:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongsheng Yang X-Patchwork-Id: 10383527 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 7D90C60353 for ; Mon, 7 May 2018 08:44:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71DB5286DF for ; Mon, 7 May 2018 08:44:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 667D528A96; Mon, 7 May 2018 08:44:33 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 27471286DF for ; Mon, 7 May 2018 08:44:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752560AbeEGIo0 (ORCPT ); Mon, 7 May 2018 04:44:26 -0400 Received: from m97136.mail.qiye.163.com ([220.181.97.136]:5460 "EHLO m97136.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752531AbeEGIoV (ORCPT ); Mon, 7 May 2018 04:44:21 -0400 Received: from atest-guest.localdomain (unknown [218.94.118.90]) by smtp2 (Coremail) with SMTP id iOCowAD3D8riEfBa7U7qAA--.740S3; Mon, 07 May 2018 16:44:19 +0800 (CST) From: Dongsheng Yang To: ceph-devel@vger.kernel.org, idryomov@gmail.com Cc: Dongsheng Yang Subject: [PATCH 1/9] rbd: show the rbd options in sysfs Date: Mon, 7 May 2018 04:43:57 -0400 Message-Id: <1525682645-30510-2-git-send-email-dongsheng.yang@easystack.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1525682645-30510-1-git-send-email-dongsheng.yang@easystack.cn> References: <1525682645-30510-1-git-send-email-dongsheng.yang@easystack.cn> X-CM-TRANSID: iOCowAD3D8riEfBa7U7qAA--.740S3 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjfUJhiSDUUUU X-Originating-IP: [218.94.118.90] X-CM-SenderInfo: 5grqw2pkhqwhp1dqwq5hdv52pwdfyhdfq/1tbiAQM-elikTLdnZQAAsC 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 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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 };