aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hpfs/namei.c
diff options
context:
space:
mode:
authorMikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>2011-05-08 14:43:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-09 12:04:23 -0400
commit7d23ce36e3f52f9b83ac8da49296b73339c8b5b8 (patch)
tree0c3973efa632e3c58d056c5d949a38b4c475193f /fs/hpfs/namei.c
parent7dd29d8d865efdb00c0542a5d2c87af8c52ea6c7 (diff)
HPFS: Remove remaining locks
Remove remaining locks Because of a new global per-fs lock, no other locks are needed Signed-off-by: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/hpfs/namei.c')
-rw-r--r--fs/hpfs/namei.c53
1 files changed, 7 insertions, 46 deletions
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index d5f8c8a19023..8c9f91537195 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -29,7 +29,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
29 fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); 29 fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh);
30 if (!fnode) 30 if (!fnode)
31 goto bail; 31 goto bail;
32 dnode = hpfs_alloc_dnode(dir->i_sb, fno, &dno, &qbh0, 1); 32 dnode = hpfs_alloc_dnode(dir->i_sb, fno, &dno, &qbh0);
33 if (!dnode) 33 if (!dnode)
34 goto bail1; 34 goto bail1;
35 memset(&dee, 0, sizeof dee); 35 memset(&dee, 0, sizeof dee);
@@ -60,8 +60,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
60 if (dee.read_only) 60 if (dee.read_only)
61 result->i_mode &= ~0222; 61 result->i_mode &= ~0222;
62 62
63 mutex_lock(&hpfs_i(dir)->i_mutex); 63 r = hpfs_add_dirent(dir, name, len, &dee);
64 r = hpfs_add_dirent(dir, name, len, &dee, 0);
65 if (r == 1) 64 if (r == 1)
66 goto bail3; 65 goto bail3;
67 if (r == -1) { 66 if (r == -1) {
@@ -101,11 +100,9 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
101 hpfs_write_inode_nolock(result); 100 hpfs_write_inode_nolock(result);
102 } 101 }
103 d_instantiate(dentry, result); 102 d_instantiate(dentry, result);
104 mutex_unlock(&hpfs_i(dir)->i_mutex);
105 hpfs_unlock(dir->i_sb); 103 hpfs_unlock(dir->i_sb);
106 return 0; 104 return 0;
107bail3: 105bail3:
108 mutex_unlock(&hpfs_i(dir)->i_mutex);
109 iput(result); 106 iput(result);
110bail2: 107bail2:
111 hpfs_brelse4(&qbh0); 108 hpfs_brelse4(&qbh0);
@@ -168,8 +165,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc
168 result->i_data.a_ops = &hpfs_aops; 165 result->i_data.a_ops = &hpfs_aops;
169 hpfs_i(result)->mmu_private = 0; 166 hpfs_i(result)->mmu_private = 0;
170 167
171 mutex_lock(&hpfs_i(dir)->i_mutex); 168 r = hpfs_add_dirent(dir, name, len, &dee);
172 r = hpfs_add_dirent(dir, name, len, &dee, 0);
173 if (r == 1) 169 if (r == 1)
174 goto bail2; 170 goto bail2;
175 if (r == -1) { 171 if (r == -1) {
@@ -193,12 +189,10 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc
193 hpfs_write_inode_nolock(result); 189 hpfs_write_inode_nolock(result);
194 } 190 }
195 d_instantiate(dentry, result); 191 d_instantiate(dentry, result);
196 mutex_unlock(&hpfs_i(dir)->i_mutex);
197 hpfs_unlock(dir->i_sb); 192 hpfs_unlock(dir->i_sb);
198 return 0; 193 return 0;
199 194
200bail2: 195bail2:
201 mutex_unlock(&hpfs_i(dir)->i_mutex);
202 iput(result); 196 iput(result);
203bail1: 197bail1:
204 brelse(bh); 198 brelse(bh);
@@ -254,8 +248,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t
254 result->i_blocks = 1; 248 result->i_blocks = 1;
255 init_special_inode(result, mode, rdev); 249 init_special_inode(result, mode, rdev);
256 250
257 mutex_lock(&hpfs_i(dir)->i_mutex); 251 r = hpfs_add_dirent(dir, name, len, &dee);
258 r = hpfs_add_dirent(dir, name, len, &dee, 0);
259 if (r == 1) 252 if (r == 1)
260 goto bail2; 253 goto bail2;
261 if (r == -1) { 254 if (r == -1) {
@@ -271,12 +264,10 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t
271 264
272 hpfs_write_inode_nolock(result); 265 hpfs_write_inode_nolock(result);
273 d_instantiate(dentry, result); 266 d_instantiate(dentry, result);
274 mutex_unlock(&hpfs_i(dir)->i_mutex);
275 brelse(bh); 267 brelse(bh);
276 hpfs_unlock(dir->i_sb); 268 hpfs_unlock(dir->i_sb);
277 return 0; 269 return 0;
278bail2: 270bail2:
279 mutex_unlock(&hpfs_i(dir)->i_mutex);
280 iput(result); 271 iput(result);
281bail1: 272bail1:
282 brelse(bh); 273 brelse(bh);
@@ -333,8 +324,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
333 result->i_op = &page_symlink_inode_operations; 324 result->i_op = &page_symlink_inode_operations;
334 result->i_data.a_ops = &hpfs_symlink_aops; 325 result->i_data.a_ops = &hpfs_symlink_aops;
335 326
336 mutex_lock(&hpfs_i(dir)->i_mutex); 327 r = hpfs_add_dirent(dir, name, len, &dee);
337 r = hpfs_add_dirent(dir, name, len, &dee, 0);
338 if (r == 1) 328 if (r == 1)
339 goto bail2; 329 goto bail2;
340 if (r == -1) { 330 if (r == -1) {
@@ -352,11 +342,9 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
352 342
353 hpfs_write_inode_nolock(result); 343 hpfs_write_inode_nolock(result);
354 d_instantiate(dentry, result); 344 d_instantiate(dentry, result);
355 mutex_unlock(&hpfs_i(dir)->i_mutex);
356 hpfs_unlock(dir->i_sb); 345 hpfs_unlock(dir->i_sb);
357 return 0; 346 return 0;
358bail2: 347bail2:
359 mutex_unlock(&hpfs_i(dir)->i_mutex);
360 iput(result); 348 iput(result);
361bail1: 349bail1:
362 brelse(bh); 350 brelse(bh);
@@ -382,8 +370,6 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry)
382 hpfs_lock(dir->i_sb); 370 hpfs_lock(dir->i_sb);
383 hpfs_adjust_length(name, &len); 371 hpfs_adjust_length(name, &len);
384again: 372again:
385 mutex_lock(&hpfs_i(inode)->i_parent_mutex);
386 mutex_lock(&hpfs_i(dir)->i_mutex);
387 err = -ENOENT; 373 err = -ENOENT;
388 de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh); 374 de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh);
389 if (!de) 375 if (!de)
@@ -410,8 +396,6 @@ again:
410 if (rep++) 396 if (rep++)
411 break; 397 break;
412 398
413 mutex_unlock(&hpfs_i(dir)->i_mutex);
414 mutex_unlock(&hpfs_i(inode)->i_parent_mutex);
415 dentry_unhash(dentry); 399 dentry_unhash(dentry);
416 if (!d_unhashed(dentry)) { 400 if (!d_unhashed(dentry)) {
417 dput(dentry); 401 dput(dentry);
@@ -445,8 +429,6 @@ again:
445out1: 429out1:
446 hpfs_brelse4(&qbh); 430 hpfs_brelse4(&qbh);
447out: 431out:
448 mutex_unlock(&hpfs_i(dir)->i_mutex);
449 mutex_unlock(&hpfs_i(inode)->i_parent_mutex);
450 hpfs_unlock(dir->i_sb); 432 hpfs_unlock(dir->i_sb);
451 return err; 433 return err;
452} 434}
@@ -466,8 +448,6 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
466 448
467 hpfs_adjust_length(name, &len); 449 hpfs_adjust_length(name, &len);
468 hpfs_lock(dir->i_sb); 450 hpfs_lock(dir->i_sb);
469 mutex_lock(&hpfs_i(inode)->i_parent_mutex);
470 mutex_lock(&hpfs_i(dir)->i_mutex);
471 err = -ENOENT; 451 err = -ENOENT;
472 de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh); 452 de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh);
473 if (!de) 453 if (!de)
@@ -505,8 +485,6 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
505out1: 485out1:
506 hpfs_brelse4(&qbh); 486 hpfs_brelse4(&qbh);
507out: 487out:
508 mutex_unlock(&hpfs_i(dir)->i_mutex);
509 mutex_unlock(&hpfs_i(inode)->i_parent_mutex);
510 hpfs_unlock(dir->i_sb); 488 hpfs_unlock(dir->i_sb);
511 return err; 489 return err;
512} 490}
@@ -568,12 +546,6 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
568 546
569 hpfs_lock(i->i_sb); 547 hpfs_lock(i->i_sb);
570 /* order doesn't matter, due to VFS exclusion */ 548 /* order doesn't matter, due to VFS exclusion */
571 mutex_lock(&hpfs_i(i)->i_parent_mutex);
572 if (new_inode)
573 mutex_lock(&hpfs_i(new_inode)->i_parent_mutex);
574 mutex_lock(&hpfs_i(old_dir)->i_mutex);
575 if (new_dir != old_dir)
576 mutex_lock(&hpfs_i(new_dir)->i_mutex);
577 549
578 /* Erm? Moving over the empty non-busy directory is perfectly legal */ 550 /* Erm? Moving over the empty non-busy directory is perfectly legal */
579 if (new_inode && S_ISDIR(new_inode->i_mode)) { 551 if (new_inode && S_ISDIR(new_inode->i_mode)) {
@@ -610,9 +582,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
610 582
611 if (new_dir == old_dir) hpfs_brelse4(&qbh); 583 if (new_dir == old_dir) hpfs_brelse4(&qbh);
612 584
613 hpfs_lock_creation(i->i_sb); 585 if ((r = hpfs_add_dirent(new_dir, new_name, new_len, &de))) {
614 if ((r = hpfs_add_dirent(new_dir, new_name, new_len, &de, 1))) {
615 hpfs_unlock_creation(i->i_sb);
616 if (r == -1) hpfs_error(new_dir->i_sb, "hpfs_rename: dirent already exists!"); 586 if (r == -1) hpfs_error(new_dir->i_sb, "hpfs_rename: dirent already exists!");
617 err = r == 1 ? -ENOSPC : -EFSERROR; 587 err = r == 1 ? -ENOSPC : -EFSERROR;
618 if (new_dir != old_dir) hpfs_brelse4(&qbh); 588 if (new_dir != old_dir) hpfs_brelse4(&qbh);
@@ -621,20 +591,17 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
621 591
622 if (new_dir == old_dir) 592 if (new_dir == old_dir)
623 if (!(dep = map_dirent(old_dir, hpfs_i(old_dir)->i_dno, old_name, old_len, &dno, &qbh))) { 593 if (!(dep = map_dirent(old_dir, hpfs_i(old_dir)->i_dno, old_name, old_len, &dno, &qbh))) {
624 hpfs_unlock_creation(i->i_sb);
625 hpfs_error(i->i_sb, "lookup succeeded but map dirent failed at #2"); 594 hpfs_error(i->i_sb, "lookup succeeded but map dirent failed at #2");
626 err = -ENOENT; 595 err = -ENOENT;
627 goto end1; 596 goto end1;
628 } 597 }
629 598
630 if ((r = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 0))) { 599 if ((r = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 0))) {
631 hpfs_unlock_creation(i->i_sb);
632 hpfs_error(i->i_sb, "hpfs_rename: could not remove dirent"); 600 hpfs_error(i->i_sb, "hpfs_rename: could not remove dirent");
633 err = r == 2 ? -ENOSPC : -EFSERROR; 601 err = r == 2 ? -ENOSPC : -EFSERROR;
634 goto end1; 602 goto end1;
635 } 603 }
636 hpfs_unlock_creation(i->i_sb); 604
637
638 end: 605 end:
639 hpfs_i(i)->i_parent_dir = new_dir->i_ino; 606 hpfs_i(i)->i_parent_dir = new_dir->i_ino;
640 if (S_ISDIR(i->i_mode)) { 607 if (S_ISDIR(i->i_mode)) {
@@ -652,12 +619,6 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
652 hpfs_i(i)->i_conv = hpfs_sb(i->i_sb)->sb_conv; 619 hpfs_i(i)->i_conv = hpfs_sb(i->i_sb)->sb_conv;
653 hpfs_decide_conv(i, new_name, new_len); 620 hpfs_decide_conv(i, new_name, new_len);
654end1: 621end1:
655 if (old_dir != new_dir)
656 mutex_unlock(&hpfs_i(new_dir)->i_mutex);
657 mutex_unlock(&hpfs_i(old_dir)->i_mutex);
658 mutex_unlock(&hpfs_i(i)->i_parent_mutex);
659 if (new_inode)
660 mutex_unlock(&hpfs_i(new_inode)->i_parent_mutex);
661 hpfs_unlock(i->i_sb); 622 hpfs_unlock(i->i_sb);
662 return err; 623 return err;
663} 624}