From nobody Sun Aug 20 04:28:20 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RT2fY0Hzkz4qgkX; Sun, 20 Aug 2023 04:28:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RT2fX6tPFz4QGS; Sun, 20 Aug 2023 04:28:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692505701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Jb1YCWNrgBfkepbQBlrd5WvWO5XjAAoOeumUSTOwIFs=; b=xH3N5LfRRoHu3hyRpkQWBAfK6XCNPb6m2DXIZ3OKG472ibfbz/hP4/ucYcwW/uvYlVPUH1 KByuvC8Fwwyi8cjGKbD0yQRAYchRv1Ip7tYZ+TbwN8svS0Q2AZ/cWWRvLkEiVERUi2Pggu P1C8CTtCxH4cvQjoOM0lqMfn2VHEc9tUMeauCf1R+dmx8Jsu6u+h8GyPg5YkBYvLLUuRdT z/EHlicZSqzgnnWoO3MQIq5qcQU0uefglH9Dzq9IM1dWrtcdX7v2j9oSnswikrVuP5egHT YJGB96XtTFQB9TwIAwBHrppr6/IEzjg5W52RoNLZa/m60aChpwu6OPWtnG9p4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692505701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Jb1YCWNrgBfkepbQBlrd5WvWO5XjAAoOeumUSTOwIFs=; b=BDX7awdkQeoxiqyoHOCqhgqcfEPtpLUQQsYccn45BebCAM8WLxcSdf1FCoXypK/v7Rm6ab /1KZZS6l7RiGZ9RBFSdNJowQSCpsfu3dYzqP/bP0CLzXHi3eWHwyYOh6u+EM5kDn7ZIxZW s/Z3kokAjRsYmuquO4oY6clbhvm5toRl/KOQyR+pcInFkPLmfMoBEHXzNQOfnx2XcjoaYN QMxvSFVNND2Tog6Vea3vVBq3KVFmNrPz6bAx58fMe7lI7IPZMrgs/t1etMqaKPO2dJkBxK DgX5nazuAzgSHzKdvUqAwDsN6vr4eKYICMC7wtGdC/3oqFKCjm/3tF+Tp5zduA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1692505701; a=rsa-sha256; cv=none; b=VoVZzMbWLZr8NAoclpi2i4I8YqSrW1lbvIIPP0UeOtM6TgyuToT9xwDrPwWOSOlGjFER2u uUD+MXKSCFA3spoAwe7DVKICovHQpe5aEugAF4VUACTHKbpvZ/7/s0jo9Uf08MuVoc+jmL WCQTAE+YcglfnAInakMayHH/3gFR1BpMuIWWeNuLuZdLspLu1SiInkBolw1X+1+wtc0Msa eJcwJUNjZaa+oyiPahbtE4vOyE4VZLymppZdFKguQWRovc9ZzKtEZsVeTcTYHaPv8lBeAG BYDIRIoOVQS4T7ObJ0H2pE8YrhDOgCwCfCkzo1ImUGtxs+1Dzkfh7K51CAlOVA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RT2fX5k5Wz9vl; Sun, 20 Aug 2023 04:28:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 37K4SKmi033421; Sun, 20 Aug 2023 04:28:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37K4SKCN033418; Sun, 20 Aug 2023 04:28:20 GMT (envelope-from git) Date: Sun, 20 Aug 2023 04:28:20 GMT Message-Id: <202308200428.37K4SKCN033418@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kirk McKusick Subject: git: 6412782800fa - stable/13 - Support background fsck_ffs(8) on filesystems using journaled soft updates List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mckusick X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6412782800fa535830abf0bba7dc3f9c9b185edf Auto-Submitted: auto-generated The branch stable/13 has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=6412782800fa535830abf0bba7dc3f9c9b185edf commit 6412782800fa535830abf0bba7dc3f9c9b185edf Author: Kirk McKusick AuthorDate: 2023-08-01 20:16:11 +0000 Commit: Kirk McKusick CommitDate: 2023-08-20 04:27:37 +0000 Support background fsck_ffs(8) on filesystems using journaled soft updates Tested-by: Peter Holm Sponsored-by: The FreeBSD Foundation (cherry picked from commit 344b5bf82528575ada304f0df356d2f045772328) --- sbin/fsck_ffs/main.c | 19 +++++++++++-------- sbin/fsck_ffs/suj.c | 25 +++++++++++++++++++------ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index a0746ea0f68e..b31aee18a843 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -274,9 +274,16 @@ checkfilesys(char *filesys) if (bkgrdcheck) { if (sbreadfailed) exit(3); /* Cannot read superblock */ - /* Earlier background failed or journaled */ - if (sblock.fs_flags & (FS_NEEDSFSCK | FS_SUJ)) - exit(4); + if ((sblock.fs_flags & FS_NEEDSFSCK) == FS_NEEDSFSCK) + exit(4); /* Earlier background failed */ + if ((sblock.fs_flags & FS_SUJ) == FS_SUJ) { + maxino = sblock.fs_ncg * sblock.fs_ipg; + maxfsblock = sblock.fs_size; + bufinit(); + preen = 1; + if (suj_check(filesys) == 0) + exit(4); /* Journal good, run it now */ + } if ((sblock.fs_flags & FS_DOSOFTDEP) == 0) exit(5); /* Not running soft updates */ size = MIBSIZE; @@ -350,7 +357,7 @@ checkfilesys(char *filesys) /* * Determine if we can and should do journal recovery. */ - if ((sblock.fs_flags & FS_SUJ) == FS_SUJ) { + if (bkgrdflag == 0 && (sblock.fs_flags & FS_SUJ) == FS_SUJ) { if ((sblock.fs_flags & FS_NEEDSFSCK) != FS_NEEDSFSCK && skipclean) { sujrecovery = 1; @@ -619,10 +626,6 @@ setup_bkgrdchk(struct statfs *mntp, int sbreadfailed, char **filesys) pwarn("FULL FSCK NEEDED, CANNOT RUN IN BACKGROUND\n"); return (0); } - if ((sblock.fs_flags & FS_SUJ) != 0) { - pwarn("JOURNALED FILESYSTEM, CANNOT RUN IN BACKGROUND\n"); - return (0); - } if (skipclean && ckclean && (sblock.fs_flags & (FS_UNCLEAN|FS_NEEDSFSCK)) == 0) { /* diff --git a/sbin/fsck_ffs/suj.c b/sbin/fsck_ffs/suj.c index 1ae9d4d4b675..dda58ce27250 100644 --- a/sbin/fsck_ffs/suj.c +++ b/sbin/fsck_ffs/suj.c @@ -2133,7 +2133,9 @@ suj_verifyino(union dinode *dp) } if (DIP(dp, di_modrev) != fs->fs_mtime) { - printf("Journal timestamp does not match fs mount time\n"); + if (!bkgrdcheck || debug) + printf("Journal timestamp does not match " + "fs mount time\n"); return (-1); } @@ -2434,7 +2436,9 @@ suj_check(const char *filesys) sujino = idesc.id_parent; irelse(&ip); } else { - printf("Journal inode removed. Use tunefs to re-create.\n"); + if (!bkgrdcheck || debug) + printf("Journal inode removed. " + "Use tunefs to re-create.\n"); sblock.fs_flags &= ~FS_SUJ; sblock.fs_sujfree = 0; irelse(&ip); @@ -2445,7 +2449,8 @@ suj_check(const char *filesys) */ ginode(sujino, &ip); jip = ip.i_dp; - printf("** SU+J Recovering %s\n", filesys); + if (!bkgrdcheck || debug) + printf("** SU+J Recovering %s\n", filesys); if (suj_verifyino(jip) != 0 || (!preen && !reply("USE JOURNAL"))) { irelse(&ip); return (-1); @@ -2454,15 +2459,23 @@ suj_check(const char *filesys) * Build a list of journal blocks in jblocks before parsing the * available journal blocks in with suj_read(). */ - printf("** Reading %jd byte journal from inode %ju.\n", - DIP(jip, di_size), (uintmax_t)sujino); + if (!bkgrdcheck || debug) + printf("** Reading %jd byte journal from inode %ju.\n", + DIP(jip, di_size), (uintmax_t)sujino); suj_jblocks = jblocks_create(); blocks = ino_visit(jip, sujino, suj_add_block, 0); if (blocks != numfrags(fs, DIP(jip, di_size))) { - printf("Sparse journal inode %ju.\n", (uintmax_t)sujino); + if (!bkgrdcheck || debug) + printf("Sparse journal inode %ju.\n", + (uintmax_t)sujino); irelse(&ip); return (-1); } + /* If journal is valid then do journal check rather than background */ + if (bkgrdcheck) { + irelse(&ip); + return (0); + } irelse(&ip); suj_read(); jblocks_destroy(suj_jblocks);