Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 May 2016 02:13:17 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r299295 - stable/10/sys/fs/ext2fs
Message-ID:  <201605100213.u4A2DHxs022492@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Tue May 10 02:13:17 2016
New Revision: 299295
URL: https://svnweb.freebsd.org/changeset/base/299295

Log:
  MFC r298609:
  ext2fs: make use of the howmany() macro when available.
  
  We have a howmany() macro in the <sys/param.h> header that is
  convenient to re-use as it makes things easier to read.

Modified:
  stable/10/sys/fs/ext2fs/ext2_vfsops.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/fs/ext2fs/ext2_vfsops.c
==============================================================================
--- stable/10/sys/fs/ext2fs/ext2_vfsops.c	Tue May 10 02:02:50 2016	(r299294)
+++ stable/10/sys/fs/ext2fs/ext2_vfsops.c	Tue May 10 02:13:17 2016	(r299295)
@@ -357,10 +357,10 @@ compute_sb_data(struct vnode *devvp, str
 	fs->e2fs_ipb = fs->e2fs_bsize / EXT2_INODE_SIZE(fs);
 	fs->e2fs_itpg = fs->e2fs_ipg / fs->e2fs_ipb;
 	/* s_resuid / s_resgid ? */
-	fs->e2fs_gcount = (es->e2fs_bcount - es->e2fs_first_dblock +
-	    EXT2_BLOCKS_PER_GROUP(fs) - 1) / EXT2_BLOCKS_PER_GROUP(fs);
+	fs->e2fs_gcount = howmany(es->e2fs_bcount - es->e2fs_first_dblock,
+	    EXT2_BLOCKS_PER_GROUP(fs));
 	e2fs_descpb = fs->e2fs_bsize / sizeof(struct ext2_gd);
-	db_count = (fs->e2fs_gcount + e2fs_descpb - 1) / e2fs_descpb;
+	db_count = howmany(fs->e2fs_gcount, e2fs_descpb);
 	fs->e2fs_gdbcount = db_count;
 	fs->e2fs_gd = malloc(db_count * fs->e2fs_bsize,
 	    M_EXT2MNT, M_WAITOK);
@@ -970,7 +970,7 @@ ext2_vget(struct mount *mp, ino_t ino, i
 	 */
 	if (!(ip->i_flag & IN_E4EXTENTS) &&
 	    (S_ISDIR(ip->i_mode) || S_ISREG(ip->i_mode))) {
-		used_blocks = (ip->i_size+fs->e2fs_bsize-1) / fs->e2fs_bsize;
+		used_blocks = howmany(ip->i_size, fs->e2fs_bsize);
 		for (i = used_blocks; i < EXT2_NDIR_BLOCKS; i++)
 			ip->i_db[i] = 0;
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605100213.u4A2DHxs022492>