Subject: kern/3389: fs_cgrotor value updated but never read
To: None <gnats-bugs@gnats.netbsd.org>
From: None <bouyer@masi.ibp.fr>
List: netbsd-bugs
Date: 03/25/1997 12:49:49
>Number:         3389
>Category:       kern
>Synopsis:       fs_cgrotor value updated but never read
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Mar 25 04:05:01 1997
>Last-Modified:
>Originator:     Manuel BOUYER
>Organization:

MASI, Universite Paris VI.

>Release:        current, 1997/03/07
>Environment:

System: NetBSD antifer.ibp.fr 1.2C NetBSD 1.2C (ANTIFER) #3: Fri Mar 21 09:54:40 MET 1997 bouyer@antifer.ibp.fr:/mnt/bouyer/src_current/sys/arch/i386/compile/ANTIFER i386


>Description:
	While browsing the code of ffs blocks allocations, I figured that the
	fs_cgrotor field of the superblock is updated twice in ufs/ffs/ffs_alloc.c,
	but this value is never used. So I think the two relevant lines could
	be removed (this would save a few cycles per allocations :)
	I'm running this change on my i386 without problems.
>How-To-Repeat:
	cd /usr/src/sys; find . -type f -exec fgrep fs_cgrotor {} /dev/null \;
>Fix:

[The similar line in sbin/fsck_ffs/setup.c should also be removed]

--- ffs_alloc.c.old     Tue Mar 25 13:37:13 1997
+++ ffs_alloc.c Tue Mar 25 13:37:42 1997
@@ -655,12 +655,10 @@
                avgbfree = fs->fs_cstotal.cs_nbfree / fs->fs_ncg;
                for (cg = startcg; cg < fs->fs_ncg; cg++)
                        if (fs->fs_cs(fs, cg).cs_nbfree >= avgbfree) {
-                               fs->fs_cgrotor = cg;
                                return (fs->fs_fpg * cg + fs->fs_frag);
                        }
                for (cg = 0; cg <= startcg; cg++)
                        if (fs->fs_cs(fs, cg).cs_nbfree >= avgbfree) {
-                               fs->fs_cgrotor = cg;
                                return (fs->fs_fpg * cg + fs->fs_frag);
                        }
                return (NULL);

>Audit-Trail:
>Unformatted: