From patchwork Wed Aug 24 13:18:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 9297721 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 8C9AE60757 for ; Wed, 24 Aug 2016 13:21:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C7A728FE7 for ; Wed, 24 Aug 2016 13:21:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7104928FEC; Wed, 24 Aug 2016 13:21:08 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 70C6A28FE7 for ; Wed, 24 Aug 2016 13:21:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755995AbcHXNVF (ORCPT ); Wed, 24 Aug 2016 09:21:05 -0400 Received: from mail-yb0-f193.google.com ([209.85.213.193]:36534 "EHLO mail-yb0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753937AbcHXNT6 (ORCPT ); Wed, 24 Aug 2016 09:19:58 -0400 Received: by mail-yb0-f193.google.com with SMTP id f60so443668ybi.3 for ; Wed, 24 Aug 2016 06:19:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=6Rt4hBCj5OGvwzr53ao4mUSlLKdpw/C/v3gPlH+fP9Q=; b=LXl7p5JuZZlc/dXWlXRCOyfYMndR86jsfsrBtTJmqQJOiOEm9ks+ExtUlj1SRR2q4y xFYYkLg2Of5DfETVyfggQcfHRBWMHPky3Ll1SFTO3jj6l6XXaarP6kQOFriHWg7VJ74Y zXNROMyPG4bdq5Dpl6MCH6LjDLgxpbo/ZhJUpqzxRvwBQ4WTL7ah7Y87NQkoPBXi4hu/ TiTotsf9GtznfCIf+TZlp+Y2h0XTg89Tx5OBS7qN75KZ/0FCXDQVrsE6zazc0aFs5ZM2 gOSp9Ptwnmx8c7eITUfM7nyRepVA8tO28hJ7dsE18eV9LZofRHYAhNMLRfjj4lP3NlMS zJXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=6Rt4hBCj5OGvwzr53ao4mUSlLKdpw/C/v3gPlH+fP9Q=; b=Wk9dBqrmAUwEhk0GMDUrnbwfpG9vHVKOuzZo2E94pQf8tcRWdajSr7g1RPE64ALiMS XOyY8hI/sXXjQ8wdsCtCy8b8RuGddCcvcfhe4rRTFxRcc9Obd11SosfHWM9sgg8BOIHL KcT0q0CBgd8VS/xHEQxS1J4k+bVs/esnKAKyF7mugNbl+cMjMuaNX1AbFGgJiIu2KzOj ZN7iWXPoYYk9ImqV6mw1zFErYP/G+89qKG0NdEGDdqUNHLI5mv72vk0QmY5UFQ29Y3fu KRuq+moncNeIQwkYDl3gepqOhHrGTkoJKv7b08c5pygCr2Zhi247YgTXBMo4Rltb+2p2 e/7Q== X-Gm-Message-State: AEkoousqoUWEeEAhA40aOc7RIuzG+jnCkD5Mc98QWVg9u3woDiNME5qq+tdU1EijoZAvPQ== X-Received: by 10.37.220.200 with SMTP id y191mr2273934ybe.37.1472044746436; Wed, 24 Aug 2016 06:19:06 -0700 (PDT) Received: from dhcp-1-219.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id e197sm5371294ywa.16.2016.08.24.06.19.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Aug 2016 06:19:05 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 14/16] rbd: add 'snap_id' sysfs rbd device attribute Date: Wed, 24 Aug 2016 15:18:38 +0200 Message-Id: <1472044720-29116-15-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1472044720-29116-1-git-send-email-idryomov@gmail.com> References: <1472044720-29116-1-git-send-email-idryomov@gmail.com> 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 From: Mike Christie Export snap id in sysfs, so tools like multipathd can use it in a uuid. Signed-off-by: Mike Christie Signed-off-by: Ilya Dryomov --- Documentation/ABI/testing/sysfs-bus-rbd | 4 ++++ drivers/block/rbd.c | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-rbd b/Documentation/ABI/testing/sysfs-bus-rbd index 9a655f3f4386..7bf8d4fa6f63 100644 --- a/Documentation/ABI/testing/sysfs-bus-rbd +++ b/Documentation/ABI/testing/sysfs-bus-rbd @@ -102,6 +102,10 @@ current_snap The current snapshot for which the device is mapped. +snap_id + + The current snapshot's id. (August 2016, since 4.9.) + parent Information identifying the chain of parent images in a layered rbd diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index c95104a80065..36ebec19dc20 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -4669,6 +4669,14 @@ static ssize_t rbd_snap_show(struct device *dev, return sprintf(buf, "%s\n", rbd_dev->spec->snap_name); } +static ssize_t rbd_snap_id_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); + + return sprintf(buf, "%llu\n", rbd_dev->spec->snap_id); +} + /* * For a v2 image, shows the chain of parent images, separated by empty * lines. For v1 images or if there is no parent, shows "(no parent @@ -4730,6 +4738,7 @@ static DEVICE_ATTR(name, S_IRUGO, rbd_name_show, NULL); static DEVICE_ATTR(image_id, S_IRUGO, rbd_image_id_show, NULL); static DEVICE_ATTR(refresh, S_IWUSR, NULL, rbd_image_refresh); 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 struct attribute *rbd_attrs[] = { @@ -4745,6 +4754,7 @@ static struct attribute *rbd_attrs[] = { &dev_attr_name.attr, &dev_attr_image_id.attr, &dev_attr_current_snap.attr, + &dev_attr_snap_id.attr, &dev_attr_parent.attr, &dev_attr_refresh.attr, NULL