Commit a11f3a0574a5734db3e5de38922430d005d35118
Committed by
Linus Torvalds
1 parent
144efe3e3e
Exists in
master
and in
4 other branches
[PATCH] sem2mutex: vfs_rename_mutex
Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Arjan van de Ven <arjan@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu> Cc: Al Viro <viro@ftp.linux.org.uk> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 10 changed files with 42 additions and 42 deletions Side-by-side Diff
fs/cifs/dir.c
... | ... | @@ -138,9 +138,9 @@ |
138 | 138 | cifs_sb = CIFS_SB(inode->i_sb); |
139 | 139 | pTcon = cifs_sb->tcon; |
140 | 140 | |
141 | - down(&direntry->d_sb->s_vfs_rename_sem); | |
141 | + mutex_lock(&direntry->d_sb->s_vfs_rename_mutex); | |
142 | 142 | full_path = build_path_from_dentry(direntry); |
143 | - up(&direntry->d_sb->s_vfs_rename_sem); | |
143 | + mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex); | |
144 | 144 | if(full_path == NULL) { |
145 | 145 | FreeXid(xid); |
146 | 146 | return -ENOMEM; |
147 | 147 | |
... | ... | @@ -317,9 +317,9 @@ |
317 | 317 | cifs_sb = CIFS_SB(inode->i_sb); |
318 | 318 | pTcon = cifs_sb->tcon; |
319 | 319 | |
320 | - down(&direntry->d_sb->s_vfs_rename_sem); | |
320 | + mutex_lock(&direntry->d_sb->s_vfs_rename_mutex); | |
321 | 321 | full_path = build_path_from_dentry(direntry); |
322 | - up(&direntry->d_sb->s_vfs_rename_sem); | |
322 | + mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex); | |
323 | 323 | if(full_path == NULL) |
324 | 324 | rc = -ENOMEM; |
325 | 325 | else if (pTcon->ses->capabilities & CAP_UNIX) { |
fs/cifs/fcntl.c
... | ... | @@ -86,9 +86,9 @@ |
86 | 86 | cifs_sb = CIFS_SB(file->f_dentry->d_sb); |
87 | 87 | pTcon = cifs_sb->tcon; |
88 | 88 | |
89 | - down(&file->f_dentry->d_sb->s_vfs_rename_sem); | |
89 | + mutex_lock(&file->f_dentry->d_sb->s_vfs_rename_mutex); | |
90 | 90 | full_path = build_path_from_dentry(file->f_dentry); |
91 | - up(&file->f_dentry->d_sb->s_vfs_rename_sem); | |
91 | + mutex_unlock(&file->f_dentry->d_sb->s_vfs_rename_mutex); | |
92 | 92 | |
93 | 93 | if(full_path == NULL) { |
94 | 94 | rc = -ENOMEM; |
fs/cifs/file.c
... | ... | @@ -203,9 +203,9 @@ |
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
206 | - down(&inode->i_sb->s_vfs_rename_sem); | |
206 | + mutex_lock(&inode->i_sb->s_vfs_rename_mutex); | |
207 | 207 | full_path = build_path_from_dentry(file->f_dentry); |
208 | - up(&inode->i_sb->s_vfs_rename_sem); | |
208 | + mutex_unlock(&inode->i_sb->s_vfs_rename_mutex); | |
209 | 209 | if (full_path == NULL) { |
210 | 210 | FreeXid(xid); |
211 | 211 | return -ENOMEM; |
fs/cifs/inode.c
... | ... | @@ -574,9 +574,9 @@ |
574 | 574 | |
575 | 575 | /* Unlink can be called from rename so we can not grab the sem here |
576 | 576 | since we deadlock otherwise */ |
577 | -/* down(&direntry->d_sb->s_vfs_rename_sem);*/ | |
577 | +/* mutex_lock(&direntry->d_sb->s_vfs_rename_mutex);*/ | |
578 | 578 | full_path = build_path_from_dentry(direntry); |
579 | -/* up(&direntry->d_sb->s_vfs_rename_sem);*/ | |
579 | +/* mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex);*/ | |
580 | 580 | if (full_path == NULL) { |
581 | 581 | FreeXid(xid); |
582 | 582 | return -ENOMEM; |
583 | 583 | |
... | ... | @@ -718,9 +718,9 @@ |
718 | 718 | cifs_sb = CIFS_SB(inode->i_sb); |
719 | 719 | pTcon = cifs_sb->tcon; |
720 | 720 | |
721 | - down(&inode->i_sb->s_vfs_rename_sem); | |
721 | + mutex_lock(&inode->i_sb->s_vfs_rename_mutex); | |
722 | 722 | full_path = build_path_from_dentry(direntry); |
723 | - up(&inode->i_sb->s_vfs_rename_sem); | |
723 | + mutex_unlock(&inode->i_sb->s_vfs_rename_mutex); | |
724 | 724 | if (full_path == NULL) { |
725 | 725 | FreeXid(xid); |
726 | 726 | return -ENOMEM; |
727 | 727 | |
... | ... | @@ -803,9 +803,9 @@ |
803 | 803 | cifs_sb = CIFS_SB(inode->i_sb); |
804 | 804 | pTcon = cifs_sb->tcon; |
805 | 805 | |
806 | - down(&inode->i_sb->s_vfs_rename_sem); | |
806 | + mutex_lock(&inode->i_sb->s_vfs_rename_mutex); | |
807 | 807 | full_path = build_path_from_dentry(direntry); |
808 | - up(&inode->i_sb->s_vfs_rename_sem); | |
808 | + mutex_unlock(&inode->i_sb->s_vfs_rename_mutex); | |
809 | 809 | if (full_path == NULL) { |
810 | 810 | FreeXid(xid); |
811 | 811 | return -ENOMEM; |
812 | 812 | |
... | ... | @@ -1137,9 +1137,9 @@ |
1137 | 1137 | rc = 0; |
1138 | 1138 | } |
1139 | 1139 | |
1140 | - down(&direntry->d_sb->s_vfs_rename_sem); | |
1140 | + mutex_lock(&direntry->d_sb->s_vfs_rename_mutex); | |
1141 | 1141 | full_path = build_path_from_dentry(direntry); |
1142 | - up(&direntry->d_sb->s_vfs_rename_sem); | |
1142 | + mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex); | |
1143 | 1143 | if (full_path == NULL) { |
1144 | 1144 | FreeXid(xid); |
1145 | 1145 | return -ENOMEM; |
fs/cifs/link.c
... | ... | @@ -48,10 +48,10 @@ |
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 | - down(&inode->i_sb->s_vfs_rename_sem); | |
51 | + mutex_lock(&inode->i_sb->s_vfs_rename_mutex); | |
52 | 52 | fromName = build_path_from_dentry(old_file); |
53 | 53 | toName = build_path_from_dentry(direntry); |
54 | - up(&inode->i_sb->s_vfs_rename_sem); | |
54 | + mutex_unlock(&inode->i_sb->s_vfs_rename_mutex); | |
55 | 55 | if((fromName == NULL) || (toName == NULL)) { |
56 | 56 | rc = -ENOMEM; |
57 | 57 | goto cifs_hl_exit; |
58 | 58 | |
... | ... | @@ -103,9 +103,9 @@ |
103 | 103 | |
104 | 104 | xid = GetXid(); |
105 | 105 | |
106 | - down(&direntry->d_sb->s_vfs_rename_sem); | |
106 | + mutex_lock(&direntry->d_sb->s_vfs_rename_mutex); | |
107 | 107 | full_path = build_path_from_dentry(direntry); |
108 | - up(&direntry->d_sb->s_vfs_rename_sem); | |
108 | + mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex); | |
109 | 109 | |
110 | 110 | if (!full_path) |
111 | 111 | goto out_no_free; |
112 | 112 | |
... | ... | @@ -164,9 +164,9 @@ |
164 | 164 | cifs_sb = CIFS_SB(inode->i_sb); |
165 | 165 | pTcon = cifs_sb->tcon; |
166 | 166 | |
167 | - down(&inode->i_sb->s_vfs_rename_sem); | |
167 | + mutex_lock(&inode->i_sb->s_vfs_rename_mutex); | |
168 | 168 | full_path = build_path_from_dentry(direntry); |
169 | - up(&inode->i_sb->s_vfs_rename_sem); | |
169 | + mutex_unlock(&inode->i_sb->s_vfs_rename_mutex); | |
170 | 170 | |
171 | 171 | if(full_path == NULL) { |
172 | 172 | FreeXid(xid); |
173 | 173 | |
... | ... | @@ -232,9 +232,9 @@ |
232 | 232 | |
233 | 233 | /* BB would it be safe against deadlock to grab this sem |
234 | 234 | even though rename itself grabs the sem and calls lookup? */ |
235 | -/* down(&inode->i_sb->s_vfs_rename_sem);*/ | |
235 | +/* mutex_lock(&inode->i_sb->s_vfs_rename_mutex);*/ | |
236 | 236 | full_path = build_path_from_dentry(direntry); |
237 | -/* up(&inode->i_sb->s_vfs_rename_sem);*/ | |
237 | +/* mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);*/ | |
238 | 238 | |
239 | 239 | if(full_path == NULL) { |
240 | 240 | FreeXid(xid); |
fs/cifs/readdir.c
... | ... | @@ -404,9 +404,9 @@ |
404 | 404 | if(pTcon == NULL) |
405 | 405 | return -EINVAL; |
406 | 406 | |
407 | - down(&file->f_dentry->d_sb->s_vfs_rename_sem); | |
407 | + mutex_lock(&file->f_dentry->d_sb->s_vfs_rename_mutex); | |
408 | 408 | full_path = build_path_from_dentry(file->f_dentry); |
409 | - up(&file->f_dentry->d_sb->s_vfs_rename_sem); | |
409 | + mutex_unlock(&file->f_dentry->d_sb->s_vfs_rename_mutex); | |
410 | 410 | |
411 | 411 | if(full_path == NULL) { |
412 | 412 | return -ENOMEM; |
fs/cifs/xattr.c
... | ... | @@ -62,9 +62,9 @@ |
62 | 62 | cifs_sb = CIFS_SB(sb); |
63 | 63 | pTcon = cifs_sb->tcon; |
64 | 64 | |
65 | - down(&sb->s_vfs_rename_sem); | |
65 | + mutex_lock(&sb->s_vfs_rename_mutex); | |
66 | 66 | full_path = build_path_from_dentry(direntry); |
67 | - up(&sb->s_vfs_rename_sem); | |
67 | + mutex_unlock(&sb->s_vfs_rename_mutex); | |
68 | 68 | if(full_path == NULL) { |
69 | 69 | FreeXid(xid); |
70 | 70 | return -ENOMEM; |
71 | 71 | |
... | ... | @@ -116,9 +116,9 @@ |
116 | 116 | cifs_sb = CIFS_SB(sb); |
117 | 117 | pTcon = cifs_sb->tcon; |
118 | 118 | |
119 | - down(&sb->s_vfs_rename_sem); | |
119 | + mutex_lock(&sb->s_vfs_rename_mutex); | |
120 | 120 | full_path = build_path_from_dentry(direntry); |
121 | - up(&sb->s_vfs_rename_sem); | |
121 | + mutex_unlock(&sb->s_vfs_rename_mutex); | |
122 | 122 | if(full_path == NULL) { |
123 | 123 | FreeXid(xid); |
124 | 124 | return -ENOMEM; |
125 | 125 | |
... | ... | @@ -223,9 +223,9 @@ |
223 | 223 | cifs_sb = CIFS_SB(sb); |
224 | 224 | pTcon = cifs_sb->tcon; |
225 | 225 | |
226 | - down(&sb->s_vfs_rename_sem); | |
226 | + mutex_lock(&sb->s_vfs_rename_mutex); | |
227 | 227 | full_path = build_path_from_dentry(direntry); |
228 | - up(&sb->s_vfs_rename_sem); | |
228 | + mutex_unlock(&sb->s_vfs_rename_mutex); | |
229 | 229 | if(full_path == NULL) { |
230 | 230 | FreeXid(xid); |
231 | 231 | return -ENOMEM; |
232 | 232 | |
... | ... | @@ -341,9 +341,9 @@ |
341 | 341 | cifs_sb = CIFS_SB(sb); |
342 | 342 | pTcon = cifs_sb->tcon; |
343 | 343 | |
344 | - down(&sb->s_vfs_rename_sem); | |
344 | + mutex_lock(&sb->s_vfs_rename_mutex); | |
345 | 345 | full_path = build_path_from_dentry(direntry); |
346 | - up(&sb->s_vfs_rename_sem); | |
346 | + mutex_unlock(&sb->s_vfs_rename_mutex); | |
347 | 347 | if(full_path == NULL) { |
348 | 348 | FreeXid(xid); |
349 | 349 | return -ENOMEM; |
fs/namei.c
... | ... | @@ -104,7 +104,7 @@ |
104 | 104 | */ |
105 | 105 | /* |
106 | 106 | * [Sep 2001 AV] Single-semaphore locking scheme (kudos to David Holland) |
107 | - * implemented. Let's see if raised priority of ->s_vfs_rename_sem gives | |
107 | + * implemented. Let's see if raised priority of ->s_vfs_rename_mutex gives | |
108 | 108 | * any extra contention... |
109 | 109 | */ |
110 | 110 | |
... | ... | @@ -1422,7 +1422,7 @@ |
1422 | 1422 | return NULL; |
1423 | 1423 | } |
1424 | 1424 | |
1425 | - down(&p1->d_inode->i_sb->s_vfs_rename_sem); | |
1425 | + mutex_lock(&p1->d_inode->i_sb->s_vfs_rename_mutex); | |
1426 | 1426 | |
1427 | 1427 | for (p = p1; p->d_parent != p; p = p->d_parent) { |
1428 | 1428 | if (p->d_parent == p2) { |
... | ... | @@ -1450,7 +1450,7 @@ |
1450 | 1450 | mutex_unlock(&p1->d_inode->i_mutex); |
1451 | 1451 | if (p1 != p2) { |
1452 | 1452 | mutex_unlock(&p2->d_inode->i_mutex); |
1453 | - up(&p1->d_inode->i_sb->s_vfs_rename_sem); | |
1453 | + mutex_unlock(&p1->d_inode->i_sb->s_vfs_rename_mutex); | |
1454 | 1454 | } |
1455 | 1455 | } |
1456 | 1456 | |
1457 | 1457 | |
1458 | 1458 | |
... | ... | @@ -2277,17 +2277,17 @@ |
2277 | 2277 | * a) we can get into loop creation. Check is done in is_subdir(). |
2278 | 2278 | * b) race potential - two innocent renames can create a loop together. |
2279 | 2279 | * That's where 4.4 screws up. Current fix: serialization on |
2280 | - * sb->s_vfs_rename_sem. We might be more accurate, but that's another | |
2280 | + * sb->s_vfs_rename_mutex. We might be more accurate, but that's another | |
2281 | 2281 | * story. |
2282 | 2282 | * c) we have to lock _three_ objects - parents and victim (if it exists). |
2283 | 2283 | * And that - after we got ->i_mutex on parents (until then we don't know |
2284 | 2284 | * whether the target exists). Solution: try to be smart with locking |
2285 | 2285 | * order for inodes. We rely on the fact that tree topology may change |
2286 | - * only under ->s_vfs_rename_sem _and_ that parent of the object we | |
2286 | + * only under ->s_vfs_rename_mutex _and_ that parent of the object we | |
2287 | 2287 | * move will be locked. Thus we can rank directories by the tree |
2288 | 2288 | * (ancestors first) and rank all non-directories after them. |
2289 | 2289 | * That works since everybody except rename does "lock parent, lookup, |
2290 | - * lock child" and rename is under ->s_vfs_rename_sem. | |
2290 | + * lock child" and rename is under ->s_vfs_rename_mutex. | |
2291 | 2291 | * HOWEVER, it relies on the assumption that any object with ->lookup() |
2292 | 2292 | * has no more than 1 dentry. If "hybrid" objects will ever appear, |
2293 | 2293 | * we'd better make sure that there's no link(2) for them. |
fs/super.c
... | ... | @@ -76,7 +76,7 @@ |
76 | 76 | down_write(&s->s_umount); |
77 | 77 | s->s_count = S_BIAS; |
78 | 78 | atomic_set(&s->s_active, 1); |
79 | - sema_init(&s->s_vfs_rename_sem,1); | |
79 | + mutex_init(&s->s_vfs_rename_mutex); | |
80 | 80 | mutex_init(&s->s_dquot.dqio_mutex); |
81 | 81 | mutex_init(&s->s_dquot.dqonoff_mutex); |
82 | 82 | init_rwsem(&s->s_dquot.dqptr_sem); |
include/linux/fs.h
... | ... | @@ -847,7 +847,7 @@ |
847 | 847 | * The next field is for VFS *only*. No filesystems have any business |
848 | 848 | * even looking at it. You had been warned. |
849 | 849 | */ |
850 | - struct semaphore s_vfs_rename_sem; /* Kludge */ | |
850 | + struct mutex s_vfs_rename_mutex; /* Kludge */ | |
851 | 851 | |
852 | 852 | /* Granuality of c/m/atime in ns. |
853 | 853 | Cannot be worse than a second */ |