From patchwork Tue Jul 2 17:00:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 2813981 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EFDE9BF4A1 for ; Tue, 2 Jul 2013 17:01:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A9C4620186 for ; Tue, 2 Jul 2013 17:01:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 591B72017B for ; Tue, 2 Jul 2013 17:01:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752334Ab3GBRA7 (ORCPT ); Tue, 2 Jul 2013 13:00:59 -0400 Received: from mail-gh0-f173.google.com ([209.85.160.173]:61947 "EHLO mail-gh0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752060Ab3GBRA6 (ORCPT ); Tue, 2 Jul 2013 13:00:58 -0400 Received: by mail-gh0-f173.google.com with SMTP id g16so2556256ghb.32 for ; Tue, 02 Jul 2013 10:00:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=amdN+0T+1EjJXlEl/4J4DFJ4oRquJgO3DZYfHVomBi0=; b=bORyt6W4MThubJiC8XnO90/simyWTWWwFkUAfG3ccn4jQGdyitVkIyj92qe0PQQU4P +aicjWCNzJt1Xv4Mo0hoOqCAi9mFAdNqBqO3y1V22AfPpVhdA0sW3wk9raA2sU/RiHME iE4Ol00ZZPRfthpeh0zIdggBnGNqP/BDRTF7zBZRnRRPGXuaC80hlvvbIkdoB9fOtOLr ZD6PXzmOzSySiwdp+wLJY1WmysniiJpPzdHfE5w61Mv3AjdMjMT/mhUST0llXfM6D4TH wtpFULgtqVjG2PyILGtin6jJ4Og3fgruNp6lGIIZhgIy2bLjk868R+rzt9x10MEPWbWc O23Q== X-Received: by 10.236.145.199 with SMTP id p47mr15065841yhj.235.1372784458150; Tue, 02 Jul 2013 10:00:58 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-107-015-124-230.nc.res.rr.com. [107.15.124.230]) by mx.google.com with ESMTPSA id s65sm41361062yhs.14.2013.07.02.10.00.56 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 02 Jul 2013 10:00:57 -0700 (PDT) From: Jeff Layton To: Trond Myklebust Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, bfields@fieldses.org, Alexander Viro Subject: [PATCH v2] rpc_pipe: set dentry operations at d_alloc time Date: Tue, 2 Jul 2013 13:00:52 -0400 Message-Id: <1372784452-2403-1-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1372122340-28982-1-git-send-email-jlayton@redhat.com> References: <1372122340-28982-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQnzCNHq93il/jTONYYKo56dLGegikZ8Gq2/OK7Eiz+X5XcN0ZkjLy5WnQjrDCD3KiUX2Fid Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Currently the way these get set is a little convoluted. If the dentry is allocated via lookup from userland, then it gets set by simple_lookup. If it gets allocated when the kernel is populating the directory, then it gets set via __rpc_lookup_create_exclusive, which has to check whether they might already be set. Between both of these, this ensures that all dentries have their d_op pointer set. Instead of doing that, just have them set at d_alloc time by pointing sb->s_d_op at them. With that change, we no longer want the lookup op to set them, so we must move to using our own lookup routine. Signed-off-by: Jeff Layton --- net/sunrpc/rpc_pipe.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index a816b3a..ca5ad70d 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c @@ -480,6 +480,23 @@ static const struct dentry_operations rpc_dentry_operations = { .d_delete = rpc_delete_dentry, }; +/* + * Lookup the data. This is trivial - if the dentry didn't already + * exist, we know it is negative. + */ +static struct dentry * +rpc_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) +{ + if (dentry->d_name.len > NAME_MAX) + return ERR_PTR(-ENAMETOOLONG); + d_add(dentry, NULL); + return NULL; +} + +const struct inode_operations rpc_dir_inode_operations = { + .lookup = rpc_lookup, +}; + static struct inode * rpc_get_inode(struct super_block *sb, umode_t mode) { @@ -492,7 +509,7 @@ rpc_get_inode(struct super_block *sb, umode_t mode) switch (mode & S_IFMT) { case S_IFDIR: inode->i_fop = &simple_dir_operations; - inode->i_op = &simple_dir_inode_operations; + inode->i_op = &rpc_dir_inode_operations; inc_nlink(inode); default: break; @@ -666,11 +683,8 @@ static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent, if (!dentry) return ERR_PTR(-ENOMEM); } - if (dentry->d_inode == NULL) { - if (!dentry->d_op) - d_set_d_op(dentry, &rpc_dentry_operations); + if (dentry->d_inode == NULL) return dentry; - } dput(dentry); return ERR_PTR(-EEXIST); } @@ -1117,6 +1131,7 @@ rpc_fill_super(struct super_block *sb, void *data, int silent) sb->s_blocksize_bits = PAGE_CACHE_SHIFT; sb->s_magic = RPCAUTH_GSSMAGIC; sb->s_op = &s_ops; + sb->s_d_op = &rpc_dentry_operations; sb->s_time_gran = 1; inode = rpc_get_inode(sb, S_IFDIR | S_IRUGO | S_IXUGO);