From patchwork Thu Sep 29 15:48:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Gruenbacher X-Patchwork-Id: 9356633 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 9D2D36077B for ; Thu, 29 Sep 2016 15:49:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DC7E29BAB for ; Thu, 29 Sep 2016 15:49:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8205B29BB1; Thu, 29 Sep 2016 15:49:35 +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 00D1E29BAB for ; Thu, 29 Sep 2016 15:49:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755547AbcI2Ptd (ORCPT ); Thu, 29 Sep 2016 11:49:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53102 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755085AbcI2Ptc (ORCPT ); Thu, 29 Sep 2016 11:49:32 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2807290E7E; Thu, 29 Sep 2016 15:49:32 +0000 (UTC) Received: from nux.redhat.com (vpn1-4-153.ams2.redhat.com [10.36.4.153]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8TFmkwH012513; Thu, 29 Sep 2016 11:49:27 -0400 From: Andreas Gruenbacher To: Alexander Viro Cc: Andreas Gruenbacher , linux-fsdevel@vger.kernel.org, Tyler Hicks , ecryptfs@vger.kernel.org, linux-unionfs@vger.kernel.org, David Howells , Serge Hallyn , Dmitry Kasatkin , linux-ima-devel@lists.sourceforge.net, Paul Moore , Stephen Smalley , Eric Paris , Casey Schaufler , Oleg Drokin , Andreas Dilger Subject: [PATCH v6 08/16] lustre: Switch to generic xattr handlers Date: Thu, 29 Sep 2016 17:48:37 +0200 Message-Id: <1475164125-28635-9-git-send-email-agruenba@redhat.com> In-Reply-To: <1475164125-28635-1-git-send-email-agruenba@redhat.com> References: <1475164125-28635-1-git-send-email-agruenba@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 29 Sep 2016 15:49:32 +0000 (UTC) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Andreas Gruenbacher --- drivers/staging/lustre/lustre/llite/file.c | 3 -- .../staging/lustre/lustre/llite/llite_internal.h | 7 ++-- drivers/staging/lustre/lustre/llite/llite_lib.c | 1 + drivers/staging/lustre/lustre/llite/namei.c | 6 ---- drivers/staging/lustre/lustre/llite/symlink.c | 3 -- drivers/staging/lustre/lustre/llite/xattr.c | 42 +++++++++++++++++++--- 6 files changed, 40 insertions(+), 22 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 57281b9..e8c81e8 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -3213,10 +3213,7 @@ const struct inode_operations ll_file_inode_operations = { .setattr = ll_setattr, .getattr = ll_getattr, .permission = ll_inode_permission, - .setxattr = ll_setxattr, - .getxattr = ll_getxattr, .listxattr = ll_listxattr, - .removexattr = ll_removexattr, .fiemap = ll_fiemap, .get_acl = ll_get_acl, }; diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 4d6d589..8695aca 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -933,12 +933,9 @@ static inline __u64 ll_file_maxbytes(struct inode *inode) } /* llite/xattr.c */ -int ll_setxattr(struct dentry *dentry, struct inode *inode, - const char *name, const void *value, size_t size, int flags); -ssize_t ll_getxattr(struct dentry *dentry, struct inode *inode, - const char *name, void *buffer, size_t size); +struct xattr_handler; +extern const struct xattr_handler *lustre_xattr_handlers[]; ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size); -int ll_removexattr(struct dentry *dentry, const char *name); /** * Common IO arguments for various VFS I/O interfaces. diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 546063e..81f4fe9 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -421,6 +421,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, #if THREAD_SIZE >= 8192 /*b=17630*/ sb->s_export_op = &lustre_export_operations; #endif + sb->s_xattr = lustre_xattr_handlers; /* make root inode * XXX: move this to after cbd setup? diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 2c4dc69..f9822403 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -1106,10 +1106,7 @@ const struct inode_operations ll_dir_inode_operations = { .setattr = ll_setattr, .getattr = ll_getattr, .permission = ll_inode_permission, - .setxattr = ll_setxattr, - .getxattr = ll_getxattr, .listxattr = ll_listxattr, - .removexattr = ll_removexattr, .get_acl = ll_get_acl, }; @@ -1117,9 +1114,6 @@ const struct inode_operations ll_special_inode_operations = { .setattr = ll_setattr, .getattr = ll_getattr, .permission = ll_inode_permission, - .setxattr = ll_setxattr, - .getxattr = ll_getxattr, .listxattr = ll_listxattr, - .removexattr = ll_removexattr, .get_acl = ll_get_acl, }; diff --git a/drivers/staging/lustre/lustre/llite/symlink.c b/drivers/staging/lustre/lustre/llite/symlink.c index 8c8bdfe..d82dab2 100644 --- a/drivers/staging/lustre/lustre/llite/symlink.c +++ b/drivers/staging/lustre/lustre/llite/symlink.c @@ -155,8 +155,5 @@ const struct inode_operations ll_fast_symlink_inode_operations = { .get_link = ll_get_link, .getattr = ll_getattr, .permission = ll_inode_permission, - .setxattr = ll_setxattr, - .getxattr = ll_getxattr, .listxattr = ll_listxattr, - .removexattr = ll_removexattr, }; diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index 98303cf..f43f523 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -34,6 +34,7 @@ #include #include #include +#include #define DEBUG_SUBSYSTEM S_LLITE @@ -149,8 +150,9 @@ int ll_setxattr_common(struct inode *inode, const char *name, return 0; } -int ll_setxattr(struct dentry *dentry, struct inode *inode, - const char *name, const void *value, size_t size, int flags) +static int ll_setxattr(struct dentry *dentry, struct inode *inode, + const char *name, const void *value, size_t size, + int flags) { LASSERT(inode); LASSERT(name); @@ -202,7 +204,7 @@ int ll_setxattr(struct dentry *dentry, struct inode *inode, OBD_MD_FLXATTR); } -int ll_removexattr(struct dentry *dentry, const char *name) +static int ll_removexattr(struct dentry *dentry, const char *name) { struct inode *inode = d_inode(dentry); @@ -351,8 +353,8 @@ out: return rc; } -ssize_t ll_getxattr(struct dentry *dentry, struct inode *inode, - const char *name, void *buffer, size_t size) +static ssize_t ll_getxattr(struct dentry *dentry, struct inode *inode, + const char *name, void *buffer, size_t size) { LASSERT(inode); LASSERT(name); @@ -518,3 +520,33 @@ out: return rc; } + +static int lustre_xattr_get(const struct xattr_handler *handler, + struct dentry *dentry, struct inode *inode, + const char *name, void *buffer, size_t size) +{ + return ll_getxattr(dentry, inode, name, buffer, size); +} + +static int lustre_xattr_set(const struct xattr_handler *handler, + struct dentry *dentry, struct inode *inode, + const char *name, const void *value, size_t size, + int flags) +{ + if (!value) { + BUG_ON(flags != XATTR_REPLACE); + return ll_removexattr(dentry, name); + } + return ll_setxattr(dentry, inode, name, value, size, flags); +} + +const struct xattr_handler lustre_xattr_handler = { + .prefix = "", /* match anything */ + .get = lustre_xattr_get, + .set = lustre_xattr_set, +}; + +const struct xattr_handler *lustre_xattr_handlers[] = { + &lustre_xattr_handler, + NULL +};