diff options
author | Christoph Hellwig <hch@lst.de> | 2009-06-08 09:35:05 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@brick.lst.de> | 2009-06-08 09:35:05 -0400 |
commit | 845b6d0cbbc2304e8a54ed4038272c55f85b2269 (patch) | |
tree | 1c8e9270f7e78a0525f1873cef4d017618e06632 | |
parent | 5a34d5cd096310133f9208db294021208a96660d (diff) |
xfs: split inode flushing from xfs_sync_inodes_ag
In many cases we only want to sync inode metadata. Split out the inode
flushing into a separate helper to prepare factoring the inode sync code.
Based on a patch from Dave Chinner, but redone to keep the current behaviour
exactly and leave changes to the flushing logic to another patch.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Sandeen <sandeen@sandeen.net>
-rw-r--r-- | fs/xfs/linux-2.6/xfs_sync.c | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c index 7adc62dd14bb..1712caa12017 100644 --- a/fs/xfs/linux-2.6/xfs_sync.c +++ b/fs/xfs/linux-2.6/xfs_sync.c | |||
@@ -77,6 +77,35 @@ xfs_sync_inode_data( | |||
77 | return error; | 77 | return error; |
78 | } | 78 | } |
79 | 79 | ||
80 | STATIC int | ||
81 | xfs_sync_inode_attr( | ||
82 | struct xfs_inode *ip, | ||
83 | int flags) | ||
84 | { | ||
85 | int error = 0; | ||
86 | |||
87 | xfs_ilock(ip, XFS_ILOCK_SHARED); | ||
88 | if (xfs_inode_clean(ip)) | ||
89 | goto out_unlock; | ||
90 | if (!xfs_iflock_nowait(ip)) { | ||
91 | if (!(flags & SYNC_WAIT)) | ||
92 | goto out_unlock; | ||
93 | xfs_iflock(ip); | ||
94 | } | ||
95 | |||
96 | if (xfs_inode_clean(ip)) { | ||
97 | xfs_ifunlock(ip); | ||
98 | goto out_unlock; | ||
99 | } | ||
100 | |||
101 | error = xfs_iflush(ip, (flags & SYNC_WAIT) ? | ||
102 | XFS_IFLUSH_SYNC : XFS_IFLUSH_DELWRI); | ||
103 | |||
104 | out_unlock: | ||
105 | xfs_iunlock(ip, XFS_ILOCK_SHARED); | ||
106 | return error; | ||
107 | } | ||
108 | |||
80 | /* | 109 | /* |
81 | * Sync all the inodes in the given AG according to the | 110 | * Sync all the inodes in the given AG according to the |
82 | * direction given by the flags. | 111 | * direction given by the flags. |
@@ -96,7 +125,6 @@ xfs_sync_inodes_ag( | |||
96 | do { | 125 | do { |
97 | struct inode *inode; | 126 | struct inode *inode; |
98 | xfs_inode_t *ip = NULL; | 127 | xfs_inode_t *ip = NULL; |
99 | int lock_flags = XFS_ILOCK_SHARED; | ||
100 | 128 | ||
101 | /* | 129 | /* |
102 | * use a gang lookup to find the next inode in the tree | 130 | * use a gang lookup to find the next inode in the tree |
@@ -155,22 +183,10 @@ xfs_sync_inodes_ag( | |||
155 | if (flags & SYNC_DELWRI) | 183 | if (flags & SYNC_DELWRI) |
156 | error = xfs_sync_inode_data(ip, flags); | 184 | error = xfs_sync_inode_data(ip, flags); |
157 | 185 | ||
158 | xfs_ilock(ip, XFS_ILOCK_SHARED); | 186 | if (flags & SYNC_ATTR) |
159 | if ((flags & SYNC_ATTR) && !xfs_inode_clean(ip)) { | 187 | error = xfs_sync_inode_attr(ip, flags); |
160 | if (flags & SYNC_WAIT) { | 188 | |
161 | xfs_iflock(ip); | 189 | IRELE(ip); |
162 | if (!xfs_inode_clean(ip)) | ||
163 | error = xfs_iflush(ip, XFS_IFLUSH_SYNC); | ||
164 | else | ||
165 | xfs_ifunlock(ip); | ||
166 | } else if (xfs_iflock_nowait(ip)) { | ||
167 | if (!xfs_inode_clean(ip)) | ||
168 | error = xfs_iflush(ip, XFS_IFLUSH_DELWRI); | ||
169 | else | ||
170 | xfs_ifunlock(ip); | ||
171 | } | ||
172 | } | ||
173 | xfs_iput(ip, lock_flags); | ||
174 | 190 | ||
175 | if (error) | 191 | if (error) |
176 | last_error = error; | 192 | last_error = error; |