summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortrociny <trociny@FreeBSD.org>2011-06-28 20:57:54 +0000
committertrociny <trociny@FreeBSD.org>2011-06-28 20:57:54 +0000
commit55657cdc996887b1bcc18c7890cd4916a682e76e (patch)
tree42c7b34e2f03ae295e1b8c4f465d5590b57ce347
parentb1ee47f4ffcb3c8f187f44d0810f23c8df8613f8 (diff)
downloadFreeBSD-src-55657cdc996887b1bcc18c7890cd4916a682e76e.zip
FreeBSD-src-55657cdc996887b1bcc18c7890cd4916a682e76e.tar.gz
Make activemap_write_start/complete check the keepdirty list, when
stating if we need to update activemap on disk. This makes keepdirty serve its purpose -- to reduce number of metadata updates. Discussed with: pjd Approved by: pjd (mentor)
-rw-r--r--sbin/hastd/activemap.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sbin/hastd/activemap.c b/sbin/hastd/activemap.c
index 2777ac5..127b2c8 100644
--- a/sbin/hastd/activemap.c
+++ b/sbin/hastd/activemap.c
@@ -205,7 +205,7 @@ keepdirty_find(struct activemap *amp, int extent)
return (kd);
}
-static void
+static bool
keepdirty_add(struct activemap *amp, int extent)
{
struct keepdirty *kd;
@@ -217,7 +217,7 @@ keepdirty_add(struct activemap *amp, int extent)
*/
TAILQ_REMOVE(&amp->am_keepdirty, kd, kd_next);
TAILQ_INSERT_HEAD(&amp->am_keepdirty, kd, kd_next);
- return;
+ return (false);
}
/*
* Add new element, but first remove the most unused one if
@@ -238,6 +238,8 @@ keepdirty_add(struct activemap *amp, int extent)
amp->am_nkeepdirty++;
TAILQ_INSERT_HEAD(&amp->am_keepdirty, kd, kd_next);
}
+
+ return (true);
}
static void
@@ -308,9 +310,9 @@ activemap_write_start(struct activemap *amp, off_t offset, off_t length)
assert(!bit_test(amp->am_memmap, ext));
bit_set(amp->am_memmap, ext);
amp->am_ndirty++;
- modified = true;
}
- keepdirty_add(amp, ext);
+ if (keepdirty_add(amp, ext))
+ modified = true;
}
return (modified);
@@ -345,7 +347,8 @@ activemap_write_complete(struct activemap *amp, off_t offset, off_t length)
if (--amp->am_memtab[ext] == 0) {
bit_clear(amp->am_memmap, ext);
amp->am_ndirty--;
- modified = true;
+ if (keepdirty_find(amp, ext) == NULL)
+ modified = true;
}
}
OpenPOWER on IntegriCloud