From patchwork Thu Jul 21 06:49:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venky Shankar X-Patchwork-Id: 9240977 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 1F6576077C for ; Thu, 21 Jul 2016 06:49:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1188A26253 for ; Thu, 21 Jul 2016 06:49:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06192279E0; Thu, 21 Jul 2016 06:49: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.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 8A02326253 for ; Thu, 21 Jul 2016 06:49:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751150AbcGUGt1 (ORCPT ); Thu, 21 Jul 2016 02:49:27 -0400 Received: from mail-pf0-f178.google.com ([209.85.192.178]:36073 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750917AbcGUGtZ (ORCPT ); Thu, 21 Jul 2016 02:49:25 -0400 Received: by mail-pf0-f178.google.com with SMTP id h186so27199862pfg.3 for ; Wed, 20 Jul 2016 23:49:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=vSGa4KKXt+7G4iThrk1GDIgHkRmPASZcJC1wPlh7DPU=; b=YmsOLjF710pM6VTNKiw4x5tvlDuMAxXCRLKTWkpke/SqSq6DHSxz8UJ86jpT6q42pj l/PtNLqxKc2X05EQEfdSJmKhy+o99JJ/FeitInBUHTMxmj2WMqhmCNdeZQdtqD0Ns2J8 5Zw1scnmC1BxJPj93+ksYv8ZrPK4ZBiN7zj2p/13AkR5wZdA8AyGEXQnIy+ZEbwOifyD x7Co4wn++h/EZcJjtwfymLkMMg5oQtpVEn3In33AFeuULpp0IzYuh/rnITfbobqUpONE yzlsWflgkQ3+lisBwPhDOgSh1SRj/igKcfYxs6fLZIbbjaCVDIusXqUH9eBa91ScbAsm F+rA== X-Gm-Message-State: ALyK8tIM0zne6bzvc7nT+gFkaltnPREotdjcbXk+zaQeEVQVJcNDRnXUyBzMANhoQ9GkrPt9 X-Received: by 10.98.131.8 with SMTP id h8mr70784522pfe.124.1469083764499; Wed, 20 Jul 2016 23:49:24 -0700 (PDT) Received: from octopus.ceph.octopus.net ([117.202.96.145]) by smtp.gmail.com with ESMTPSA id n9sm8516952paz.13.2016.07.20.23.49.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Jul 2016 23:49:23 -0700 (PDT) From: Venky Shankar To: ceph-devel@vger.kernel.org Cc: zyan@redhat.com Subject: [RFC 1/2] ceph: introduce 'ceph.all' virtual xattr Date: Thu, 21 Jul 2016 12:19:17 +0530 Message-Id: <1469083758-2153-1-git-send-email-vshankar@redhat.com> X-Mailer: git-send-email 2.1.4 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 As of now listing extended attributes result in ceph dump all of it's internal xattrs thereby confusing tools such as rsync and the likes. This functionality would be removed in the subsequent patch, but there needs to be a way to examine ceph's internal xattr. Remembering all internal xattrs is cumbersome and error prone, so, we provide a virtual xattr to fetch a list of ceph's internal xattr, obviously excluding itself. Signed-off-by: Venky Shankar --- fs/ceph/xattr.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c index 4870b29..d0f59cb 100644 --- a/fs/ceph/xattr.c +++ b/fs/ceph/xattr.c @@ -204,7 +204,45 @@ static size_t ceph_vxattrcb_dir_rctime(struct ceph_inode_info *ci, char *val, (long)ci->i_rctime.tv_nsec); } +static struct ceph_vxattr *ceph_inode_vxattrs(struct inode *inode); +static size_t ceph_vxattrs_name_size(struct ceph_vxattr *vxattrs); +/* list all ceph internal xattrs */ +static size_t ceph_vxattrcb_list_all(struct ceph_inode_info *ci, char *val, + size_t size) +{ + struct inode *inode = &ci->vfs_inode; + struct ceph_vxattr *vxattr; + struct ceph_vxattr *vxattrs = ceph_inode_vxattrs(inode); + u32 len, namelen; + int err = 0; + + if (!vxattrs) + goto out; + + namelen = ceph_vxattrs_name_size(vxattrs); + + err = -ERANGE; + if (size && (namelen > size)) + goto out; + err = namelen; + if (size == 0) + goto out; + + /* fill up buffer with virtual xattrs */ + for (err = 0, vxattr = vxattrs; vxattr->name; vxattr++) { + if (!vxattr->hidden && !(vxattr->exists_cb + && !vxattr->exists_cb(ci))) { + len = snprintf(val + err, size - err, "%s", vxattr->name); + err += len + 1; + } + } + + out: + return err; +} + +#define CEPH_XATTR_LIST_INTERNAL XATTR_CEPH_PREFIX"all" #define CEPH_XATTR_NAME(_type, _name) XATTR_CEPH_PREFIX #_type "." #_name #define CEPH_XATTR_NAME2(_type, _name, _name2) \ XATTR_CEPH_PREFIX #_type "." #_name "." #_name2 @@ -237,6 +275,14 @@ static struct ceph_vxattr ceph_dir_vxattrs[] = { .hidden = true, .exists_cb = ceph_vxattrcb_layout_exists, }, + { + .name = CEPH_XATTR_LIST_INTERNAL, + .name_size = sizeof(CEPH_XATTR_LIST_INTERNAL), + .getxattr_cb = ceph_vxattrcb_list_all, + .readonly = true, + .hidden = true, + .exists_cb = NULL, + }, XATTR_LAYOUT_FIELD(dir, layout, stripe_unit), XATTR_LAYOUT_FIELD(dir, layout, stripe_count), XATTR_LAYOUT_FIELD(dir, layout, object_size), @@ -264,6 +310,14 @@ static struct ceph_vxattr ceph_file_vxattrs[] = { .hidden = true, .exists_cb = ceph_vxattrcb_layout_exists, }, + { + .name = CEPH_XATTR_LIST_INTERNAL, + .name_size = sizeof(CEPH_XATTR_LIST_INTERNAL), + .getxattr_cb = ceph_vxattrcb_list_all, + .readonly = true, + .hidden = true, + .exists_cb = NULL, + }, XATTR_LAYOUT_FIELD(file, layout, stripe_unit), XATTR_LAYOUT_FIELD(file, layout, stripe_count), XATTR_LAYOUT_FIELD(file, layout, object_size),