aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_inode.c')
-rw-r--r--fs/xfs/xfs_inode.c68
1 files changed, 12 insertions, 56 deletions
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index fa31360046d4..0ffd56447045 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2439,75 +2439,31 @@ xfs_idestroy_fork(
2439} 2439}
2440 2440
2441/* 2441/*
2442 * Increment the pin count of the given buffer. 2442 * This is called to unpin an inode. The caller must have the inode locked
2443 * This value is protected by ipinlock spinlock in the mount structure. 2443 * in at least shared mode so that the buffer cannot be subsequently pinned
2444 * once someone is waiting for it to be unpinned.
2444 */ 2445 */
2445void 2446static void
2446xfs_ipin( 2447xfs_iunpin_nowait(
2447 xfs_inode_t *ip) 2448 struct xfs_inode *ip)
2448{
2449 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
2450
2451 atomic_inc(&ip->i_pincount);
2452}
2453
2454/*
2455 * Decrement the pin count of the given inode, and wake up
2456 * anyone in xfs_iwait_unpin() if the count goes to 0. The
2457 * inode must have been previously pinned with a call to xfs_ipin().
2458 */
2459void
2460xfs_iunpin(
2461 xfs_inode_t *ip)
2462{
2463 ASSERT(atomic_read(&ip->i_pincount) > 0);
2464
2465 if (atomic_dec_and_test(&ip->i_pincount))
2466 wake_up(&ip->i_ipin_wait);
2467}
2468
2469/*
2470 * This is called to unpin an inode. It can be directed to wait or to return
2471 * immediately without waiting for the inode to be unpinned. The caller must
2472 * have the inode locked in at least shared mode so that the buffer cannot be
2473 * subsequently pinned once someone is waiting for it to be unpinned.
2474 */
2475STATIC void
2476__xfs_iunpin_wait(
2477 xfs_inode_t *ip,
2478 int wait)
2479{ 2449{
2480 xfs_inode_log_item_t *iip = ip->i_itemp;
2481
2482 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); 2450 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED));
2483 if (atomic_read(&ip->i_pincount) == 0)
2484 return;
2485 2451
2486 /* Give the log a push to start the unpinning I/O */ 2452 /* Give the log a push to start the unpinning I/O */
2487 if (iip && iip->ili_last_lsn) 2453 xfs_log_force_lsn(ip->i_mount, ip->i_itemp->ili_last_lsn, 0);
2488 xfs_log_force_lsn(ip->i_mount, iip->ili_last_lsn, 0);
2489 else
2490 xfs_log_force(ip->i_mount, 0);
2491 2454
2492 if (wait)
2493 wait_event(ip->i_ipin_wait, (atomic_read(&ip->i_pincount) == 0));
2494} 2455}
2495 2456
2496void 2457void
2497xfs_iunpin_wait( 2458xfs_iunpin_wait(
2498 xfs_inode_t *ip) 2459 struct xfs_inode *ip)
2499{ 2460{
2500 __xfs_iunpin_wait(ip, 1); 2461 if (xfs_ipincount(ip)) {
2501} 2462 xfs_iunpin_nowait(ip);
2502 2463 wait_event(ip->i_ipin_wait, (xfs_ipincount(ip) == 0));
2503static inline void 2464 }
2504xfs_iunpin_nowait(
2505 xfs_inode_t *ip)
2506{
2507 __xfs_iunpin_wait(ip, 0);
2508} 2465}
2509 2466
2510
2511/* 2467/*
2512 * xfs_iextents_copy() 2468 * xfs_iextents_copy()
2513 * 2469 *