From patchwork Wed Aug 24 13:18:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 9297711 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 D9052607D0 for ; Wed, 24 Aug 2016 13:20:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CACA828FE6 for ; Wed, 24 Aug 2016 13:20:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFD6328FE9; Wed, 24 Aug 2016 13:20:26 +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 5ACCB28FE7 for ; Wed, 24 Aug 2016 13:20:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755271AbcHXNUG (ORCPT ); Wed, 24 Aug 2016 09:20:06 -0400 Received: from mail-yw0-f195.google.com ([209.85.161.195]:35670 "EHLO mail-yw0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753889AbcHXNT6 (ORCPT ); Wed, 24 Aug 2016 09:19:58 -0400 Received: by mail-yw0-f195.google.com with SMTP id r9so789553ywg.2 for ; Wed, 24 Aug 2016 06:19:04 -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=+oJQagDcEahPYLtBVIALOaWSI28M6fpOS+vF3XS+pFE=; b=0Tq8J/BORpXm01C7VhozpmxTJv5kHfzotBTFAnTbENQnkMmK78UNe49nBNfd5ro/5J g4Qn966UgTs4Yz4M4HmCjyckR9eM7THqlSUl9zDlyexyrhQrEzZHZA2lzkH3UpquPbCi 9AQZQEEAycvcH8Qv8onKgJ6bXKkJ1McXyiJH9Dp84C3ugzJ870DSK1RPbxMMVvGH4xYm dGaEKM5+7333MOxjhjxnEOngNjfiVwmaU61JzPPEyVwn7TNqjnBCJ8aQEEsQ+eUCj75B rAkmLrqk4V7BIT1qOk5ZDxxv9qusHMbsNz8PztUJBqGJ/dVLmz2D+tuvoazDmTHscTWn vayQ== 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=+oJQagDcEahPYLtBVIALOaWSI28M6fpOS+vF3XS+pFE=; b=C/Lj3p+5QxlLIrM//MOzcxS3BKyeq5FzaZQP6nBSmYAFCv9ufDqumi3rTGFM77AA1E YZz3e4ua9cm4SlqxfrVzXaGKStiH0Qx5Oz90vbK29Zqtb6asyYsQJ4qkKKh7yXAsZYp5 OsS/XpNynOTubzvKer+6YADJfW7arYqiDeCYzGpGRne5v42Im9dJnFvR/UGjNoRc5yQb cqrvkrnL1QzCjLn0JfhVcVlxSfRO2aJ4Qjtmtcta9AVWw+QWh80XxP/q83lnlPAVcWHD oAG0eE88EUjkQtmAC2IC6MgPxvrTWLaylH1K4ew2BCmMgdnuNDDTwTR7eKrw6FxOZ84m K9gw== X-Gm-Message-State: AE9vXwMVOyboA9LbAsjH93jUfpg6a4l2NseM3fOiYeGBv37umPEEKPVGX56HKBb9rjeY+Q== X-Received: by 10.129.145.6 with SMTP id i6mr2341506ywg.35.1472044744277; Wed, 24 Aug 2016 06:19:04 -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.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Aug 2016 06:19:03 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 12/16] rbd: add 'client_addr' sysfs rbd device attribute Date: Wed, 24 Aug 2016 15:18:36 +0200 Message-Id: <1472044720-29116-13-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 Export client addr/nonce, so userspace can check if a image is being blacklisted. Signed-off-by: Mike Christie [idryomov@gmail.com: ceph_client_addr(), endianess fix] Signed-off-by: Ilya Dryomov --- Documentation/ABI/testing/sysfs-bus-rbd | 6 ++++++ drivers/block/rbd.c | 13 +++++++++++++ include/linux/ceph/libceph.h | 1 + net/ceph/ceph_common.c | 6 ++++++ 4 files changed, 26 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-rbd b/Documentation/ABI/testing/sysfs-bus-rbd index 2ddd680929d8..273e27f2491f 100644 --- a/Documentation/ABI/testing/sysfs-bus-rbd +++ b/Documentation/ABI/testing/sysfs-bus-rbd @@ -43,6 +43,12 @@ Description: Available only if rbd module is inserted with single_major Entries under /sys/bus/rbd/devices// -------------------------------------------- +client_addr + + The ceph unique client entity_addr_t (address + nonce). + The format is
:/: '1.2.3.4:1234/5678' or + '[1:2:3:4:5:6:7:8]:1234/5678'. (August 2016, since 4.9.) + client_id The ceph unique client id that was assigned for this specific session. diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index fd1a9891b348..69d76c3afcdd 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -4592,6 +4592,17 @@ static ssize_t rbd_minor_show(struct device *dev, return sprintf(buf, "%d\n", rbd_dev->minor); } +static ssize_t rbd_client_addr_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); + struct ceph_entity_addr *client_addr = + ceph_client_addr(rbd_dev->rbd_client->client); + + return sprintf(buf, "%pISpc/%u\n", &client_addr->in_addr, + le32_to_cpu(client_addr->nonce)); +} + static ssize_t rbd_client_id_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -4702,6 +4713,7 @@ 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); static DEVICE_ATTR(minor, S_IRUGO, rbd_minor_show, NULL); +static DEVICE_ATTR(client_addr, S_IRUGO, rbd_client_addr_show, NULL); static DEVICE_ATTR(client_id, S_IRUGO, rbd_client_id_show, NULL); static DEVICE_ATTR(pool, S_IRUGO, rbd_pool_show, NULL); static DEVICE_ATTR(pool_id, S_IRUGO, rbd_pool_id_show, NULL); @@ -4716,6 +4728,7 @@ static struct attribute *rbd_attrs[] = { &dev_attr_features.attr, &dev_attr_major.attr, &dev_attr_minor.attr, + &dev_attr_client_addr.attr, &dev_attr_client_id.attr, &dev_attr_pool.attr, &dev_attr_pool_id.attr, diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h index b4cffff70e44..1816c5e26581 100644 --- a/include/linux/ceph/libceph.h +++ b/include/linux/ceph/libceph.h @@ -264,6 +264,7 @@ extern struct ceph_client *ceph_create_client(struct ceph_options *opt, void *private, u64 supported_features, u64 required_features); +struct ceph_entity_addr *ceph_client_addr(struct ceph_client *client); u64 ceph_client_gid(struct ceph_client *client); extern void ceph_destroy_client(struct ceph_client *client); extern int __ceph_open_session(struct ceph_client *client, diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c index 8a7921767308..464e88599b9d 100644 --- a/net/ceph/ceph_common.c +++ b/net/ceph/ceph_common.c @@ -566,6 +566,12 @@ int ceph_print_client_options(struct seq_file *m, struct ceph_client *client) } EXPORT_SYMBOL(ceph_print_client_options); +struct ceph_entity_addr *ceph_client_addr(struct ceph_client *client) +{ + return &client->msgr.inst.addr; +} +EXPORT_SYMBOL(ceph_client_addr); + u64 ceph_client_gid(struct ceph_client *client) { return client->monc.auth->global_id;