diff options
author | Christoph Hellwig <hch@lst.de> | 2011-07-08 08:36:19 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2011-07-08 08:36:19 -0400 |
commit | 0c842ad46a51891ac4420b7285613f4134a65ccd (patch) | |
tree | cf82cc7853821a21998114d20b1297b14061eade /fs/xfs | |
parent | bbb4197c73be356a052dac25cce5ed0c157c6c90 (diff) |
xfs: clean up buffer locking helpers
Rename xfs_buf_cond_lock and reverse it's return value to fit most other
trylock operations in the Kernel and XFS (with the exception of down_trylock,
after which xfs_buf_cond_lock was modelled), and replace xfs_buf_lock_val
with an xfs_buf_islocked for use in asserts, or and opencoded variant in
tracing. remove the XFS_BUF_* wrappers for all the locking helpers.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_buf.c | 31 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_buf.h | 9 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_trace.h | 10 | ||||
-rw-r--r-- | fs/xfs/quota/xfs_dquot.c | 6 | ||||
-rw-r--r-- | fs/xfs/xfs_buf_item.c | 6 | ||||
-rw-r--r-- | fs/xfs/xfs_log.c | 6 | ||||
-rw-r--r-- | fs/xfs/xfs_log_recover.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_mount.c | 19 | ||||
-rw-r--r-- | fs/xfs/xfs_trans_buf.c | 4 |
9 files changed, 39 insertions, 54 deletions
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c index 5e68099db2a5..c77227615403 100644 --- a/fs/xfs/linux-2.6/xfs_buf.c +++ b/fs/xfs/linux-2.6/xfs_buf.c | |||
@@ -499,16 +499,14 @@ found: | |||
499 | spin_unlock(&pag->pag_buf_lock); | 499 | spin_unlock(&pag->pag_buf_lock); |
500 | xfs_perag_put(pag); | 500 | xfs_perag_put(pag); |
501 | 501 | ||
502 | if (xfs_buf_cond_lock(bp)) { | 502 | if (!xfs_buf_trylock(bp)) { |
503 | /* failed, so wait for the lock if requested. */ | 503 | if (flags & XBF_TRYLOCK) { |
504 | if (!(flags & XBF_TRYLOCK)) { | ||
505 | xfs_buf_lock(bp); | ||
506 | XFS_STATS_INC(xb_get_locked_waited); | ||
507 | } else { | ||
508 | xfs_buf_rele(bp); | 504 | xfs_buf_rele(bp); |
509 | XFS_STATS_INC(xb_busy_locked); | 505 | XFS_STATS_INC(xb_busy_locked); |
510 | return NULL; | 506 | return NULL; |
511 | } | 507 | } |
508 | xfs_buf_lock(bp); | ||
509 | XFS_STATS_INC(xb_get_locked_waited); | ||
512 | } | 510 | } |
513 | 511 | ||
514 | /* | 512 | /* |
@@ -896,8 +894,8 @@ xfs_buf_rele( | |||
896 | * to push on stale inode buffers. | 894 | * to push on stale inode buffers. |
897 | */ | 895 | */ |
898 | int | 896 | int |
899 | xfs_buf_cond_lock( | 897 | xfs_buf_trylock( |
900 | xfs_buf_t *bp) | 898 | struct xfs_buf *bp) |
901 | { | 899 | { |
902 | int locked; | 900 | int locked; |
903 | 901 | ||
@@ -907,15 +905,8 @@ xfs_buf_cond_lock( | |||
907 | else if (atomic_read(&bp->b_pin_count) && (bp->b_flags & XBF_STALE)) | 905 | else if (atomic_read(&bp->b_pin_count) && (bp->b_flags & XBF_STALE)) |
908 | xfs_log_force(bp->b_target->bt_mount, 0); | 906 | xfs_log_force(bp->b_target->bt_mount, 0); |
909 | 907 | ||
910 | trace_xfs_buf_cond_lock(bp, _RET_IP_); | 908 | trace_xfs_buf_trylock(bp, _RET_IP_); |
911 | return locked ? 0 : -EBUSY; | 909 | return locked; |
912 | } | ||
913 | |||
914 | int | ||
915 | xfs_buf_lock_value( | ||
916 | xfs_buf_t *bp) | ||
917 | { | ||
918 | return bp->b_sema.count; | ||
919 | } | 910 | } |
920 | 911 | ||
921 | /* | 912 | /* |
@@ -929,7 +920,7 @@ xfs_buf_lock_value( | |||
929 | */ | 920 | */ |
930 | void | 921 | void |
931 | xfs_buf_lock( | 922 | xfs_buf_lock( |
932 | xfs_buf_t *bp) | 923 | struct xfs_buf *bp) |
933 | { | 924 | { |
934 | trace_xfs_buf_lock(bp, _RET_IP_); | 925 | trace_xfs_buf_lock(bp, _RET_IP_); |
935 | 926 | ||
@@ -950,7 +941,7 @@ xfs_buf_lock( | |||
950 | */ | 941 | */ |
951 | void | 942 | void |
952 | xfs_buf_unlock( | 943 | xfs_buf_unlock( |
953 | xfs_buf_t *bp) | 944 | struct xfs_buf *bp) |
954 | { | 945 | { |
955 | if ((bp->b_flags & (XBF_DELWRI|_XBF_DELWRI_Q)) == XBF_DELWRI) { | 946 | if ((bp->b_flags & (XBF_DELWRI|_XBF_DELWRI_Q)) == XBF_DELWRI) { |
956 | atomic_inc(&bp->b_hold); | 947 | atomic_inc(&bp->b_hold); |
@@ -1694,7 +1685,7 @@ xfs_buf_delwri_split( | |||
1694 | list_for_each_entry_safe(bp, n, dwq, b_list) { | 1685 | list_for_each_entry_safe(bp, n, dwq, b_list) { |
1695 | ASSERT(bp->b_flags & XBF_DELWRI); | 1686 | ASSERT(bp->b_flags & XBF_DELWRI); |
1696 | 1687 | ||
1697 | if (!XFS_BUF_ISPINNED(bp) && !xfs_buf_cond_lock(bp)) { | 1688 | if (!XFS_BUF_ISPINNED(bp) && xfs_buf_trylock(bp)) { |
1698 | if (!force && | 1689 | if (!force && |
1699 | time_before(jiffies, bp->b_queuetime + age)) { | 1690 | time_before(jiffies, bp->b_queuetime + age)) { |
1700 | xfs_buf_unlock(bp); | 1691 | xfs_buf_unlock(bp); |
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h index 6847dc4dceeb..706c40069116 100644 --- a/fs/xfs/linux-2.6/xfs_buf.h +++ b/fs/xfs/linux-2.6/xfs_buf.h | |||
@@ -187,10 +187,11 @@ extern void xfs_buf_free(xfs_buf_t *); | |||
187 | extern void xfs_buf_rele(xfs_buf_t *); | 187 | extern void xfs_buf_rele(xfs_buf_t *); |
188 | 188 | ||
189 | /* Locking and Unlocking Buffers */ | 189 | /* Locking and Unlocking Buffers */ |
190 | extern int xfs_buf_cond_lock(xfs_buf_t *); | 190 | extern int xfs_buf_trylock(xfs_buf_t *); |
191 | extern int xfs_buf_lock_value(xfs_buf_t *); | ||
192 | extern void xfs_buf_lock(xfs_buf_t *); | 191 | extern void xfs_buf_lock(xfs_buf_t *); |
193 | extern void xfs_buf_unlock(xfs_buf_t *); | 192 | extern void xfs_buf_unlock(xfs_buf_t *); |
193 | #define xfs_buf_islocked(bp) \ | ||
194 | ((bp)->b_sema.count <= 0) | ||
194 | 195 | ||
195 | /* Buffer Read and Write Routines */ | 196 | /* Buffer Read and Write Routines */ |
196 | extern int xfs_bwrite(struct xfs_mount *mp, struct xfs_buf *bp); | 197 | extern int xfs_bwrite(struct xfs_mount *mp, struct xfs_buf *bp); |
@@ -308,10 +309,6 @@ xfs_buf_set_ref( | |||
308 | 309 | ||
309 | #define XFS_BUF_ISPINNED(bp) atomic_read(&((bp)->b_pin_count)) | 310 | #define XFS_BUF_ISPINNED(bp) atomic_read(&((bp)->b_pin_count)) |
310 | 311 | ||
311 | #define XFS_BUF_VALUSEMA(bp) xfs_buf_lock_value(bp) | ||
312 | #define XFS_BUF_CPSEMA(bp) (xfs_buf_cond_lock(bp) == 0) | ||
313 | #define XFS_BUF_VSEMA(bp) xfs_buf_unlock(bp) | ||
314 | #define XFS_BUF_PSEMA(bp,x) xfs_buf_lock(bp) | ||
315 | #define XFS_BUF_FINISH_IOWAIT(bp) complete(&bp->b_iowait); | 312 | #define XFS_BUF_FINISH_IOWAIT(bp) complete(&bp->b_iowait); |
316 | 313 | ||
317 | #define XFS_BUF_SET_TARGET(bp, target) ((bp)->b_target = (target)) | 314 | #define XFS_BUF_SET_TARGET(bp, target) ((bp)->b_target = (target)) |
diff --git a/fs/xfs/linux-2.6/xfs_trace.h b/fs/xfs/linux-2.6/xfs_trace.h index 4fe53f9f0477..3bdfcb9f52b7 100644 --- a/fs/xfs/linux-2.6/xfs_trace.h +++ b/fs/xfs/linux-2.6/xfs_trace.h | |||
@@ -293,7 +293,7 @@ DECLARE_EVENT_CLASS(xfs_buf_class, | |||
293 | __entry->buffer_length = bp->b_buffer_length; | 293 | __entry->buffer_length = bp->b_buffer_length; |
294 | __entry->hold = atomic_read(&bp->b_hold); | 294 | __entry->hold = atomic_read(&bp->b_hold); |
295 | __entry->pincount = atomic_read(&bp->b_pin_count); | 295 | __entry->pincount = atomic_read(&bp->b_pin_count); |
296 | __entry->lockval = xfs_buf_lock_value(bp); | 296 | __entry->lockval = bp->b_sema.count; |
297 | __entry->flags = bp->b_flags; | 297 | __entry->flags = bp->b_flags; |
298 | __entry->caller_ip = caller_ip; | 298 | __entry->caller_ip = caller_ip; |
299 | ), | 299 | ), |
@@ -323,7 +323,7 @@ DEFINE_BUF_EVENT(xfs_buf_bawrite); | |||
323 | DEFINE_BUF_EVENT(xfs_buf_bdwrite); | 323 | DEFINE_BUF_EVENT(xfs_buf_bdwrite); |
324 | DEFINE_BUF_EVENT(xfs_buf_lock); | 324 | DEFINE_BUF_EVENT(xfs_buf_lock); |
325 | DEFINE_BUF_EVENT(xfs_buf_lock_done); | 325 | DEFINE_BUF_EVENT(xfs_buf_lock_done); |
326 | DEFINE_BUF_EVENT(xfs_buf_cond_lock); | 326 | DEFINE_BUF_EVENT(xfs_buf_trylock); |
327 | DEFINE_BUF_EVENT(xfs_buf_unlock); | 327 | DEFINE_BUF_EVENT(xfs_buf_unlock); |
328 | DEFINE_BUF_EVENT(xfs_buf_iowait); | 328 | DEFINE_BUF_EVENT(xfs_buf_iowait); |
329 | DEFINE_BUF_EVENT(xfs_buf_iowait_done); | 329 | DEFINE_BUF_EVENT(xfs_buf_iowait_done); |
@@ -366,7 +366,7 @@ DECLARE_EVENT_CLASS(xfs_buf_flags_class, | |||
366 | __entry->flags = flags; | 366 | __entry->flags = flags; |
367 | __entry->hold = atomic_read(&bp->b_hold); | 367 | __entry->hold = atomic_read(&bp->b_hold); |
368 | __entry->pincount = atomic_read(&bp->b_pin_count); | 368 | __entry->pincount = atomic_read(&bp->b_pin_count); |
369 | __entry->lockval = xfs_buf_lock_value(bp); | 369 | __entry->lockval = bp->b_sema.count; |
370 | __entry->caller_ip = caller_ip; | 370 | __entry->caller_ip = caller_ip; |
371 | ), | 371 | ), |
372 | TP_printk("dev %d:%d bno 0x%llx len 0x%zx hold %d pincount %d " | 372 | TP_printk("dev %d:%d bno 0x%llx len 0x%zx hold %d pincount %d " |
@@ -409,7 +409,7 @@ TRACE_EVENT(xfs_buf_ioerror, | |||
409 | __entry->buffer_length = bp->b_buffer_length; | 409 | __entry->buffer_length = bp->b_buffer_length; |
410 | __entry->hold = atomic_read(&bp->b_hold); | 410 | __entry->hold = atomic_read(&bp->b_hold); |
411 | __entry->pincount = atomic_read(&bp->b_pin_count); | 411 | __entry->pincount = atomic_read(&bp->b_pin_count); |
412 | __entry->lockval = xfs_buf_lock_value(bp); | 412 | __entry->lockval = bp->b_sema.count; |
413 | __entry->error = error; | 413 | __entry->error = error; |
414 | __entry->flags = bp->b_flags; | 414 | __entry->flags = bp->b_flags; |
415 | __entry->caller_ip = caller_ip; | 415 | __entry->caller_ip = caller_ip; |
@@ -454,7 +454,7 @@ DECLARE_EVENT_CLASS(xfs_buf_item_class, | |||
454 | __entry->buf_flags = bip->bli_buf->b_flags; | 454 | __entry->buf_flags = bip->bli_buf->b_flags; |
455 | __entry->buf_hold = atomic_read(&bip->bli_buf->b_hold); | 455 | __entry->buf_hold = atomic_read(&bip->bli_buf->b_hold); |
456 | __entry->buf_pincount = atomic_read(&bip->bli_buf->b_pin_count); | 456 | __entry->buf_pincount = atomic_read(&bip->bli_buf->b_pin_count); |
457 | __entry->buf_lockval = xfs_buf_lock_value(bip->bli_buf); | 457 | __entry->buf_lockval = bip->bli_buf->b_sema.count; |
458 | __entry->li_desc = bip->bli_item.li_desc; | 458 | __entry->li_desc = bip->bli_item.li_desc; |
459 | __entry->li_flags = bip->bli_item.li_flags; | 459 | __entry->li_flags = bip->bli_item.li_flags; |
460 | ), | 460 | ), |
diff --git a/fs/xfs/quota/xfs_dquot.c b/fs/xfs/quota/xfs_dquot.c index 6fa214603819..dec11497a2ef 100644 --- a/fs/xfs/quota/xfs_dquot.c +++ b/fs/xfs/quota/xfs_dquot.c | |||
@@ -318,7 +318,7 @@ xfs_qm_init_dquot_blk( | |||
318 | 318 | ||
319 | ASSERT(tp); | 319 | ASSERT(tp); |
320 | ASSERT(XFS_BUF_ISBUSY(bp)); | 320 | ASSERT(XFS_BUF_ISBUSY(bp)); |
321 | ASSERT(XFS_BUF_VALUSEMA(bp) <= 0); | 321 | ASSERT(xfs_buf_islocked(bp)); |
322 | 322 | ||
323 | d = (xfs_dqblk_t *)XFS_BUF_PTR(bp); | 323 | d = (xfs_dqblk_t *)XFS_BUF_PTR(bp); |
324 | 324 | ||
@@ -534,7 +534,7 @@ xfs_qm_dqtobp( | |||
534 | } | 534 | } |
535 | 535 | ||
536 | ASSERT(XFS_BUF_ISBUSY(bp)); | 536 | ASSERT(XFS_BUF_ISBUSY(bp)); |
537 | ASSERT(XFS_BUF_VALUSEMA(bp) <= 0); | 537 | ASSERT(xfs_buf_islocked(bp)); |
538 | 538 | ||
539 | /* | 539 | /* |
540 | * calculate the location of the dquot inside the buffer. | 540 | * calculate the location of the dquot inside the buffer. |
@@ -622,7 +622,7 @@ xfs_qm_dqread( | |||
622 | * brelse it because we have the changes incore. | 622 | * brelse it because we have the changes incore. |
623 | */ | 623 | */ |
624 | ASSERT(XFS_BUF_ISBUSY(bp)); | 624 | ASSERT(XFS_BUF_ISBUSY(bp)); |
625 | ASSERT(XFS_BUF_VALUSEMA(bp) <= 0); | 625 | ASSERT(xfs_buf_islocked(bp)); |
626 | xfs_trans_brelse(tp, bp); | 626 | xfs_trans_brelse(tp, bp); |
627 | 627 | ||
628 | return (error); | 628 | return (error); |
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c index 7b7e005e3dcc..da399ac4411d 100644 --- a/fs/xfs/xfs_buf_item.c +++ b/fs/xfs/xfs_buf_item.c | |||
@@ -420,7 +420,7 @@ xfs_buf_item_unpin( | |||
420 | 420 | ||
421 | if (freed && stale) { | 421 | if (freed && stale) { |
422 | ASSERT(bip->bli_flags & XFS_BLI_STALE); | 422 | ASSERT(bip->bli_flags & XFS_BLI_STALE); |
423 | ASSERT(XFS_BUF_VALUSEMA(bp) <= 0); | 423 | ASSERT(xfs_buf_islocked(bp)); |
424 | ASSERT(!(XFS_BUF_ISDELAYWRITE(bp))); | 424 | ASSERT(!(XFS_BUF_ISDELAYWRITE(bp))); |
425 | ASSERT(XFS_BUF_ISSTALE(bp)); | 425 | ASSERT(XFS_BUF_ISSTALE(bp)); |
426 | ASSERT(bip->bli_format.blf_flags & XFS_BLF_CANCEL); | 426 | ASSERT(bip->bli_format.blf_flags & XFS_BLF_CANCEL); |
@@ -483,7 +483,7 @@ xfs_buf_item_trylock( | |||
483 | 483 | ||
484 | if (XFS_BUF_ISPINNED(bp)) | 484 | if (XFS_BUF_ISPINNED(bp)) |
485 | return XFS_ITEM_PINNED; | 485 | return XFS_ITEM_PINNED; |
486 | if (!XFS_BUF_CPSEMA(bp)) | 486 | if (!xfs_buf_trylock(bp)) |
487 | return XFS_ITEM_LOCKED; | 487 | return XFS_ITEM_LOCKED; |
488 | 488 | ||
489 | /* take a reference to the buffer. */ | 489 | /* take a reference to the buffer. */ |
@@ -905,7 +905,7 @@ xfs_buf_attach_iodone( | |||
905 | xfs_log_item_t *head_lip; | 905 | xfs_log_item_t *head_lip; |
906 | 906 | ||
907 | ASSERT(XFS_BUF_ISBUSY(bp)); | 907 | ASSERT(XFS_BUF_ISBUSY(bp)); |
908 | ASSERT(XFS_BUF_VALUSEMA(bp) <= 0); | 908 | ASSERT(xfs_buf_islocked(bp)); |
909 | 909 | ||
910 | lip->li_cb = cb; | 910 | lip->li_cb = cb; |
911 | if (XFS_BUF_FSPRIVATE(bp, void *) != NULL) { | 911 | if (XFS_BUF_FSPRIVATE(bp, void *) != NULL) { |
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 5b24a71811f8..68e053ea6e78 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -1059,7 +1059,7 @@ xlog_alloc_log(xfs_mount_t *mp, | |||
1059 | XFS_BUF_SET_IODONE_FUNC(bp, xlog_iodone); | 1059 | XFS_BUF_SET_IODONE_FUNC(bp, xlog_iodone); |
1060 | XFS_BUF_SET_FSPRIVATE2(bp, (unsigned long)1); | 1060 | XFS_BUF_SET_FSPRIVATE2(bp, (unsigned long)1); |
1061 | ASSERT(XFS_BUF_ISBUSY(bp)); | 1061 | ASSERT(XFS_BUF_ISBUSY(bp)); |
1062 | ASSERT(XFS_BUF_VALUSEMA(bp) <= 0); | 1062 | ASSERT(xfs_buf_islocked(bp)); |
1063 | log->l_xbuf = bp; | 1063 | log->l_xbuf = bp; |
1064 | 1064 | ||
1065 | spin_lock_init(&log->l_icloglock); | 1065 | spin_lock_init(&log->l_icloglock); |
@@ -1090,7 +1090,7 @@ xlog_alloc_log(xfs_mount_t *mp, | |||
1090 | log->l_iclog_size, 0); | 1090 | log->l_iclog_size, 0); |
1091 | if (!bp) | 1091 | if (!bp) |
1092 | goto out_free_iclog; | 1092 | goto out_free_iclog; |
1093 | if (!XFS_BUF_CPSEMA(bp)) | 1093 | if (!xfs_buf_trylock(bp)) |
1094 | ASSERT(0); | 1094 | ASSERT(0); |
1095 | XFS_BUF_SET_IODONE_FUNC(bp, xlog_iodone); | 1095 | XFS_BUF_SET_IODONE_FUNC(bp, xlog_iodone); |
1096 | XFS_BUF_SET_FSPRIVATE2(bp, (unsigned long)1); | 1096 | XFS_BUF_SET_FSPRIVATE2(bp, (unsigned long)1); |
@@ -1118,7 +1118,7 @@ xlog_alloc_log(xfs_mount_t *mp, | |||
1118 | iclog->ic_datap = (char *)iclog->ic_data + log->l_iclog_hsize; | 1118 | iclog->ic_datap = (char *)iclog->ic_data + log->l_iclog_hsize; |
1119 | 1119 | ||
1120 | ASSERT(XFS_BUF_ISBUSY(iclog->ic_bp)); | 1120 | ASSERT(XFS_BUF_ISBUSY(iclog->ic_bp)); |
1121 | ASSERT(XFS_BUF_VALUSEMA(iclog->ic_bp) <= 0); | 1121 | ASSERT(xfs_buf_islocked(iclog->ic_bp)); |
1122 | init_waitqueue_head(&iclog->ic_force_wait); | 1122 | init_waitqueue_head(&iclog->ic_force_wait); |
1123 | init_waitqueue_head(&iclog->ic_write_wait); | 1123 | init_waitqueue_head(&iclog->ic_write_wait); |
1124 | 1124 | ||
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index fb528b354c0d..a74e26408343 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -264,7 +264,7 @@ xlog_bwrite( | |||
264 | XFS_BUF_ZEROFLAGS(bp); | 264 | XFS_BUF_ZEROFLAGS(bp); |
265 | XFS_BUF_BUSY(bp); | 265 | XFS_BUF_BUSY(bp); |
266 | XFS_BUF_HOLD(bp); | 266 | XFS_BUF_HOLD(bp); |
267 | XFS_BUF_PSEMA(bp, PRIBIO); | 267 | xfs_buf_lock(bp); |
268 | XFS_BUF_SET_COUNT(bp, BBTOB(nbblks)); | 268 | XFS_BUF_SET_COUNT(bp, BBTOB(nbblks)); |
269 | XFS_BUF_SET_TARGET(bp, log->l_mp->m_logdev_targp); | 269 | XFS_BUF_SET_TARGET(bp, log->l_mp->m_logdev_targp); |
270 | 270 | ||
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 63659ee316bd..77ffe3ce71fe 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c | |||
@@ -1941,22 +1941,19 @@ unwind: | |||
1941 | * the superblock buffer if it can be locked without sleeping. | 1941 | * the superblock buffer if it can be locked without sleeping. |
1942 | * If it can't then we'll return NULL. | 1942 | * If it can't then we'll return NULL. |
1943 | */ | 1943 | */ |
1944 | xfs_buf_t * | 1944 | struct xfs_buf * |
1945 | xfs_getsb( | 1945 | xfs_getsb( |
1946 | xfs_mount_t *mp, | 1946 | struct xfs_mount *mp, |
1947 | int flags) | 1947 | int flags) |
1948 | { | 1948 | { |
1949 | xfs_buf_t *bp; | 1949 | struct xfs_buf *bp = mp->m_sb_bp; |
1950 | 1950 | ||
1951 | ASSERT(mp->m_sb_bp != NULL); | 1951 | if (!xfs_buf_trylock(bp)) { |
1952 | bp = mp->m_sb_bp; | 1952 | if (flags & XBF_TRYLOCK) |
1953 | if (flags & XBF_TRYLOCK) { | ||
1954 | if (!XFS_BUF_CPSEMA(bp)) { | ||
1955 | return NULL; | 1953 | return NULL; |
1956 | } | 1954 | xfs_buf_lock(bp); |
1957 | } else { | ||
1958 | XFS_BUF_PSEMA(bp, PRIBIO); | ||
1959 | } | 1955 | } |
1956 | |||
1960 | XFS_BUF_HOLD(bp); | 1957 | XFS_BUF_HOLD(bp); |
1961 | ASSERT(XFS_BUF_ISDONE(bp)); | 1958 | ASSERT(XFS_BUF_ISDONE(bp)); |
1962 | return bp; | 1959 | return bp; |
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c index 03b3b7f85a3b..bd5445787855 100644 --- a/fs/xfs/xfs_trans_buf.c +++ b/fs/xfs/xfs_trans_buf.c | |||
@@ -160,7 +160,7 @@ xfs_trans_get_buf(xfs_trans_t *tp, | |||
160 | */ | 160 | */ |
161 | bp = xfs_trans_buf_item_match(tp, target_dev, blkno, len); | 161 | bp = xfs_trans_buf_item_match(tp, target_dev, blkno, len); |
162 | if (bp != NULL) { | 162 | if (bp != NULL) { |
163 | ASSERT(XFS_BUF_VALUSEMA(bp) <= 0); | 163 | ASSERT(xfs_buf_islocked(bp)); |
164 | if (XFS_FORCED_SHUTDOWN(tp->t_mountp)) | 164 | if (XFS_FORCED_SHUTDOWN(tp->t_mountp)) |
165 | XFS_BUF_SUPER_STALE(bp); | 165 | XFS_BUF_SUPER_STALE(bp); |
166 | 166 | ||
@@ -327,7 +327,7 @@ xfs_trans_read_buf( | |||
327 | */ | 327 | */ |
328 | bp = xfs_trans_buf_item_match(tp, target, blkno, len); | 328 | bp = xfs_trans_buf_item_match(tp, target, blkno, len); |
329 | if (bp != NULL) { | 329 | if (bp != NULL) { |
330 | ASSERT(XFS_BUF_VALUSEMA(bp) <= 0); | 330 | ASSERT(xfs_buf_islocked(bp)); |
331 | ASSERT(XFS_BUF_FSPRIVATE2(bp, xfs_trans_t *) == tp); | 331 | ASSERT(XFS_BUF_FSPRIVATE2(bp, xfs_trans_t *) == tp); |
332 | ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL); | 332 | ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL); |
333 | ASSERT((XFS_BUF_ISERROR(bp)) == 0); | 333 | ASSERT((XFS_BUF_ISERROR(bp)) == 0); |