[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1447801246-24588-8-git-send-email-viro@ZenIV.linux.org.uk>
Date: Tue, 17 Nov 2015 23:00:44 +0000
From: Al Viro <viro@...IV.linux.org.uk>
To: linux-kernel@...r.kernel.org
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Neil Brown <neilb@...e.de>, linux-fsdevel@...r.kernel.org
Subject: [PATCH 08/10] teach page_get_link() to work in RCU mode
From: Al Viro <viro@...iv.linux.org.uk>
more or less along the lines of Neil's patchset, sans the insanity
around kmap().
Signed-off-by: Al Viro <viro@...iv.linux.org.uk>
---
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists