aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
authorJes Sorensen <jes@sgi.com>2006-01-09 18:59:24 -0500
committerIngo Molnar <mingo@hera.kernel.org>2006-01-09 18:59:24 -0500
commit1b1dcc1b57a49136f118a0f16367256ff9994a69 (patch)
treeb0b36d4f41d28c9d6514fb309d33c1a084d6309b /fs/ocfs2
parent794ee1baee1c26be40410233e6c20bceb2b03c08 (diff)
[PATCH] mutex subsystem, semaphore to mutex: VFS, ->i_sem
This patch converts the inode semaphore to a mutex. I have tested it on XFS and compiled as much as one can consider on an ia64. Anyway your luck with it might be different. Modified-by: Ingo Molnar <mingo@elte.hu> (finished the conversion) Signed-off-by: Jes Sorensen <jes@sgi.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/alloc.c24
-rw-r--r--fs/ocfs2/cluster/nodemanager.c2
-rw-r--r--fs/ocfs2/dir.c4
-rw-r--r--fs/ocfs2/file.c8
-rw-r--r--fs/ocfs2/inode.c12
-rw-r--r--fs/ocfs2/journal.c14
-rw-r--r--fs/ocfs2/localalloc.c6
7 files changed, 35 insertions, 35 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 465f797451ee..6b9812db3779 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -966,7 +966,7 @@ static int ocfs2_truncate_log_append(struct ocfs2_super *osb,
966 mlog_entry("start_blk = %"MLFu64", num_clusters = %u\n", start_blk, 966 mlog_entry("start_blk = %"MLFu64", num_clusters = %u\n", start_blk,
967 num_clusters); 967 num_clusters);
968 968
969 BUG_ON(!down_trylock(&tl_inode->i_sem)); 969 BUG_ON(mutex_trylock(&tl_inode->i_mutex));
970 970
971 start_cluster = ocfs2_blocks_to_clusters(osb->sb, start_blk); 971 start_cluster = ocfs2_blocks_to_clusters(osb->sb, start_blk);
972 972
@@ -1108,7 +1108,7 @@ bail:
1108 return status; 1108 return status;
1109} 1109}
1110 1110
1111/* Expects you to already be holding tl_inode->i_sem */ 1111/* Expects you to already be holding tl_inode->i_mutex */
1112static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb) 1112static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb)
1113{ 1113{
1114 int status; 1114 int status;
@@ -1123,7 +1123,7 @@ static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb)
1123 1123
1124 mlog_entry_void(); 1124 mlog_entry_void();
1125 1125
1126 BUG_ON(!down_trylock(&tl_inode->i_sem)); 1126 BUG_ON(mutex_trylock(&tl_inode->i_mutex));
1127 1127
1128 di = (struct ocfs2_dinode *) tl_bh->b_data; 1128 di = (struct ocfs2_dinode *) tl_bh->b_data;
1129 tl = &di->id2.i_dealloc; 1129 tl = &di->id2.i_dealloc;
@@ -1198,9 +1198,9 @@ int ocfs2_flush_truncate_log(struct ocfs2_super *osb)
1198 int status; 1198 int status;
1199 struct inode *tl_inode = osb->osb_tl_inode; 1199 struct inode *tl_inode = osb->osb_tl_inode;
1200 1200
1201 down(&tl_inode->i_sem); 1201 mutex_lock(&tl_inode->i_mutex);
1202 status = __ocfs2_flush_truncate_log(osb); 1202 status = __ocfs2_flush_truncate_log(osb);
1203 up(&tl_inode->i_sem); 1203 mutex_unlock(&tl_inode->i_mutex);
1204 1204
1205 return status; 1205 return status;
1206} 1206}
@@ -1363,7 +1363,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb,
1363 mlog(0, "cleanup %u records from %"MLFu64"\n", num_recs, 1363 mlog(0, "cleanup %u records from %"MLFu64"\n", num_recs,
1364 tl_copy->i_blkno); 1364 tl_copy->i_blkno);
1365 1365
1366 down(&tl_inode->i_sem); 1366 mutex_lock(&tl_inode->i_mutex);
1367 for(i = 0; i < num_recs; i++) { 1367 for(i = 0; i < num_recs; i++) {
1368 if (ocfs2_truncate_log_needs_flush(osb)) { 1368 if (ocfs2_truncate_log_needs_flush(osb)) {
1369 status = __ocfs2_flush_truncate_log(osb); 1369 status = __ocfs2_flush_truncate_log(osb);
@@ -1395,7 +1395,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb,
1395 } 1395 }
1396 1396
1397bail_up: 1397bail_up:
1398 up(&tl_inode->i_sem); 1398 mutex_unlock(&tl_inode->i_mutex);
1399 1399
1400 mlog_exit(status); 1400 mlog_exit(status);
1401 return status; 1401 return status;
@@ -1840,7 +1840,7 @@ start:
1840 1840
1841 mlog(0, "clusters_to_del = %u in this pass\n", clusters_to_del); 1841 mlog(0, "clusters_to_del = %u in this pass\n", clusters_to_del);
1842 1842
1843 down(&tl_inode->i_sem); 1843 mutex_lock(&tl_inode->i_mutex);
1844 tl_sem = 1; 1844 tl_sem = 1;
1845 /* ocfs2_truncate_log_needs_flush guarantees us at least one 1845 /* ocfs2_truncate_log_needs_flush guarantees us at least one
1846 * record is free for use. If there isn't any, we flush to get 1846 * record is free for use. If there isn't any, we flush to get
@@ -1875,7 +1875,7 @@ start:
1875 goto bail; 1875 goto bail;
1876 } 1876 }
1877 1877
1878 up(&tl_inode->i_sem); 1878 mutex_unlock(&tl_inode->i_mutex);
1879 tl_sem = 0; 1879 tl_sem = 0;
1880 1880
1881 ocfs2_commit_trans(handle); 1881 ocfs2_commit_trans(handle);
@@ -1890,7 +1890,7 @@ bail:
1890 ocfs2_schedule_truncate_log_flush(osb, 1); 1890 ocfs2_schedule_truncate_log_flush(osb, 1);
1891 1891
1892 if (tl_sem) 1892 if (tl_sem)
1893 up(&tl_inode->i_sem); 1893 mutex_unlock(&tl_inode->i_mutex);
1894 1894
1895 if (handle) 1895 if (handle)
1896 ocfs2_commit_trans(handle); 1896 ocfs2_commit_trans(handle);
@@ -1994,7 +1994,7 @@ int ocfs2_prepare_truncate(struct ocfs2_super *osb,
1994 goto bail; 1994 goto bail;
1995 } 1995 }
1996 1996
1997 down(&ext_alloc_inode->i_sem); 1997 mutex_lock(&ext_alloc_inode->i_mutex);
1998 (*tc)->tc_ext_alloc_inode = ext_alloc_inode; 1998 (*tc)->tc_ext_alloc_inode = ext_alloc_inode;
1999 1999
2000 status = ocfs2_meta_lock(ext_alloc_inode, 2000 status = ocfs2_meta_lock(ext_alloc_inode,
@@ -2026,7 +2026,7 @@ static void ocfs2_free_truncate_context(struct ocfs2_truncate_context *tc)
2026 if (tc->tc_ext_alloc_locked) 2026 if (tc->tc_ext_alloc_locked)
2027 ocfs2_meta_unlock(tc->tc_ext_alloc_inode, 1); 2027 ocfs2_meta_unlock(tc->tc_ext_alloc_inode, 1);
2028 2028
2029 up(&tc->tc_ext_alloc_inode->i_sem); 2029 mutex_unlock(&tc->tc_ext_alloc_inode->i_mutex);
2030 iput(tc->tc_ext_alloc_inode); 2030 iput(tc->tc_ext_alloc_inode);
2031 } 2031 }
2032 2032
diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c
index 5fd60c105913..cf7828f23361 100644
--- a/fs/ocfs2/cluster/nodemanager.c
+++ b/fs/ocfs2/cluster/nodemanager.c
@@ -653,7 +653,7 @@ static struct config_group *o2nm_cluster_group_make_group(struct config_group *g
653 struct config_group *o2hb_group = NULL, *ret = NULL; 653 struct config_group *o2hb_group = NULL, *ret = NULL;
654 void *defs = NULL; 654 void *defs = NULL;
655 655
656 /* this runs under the parent dir's i_sem; there can be only 656 /* this runs under the parent dir's i_mutex; there can be only
657 * one caller in here at a time */ 657 * one caller in here at a time */
658 if (o2nm_single_cluster) 658 if (o2nm_single_cluster)
659 goto out; /* ENOSPC */ 659 goto out; /* ENOSPC */
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 856e20ae8263..57158fa75d91 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -202,7 +202,7 @@ bail:
202} 202}
203 203
204/* 204/*
205 * NOTE: this should always be called with parent dir i_sem taken. 205 * NOTE: this should always be called with parent dir i_mutex taken.
206 */ 206 */
207int ocfs2_find_files_on_disk(const char *name, 207int ocfs2_find_files_on_disk(const char *name,
208 int namelen, 208 int namelen,
@@ -245,7 +245,7 @@ leave:
245 * Return 0 if the name does not exist 245 * Return 0 if the name does not exist
246 * Return -EEXIST if the directory contains the name 246 * Return -EEXIST if the directory contains the name
247 * 247 *
248 * Callers should have i_sem + a cluster lock on dir 248 * Callers should have i_mutex + a cluster lock on dir
249 */ 249 */
250int ocfs2_check_dir_for_entry(struct inode *dir, 250int ocfs2_check_dir_for_entry(struct inode *dir,
251 const char *name, 251 const char *name,
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 72ae9e3306f4..ca5f9f90d794 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -492,7 +492,7 @@ restart_all:
492 } 492 }
493 493
494 /* blocks peope in read/write from reading our allocation 494 /* blocks peope in read/write from reading our allocation
495 * until we're done changing it. We depend on i_sem to block 495 * until we're done changing it. We depend on i_mutex to block
496 * other extend/truncate calls while we're here. Ordering wrt 496 * other extend/truncate calls while we're here. Ordering wrt
497 * start_trans is important here -- always do it before! */ 497 * start_trans is important here -- always do it before! */
498 down_write(&OCFS2_I(inode)->ip_alloc_sem); 498 down_write(&OCFS2_I(inode)->ip_alloc_sem);
@@ -958,8 +958,8 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
958 filp->f_flags &= ~O_DIRECT; 958 filp->f_flags &= ~O_DIRECT;
959#endif 959#endif
960 960
961 down(&inode->i_sem); 961 mutex_lock(&inode->i_mutex);
962 /* to match setattr's i_sem -> i_alloc_sem -> rw_lock ordering */ 962 /* to match setattr's i_mutex -> i_alloc_sem -> rw_lock ordering */
963 if (filp->f_flags & O_DIRECT) { 963 if (filp->f_flags & O_DIRECT) {
964 have_alloc_sem = 1; 964 have_alloc_sem = 1;
965 down_read(&inode->i_alloc_sem); 965 down_read(&inode->i_alloc_sem);
@@ -1123,7 +1123,7 @@ out:
1123 up_read(&inode->i_alloc_sem); 1123 up_read(&inode->i_alloc_sem);
1124 if (rw_level != -1) 1124 if (rw_level != -1)
1125 ocfs2_rw_unlock(inode, rw_level); 1125 ocfs2_rw_unlock(inode, rw_level);
1126 up(&inode->i_sem); 1126 mutex_unlock(&inode->i_mutex);
1127 1127
1128 mlog_exit(ret); 1128 mlog_exit(ret);
1129 return ret; 1129 return ret;
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index a91ba4dec936..d4ecc0627716 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -485,10 +485,10 @@ static int ocfs2_remove_inode(struct inode *inode,
485 goto bail; 485 goto bail;
486 } 486 }
487 487
488 down(&inode_alloc_inode->i_sem); 488 mutex_lock(&inode_alloc_inode->i_mutex);
489 status = ocfs2_meta_lock(inode_alloc_inode, NULL, &inode_alloc_bh, 1); 489 status = ocfs2_meta_lock(inode_alloc_inode, NULL, &inode_alloc_bh, 1);
490 if (status < 0) { 490 if (status < 0) {
491 up(&inode_alloc_inode->i_sem); 491 mutex_unlock(&inode_alloc_inode->i_mutex);
492 492
493 mlog_errno(status); 493 mlog_errno(status);
494 goto bail; 494 goto bail;
@@ -536,7 +536,7 @@ bail_commit:
536 ocfs2_commit_trans(handle); 536 ocfs2_commit_trans(handle);
537bail_unlock: 537bail_unlock:
538 ocfs2_meta_unlock(inode_alloc_inode, 1); 538 ocfs2_meta_unlock(inode_alloc_inode, 1);
539 up(&inode_alloc_inode->i_sem); 539 mutex_unlock(&inode_alloc_inode->i_mutex);
540 brelse(inode_alloc_bh); 540 brelse(inode_alloc_bh);
541bail: 541bail:
542 iput(inode_alloc_inode); 542 iput(inode_alloc_inode);
@@ -567,10 +567,10 @@ static int ocfs2_wipe_inode(struct inode *inode,
567 /* Lock the orphan dir. The lock will be held for the entire 567 /* Lock the orphan dir. The lock will be held for the entire
568 * delete_inode operation. We do this now to avoid races with 568 * delete_inode operation. We do this now to avoid races with
569 * recovery completion on other nodes. */ 569 * recovery completion on other nodes. */
570 down(&orphan_dir_inode->i_sem); 570 mutex_lock(&orphan_dir_inode->i_mutex);
571 status = ocfs2_meta_lock(orphan_dir_inode, NULL, &orphan_dir_bh, 1); 571 status = ocfs2_meta_lock(orphan_dir_inode, NULL, &orphan_dir_bh, 1);
572 if (status < 0) { 572 if (status < 0) {
573 up(&orphan_dir_inode->i_sem); 573 mutex_unlock(&orphan_dir_inode->i_mutex);
574 574
575 mlog_errno(status); 575 mlog_errno(status);
576 goto bail; 576 goto bail;
@@ -593,7 +593,7 @@ static int ocfs2_wipe_inode(struct inode *inode,
593 593
594bail_unlock_dir: 594bail_unlock_dir:
595 ocfs2_meta_unlock(orphan_dir_inode, 1); 595 ocfs2_meta_unlock(orphan_dir_inode, 1);
596 up(&orphan_dir_inode->i_sem); 596 mutex_unlock(&orphan_dir_inode->i_mutex);
597 brelse(orphan_dir_bh); 597 brelse(orphan_dir_bh);
598bail: 598bail:
599 iput(orphan_dir_inode); 599 iput(orphan_dir_inode);
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 04428042e5e5..303c8d96457f 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -216,7 +216,7 @@ void ocfs2_handle_add_inode(struct ocfs2_journal_handle *handle,
216 atomic_inc(&inode->i_count); 216 atomic_inc(&inode->i_count);
217 217
218 /* we're obviously changing it... */ 218 /* we're obviously changing it... */
219 down(&inode->i_sem); 219 mutex_lock(&inode->i_mutex);
220 220
221 /* sanity check */ 221 /* sanity check */
222 BUG_ON(OCFS2_I(inode)->ip_handle); 222 BUG_ON(OCFS2_I(inode)->ip_handle);
@@ -241,7 +241,7 @@ static void ocfs2_handle_unlock_inodes(struct ocfs2_journal_handle *handle)
241 OCFS2_I(inode)->ip_handle = NULL; 241 OCFS2_I(inode)->ip_handle = NULL;
242 list_del_init(&OCFS2_I(inode)->ip_handle_list); 242 list_del_init(&OCFS2_I(inode)->ip_handle_list);
243 243
244 up(&inode->i_sem); 244 mutex_unlock(&inode->i_mutex);
245 iput(inode); 245 iput(inode);
246 } 246 }
247} 247}
@@ -1433,10 +1433,10 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb,
1433 goto out; 1433 goto out;
1434 } 1434 }
1435 1435
1436 down(&orphan_dir_inode->i_sem); 1436 mutex_lock(&orphan_dir_inode->i_mutex);
1437 status = ocfs2_meta_lock(orphan_dir_inode, NULL, NULL, 0); 1437 status = ocfs2_meta_lock(orphan_dir_inode, NULL, NULL, 0);
1438 if (status < 0) { 1438 if (status < 0) {
1439 up(&orphan_dir_inode->i_sem); 1439 mutex_unlock(&orphan_dir_inode->i_mutex);
1440 mlog_errno(status); 1440 mlog_errno(status);
1441 goto out; 1441 goto out;
1442 } 1442 }
@@ -1451,7 +1451,7 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb,
1451 if (!bh) 1451 if (!bh)
1452 status = -EINVAL; 1452 status = -EINVAL;
1453 if (status < 0) { 1453 if (status < 0) {
1454 up(&orphan_dir_inode->i_sem); 1454 mutex_unlock(&orphan_dir_inode->i_mutex);
1455 if (bh) 1455 if (bh)
1456 brelse(bh); 1456 brelse(bh);
1457 mlog_errno(status); 1457 mlog_errno(status);
@@ -1465,7 +1465,7 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb,
1465 1465
1466 if (!ocfs2_check_dir_entry(orphan_dir_inode, 1466 if (!ocfs2_check_dir_entry(orphan_dir_inode,
1467 de, bh, local)) { 1467 de, bh, local)) {
1468 up(&orphan_dir_inode->i_sem); 1468 mutex_unlock(&orphan_dir_inode->i_mutex);
1469 status = -EINVAL; 1469 status = -EINVAL;
1470 mlog_errno(status); 1470 mlog_errno(status);
1471 brelse(bh); 1471 brelse(bh);
@@ -1509,7 +1509,7 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb,
1509 } 1509 }
1510 brelse(bh); 1510 brelse(bh);
1511 } 1511 }
1512 up(&orphan_dir_inode->i_sem); 1512 mutex_unlock(&orphan_dir_inode->i_mutex);
1513 1513
1514 ocfs2_meta_unlock(orphan_dir_inode, 0); 1514 ocfs2_meta_unlock(orphan_dir_inode, 0);
1515 have_disk_lock = 0; 1515 have_disk_lock = 0;
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index fe373a2101d9..149b35181666 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -334,7 +334,7 @@ int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb,
334 goto bail; 334 goto bail;
335 } 335 }
336 336
337 down(&inode->i_sem); 337 mutex_lock(&inode->i_mutex);
338 338
339 status = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno, 339 status = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno,
340 &alloc_bh, 0, inode); 340 &alloc_bh, 0, inode);
@@ -367,7 +367,7 @@ bail:
367 brelse(alloc_bh); 367 brelse(alloc_bh);
368 368
369 if (inode) { 369 if (inode) {
370 up(&inode->i_sem); 370 mutex_unlock(&inode->i_mutex);
371 iput(inode); 371 iput(inode);
372 } 372 }
373 373
@@ -446,7 +446,7 @@ bail:
446 446
447/* 447/*
448 * make sure we've got at least bitswanted contiguous bits in the 448 * make sure we've got at least bitswanted contiguous bits in the
449 * local alloc. You lose them when you drop i_sem. 449 * local alloc. You lose them when you drop i_mutex.
450 * 450 *
451 * We will add ourselves to the transaction passed in, but may start 451 * We will add ourselves to the transaction passed in, but may start
452 * our own in order to shift windows. 452 * our own in order to shift windows.