xfs_finish_reclaim currently has a rather odd style using a while
loop and two local variables to implement a restart the list walking
loop operation. Convert this to use a plain goto restart style as
used all over the kernel. Also add a sync_mode argument instead of
always using XFS_IFLUSH_DELWRI_ELSE_ASYNC - a new caller added in
patch three will pass in a different argument.
Signed-off-by: Christoph Hellwig <hch@xxxxxx>
Index: linux-2.6/fs/xfs/xfs_inode.h
===================================================================
--- linux-2.6.orig/fs/xfs/xfs_inode.h 2007-04-24 10:44:38.000000000 +0200
+++ linux-2.6/fs/xfs/xfs_inode.h 2007-04-24 10:44:42.000000000 +0200
@@ -461,7 +461,7 @@ void xfs_iunlock_map_shared(xfs_inode_t
void xfs_ifunlock(xfs_inode_t *);
void xfs_ireclaim(xfs_inode_t *);
int xfs_finish_reclaim(xfs_inode_t *, int, int);
-int xfs_finish_reclaim_all(struct xfs_mount *, int);
+int xfs_finish_reclaim_all(struct xfs_mount *, int, int);
/*
* xfs_inode.c prototypes.
Index: linux-2.6/fs/xfs/xfs_vfsops.c
===================================================================
--- linux-2.6.orig/fs/xfs/xfs_vfsops.c 2007-04-24 10:44:38.000000000 +0200
+++ linux-2.6/fs/xfs/xfs_vfsops.c 2007-04-24 10:45:50.000000000 +0200
@@ -628,7 +628,7 @@ xfs_quiesce_fs(
xfs_refcache_purge_mp(mp);
xfs_flush_buftarg(mp->m_ddev_targp, 0);
- xfs_finish_reclaim_all(mp, 0);
+ xfs_finish_reclaim_all(mp, 0, XFS_IFLUSH_DELWRI_ELSE_ASYNC);
/* This loop must run at least twice.
* The first instance of the loop will flush
@@ -1435,7 +1435,8 @@ xfs_syncsub(
if (flags & (SYNC_ATTR|SYNC_DELWRI)) {
if (flags & SYNC_BDFLUSH)
- xfs_finish_reclaim_all(mp, 1);
+ xfs_finish_reclaim_all(mp, 1,
+ XFS_IFLUSH_DELWRI_ELSE_ASYNC);
else
error = xfs_sync_inodes(mp, flags, bypassed);
}
Index: linux-2.6/fs/xfs/xfs_vnodeops.c
===================================================================
--- linux-2.6.orig/fs/xfs/xfs_vnodeops.c 2007-04-24 10:44:38.000000000
+0200
+++ linux-2.6/fs/xfs/xfs_vnodeops.c 2007-04-24 10:47:37.000000000 +0200
@@ -3908,36 +3908,29 @@ xfs_finish_reclaim(
}
int
-xfs_finish_reclaim_all(xfs_mount_t *mp, int noblock)
+xfs_finish_reclaim_all(
+ xfs_mount_t *mp,
+ int noblock,
+ int sync_mode)
{
- int purged;
xfs_inode_t *ip, *n;
- int done = 0;
- while (!done) {
- purged = 0;
- XFS_MOUNT_ILOCK(mp);
- list_for_each_entry_safe(ip, n, &mp->m_del_inodes, i_reclaim) {
- if (noblock) {
- if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL) == 0)
- continue;
- if (xfs_ipincount(ip) ||
- !xfs_iflock_nowait(ip)) {
- xfs_iunlock(ip, XFS_ILOCK_EXCL);
- continue;
- }
+ restart:
+ XFS_MOUNT_ILOCK(mp);
+ list_for_each_entry_safe(ip, n, &mp->m_del_inodes, i_reclaim) {
+ if (noblock) {
+ if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL) == 0)
+ continue;
+ if (xfs_ipincount(ip) || !xfs_iflock_nowait(ip)) {
+ xfs_iunlock(ip, XFS_ILOCK_EXCL);
+ continue;
}
- XFS_MOUNT_IUNLOCK(mp);
- if (xfs_finish_reclaim(ip, noblock,
- XFS_IFLUSH_DELWRI_ELSE_ASYNC))
- delay(1);
- purged = 1;
- break;
}
-
- done = !purged;
+ XFS_MOUNT_IUNLOCK(mp);
+ if (xfs_finish_reclaim(ip, noblock, sync_mode))
+ delay(1);
+ goto restart;
}
-
XFS_MOUNT_IUNLOCK(mp);
return 0;
}
|