From owner-dev-commits-src-all@freebsd.org Mon May 17 00:16:56 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6ADF863713A; Mon, 17 May 2021 00:16:56 +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 4Fk07D2b6mz4t9f; Mon, 17 May 2021 00:16:56 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 328702216E; Mon, 17 May 2021 00:16:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14H0Guso072172; Mon, 17 May 2021 00:16:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14H0Gurv072171; Mon, 17 May 2021 00:16:56 GMT (envelope-from git) Date: Mon, 17 May 2021 00:16:56 GMT Message-Id: <202105170016.14H0Gurv072171@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: 501b4fb50e80 - stable/13 - Make fsck_ffs more persistent in creating a lost+found directory. 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: 501b4fb50e80d9f34ec85f79a4e438d66f9a00e4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 00:16:56 -0000 The branch stable/13 has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=501b4fb50e80d9f34ec85f79a4e438d66f9a00e4 commit 501b4fb50e80d9f34ec85f79a4e438d66f9a00e4 Author: Kirk McKusick AuthorDate: 2021-04-26 23:47:27 +0000 Commit: Kirk McKusick CommitDate: 2021-05-17 00:18:31 +0000 Make fsck_ffs more persistent in creating a lost+found directory. (cherry picked from commit 84a0e3f95700733695115fb2a9d84d6666efe5d9) Sponsored by: Netflix --- sbin/fsck_ffs/dir.c | 2 ++ sbin/fsck_ffs/fsutil.c | 6 ++++-- sbin/fsck_ffs/inode.c | 19 +++++++++++++------ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/sbin/fsck_ffs/dir.c b/sbin/fsck_ffs/dir.c index e88d1650ce5a..e806f113ff16 100644 --- a/sbin/fsck_ffs/dir.c +++ b/sbin/fsck_ffs/dir.c @@ -801,6 +801,8 @@ allocdir(ino_t parent, ino_t request, int mode) struct dirtemplate *dirp; ino = allocino(request, IFDIR|mode); + if (ino == 0) + return (0); dirp = &dirhead; dirp->dot_ino = ino; dirp->dotdot_ino = parent; diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c index ca19f6726af5..276d543dedc6 100644 --- a/sbin/fsck_ffs/fsutil.c +++ b/sbin/fsck_ffs/fsutil.c @@ -1048,8 +1048,10 @@ allocblk(long frags) cg = dtog(&sblock, i + j); cgbp = cglookup(cg); cgp = cgbp->b_un.b_cg; - if (!check_cgmagic(cg, cgbp, 0)) - return (0); + if (!check_cgmagic(cg, cgbp, 0)) { + i = (cg + 1) * sblock.fs_fpg - sblock.fs_frag; + continue; + } baseblk = dtogd(&sblock, i + j); for (k = 0; k < frags; k++) { setbmap(i + j + k); diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c index 020a69dd72f8..d4e5723f559f 100644 --- a/sbin/fsck_ffs/inode.c +++ b/sbin/fsck_ffs/inode.c @@ -902,22 +902,29 @@ allocino(ino_t request, int type) union dinode *dp; struct bufarea *cgbp; struct cg *cgp; - int cg; + int cg, anyino; - if (request == 0) + anyino = 0; + if (request == 0) { request = UFS_ROOTINO; - else if (inoinfo(request)->ino_state != USTATE) + anyino = 1; + } else if (inoinfo(request)->ino_state != USTATE) return (0); +retry: for (ino = request; ino < maxino; ino++) if (inoinfo(ino)->ino_state == USTATE) break; - if (ino == maxino) + if (ino >= maxino) return (0); cg = ino_to_cg(&sblock, ino); cgbp = cglookup(cg); cgp = cgbp->b_un.b_cg; - if (!check_cgmagic(cg, cgbp, 0)) - return (0); + if (!check_cgmagic(cg, cgbp, 0)) { + if (anyino == 0) + return (0); + request = (cg + 1) * sblock.fs_ipg; + goto retry; + } setbit(cg_inosused(cgp), ino % sblock.fs_ipg); cgp->cg_cs.cs_nifree--; switch (type & IFMT) {