From owner-freebsd-hackers Sun Mar 19 08:01:41 1995 Return-Path: hackers-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id IAA10817 for hackers-outgoing; Sun, 19 Mar 1995 08:01:41 -0800 Received: from ibp.ibp.fr (ibp.ibp.fr [132.227.60.30]) by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id IAA10808 for ; Sun, 19 Mar 1995 08:01:36 -0800 From: Remy.Card@masi.ibp.fr Received: from blaise.ibp.fr (blaise.ibp.fr [132.227.60.1]) by ibp.ibp.fr (8.6.11/jtpda-5.0) with SMTP id RAA00116 for ; Sun, 19 Mar 1995 17:01:42 +0100 Received: by blaise.ibp.fr (4.1/SMI-4.1) id AA15331; Sun, 19 Mar 95 17:01:30 +0100 Received: (card@localhost) by bbj.ibp.fr (8.6.9/bbj-1.0) id QAA00122 for hackers@FreeBSD.ORG; Sun, 19 Mar 1995 16:58:09 GMT Message-Id: <199503191658.QAA00122@bbj.ibp.fr> Subject: Filesystem clean flag To: hackers@FreeBSD.org Date: Sun, 19 Mar 1995 16:58:08 +0000 () X-Mailer: ELM [version 2.4 PL23beta2] Content-Type: text Content-Length: 2205 Sender: hackers-owner@FreeBSD.org Precedence: bulk I am currently studying the filesystem kernel code and I think that the current clean flag implementation could be improved. Currently, the clean flag is set to 0 when a filesystem is mounted in read-write mode and set to 1 when the filesystem is unmounted. This way of doing things can be a problem in some cases: suppose that a system crashes (so the filesystems are marked as not clean), the system is rebooted in single user mode (so fsck is not run at boot), and then goes to multiuser mode. When the system is subsequently rebooted in a proper way, the clean flag is set to 1, and, voila, the filesystems are marked as clean for the next boot but they can contain errors. Correcting this problem is trivial: when a filesystem is mounted in read-write mode, store the value of the clean flag and restore this value in the superblock when the filesystem is unmounted. Also, I have compared the clean flag implementation with my own implementation in the Linux Ext2 filesystem and I found that FreeBSD does not allow the administrator to request periodical checks of the filesystems. In the Linux Ext2 fs, two fields are reserved in the superblock for this: - a mount counter is incremented each time the filesystem is mounted in read-write mode. When this counter is greater than a maximal mount count (also contained in the superblock and changeable with tunefs), fsck checks the filesystem regardless of the clean flag value. - a last check time and a check interval are also stored in the superblock. When fsck checks a filesystem, it stores the current time in the last check time. When the current time is greater than (last_check_time + check_interval), fsck checks the filesystem regardless of the clean value. The check interval can also be changed by using tunefs. Of course, both the mount counter and the check interval can be disabled to obtain the same behavior as the FreeBSD's current one. I think that it would be worth implementing these features in FreeBSD. I even think that I can come with a patch if people are interested but I'd like to have your opinion before starting working on it. Please, no ``BSD vs Linux'' or ``UFS vs Ext2fs'' war! :-) Thanks Remy