From owner-svn-src-head@freebsd.org Tue Aug 21 18:39:30 2018 Return-Path: Delivered-To: svn-src-head@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 CA2BE107BDF0; Tue, 21 Aug 2018 18:39:30 +0000 (UTC) (envelope-from fsu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 80168916CC; Tue, 21 Aug 2018 18:39:30 +0000 (UTC) (envelope-from fsu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 60DD327C41; Tue, 21 Aug 2018 18:39:30 +0000 (UTC) (envelope-from fsu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w7LIdUHA093278; Tue, 21 Aug 2018 18:39:30 GMT (envelope-from fsu@FreeBSD.org) Received: (from fsu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w7LIdUZV093277; Tue, 21 Aug 2018 18:39:30 GMT (envelope-from fsu@FreeBSD.org) Message-Id: <201808211839.w7LIdUZV093277@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: fsu set sender to fsu@FreeBSD.org using -f From: Fedor Uporov Date: Tue, 21 Aug 2018 18:39:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r338151 - head/sys/fs/ext2fs X-SVN-Group: head X-SVN-Commit-Author: fsu X-SVN-Commit-Paths: head/sys/fs/ext2fs X-SVN-Commit-Revision: 338151 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Aug 2018 18:39:31 -0000 Author: fsu Date: Tue Aug 21 18:39:29 2018 New Revision: 338151 URL: https://svnweb.freebsd.org/changeset/base/338151 Log: Change unused inodes counters behavior in the cylinder groups. Make it more close to native ext4 implementation to avoid fsck errors. Modified: head/sys/fs/ext2fs/ext2_alloc.c Modified: head/sys/fs/ext2fs/ext2_alloc.c ============================================================================== --- head/sys/fs/ext2fs/ext2_alloc.c Tue Aug 21 18:39:02 2018 (r338150) +++ head/sys/fs/ext2fs/ext2_alloc.c Tue Aug 21 18:39:29 2018 (r338151) @@ -1210,7 +1210,7 @@ ext2_nodealloccg(struct inode *ip, int cg, daddr_t ipr struct m_ext2fs *fs; struct buf *bp; struct ext2mount *ump; - int error, start, len; + int error, start, len, ifree; char *ibp, *loc; ipref--; /* to avoid a lot of (ipref -1) */ @@ -1285,9 +1285,12 @@ gotit: e2fs_gd_set_nifree(&fs->e2fs_gd[cg], e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) - 1); if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) || - EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) - e2fs_gd_set_i_unused(&fs->e2fs_gd[cg], - e2fs_gd_get_i_unused(&fs->e2fs_gd[cg]) - 1); + EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) { + ifree = fs->e2fs->e2fs_ipg - e2fs_gd_get_i_unused(&fs->e2fs_gd[cg]); + if (ipref + 1 > ifree) + e2fs_gd_set_i_unused(&fs->e2fs_gd[cg], + fs->e2fs->e2fs_ipg - (ipref + 1)); + } fs->e2fs->e2fs_ficount--; fs->e2fs_fmod = 1; if ((mode & IFMT) == IFDIR) { @@ -1391,10 +1394,6 @@ ext2_vfree(struct vnode *pvp, ino_t ino, int mode) fs->e2fs->e2fs_ficount++; e2fs_gd_set_nifree(&fs->e2fs_gd[cg], e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) + 1); - if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) || - EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) - e2fs_gd_set_i_unused(&fs->e2fs_gd[cg], - e2fs_gd_get_i_unused(&fs->e2fs_gd[cg]) + 1); if ((mode & IFMT) == IFDIR) { e2fs_gd_set_ndirs(&fs->e2fs_gd[cg], e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]) - 1);