From patchwork Mon Mar 23 02:37:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 6068831 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 3E98A9F2A9 for ; Mon, 23 Mar 2015 02:40:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 743DE201FE for ; Mon, 23 Mar 2015 02:40:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B17620219 for ; Mon, 23 Mar 2015 02:40:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932092AbbCWCkF (ORCPT ); Sun, 22 Mar 2015 22:40:05 -0400 Received: from cantor2.suse.de ([195.135.220.15]:34563 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932084AbbCWCkB (ORCPT ); Sun, 22 Mar 2015 22:40:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E622EACF9; Mon, 23 Mar 2015 02:39:59 +0000 (UTC) From: NeilBrown To: Al Viro Date: Mon, 23 Mar 2015 13:37:40 +1100 Subject: [PATCH 20/20] NFS: support LOOKUP_RCU in nfs_follow_link. Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Message-ID: <20150323023740.8161.58517.stgit@notabene.brown> In-Reply-To: <20150323023258.8161.32467.stgit@notabene.brown> References: <20150323023258.8161.32467.stgit@notabene.brown> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 If the inode is valid and the page has been read in, then we can follow a link in RCU-walk. Signed-off-by: NeilBrown --- fs/nfs/inode.c | 21 +++++++++++++++++++++ fs/nfs/symlink.c | 20 ++++++++++++++++++-- include/linux/nfs_fs.h | 1 + 3 files changed, 40 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index d42dff6d5e98..430899a789c6 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1162,6 +1162,27 @@ int nfs_revalidate_mapping_protected(struct inode *inode, struct address_space * return __nfs_revalidate_mapping(inode, mapping, true); } +int nfs_revalidate_mapping_rcu(struct inode *inode) +{ + struct nfs_inode *nfsi = NFS_I(inode); + unsigned long *bitlock = &nfsi->flags; + int ret = 0; + + if (IS_SWAPFILE(inode)) + goto out; + if (nfs_mapping_need_revalidate_inode(inode)) { + ret = -ECHILD; + goto out; + } + spin_lock(&inode->i_lock); + if (test_bit(NFS_INO_INVALIDATING, bitlock) || + (nfsi->cache_validity & NFS_INO_INVALID_DATA)) + ret = -ECHILD; + spin_unlock(&inode->i_lock); +out: + return ret; +} + static unsigned long nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr) { struct nfs_inode *nfsi = NFS_I(inode); diff --git a/fs/nfs/symlink.c b/fs/nfs/symlink.c index 32bbac1bb4bc..1c0a94b3d12e 100644 --- a/fs/nfs/symlink.c +++ b/fs/nfs/symlink.c @@ -49,8 +49,24 @@ static void *nfs_follow_link(struct dentry *dentry, struct inode *inode, struct page *page; void *err; - if (flags & LOOKUP_RCU) - return ERR_PTR(-ECHILD); + if (flags & LOOKUP_RCU) { + err = ERR_PTR(nfs_revalidate_mapping_rcu(inode)); + if (err) + goto read_failed; + page = find_get_page(inode->i_mapping, 0); + if (page && + (!PageUptodate(page) || PageHighMem(page))) { + put_page(page); + page = NULL; + } + if (!page) { + err = ERR_PTR(-ECHILD); + goto read_failed; + } + nd_set_link(page_address(page)); + page = (void *)((unsigned long)page | 1); + return page; + } err = ERR_PTR(nfs_revalidate_mapping(inode, inode->i_mapping)); if (err) goto read_failed; diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index b01ccf371fdc..2eea59456ebb 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -357,6 +357,7 @@ extern int nfs_revalidate_inode_rcu(struct nfs_server *server, struct inode *ino extern int __nfs_revalidate_inode(struct nfs_server *, struct inode *); extern int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping); extern int nfs_revalidate_mapping_protected(struct inode *inode, struct address_space *mapping); +extern int nfs_revalidate_mapping_rcu(struct inode *inode); extern int nfs_setattr(struct dentry *, struct iattr *); extern void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr, struct nfs_fattr *); extern void nfs_setsecurity(struct inode *inode, struct nfs_fattr *fattr,