Skip to contentSkip to conversation

reiserfsprogs: add ext3-style mount count and last check expiry for better fsck -a behavior

PATCH In review Jeff Mahoney 1 participant 1 message Nov 26, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 reiserfsprogs: add ext3-style mount count and last check expiry for better fsck -a behavior

Currently, fsck.reiserfs -a <dev> performs a full --check scan on every reiserfs file system during every boot. This is obviously suboptimal, since it kills one of the major features of a journaled file system.

This patch adds mount counting and last check expiration to fsck, mkfs, and debugfs so that we can perform fscks on a user defined schedule.

The defaults are 180 days or 30 mounts before fsck -a results in a full scan.

On file systems where this feature hasn't yet been enabled, the fsck -a will perform a full scan and then mark the superblock with the defaults.

While the mount count won't work with kernels that don't support it, the timeout obviously will. I'll be following this patch up with a kernel patch that reserves the fields and updates the mount counts.

This support is super important with multi-terabyte file systems, since the check is causing huge delays during mount.

Whether or not this patch is immediately accepted into the reiserfsprogs repository, I'd at least like confirmation that I can reserve these fields in the superblock for this purpose.

Thanks.

---

 include/reiserfs/super.h |   19 +++++++++++++++
 include/reiserfs/types.h |    6 ++++
 libreiserfs/filesystem.c |    6 ++++
 libreiserfs/super.c      |   21 +++++++++++++++++
 utils/fsck/main.c        |   58 ++++++++++++++++++++++++++++++++++++++++++++++-
 utils/tune/tune.c        |   45 +++++++++++++++++++++++++++++++++++-
 6 files changed, 151 insertions(+), 4 deletions(-)
include/reiserfs/super.h +19 -0
@@ -82,6 +82,22 @@ typedef enum {
 #define reiserfs_sb_get_gen(sb)		get_le32 (sb, sb_inode_generation)
 #define reiserfs_sb_set_gen(sb,val)	set_le32 (sb, sb_inode_generation, val)
 
+#define reiserfs_sb_get_mnt_count(sb)		get_le16 (sb, s_mnt_count)
+#define reiserfs_sb_set_mnt_count(sb,val)	set_le16 (sb, s_mnt_count, val)
+
+#define reiserfs_sb_get_max_mnt_count(sb)			\
+	get_le16 (sb, s_max_mnt_count)
+#define reiserfs_sb_set_max_mnt_count(sb,val)			\
+	set_le16 (sb, s_max_mnt_count, val)
+
+#define reiserfs_sb_get_lastcheck(sb)		get_le32 (sb, s_lastcheck)
+#define reiserfs_sb_set_lastcheck(sb,val)	set_le32 (sb, s_lastcheck, val)
+
+#define reiserfs_sb_get_check_interval(sb)			\
+	get_le32 (sb, s_check_interval)
+#define reiserfs_sb_set_check_interval(sb,val)			\
+	set_le32 (sb, s_check_interval, val)
+
 #define reiserfs_sb_get_flags(sb)	get_le32 (sb, s_flags)
 #define reiserfs_sb_set_flags(sb, val)	set_le32 (sb, s_flags, val)
 
@@ -114,6 +130,9 @@ typedef enum {
 #define REISERFS_JR_SUPER_MAGIC_STRING "ReIsEr3Fs" /* JR stands for Journal
 						      Relocation */
 
+#define DEFAULT_MAX_MNT_COUNT	30			/* 30 mounts */
+#define DEFAULT_CHECK_INTERVAL	(180 * 60 * 60 * 24)	/* 180 days */
+
 /* these are possible values for sb_fs_state */
 enum reiserfs_state_flags {
 	/* this is set by mkreiserfs and by reiserfsck */
include/reiserfs/types.h +5 -1
@@ -134,7 +134,11 @@ struct reiserfs_super_block {
 /*100 */    unsigned char s_label[16];
 /* zero filled by mkreiserfs and reiserfs_convert_objectid_map_v1()
  * so any additions must be updated there as well. */ 
-/*116 */    char s_unused[88];
+/*116 */    __u16 s_mnt_count;
+/*118 */    __u16 s_max_mnt_count;
+/*120 */    __u32 s_lastcheck;
+/*124 */    __u32 s_check_interval;
+/*128 */    char s_unused[76];
 /*204*/
 } __attribute__ ((__packed__));;
 
libreiserfs/filesystem.c +5 -1
@@ -283,7 +283,11 @@ reiserfs_filsys_t * reiserfs_fs_create (
     reiserfs_sb_set_version (fs->fs_ondisk_sb, version);
     reiserfs_sb_set_bmaps (fs->fs_ondisk_sb, 
 			   reiserfs_bmap_over(bmap_nr) ? 0 : bmap_nr);
-    
+    reiserfs_sb_set_lastcheck(fs->fs_ondisk_sb, time());
+    reiserfs_sb_set_check_interval(fs->fs_ondisk_sb, DEFAULT_CHECK_INTERVAL);
+    reiserfs_sb_set_mnt_count(fs->fs_ondisk_sb, 1);
+    reiserfs_sb_set_max_mnt_count(fs->fs_ondisk_sb, DEFAULT_MAX_MNT_COUNT);
+
     /* sb_not_used1 */
     reiserfs_buffer_mkdirty (fs->fs_super_bh);
     fs->fs_dirt = 1;
libreiserfs/super.c +21 -0
@@ -104,6 +104,8 @@ int reiserfs_super_print (FILE * fp, 
     reiserfs_sb_t * sb = (reiserfs_sb_t *)(bh->b_data);
     int format = 0;
     __u16 state;
+    time_t last_check = reiserfs_sb_get_lastcheck(sb);
+    char last_check_buf[26];
 
     if (!reiserfs_super_valid(bh))
 	return 1;
@@ -174,6 +176,25 @@ int reiserfs_super_print (FILE * fp, 
         reiserfs_warning (fp, "Set flags in SB:\n");
 	if ((reiserfs_sb_isflag (sb, reiserfs_attrs_cleared)))
 	    reiserfs_warning (fp, "\tATTRIBUTES CLEAN\n");
+	reiserfs_warning(fp, "Mount count: %u\n",
+			 reiserfs_sb_get_mnt_count(sb));
+	reiserfs_warning(fp, "Maximum mount count: ");
+	if (reiserfs_sb_get_max_mnt_count(sb))
+		reiserfs_warning(fp, "%u\n", reiserfs_sb_get_max_mnt_count(sb));
+	else
+		reiserfs_warning(fp, "Disabled. (Use tunefs.reiserfs)\n");
+	if (last_check) {
+		ctime_r(&last_check, last_check_buf);
+		reiserfs_warning(fp, "Last fsck run: %s", last_check_buf);
+	} else
+		reiserfs_warning(fp, "Last fsck run: Never with a version "
+				 "that supports this feature.\n");
+	reiserfs_warning(fp, "Check interval in days: ");
+	if (reiserfs_sb_get_check_interval(sb))
+		reiserfs_warning(fp, "%u\n",
+			 reiserfs_sb_get_check_interval(sb) / (24*60*60));
+	else
+		reiserfs_warning(fp, "Disabled. (Use tunefs.reiserfs)\n");
     }
 
     return 0;
utils/fsck/main.c +57 -1

88 lines not on this page · raw message

utils/tune/tune.c +44 -1

93 lines not on this page · raw message

Signature · 2 lines
Jeff Mahoney
SUSE Labs