lkml.org 
[lkml]   [2015]   [Nov]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 08/10] teach page_get_link() to work in RCU mode
Date
From: Al Viro <viro@zeniv.linux.org.uk>

more or less along the lines of Neil's patchset, sans the insanity
around kmap().

Signed-off-by: Al Viro <viro@zeniv.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


\
 
 \ /
  Last update: 2015-11-18 00:21    [W:0.077 / U:3.356 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site