From patchwork Thu Aug 20 18:19:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Andreas_Gr=C3=BCnbacher?= X-Patchwork-Id: 7046471 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6D5C99F372 for ; Thu, 20 Aug 2015 18:23:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 564E3204EC for ; Thu, 20 Aug 2015 18:23:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 29BD720439 for ; Thu, 20 Aug 2015 18:23:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752327AbbHTSXC (ORCPT ); Thu, 20 Aug 2015 14:23:02 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:35253 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752309AbbHTSXA (ORCPT ); Thu, 20 Aug 2015 14:23:00 -0400 Received: by wicne3 with SMTP id ne3so153032708wic.0; Thu, 20 Aug 2015 11:22:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yPR6zqwCj1fq4aNuAsp1Oi8l5XKSbSHm4JFmrxl8M2c=; b=xZiaPieRecAo+mG12WSXxmBG64Hny8z0sSq/2jJTnyxZkT5fHDuVGFf0xHWGQuqSMH aLtLHAaypMzqUHDiYG+3I4udPv6LbIP/KPJ3uDjn4KKz1ZgwOrn76F+1MSI2VMv5+CCQ R3ml+jkocnx6DVTP8b1hCjh1iIUfzDM3intki14N4ewFUw6XT98P5U97NJP4qdoBQvUy GNrX0T6CRwomGpdF9spjRtqkQBsB3jgNpn2yS/cThKVEtlrHu3S2iTeYQKIKm5NHPnbz sJREfbRNnHKtTuzVU1YPv4vaRpNjuj2KK5xKz35c3qDxhZ/a/vJ8bVf20HNfo6dlxR3G Kijw== X-Received: by 10.180.80.195 with SMTP id t3mr4273609wix.15.1440094978832; Thu, 20 Aug 2015 11:22:58 -0700 (PDT) Received: from nuc.home.com (p549817FE.dip0.t-ipconnect.de. [84.152.23.254]) by smtp.gmail.com with ESMTPSA id ma4sm6598334wjb.38.2015.08.20.11.22.22 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2015 11:22:58 -0700 (PDT) From: Andreas Gruenbacher X-Google-Original-From: Andreas Gruenbacher To: Alexander Viro , Christoph Hellwig , Eric Paris , "Aneesh Kumar K.V" , linux-fsdevel@vger.kernel.org, David Quigley , "J. Bruce Fields" Cc: linux-security-module@vger.kernel.org, cluster-devel@redhat.com Subject: [RFC 07/11] 9p: Stop using the generic xattr_handler infrastructure Date: Thu, 20 Aug 2015 20:19:54 +0200 Message-Id: <1440094798-1411-8-git-send-email-agruenba@redhat.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1440094798-1411-1-git-send-email-agruenba@redhat.com> References: <1440094798-1411-1-git-send-email-agruenba@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Of all the file systems that use the generic xattr handler infrastructure, 9p is the only one that needs dentries inside the xattr file system code. Open code the xattr handling code in 9p so that we can then convert the generic code to pass down inodes instead of dentries; this actually takes only little additional code. Signed-off-by: Andreas Gruenbacher --- fs/9p/acl.c | 12 ++++++------ fs/9p/vfs_super.c | 5 ++--- fs/9p/xattr.c | 46 ++++++++++++++++++++++++++++++++++++++-------- fs/9p/xattr.h | 15 ++++++++++++--- 4 files changed, 58 insertions(+), 20 deletions(-) diff --git a/fs/9p/acl.c b/fs/9p/acl.c index 5325304..d6a02e0 100644 --- a/fs/9p/acl.c +++ b/fs/9p/acl.c @@ -212,9 +212,9 @@ int v9fs_acl_mode(struct inode *dir, umode_t *modep, return 0; } -static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name, - void *buffer, size_t size, - const struct xattr_handler *handler) +static ssize_t v9fs_xattr_get_acl(struct dentry *dentry, const char *name, + void *buffer, size_t size, + const struct v9fs_xattr_handler *handler) { struct v9fs_session_info *v9ses; struct posix_acl *acl; @@ -243,7 +243,7 @@ static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name, static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, size_t size, - int flags, const struct xattr_handler *handler) + int flags, const struct v9fs_xattr_handler *handler) { int retval; struct posix_acl *acl; @@ -327,14 +327,14 @@ err_out: return retval; } -const struct xattr_handler v9fs_xattr_acl_access_handler = { +const struct v9fs_xattr_handler v9fs_xattr_acl_access_handler = { .prefix = POSIX_ACL_XATTR_ACCESS, .flags = ACL_TYPE_ACCESS, .get = v9fs_xattr_get_acl, .set = v9fs_xattr_set_acl, }; -const struct xattr_handler v9fs_xattr_acl_default_handler = { +const struct v9fs_xattr_handler v9fs_xattr_acl_default_handler = { .prefix = POSIX_ACL_XATTR_DEFAULT, .flags = ACL_TYPE_DEFAULT, .get = v9fs_xattr_get_acl, diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index bf495ce..7914544 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c @@ -80,10 +80,9 @@ v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses, sb->s_blocksize_bits = fls(v9ses->maxdata - 1); sb->s_blocksize = 1 << sb->s_blocksize_bits; sb->s_magic = V9FS_MAGIC; - if (v9fs_proto_dotl(v9ses)) { + if (v9fs_proto_dotl(v9ses)) sb->s_op = &v9fs_super_ops_dotl; - sb->s_xattr = v9fs_xattr_handlers; - } else + else sb->s_op = &v9fs_super_ops; sb->s_bdi = &v9ses->bdi; if (v9ses->cache) diff --git a/fs/9p/xattr.c b/fs/9p/xattr.c index 00b28f4..64ffd00 100644 --- a/fs/9p/xattr.c +++ b/fs/9p/xattr.c @@ -132,14 +132,44 @@ int v9fs_fid_xattr_set(struct p9_fid *fid, const char *name, return retval; } +ssize_t v9fs_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size) +{ + const struct v9fs_xattr_handler **handlers = v9fs_xattr_handlers; + + for (; *handlers != NULL; handlers++) { + const struct v9fs_xattr_handler *handler = *handlers; + const char *suffix = strcmp_prefix(name, handler->prefix); + + if (suffix) + return handler->get(dentry, suffix, buffer, size, handler); + } + return -EOPNOTSUPP; +} + +int v9fs_setxattr(struct dentry *dentry, const char *name, const void *value, + size_t size, int flags) +{ + const struct v9fs_xattr_handler **handlers = v9fs_xattr_handlers; + + for (; *handlers != NULL; handlers++) { + const struct v9fs_xattr_handler *handler = *handlers; + const char *suffix = strcmp_prefix(name, handler->prefix); + + if (suffix) + return handler->set(dentry, name, value, size, flags, + handler); + } + return -EOPNOTSUPP; +} + ssize_t v9fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) { return v9fs_xattr_get(dentry, NULL, buffer, buffer_size); } -static int v9fs_xattr_handler_get(struct dentry *dentry, const char *name, - void *buffer, size_t size, - const struct xattr_handler *handler) +static ssize_t v9fs_xattr_handler_get(struct dentry *dentry, const char *name, + void *buffer, size_t size, + const struct v9fs_xattr_handler *handler) { int prefix_len = strlen(handler->prefix); @@ -150,7 +180,7 @@ static int v9fs_xattr_handler_get(struct dentry *dentry, const char *name, static int v9fs_xattr_handler_set(struct dentry *dentry, const char *name, const void *value, size_t size, int flags, - const struct xattr_handler *handler) + const struct v9fs_xattr_handler *handler) { int prefix_len = strlen(handler->prefix); @@ -159,27 +189,27 @@ static int v9fs_xattr_handler_set(struct dentry *dentry, const char *name, return v9fs_xattr_set(dentry, name - prefix_len, value, size, flags); } -static struct xattr_handler v9fs_xattr_user_handler = { +static struct v9fs_xattr_handler v9fs_xattr_user_handler = { .prefix = XATTR_USER_PREFIX, .get = v9fs_xattr_handler_get, .set = v9fs_xattr_handler_set, }; -static struct xattr_handler v9fs_xattr_trusted_handler = { +static struct v9fs_xattr_handler v9fs_xattr_trusted_handler = { .prefix = XATTR_TRUSTED_PREFIX, .get = v9fs_xattr_handler_get, .set = v9fs_xattr_handler_set, }; #ifdef CONFIG_9P_FS_SECURITY -static struct xattr_handler v9fs_xattr_security_handler = { +static struct v9fs_xattr_handler v9fs_xattr_security_handler = { .prefix = XATTR_SECURITY_PREFIX, .get = v9fs_xattr_handler_get, .set = v9fs_xattr_handler_set, }; #endif -const struct xattr_handler *v9fs_xattr_handlers[] = { +const struct v9fs_xattr_handler *v9fs_xattr_handlers[] = { &v9fs_xattr_user_handler, &v9fs_xattr_trusted_handler, #ifdef CONFIG_9P_FS_POSIX_ACL diff --git a/fs/9p/xattr.h b/fs/9p/xattr.h index c63c3be..488ad6d 100644 --- a/fs/9p/xattr.h +++ b/fs/9p/xattr.h @@ -18,9 +18,18 @@ #include #include -extern const struct xattr_handler *v9fs_xattr_handlers[]; -extern const struct xattr_handler v9fs_xattr_acl_access_handler; -extern const struct xattr_handler v9fs_xattr_acl_default_handler; +struct v9fs_xattr_handler { + const char *prefix; + int flags; + ssize_t (*get)(struct dentry *, const char *, void *, size_t, + const struct v9fs_xattr_handler *); + int (*set)(struct dentry *, const char *, const void *, size_t, int, + const struct v9fs_xattr_handler *); +}; + +extern const struct v9fs_xattr_handler *v9fs_xattr_handlers[]; +extern const struct v9fs_xattr_handler v9fs_xattr_acl_access_handler; +extern const struct v9fs_xattr_handler v9fs_xattr_acl_default_handler; extern ssize_t v9fs_fid_xattr_get(struct p9_fid *, const char *, void *, size_t);