From patchwork Mon Mar 6 15:24:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 9606963 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 8B4D960414 for ; Mon, 6 Mar 2017 15:24:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AEBC2838E for ; Mon, 6 Mar 2017 15:24:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6DFB12844E; Mon, 6 Mar 2017 15:24:29 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 105B32838E for ; Mon, 6 Mar 2017 15:24:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753334AbdCFPY2 (ORCPT ); Mon, 6 Mar 2017 10:24:28 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:33059 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752797AbdCFPY0 (ORCPT ); Mon, 6 Mar 2017 10:24:26 -0500 Received: by mail-wm0-f65.google.com with SMTP id n11so14318452wma.0 for ; Mon, 06 Mar 2017 07:24:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=MSVLHft0hkxTNHh+M9s/gw44lGmtTR8SLtMDvYBCA8w=; b=euc16kl860QvLdlU2sgQm0/gtx0nAJQvkje3OZwWJmClh91bBaylMIERSEW9Pu4TfX wkT5qH+DAifiyCbDe6iV+P4pMNZIEGkNpXSq0qRJfwTAaOvaYPrPaQ7xmQsNMLQLeNpK mrEYWAAc5Hb2b1goYQoN7jPzZSAP4Y2uBZ/aPNj9dt79NjukUAbN3gc8ruwBomR9IBF3 LH0vNXTMgZ+/nYOy0tILuO4Kal4fd2kz0eDciwneyv1yyFFZs6DwJISZktJcQVzrzbK5 8/+q90HxVks1ErgpR7NEWD8e2vXqUc9Cg7OCmh7sjgViGhAGyiHF0PN10QDq9TxCb2p8 xKvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=MSVLHft0hkxTNHh+M9s/gw44lGmtTR8SLtMDvYBCA8w=; b=dEJMIBAnqMd0xnW51htACS1+i5bFzjXLpyRKwNwXr+3qPUzL/WTn04WA4ZXf64tOzx 84dCSSg9Funy7MaHZkeykOXGF8LJppq0Qc4YW5KHe2Vh/NFIPJteUeWPtPYT+Hz6cNLI K0vha/UJ2uAU75Tp9pk9FwpmKBYVYxsRqPWWBbXJwwh1NtWymN4pazeZiRgzepYV7ypd LVuYIJk2TdX7Uz1aE8mu/Ar8dq0dBpzL8fak7sj/89sBRwRlAyv4U4dfv1ycU1Gvya7V XLWA0E22v6yX+nce4S9LBTzTAQy+uCge4azMcMUNXD8iYO3YeBspev9wzZAcZ3XSgn9C MPvw== X-Gm-Message-State: AMke39mnp379VGtGXg/MfwJ9gxMO09NEl66Eq333zqVVzrCeRcEG0txNB9O2MOp42HSSww== X-Received: by 10.28.135.21 with SMTP id j21mr5216782wmd.70.1488813864580; Mon, 06 Mar 2017 07:24:24 -0800 (PST) Received: from localhost.localdomain.com (ip-78-102-108-116.net.upcbroadband.cz. [78.102.108.116]) by smtp.gmail.com with ESMTPSA id w30sm27355682wrb.5.2017.03.06.07.24.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Mar 2017 07:24:24 -0800 (PST) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH] rbd: supported_features bus attribute Date: Mon, 6 Mar 2017 16:24:05 +0100 Message-Id: <1488813845-4201-1-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 2.4.3 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 ... so that userspace can generate meaningful error messages and spell out unsupported features that need to be disabled. Signed-off-by: Ilya Dryomov Reviewed-by: Sage Weil --- drivers/block/rbd.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 4138ed8565c6..8cfbac1e815e 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -120,10 +120,11 @@ static int atomic_dec_return_safe(atomic_t *v) /* Feature bits */ -#define RBD_FEATURE_LAYERING (1<<0) -#define RBD_FEATURE_STRIPINGV2 (1<<1) -#define RBD_FEATURE_EXCLUSIVE_LOCK (1<<2) -#define RBD_FEATURE_DATA_POOL (1<<7) +#define RBD_FEATURE_LAYERING (1ULL<<0) +#define RBD_FEATURE_STRIPINGV2 (1ULL<<1) +#define RBD_FEATURE_EXCLUSIVE_LOCK (1ULL<<2) +#define RBD_FEATURE_DATA_POOL (1ULL<<7) + #define RBD_FEATURES_ALL (RBD_FEATURE_LAYERING | \ RBD_FEATURE_STRIPINGV2 | \ RBD_FEATURE_EXCLUSIVE_LOCK | \ @@ -499,16 +500,23 @@ static bool rbd_is_lock_owner(struct rbd_device *rbd_dev) return is_lock_owner; } +static ssize_t rbd_supported_features_show(struct bus_type *bus, char *buf) +{ + return sprintf(buf, "0x%llx\n", RBD_FEATURES_SUPPORTED); +} + static BUS_ATTR(add, S_IWUSR, NULL, rbd_add); static BUS_ATTR(remove, S_IWUSR, NULL, rbd_remove); static BUS_ATTR(add_single_major, S_IWUSR, NULL, rbd_add_single_major); static BUS_ATTR(remove_single_major, S_IWUSR, NULL, rbd_remove_single_major); +static BUS_ATTR(supported_features, S_IRUGO, rbd_supported_features_show, NULL); static struct attribute *rbd_bus_attrs[] = { &bus_attr_add.attr, &bus_attr_remove.attr, &bus_attr_add_single_major.attr, &bus_attr_remove_single_major.attr, + &bus_attr_supported_features.attr, NULL, };