summaryrefslogtreecommitdiff
path: root/ext2fs/pokel.c
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1996-01-15 22:28:56 +0000
committerMiles Bader <miles@gnu.org>1996-01-15 22:28:56 +0000
commitc3e956775fe5d7f57049b15283a62824d9e467e0 (patch)
tree39fd22730259681d9ba298f4da9fbe4fda78c123 /ext2fs/pokel.c
parentd315e19770ed9e01ead822af3c17657e8c209927 (diff)
(pokel_inherit, pokel_finalize): New functions.
Diffstat (limited to 'ext2fs/pokel.c')
-rw-r--r--ext2fs/pokel.c51
1 files changed, 49 insertions, 2 deletions
diff --git a/ext2fs/pokel.c b/ext2fs/pokel.c
index a6d1c65a..85b4d2d1 100644
--- a/ext2fs/pokel.c
+++ b/ext2fs/pokel.c
@@ -22,7 +22,8 @@
#include "ext2fs.h"
-void pokel_init (struct pokel *pokel, struct pager *pager, void *image)
+void
+pokel_init (struct pokel *pokel, struct pager *pager, void *image)
{
pokel->lock = SPIN_LOCK_INITIALIZER;
pokel->pokes = NULL;
@@ -31,6 +32,23 @@ void pokel_init (struct pokel *pokel, struct pager *pager, void *image)
pokel->image = image;
}
+/* Clean up any state associated with POKEL (but don't free POKEL). */
+void
+pokel_finalize (struct pokel *pokel)
+{
+ struct poke *pl, *next;
+ for (pl = pokel->pokes; pl; pl = next)
+ {
+ next = pl->next;
+ free (pl);
+ }
+ for (pl = pokel->free_pokes; pl; pl = next)
+ {
+ next = pl->next;
+ free (pl);
+ }
+}
+
/* Remember that data here on the disk has been modified. */
void
pokel_add (struct pokel *pokel, void *loc, vm_size_t length)
@@ -81,7 +99,7 @@ pokel_add (struct pokel *pokel, void *loc, vm_size_t length)
spin_unlock (&pokel->lock);
}
-
+
/* Move all pending pokes from POKEL into its free list. If SYNC is true,
otherwise do nothing. */
void
@@ -123,3 +141,32 @@ pokel_flush (struct pokel *pokel)
{
_pokel_exec (pokel, 0, 0);
}
+
+/* Transfer all regions from FROM to POKEL, which must have the same pager. */
+void
+pokel_inherit (struct pokel *pokel, struct pokel *from)
+{
+ struct poke *pokes, *last;
+
+ assert (pokel->pager == from->pager);
+ assert (pokel->image == from->image);
+
+ /* Take all pokes from FROM... */
+ spin_lock (&from->lock);
+ pokes = from->pokes;
+ from->pokes = NULL;
+ spin_unlock (&from->lock);
+
+ /* And put them in POKEL. */
+ spin_lock (&pokel->lock);
+ last = pokel->pokes;
+ if (last)
+ {
+ while (last->next)
+ last = last->next;
+ last->next = pokes;
+ }
+ else
+ pokel->pokes = pokes;
+ spin_unlock (&pokel->lock);
+}