aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2008-12-03 06:20:39 -0500
committerNiv Sardi <xaiki@sgi.com>2008-12-03 23:39:24 -0500
commit25e41b3d521f52771354a718042a753a3e77df0a (patch)
tree947d169a36fad5355abb9bc512a1a488bc13439c /fs/xfs
parent583fa586f0e4a8222dd091ce971b85c1364f3d92 (diff)
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: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <david@fromorbit.com> Signed-off-by: Niv Sardi <xaiki@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c38
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.h3
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c2
-rw-r--r--fs/xfs/linux-2.6/xfs_sync.c2
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.c34
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.h10
-rw-r--r--fs/xfs/xfs_inode.c6
-rw-r--r--fs/xfs/xfs_vnodeops.c7
8 files changed, 48 insertions, 54 deletions
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index f35dba9bf1d9..de3a198f771e 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -42,6 +42,40 @@
42#include <linux/pagevec.h> 42#include <linux/pagevec.h>
43#include <linux/writeback.h> 43#include <linux/writeback.h>
44 44
45
46/*
47 * Prime number of hash buckets since address is used as the key.
48 */
49#define NVSYNC 37
50#define to_ioend_wq(v) (&xfs_ioend_wq[((unsigned long)v) % NVSYNC])
51static wait_queue_head_t xfs_ioend_wq[NVSYNC];
52
53void __init
54xfs_ioend_init(void)
55{
56 int i;
57
58 for (i = 0; i < NVSYNC; i++)
59 init_waitqueue_head(&xfs_ioend_wq[i]);
60}
61
62void
63xfs_ioend_wait(
64 xfs_inode_t *ip)
65{
66 wait_queue_head_t *wq = to_ioend_wq(ip);
67
68 wait_event(*wq, (atomic_read(&ip->i_iocount) == 0));
69}
70
71STATIC void
72xfs_ioend_wake(
73 xfs_inode_t *ip)
74{
75 if (atomic_dec_and_test(&ip->i_iocount))
76 wake_up(to_ioend_wq(ip));
77}
78
45STATIC void 79STATIC void
46xfs_count_page_state( 80xfs_count_page_state(
47 struct page *page, 81 struct page *page,
@@ -164,7 +198,7 @@ xfs_destroy_ioend(
164 __FILE__, __LINE__); 198 __FILE__, __LINE__);
165 } 199 }
166 200
167 vn_iowake(ip); 201 xfs_ioend_wake(ip);
168 mempool_free(ioend, xfs_ioend_pool); 202 mempool_free(ioend, xfs_ioend_pool);
169} 203}
170 204
@@ -516,7 +550,7 @@ xfs_cancel_ioend(
516 unlock_buffer(bh); 550 unlock_buffer(bh);
517 } while ((bh = next_bh) != NULL); 551 } while ((bh = next_bh) != NULL);
518 552
519 vn_iowake(XFS_I(ioend->io_inode)); 553 xfs_ioend_wake(XFS_I(ioend->io_inode));
520 mempool_free(ioend, xfs_ioend_pool); 554 mempool_free(ioend, xfs_ioend_pool);
521 } while ((ioend = next) != NULL); 555 } while ((ioend = next) != NULL);
522} 556}
diff --git a/fs/xfs/linux-2.6/xfs_aops.h b/fs/xfs/linux-2.6/xfs_aops.h
index 3ba0631a3818..7b26f5ff9692 100644
--- a/fs/xfs/linux-2.6/xfs_aops.h
+++ b/fs/xfs/linux-2.6/xfs_aops.h
@@ -43,4 +43,7 @@ typedef struct xfs_ioend {
43extern const struct address_space_operations xfs_address_space_operations; 43extern const struct address_space_operations xfs_address_space_operations;
44extern int xfs_get_blocks(struct inode *, sector_t, struct buffer_head *, int); 44extern int xfs_get_blocks(struct inode *, sector_t, struct buffer_head *, int);
45 45
46extern void xfs_ioend_init(void);
47extern void xfs_ioend_wait(struct xfs_inode *);
48
46#endif /* __XFS_AOPS_H__ */ 49#endif /* __XFS_AOPS_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 4ebbd6820e7f..36f6cc703ef2 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -1822,7 +1822,7 @@ init_xfs_fs(void)
1822 XFS_BUILD_OPTIONS " enabled\n"); 1822 XFS_BUILD_OPTIONS " enabled\n");
1823 1823
1824 ktrace_init(64); 1824 ktrace_init(64);
1825 vn_init(); 1825 xfs_ioend_init();
1826 xfs_dir_startup(); 1826 xfs_dir_startup();
1827 1827
1828 error = xfs_init_zones(); 1828 error = xfs_init_zones();
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c
index d12d31b86fa0..ca5bd2951a84 100644
--- a/fs/xfs/linux-2.6/xfs_sync.c
+++ b/fs/xfs/linux-2.6/xfs_sync.c
@@ -133,7 +133,7 @@ xfs_sync_inodes_ag(
133 lock_flags |= XFS_IOLOCK_SHARED; 133 lock_flags |= XFS_IOLOCK_SHARED;
134 error = xfs_flush_pages(ip, 0, -1, fflag, FI_NONE); 134 error = xfs_flush_pages(ip, 0, -1, fflag, FI_NONE);
135 if (flags & SYNC_IOWAIT) 135 if (flags & SYNC_IOWAIT)
136 vn_iowait(ip); 136 xfs_ioend_wait(ip);
137 } 137 }
138 xfs_ilock(ip, XFS_ILOCK_SHARED); 138 xfs_ilock(ip, XFS_ILOCK_SHARED);
139 139
diff --git a/fs/xfs/linux-2.6/xfs_vnode.c b/fs/xfs/linux-2.6/xfs_vnode.c
index a8cf97a4319a..f6d141122792 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.c
+++ b/fs/xfs/linux-2.6/xfs_vnode.c
@@ -32,40 +32,6 @@
32#include "xfs_mount.h" 32#include "xfs_mount.h"
33 33
34 34
35/*
36 * Dedicated vnode inactive/reclaim sync wait queues.
37 * Prime number of hash buckets since address is used as the key.
38 */
39#define NVSYNC 37
40#define vptosync(v) (&vsync[((unsigned long)v) % NVSYNC])
41static wait_queue_head_t vsync[NVSYNC];
42
43void __init
44vn_init(void)
45{
46 int i;
47
48 for (i = 0; i < NVSYNC; i++)
49 init_waitqueue_head(&vsync[i]);
50}
51
52void
53vn_iowait(
54 xfs_inode_t *ip)
55{
56 wait_queue_head_t *wq = vptosync(ip);
57
58 wait_event(*wq, (atomic_read(&ip->i_iocount) == 0));
59}
60
61void
62vn_iowake(
63 xfs_inode_t *ip)
64{
65 if (atomic_dec_and_test(&ip->i_iocount))
66 wake_up(vptosync(ip));
67}
68
69#ifdef XFS_INODE_TRACE 35#ifdef XFS_INODE_TRACE
70 36
71#define KTRACE_ENTER(ip, vk, s, line, ra) \ 37#define KTRACE_ENTER(ip, vk, s, line, ra) \
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h
index 07fed8837db9..bd3e05c47903 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.h
+++ b/fs/xfs/linux-2.6/xfs_vnode.h
@@ -54,16 +54,6 @@ struct attrlist_cursor_kern;
54 Prevent VM access to the pages until 54 Prevent VM access to the pages until
55 the operation completes. */ 55 the operation completes. */
56 56
57
58extern void vn_init(void);
59
60/*
61 * Yeah, these don't take vnode anymore at all, all this should be
62 * cleaned up at some point.
63 */
64extern void vn_iowait(struct xfs_inode *ip);
65extern void vn_iowake(struct xfs_inode *ip);
66
67#define IHOLD(ip) \ 57#define IHOLD(ip) \
68do { \ 58do { \
69 ASSERT(atomic_read(&VFS_I(ip)->i_count) > 0) ; \ 59 ASSERT(atomic_read(&VFS_I(ip)->i_count) > 0) ; \
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 4e664f57860b..063da344e185 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1322,8 +1322,8 @@ xfs_itrunc_trace(
1322 * direct I/O with the truncate operation. Also, because we hold 1322 * direct I/O with the truncate operation. Also, because we hold
1323 * the IOLOCK in exclusive mode, we prevent new direct I/Os from being 1323 * the IOLOCK in exclusive mode, we prevent new direct I/Os from being
1324 * started until the truncate completes and drops the lock. Essentially, 1324 * started until the truncate completes and drops the lock. Essentially,
1325 * the vn_iowait() call forms an I/O barrier that provides strict ordering 1325 * the xfs_ioend_wait() call forms an I/O barrier that provides strict
1326 * between direct I/Os and the truncate operation. 1326 * ordering between direct I/Os and the truncate operation.
1327 * 1327 *
1328 * The flags parameter can have either the value XFS_ITRUNC_DEFINITE 1328 * The flags parameter can have either the value XFS_ITRUNC_DEFINITE
1329 * or XFS_ITRUNC_MAYBE. The XFS_ITRUNC_MAYBE value should be used 1329 * or XFS_ITRUNC_MAYBE. The XFS_ITRUNC_MAYBE value should be used
@@ -1354,7 +1354,7 @@ xfs_itruncate_start(
1354 1354
1355 /* wait for the completion of any pending DIOs */ 1355 /* wait for the completion of any pending DIOs */
1356 if (new_size == 0 || new_size < ip->i_size) 1356 if (new_size == 0 || new_size < ip->i_size)
1357 vn_iowait(ip); 1357 xfs_ioend_wait(ip);
1358 1358
1359 /* 1359 /*
1360 * Call toss_pages or flushinval_pages to get rid of pages 1360 * Call toss_pages or flushinval_pages to get rid of pages
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index b29a0eb9c0f7..2d57aae0e310 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -338,7 +338,7 @@ xfs_setattr(
338 } 338 }
339 339
340 /* wait for all I/O to complete */ 340 /* wait for all I/O to complete */
341 vn_iowait(ip); 341 xfs_ioend_wait(ip);
342 342
343 if (!code) 343 if (!code)
344 code = xfs_itruncate_data(ip, iattr->ia_size); 344 code = xfs_itruncate_data(ip, iattr->ia_size);
@@ -2758,7 +2758,7 @@ xfs_reclaim(
2758 return 0; 2758 return 0;
2759 } 2759 }
2760 2760
2761 vn_iowait(ip); 2761 xfs_ioend_wait(ip);
2762 2762
2763 ASSERT(XFS_FORCED_SHUTDOWN(ip->i_mount) || ip->i_delayed_blks == 0); 2763 ASSERT(XFS_FORCED_SHUTDOWN(ip->i_mount) || ip->i_delayed_blks == 0);
2764 2764
@@ -3149,7 +3149,8 @@ xfs_free_file_space(
3149 need_iolock = 0; 3149 need_iolock = 0;
3150 if (need_iolock) { 3150 if (need_iolock) {
3151 xfs_ilock(ip, XFS_IOLOCK_EXCL); 3151 xfs_ilock(ip, XFS_IOLOCK_EXCL);
3152 vn_iowait(ip); /* wait for the completion of any pending DIOs */ 3152 /* wait for the completion of any pending DIOs */
3153 xfs_ioend_wait(ip);
3153 } 3154 }
3154 3155
3155 rounding = max_t(uint, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE); 3156 rounding = max_t(uint, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE);