From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zeniv.linux.org.uk ([195.92.253.2]:54384 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754953AbbKQXAs (ORCPT ); Tue, 17 Nov 2015 18:00:48 -0500 From: Al Viro To: linux-kernel@vger.kernel.org Cc: Linus Torvalds , Neil Brown , linux-fsdevel@vger.kernel.org Subject: [PATCH 08/10] teach page_get_link() to work in RCU mode Date: Tue, 17 Nov 2015 23:00:44 +0000 Message-Id: <1447801246-24588-8-git-send-email-viro@ZenIV.linux.org.uk> In-Reply-To: <20151117225752.GZ22011@ZenIV.linux.org.uk> References: <20151117225752.GZ22011@ZenIV.linux.org.uk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: From: Al Viro more or less along the lines of Neil's patchset, sans the insanity around kmap(). Signed-off-by: Al Viro --- fs/namei.c | 19 +++++++++++++------ fs/proc/self.c | 2 +- fs/proc/thread_self.c | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 089c37f..76cc4a2 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -4534,12 +4534,19 @@ const char *page_get_link(struct dentry *dentry, struct inode *inode, struct page *page; struct address_space *mapping = inode->i_mapping; - if (!dentry) - return ERR_PTR(-ECHILD); - - page = read_mapping_page(mapping, 0, NULL); - if (IS_ERR(page)) - return (char*)page; + if (!dentry) { + page = find_get_page(mapping, 0); + if (!page) + return ERR_PTR(-ECHILD); + if (!PageUptodate(page)) { + put_page(page); + return ERR_PTR(-ECHILD); + } + } else { + page = read_mapping_page(mapping, 0, NULL); + if (IS_ERR(page)) + return (char*)page; + } *cookie = page; BUG_ON(mapping_gfp_mask(mapping) & __GFP_HIGHMEM); kaddr = page_address(page); diff --git a/fs/proc/self.c b/fs/proc/self.c index bc599fb..9dd0ae6 100644 --- a/fs/proc/self.c +++ b/fs/proc/self.c @@ -21,7 +21,7 @@ static int proc_self_readlink(struct dentry *dentry, char __user *buffer, static const char *proc_self_get_link(struct dentry *dentry, struct inode *inode, void **cookie) { - struct pid_namespace *ns = dentry->d_sb->s_fs_info; + struct pid_namespace *ns = inode->i_sb->s_fs_info; pid_t tgid = task_tgid_nr_ns(current, ns); char *name; diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c index 1c78507..50eef6f 100644 --- a/fs/proc/thread_self.c +++ b/fs/proc/thread_self.c @@ -22,7 +22,7 @@ static int proc_thread_self_readlink(struct dentry *dentry, char __user *buffer, static const char *proc_thread_self_get_link(struct dentry *dentry, struct inode *inode, void **cookie) { - struct pid_namespace *ns = dentry->d_sb->s_fs_info; + struct pid_namespace *ns = inode->i_sb->s_fs_info; pid_t tgid = task_tgid_nr_ns(current, ns); pid_t pid = task_pid_nr_ns(current, ns); char *name; -- 2.1.4