@@ -303,7 +303,7 @@ xfs_readlink_by_handle(
goto out_dput;
}
- error = xfs_readlink(XFS_I(dentry->d_inode), link);
+ error = xfs_readlink(XFS_I(dentry->d_inode), link, 0);
if (error)
goto out_kfree;
error = readlink_copy(hreq->ohandle, olen, link);
@@ -415,15 +415,20 @@ xfs_vn_follow_link(
struct nameidata *nd)
{
char *link;
- int error = -ENOMEM;
+ int error;
- if (nd_is_rcu(nd))
- return ERR_PTR(-ECHILD);
- link = kmalloc(MAXPATHLEN+1, GFP_KERNEL);
+ if (nd_is_rcu(nd)) {
+ error = -ECHILD;
+ link = kmalloc(MAXPATHLEN+1, GFP_ATOMIC);
+ } else {
+ error = -ENOMEM;
+ link = kmalloc(MAXPATHLEN+1, GFP_KERNEL);
+ }
if (!link)
goto out_err;
- error = xfs_readlink(XFS_I(dentry->d_inode), link);
+ error = xfs_readlink(XFS_I(dentry->d_inode), link,
+ nd_is_rcu(nd));
if (unlikely(error))
goto out_kfree;
@@ -123,7 +123,8 @@ xfs_readlink_bmap(
int
xfs_readlink(
struct xfs_inode *ip,
- char *link)
+ char *link,
+ int rcu)
{
struct xfs_mount *mp = ip->i_mount;
xfs_fsize_t pathlen;
@@ -134,7 +135,11 @@ xfs_readlink(
if (XFS_FORCED_SHUTDOWN(mp))
return -EIO;
- xfs_ilock(ip, XFS_ILOCK_SHARED);
+ if (rcu) {
+ if (xfs_ilock_nowait(ip, XFS_ILOCK_SHARED) == 0)
+ return -ECHILD;
+ } else
+ xfs_ilock(ip, XFS_ILOCK_SHARED);
pathlen = ip->i_d.di_size;
if (!pathlen)
@@ -153,6 +158,8 @@ xfs_readlink(
if (ip->i_df.if_flags & XFS_IFINLINE) {
memcpy(link, ip->i_df.if_u1.if_data, pathlen);
link[pathlen] = '\0';
+ } else if (rcu) {
+ error = -ECHILD;
} else {
error = xfs_readlink_bmap(ip, link);
}
@@ -21,7 +21,7 @@
int xfs_symlink(struct xfs_inode *dp, struct xfs_name *link_name,
const char *target_path, umode_t mode, struct xfs_inode **ipp);
-int xfs_readlink(struct xfs_inode *ip, char *link);
+int xfs_readlink(struct xfs_inode *ip, char *link, int rcu);
int xfs_inactive_symlink(struct xfs_inode *ip);
#endif /* __XFS_SYMLINK_H */
If LOOKUP_RCU is set, use GFP_ATOMIC rather than GFP_KERNEL, and try to get the ilock without blocking. When these succeed, follow_link() can succeed without dropping out of RCU-walk. Signed-off-by: NeilBrown <neilb@suse.de> --- fs/xfs/xfs_ioctl.c | 2 +- fs/xfs/xfs_iops.c | 15 ++++++++++----- fs/xfs/xfs_symlink.c | 11 +++++++++-- fs/xfs/xfs_symlink.h | 2 +- 4 files changed, 21 insertions(+), 9 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