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