mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 12:42:02 +00:00
xfs: replace i_pin_wait with a bit waitqueue
Replace i_pin_wait, which is only used during synchronous inode flushing with a bit waitqueue. This trades off a much smaller inode against slightly slower wakeup performance, and saves 12 (32-bit) or 20 (64-bit) bytes in the XFS inode. Reviewed-by: Alex Elder <aelder@sgi.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Ben Myers <bpm@sgi.com>
This commit is contained in:
parent
474fce0675
commit
f392e6319a
@ -2037,7 +2037,7 @@ xfs_idestroy_fork(
|
|||||||
* once someone is waiting for it to be unpinned.
|
* once someone is waiting for it to be unpinned.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
xfs_iunpin_nowait(
|
xfs_iunpin(
|
||||||
struct xfs_inode *ip)
|
struct xfs_inode *ip)
|
||||||
{
|
{
|
||||||
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED));
|
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED));
|
||||||
@ -2049,14 +2049,29 @@ xfs_iunpin_nowait(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
__xfs_iunpin_wait(
|
||||||
|
struct xfs_inode *ip)
|
||||||
|
{
|
||||||
|
wait_queue_head_t *wq = bit_waitqueue(&ip->i_flags, __XFS_IPINNED_BIT);
|
||||||
|
DEFINE_WAIT_BIT(wait, &ip->i_flags, __XFS_IPINNED_BIT);
|
||||||
|
|
||||||
|
xfs_iunpin(ip);
|
||||||
|
|
||||||
|
do {
|
||||||
|
prepare_to_wait(wq, &wait.wait, TASK_UNINTERRUPTIBLE);
|
||||||
|
if (xfs_ipincount(ip))
|
||||||
|
io_schedule();
|
||||||
|
} while (xfs_ipincount(ip));
|
||||||
|
finish_wait(wq, &wait.wait);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xfs_iunpin_wait(
|
xfs_iunpin_wait(
|
||||||
struct xfs_inode *ip)
|
struct xfs_inode *ip)
|
||||||
{
|
{
|
||||||
if (xfs_ipincount(ip)) {
|
if (xfs_ipincount(ip))
|
||||||
xfs_iunpin_nowait(ip);
|
__xfs_iunpin_wait(ip);
|
||||||
wait_event(ip->i_ipin_wait, (xfs_ipincount(ip) == 0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2415,7 +2430,7 @@ xfs_iflush(
|
|||||||
* out for us if they occur after the log force completes.
|
* out for us if they occur after the log force completes.
|
||||||
*/
|
*/
|
||||||
if (!(flags & SYNC_WAIT) && xfs_ipincount(ip)) {
|
if (!(flags & SYNC_WAIT) && xfs_ipincount(ip)) {
|
||||||
xfs_iunpin_nowait(ip);
|
xfs_iunpin(ip);
|
||||||
xfs_ifunlock(ip);
|
xfs_ifunlock(ip);
|
||||||
return EAGAIN;
|
return EAGAIN;
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,6 @@ typedef struct xfs_inode {
|
|||||||
mrlock_t i_lock; /* inode lock */
|
mrlock_t i_lock; /* inode lock */
|
||||||
mrlock_t i_iolock; /* inode IO lock */
|
mrlock_t i_iolock; /* inode IO lock */
|
||||||
atomic_t i_pincount; /* inode pin count */
|
atomic_t i_pincount; /* inode pin count */
|
||||||
wait_queue_head_t i_ipin_wait; /* inode pinning wait queue */
|
|
||||||
spinlock_t i_flags_lock; /* inode i_flags lock */
|
spinlock_t i_flags_lock; /* inode i_flags lock */
|
||||||
/* Miscellaneous state. */
|
/* Miscellaneous state. */
|
||||||
unsigned long i_flags; /* see defined flags below */
|
unsigned long i_flags; /* see defined flags below */
|
||||||
@ -367,6 +366,8 @@ xfs_set_projid(struct xfs_inode *ip,
|
|||||||
#define XFS_IDIRTY_RELEASE (1 << 6) /* dirty release already seen */
|
#define XFS_IDIRTY_RELEASE (1 << 6) /* dirty release already seen */
|
||||||
#define __XFS_IFLOCK_BIT 7 /* inode is being flushed right now */
|
#define __XFS_IFLOCK_BIT 7 /* inode is being flushed right now */
|
||||||
#define XFS_IFLOCK (1 << __XFS_IFLOCK_BIT)
|
#define XFS_IFLOCK (1 << __XFS_IFLOCK_BIT)
|
||||||
|
#define __XFS_IPINNED_BIT 8 /* wakeup key for zero pin count */
|
||||||
|
#define XFS_IPINNED (1 << __XFS_IPINNED_BIT)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Per-lifetime flags need to be reset when re-using a reclaimable inode during
|
* Per-lifetime flags need to be reset when re-using a reclaimable inode during
|
||||||
|
@ -555,7 +555,7 @@ xfs_inode_item_unpin(
|
|||||||
trace_xfs_inode_unpin(ip, _RET_IP_);
|
trace_xfs_inode_unpin(ip, _RET_IP_);
|
||||||
ASSERT(atomic_read(&ip->i_pincount) > 0);
|
ASSERT(atomic_read(&ip->i_pincount) > 0);
|
||||||
if (atomic_dec_and_test(&ip->i_pincount))
|
if (atomic_dec_and_test(&ip->i_pincount))
|
||||||
wake_up(&ip->i_ipin_wait);
|
wake_up_bit(&ip->i_flags, __XFS_IPINNED_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -828,7 +828,6 @@ xfs_fs_inode_init_once(
|
|||||||
/* xfs inode */
|
/* xfs inode */
|
||||||
atomic_set(&ip->i_pincount, 0);
|
atomic_set(&ip->i_pincount, 0);
|
||||||
spin_lock_init(&ip->i_flags_lock);
|
spin_lock_init(&ip->i_flags_lock);
|
||||||
init_waitqueue_head(&ip->i_ipin_wait);
|
|
||||||
|
|
||||||
mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER,
|
mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER,
|
||||||
"xfsino", ip->i_ino);
|
"xfsino", ip->i_ino);
|
||||||
|
Loading…
Reference in New Issue
Block a user