[patch 135/327] ext2/4: use is_power_of_2()

2007-10-17 Thread akpm
From: vignesh babu [EMAIL PROTECTED]

Replace n  (n - 1) with is_power_of_2(n)

Signed-off-by: vignesh babu [EMAIL PROTECTED]
Cc: linux-ext4@vger.kernel.org
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
---

 fs/ext2/super.c |3 ++-
 fs/ext4/super.c |2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff -puN fs/ext2/super.c~ext2-4-use-is_power_of_2 fs/ext2/super.c
--- a/fs/ext2/super.c~ext2-4-use-is_power_of_2
+++ a/fs/ext2/super.c
@@ -30,6 +30,7 @@
 #include linux/vfs.h
 #include linux/seq_file.h
 #include linux/mount.h
+#include linux/log2.h
 #include asm/uaccess.h
 #include ext2.h
 #include xattr.h
@@ -862,7 +863,7 @@ static int ext2_fill_super(struct super_
sbi-s_inode_size = le16_to_cpu(es-s_inode_size);
sbi-s_first_ino = le32_to_cpu(es-s_first_ino);
if ((sbi-s_inode_size  EXT2_GOOD_OLD_INODE_SIZE) ||
-   (sbi-s_inode_size  (sbi-s_inode_size - 1)) ||
+   !is_power_of_2(sbi-s_inode_size) ||
(sbi-s_inode_size  blocksize)) {
printk (EXT2-fs: unsupported inode size: %d\n,
sbi-s_inode_size);
diff -puN fs/ext4/super.c~ext2-4-use-is_power_of_2 fs/ext4/super.c
--- a/fs/ext4/super.c~ext2-4-use-is_power_of_2
+++ a/fs/ext4/super.c
@@ -1738,7 +1738,7 @@ static int ext4_fill_super (struct super
if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_64BIT)) {
if (sbi-s_desc_size  EXT4_MIN_DESC_SIZE_64BIT ||
sbi-s_desc_size  EXT4_MAX_DESC_SIZE ||
-   sbi-s_desc_size  (sbi-s_desc_size - 1)) {
+   !is_power_of_2(sbi-s_desc_size)) {
printk(KERN_ERR
   EXT4-fs: unsupported descriptor size %lu\n,
   sbi-s_desc_size);
_
-
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


[patch 075/327] ext3: show all mount options

2007-10-17 Thread akpm
From: Miklos Szeredi [EMAIL PROTECTED]

Signed-off-by: Miklos Szeredi [EMAIL PROTECTED]
Cc: linux-ext4@vger.kernel.org
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
---

 fs/ext3/super.c|   70 +++
 include/linux/ext3_fs_sb.h |1 
 2 files changed, 71 insertions(+)

diff -puN fs/ext3/super.c~ext3-show-all-mount-options fs/ext3/super.c
--- a/fs/ext3/super.c~ext3-show-all-mount-options
+++ a/fs/ext3/super.c
@@ -545,9 +545,78 @@ static inline void ext3_show_quota_optio
 #endif
 }
 
+/*
+ * Show an option if
+ *  - it's set to a non-default value OR
+ *  - if the per-sb default is different from the global default
+ */
 static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs)
 {
struct super_block *sb = vfs-mnt_sb;
+   struct ext3_sb_info *sbi = EXT3_SB(sb);
+   struct ext3_super_block *es = sbi-s_es;
+   unsigned long def_mount_opts;
+
+   def_mount_opts = le32_to_cpu(es-s_default_mount_opts);
+
+   if (sbi-s_sb_block != 1)
+   seq_printf(seq, ,sb=%lu, sbi-s_sb_block);
+   if (test_opt(sb, MINIX_DF))
+   seq_puts(seq, ,minixdf);
+   if (test_opt(sb, GRPID))
+   seq_puts(seq, ,grpid);
+   if (!test_opt(sb, GRPID)  (def_mount_opts  EXT3_DEFM_BSDGROUPS))
+   seq_puts(seq, ,nogrpid);
+   if (sbi-s_resuid != EXT3_DEF_RESUID ||
+   le16_to_cpu(es-s_def_resuid) != EXT3_DEF_RESUID) {
+   seq_printf(seq, ,resuid=%u, sbi-s_resuid);
+   }
+   if (sbi-s_resgid != EXT3_DEF_RESGID ||
+   le16_to_cpu(es-s_def_resgid) != EXT3_DEF_RESGID) {
+   seq_printf(seq, ,resgid=%u, sbi-s_resgid);
+   }
+   if (test_opt(sb, ERRORS_CONT)) {
+   int def_errors = le16_to_cpu(es-s_errors);
+
+   if (def_errors == EXT3_ERRORS_PANIC ||
+   def_errors == EXT3_ERRORS_RO) {
+   seq_puts(seq, ,errors=continue);
+   }
+   }
+   if (test_opt(sb, ERRORS_RO))
+   seq_puts(seq, ,errors=remount-ro);
+   if (test_opt(sb, ERRORS_PANIC))
+   seq_puts(seq, ,errors=panic);
+   if (test_opt(sb, NO_UID32))
+   seq_puts(seq, ,nouid32);
+   if (test_opt(sb, DEBUG))
+   seq_puts(seq, ,debug);
+   if (test_opt(sb, OLDALLOC))
+   seq_puts(seq, ,oldalloc);
+#ifdef CONFIG_EXT3_FS_XATTR
+   if (test_opt(sb, XATTR_USER))
+   seq_puts(seq, ,user_xattr);
+   if (!test_opt(sb, XATTR_USER) 
+   (def_mount_opts  EXT3_DEFM_XATTR_USER)) {
+   seq_puts(seq, ,nouser_xattr);
+   }
+#endif
+#ifdef CONFIG_EXT3_FS_POSIX_ACL
+   if (test_opt(sb, POSIX_ACL))
+   seq_puts(seq, ,acl);
+   if (!test_opt(sb, POSIX_ACL)  (def_mount_opts  EXT3_DEFM_ACL))
+   seq_puts(seq, ,noacl);
+#endif
+   if (!test_opt(sb, RESERVATION))
+   seq_puts(seq, ,noreservation);
+   if (sbi-s_commit_interval) {
+   seq_printf(seq, ,commit=%u,
+  (unsigned) (sbi-s_commit_interval / HZ));
+   }
+   if (test_opt(sb, BARRIER))
+   seq_puts(seq, ,barrier=1);
+   if (test_opt(sb, NOBH))
+   seq_puts(seq, ,nobh);
 
if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA)
seq_puts(seq, ,data=journal);
@@ -1425,6 +1494,7 @@ static int ext3_fill_super (struct super
sbi-s_mount_opt = 0;
sbi-s_resuid = EXT3_DEF_RESUID;
sbi-s_resgid = EXT3_DEF_RESGID;
+   sbi-s_sb_block = sb_block;
 
unlock_kernel();
 
diff -puN include/linux/ext3_fs_sb.h~ext3-show-all-mount-options 
include/linux/ext3_fs_sb.h
--- a/include/linux/ext3_fs_sb.h~ext3-show-all-mount-options
+++ a/include/linux/ext3_fs_sb.h
@@ -44,6 +44,7 @@ struct ext3_sb_info {
struct ext3_super_block * s_es; /* Pointer to the super block in the 
buffer */
struct buffer_head ** s_group_desc;
unsigned long  s_mount_opt;
+   ext3_fsblk_t s_sb_block;
uid_t s_resuid;
gid_t s_resgid;
unsigned short s_mount_state;
_
-
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


[patch 076/327] ext4: show all mount options

2007-10-17 Thread akpm
From: Miklos Szeredi [EMAIL PROTECTED]

Signed-off-by: Miklos Szeredi [EMAIL PROTECTED]
Cc: linux-ext4@vger.kernel.org
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
---

 fs/ext4/super.c|   72 +++
 include/linux/ext4_fs_sb.h |1 
 2 files changed, 73 insertions(+)

diff -puN fs/ext4/super.c~ext4-show-all-mount-options fs/ext4/super.c
--- a/fs/ext4/super.c~ext4-show-all-mount-options
+++ a/fs/ext4/super.c
@@ -596,9 +596,80 @@ static inline void ext4_show_quota_optio
 #endif
 }
 
+/*
+ * Show an option if
+ *  - it's set to a non-default value OR
+ *  - if the per-sb default is different from the global default
+ */
 static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
 {
struct super_block *sb = vfs-mnt_sb;
+   struct ext4_sb_info *sbi = EXT4_SB(sb);
+   struct ext4_super_block *es = sbi-s_es;
+   unsigned long def_mount_opts;
+
+   def_mount_opts = le32_to_cpu(es-s_default_mount_opts);
+
+   if (sbi-s_sb_block != 1)
+   seq_printf(seq, ,sb=%llu, sbi-s_sb_block);
+   if (test_opt(sb, MINIX_DF))
+   seq_puts(seq, ,minixdf);
+   if (test_opt(sb, GRPID))
+   seq_puts(seq, ,grpid);
+   if (!test_opt(sb, GRPID)  (def_mount_opts  EXT4_DEFM_BSDGROUPS))
+   seq_puts(seq, ,nogrpid);
+   if (sbi-s_resuid != EXT4_DEF_RESUID ||
+   le16_to_cpu(es-s_def_resuid) != EXT4_DEF_RESUID) {
+   seq_printf(seq, ,resuid=%u, sbi-s_resuid);
+   }
+   if (sbi-s_resgid != EXT4_DEF_RESGID ||
+   le16_to_cpu(es-s_def_resgid) != EXT4_DEF_RESGID) {
+   seq_printf(seq, ,resgid=%u, sbi-s_resgid);
+   }
+   if (test_opt(sb, ERRORS_CONT)) {
+   int def_errors = le16_to_cpu(es-s_errors);
+
+   if (def_errors == EXT4_ERRORS_PANIC ||
+   def_errors == EXT4_ERRORS_RO) {
+   seq_puts(seq, ,errors=continue);
+   }
+   }
+   if (test_opt(sb, ERRORS_RO))
+   seq_puts(seq, ,errors=remount-ro);
+   if (test_opt(sb, ERRORS_PANIC))
+   seq_puts(seq, ,errors=panic);
+   if (test_opt(sb, NO_UID32))
+   seq_puts(seq, ,nouid32);
+   if (test_opt(sb, DEBUG))
+   seq_puts(seq, ,debug);
+   if (test_opt(sb, OLDALLOC))
+   seq_puts(seq, ,oldalloc);
+#ifdef CONFIG_EXT4_FS_XATTR
+   if (test_opt(sb, XATTR_USER))
+   seq_puts(seq, ,user_xattr);
+   if (!test_opt(sb, XATTR_USER) 
+   (def_mount_opts  EXT4_DEFM_XATTR_USER)) {
+   seq_puts(seq, ,nouser_xattr);
+   }
+#endif
+#ifdef CONFIG_EXT4_FS_POSIX_ACL
+   if (test_opt(sb, POSIX_ACL))
+   seq_puts(seq, ,acl);
+   if (!test_opt(sb, POSIX_ACL)  (def_mount_opts  EXT4_DEFM_ACL))
+   seq_puts(seq, ,noacl);
+#endif
+   if (!test_opt(sb, RESERVATION))
+   seq_puts(seq, ,noreservation);
+   if (sbi-s_commit_interval) {
+   seq_printf(seq, ,commit=%u,
+  (unsigned) (sbi-s_commit_interval / HZ));
+   }
+   if (test_opt(sb, BARRIER))
+   seq_puts(seq, ,barrier=1);
+   if (test_opt(sb, NOBH))
+   seq_puts(seq, ,nobh);
+   if (!test_opt(sb, EXTENTS))
+   seq_puts(seq, ,noextents);
 
if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)
seq_puts(seq, ,data=journal);
@@ -1486,6 +1557,7 @@ static int ext4_fill_super (struct super
sbi-s_mount_opt = 0;
sbi-s_resuid = EXT4_DEF_RESUID;
sbi-s_resgid = EXT4_DEF_RESGID;
+   sbi-s_sb_block = sb_block;
 
unlock_kernel();
 
diff -puN include/linux/ext4_fs_sb.h~ext4-show-all-mount-options 
include/linux/ext4_fs_sb.h
--- a/include/linux/ext4_fs_sb.h~ext4-show-all-mount-options
+++ a/include/linux/ext4_fs_sb.h
@@ -45,6 +45,7 @@ struct ext4_sb_info {
struct ext4_super_block * s_es; /* Pointer to the super block in the 
buffer */
struct buffer_head ** s_group_desc;
unsigned long  s_mount_opt;
+   ext4_fsblk_t s_sb_block;
uid_t s_resuid;
gid_t s_resgid;
unsigned short s_mount_state;
_
-
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


[patch 074/327] ext2: show all mount options

2007-10-17 Thread akpm
From: Miklos Szeredi [EMAIL PROTECTED]

Using mtab is problematic for various reasons, one of them is that
unprivileged mounts won't turn up in there.  So we want to get rid of it, and
use /proc/mounts instead.

But most filesystems are lazy, and are not showing all mount options.  Which
means, that without mtab, the user won't be able to see some or all of the
options.

It would be nice if the generic code could remember the mount options, and
show them without the need to add extra code to filesystems.  But this is not
easy, because different filesystems handle mount options given options, and
not tough the rest.  This is not taken into account by mount(8) either, so
/etc/mtab will be broken in this case.

This series fixes up -show_options() in ext[234].

Signed-off-by: Miklos Szeredi [EMAIL PROTECTED]
Cc: linux-ext4@vger.kernel.org
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
---

 fs/ext2/super.c|   61 +--
 include/linux/ext2_fs_sb.h |1 
 2 files changed, 60 insertions(+), 2 deletions(-)

diff -puN fs/ext2/super.c~ext2-show-all-mount-options fs/ext2/super.c
--- a/fs/ext2/super.c~ext2-show-all-mount-options
+++ a/fs/ext2/super.c
@@ -203,10 +203,66 @@ static void ext2_clear_inode(struct inod
 
 static int ext2_show_options(struct seq_file *seq, struct vfsmount *vfs)
 {
-   struct ext2_sb_info *sbi = EXT2_SB(vfs-mnt_sb);
+   struct super_block *sb = vfs-mnt_sb;
+   struct ext2_sb_info *sbi = EXT2_SB(sb);
+   struct ext2_super_block *es = sbi-s_es;
+   unsigned long def_mount_opts;
+
+   def_mount_opts = le32_to_cpu(es-s_default_mount_opts);
 
-   if (sbi-s_mount_opt  EXT2_MOUNT_GRPID)
+   if (sbi-s_sb_block != 1)
+   seq_printf(seq, ,sb=%lu, sbi-s_sb_block);
+   if (test_opt(sb, MINIX_DF))
+   seq_puts(seq, ,minixdf);
+   if (test_opt(sb, GRPID))
seq_puts(seq, ,grpid);
+   if (!test_opt(sb, GRPID)  (def_mount_opts  EXT2_DEFM_BSDGROUPS))
+   seq_puts(seq, ,nogrpid);
+   if (sbi-s_resuid != EXT2_DEF_RESUID ||
+   le16_to_cpu(es-s_def_resuid) != EXT2_DEF_RESUID) {
+   seq_printf(seq, ,resuid=%u, sbi-s_resuid);
+   }
+   if (sbi-s_resgid != EXT2_DEF_RESGID ||
+   le16_to_cpu(es-s_def_resgid) != EXT2_DEF_RESGID) {
+   seq_printf(seq, ,resgid=%u, sbi-s_resgid);
+   }
+   if (test_opt(sb, ERRORS_CONT)) {
+   int def_errors = le16_to_cpu(es-s_errors);
+
+   if (def_errors == EXT2_ERRORS_PANIC ||
+   def_errors == EXT2_ERRORS_RO) {
+   seq_puts(seq, ,errors=continue);
+   }
+   }
+   if (test_opt(sb, ERRORS_RO))
+   seq_puts(seq, ,errors=remount-ro);
+   if (test_opt(sb, ERRORS_PANIC))
+   seq_puts(seq, ,errors=panic);
+   if (test_opt(sb, NO_UID32))
+   seq_puts(seq, ,nouid32);
+   if (test_opt(sb, DEBUG))
+   seq_puts(seq, ,debug);
+   if (test_opt(sb, OLDALLOC))
+   seq_puts(seq, ,oldalloc);
+
+#ifdef CONFIG_EXT2_FS_XATTR
+   if (test_opt(sb, XATTR_USER))
+   seq_puts(seq, ,user_xattr);
+   if (!test_opt(sb, XATTR_USER) 
+   (def_mount_opts  EXT2_DEFM_XATTR_USER)) {
+   seq_puts(seq, ,nouser_xattr);
+   }
+#endif
+
+#ifdef CONFIG_EXT2_FS_POSIX_ACL
+   if (test_opt(sb, POSIX_ACL))
+   seq_puts(seq, ,acl);
+   if (!test_opt(sb, POSIX_ACL)  (def_mount_opts  EXT2_DEFM_ACL))
+   seq_puts(seq, ,noacl);
+#endif
+
+   if (test_opt(sb, NOBH))
+   seq_puts(seq, ,nobh);
 
 #if defined(CONFIG_QUOTA)
if (sbi-s_mount_opt  EXT2_MOUNT_USRQUOTA)
@@ -659,6 +715,7 @@ static int ext2_fill_super(struct super_
if (!sbi)
return -ENOMEM;
sb-s_fs_info = sbi;
+   sbi-s_sb_block = sb_block;
 
/*
 * See what the current blocksize for the device is, and
diff -puN include/linux/ext2_fs_sb.h~ext2-show-all-mount-options 
include/linux/ext2_fs_sb.h
--- a/include/linux/ext2_fs_sb.h~ext2-show-all-mount-options
+++ a/include/linux/ext2_fs_sb.h
@@ -39,6 +39,7 @@ struct ext2_sb_info {
struct ext2_super_block * s_es; /* Pointer to the super block in the 
buffer */
struct buffer_head ** s_group_desc;
unsigned long  s_mount_opt;
+   unsigned long s_sb_block;
uid_t s_resuid;
gid_t s_resgid;
unsigned short s_mount_state;
_
-
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


[patch 075/327] ext3: show all mount options

2007-10-17 Thread akpm
From: Miklos Szeredi [EMAIL PROTECTED]

Signed-off-by: Miklos Szeredi [EMAIL PROTECTED]
Cc: linux-ext4@vger.kernel.org
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
---

 fs/ext3/super.c|   70 +++
 include/linux/ext3_fs_sb.h |1 
 2 files changed, 71 insertions(+)

diff -puN fs/ext3/super.c~ext3-show-all-mount-options fs/ext3/super.c
--- a/fs/ext3/super.c~ext3-show-all-mount-options
+++ a/fs/ext3/super.c
@@ -545,9 +545,78 @@ static inline void ext3_show_quota_optio
 #endif
 }
 
+/*
+ * Show an option if
+ *  - it's set to a non-default value OR
+ *  - if the per-sb default is different from the global default
+ */
 static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs)
 {
struct super_block *sb = vfs-mnt_sb;
+   struct ext3_sb_info *sbi = EXT3_SB(sb);
+   struct ext3_super_block *es = sbi-s_es;
+   unsigned long def_mount_opts;
+
+   def_mount_opts = le32_to_cpu(es-s_default_mount_opts);
+
+   if (sbi-s_sb_block != 1)
+   seq_printf(seq, ,sb=%lu, sbi-s_sb_block);
+   if (test_opt(sb, MINIX_DF))
+   seq_puts(seq, ,minixdf);
+   if (test_opt(sb, GRPID))
+   seq_puts(seq, ,grpid);
+   if (!test_opt(sb, GRPID)  (def_mount_opts  EXT3_DEFM_BSDGROUPS))
+   seq_puts(seq, ,nogrpid);
+   if (sbi-s_resuid != EXT3_DEF_RESUID ||
+   le16_to_cpu(es-s_def_resuid) != EXT3_DEF_RESUID) {
+   seq_printf(seq, ,resuid=%u, sbi-s_resuid);
+   }
+   if (sbi-s_resgid != EXT3_DEF_RESGID ||
+   le16_to_cpu(es-s_def_resgid) != EXT3_DEF_RESGID) {
+   seq_printf(seq, ,resgid=%u, sbi-s_resgid);
+   }
+   if (test_opt(sb, ERRORS_CONT)) {
+   int def_errors = le16_to_cpu(es-s_errors);
+
+   if (def_errors == EXT3_ERRORS_PANIC ||
+   def_errors == EXT3_ERRORS_RO) {
+   seq_puts(seq, ,errors=continue);
+   }
+   }
+   if (test_opt(sb, ERRORS_RO))
+   seq_puts(seq, ,errors=remount-ro);
+   if (test_opt(sb, ERRORS_PANIC))
+   seq_puts(seq, ,errors=panic);
+   if (test_opt(sb, NO_UID32))
+   seq_puts(seq, ,nouid32);
+   if (test_opt(sb, DEBUG))
+   seq_puts(seq, ,debug);
+   if (test_opt(sb, OLDALLOC))
+   seq_puts(seq, ,oldalloc);
+#ifdef CONFIG_EXT3_FS_XATTR
+   if (test_opt(sb, XATTR_USER))
+   seq_puts(seq, ,user_xattr);
+   if (!test_opt(sb, XATTR_USER) 
+   (def_mount_opts  EXT3_DEFM_XATTR_USER)) {
+   seq_puts(seq, ,nouser_xattr);
+   }
+#endif
+#ifdef CONFIG_EXT3_FS_POSIX_ACL
+   if (test_opt(sb, POSIX_ACL))
+   seq_puts(seq, ,acl);
+   if (!test_opt(sb, POSIX_ACL)  (def_mount_opts  EXT3_DEFM_ACL))
+   seq_puts(seq, ,noacl);
+#endif
+   if (!test_opt(sb, RESERVATION))
+   seq_puts(seq, ,noreservation);
+   if (sbi-s_commit_interval) {
+   seq_printf(seq, ,commit=%u,
+  (unsigned) (sbi-s_commit_interval / HZ));
+   }
+   if (test_opt(sb, BARRIER))
+   seq_puts(seq, ,barrier=1);
+   if (test_opt(sb, NOBH))
+   seq_puts(seq, ,nobh);
 
if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA)
seq_puts(seq, ,data=journal);
@@ -1425,6 +1494,7 @@ static int ext3_fill_super (struct super
sbi-s_mount_opt = 0;
sbi-s_resuid = EXT3_DEF_RESUID;
sbi-s_resgid = EXT3_DEF_RESGID;
+   sbi-s_sb_block = sb_block;
 
unlock_kernel();
 
diff -puN include/linux/ext3_fs_sb.h~ext3-show-all-mount-options 
include/linux/ext3_fs_sb.h
--- a/include/linux/ext3_fs_sb.h~ext3-show-all-mount-options
+++ a/include/linux/ext3_fs_sb.h
@@ -44,6 +44,7 @@ struct ext3_sb_info {
struct ext3_super_block * s_es; /* Pointer to the super block in the 
buffer */
struct buffer_head ** s_group_desc;
unsigned long  s_mount_opt;
+   ext3_fsblk_t s_sb_block;
uid_t s_resuid;
gid_t s_resgid;
unsigned short s_mount_state;
_
-
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


[patch 076/327] ext4: show all mount options

2007-10-17 Thread akpm
From: Miklos Szeredi [EMAIL PROTECTED]

Signed-off-by: Miklos Szeredi [EMAIL PROTECTED]
Cc: linux-ext4@vger.kernel.org
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
---

 fs/ext4/super.c|   72 +++
 include/linux/ext4_fs_sb.h |1 
 2 files changed, 73 insertions(+)

diff -puN fs/ext4/super.c~ext4-show-all-mount-options fs/ext4/super.c
--- a/fs/ext4/super.c~ext4-show-all-mount-options
+++ a/fs/ext4/super.c
@@ -596,9 +596,80 @@ static inline void ext4_show_quota_optio
 #endif
 }
 
+/*
+ * Show an option if
+ *  - it's set to a non-default value OR
+ *  - if the per-sb default is different from the global default
+ */
 static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
 {
struct super_block *sb = vfs-mnt_sb;
+   struct ext4_sb_info *sbi = EXT4_SB(sb);
+   struct ext4_super_block *es = sbi-s_es;
+   unsigned long def_mount_opts;
+
+   def_mount_opts = le32_to_cpu(es-s_default_mount_opts);
+
+   if (sbi-s_sb_block != 1)
+   seq_printf(seq, ,sb=%llu, sbi-s_sb_block);
+   if (test_opt(sb, MINIX_DF))
+   seq_puts(seq, ,minixdf);
+   if (test_opt(sb, GRPID))
+   seq_puts(seq, ,grpid);
+   if (!test_opt(sb, GRPID)  (def_mount_opts  EXT4_DEFM_BSDGROUPS))
+   seq_puts(seq, ,nogrpid);
+   if (sbi-s_resuid != EXT4_DEF_RESUID ||
+   le16_to_cpu(es-s_def_resuid) != EXT4_DEF_RESUID) {
+   seq_printf(seq, ,resuid=%u, sbi-s_resuid);
+   }
+   if (sbi-s_resgid != EXT4_DEF_RESGID ||
+   le16_to_cpu(es-s_def_resgid) != EXT4_DEF_RESGID) {
+   seq_printf(seq, ,resgid=%u, sbi-s_resgid);
+   }
+   if (test_opt(sb, ERRORS_CONT)) {
+   int def_errors = le16_to_cpu(es-s_errors);
+
+   if (def_errors == EXT4_ERRORS_PANIC ||
+   def_errors == EXT4_ERRORS_RO) {
+   seq_puts(seq, ,errors=continue);
+   }
+   }
+   if (test_opt(sb, ERRORS_RO))
+   seq_puts(seq, ,errors=remount-ro);
+   if (test_opt(sb, ERRORS_PANIC))
+   seq_puts(seq, ,errors=panic);
+   if (test_opt(sb, NO_UID32))
+   seq_puts(seq, ,nouid32);
+   if (test_opt(sb, DEBUG))
+   seq_puts(seq, ,debug);
+   if (test_opt(sb, OLDALLOC))
+   seq_puts(seq, ,oldalloc);
+#ifdef CONFIG_EXT4_FS_XATTR
+   if (test_opt(sb, XATTR_USER))
+   seq_puts(seq, ,user_xattr);
+   if (!test_opt(sb, XATTR_USER) 
+   (def_mount_opts  EXT4_DEFM_XATTR_USER)) {
+   seq_puts(seq, ,nouser_xattr);
+   }
+#endif
+#ifdef CONFIG_EXT4_FS_POSIX_ACL
+   if (test_opt(sb, POSIX_ACL))
+   seq_puts(seq, ,acl);
+   if (!test_opt(sb, POSIX_ACL)  (def_mount_opts  EXT4_DEFM_ACL))
+   seq_puts(seq, ,noacl);
+#endif
+   if (!test_opt(sb, RESERVATION))
+   seq_puts(seq, ,noreservation);
+   if (sbi-s_commit_interval) {
+   seq_printf(seq, ,commit=%u,
+  (unsigned) (sbi-s_commit_interval / HZ));
+   }
+   if (test_opt(sb, BARRIER))
+   seq_puts(seq, ,barrier=1);
+   if (test_opt(sb, NOBH))
+   seq_puts(seq, ,nobh);
+   if (!test_opt(sb, EXTENTS))
+   seq_puts(seq, ,noextents);
 
if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)
seq_puts(seq, ,data=journal);
@@ -1486,6 +1557,7 @@ static int ext4_fill_super (struct super
sbi-s_mount_opt = 0;
sbi-s_resuid = EXT4_DEF_RESUID;
sbi-s_resgid = EXT4_DEF_RESGID;
+   sbi-s_sb_block = sb_block;
 
unlock_kernel();
 
diff -puN include/linux/ext4_fs_sb.h~ext4-show-all-mount-options 
include/linux/ext4_fs_sb.h
--- a/include/linux/ext4_fs_sb.h~ext4-show-all-mount-options
+++ a/include/linux/ext4_fs_sb.h
@@ -45,6 +45,7 @@ struct ext4_sb_info {
struct ext4_super_block * s_es; /* Pointer to the super block in the 
buffer */
struct buffer_head ** s_group_desc;
unsigned long  s_mount_opt;
+   ext4_fsblk_t s_sb_block;
uid_t s_resuid;
gid_t s_resgid;
unsigned short s_mount_state;
_
-
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


[patch 074/327] ext2: show all mount options

2007-10-17 Thread akpm
From: Miklos Szeredi [EMAIL PROTECTED]

Using mtab is problematic for various reasons, one of them is that
unprivileged mounts won't turn up in there.  So we want to get rid of it, and
use /proc/mounts instead.

But most filesystems are lazy, and are not showing all mount options.  Which
means, that without mtab, the user won't be able to see some or all of the
options.

It would be nice if the generic code could remember the mount options, and
show them without the need to add extra code to filesystems.  But this is not
easy, because different filesystems handle mount options given options, and
not tough the rest.  This is not taken into account by mount(8) either, so
/etc/mtab will be broken in this case.

This series fixes up -show_options() in ext[234].

Signed-off-by: Miklos Szeredi [EMAIL PROTECTED]
Cc: linux-ext4@vger.kernel.org
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
---

 fs/ext2/super.c|   61 +--
 include/linux/ext2_fs_sb.h |1 
 2 files changed, 60 insertions(+), 2 deletions(-)

diff -puN fs/ext2/super.c~ext2-show-all-mount-options fs/ext2/super.c
--- a/fs/ext2/super.c~ext2-show-all-mount-options
+++ a/fs/ext2/super.c
@@ -203,10 +203,66 @@ static void ext2_clear_inode(struct inod
 
 static int ext2_show_options(struct seq_file *seq, struct vfsmount *vfs)
 {
-   struct ext2_sb_info *sbi = EXT2_SB(vfs-mnt_sb);
+   struct super_block *sb = vfs-mnt_sb;
+   struct ext2_sb_info *sbi = EXT2_SB(sb);
+   struct ext2_super_block *es = sbi-s_es;
+   unsigned long def_mount_opts;
+
+   def_mount_opts = le32_to_cpu(es-s_default_mount_opts);
 
-   if (sbi-s_mount_opt  EXT2_MOUNT_GRPID)
+   if (sbi-s_sb_block != 1)
+   seq_printf(seq, ,sb=%lu, sbi-s_sb_block);
+   if (test_opt(sb, MINIX_DF))
+   seq_puts(seq, ,minixdf);
+   if (test_opt(sb, GRPID))
seq_puts(seq, ,grpid);
+   if (!test_opt(sb, GRPID)  (def_mount_opts  EXT2_DEFM_BSDGROUPS))
+   seq_puts(seq, ,nogrpid);
+   if (sbi-s_resuid != EXT2_DEF_RESUID ||
+   le16_to_cpu(es-s_def_resuid) != EXT2_DEF_RESUID) {
+   seq_printf(seq, ,resuid=%u, sbi-s_resuid);
+   }
+   if (sbi-s_resgid != EXT2_DEF_RESGID ||
+   le16_to_cpu(es-s_def_resgid) != EXT2_DEF_RESGID) {
+   seq_printf(seq, ,resgid=%u, sbi-s_resgid);
+   }
+   if (test_opt(sb, ERRORS_CONT)) {
+   int def_errors = le16_to_cpu(es-s_errors);
+
+   if (def_errors == EXT2_ERRORS_PANIC ||
+   def_errors == EXT2_ERRORS_RO) {
+   seq_puts(seq, ,errors=continue);
+   }
+   }
+   if (test_opt(sb, ERRORS_RO))
+   seq_puts(seq, ,errors=remount-ro);
+   if (test_opt(sb, ERRORS_PANIC))
+   seq_puts(seq, ,errors=panic);
+   if (test_opt(sb, NO_UID32))
+   seq_puts(seq, ,nouid32);
+   if (test_opt(sb, DEBUG))
+   seq_puts(seq, ,debug);
+   if (test_opt(sb, OLDALLOC))
+   seq_puts(seq, ,oldalloc);
+
+#ifdef CONFIG_EXT2_FS_XATTR
+   if (test_opt(sb, XATTR_USER))
+   seq_puts(seq, ,user_xattr);
+   if (!test_opt(sb, XATTR_USER) 
+   (def_mount_opts  EXT2_DEFM_XATTR_USER)) {
+   seq_puts(seq, ,nouser_xattr);
+   }
+#endif
+
+#ifdef CONFIG_EXT2_FS_POSIX_ACL
+   if (test_opt(sb, POSIX_ACL))
+   seq_puts(seq, ,acl);
+   if (!test_opt(sb, POSIX_ACL)  (def_mount_opts  EXT2_DEFM_ACL))
+   seq_puts(seq, ,noacl);
+#endif
+
+   if (test_opt(sb, NOBH))
+   seq_puts(seq, ,nobh);
 
 #if defined(CONFIG_QUOTA)
if (sbi-s_mount_opt  EXT2_MOUNT_USRQUOTA)
@@ -659,6 +715,7 @@ static int ext2_fill_super(struct super_
if (!sbi)
return -ENOMEM;
sb-s_fs_info = sbi;
+   sbi-s_sb_block = sb_block;
 
/*
 * See what the current blocksize for the device is, and
diff -puN include/linux/ext2_fs_sb.h~ext2-show-all-mount-options 
include/linux/ext2_fs_sb.h
--- a/include/linux/ext2_fs_sb.h~ext2-show-all-mount-options
+++ a/include/linux/ext2_fs_sb.h
@@ -39,6 +39,7 @@ struct ext2_sb_info {
struct ext2_super_block * s_es; /* Pointer to the super block in the 
buffer */
struct buffer_head ** s_group_desc;
unsigned long  s_mount_opt;
+   unsigned long s_sb_block;
uid_t s_resuid;
gid_t s_resgid;
unsigned short s_mount_state;
_
-
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


[patch 230/327] ext3: remove #ifdef CONFIG_EXT3_INDEX

2007-10-17 Thread akpm
From: Eric Sandeen [EMAIL PROTECTED]

CONFIG_EXT3_INDEX is not an exposed config option in the kernel, and it is
unconditionally defined in ext3_fs.h.  tune2fs is already able to turn off
dir indexing, so at this point it's just cluttering up the code.  Remove
it.

Signed-off-by: Eric Sandeen [EMAIL PROTECTED]
Cc: linux-ext4@vger.kernel.org
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
---

 fs/ext3/dir.c   |7 ---
 fs/ext3/namei.c |   19 ---
 include/linux/ext3_fs.h |   14 ++
 3 files changed, 2 insertions(+), 38 deletions(-)

diff -puN fs/ext3/dir.c~ext3-remove-ifdef-config_ext3_index fs/ext3/dir.c
--- a/fs/ext3/dir.c~ext3-remove-ifdef-config_ext3_index
+++ a/fs/ext3/dir.c
@@ -47,9 +47,7 @@ const struct file_operations ext3_dir_op
.compat_ioctl   = ext3_compat_ioctl,
 #endif
.fsync  = ext3_sync_file,   /* BKL held */
-#ifdef CONFIG_EXT3_INDEX
.release= ext3_release_dir,
-#endif
 };
 
 
@@ -107,7 +105,6 @@ static int ext3_readdir(struct file * fi
 
sb = inode-i_sb;
 
-#ifdef CONFIG_EXT3_INDEX
if (EXT3_HAS_COMPAT_FEATURE(inode-i_sb,
EXT3_FEATURE_COMPAT_DIR_INDEX) 
((EXT3_I(inode)-i_flags  EXT3_INDEX_FL) ||
@@ -123,7 +120,6 @@ static int ext3_readdir(struct file * fi
 */
EXT3_I(filp-f_path.dentry-d_inode)-i_flags = ~EXT3_INDEX_FL;
}
-#endif
stored = 0;
offset = filp-f_pos  (sb-s_blocksize - 1);
 
@@ -232,7 +228,6 @@ out:
return ret;
 }
 
-#ifdef CONFIG_EXT3_INDEX
 /*
  * These functions convert from the major/minor hash to an f_pos
  * value.
@@ -518,5 +513,3 @@ static int ext3_release_dir (struct inod
 
return 0;
 }
-
-#endif
diff -puN fs/ext3/namei.c~ext3-remove-ifdef-config_ext3_index fs/ext3/namei.c
--- a/fs/ext3/namei.c~ext3-remove-ifdef-config_ext3_index
+++ a/fs/ext3/namei.c
@@ -144,7 +144,6 @@ struct dx_map_entry
u16 size;
 };
 
-#ifdef CONFIG_EXT3_INDEX
 static inline unsigned dx_get_block (struct dx_entry *entry);
 static void dx_set_block (struct dx_entry *entry, unsigned value);
 static inline unsigned dx_get_hash (struct dx_entry *entry);
@@ -768,8 +767,6 @@ static void dx_insert_block(struct dx_fr
dx_set_block(new, block);
dx_set_count(entries, count + 1);
 }
-#endif
-
 
 static void ext3_update_dx_flag(struct inode *inode)
 {
@@ -871,7 +868,6 @@ static struct buffer_head * ext3_find_en
name = dentry-d_name.name;
if (namelen  EXT3_NAME_LEN)
return NULL;
-#ifdef CONFIG_EXT3_INDEX
if (is_dx(dir)) {
bh = ext3_dx_find_entry(dentry, res_dir, err);
/*
@@ -883,7 +879,6 @@ static struct buffer_head * ext3_find_en
return bh;
dxtrace(printk(ext3_find_entry: dx failed, falling back\n));
}
-#endif
nblocks = dir-i_size  EXT3_BLOCK_SIZE_BITS(sb);
start = EXT3_I(dir)-i_dir_start_lookup;
if (start = nblocks)
@@ -959,7 +954,6 @@ cleanup_and_exit:
return ret;
 }
 
-#ifdef CONFIG_EXT3_INDEX
 static struct buffer_head * ext3_dx_find_entry(struct dentry *dentry,
   struct ext3_dir_entry_2 **res_dir, int *err)
 {
@@ -1027,7 +1021,6 @@ errout:
dx_release (frames);
return NULL;
 }
-#endif
 
 static struct dentry *ext3_lookup(struct inode * dir, struct dentry *dentry, 
struct nameidata *nd)
 {
@@ -1123,7 +1116,6 @@ static inline void ext3_set_de_type(stru
de-file_type = ext3_type_by_mode[(mode  S_IFMT)S_SHIFT];
 }
 
-#ifdef CONFIG_EXT3_INDEX
 /*
  * Move count entries from end of map between two memory locations.
  * Returns pointer to last entry moved.
@@ -1268,7 +1260,6 @@ errout:
*error = err;
return NULL;
 }
-#endif
 
 
 /*
@@ -1366,7 +1357,6 @@ static int add_dirent_to_buf(handle_t *h
return 0;
 }
 
-#ifdef CONFIG_EXT3_INDEX
 /*
  * This converts a one block unindexed directory to a 3 block indexed
  * directory, and adds the dentry to the indexed directory.
@@ -1445,7 +1435,6 @@ static int make_indexed_dir(handle_t *ha
 
return add_dirent_to_buf(handle, dentry, inode, de, bh);
 }
-#endif
 
 /*
  * ext3_add_entry()
@@ -1466,9 +1455,7 @@ static int ext3_add_entry (handle_t *han
struct ext3_dir_entry_2 *de;
struct super_block * sb;
int retval;
-#ifdef CONFIG_EXT3_INDEX
int dx_fallback=0;
-#endif
unsigned blocksize;
u32 block, blocks;
 
@@ -1476,7 +1463,6 @@ static int ext3_add_entry (handle_t *han
blocksize = sb-s_blocksize;
if (!dentry-d_name.len)
return -EINVAL;
-#ifdef CONFIG_EXT3_INDEX
if (is_dx(dir)) {
retval = ext3_dx_add_entry(handle, dentry, inode);
if (!retval || (retval != ERR_BAD_DX_DIR))
@@ -1485,7 +1471,6 @@ static int ext3_add_entry (handle_t *han
dx_fallback++;
   

[patch 237/327] ext3: lighten up resize transaction requirements

2007-10-17 Thread akpm
From: Eric Sandeen [EMAIL PROTECTED]

When resizing online, setup_new_group_blocks attempts to reserve a
potentially very large transaction, depending on the current filesystem
geometry.  For some journal sizes, there may not be enough room for this
transaction, and the online resize will fail.

The patch below resizes  restarts the transaction as necessary while
setting up the new group, and should work with even the smallest journal.

Tested with something like:

[EMAIL PROTECTED] ~]# dd if=/dev/zero of=fsfile bs=1024 count=32768
[EMAIL PROTECTED] ~]# mkfs.ext3 -b 1024 fsfile 16384
[EMAIL PROTECTED] ~]# mount -o loop fsfile mnt/
[EMAIL PROTECTED] ~]# resize2fs /dev/loop0
resize2fs 1.40.2 (12-Jul-2007)
Filesystem at /dev/loop0 is mounted on /root/mnt; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/loop0 to 32768 (1k) blocks.
resize2fs: No space left on device While trying to add group #2
[EMAIL PROTECTED] ~]# dmesg | tail -n 1
JBD: resize2fs wants too many credits (258  256)
[EMAIL PROTECTED] ~]#

With the below change, it works.

[EMAIL PROTECTED]: coding-style fixes]
Signed-off-by: Eric Sandeen [EMAIL PROTECTED]
Acked-by: Andreas Dilger [EMAIL PROTECTED]
Cc: linux-ext4@vger.kernel.org
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
---

 fs/ext3/resize.c |   51 +++--
 1 file changed, 49 insertions(+), 2 deletions(-)

diff -puN fs/ext3/resize.c~ext3-lighten-up-resize-transaction-requirements 
fs/ext3/resize.c
--- a/fs/ext3/resize.c~ext3-lighten-up-resize-transaction-requirements
+++ a/fs/ext3/resize.c
@@ -154,6 +154,34 @@ static void mark_bitmap_end(int start_bi
 }
 
 /*
+ * If we have fewer than thresh credits, extend by EXT3_MAX_TRANS_DATA.
+ * If that fails, restart the transaction  regain write access for the
+ * buffer head which is used for block_bitmap modifications.
+ */
+static int extend_or_restart_transaction(handle_t *handle, int thresh,
+struct buffer_head *bh)
+{
+   int err;
+
+   if (handle-h_buffer_credits = thresh)
+   return 0;
+
+   err = ext3_journal_extend(handle, EXT3_MAX_TRANS_DATA);
+   if (err  0)
+   return err;
+   if (err) {
+   err = ext3_journal_restart(handle, EXT3_MAX_TRANS_DATA);
+   if (err)
+   return err;
+   err = ext3_journal_get_write_access(handle, bh);
+   if (err)
+   return err;
+   }
+
+   return 0;
+}
+
+/*
  * Set up the block and inode bitmaps, and the inode table for the new group.
  * This doesn't need to be part of the main transaction, since we are only
  * changing blocks outside the actual filesystem.  We still do journaling to
@@ -175,8 +203,9 @@ static int setup_new_group_blocks(struct
int i;
int err = 0, err2;
 
-   handle = ext3_journal_start_sb(sb, reserved_gdb + gdblocks +
-  2 + sbi-s_itb_per_group);
+   /* This transaction may be extended/restarted along the way */
+   handle = ext3_journal_start_sb(sb, EXT3_MAX_TRANS_DATA);
+
if (IS_ERR(handle))
return PTR_ERR(handle);
 
@@ -203,6 +232,10 @@ static int setup_new_group_blocks(struct
 
ext3_debug(update backup group %#04lx (+%d)\n, block, bit);
 
+   err = extend_or_restart_transaction(handle, 1, bh);
+   if (err)
+   goto exit_bh;
+
gdb = sb_getblk(sb, block);
if (!gdb) {
err = -EIO;
@@ -228,6 +261,10 @@ static int setup_new_group_blocks(struct
 
ext3_debug(clear reserved block %#04lx (+%d)\n, block, bit);
 
+   err = extend_or_restart_transaction(handle, 1, bh);
+   if (err)
+   goto exit_bh;
+
if (IS_ERR(gdb = bclean(handle, sb, block))) {
err = PTR_ERR(bh);
goto exit_bh;
@@ -249,6 +286,11 @@ static int setup_new_group_blocks(struct
struct buffer_head *it;
 
ext3_debug(clear inode block %#04lx (+%d)\n, block, bit);
+
+   err = extend_or_restart_transaction(handle, 1, bh);
+   if (err)
+   goto exit_bh;
+
if (IS_ERR(it = bclean(handle, sb, block))) {
err = PTR_ERR(it);
goto exit_bh;
@@ -257,6 +299,11 @@ static int setup_new_group_blocks(struct
brelse(it);
ext3_set_bit(bit, bh-b_data);
}
+
+   err = extend_or_restart_transaction(handle, 2, bh);
+   if (err)
+   goto exit_bh;
+
mark_bitmap_end(input-blocks_count, EXT3_BLOCKS_PER_GROUP(sb),
bh-b_data);
ext3_journal_dirty_metadata(handle, bh);
_
-
To unsubscribe from this list: send the line unsubscribe linux-ext4 in

[patch 144/327] Fix f_version type: should be u64 instead of unsigned long

2007-10-17 Thread akpm
From: Mathieu Desnoyers [EMAIL PROTECTED]

Fix f_version type: should be u64 instead of long

There is a type inconsistency between struct inode i_version and struct file
f_version.

fs.h:

struct inode
  u64 i_version;

and

struct file
  unsigned long   f_version;

Users do:

fs/ext3/dir.c:

if (filp-f_version != inode-i_version) {

So why isn't f_version a u64 ? It becomes a problem if versions gets
higher than 2^32 and we are on an architecture where longs are 32 bits.

This patch changes the f_version type to u64, and updates the users accordingly.

It applies to 2.6.23-rc2-mm2.

Signed-off-by: Mathieu Desnoyers [EMAIL PROTECTED]
Cc: Martin Bligh [EMAIL PROTECTED]
Cc: Randy.Dunlap [EMAIL PROTECTED]
Cc: Al Viro [EMAIL PROTECTED]
Cc: linux-ext4@vger.kernel.org
Cc: Mark Fasheh [EMAIL PROTECTED]
Cc: Christoph Hellwig [EMAIL PROTECTED]
Cc: J. Bruce Fields [EMAIL PROTECTED]
Cc: Trond Myklebust [EMAIL PROTECTED]
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
---

 fs/ext3/dir.c|2 +-
 fs/ext4/dir.c|2 +-
 fs/ocfs2/dir.c   |   10 +-
 fs/proc/base.c   |4 ++--
 include/linux/fs.h   |2 +-
 include/linux/seq_file.h |2 +-
 6 files changed, 11 insertions(+), 11 deletions(-)

diff -puN 
fs/ext3/dir.c~fix-f_version-type-should-be-u64-instead-of-unsigned-long 
fs/ext3/dir.c
--- a/fs/ext3/dir.c~fix-f_version-type-should-be-u64-instead-of-unsigned-long
+++ a/fs/ext3/dir.c
@@ -210,7 +210,7 @@ revalidate:
 * not the directory has been modified
 * during the copy operation.
 */
-   unsigned long version = filp-f_version;
+   u64 version = filp-f_version;
 
error = filldir(dirent, de-name,
de-name_len,
diff -puN 
fs/ext4/dir.c~fix-f_version-type-should-be-u64-instead-of-unsigned-long 
fs/ext4/dir.c
--- a/fs/ext4/dir.c~fix-f_version-type-should-be-u64-instead-of-unsigned-long
+++ a/fs/ext4/dir.c
@@ -210,7 +210,7 @@ revalidate:
 * not the directory has been modified
 * during the copy operation.
 */
-   unsigned long version = filp-f_version;
+   u64 version = filp-f_version;
 
error = filldir(dirent, de-name,
de-name_len,
diff -puN 
fs/ocfs2/dir.c~fix-f_version-type-should-be-u64-instead-of-unsigned-long 
fs/ocfs2/dir.c
--- a/fs/ocfs2/dir.c~fix-f_version-type-should-be-u64-instead-of-unsigned-long
+++ a/fs/ocfs2/dir.c
@@ -586,7 +586,7 @@ bail:
 }
 
 static int ocfs2_dir_foreach_blk_id(struct inode *inode,
-   unsigned long *f_version,
+   u64 *f_version,
loff_t *f_pos, void *priv,
filldir_t filldir, int *filldir_err)
 {
@@ -648,7 +648,7 @@ revalidate:
 * not the directory has been modified
 * during the copy operation.
 */
-   unsigned long version = *f_version;
+   u64 version = *f_version;
unsigned char d_type = DT_UNKNOWN;
 
if (de-file_type  OCFS2_FT_MAX)
@@ -677,7 +677,7 @@ out:
 }
 
 static int ocfs2_dir_foreach_blk_el(struct inode *inode,
-   unsigned long *f_version,
+   u64 *f_version,
loff_t *f_pos, void *priv,
filldir_t filldir, int *filldir_err)
 {
@@ -798,7 +798,7 @@ out:
return stored;
 }
 
-static int ocfs2_dir_foreach_blk(struct inode *inode, unsigned long *f_version,
+static int ocfs2_dir_foreach_blk(struct inode *inode, u64 *f_version,
 loff_t *f_pos, void *priv, filldir_t filldir,
 int *filldir_err)
 {
@@ -818,7 +818,7 @@ int ocfs2_dir_foreach(struct inode *inod
  filldir_t filldir)
 {
int ret = 0, filldir_err = 0;
-   unsigned long version = inode-i_version;
+   u64 version = inode-i_version;
 
while (*f_pos  i_size_read(inode)) {
ret = ocfs2_dir_foreach_blk(inode, version, f_pos, priv,
diff -puN 
fs/proc/base.c~fix-f_version-type-should-be-u64-instead-of-unsigned-long 
fs/proc/base.c
--- a/fs/proc/base.c~fix-f_version-type-should-be-u64-instead-of-unsigned-long
+++ a/fs/proc/base.c
@@ -2586,7 +2586,7 @@ static int proc_task_readdir(struct file
/* f_version caches the tgid value that the last readdir call couldn't
 * return. lseek aka telldir automagically resets f_version to 0.
  

[patch 073/327] convert ill defined log2() to ilog2()

2007-10-17 Thread akpm
From: Fengguang Wu [EMAIL PROTECTED]

It's *wrong* to have
#define log2(n) ffz(~(n))
It should be *reversed*:
#define log2(n) flz(~(n))
or
#define log2(n) fls(n)
or just use
ilog2(n) defined in linux/log2.h.

This patch follows the last solution, recommended by Andrew Morton.

Cc: linux-ext4@vger.kernel.org
Cc: Mingming Cao [EMAIL PROTECTED]
Cc: Bjorn Helgaas [EMAIL PROTECTED]
Cc: Chris Ahna [EMAIL PROTECTED]
Cc: David Mosberger-Tang [EMAIL PROTECTED]
Cc: Kyle McMartin [EMAIL PROTECTED]
Cc: Dave Airlie [EMAIL PROTECTED]
Cc: Dave Jones [EMAIL PROTECTED]
Signed-off-by: Fengguang Wu [EMAIL PROTECTED]
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
---

 drivers/char/agp/hp-agp.c |9 +++--
 drivers/char/agp/i460-agp.c   |5 ++---
 drivers/char/agp/parisc-agp.c |7 ++-
 fs/ext4/super.c   |6 ++
 4 files changed, 9 insertions(+), 18 deletions(-)

diff -puN drivers/char/agp/hp-agp.c~convert-ill-defined-log2-to-ilog2 
drivers/char/agp/hp-agp.c
--- a/drivers/char/agp/hp-agp.c~convert-ill-defined-log2-to-ilog2
+++ a/drivers/char/agp/hp-agp.c
@@ -14,15 +14,12 @@
 #include linux/pci.h
 #include linux/init.h
 #include linux/agp_backend.h
+#include linux/log2.h
 
 #include asm/acpi-ext.h
 
 #include agp.h
 
-#ifndef log2
-#define log2(x)ffz(~(x))
-#endif
-
 #define HP_ZX1_IOC_OFFSET  0x1000  /* ACPI reports SBA, we want IOC */
 
 /* HP ZX1 IOC registers */
@@ -257,7 +254,7 @@ hp_zx1_configure (void)
readl(hp-ioc_regs+HP_ZX1_IMASK);
writel(hp-iova_base|1, hp-ioc_regs+HP_ZX1_IBASE);
readl(hp-ioc_regs+HP_ZX1_IBASE);
-   writel(hp-iova_base|log2(HP_ZX1_IOVA_SIZE), 
hp-ioc_regs+HP_ZX1_PCOM);
+   writel(hp-iova_base|ilog2(HP_ZX1_IOVA_SIZE), 
hp-ioc_regs+HP_ZX1_PCOM);
readl(hp-ioc_regs+HP_ZX1_PCOM);
}
 
@@ -285,7 +282,7 @@ hp_zx1_tlbflush (struct agp_memory *mem)
 {
struct _hp_private *hp = hp_private;
 
-   writeq(hp-gart_base | log2(hp-gart_size), hp-ioc_regs+HP_ZX1_PCOM);
+   writeq(hp-gart_base | ilog2(hp-gart_size), hp-ioc_regs+HP_ZX1_PCOM);
readq(hp-ioc_regs+HP_ZX1_PCOM);
 }
 
diff -puN drivers/char/agp/i460-agp.c~convert-ill-defined-log2-to-ilog2 
drivers/char/agp/i460-agp.c
--- a/drivers/char/agp/i460-agp.c~convert-ill-defined-log2-to-ilog2
+++ a/drivers/char/agp/i460-agp.c
@@ -13,6 +13,7 @@
 #include linux/string.h
 #include linux/slab.h
 #include linux/agp_backend.h
+#include linux/log2.h
 
 #include agp.h
 
@@ -59,8 +60,6 @@
  */
 #define WR_FLUSH_GATT(index)   RD_GATT(index)
 
-#define log2(x)ffz(~(x))
-
 static struct {
void *gatt; /* ioremap'd GATT area */
 
@@ -148,7 +147,7 @@ static int i460_fetch_size (void)
 * values[i].size.
 */
values[i].num_entries = (values[i].size  8)  
(I460_IO_PAGE_SHIFT - 12);
-   values[i].page_order = log2((sizeof(u32)*values[i].num_entries) 
 PAGE_SHIFT);
+   values[i].page_order = 
ilog2((sizeof(u32)*values[i].num_entries)  PAGE_SHIFT);
}
 
for (i = 0; i  agp_bridge-driver-num_aperture_sizes; i++) {
diff -puN drivers/char/agp/parisc-agp.c~convert-ill-defined-log2-to-ilog2 
drivers/char/agp/parisc-agp.c
--- a/drivers/char/agp/parisc-agp.c~convert-ill-defined-log2-to-ilog2
+++ a/drivers/char/agp/parisc-agp.c
@@ -18,6 +18,7 @@
 #include linux/init.h
 #include linux/klist.h
 #include linux/agp_backend.h
+#include linux/log2.h
 
 #include asm-parisc/parisc-device.h
 #include asm-parisc/ropes.h
@@ -27,10 +28,6 @@
 #define DRVNAMEquicksilver
 #define DRVPFX DRVNAME : 
 
-#ifndef log2
-#define log2(x)ffz(~(x))
-#endif
-
 #define AGP8X_MODE_BIT 3
 #define AGP8X_MODE (1  AGP8X_MODE_BIT)
 
@@ -92,7 +89,7 @@ parisc_agp_tlbflush(struct agp_memory *m
 {
struct _parisc_agp_info *info = parisc_agp_info;
 
-   writeq(info-gart_base | log2(info-gart_size), 
info-ioc_regs+IOC_PCOM);
+   writeq(info-gart_base | ilog2(info-gart_size), 
info-ioc_regs+IOC_PCOM);
readq(info-ioc_regs+IOC_PCOM); /* flush */
 }
 
diff -puN fs/ext4/super.c~convert-ill-defined-log2-to-ilog2 fs/ext4/super.c
--- a/fs/ext4/super.c~convert-ill-defined-log2-to-ilog2
+++ a/fs/ext4/super.c
@@ -1415,8 +1415,6 @@ static void ext4_orphan_cleanup (struct 
sb-s_flags = s_flags; /* Restore MS_RDONLY status */
 }
 
-#define log2(n) ffz(~(n))
-
 /*
  * Maximal file size.  There is a direct, and {,double-,triple-}indirect
  * block limit, and also a limit of (2^32 - 1) 512-byte sectors in i_blocks.
@@ -1689,8 +1687,8 @@ static int ext4_fill_super (struct super
sbi-s_desc_per_block = blocksize / EXT4_DESC_SIZE(sb);
sbi-s_sbh = bh;
sbi-s_mount_state = le16_to_cpu(es-s_state);
-   sbi-s_addr_per_block_bits = 

- convert-ill-defined-log2-to-ilog2.patch removed from -mm tree

2007-10-17 Thread akpm

The patch titled
 convert ill defined log2() to ilog2()
has been removed from the -mm tree.  Its filename was
 convert-ill-defined-log2-to-ilog2.patch

This patch was dropped because it is obsolete

--
Subject: convert ill defined log2() to ilog2()
From: Fengguang Wu [EMAIL PROTECTED]

It's *wrong* to have
#define log2(n) ffz(~(n))
It should be *reversed*:
#define log2(n) flz(~(n))
or
#define log2(n) fls(n)
or just use
ilog2(n) defined in linux/log2.h.

This patch follows the last solution, recommended by Andrew Morton.

Cc: linux-ext4@vger.kernel.org
Cc: Mingming Cao [EMAIL PROTECTED]
Cc: Bjorn Helgaas [EMAIL PROTECTED]
Cc: Chris Ahna [EMAIL PROTECTED]
Cc: David Mosberger-Tang [EMAIL PROTECTED]
Cc: Kyle McMartin [EMAIL PROTECTED]
Cc: Dave Airlie [EMAIL PROTECTED]
Cc: Dave Jones [EMAIL PROTECTED]
Signed-off-by: Fengguang Wu [EMAIL PROTECTED]
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
---

 drivers/char/agp/hp-agp.c |9 +++--
 drivers/char/agp/i460-agp.c   |5 ++---
 drivers/char/agp/parisc-agp.c |7 ++-
 fs/ext4/super.c   |6 ++
 4 files changed, 9 insertions(+), 18 deletions(-)

diff -puN drivers/char/agp/hp-agp.c~convert-ill-defined-log2-to-ilog2 
drivers/char/agp/hp-agp.c
--- a/drivers/char/agp/hp-agp.c~convert-ill-defined-log2-to-ilog2
+++ a/drivers/char/agp/hp-agp.c
@@ -14,15 +14,12 @@
 #include linux/pci.h
 #include linux/init.h
 #include linux/agp_backend.h
+#include linux/log2.h
 
 #include asm/acpi-ext.h
 
 #include agp.h
 
-#ifndef log2
-#define log2(x)ffz(~(x))
-#endif
-
 #define HP_ZX1_IOC_OFFSET  0x1000  /* ACPI reports SBA, we want IOC */
 
 /* HP ZX1 IOC registers */
@@ -257,7 +254,7 @@ hp_zx1_configure (void)
readl(hp-ioc_regs+HP_ZX1_IMASK);
writel(hp-iova_base|1, hp-ioc_regs+HP_ZX1_IBASE);
readl(hp-ioc_regs+HP_ZX1_IBASE);
-   writel(hp-iova_base|log2(HP_ZX1_IOVA_SIZE), 
hp-ioc_regs+HP_ZX1_PCOM);
+   writel(hp-iova_base|ilog2(HP_ZX1_IOVA_SIZE), 
hp-ioc_regs+HP_ZX1_PCOM);
readl(hp-ioc_regs+HP_ZX1_PCOM);
}
 
@@ -285,7 +282,7 @@ hp_zx1_tlbflush (struct agp_memory *mem)
 {
struct _hp_private *hp = hp_private;
 
-   writeq(hp-gart_base | log2(hp-gart_size), hp-ioc_regs+HP_ZX1_PCOM);
+   writeq(hp-gart_base | ilog2(hp-gart_size), hp-ioc_regs+HP_ZX1_PCOM);
readq(hp-ioc_regs+HP_ZX1_PCOM);
 }
 
diff -puN drivers/char/agp/i460-agp.c~convert-ill-defined-log2-to-ilog2 
drivers/char/agp/i460-agp.c
--- a/drivers/char/agp/i460-agp.c~convert-ill-defined-log2-to-ilog2
+++ a/drivers/char/agp/i460-agp.c
@@ -13,6 +13,7 @@
 #include linux/string.h
 #include linux/slab.h
 #include linux/agp_backend.h
+#include linux/log2.h
 
 #include agp.h
 
@@ -59,8 +60,6 @@
  */
 #define WR_FLUSH_GATT(index)   RD_GATT(index)
 
-#define log2(x)ffz(~(x))
-
 static struct {
void *gatt; /* ioremap'd GATT area */
 
@@ -148,7 +147,7 @@ static int i460_fetch_size (void)
 * values[i].size.
 */
values[i].num_entries = (values[i].size  8)  
(I460_IO_PAGE_SHIFT - 12);
-   values[i].page_order = log2((sizeof(u32)*values[i].num_entries) 
 PAGE_SHIFT);
+   values[i].page_order = 
ilog2((sizeof(u32)*values[i].num_entries)  PAGE_SHIFT);
}
 
for (i = 0; i  agp_bridge-driver-num_aperture_sizes; i++) {
diff -puN drivers/char/agp/parisc-agp.c~convert-ill-defined-log2-to-ilog2 
drivers/char/agp/parisc-agp.c
--- a/drivers/char/agp/parisc-agp.c~convert-ill-defined-log2-to-ilog2
+++ a/drivers/char/agp/parisc-agp.c
@@ -18,6 +18,7 @@
 #include linux/init.h
 #include linux/klist.h
 #include linux/agp_backend.h
+#include linux/log2.h
 
 #include asm-parisc/parisc-device.h
 #include asm-parisc/ropes.h
@@ -27,10 +28,6 @@
 #define DRVNAMEquicksilver
 #define DRVPFX DRVNAME : 
 
-#ifndef log2
-#define log2(x)ffz(~(x))
-#endif
-
 #define AGP8X_MODE_BIT 3
 #define AGP8X_MODE (1  AGP8X_MODE_BIT)
 
@@ -92,7 +89,7 @@ parisc_agp_tlbflush(struct agp_memory *m
 {
struct _parisc_agp_info *info = parisc_agp_info;
 
-   writeq(info-gart_base | log2(info-gart_size), 
info-ioc_regs+IOC_PCOM);
+   writeq(info-gart_base | ilog2(info-gart_size), 
info-ioc_regs+IOC_PCOM);
readq(info-ioc_regs+IOC_PCOM); /* flush */
 }
 
diff -puN fs/ext4/super.c~convert-ill-defined-log2-to-ilog2 fs/ext4/super.c
--- a/fs/ext4/super.c~convert-ill-defined-log2-to-ilog2
+++ a/fs/ext4/super.c
@@ -1415,8 +1415,6 @@ static void ext4_orphan_cleanup (struct 
sb-s_flags = s_flags; /* Restore MS_RDONLY status */
 }
 
-#define log2(n) ffz(~(n))
-
 /*
  * Maximal file size.  There is a direct, and {,double-,triple-}indirect
  * block limit, and also 

Re: [PATCH 0/8][e2fsprogs] 64-bit block number support - first part

2007-10-17 Thread Valerie Clement

Theodore Tso wrote:

It's good to clean this up, but this presumes that blk_t is going to
change to a 64-bit type.  I'd much rather *add* a blk64_t, and keep
blk_t at 32 bits.  This patch series in a number of places makes the
presumption that blk_t will change size --- in particular when it
creates new interfaces that returns 64-bits through a blk_t.  Please
don't do that.


Does it mean that we'll have to duplicate all of the structures
containing fields of type blk_t (like process_block_struct,
e2fsck_struct, ext2_inode_cache, ...) and also duplicate most of
the code for the functions which use variables of type blk_t?

  Valérie
-
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


Re: [PATCH 0/8][e2fsprogs] 64-bit block number support - first part

2007-10-17 Thread Theodore Tso
On Wed, Oct 17, 2007 at 04:13:50PM +0200, Valerie Clement wrote:
 Theodore Tso wrote:
 It's good to clean this up, but this presumes that blk_t is going to
 change to a 64-bit type.  I'd much rather *add* a blk64_t, and keep
 blk_t at 32 bits.  This patch series in a number of places makes the
 presumption that blk_t will change size --- in particular when it
 creates new interfaces that returns 64-bits through a blk_t.  Please
 don't do that.

 Does it mean that we'll have to duplicate all of the structures
 containing fields of type blk_t (like process_block_struct,
 e2fsck_struct, ext2_inode_cache, ...) and also duplicate most of
 the code for the functions which use variables of type blk_t?

process_block_struct and e2fsck_struct are e2fsck specific structures,
so they don't have to be duplicated; the concern is libext2fs ABI
compatibility.

As far as ext2_inode_cache, you will note that the structure is
defined in ext2fsP.h, so it's not visible to outside callers.  The
ext2fsP.h file was created specifically to allow internal
implementation changes without breaking the ABI, because structures in
ext2fsP.h aren't part of the published interface.

If there are functions where we can show that none of the users of
libext2fs library are calling it, by surveying all known apps that
link against libext2fs (both in e2fsprogs and external to e2fsprogs),
then there is another alternative.  If we know that it's most likely
only being used as an internal helper functions by libext2fs, and the
only reason it wasn't declared static was because it was being used
from another .c file, we could use a linker script to hide the
internal functions using ELF symbol versions, so that applications
would never see those functions.  It won't work for the static
library, so it's not full proof, but if we at the same time use a
function prefix like ext2fs__ with two underscores, it'll probably be
good enough.  This would be the equivalent of removing a function from
the library (as far as outside callers are concerned), so we would
have to do our own due diligence before we could proceed, but it would
be possible.

- Ted
-
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


Re: [GIT PULL] ext4 update

2007-10-17 Thread Linus Torvalds


On Wed, 17 Oct 2007, Theodore Ts'o wrote:
 
 Please pull from:
 
 git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git for_linus

This conflicts in nontrivial ways with

commit 7c9e69faa28027913ee059c285a5ea8382e24b5d
Author: Aneesh Kumar K.V [EMAIL PROTECTED]
Date:   Tue Oct 16 23:27:02 2007 -0700

ext2/ext3/ext4: add block bitmap validation

which I just merged from -mm.

I suspect it's trivial to fix up for somebody who knows/understands the 
code, but I'm not that person, and I cannot verify the end result.

So can you please do the merge, and I'll pull the merged tree?

Linus
-
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


Re: [GIT PULL] ext4 update

2007-10-17 Thread Theodore Tso
On Wed, Oct 17, 2007 at 08:59:53AM -0700, Linus Torvalds wrote:
  Please pull from:
  
  git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git 
  for_linus
 
 This conflicts in nontrivial ways with
 
 which I just merged from -mm.
 
 I suspect it's trivial to fix up for somebody who knows/understands the 
 code, but I'm not that person, and I cannot verify the end result.
 
 So can you please do the merge, and I'll pull the merged tree?
 

OK, I've rebased and fixed up the patches with your latest git tree.

Could you please pull from:

git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git for_linus

now?   Thanks!!

- Ted
-
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


+ ext3-fix-setup_new_group_blocks-locking.patch added to -mm tree

2007-10-17 Thread akpm

The patch titled
 ext3: fix setup_new_group_blocks locking
has been added to the -mm tree.  Its filename is
 ext3-fix-setup_new_group_blocks-locking.patch

*** Remember to use Documentation/SubmitChecklist when testing your code ***

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

--
Subject: ext3: fix setup_new_group_blocks locking
From: Eric Sandeen [EMAIL PROTECTED]

setup_new_group_blocks() manipulates the group descriptor block bh under
the block_bitmap bh's lock.  It shouldn't matter since nobody but resize
should be touching these blocks, but it's worth fixing up.

Signed-off-by: Eric Sandeen [EMAIL PROTECTED]
C: linux-ext4@vger.kernel.org
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
---

 fs/ext3/resize.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff -puN fs/ext3/resize.c~ext3-fix-setup_new_group_blocks-locking 
fs/ext3/resize.c
--- a/fs/ext3/resize.c~ext3-fix-setup_new_group_blocks-locking
+++ a/fs/ext3/resize.c
@@ -245,10 +245,10 @@ static int setup_new_group_blocks(struct
brelse(gdb);
goto exit_bh;
}
-   lock_buffer(bh);
-   memcpy(gdb-b_data, sbi-s_group_desc[i]-b_data, bh-b_size);
+   lock_buffer(gdb);
+   memcpy(gdb-b_data, sbi-s_group_desc[i]-b_data, gdb-b_size);
set_buffer_uptodate(gdb);
-   unlock_buffer(bh);
+   unlock_buffer(gdb);
ext3_journal_dirty_metadata(handle, gdb);
ext3_set_bit(bit, bh-b_data);
brelse(gdb);
_

Patches currently in -mm which might be from [EMAIL PROTECTED] are

remove-unused-bh-in-calls-to-ext234_get_group_desc.patch
limit-minixfs-printks-on-corrupted-dir-i_size.patch
ext3-remove-ifdef-config_ext3_index.patch
ext3-lighten-up-resize-transaction-requirements.patch
ext4-remove-ifdef-config_ext4_index.patch
ext3-fix-setup_new_group_blocks-locking.patch

-
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


Re: [PATCH] ext2 statfs improvement for block and inode free count

2007-10-17 Thread Andreas Dilger
On Oct 16, 2007  15:00 -0700, Andrew Morton wrote:
 On Fri, 13 Jul 2007 18:36:54 -0700
 Badari Pulavarty [EMAIL PROTECTED] wrote:
  @@ -1136,12 +1136,12 @@ static int ext2_statfs (struct dentry * 
  buf-f_type = EXT2_SUPER_MAGIC;
  buf-f_bsize = sb-s_blocksize;
  buf-f_blocks = le32_to_cpu(es-s_blocks_count) - overhead;
  -   buf-f_bfree = ext2_count_free_blocks(sb);
  +   buf-f_bfree = percpu_counter_sum(sbi-s_freeblocks_counter);
  buf-f_bavail = buf-f_bfree - le32_to_cpu(es-s_r_blocks_count);
  if (buf-f_bfree  le32_to_cpu(es-s_r_blocks_count))
  buf-f_bavail = 0;
  buf-f_files = le32_to_cpu(es-s_inodes_count);
  -   buf-f_ffree = ext2_count_free_inodes(sb);
  +   buf-f_ffree = percpu_counter_sum(sbi-s_freeinodes_counter);
  buf-f_namelen = EXT2_NAME_LEN;
  fsid = le64_to_cpup((void *)es-s_uuid) ^
 le64_to_cpup((void *)es-s_uuid + sizeof(u64));
  
 
 Guys, I have this patch in a stalled state pending some convincing
 demonstration/argument that it's actually a worthwhile change.

Is it just this part of the change, or the whole overhead calculation?
It looks like this is also missing the overhead_last part of the change?
The filesystem overhead is static outside of fs resize and there is no
point in recalculating it.  In fact there was a cond_resched() added in
there expressly because it was causing hiccups in the low-latency tests,
so it is a non-trivial CPU user.

 How much hurt will it cause on large-numa, and how much benefit do we get
 for that hurt? 

To be honest, I suspect the tradeoff depends on the size of the filesystem
and the number of CPUs.  It might not make sense for ext2, but it likely
does for ext4.  If you consider that ext2_count_free_*() will walk all
of the block group descriptors (1 per 128MB on a 4kB filesystem, 1 per
8MB on a 1kB filesystem) and look at average filesystem sizes these days
(80GB let's say for small ones, 8TB for big ones) that means 640 loops
for an average fs, 64k loops for a big fs.

We might also consider using percpu_counter_read() and ensure the value
is = 0, since these values do not have to be exact.  We can't use
percpu_counter_read_positive() since it will return 1 block free if the
percpu value is negative.

Using just percpu_counter_read() means we are inaccurate by at most
(+/-)NR_CPUS * num_online_cpus * 2 blocks, but on average this will be
0 blocks.

What's also missing from these patches somehow (was in the original patch
I sent) is the update of the superblock fields.

buf-f_bsize = sb-s_blocksize;
buf-f_blocks = le32_to_cpu(es-s_blocks_count) - sbi-s_overhead_last;
buf-f_bfree = ext3_count_free_blocks (sb);
+   es-s_free_blocks_count = cpu_to_le32(buf-f_bfree);
buf-f_bavail = buf-f_bfree - le32_to_cpu(es-s_r_blocks_count);
if (buf-f_bfree  le32_to_cpu(es-s_r_blocks_count))
buf-f_bavail = 0;
buf-f_files = le32_to_cpu(es-s_inodes_count);
buf-f_ffree = ext3_count_free_inodes (sb);
+   es-s_free_inodes_count = cpu_to_le32(buf-f_ffree);
buf-f_namelen = EXT3_NAME_LEN;
return 0;

Without this, e2fsck will report spurious when doing a read-only check,
even if the fs is idle:

Pass 5: Checking group summary information
Free blocks count wrong (83302, counted=83276).
Fix? no

Free inodes count wrong (99987, counted=99972).

Yes, I know you aren't guaranteed consistency on a read-only e2fsck, but
we should at least allow the problem to be addressed if it is easy.


Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.

-
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


Re: ext3 warnings from LTP rename14

2007-10-17 Thread Martin Habets
Hi,

On Tue, Oct 16, 2007 at 08:20:59PM -0500, Eric Sandeen wrote:
 Martin Habets wrote:
  Hello,
  
  I ran the ltp-full-20070930 tests on 2.6.23-rc9-mph4 (sparc32 SMP), and am
  seeing the following warnings:
 
 This makes me a little nervous about my change
 ef2b02d3e617cb0400eedf2668f86215e1b0e6af
 (ext34: ensure do_split leaves enough free space in both blocks)
 
 Do you know when this first showed up?  Could you test -rc6?

Thanks for the input.
Tried this on -rc6, it behaves worse. Besides the earlier warnings
  EXT3-fs warning (device sdb4): ext3_rename: Deleting old file (268753), 2, 
error=-2
I also get a lot of these
  EXT3-fs error (device sdb4): ext3_add_entry: bad entry in directory #268753: 
rec_len is smaller than minimal - offset=56, inode=8026488, rec_len=0, 
name_len=0
and these at the end of the test:
  EXT3-fs warning (device sdb4): ext3_unlink: Deleting nonexistent file 
(268761), 0
  EXT3-fs error (device sdb4): ext3_readdir: bad entry in directory #268753: 
rec_len is smaller than minimal - offset=56, inode=8026488, rec_len=0, 
name_len=0
  EXT3-fs error (device sdb4): empty_dir: bad entry in directory #268753: 
rec_len is smaller than minimal - offset=56, inode=8026488, rec_len=0, 
name_len=0

The FS is still mounted rw.

 You say you can reproduce it; have you checked (fsck'd) the filesystem
 in between, and is it in good shape?

Like you, I rerun rename14 stand-alone at the moment.
I didnt do an explicit fschk between all runs, but I also did 2 reboots
which did check the FS.

I'll try to bisect the original ext3_rename warning further.
-- 
Martin
-
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


Re: [PATCH 2/2] ext2: Avoid rec_len overflow with 64KB block size

2007-10-17 Thread Andrew Morton
On Thu, 11 Oct 2007 13:18:49 +0200 Jan Kara [EMAIL PROTECTED] wrote:

 +static inline __le16 ext2_rec_len_to_disk(unsigned len)
 +{
 + if (len == (1  16))
 + return cpu_to_le16(EXT2_MAX_REC_LEN);
 + else if (len  (1  16))
 + BUG();
 + return cpu_to_le16(len);
 +}

Of course, ext2 shouldn't be trying to write a bad record length into a
directory entry.  But are we sure that there is no way in which this
situation could occur is the on-disk data was _already_ bad?

Because it is very bad for a fileysstem to go BUG in response to unexpected
data on the disk.

-
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


Re: [PATCH 2/2] ext2: Avoid rec_len overflow with 64KB block size

2007-10-17 Thread Andrew Morton
On Thu, 11 Oct 2007 13:18:49 +0200 Jan Kara [EMAIL PROTECTED] wrote:

 With 64KB blocksize, a directory entry can have size 64KB which does not fit
 into 16 bits we have for entry lenght. So we store 0x instead and convert
 value when read from / written to disk.

btw, this changes ext2's on-disk format.

a) is the ext2 format documented anywhere?  If so, that document will
   need updating.

b) what happens when an old ext2 driver tries to read and/or write this
   directory entry?  Do we need a compat flag for it?

c) what happens when old and new ext3 or ext4 try to read/write this
   directory entry?


-
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


+ ext2-avoid-rec_len-overflow-with-64kb-block-size.patch added to -mm tree

2007-10-17 Thread akpm

The patch titled
 ext2: avoid rec_len overflow with 64KB block size
has been added to the -mm tree.  Its filename is
 ext2-avoid-rec_len-overflow-with-64kb-block-size.patch

*** Remember to use Documentation/SubmitChecklist when testing your code ***

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

--
Subject: ext2: avoid rec_len overflow with 64KB block size
From: Jan Kara [EMAIL PROTECTED]

With 64KB blocksize, a directory entry can have size 64KB which does not
fit into 16 bits we have for entry length.  So we store 0x instead and
convert the value when read from / written to disk.

Signed-off-by: Jan Kara [EMAIL PROTECTED]
Cc: linux-ext4@vger.kernel.org
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
---

 fs/ext2/dir.c   |   44 +++---
 include/linux/ext2_fs.h |1 
 2 files changed, 33 insertions(+), 12 deletions(-)

diff -puN fs/ext2/dir.c~ext2-avoid-rec_len-overflow-with-64kb-block-size 
fs/ext2/dir.c
--- a/fs/ext2/dir.c~ext2-avoid-rec_len-overflow-with-64kb-block-size
+++ a/fs/ext2/dir.c
@@ -28,6 +28,24 @@
 
 typedef struct ext2_dir_entry_2 ext2_dirent;
 
+static inline unsigned ext2_rec_len_from_disk(__le16 dlen)
+{
+   unsigned len = le16_to_cpu(dlen);
+
+   if (len == EXT2_MAX_REC_LEN)
+   return 1  16;
+   return len;
+}
+
+static inline __le16 ext2_rec_len_to_disk(unsigned len)
+{
+   if (len == (1  16))
+   return cpu_to_le16(EXT2_MAX_REC_LEN);
+   else if (len  (1  16))
+   BUG();
+   return cpu_to_le16(len);
+}
+
 /*
  * ext2 uses block-sized chunks. Arguably, sector-sized ones would be
  * more robust, but we have what we have
@@ -106,7 +124,7 @@ static void ext2_check_page(struct page 
}
for (offs = 0; offs = limit - EXT2_DIR_REC_LEN(1); offs += rec_len) {
p = (ext2_dirent *)(kaddr + offs);
-   rec_len = le16_to_cpu(p-rec_len);
+   rec_len = ext2_rec_len_from_disk(p-rec_len);
 
if (rec_len  EXT2_DIR_REC_LEN(1))
goto Eshort;
@@ -204,7 +222,8 @@ static inline int ext2_match (int len, c
  */
 static inline ext2_dirent *ext2_next_entry(ext2_dirent *p)
 {
-   return (ext2_dirent *)((char*)p + le16_to_cpu(p-rec_len));
+   return (ext2_dirent *)((char*)p +
+   ext2_rec_len_from_disk(p-rec_len));
 }
 
 static inline unsigned 
@@ -316,7 +335,7 @@ ext2_readdir (struct file * filp, void *
return 0;
}
}
-   filp-f_pos += le16_to_cpu(de-rec_len);
+   filp-f_pos += ext2_rec_len_from_disk(de-rec_len);
}
ext2_put_page(page);
}
@@ -425,7 +444,7 @@ void ext2_set_link(struct inode *dir, st
 {
loff_t pos = page_offset(page) +
(char *) de - (char *) page_address(page);
-   unsigned len = le16_to_cpu(de-rec_len);
+   unsigned len = ext2_rec_len_from_disk(de-rec_len);
int err;
 
lock_page(page);
@@ -482,7 +501,7 @@ int ext2_add_link (struct dentry *dentry
/* We hit i_size */
name_len = 0;
rec_len = chunk_size;
-   de-rec_len = cpu_to_le16(chunk_size);
+   de-rec_len = ext2_rec_len_to_disk(chunk_size);
de-inode = 0;
goto got_it;
}
@@ -496,7 +515,7 @@ int ext2_add_link (struct dentry *dentry
if (ext2_match (namelen, name, de))
goto out_unlock;
name_len = EXT2_DIR_REC_LEN(de-name_len);
-   rec_len = le16_to_cpu(de-rec_len);
+   rec_len = ext2_rec_len_from_disk(de-rec_len);
if (!de-inode  rec_len = reclen)
goto got_it;
if (rec_len = name_len + reclen)
@@ -518,8 +537,8 @@ got_it:
goto out_unlock;
if (de-inode) {
ext2_dirent *de1 = (ext2_dirent *) ((char *) de + name_len);
-   de1-rec_len = cpu_to_le16(rec_len - name_len);
-   de-rec_len = cpu_to_le16(name_len);
+   de1-rec_len = ext2_rec_len_to_disk(rec_len - name_len);
+   de-rec_len = ext2_rec_len_to_disk(name_len);
de = de1;
}
de-name_len = namelen;
@@ -550,7 +569,8 @@ int ext2_delete_entry (struct ext2_dir_e
struct inode *inode = mapping-host;
char *kaddr = page_address(page);
unsigned from = ((char*)dir - kaddr)  ~(ext2_chunk_size(inode)-1);
-   unsigned to = ((char*)dir - kaddr) + le16_to_cpu(dir-rec_len);
+