From owner-freebsd-bugs@FreeBSD.ORG Sat Jul 26 12:10:21 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 687D337B404 for ; Sat, 26 Jul 2003 12:10:21 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6F52E43FBD for ; Sat, 26 Jul 2003 12:10:20 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h6QJAKUp094531 for ; Sat, 26 Jul 2003 12:10:20 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h6QJAKRI094530; Sat, 26 Jul 2003 12:10:20 -0700 (PDT) Resent-Date: Sat, 26 Jul 2003 12:10:20 -0700 (PDT) Resent-Message-Id: <200307261910.h6QJAKRI094530@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Alex Popa Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AA5BA37B401 for ; Sat, 26 Jul 2003 12:02:24 -0700 (PDT) Received: from ldc.ro (ldc-gw.rdsnet.ro [213.157.163.8]) by mx1.FreeBSD.org (Postfix) with SMTP id 4894F43F85 for ; Sat, 26 Jul 2003 12:02:15 -0700 (PDT) (envelope-from razor@ldc.ro) Received: (qmail 29202 invoked by uid 666); 26 Jul 2003 19:02:13 -0000 Message-Id: <20030726190213.29201.qmail@ldc.ro> Date: 26 Jul 2003 19:02:13 -0000 From: Alex Popa To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/54884: FreeBSD -stable and -current free space handling for UFS filesystems X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Alex Popa List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Jul 2003 19:10:21 -0000 >Number: 54884 >Category: kern >Synopsis: FreeBSD -stable and -current free space handling for UFS filesystems >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Jul 26 12:10:19 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Alex Popa >Release: FreeBSD 4.8-STABLE i386 / FreeBSD 5.1-CURRENT i386 >Organization: >Environment: System: FreeBSD xxx.xxx.xx 4.8-STABLE FreeBSD 4.8-STABLE #0: Fri Jul 4 14:01:45 EEST 2003 root@xxx.xxx.xx:/usr/obj/usr/src/sys/XXX i386 >Description: There appears to be a caching of free space on UFS1 filesystem in the filesystem superblock. These caching methods appear to be different in -current and -stable. An update free space value for a certain UFS1 filesystem mounted on a -current kernel will be seen when the filesystem is mounted in -stable. However, if there is a change of the free space while the filesystem is mounted in -stable, the change will not reflect in -current. Please note this is NOT related to the reserved percent of UFS filesystems (-m flag to tunefs). >How-To-Repeat: Make sure an UFS1 filesystem is clean. Force fsck both on -current and -stable (see below). Mount the filesystem in -current, then create a large file, preferably amounting to a large percentage of the filesystem size. Write down the values returned by df for that filesystem, then reboot to -stable and remove the file. Reboot again to -current, and notice the values from df have not changed. However, the file can be created again, and deleted again in -stable. Another way to abuse this is to create the files on -stable and remove them in -current. This will make the used blocks count on the filesystem to decrease with each repetition. It is possible to fix the free space issue by forcing fsck. Otherwise the filesystem will appear clean. However, it seems that the -stable and -current versions of fsck do not check for the same things, and only fix the issue for their respective OS versions. Mounting the filesystem read/write on -current, after the -current fsck is run will cause the kernel to update both versions of the free space value. Some command outputs STABLE: *on fsck -p /dev/ad0s2g: clean, -212550 free (79930 frags, -36560 blocks, 3.5% fragmentation) *on forcing fsck: ** /dev/ad0s2g ** Last Mounted on /usr ** Phase 1 - Check Blocks and Sizes ** Phase 2 - Check Pathnames ** Phase 3 - Check Connectivity ** Phase 4 - Check Reference Counts ** Phase 5 - Check Cyl groups SUMMARY INFORMATION BAD SALVAGE? [yn] y FREE BLK COUNT(S) WRONG IN SUPERBLK SALVAGE? [yn] y 208421 files, 1831342 used, 422700 free (80596 frags, 42763 blocks, 3.6% fragmentation) CURRENT: *on fsck -p /dev/ad0s2g: FILESYSTEM CLEAN; SKIPPING CHECKS /dev/ad0s2g: clean, -212550 free (79930 frags, -36560 blocks, 3.5% fragmentation) *on forcing fsck ** /dev/ad0s2g ** Last Mounted on /usr ** Phase 1 - Check Blocks and Sizes ** Phase 2 - Check Pathnames ** Phase 3 - Check Connectivity ** Phase 4 - Check Reference Counts ** Phase 5 - Check Cyl groups SUMMARY BLK COUNT(S) WRONG IN SUPERBLK SALVAGE? [yn] y 208421 files, 1831344 used, 422698 free (80586 frags, 42764 blocks, 3.6% fragmentation) ***** FILE SYSTEM WAS MODIFIED ***** Fun things to do: (1) Get the filesystem usage figure to over 109% on an UFS1 filesystem, which has the default reserved percentage for the superuser at 8%, or get df to report more used blocks than the filesystem size. Example: Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/ad0s2g 4508084 4933184 -785746 119% /usr2 (2) Get the filesystem usage figure to be negative. Example: Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/ad0s2g 4508084 -282454 4429892 -7% /usr >Fix: Workaround by forcing fsck when booting from one version to the other, or do not use one UFS1 filesystem under both versions of FreeBSD. >Release-Note: >Audit-Trail: >Unformatted: