diff options
author | Michael I. Bushnell <mib@gnu.org> | 1995-06-20 01:17:19 +0000 |
---|---|---|
committer | Michael I. Bushnell <mib@gnu.org> | 1995-06-20 01:17:19 +0000 |
commit | 5fba004ecf5c7e226617e9744e65779a415e1b66 (patch) | |
tree | 7787365cb836d6856595742c2d366c6d02e9986c /ufs | |
parent | a11ea13e5c634d839bcfed7e9cd4c2d6da0fcae8 (diff) |
(diskfs_node_iterate): New function.
(write_all_disknodes): Use it.
Diffstat (limited to 'ufs')
-rw-r--r-- | ufs/inode.c | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/ufs/inode.c b/ufs/inode.c index 7f302e47..df5fec17 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -404,17 +404,15 @@ read_symlink_hook (struct node *np, } error_t (*diskfs_read_symlink_hook)(struct node *, char *) = read_symlink_hook; - -/* Write all active disknodes into the dinode pager. */ -void -write_all_disknodes () +error_t +diskfs_node_iterate (error_t (*fun)(struct node *)) { - int n; struct node *np; struct item {struct item *next; struct node *np;} *list = 0; struct item *i; - + error_t err; + /* Acquire a reference on all the nodes in the hash table and enter them into a list on the stack. */ spin_lock (&diskfs_node_refcnt_lock); @@ -428,16 +426,33 @@ write_all_disknodes () list = i; } spin_unlock (&diskfs_node_refcnt_lock); - - /* Update each node. */ + + err = 0; for (i = list; i; i = i->next) { - mutex_lock (&i->np->lock); - diskfs_set_node_times (i->np); - write_node (i->np); - diskfs_nput (i->np); + if (!err) + { + mutex_lock (&i->np->lock); + err = (*fun)(i->np); + mutex_unlock (&i->np->lock); + } + diskfs_nrele (i->np); } } + +/* Write all active disknodes into the dinode pager. */ +void +write_all_disknodes () +{ + error_t + helper (struct node *np) + { + diskfs_set_node_times (np); + write_node (np); + } + + diskfs_node_iterate (helper); +} void diskfs_write_disknode (struct node *np, int wait) |