From owner-svn-src-all@freebsd.org Tue May 7 00:47:53 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 009531599D33; Tue, 7 May 2019 00:47:53 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0A3646A1BC; Tue, 7 May 2019 00:47:51 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id x470ldgN043694 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 7 May 2019 03:47:42 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua x470ldgN043694 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id x470ldL7043693; Tue, 7 May 2019 03:47:39 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 7 May 2019 03:47:39 +0300 From: Konstantin Belousov To: Kirk McKusick Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: Re: svn commit: r347199 - stable/12/sbin/fsck_ffs Message-ID: <20190507004738.GN2748@kib.kiev.ua> References: <201905061913.x46JD44p004260@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201905061913.x46JD44p004260@repo.freebsd.org> User-Agent: Mutt/1.11.4 (2019-03-13) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 May 2019 00:47:53 -0000 On Mon, May 06, 2019 at 07:13:04PM +0000, Kirk McKusick wrote: > Author: mckusick > Date: Mon May 6 19:13:04 2019 > New Revision: 347199 > URL: https://svnweb.freebsd.org/changeset/base/347199 > > Log: > MFC of 345758 I think this was an MFC of r346185. > > Properly flush outstanding I/Os when forcibly deleteing a memory disk device. > > Sponsored by: Netflix > > Modified: > stable/12/sbin/fsck_ffs/fsck.h > stable/12/sbin/fsck_ffs/inode.c > stable/12/sbin/fsck_ffs/pass1.c > Directory Properties: > stable/12/ (props changed) > > Modified: stable/12/sbin/fsck_ffs/fsck.h > ============================================================================== > --- stable/12/sbin/fsck_ffs/fsck.h Mon May 6 19:08:03 2019 (r347198) > +++ stable/12/sbin/fsck_ffs/fsck.h Mon May 6 19:13:04 2019 (r347199) > @@ -231,6 +231,7 @@ struct inodesc { > ino_t id_parent; /* for DATA nodes, their parent */ > ufs_lbn_t id_lbn; /* logical block number of current block */ > ufs2_daddr_t id_blkno; /* current block number being examined */ > + int id_level; /* level of indirection of this block */ > int id_numfrags; /* number of frags contained in block */ > ufs_lbn_t id_lballoc; /* pass1: last LBN that is allocated */ > off_t id_filesize; /* for DATA nodes, the size of the directory */ > > Modified: stable/12/sbin/fsck_ffs/inode.c > ============================================================================== > --- stable/12/sbin/fsck_ffs/inode.c Mon May 6 19:08:03 2019 (r347198) > +++ stable/12/sbin/fsck_ffs/inode.c Mon May 6 19:13:04 2019 (r347199) > @@ -54,7 +54,7 @@ __FBSDID("$FreeBSD$"); > > static ino_t startinum; > > -static int iblock(struct inodesc *, long ilevel, off_t isize, int type); > +static int iblock(struct inodesc *, off_t isize, int type); > > int > ckinode(union dinode *dp, struct inodesc *idesc) > @@ -69,6 +69,8 @@ ckinode(union dinode *dp, struct inodesc *idesc) > if (idesc->id_fix != IGNORE) > idesc->id_fix = DONTKNOW; > idesc->id_lbn = -1; > + idesc->id_lballoc = -1; > + idesc->id_level = 0; > idesc->id_entryno = 0; > idesc->id_filesize = DIP(dp, di_size); > mode = DIP(dp, di_mode) & IFMT; > @@ -121,9 +123,10 @@ ckinode(union dinode *dp, struct inodesc *idesc) > sizepb = sblock.fs_bsize; > for (i = 0; i < UFS_NIADDR; i++) { > sizepb *= NINDIR(&sblock); > + idesc->id_level = i + 1; > if (DIP(&dino, di_ib[i])) { > idesc->id_blkno = DIP(&dino, di_ib[i]); > - ret = iblock(idesc, i + 1, remsize, BT_LEVEL1 + i); > + ret = iblock(idesc, remsize, BT_LEVEL1 + i); > if (ret & STOP) > return (ret); > } else if (remsize > 0) { > @@ -153,7 +156,7 @@ ckinode(union dinode *dp, struct inodesc *idesc) > } > > static int > -iblock(struct inodesc *idesc, long ilevel, off_t isize, int type) > +iblock(struct inodesc *idesc, off_t isize, int type) > { > struct bufarea *bp; > int i, n, (*func)(struct inodesc *), nif; > @@ -171,8 +174,8 @@ iblock(struct inodesc *idesc, long ilevel, off_t isize > if (chkrange(idesc->id_blkno, idesc->id_numfrags)) > return (SKIP); > bp = getdatablk(idesc->id_blkno, sblock.fs_bsize, type); > - ilevel--; > - for (sizepb = sblock.fs_bsize, i = 0; i < ilevel; i++) > + idesc->id_level--; > + for (sizepb = sblock.fs_bsize, i = 0; i < idesc->id_level; i++) > sizepb *= NINDIR(&sblock); > if (howmany(isize, sizepb) > NINDIR(&sblock)) > nif = NINDIR(&sblock); > @@ -194,19 +197,21 @@ iblock(struct inodesc *idesc, long ilevel, off_t isize > flush(fswritefd, bp); > } > for (i = 0; i < nif; i++) { > - if (ilevel == 0) > - idesc->id_lbn++; > if (IBLK(bp, i)) { > idesc->id_blkno = IBLK(bp, i); > - if (ilevel == 0) > + if (idesc->id_level == 0) { > + idesc->id_lbn++; > n = (*func)(idesc); > - else > - n = iblock(idesc, ilevel, isize, type); > + } else { > + n = iblock(idesc, isize, type); > + idesc->id_level++; > + } > if (n & STOP) { > bp->b_flags &= ~B_INUSE; > return (n); > } > } else { > + idesc->id_lbn += sizepb / sblock.fs_bsize; > if (idesc->id_type == DATA && isize > 0) { > /* An empty block in a directory XXX */ > getpathname(pathbuf, idesc->id_number, > > Modified: stable/12/sbin/fsck_ffs/pass1.c > ============================================================================== > --- stable/12/sbin/fsck_ffs/pass1.c Mon May 6 19:08:03 2019 (r347198) > +++ stable/12/sbin/fsck_ffs/pass1.c Mon May 6 19:13:04 2019 (r347199) > @@ -378,7 +378,6 @@ checkinode(ino_t inumber, struct inodesc *idesc, int r > idesc->id_type = SNAP; > else > idesc->id_type = ADDR; > - idesc->id_lballoc = -1; > (void)ckinode(dp, idesc); > if (sblock.fs_magic == FS_UFS2_MAGIC && dp->dp2.di_extsize > 0) { > idesc->id_type = ADDR; > @@ -565,7 +564,7 @@ pass1check(struct inodesc *idesc) > */ > idesc->id_entryno++; > } > - if (idesc->id_lballoc == -1 || idesc->id_lballoc < idesc->id_lbn) > + if (idesc->id_level == 0 && idesc->id_lballoc < idesc->id_lbn) > idesc->id_lballoc = idesc->id_lbn; > return (res); > }