Commit 25e41b3d authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Niv Sardi
Browse files

move vn_iowait / vn_iowake into xfs_aops.c



The whole machinery to wait on I/O completion is related to the I/O path
and should be there instead of in xfs_vnode.c.  Also give the functions
more descriptive names.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <david@fromorbit.com>
Signed-off-by: default avatarNiv Sardi <xaiki@sgi.com>
parent 583fa586
Loading
Loading
Loading
Loading
+36 −2
Original line number Diff line number Diff line
@@ -42,6 +42,40 @@
#include <linux/pagevec.h>
#include <linux/writeback.h>


/*
 * Prime number of hash buckets since address is used as the key.
 */
#define NVSYNC		37
#define to_ioend_wq(v)	(&xfs_ioend_wq[((unsigned long)v) % NVSYNC])
static wait_queue_head_t xfs_ioend_wq[NVSYNC];

void __init
xfs_ioend_init(void)
{
	int i;

	for (i = 0; i < NVSYNC; i++)
		init_waitqueue_head(&xfs_ioend_wq[i]);
}

void
xfs_ioend_wait(
	xfs_inode_t	*ip)
{
	wait_queue_head_t *wq = to_ioend_wq(ip);

	wait_event(*wq, (atomic_read(&ip->i_iocount) == 0));
}

STATIC void
xfs_ioend_wake(
	xfs_inode_t	*ip)
{
	if (atomic_dec_and_test(&ip->i_iocount))
		wake_up(to_ioend_wq(ip));
}

STATIC void
xfs_count_page_state(
	struct page		*page,
@@ -164,7 +198,7 @@ xfs_destroy_ioend(
				      __FILE__, __LINE__);
	}

	vn_iowake(ip);
	xfs_ioend_wake(ip);
	mempool_free(ioend, xfs_ioend_pool);
}

@@ -516,7 +550,7 @@ xfs_cancel_ioend(
			unlock_buffer(bh);
		} while ((bh = next_bh) != NULL);

		vn_iowake(XFS_I(ioend->io_inode));
		xfs_ioend_wake(XFS_I(ioend->io_inode));
		mempool_free(ioend, xfs_ioend_pool);
	} while ((ioend = next) != NULL);
}
+3 −0
Original line number Diff line number Diff line
@@ -43,4 +43,7 @@ typedef struct xfs_ioend {
extern const struct address_space_operations xfs_address_space_operations;
extern int xfs_get_blocks(struct inode *, sector_t, struct buffer_head *, int);

extern void xfs_ioend_init(void);
extern void xfs_ioend_wait(struct xfs_inode *);

#endif /* __XFS_AOPS_H__ */
+1 −1
Original line number Diff line number Diff line
@@ -1822,7 +1822,7 @@ init_xfs_fs(void)
			 XFS_BUILD_OPTIONS " enabled\n");

	ktrace_init(64);
	vn_init();
	xfs_ioend_init();
	xfs_dir_startup();

	error = xfs_init_zones();
+1 −1
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ xfs_sync_inodes_ag(
			lock_flags |= XFS_IOLOCK_SHARED;
			error = xfs_flush_pages(ip, 0, -1, fflag, FI_NONE);
			if (flags & SYNC_IOWAIT)
				vn_iowait(ip);
				xfs_ioend_wait(ip);
		}
		xfs_ilock(ip, XFS_ILOCK_SHARED);

+0 −34
Original line number Diff line number Diff line
@@ -32,40 +32,6 @@
#include "xfs_mount.h"


/*
 * Dedicated vnode inactive/reclaim sync wait queues.
 * Prime number of hash buckets since address is used as the key.
 */
#define NVSYNC                  37
#define vptosync(v)             (&vsync[((unsigned long)v) % NVSYNC])
static wait_queue_head_t vsync[NVSYNC];

void __init
vn_init(void)
{
	int i;

	for (i = 0; i < NVSYNC; i++)
		init_waitqueue_head(&vsync[i]);
}

void
vn_iowait(
	xfs_inode_t	*ip)
{
	wait_queue_head_t *wq = vptosync(ip);

	wait_event(*wq, (atomic_read(&ip->i_iocount) == 0));
}

void
vn_iowake(
	xfs_inode_t	*ip)
{
	if (atomic_dec_and_test(&ip->i_iocount))
		wake_up(vptosync(ip));
}

#ifdef	XFS_INODE_TRACE

#define KTRACE_ENTER(ip, vk, s, line, ra)			\
Loading