From 72f854ce8f359100d957a07da44ae98591d3dfd9 Mon Sep 17 00:00:00 2001 From: Kirk McKusick Date: Wed, 17 Jan 2018 17:58:24 +0000 Subject: Correct fsck journal-recovery code to update a cylinder-group check-hash after making changes to the cylinder group. The problem was that the journal-recovery code was calling the libufs bwrite() function instead of the cgput() function. The cgput() function updates the cylinder-group check-hash before writing the cylinder group. This change required the additions of the cgget() and cgput() functions to the libufs API to avoid a gratuitous bcopy of every cylinder group to be read or written. These new functions have been added to the libufs manual pages. This was the first opportunity that I have had to use and document the use of the EDOOFUS error code. Reviewed by: kib Reported by: emaste and others --- sbin/fsck_ffs/gjournal.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'sbin/fsck_ffs/gjournal.c') diff --git a/sbin/fsck_ffs/gjournal.c b/sbin/fsck_ffs/gjournal.c index ea972dafe916..06505f250f87 100644 --- a/sbin/fsck_ffs/gjournal.c +++ b/sbin/fsck_ffs/gjournal.c @@ -134,9 +134,8 @@ getcg(int cg) if (cgc == NULL) err(1, "malloc(%zu)", sizeof(*cgc)); } - if (cgread1(disk, cg) == -1) - err(1, "cgread1(%d)", cg); - bcopy(&disk->d_cg, &cgc->cgc_cg, sizeof(cgc->cgc_union)); + if (cgget(disk, cg, &cgc->cgc_cg) == -1) + err(1, "cgget(%d)", cg); cgc->cgc_busy = 0; cgc->cgc_dirty = 0; LIST_INSERT_HEAD(&cglist, cgc, cgc_next); @@ -191,10 +190,8 @@ putcgs(void) LIST_REMOVE(cgc, cgc_next); ncgs--; if (cgc->cgc_dirty) { - bcopy(&cgc->cgc_cg, &disk->d_cg, - sizeof(cgc->cgc_union)); - if (cgwrite1(disk, cgc->cgc_cg.cg_cgx) == -1) - err(1, "cgwrite1(%d)", cgc->cgc_cg.cg_cgx); + if (cgput(disk, &cgc->cgc_cg) == -1) + err(1, "cgput(%d)", cgc->cgc_cg.cg_cgx); //printf("%s: Wrote cg=%d\n", __func__, // cgc->cgc_cg.cg_cgx); } -- cgit v1.2.3