aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Piggin <npiggin@suse.de>2008-08-02 06:02:13 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-08-05 00:56:09 -0400
commitca5de404ff036a29b25e9a83f6919c9f606c5841 (patch)
tree474da867c4d4086313cee90cdc3560bb17fade96
parent529ae9aaa08378cfe2a4350bded76f32cc8ff0ce (diff)
fs: rename buffer trylock
Like the page lock change, this also requires name change, so convert the raw test_and_set bitop to a trylock. Signed-off-by: Nick Piggin <npiggin@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/buffer.c4
-rw-r--r--fs/jbd/commit.c2
-rw-r--r--fs/ntfs/aops.c2
-rw-r--r--fs/ntfs/compress.c2
-rw-r--r--fs/ntfs/mft.c4
-rw-r--r--fs/reiserfs/inode.c2
-rw-r--r--fs/reiserfs/journal.c4
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c2
-rw-r--r--include/linux/buffer_head.h8
9 files changed, 17 insertions, 13 deletions
diff --git a/fs/buffer.c b/fs/buffer.c
index 4dbe52948e8f..38653e36e225 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1720,7 +1720,7 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
1720 */ 1720 */
1721 if (wbc->sync_mode != WB_SYNC_NONE || !wbc->nonblocking) { 1721 if (wbc->sync_mode != WB_SYNC_NONE || !wbc->nonblocking) {
1722 lock_buffer(bh); 1722 lock_buffer(bh);
1723 } else if (test_set_buffer_locked(bh)) { 1723 } else if (!trylock_buffer(bh)) {
1724 redirty_page_for_writepage(wbc, page); 1724 redirty_page_for_writepage(wbc, page);
1725 continue; 1725 continue;
1726 } 1726 }
@@ -3000,7 +3000,7 @@ void ll_rw_block(int rw, int nr, struct buffer_head *bhs[])
3000 3000
3001 if (rw == SWRITE || rw == SWRITE_SYNC) 3001 if (rw == SWRITE || rw == SWRITE_SYNC)
3002 lock_buffer(bh); 3002 lock_buffer(bh);
3003 else if (test_set_buffer_locked(bh)) 3003 else if (!trylock_buffer(bh))
3004 continue; 3004 continue;
3005 3005
3006 if (rw == WRITE || rw == SWRITE || rw == SWRITE_SYNC) { 3006 if (rw == WRITE || rw == SWRITE || rw == SWRITE_SYNC) {
diff --git a/fs/jbd/commit.c b/fs/jbd/commit.c
index 81a9ad7177ca..ae08c057e751 100644
--- a/fs/jbd/commit.c
+++ b/fs/jbd/commit.c
@@ -221,7 +221,7 @@ write_out_data:
221 * blocking lock_buffer(). 221 * blocking lock_buffer().
222 */ 222 */
223 if (buffer_dirty(bh)) { 223 if (buffer_dirty(bh)) {
224 if (test_set_buffer_locked(bh)) { 224 if (!trylock_buffer(bh)) {
225 BUFFER_TRACE(bh, "needs blocking lock"); 225 BUFFER_TRACE(bh, "needs blocking lock");
226 spin_unlock(&journal->j_list_lock); 226 spin_unlock(&journal->j_list_lock);
227 /* Write out all data to prevent deadlocks */ 227 /* Write out all data to prevent deadlocks */
diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c
index 00e9ccde8e42..b38f944f0667 100644
--- a/fs/ntfs/aops.c
+++ b/fs/ntfs/aops.c
@@ -1194,7 +1194,7 @@ lock_retry_remap:
1194 tbh = bhs[i]; 1194 tbh = bhs[i];
1195 if (!tbh) 1195 if (!tbh)
1196 continue; 1196 continue;
1197 if (unlikely(test_set_buffer_locked(tbh))) 1197 if (!trylock_buffer(tbh))
1198 BUG(); 1198 BUG();
1199 /* The buffer dirty state is now irrelevant, just clean it. */ 1199 /* The buffer dirty state is now irrelevant, just clean it. */
1200 clear_buffer_dirty(tbh); 1200 clear_buffer_dirty(tbh);
diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
index 33ff314cc507..9669541d0119 100644
--- a/fs/ntfs/compress.c
+++ b/fs/ntfs/compress.c
@@ -665,7 +665,7 @@ lock_retry_remap:
665 for (i = 0; i < nr_bhs; i++) { 665 for (i = 0; i < nr_bhs; i++) {
666 struct buffer_head *tbh = bhs[i]; 666 struct buffer_head *tbh = bhs[i];
667 667
668 if (unlikely(test_set_buffer_locked(tbh))) 668 if (!trylock_buffer(tbh))
669 continue; 669 continue;
670 if (unlikely(buffer_uptodate(tbh))) { 670 if (unlikely(buffer_uptodate(tbh))) {
671 unlock_buffer(tbh); 671 unlock_buffer(tbh);
diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
index 790defb847e7..17d32ca6bc35 100644
--- a/fs/ntfs/mft.c
+++ b/fs/ntfs/mft.c
@@ -586,7 +586,7 @@ int ntfs_sync_mft_mirror(ntfs_volume *vol, const unsigned long mft_no,
586 for (i_bhs = 0; i_bhs < nr_bhs; i_bhs++) { 586 for (i_bhs = 0; i_bhs < nr_bhs; i_bhs++) {
587 struct buffer_head *tbh = bhs[i_bhs]; 587 struct buffer_head *tbh = bhs[i_bhs];
588 588
589 if (unlikely(test_set_buffer_locked(tbh))) 589 if (!trylock_buffer(tbh))
590 BUG(); 590 BUG();
591 BUG_ON(!buffer_uptodate(tbh)); 591 BUG_ON(!buffer_uptodate(tbh));
592 clear_buffer_dirty(tbh); 592 clear_buffer_dirty(tbh);
@@ -779,7 +779,7 @@ int write_mft_record_nolock(ntfs_inode *ni, MFT_RECORD *m, int sync)
779 for (i_bhs = 0; i_bhs < nr_bhs; i_bhs++) { 779 for (i_bhs = 0; i_bhs < nr_bhs; i_bhs++) {
780 struct buffer_head *tbh = bhs[i_bhs]; 780 struct buffer_head *tbh = bhs[i_bhs];
781 781
782 if (unlikely(test_set_buffer_locked(tbh))) 782 if (!trylock_buffer(tbh))
783 BUG(); 783 BUG();
784 BUG_ON(!buffer_uptodate(tbh)); 784 BUG_ON(!buffer_uptodate(tbh));
785 clear_buffer_dirty(tbh); 785 clear_buffer_dirty(tbh);
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 192269698a8a..5699171212ae 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -2435,7 +2435,7 @@ static int reiserfs_write_full_page(struct page *page,
2435 if (wbc->sync_mode != WB_SYNC_NONE || !wbc->nonblocking) { 2435 if (wbc->sync_mode != WB_SYNC_NONE || !wbc->nonblocking) {
2436 lock_buffer(bh); 2436 lock_buffer(bh);
2437 } else { 2437 } else {
2438 if (test_set_buffer_locked(bh)) { 2438 if (!trylock_buffer(bh)) {
2439 redirty_page_for_writepage(wbc, page); 2439 redirty_page_for_writepage(wbc, page);
2440 continue; 2440 continue;
2441 } 2441 }
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index ce2208b27118..c21df71943a6 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -855,7 +855,7 @@ static int write_ordered_buffers(spinlock_t * lock,
855 jh = JH_ENTRY(list->next); 855 jh = JH_ENTRY(list->next);
856 bh = jh->bh; 856 bh = jh->bh;
857 get_bh(bh); 857 get_bh(bh);
858 if (test_set_buffer_locked(bh)) { 858 if (!trylock_buffer(bh)) {
859 if (!buffer_dirty(bh)) { 859 if (!buffer_dirty(bh)) {
860 list_move(&jh->list, &tmp); 860 list_move(&jh->list, &tmp);
861 goto loop_next; 861 goto loop_next;
@@ -3871,7 +3871,7 @@ int reiserfs_prepare_for_journal(struct super_block *p_s_sb,
3871{ 3871{
3872 PROC_INFO_INC(p_s_sb, journal.prepare); 3872 PROC_INFO_INC(p_s_sb, journal.prepare);
3873 3873
3874 if (test_set_buffer_locked(bh)) { 3874 if (!trylock_buffer(bh)) {
3875 if (!wait) 3875 if (!wait)
3876 return 0; 3876 return 0;
3877 lock_buffer(bh); 3877 lock_buffer(bh);
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index fa73179233ad..fa47e43b8b41 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -1104,7 +1104,7 @@ xfs_page_state_convert(
1104 * that we are writing into for the first time. 1104 * that we are writing into for the first time.
1105 */ 1105 */
1106 type = IOMAP_NEW; 1106 type = IOMAP_NEW;
1107 if (!test_and_set_bit(BH_Lock, &bh->b_state)) { 1107 if (trylock_buffer(bh)) {
1108 ASSERT(buffer_mapped(bh)); 1108 ASSERT(buffer_mapped(bh));
1109 if (iomap_valid) 1109 if (iomap_valid)
1110 all_bh = 1; 1110 all_bh = 1;
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index 50cfe8ceb478..eadaab44015f 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -115,7 +115,6 @@ BUFFER_FNS(Uptodate, uptodate)
115BUFFER_FNS(Dirty, dirty) 115BUFFER_FNS(Dirty, dirty)
116TAS_BUFFER_FNS(Dirty, dirty) 116TAS_BUFFER_FNS(Dirty, dirty)
117BUFFER_FNS(Lock, locked) 117BUFFER_FNS(Lock, locked)
118TAS_BUFFER_FNS(Lock, locked)
119BUFFER_FNS(Req, req) 118BUFFER_FNS(Req, req)
120TAS_BUFFER_FNS(Req, req) 119TAS_BUFFER_FNS(Req, req)
121BUFFER_FNS(Mapped, mapped) 120BUFFER_FNS(Mapped, mapped)
@@ -321,10 +320,15 @@ static inline void wait_on_buffer(struct buffer_head *bh)
321 __wait_on_buffer(bh); 320 __wait_on_buffer(bh);
322} 321}
323 322
323static inline int trylock_buffer(struct buffer_head *bh)
324{
325 return likely(!test_and_set_bit(BH_Lock, &bh->b_state));
326}
327
324static inline void lock_buffer(struct buffer_head *bh) 328static inline void lock_buffer(struct buffer_head *bh)
325{ 329{
326 might_sleep(); 330 might_sleep();
327 if (test_set_buffer_locked(bh)) 331 if (!trylock_buffer(bh))
328 __lock_buffer(bh); 332 __lock_buffer(bh);
329} 333}
330 334