Date: Wed, 13 Jul 2011 05:42:04 +0000 (UTC) From: Mikolaj Golub <trociny@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r223975 - stable/8/sbin/hastd Message-ID: <201107130542.p6D5g4qh071207@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: trociny Date: Wed Jul 13 05:42:04 2011 New Revision: 223975 URL: http://svn.freebsd.org/changeset/base/223975 Log: MFC r223654, r223655, r223780, 223974: r223654: 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 r223655, 223974: Check the returned value of activemap_write_complete() and update matadata on disk if needed. This should fix a potential case when extents are cleared in activemap but metadata is not updated on disk. Suggested by: pjd r223780: Remove useless initialization. Approved by: pjd (mentor) Modified: stable/8/sbin/hastd/activemap.c stable/8/sbin/hastd/control.c stable/8/sbin/hastd/primary.c Directory Properties: stable/8/sbin/hastd/ (props changed) Modified: stable/8/sbin/hastd/activemap.c ============================================================================== --- stable/8/sbin/hastd/activemap.c Wed Jul 13 05:32:55 2011 (r223974) +++ stable/8/sbin/hastd/activemap.c Wed Jul 13 05:42:04 2011 (r223975) @@ -205,7 +205,7 @@ keepdirty_find(struct activemap *amp, in 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 */ TAILQ_REMOVE(&->am_keepdirty, kd, kd_next); TAILQ_INSERT_HEAD(&->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 amp->am_nkeepdirty++; TAILQ_INSERT_HEAD(&->am_keepdirty, kd, kd_next); } + + return (true); } static void @@ -308,9 +310,9 @@ activemap_write_start(struct activemap * 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 activema 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; } } Modified: stable/8/sbin/hastd/control.c ============================================================================== --- stable/8/sbin/hastd/control.c Wed Jul 13 05:32:55 2011 (r223974) +++ stable/8/sbin/hastd/control.c Wed Jul 13 05:42:04 2011 (r223975) @@ -155,8 +155,7 @@ control_status_worker(struct hast_resour const char *str; int error; - cnvin = cnvout = NULL; - error = 0; + cnvin = NULL; /* * Prepare and send command to worker process. Modified: stable/8/sbin/hastd/primary.c ============================================================================== --- stable/8/sbin/hastd/primary.c Wed Jul 13 05:32:55 2011 (r223974) +++ stable/8/sbin/hastd/primary.c Wed Jul 13 05:42:04 2011 (r223975) @@ -1687,8 +1687,11 @@ ggate_send_thread(void *arg) } if (ggio->gctl_error == 0 && ggio->gctl_cmd == BIO_WRITE) { mtx_lock(&res->hr_amp_lock); - activemap_write_complete(res->hr_amp, - ggio->gctl_offset, ggio->gctl_length); + if (activemap_write_complete(res->hr_amp, + ggio->gctl_offset, ggio->gctl_length)) { + res->hr_stat_activemap_update++; + (void)hast_activemap_flush(res); + } mtx_unlock(&res->hr_amp_lock); } if (ggio->gctl_cmd == BIO_WRITE) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201107130542.p6D5g4qh071207>