Skip to contentSkip to conversation

e2fsprogs: update mkfs defaults

PATCH Superseded Eric Sandeen 5 participants 19 messages Feb 16, 2011 – Feb 21, 2011

lore
Share & tools
lore
#0 lore raw

cover e2fsprogs: update mkfs defaults

Anaconda (the Fedora/RHEL installer) had been "fixing up" extN filesystems it created by setting the max mount count and check interval to 0, as well as adding user_xattr to filesystem mount options.

As part of their efforts to stop special-casing around upstream defaults, they've removed these changes upstream.

However, I'd like to at least propose that these changes be made default.

The forced fsck often comes at unexpected and inopportune moments, and even enterprise customers are often caught by surprise when this happens. Because a filesystem with an error condition will be marked as requiring fsck anyway, I submit that the time-based and mount-based checks are not particularly useful, and that administrators can schedule fscks on their own time, or tune2fs the enforced intervals if they so choose. Patch #1 disables the intervals by default, and I've added a new mkfs option (-C) to turn on the old behavior of random, unexpected, time-consuming fscks at boot time. ;)

User namespace xattrs are generally useful, and I think extN is the only filesystem requiring a special mount option to enable them, when xattrs are otherwise available. So patch #2 sets that mount option into the defaults.

Thanks,
-Eric

#1 lore raw

PATCH 1/2 e2fsprogs: turn off enforced fsck intervals by default

The forced fsck often comes at unexpected and inopportune moments, and even enterprise customers are often caught by surprise when this happens. Because a filesystem with an error condition will be marked as requiring fsck anyway, I submit that the time-based and mount-based checks are not particularly useful, and that administrators can schedule fscks on their own time, or tune2fs the enforced intervals if they so choose. Patch #1 disables the intervals by default, and I've added a new mkfs option (-C) to turn on the old behavior of random, unexpected, time-consuming fscks at boot time. ;)

---

lib/ext2fs/ext2fs.h +1 -0
index a204eb7..37584aa 100644
@@ -184,6 +184,7 @@ typedef struct ext2_file *ext2_file_t;
 #define EXT2_FLAG_64BITS		0x20000
 #define EXT2_FLAG_PRINT_PROGRESS	0x40000
 #define EXT2_FLAG_DIRECT_IO		0x80000
+#define EXT2_FLAG_MOUNT_FSCK_CHECK	0x100000
 
 /*
  * Special flag in the ext2 inode i_flag field that means that this is
lib/ext2fs/initialize.c +4 -2
index 7c38975..ff63a92 100644
@@ -155,7 +155,6 @@ errcode_t ext2fs_initialize(const char *name, int flags,
 	set_field(s_log_block_size, 0);	/* default blocksize: 1024 bytes */
 	set_field(s_log_frag_size, 0); /* default fragsize: 1024 bytes */
 	set_field(s_first_data_block, super->s_log_block_size ? 0 : 1);
-	set_field(s_max_mnt_count, EXT2_DFL_MAX_MNT_COUNT);
 	set_field(s_errors, EXT2_ERRORS_DEFAULT);
 	set_field(s_feature_compat, 0);
 	set_field(s_feature_incompat, 0);
@@ -189,7 +188,10 @@ errcode_t ext2fs_initialize(const char *name, int flags,
 		super->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE;
 	}
 
-	set_field(s_checkinterval, EXT2_DFL_CHECKINTERVAL);
+	if (flags & EXT2_FLAG_MOUNT_FSCK_CHECK) {
+		set_field(s_max_mnt_count, EXT2_DFL_MAX_MNT_COUNT);
+		set_field(s_checkinterval, EXT2_DFL_CHECKINTERVAL);
+	}
 	super->s_mkfs_time = super->s_lastcheck = fs->now ? fs->now : time(NULL);
 
 	super->s_creator_os = CREATOR_OS;
misc/mke2fs.8.in +7 -0
index 2eead17..758307f 100644
@@ -18,6 +18,9 @@ mke2fs \- create an ext2/ext3/ext4 filesystem
 .I block-size
 ]
 [
+.B \-C
+]
+[
 .B \-f
 .I fragment-size
 ]
@@ -184,6 +187,10 @@ Check the device for bad blocks before creating the file system.  If
 this option is specified twice, then a slower read-write
 test is used instead of a fast read-only test.
 .TP
+.B \-C
+Set maximum mount count and interval between checks, so that a full fsck
+will be enforced when these counts are exceeded.
+.TP
 .BI \-E " extended-options"
 Set extended options for the filesystem.  Extended options are comma
 separated, and may take an argument using the equals ('=') sign.  The
misc/mke2fs.c +12 -4
index 0ba4a4c..fdeafe3 100644
@@ -80,6 +80,7 @@ const char * device_name /* = NULL */;
 
 /* Command line options */
 int	cflag;
+int	Cflag;
 int	verbose;
 int	quiet;
 int	super_only;
@@ -1228,7 +1229,7 @@ profile_error:
 	}
 
 	while ((c = getopt (argc, argv,
-		    "b:cf:g:G:i:jl:m:no:qr:s:t:vE:FI:J:KL:M:N:O:R:ST:U:V")) != EOF) {
+		    "b:cf:g:G:i:jl:m:no:qr:s:t:vCE:FI:J:KL:M:N:O:R:ST:U:V")) != EOF) {
 		switch (c) {
 		case 'b':
 			blocksize = strtol(optarg, &tmp, 0);
@@ -1251,6 +1252,9 @@ profile_error:
 		case 'c':	/* Check for bad blocks */
 			cflag++;
 			break;
+		case 'C':	/* Set default check/fsck intervals */
+			Cflag++;
+			break;
 		case 'f':
 			size = strtoul(optarg, &tmp, 0);
 			if (size < EXT2_MIN_BLOCK_SIZE ||
@@ -2030,6 +2034,8 @@ int main (int argc, char *argv[])
 	 */
 	if (!quiet)
 		flags |= EXT2_FLAG_PRINT_PROGRESS;
+	if (Cflag)
+		flags |= EXT2_FLAG_MOUNT_FSCK_CHECK;
 	retval = ext2fs_initialize(device_name, flags, &fs_param, io_ptr, &fs);
 	if (retval) {
 		com_err(device_name, retval, _("while setting up superblock"));
@@ -2109,9 +2115,11 @@ int main (int argc, char *argv[])
 	 * don't check all the filesystems at the same time.  We use a
 	 * kludgy hack of using the UUID to derive a random jitter value.
 	 */
-	for (i = 0, val = 0 ; i < sizeof(fs->super->s_uuid); i++)
-		val += fs->super->s_uuid[i];
-	fs->super->s_max_mnt_count += val % EXT2_DFL_MAX_MNT_COUNT;
+	if (Cflag) {
+		for (i = 0, val = 0 ; i < sizeof(fs->super->s_uuid); i++)
+			val += fs->super->s_uuid[i];
+		fs->super->s_max_mnt_count += val % EXT2_DFL_MAX_MNT_COUNT;
+	}
 
 	/*
 	 * Override the creator OS, if applicable
#2 lore raw

Re: [PATCH 1/2] e2fsprogs: turn off enforced fsck intervals by default

Quoted 10 lines · Eric Sandeen

The forced fsck often comes at unexpected and inopportune moments, and even enterprise customers are often caught by surprise when this happens. Because a filesystem with an error condition will be marked as requiring fsck anyway, I submit that the time-based and mount-based checks are not particularly useful, and that administrators can schedule fscks on their own time, or tune2fs the enforced intervals if they so choose. Patch #1 disables the intervals by default, and I've added a new mkfs option (-C) to turn on the old behavior of random, unexpected, time-consuming fscks at boot time. ;)

I completely agree with you and I like the idea.

Quoted 70 lines

---

lib/ext2fs/ext2fs.h +1 -0
index a204eb7..37584aa 100644
@@ -184,6 +184,7 @@ typedef struct ext2_file *ext2_file_t;
 #define EXT2_FLAG_64BITS		0x20000
 #define EXT2_FLAG_PRINT_PROGRESS	0x40000
 #define EXT2_FLAG_DIRECT_IO		0x80000
+#define EXT2_FLAG_MOUNT_FSCK_CHECK	0x100000
 
 /*
  * Special flag in the ext2 inode i_flag field that means that this is
lib/ext2fs/initialize.c +4 -2
index 7c38975..ff63a92 100644
@@ -155,7 +155,6 @@ errcode_t ext2fs_initialize(const char *name, int flags,
 	set_field(s_log_block_size, 0);	/* default blocksize: 1024 bytes */
 	set_field(s_log_frag_size, 0); /* default fragsize: 1024 bytes */
 	set_field(s_first_data_block, super->s_log_block_size ? 0 : 1);
-	set_field(s_max_mnt_count, EXT2_DFL_MAX_MNT_COUNT);
 	set_field(s_errors, EXT2_ERRORS_DEFAULT);
 	set_field(s_feature_compat, 0);
 	set_field(s_feature_incompat, 0);
@@ -189,7 +188,10 @@ errcode_t ext2fs_initialize(const char *name, int flags,
 		super->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE;
 	}
 
-	set_field(s_checkinterval, EXT2_DFL_CHECKINTERVAL);
+	if (flags & EXT2_FLAG_MOUNT_FSCK_CHECK) {
+		set_field(s_max_mnt_count, EXT2_DFL_MAX_MNT_COUNT);
+		set_field(s_checkinterval, EXT2_DFL_CHECKINTERVAL);
+	}
 	super->s_mkfs_time = super->s_lastcheck = fs->now ? fs->now : time(NULL);
 
 	super->s_creator_os = CREATOR_OS;
misc/mke2fs.8.in +7 -0
index 2eead17..758307f 100644
@@ -18,6 +18,9 @@ mke2fs \- create an ext2/ext3/ext4 filesystem
 .I block-size
 ]
 [
+.B \-C
+]
+[
 .B \-f
 .I fragment-size
 ]
@@ -184,6 +187,10 @@ Check the device for bad blocks before creating the file system.  If
 this option is specified twice, then a slower read-write
 test is used instead of a fast read-only test.
 .TP
+.B \-C
+Set maximum mount count and interval between checks, so that a full fsck
+will be enforced when these counts are exceeded.
+.TP
 .BI \-E " extended-options"
 Set extended options for the filesystem.  Extended options are comma
 separated, and may take an argument using the equals ('=') sign.  The
misc/mke2fs.c +0 -0
index 0ba4a4c..fdeafe3 100644

misc/mke2fs.c const char * device_name /* = NULL */; · line 83

Quoted 4 lines
misc/mke2fs.c +1 -0
@@ -80,6 +80,7 @@ const char * device_name /* = NULL */;
 
 /* Command line options */
 int	cflag;
+int	Cflag;

Uff, this is not really an issue, however would it be possible to have better name for Cflags :) ? it is just confusing.

Quoted 52 lines
misc/mke2fs.c +11 -5
 int	verbose;
 int	quiet;
 int	super_only;
@@ -1228,7 +1229,7 @@ profile_error:
 	}
 
 	while ((c = getopt (argc, argv,
-		    "b:cf:g:G:i:jl:m:no:qr:s:t:vE:FI:J:KL:M:N:O:R:ST:U:V")) != EOF) {
+		    "b:cf:g:G:i:jl:m:no:qr:s:t:vCE:FI:J:KL:M:N:O:R:ST:U:V")) != EOF) {
 		switch (c) {
 		case 'b':
 			blocksize = strtol(optarg, &tmp, 0);
@@ -1251,6 +1252,9 @@ profile_error:
 		case 'c':	/* Check for bad blocks */
 			cflag++;
 			break;
+		case 'C':	/* Set default check/fsck intervals */
+			Cflag++;
+			break;
 		case 'f':
 			size = strtoul(optarg, &tmp, 0);
 			if (size < EXT2_MIN_BLOCK_SIZE ||
@@ -2030,6 +2034,8 @@ int main (int argc, char *argv[])
 	 */
 	if (!quiet)
 		flags |= EXT2_FLAG_PRINT_PROGRESS;
+	if (Cflag)
+		flags |= EXT2_FLAG_MOUNT_FSCK_CHECK;
 	retval = ext2fs_initialize(device_name, flags, &fs_param, io_ptr, &fs);
 	if (retval) {
 		com_err(device_name, retval, _("while setting up superblock"));
@@ -2109,9 +2115,11 @@ int main (int argc, char *argv[])
 	 * don't check all the filesystems at the same time.  We use a
 	 * kludgy hack of using the UUID to derive a random jitter value.
 	 */
-	for (i = 0, val = 0 ; i < sizeof(fs->super->s_uuid); i++)
-		val += fs->super->s_uuid[i];
-	fs->super->s_max_mnt_count += val % EXT2_DFL_MAX_MNT_COUNT;
+	if (Cflag) {
+		for (i = 0, val = 0 ; i < sizeof(fs->super->s_uuid); i++)
+			val += fs->super->s_uuid[i];
+		fs->super->s_max_mnt_count += val % EXT2_DFL_MAX_MNT_COUNT;
+	}
 
 	/*
 	 * Override the creator OS, if applicable
 
--

To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

Re: [PATCH 1/2] e2fsprogs: turn off enforced fsck intervals by default

Quoted 13 lines · Lukas Czerner
Quoted 10 lines · Eric Sandeen

The forced fsck often comes at unexpected and inopportune moments, and even enterprise customers are often caught by surprise when this happens.  Because a filesystem with an error condition will be marked as requiring fsck anyway, I submit that the time-based and mount-based checks are not particularly useful, and that administrators can schedule fscks on their own time, or tune2fs the enforced intervals if they so choose.  Patch #1 disables the intervals by default, and I've added a new mkfs option (-C) to turn on the old behavior of random, unexpected, time-consuming fscks at boot time.  ;)

Quoted 1 line

I completely agree with you and I like the idea.

I second that, though I would change the mkfs option to -OCD ;-)

Quoted 126 lines
Quoted 71 lines

---

lib/ext2fs/ext2fs.h +1 -0
index a204eb7..37584aa 100644
@@ -184,6 +184,7 @@ typedef struct ext2_file *ext2_file_t;
  #define EXT2_FLAG_64BITS             0x20000
  #define EXT2_FLAG_PRINT_PROGRESS     0x40000
  #define EXT2_FLAG_DIRECT_IO          0x80000
+#define EXT2_FLAG_MOUNT_FSCK_CHECK   0x100000
 
  /*
   * Special flag in the ext2 inode i_flag field that means that this is
lib/ext2fs/initialize.c +0 -0
index 7c38975..ff63a92 100644
@@ -155,7 +155,6 @@ errcode_t ext2fs_initialize(const char *name, int flags,

      set_field(s_log_block_size, 0); /* default blocksize: 1024 bytes */ set_field(s_log_frag_size, 0); /* default fragsize: 1024 bytes */ set_field(s_first_data_block, super->s_log_block_size ? 0 : 1);
-     set_field(s_max_mnt_count, EXT2_DFL_MAX_MNT_COUNT); set_field(s_errors, EXT2_ERRORS_DEFAULT); set_field(s_feature_compat, 0); set_field(s_feature_incompat, 0);

lib/ext2fs/initialize.c +4 -1
@@ -189,7 +188,10 @@ errcode_t ext2fs_initialize(const char *name, int flags,
               super->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE;
       }
 
-     set_field(s_checkinterval, EXT2_DFL_CHECKINTERVAL);
+     if (flags & EXT2_FLAG_MOUNT_FSCK_CHECK) {
+             set_field(s_max_mnt_count, EXT2_DFL_MAX_MNT_COUNT);
+             set_field(s_checkinterval, EXT2_DFL_CHECKINTERVAL);
+     }
       super->s_mkfs_time = super->s_lastcheck = fs->now ? fs->now : time(NULL);
 
       super->s_creator_os = CREATOR_OS;
misc/mke2fs.8.in +0 -0
index 2eead17..758307f 100644
@@ -18,6 +18,9 @@ mke2fs \- create an ext2/ext3/ext4 filesystem

 .I block-size
 ]
 [
+.B \-C
+]
+[
 .B \-f
 .I fragment-size
 ]

misc/mke2fs.8.in +0 -0
@@ -184,6 +187,10 @@ Check the device for bad blocks before creating the file system.  If

 this option is specified twice, then a slower read-write test is used instead of a fast read-only test. .TP
+.B \-C

misc/mke2fs.8.in +3 -0
+Set maximum mount count and interval between checks, so that a full fsck
+will be enforced when these counts are exceeded.
+.TP

 .BI \-E " extended-options"
 Set extended options for the filesystem.  Extended options are comma separated, and may take an argument using the equals ('=') sign.  The

misc/mke2fs.c +0 -0
index 0ba4a4c..fdeafe3 100644

misc/mke2fs.c const char * device_name /* = NULL */; · line 83

Quoted 4 lines
misc/mke2fs.c +1 -0
@@ -80,6 +80,7 @@ const char * device_name /* = NULL */;
 
  /* Command line options */
  int  cflag;
+int  Cflag;

Uff, this is not really an issue, however would it be possible to have better name for Cflags :) ? it is just confusing.

Quoted 47 lines
misc/mke2fs.c +1 -1
  int  verbose;
  int  quiet;
  int  super_only;
@@ -1228,7 +1229,7 @@ profile_error:
       }
 
       while ((c = getopt (argc, argv,
-                 "b:cf:g:G:i:jl:m:no:qr:s:t:vE:FI:J:KL:M:N:O:R:ST:U:V")) != EOF) {
+                 "b:cf:g:G:i:jl:m:no:qr:s:t:vCE:FI:J:KL:M:N:O:R:ST:U:V")) != EOF) {
               switch (c) {

              case 'b':
                      blocksize = strtol(optarg, &tmp, 0);

misc/mke2fs.c +0 -0
@@ -1251,6 +1252,9 @@ profile_error:

              case 'c':       /* Check for bad blocks */ cflag++;
                      break;
+             case 'C':       /* Set default check/fsck intervals */
+                     Cflag++;
+                     break;
              case 'f':
                      size = strtoul(optarg, &tmp, 0);
                      if (size < EXT2_MIN_BLOCK_SIZE ||

misc/mke2fs.c +7 -3
@@ -2030,6 +2034,8 @@ int main (int argc, char *argv[])
        */
       if (!quiet)
               flags |= EXT2_FLAG_PRINT_PROGRESS;
+     if (Cflag)
+             flags |= EXT2_FLAG_MOUNT_FSCK_CHECK;
       retval = ext2fs_initialize(device_name, flags, &fs_param, io_ptr, &fs);
       if (retval) {
               com_err(device_name, retval, _("while setting up superblock"));
@@ -2109,9 +2115,11 @@ int main (int argc, char *argv[])
        * don't check all the filesystems at the same time.  We use a
        * kludgy hack of using the UUID to derive a random jitter value.
        */
-     for (i = 0, val = 0 ; i < sizeof(fs->super->s_uuid); i++)
-             val += fs->super->s_uuid[i];
-     fs->super->s_max_mnt_count += val % EXT2_DFL_MAX_MNT_COUNT;
+     if (Cflag) {
+             for (i = 0, val = 0 ; i < sizeof(fs->super->s_uuid); i++)
+                     val += fs->super->s_uuid[i];
+             fs->super->s_max_mnt_count += val % EXT2_DFL_MAX_MNT_COUNT;
+     }
 
       /*
        * Override the creator OS, if applicable
Quoted 12 lines
Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

Re: [PATCH 1/2] e2fsprogs: turn off enforced fsck intervals by default

In reply to Eric Sandeen
Quoted 11 lines · Eric Sandeen

The forced fsck often comes at unexpected and inopportune moments, and even enterprise customers are often caught by surprise when this happens. Because a filesystem with an error condition will be marked as requiring fsck anyway, I submit that the time-based and mount-based checks are not particularly useful, and that administrators can schedule fscks on their own time, or tune2fs the enforced intervals if they so choose. Patch #1 disables the intervals by default, and I've added a new mkfs option (-C) to turn on the old behavior of random, unexpected, time-consuming fscks at boot time. ;)

Quoted 1 line

How about just making it be an /etc/mke2fs.conf profile. Just use something like this:

get_bool_from_profile(fs_types, "enable_periodic_fsck", 0)

... and I don't think we need to have a new command-line option. People who want old behaviour can do

[defaults]
enable_period_fsck = true

- Ted

#5 lore raw

PATCH v2 1/2 e2fsprogs: turn off enforced fsck intervals by default

In reply to Eric Sandeen

The forced fsck often comes at unexpected and inopportune moments, and even enterprise customers are often caught by surprise when this happens. Because a filesystem with an error condition will be marked as requiring fsck anyway, I submit that the time-based and mount-based checks are not particularly useful, and that administrators can schedule fscks on their own time, or tune2fs the enforced intervals if they so choose. This patch disables the intervals by default, and I've added a new mkfs.conf option to turn on the old behavior of random, unexpected, time-consuming fscks at boot time. ;)

---

lib/ext2fs/initialize.c +2 -15
index 7c38975..1d2927c 100644
@@ -46,19 +46,6 @@
 #endif /* defined(__linux__)   && defined(EXT2_OS_LINUX) */
 
 /*
- * Note we override the kernel include file's idea of what the default
- * check interval (never) should be.  It's a good idea to check at
- * least *occasionally*, specially since servers will never rarely get
- * to reboot, since Linux is so robust these days.  :-)
- *
- * 180 days (six months) seems like a good value.
- */
-#ifdef EXT2_DFL_CHECKINTERVAL
-#undef EXT2_DFL_CHECKINTERVAL
-#endif
-#define EXT2_DFL_CHECKINTERVAL (86400L * 180L)
-
-/*
  * Calculate the number of GDT blocks to reserve for online filesystem growth.
  * The absolute maximum number of GDT blocks we can reserve is determined by
  * the number of block pointers that can fit into a single block.
@@ -155,7 +142,7 @@ errcode_t ext2fs_initialize(const char *name, int flags,
 	set_field(s_log_block_size, 0);	/* default blocksize: 1024 bytes */
 	set_field(s_log_frag_size, 0); /* default fragsize: 1024 bytes */
 	set_field(s_first_data_block, super->s_log_block_size ? 0 : 1);
-	set_field(s_max_mnt_count, EXT2_DFL_MAX_MNT_COUNT);
+	set_field(s_max_mnt_count, 0);
 	set_field(s_errors, EXT2_ERRORS_DEFAULT);
 	set_field(s_feature_compat, 0);
 	set_field(s_feature_incompat, 0);
@@ -189,7 +176,7 @@ errcode_t ext2fs_initialize(const char *name, int flags,
 		super->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE;
 	}
 
-	set_field(s_checkinterval, EXT2_DFL_CHECKINTERVAL);
+	set_field(s_checkinterval, 0);
 	super->s_mkfs_time = super->s_lastcheck = fs->now ? fs->now : time(NULL);
 
 	super->s_creator_os = CREATOR_OS;
misc/mke2fs.c +24 -6
index 0ba4a4c..2910e6e 100644
@@ -2105,13 +2105,31 @@ int main (int argc, char *argv[])
 	uuid_generate((unsigned char *) fs->super->s_hash_seed);
 
 	/*
-	 * Add "jitter" to the superblock's check interval so that we
-	 * don't check all the filesystems at the same time.  We use a
-	 * kludgy hack of using the UUID to derive a random jitter value.
+	 * Periodic checks can be enabled/disabled via config file.
+	 * Note we override the kernel include file's idea of what the default
+	 * check interval (never) should be.  It's a good idea to check at
+	 * least *occasionally*, specially since servers will never rarely get
+	 * to reboot, since Linux is so robust these days.  :-)
+	 *
+	 * 180 days (six months) seems like a good value.
 	 */
-	for (i = 0, val = 0 ; i < sizeof(fs->super->s_uuid); i++)
-		val += fs->super->s_uuid[i];
-	fs->super->s_max_mnt_count += val % EXT2_DFL_MAX_MNT_COUNT;
+#ifdef EXT2_DFL_CHECKINTERVAL
+#undef EXT2_DFL_CHECKINTERVAL
+#endif
+#define EXT2_DFL_CHECKINTERVAL (86400L * 180L)
+
+	if (get_bool_from_profile(fs_types, "enable_periodic_fsck", 0)) {
+		fs->super->s_checkinterval = EXT2_DFL_CHECKINTERVAL;
+		fs->super->s_max_mnt_count = EXT2_DFL_MAX_MNT_COUNT;
+		/*
+		 * Add "jitter" to the superblock's check interval so that we
+		 * don't check all the filesystems at the same time.  We use a
+		 * kludgy hack of using the UUID to derive a random jitter value
+		 */
+		for (i = 0, val = 0 ; i < sizeof(fs->super->s_uuid); i++)
+			val += fs->super->s_uuid[i];
+		fs->super->s_max_mnt_count += val % EXT2_DFL_MAX_MNT_COUNT;
+	}
 
 	/*
 	 * Override the creator OS, if applicable
misc/mke2fs.conf +1 -0
index a7dd1c7..a96251e 100644
@@ -1,5 +1,6 @@
 [defaults]
 	base_features = sparse_super,filetype,resize_inode,dir_index,ext_attr
+	enable_periodic_fsck = 0
 	blocksize = 4096
 	inode_size = 256
 	inode_ratio = 16384
misc/mke2fs.conf.5.in +11 -0
index e9913cb..1e777cd 100644
@@ -107,6 +107,17 @@ command-line option
 to 
 .BR mke2fs (8).
 .TP
+.I enable_periodic_fsck
+This relation specifies whether periodic filesystem checks should be
+enforced at boot time.  If enabled, checks will be forced every
+180 days, or after a random number of mounts.  These values may
+be changed later via the
+.B -i
+and
+.B -c
+command-line options to
+.BR tune2fs (8).
+.TP
 .I force_undo
 This relation, if set to a boolean value of true, forces
 .B mke2fs
#6 lore raw

PATCH 2/2 e2fsprogs: enable user namespace xattrs by default

In reply to Eric Sandeen

User namespace xattrs are generally useful, and I think extN is the only filesystem requiring a special mount option to enable them, when xattrs are otherwise available. So this change sets that mount option into the defaults.

Note that if xattrs are config'd off, this will lead to a mostly-harmless:

EXT4-fs (sdc1): (no)user_xattr options not supported

message at mount time...

---

lib/ext2fs/initialize.c +1 -0
index ff63a92..12a9452 100644
@@ -164,6 +164,7 @@ errcode_t ext2fs_initialize(const char *name, int flags,
 	set_field(s_raid_stripe_width, 0);	/* default stripe width: 0 */
 	set_field(s_log_groups_per_flex, 0);
 	set_field(s_flags, 0);
+	set_field(s_default_mount_opts, EXT2_DEFM_XATTR_USER);
 	if (super->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP) {
 		retval = EXT2_ET_UNSUPP_FEATURE;
 		goto cleanup;
#7 lore raw

Re: [PATCH 2/2] e2fsprogs: enable user namespace xattrs by default

Quoted 11 lines · Eric Sandeen

User namespace xattrs are generally useful, and I think extN is the only filesystem requiring a special mount option to enable them, when xattrs are otherwise available. So this change sets that mount option into the defaults.

Note that if xattrs are config'd off, this will lead to a mostly-harmless:

EXT4-fs (sdc1): (no)user_xattr options not supported

message at mount time...

Wouldn't it be more useful to change this in the kernel, instead of only changing it in the superblock for new filesystems?

Cheers, Andreas

#8 lore raw

Re: [PATCH 2/2] e2fsprogs: enable user namespace xattrs by default

Quoted 9 lines · Andreas Dilger
Quoted 8 lines · Eric Sandeen

User namespace xattrs are generally useful, and I think extN is the only filesystem requiring a special mount option to enable them, when xattrs are otherwise available. So this change sets that mount option into the defaults.

Note that if xattrs are config'd off, this will lead to a mostly-harmless:

Quoted 7 lines
Quoted 3 lines

EXT4-fs (sdc1): (no)user_xattr options not supported

message at mount time...

Wouldn't it be more useful to change this in the kernel, instead of only changing it in the superblock for new filesystems?

Cheers, Andreas

I thought about that; maybe it should happen in both places?

-Eric

#9 lore raw

Re: [PATCH 2/2] e2fsprogs: enable user namespace xattrs by default

Quoted 8 lines · Eric Sandeen
Quoted 7 lines · Andreas Dilger
Quoted 5 lines · Eric Sandeen

User namespace xattrs are generally useful, and I think extN is the only filesystem requiring a special mount option to enable them, when xattrs are otherwise available. So this change sets that mount option into the defaults.

Quoted 4 lines
Quoted 2 lines

Wouldn't it be more useful to change this in the kernel, instead of only changing it in the superblock for new filesystems?

I thought about that; maybe it should happen in both places?

Yes, agreed. Maybe we should do the same thing with posix ACL's as well? ACL's can only take away access as compared to the unix permission bits, so it's safe to enable ACL's.

- Ted

#10 lore raw

Re: [PATCH 2/2] e2fsprogs: enable user namespace xattrs by default

Quoted 12 lines · Ted Ts'o
Quoted 11 lines · Eric Sandeen
Quoted 9 lines · Andreas Dilger
Quoted 5 lines · Eric Sandeen

User namespace xattrs are generally useful, and I think extN is the only filesystem requiring a special mount option to enable them, when xattrs are otherwise available. So this change sets that mount option into the defaults.

Wouldn't it be more useful to change this in the kernel, instead of only changing it in the superblock for new filesystems?

Quoted 8 lines
Quoted 1 line

I thought about that; maybe it should happen in both places?

Yes, agreed. Maybe we should do the same thing with posix ACL's as well? ACL's can only take away access as compared to the unix permission bits, so it's safe to enable ACL's.

- Ted

Whoops, I didn't realize that acls were in the same boat, of "config on and then turn on with a mount option"

Ok, sure, adding that makes sense to me too...

Is sticking it in the _initialize() function ok with you? It's a little odd, but ...

-Eric

#11 lore raw

Re: [PATCH 2/2] e2fsprogs: enable user namespace xattrs by default

Quoted 7 lines · Eric Sandeen

Whoops, I didn't realize that acls were in the same boat, of "config on and then turn on with a mount option"

Ok, sure, adding that makes sense to me too...

Is sticking it in the _initialize() function ok with you? It's a little odd, but ...

I think it's probably better to put it in the misc/mke2fs.c; we set a number of superblock options there already. But either place is fine...

- Ted

#12 lore raw

Re: [PATCH 2/2] e2fsprogs: enable user namespace xattrs by default

Quoted 6 lines · Ted Ts'o
Quoted 5 lines · Eric Sandeen

Whoops, I didn't realize that acls were in the same boat, of "config on and then turn on with a mount option"

Ok, sure, adding that makes sense to me too...

Quoted 7 lines
Quoted 2 lines

Is sticking it in the _initialize() function ok with you? It's a little odd, but ...

I think it's probably better to put it in the misc/mke2fs.c; we set a number of superblock options there already. But either place is fine...

- Ted

Ok, if we do it in mke2fs.c that's probably better.

Or - I wonder how hard it'd be to make this into a mke2fs.conf option instead? I always forget about that route.

get_string_from_profile(... "default_mount_opts" ....) ?

-Eric

#13 lore raw

Re: [PATCH 2/2] e2fsprogs: enable user namespace xattrs by default

Quoted 7 lines · Eric Sandeen

Ok, if we do it in mke2fs.c that's probably better.

Or - I wonder how hard it'd be to make this into a mke2fs.conf option instead? I always forget about that route.

get_string_from_profile(... "default_mount_opts" ....) ?

That would certainly be more general. I don't really think it matters for acl and xattr, since I think it's better to make them be the default in the kernel, and then long term make noacl and noxattr disappear as mount options altogether.

One reason for doing this is just to make the output of /proc/mounts look nicer. :-)

- Ted

#14 lore raw

PATCH v2 2/2 e2fsprogs: enable user namespace xattrs by default

In reply to Eric Sandeen

User namespace xattrs are generally useful, and I think extN is the only filesystem requiring a special mount option to enable them, when xattrs are otherwise available. So this change sets that mount option into the defaults, via a mke2fs.conf option.

Note that if xattrs are config'd off, this will lead to a mostly-harmless:

EXT4-fs (sdc1): (no)user_xattr options not supported

message at mount time...

---

lib/ext2fs/initialize.c +1 -0
index 1d2927c..4cf0863 100644
@@ -147,6 +147,7 @@ errcode_t ext2fs_initialize(const char *name, int flags,
 	set_field(s_feature_compat, 0);
 	set_field(s_feature_incompat, 0);
 	set_field(s_feature_ro_compat, 0);
+	set_field(s_default_mount_opts, 0);
 	set_field(s_first_meta_bg, 0);
 	set_field(s_raid_stride, 0);		/* default stride size: 0 */
 	set_field(s_raid_stripe_width, 0);	/* default stripe width: 0 */
misc/mke2fs.c +22 -0
index 2910e6e..e9e3129 100644
@@ -829,6 +829,18 @@ static void edit_feature(const char *str, __u32 *compat_array)
 	}
 }
 
+static void edit_mntopts(const char *str, __u32 *mntopts)
+{
+	if (!str)
+		return;
+
+	if (e2p_edit_mntopts(str, mntopts, ~0)) {
+		fprintf(stderr, _("Invalid mount option set: %s\n"),
+			str);
+		exit(1);
+	}
+}
+
 struct str_list {
 	char **list;
 	int num;
@@ -1576,6 +1588,16 @@ profile_error:
 	}
 	edit_feature(fs_features ? fs_features : tmp,
 		     &fs_param.s_feature_compat);
+
+	if (tmp)
+		free(tmp);
+
+	/* And which mount options as well */
+	tmp = NULL;
+	tmp = get_string_from_profile(fs_types, "default_mntopts",
+		"acl,user_xattr");
+	edit_mntopts(tmp, &fs_param.s_default_mount_opts);
+
 	if (tmp)
 		free(tmp);
 
misc/mke2fs.conf +1 -0
index a96251e..775e046 100644
@@ -1,5 +1,6 @@
 [defaults]
 	base_features = sparse_super,filetype,resize_inode,dir_index,ext_attr
+	default_mntopts = acl,user_xattr
 	enable_periodic_fsck = 0
 	blocksize = 4096
 	inode_size = 256
misc/mke2fs.conf.5.in +7 -0
index 1e777cd..791cf7e 100644
@@ -314,6 +314,13 @@ relations.  It may be overridden by the
 command-line option to
 .BR mke2fs (8).
 .TP
+.I default_mntopts
+This relation specifies the set of mount options which should be enabled
+by default.  These may be changed at a later time with the
+.B -o
+command-line option to
+.BR tune2fs (8).
+.TP
 .I auto_64-bit_support
 This relation is a boolean which specifies whether
 .BR mke2fs (8)
#15 lore raw

Re: [PATCH 2/2 V2] e2fsprogs: enable user namespace xattrs by default

Quoted 6 lines · Eric Sandeen

User namespace xattrs are generally useful, and I think extN is the only filesystem requiring a special mount option to enable them, when xattrs are otherwise available. So this change sets that mount option into the defaults, via a mke2fs.conf option.

Quoted 8 lines

Note that if xattrs are config'd off, this will lead to a mostly-harmless:

EXT4-fs (sdc1): (no)user_xattr options not supported

message at mount time...

You didn't run "make check" before submitting these patches. Please do so in the future! :-)

I'll fix up the expected test commit results for these two commits.

- Ted

#16 lore raw

Re: [PATCH 2/2 V2] e2fsprogs: enable user namespace xattrs by default

Quoted 14 lines · Ted Ts'o
Quoted 13 lines · Eric Sandeen

User namespace xattrs are generally useful, and I think extN is the only filesystem requiring a special mount option to enable them, when xattrs are otherwise available. So this change sets that mount option into the defaults, via a mke2fs.conf option.

Note that if xattrs are config'd off, this will lead to a mostly-harmless:

EXT4-fs (sdc1): (no)user_xattr options not supported

message at mount time...

Quoted 8 lines
Quoted 1 line

You didn't run "make check" before submitting these patches. Please do so in the future! :-)

I'll fix up the expected test commit results for these two commits.

- Ted

Argh sorry. Out of practice I guess.

Thanks,
-Eric

#17 lore raw
In reply to Eric Sandeen
Quoted 5 lines · Eric Sandeen

Anaconda (the Fedora/RHEL installer) had been "fixing up" extN filesystems it created by setting the max mount count and check interval to 0, as well as adding user_xattr to filesystem mount options.

As part of their efforts to stop special-casing around upstream defaults, they've removed these changes upstream.

However, I'd like to at least propose that these changes be made default.

I'd really prefer instead that the "lvcheck" script be included into the distro, instead of changing mke2fs. That achieves the same end result (periodic scrubbing of the filesystem to look for hidden errors), without introducing boot-time delays. Given the size of disks today and the undetected bit-error-rate (somewhere around 1/10^15 bits or 12TB), I think it is important that there be automated scrubbing of the filesystem.

I think the best place to put that script would be in the lvm tools (since it is applicable to multiple filesystems), which I think Eric has the most leverage in getting accepted (I've been but I'd be OK including it with e2fsprogs if there is pushback on that.

Quoted 1 line

The forced fsck often comes at unexpected and inopportune moments, and even enterprise customers are often caught by surprise when this happens. Because a filesystem with an error condition will be marked as requiring fsck anyway,

Any decent RAID array does background scrubbing for integrity verification, it doesn't just wait until there is an uncorrectable error detected in the block device. If we can do something proactive to prevent this (i.e. lvcheck run by cron.weekly), it is worthwhile.

I think customers are equally surprised when their server fails (remount-ro/panic) due to the kernel detecting an error that might have been on disk for weeks or months.

Quoted 1 line

I submit that the time-based and mount-based checks are not particularly useful, and that administrators can schedule fscks on their own time, or tune2fs the enforced intervals if they so choose.

I think you are projecting your own self-enlightenment onto users ;-). As we see on this list, there are many users that don't even back up their critical data, so IMHO taking out "safe by default" options is a step in the wrong direction.

Attached is my latest version of the lvcheck script, and a default /etc/lvcheck.conf script. It's been enhanced to include a usage message, command-line option parsing to override default parameters, and the ability to check snapshots of ext3/4 filesystems with an external journal.

Cheers, Andreas

#18 lore raw
Quoted 12 lines · Andreas Dilger
Quoted 10 lines · Eric Sandeen

Anaconda (the Fedora/RHEL installer) had been "fixing up" extN filesystems it created by setting the max mount count and check interval to 0, as well as adding user_xattr to filesystem mount options.

As part of their efforts to stop special-casing around upstream defaults, they've removed these changes upstream.

However, I'd like to at least propose that these changes be made default.

Quoted 7 lines

I'd really prefer instead that the "lvcheck" script be included into the distro, instead of changing mke2fs. That achieves the same end result (periodic scrubbing of the filesystem to look for hidden errors), without introducing boot-time delays. Given the size of disks today and the undetected bit-error-rate (somewhere around 1/10^15 bits or 12TB), I think it is important that there be automated scrubbing of the filesystem.

lvcheck is well and good, but is not a panacea; it is useful only for snapshottable volumes.... and only lvm for now?

Quoted 4 lines

I think the best place to put that script would be in the lvm tools (since it is applicable to multiple filesystems), which I think Eric has the most leverage in getting accepted (I've been but I'd be OK including it with e2fsprogs if there is pushback on that.

device-mapper utilities ended up being a black hole... combination of "the scripts don't conform to our style" or somesuch, but no real interest in adopting & fixing them to do so, IIRC.

Quoted 9 lines
Quoted 4 lines

The forced fsck often comes at unexpected and inopportune moments, and even enterprise customers are often caught by surprise when this happens. Because a filesystem with an error condition will be marked as requiring fsck anyway,

Any decent RAID array does background scrubbing for integrity verification, it doesn't just wait until there is an uncorrectable error detected in the block device. If we can do something proactive to prevent this (i.e. lvcheck run by cron.weekly), it is worthwhile.

If the raid went offline for a couple hours at random times to do this, users would scream too. This is essentially what the forced fsck does today.

Quoted 3 lines

I think customers are equally surprised when their server fails (remount-ro/panic) due to the kernel detecting an error that might have been on disk for weeks or months.

If I were an administrator, I would schedule fscks to avoid this, rather than rely on a "kludgy hack of using the UUID to derive a random" time for this to hit...

Quoted 9 lines
Quoted 4 lines

I submit that the time-based and mount-based checks are not particularly useful, and that administrators can schedule fscks on their own time, or tune2fs the enforced intervals if they so choose.

I think you are projecting your own self-enlightenment onto users ;-). As we see on this list, there are many users that don't even back up their critical data, so IMHO taking out "safe by default" options is a step in the wrong direction.

Perhaps I'll whip up a s_last_backup_time patch, and refuse to mount if the user hasn't conformed to our enlightened notions of how often is often enough, as well. I could integrate it with dumpe2fs. ;)

There is "safe by default" and then there is "assuming administrator responsibilities," IMHO. I just personally think it's too much.

Quoted 6 lines

Attached is my latest version of the lvcheck script, and a default /etc/lvcheck.conf script. It's been enhanced to include a usage message, command-line option parsing to override default parameters, and the ability to check snapshots of ext3/4 filesystems with an external journal.

The script is great, but has limited application.

Well, anyway, I knew this wouldn't be super popular with everyone, but figured I'd put it out there for discussion.

-Eric

Quoted 4 lines

Cheers, Andreas