git: 6412782800fa - stable/13 - Support background fsck_ffs(8) on filesystems using journaled soft updates
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 20 Aug 2023 04:28:20 UTC
The branch stable/13 has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=6412782800fa535830abf0bba7dc3f9c9b185edf commit 6412782800fa535830abf0bba7dc3f9c9b185edf Author: Kirk McKusick <mckusick@FreeBSD.org> AuthorDate: 2023-08-01 20:16:11 +0000 Commit: Kirk McKusick <mckusick@FreeBSD.org> 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);