diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-06-08 15:59:33 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-07-14 08:35:15 -0400 |
commit | ee3efa91e240f513898050ef305a49a653c8ed90 (patch) | |
tree | d6cf061b3636f3c5f9840c09f3ed6ccd625cff22 /fs/dcache.c | |
parent | e77fb7cef87856d9d35f2f4d617d0b97148ee7c2 (diff) |
__d_unalias() should refuse to move mountpoints
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/dcache.c')
-rw-r--r-- | fs/dcache.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/dcache.c b/fs/dcache.c index 015586f1ffc6..8086636bf796 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -2387,14 +2387,13 @@ static struct dentry *__d_unalias(struct inode *inode, | |||
2387 | struct dentry *dentry, struct dentry *alias) | 2387 | struct dentry *dentry, struct dentry *alias) |
2388 | { | 2388 | { |
2389 | struct mutex *m1 = NULL, *m2 = NULL; | 2389 | struct mutex *m1 = NULL, *m2 = NULL; |
2390 | struct dentry *ret; | 2390 | struct dentry *ret = ERR_PTR(-EBUSY); |
2391 | 2391 | ||
2392 | /* If alias and dentry share a parent, then no extra locks required */ | 2392 | /* If alias and dentry share a parent, then no extra locks required */ |
2393 | if (alias->d_parent == dentry->d_parent) | 2393 | if (alias->d_parent == dentry->d_parent) |
2394 | goto out_unalias; | 2394 | goto out_unalias; |
2395 | 2395 | ||
2396 | /* See lock_rename() */ | 2396 | /* See lock_rename() */ |
2397 | ret = ERR_PTR(-EBUSY); | ||
2398 | if (!mutex_trylock(&dentry->d_sb->s_vfs_rename_mutex)) | 2397 | if (!mutex_trylock(&dentry->d_sb->s_vfs_rename_mutex)) |
2399 | goto out_err; | 2398 | goto out_err; |
2400 | m1 = &dentry->d_sb->s_vfs_rename_mutex; | 2399 | m1 = &dentry->d_sb->s_vfs_rename_mutex; |
@@ -2402,8 +2401,10 @@ static struct dentry *__d_unalias(struct inode *inode, | |||
2402 | goto out_err; | 2401 | goto out_err; |
2403 | m2 = &alias->d_parent->d_inode->i_mutex; | 2402 | m2 = &alias->d_parent->d_inode->i_mutex; |
2404 | out_unalias: | 2403 | out_unalias: |
2405 | __d_move(alias, dentry); | 2404 | if (likely(!d_mountpoint(alias))) { |
2406 | ret = alias; | 2405 | __d_move(alias, dentry); |
2406 | ret = alias; | ||
2407 | } | ||
2407 | out_err: | 2408 | out_err: |
2408 | spin_unlock(&inode->i_lock); | 2409 | spin_unlock(&inode->i_lock); |
2409 | if (m2) | 2410 | if (m2) |