lkml.org 
[lkml]   [2015]   [Mar]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
Subject[PATCH 5/9] VFS/namei: enhance follow_link to support RCU-walk.
If LOOKUP_RCU is set, follow_link will not take/drop reference counts.

Replace cond_resched() with _cond_resched() as the latter
is a no-op if rcu_read_lock() is held while the former will
give a warning in that case.

Signed-off-by: NeilBrown <neilb@suse.de>
---
fs/namei.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 5814d1b2daab..4ddbc1ef5726 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -883,7 +883,8 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
if (unlikely(current->total_link_count >= 40))
goto out_put_nd_path;

- cond_resched();
+ /* If rcu_read_locked(), this will not resched, and will not warn */
+ _cond_resched();
current->total_link_count++;

if (nd->flags & LOOKUP_RCU) {
@@ -913,11 +914,17 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
return PTR_ERR(s);
}
if (*s == '/') {
- if (!nd->root.mnt)
- set_root(nd);
- path_put(&nd->path);
- nd->path = nd->root;
- path_get(&nd->root);
+ if (nd->flags & LOOKUP_RCU) {
+ if (!nd->root.mnt)
+ set_root_rcu(nd);
+ nd->path = nd->root;
+ } else {
+ if (!nd->root.mnt)
+ set_root(nd);
+ path_put(&nd->path);
+ nd->path = nd->root;
+ path_get(&nd->root);
+ }
nd->flags |= LOOKUP_JUMPED;
}
nd->inode = nd->path.dentry->d_inode;



\
 
 \ /
  Last update: 2015-03-05 06:41    [W:0.111 / U:0.376 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site