Commit 0bd4fa97 authored by Steve French's avatar Steve French

[CIFS] [CIFS] Do not take rename sem on most path based calls (during

building of full path) to avoid hang rename/readdir hang

Reported by Alan Tyson
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent f4ffaa45
...@@ -139,9 +139,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, ...@@ -139,9 +139,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
cifs_sb = CIFS_SB(inode->i_sb); cifs_sb = CIFS_SB(inode->i_sb);
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
mutex_lock(&direntry->d_sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex);
if(full_path == NULL) { if(full_path == NULL) {
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return -ENOMEM;
...@@ -316,9 +314,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, ...@@ -316,9 +314,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
cifs_sb = CIFS_SB(inode->i_sb); cifs_sb = CIFS_SB(inode->i_sb);
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
mutex_lock(&direntry->d_sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex);
if(full_path == NULL) if(full_path == NULL)
rc = -ENOMEM; rc = -ENOMEM;
else if (pTcon->ses->capabilities & CAP_UNIX) { else if (pTcon->ses->capabilities & CAP_UNIX) {
......
...@@ -86,9 +86,7 @@ int cifs_dir_notify(struct file * file, unsigned long arg) ...@@ -86,9 +86,7 @@ int cifs_dir_notify(struct file * file, unsigned long arg)
cifs_sb = CIFS_SB(file->f_dentry->d_sb); cifs_sb = CIFS_SB(file->f_dentry->d_sb);
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
mutex_lock(&file->f_dentry->d_sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(file->f_dentry); full_path = build_path_from_dentry(file->f_dentry);
mutex_unlock(&file->f_dentry->d_sb->s_vfs_rename_mutex);
if(full_path == NULL) { if(full_path == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
......
...@@ -203,9 +203,7 @@ int cifs_open(struct inode *inode, struct file *file) ...@@ -203,9 +203,7 @@ int cifs_open(struct inode *inode, struct file *file)
} }
} }
mutex_lock(&inode->i_sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(file->f_dentry); full_path = build_path_from_dentry(file->f_dentry);
mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);
if (full_path == NULL) { if (full_path == NULL) {
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return -ENOMEM;
......
...@@ -722,9 +722,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) ...@@ -722,9 +722,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
cifs_sb = CIFS_SB(inode->i_sb); cifs_sb = CIFS_SB(inode->i_sb);
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
mutex_lock(&inode->i_sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);
if (full_path == NULL) { if (full_path == NULL) {
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return -ENOMEM;
...@@ -807,9 +805,7 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry) ...@@ -807,9 +805,7 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
cifs_sb = CIFS_SB(inode->i_sb); cifs_sb = CIFS_SB(inode->i_sb);
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
mutex_lock(&inode->i_sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);
if (full_path == NULL) { if (full_path == NULL) {
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return -ENOMEM;
...@@ -1141,9 +1137,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) ...@@ -1141,9 +1137,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
rc = 0; rc = 0;
} }
mutex_lock(&direntry->d_sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex);
if (full_path == NULL) { if (full_path == NULL) {
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return -ENOMEM;
......
...@@ -48,10 +48,8 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode, ...@@ -48,10 +48,8 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
/* No need to check for cross device links since server will do that /* No need to check for cross device links since server will do that
BB note DFS case in future though (when we may have to check) */ BB note DFS case in future though (when we may have to check) */
mutex_lock(&inode->i_sb->s_vfs_rename_mutex);
fromName = build_path_from_dentry(old_file); fromName = build_path_from_dentry(old_file);
toName = build_path_from_dentry(direntry); toName = build_path_from_dentry(direntry);
mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);
if((fromName == NULL) || (toName == NULL)) { if((fromName == NULL) || (toName == NULL)) {
rc = -ENOMEM; rc = -ENOMEM;
goto cifs_hl_exit; goto cifs_hl_exit;
...@@ -103,9 +101,7 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd) ...@@ -103,9 +101,7 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
xid = GetXid(); xid = GetXid();
mutex_lock(&direntry->d_sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex);
if (!full_path) if (!full_path)
goto out_no_free; goto out_no_free;
...@@ -164,9 +160,7 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname) ...@@ -164,9 +160,7 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)
cifs_sb = CIFS_SB(inode->i_sb); cifs_sb = CIFS_SB(inode->i_sb);
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
mutex_lock(&inode->i_sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);
if(full_path == NULL) { if(full_path == NULL) {
FreeXid(xid); FreeXid(xid);
......
...@@ -404,9 +404,7 @@ static int initiate_cifs_search(const int xid, struct file *file) ...@@ -404,9 +404,7 @@ static int initiate_cifs_search(const int xid, struct file *file)
if(pTcon == NULL) if(pTcon == NULL)
return -EINVAL; return -EINVAL;
mutex_lock(&file->f_dentry->d_sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(file->f_dentry); full_path = build_path_from_dentry(file->f_dentry);
mutex_unlock(&file->f_dentry->d_sb->s_vfs_rename_mutex);
if(full_path == NULL) { if(full_path == NULL) {
return -ENOMEM; return -ENOMEM;
......
...@@ -62,9 +62,7 @@ int cifs_removexattr(struct dentry * direntry, const char * ea_name) ...@@ -62,9 +62,7 @@ int cifs_removexattr(struct dentry * direntry, const char * ea_name)
cifs_sb = CIFS_SB(sb); cifs_sb = CIFS_SB(sb);
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
mutex_lock(&sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
mutex_unlock(&sb->s_vfs_rename_mutex);
if(full_path == NULL) { if(full_path == NULL) {
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return -ENOMEM;
...@@ -116,9 +114,7 @@ int cifs_setxattr(struct dentry * direntry, const char * ea_name, ...@@ -116,9 +114,7 @@ int cifs_setxattr(struct dentry * direntry, const char * ea_name,
cifs_sb = CIFS_SB(sb); cifs_sb = CIFS_SB(sb);
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
mutex_lock(&sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
mutex_unlock(&sb->s_vfs_rename_mutex);
if(full_path == NULL) { if(full_path == NULL) {
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return -ENOMEM;
...@@ -223,9 +219,7 @@ ssize_t cifs_getxattr(struct dentry * direntry, const char * ea_name, ...@@ -223,9 +219,7 @@ ssize_t cifs_getxattr(struct dentry * direntry, const char * ea_name,
cifs_sb = CIFS_SB(sb); cifs_sb = CIFS_SB(sb);
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
mutex_lock(&sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
mutex_unlock(&sb->s_vfs_rename_mutex);
if(full_path == NULL) { if(full_path == NULL) {
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return -ENOMEM;
...@@ -341,9 +335,7 @@ ssize_t cifs_listxattr(struct dentry * direntry, char * data, size_t buf_size) ...@@ -341,9 +335,7 @@ ssize_t cifs_listxattr(struct dentry * direntry, char * data, size_t buf_size)
cifs_sb = CIFS_SB(sb); cifs_sb = CIFS_SB(sb);
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
mutex_lock(&sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
mutex_unlock(&sb->s_vfs_rename_mutex);
if(full_path == NULL) { if(full_path == NULL) {
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment