[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: Steve French <sfrench@us.ibm.com>

-30
-4
fs/cifs/dir.c
··· 139 139 cifs_sb = CIFS_SB(inode->i_sb); 140 140 pTcon = cifs_sb->tcon; 141 141 142 - mutex_lock(&direntry->d_sb->s_vfs_rename_mutex); 143 142 full_path = build_path_from_dentry(direntry); 144 - mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex); 145 143 if(full_path == NULL) { 146 144 FreeXid(xid); 147 145 return -ENOMEM; ··· 314 316 cifs_sb = CIFS_SB(inode->i_sb); 315 317 pTcon = cifs_sb->tcon; 316 318 317 - mutex_lock(&direntry->d_sb->s_vfs_rename_mutex); 318 319 full_path = build_path_from_dentry(direntry); 319 - mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex); 320 320 if(full_path == NULL) 321 321 rc = -ENOMEM; 322 322 else if (pTcon->ses->capabilities & CAP_UNIX) {
-2
fs/cifs/fcntl.c
··· 86 86 cifs_sb = CIFS_SB(file->f_dentry->d_sb); 87 87 pTcon = cifs_sb->tcon; 88 88 89 - mutex_lock(&file->f_dentry->d_sb->s_vfs_rename_mutex); 90 89 full_path = build_path_from_dentry(file->f_dentry); 91 - mutex_unlock(&file->f_dentry->d_sb->s_vfs_rename_mutex); 92 90 93 91 if(full_path == NULL) { 94 92 rc = -ENOMEM;
-2
fs/cifs/file.c
··· 203 203 } 204 204 } 205 205 206 - mutex_lock(&inode->i_sb->s_vfs_rename_mutex); 207 206 full_path = build_path_from_dentry(file->f_dentry); 208 - mutex_unlock(&inode->i_sb->s_vfs_rename_mutex); 209 207 if (full_path == NULL) { 210 208 FreeXid(xid); 211 209 return -ENOMEM;
-6
fs/cifs/inode.c
··· 722 722 cifs_sb = CIFS_SB(inode->i_sb); 723 723 pTcon = cifs_sb->tcon; 724 724 725 - mutex_lock(&inode->i_sb->s_vfs_rename_mutex); 726 725 full_path = build_path_from_dentry(direntry); 727 - mutex_unlock(&inode->i_sb->s_vfs_rename_mutex); 728 726 if (full_path == NULL) { 729 727 FreeXid(xid); 730 728 return -ENOMEM; ··· 805 807 cifs_sb = CIFS_SB(inode->i_sb); 806 808 pTcon = cifs_sb->tcon; 807 809 808 - mutex_lock(&inode->i_sb->s_vfs_rename_mutex); 809 810 full_path = build_path_from_dentry(direntry); 810 - mutex_unlock(&inode->i_sb->s_vfs_rename_mutex); 811 811 if (full_path == NULL) { 812 812 FreeXid(xid); 813 813 return -ENOMEM; ··· 1137 1141 rc = 0; 1138 1142 } 1139 1143 1140 - mutex_lock(&direntry->d_sb->s_vfs_rename_mutex); 1141 1144 full_path = build_path_from_dentry(direntry); 1142 - mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex); 1143 1145 if (full_path == NULL) { 1144 1146 FreeXid(xid); 1145 1147 return -ENOMEM;
-6
fs/cifs/link.c
··· 48 48 /* No need to check for cross device links since server will do that 49 49 BB note DFS case in future though (when we may have to check) */ 50 50 51 - mutex_lock(&inode->i_sb->s_vfs_rename_mutex); 52 51 fromName = build_path_from_dentry(old_file); 53 52 toName = build_path_from_dentry(direntry); 54 - mutex_unlock(&inode->i_sb->s_vfs_rename_mutex); 55 53 if((fromName == NULL) || (toName == NULL)) { 56 54 rc = -ENOMEM; 57 55 goto cifs_hl_exit; ··· 101 103 102 104 xid = GetXid(); 103 105 104 - mutex_lock(&direntry->d_sb->s_vfs_rename_mutex); 105 106 full_path = build_path_from_dentry(direntry); 106 - mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex); 107 107 108 108 if (!full_path) 109 109 goto out_no_free; ··· 160 164 cifs_sb = CIFS_SB(inode->i_sb); 161 165 pTcon = cifs_sb->tcon; 162 166 163 - mutex_lock(&inode->i_sb->s_vfs_rename_mutex); 164 167 full_path = build_path_from_dentry(direntry); 165 - mutex_unlock(&inode->i_sb->s_vfs_rename_mutex); 166 168 167 169 if(full_path == NULL) { 168 170 FreeXid(xid);
-2
fs/cifs/readdir.c
··· 404 404 if(pTcon == NULL) 405 405 return -EINVAL; 406 406 407 - mutex_lock(&file->f_dentry->d_sb->s_vfs_rename_mutex); 408 407 full_path = build_path_from_dentry(file->f_dentry); 409 - mutex_unlock(&file->f_dentry->d_sb->s_vfs_rename_mutex); 410 408 411 409 if(full_path == NULL) { 412 410 return -ENOMEM;
-8
fs/cifs/xattr.c
··· 62 62 cifs_sb = CIFS_SB(sb); 63 63 pTcon = cifs_sb->tcon; 64 64 65 - mutex_lock(&sb->s_vfs_rename_mutex); 66 65 full_path = build_path_from_dentry(direntry); 67 - mutex_unlock(&sb->s_vfs_rename_mutex); 68 66 if(full_path == NULL) { 69 67 FreeXid(xid); 70 68 return -ENOMEM; ··· 114 116 cifs_sb = CIFS_SB(sb); 115 117 pTcon = cifs_sb->tcon; 116 118 117 - mutex_lock(&sb->s_vfs_rename_mutex); 118 119 full_path = build_path_from_dentry(direntry); 119 - mutex_unlock(&sb->s_vfs_rename_mutex); 120 120 if(full_path == NULL) { 121 121 FreeXid(xid); 122 122 return -ENOMEM; ··· 219 223 cifs_sb = CIFS_SB(sb); 220 224 pTcon = cifs_sb->tcon; 221 225 222 - mutex_lock(&sb->s_vfs_rename_mutex); 223 226 full_path = build_path_from_dentry(direntry); 224 - mutex_unlock(&sb->s_vfs_rename_mutex); 225 227 if(full_path == NULL) { 226 228 FreeXid(xid); 227 229 return -ENOMEM; ··· 335 341 cifs_sb = CIFS_SB(sb); 336 342 pTcon = cifs_sb->tcon; 337 343 338 - mutex_lock(&sb->s_vfs_rename_mutex); 339 344 full_path = build_path_from_dentry(direntry); 340 - mutex_unlock(&sb->s_vfs_rename_mutex); 341 345 if(full_path == NULL) { 342 346 FreeXid(xid); 343 347 return -ENOMEM;