Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 222789
b: refs/heads/master
c: 90810b9
h: refs/heads/master
i:
  222787: f7b0afb
v: v3
  • Loading branch information
Dave Chinner authored and Alex Elder committed Dec 1, 2010
1 parent d96ba0f commit 23fd758
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c726de4409a8d3a03877b1ef4342bfe8a15f5e5e
refs/heads/master: 90810b9e82a36c3c57c1aeb8b2918b242a130b26
35 changes: 16 additions & 19 deletions trunk/fs/xfs/linux-2.6/xfs_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,29 +488,16 @@ _xfs_buf_find(
spin_unlock(&pag->pag_buf_lock);
xfs_perag_put(pag);

/* Attempt to get the semaphore without sleeping,
* if this does not work then we need to drop the
* spinlock and do a hard attempt on the semaphore.
*/
if (down_trylock(&bp->b_sema)) {
if (xfs_buf_cond_lock(bp)) {
/* failed, so wait for the lock if requested. */
if (!(flags & XBF_TRYLOCK)) {
/* wait for buffer ownership */
xfs_buf_lock(bp);
XFS_STATS_INC(xb_get_locked_waited);
} else {
/* We asked for a trylock and failed, no need
* to look at file offset and length here, we
* know that this buffer at least overlaps our
* buffer and is locked, therefore our buffer
* either does not exist, or is this buffer.
*/
xfs_buf_rele(bp);
XFS_STATS_INC(xb_busy_locked);
return NULL;
}
} else {
/* trylock worked */
XB_SET_OWNER(bp);
}

if (bp->b_flags & XBF_STALE) {
Expand Down Expand Up @@ -876,10 +863,18 @@ xfs_buf_rele(
*/

/*
* Locks a buffer object, if it is not already locked.
* Note that this in no way locks the underlying pages, so it is only
* useful for synchronizing concurrent use of buffer objects, not for
* synchronizing independent access to the underlying pages.
* Locks a buffer object, if it is not already locked. Note that this in
* no way locks the underlying pages, so it is only useful for
* synchronizing concurrent use of buffer objects, not for synchronizing
* independent access to the underlying pages.
*
* If we come across a stale, pinned, locked buffer, we know that we are
* being asked to lock a buffer that has been reallocated. Because it is
* pinned, we know that the log has not been pushed to disk and hence it
* will still be locked. Rather than continuing to have trylock attempts
* fail until someone else pushes the log, push it ourselves before
* returning. This means that the xfsaild will not get stuck trying
* to push on stale inode buffers.
*/
int
xfs_buf_cond_lock(
Expand All @@ -890,6 +885,8 @@ xfs_buf_cond_lock(
locked = down_trylock(&bp->b_sema) == 0;
if (locked)
XB_SET_OWNER(bp);
else if (atomic_read(&bp->b_pin_count) && (bp->b_flags & XBF_STALE))
xfs_log_force(bp->b_target->bt_mount, 0);

trace_xfs_buf_cond_lock(bp, _RET_IP_);
return locked ? 0 : -EBUSY;
Expand Down

0 comments on commit 23fd758

Please sign in to comment.