2008-06-04 12:53:30

by Duane Griffin

[permalink] [raw]
Subject: [PATCH 0/3] ext{2,3,4}: don't inherit inappropriate inode flags from parent

This patch series fixes the TOPDIR flag inheritance bug reported at
http://bugzilla.kernel.org/show_bug.cgi?id=9866. It also prevents inheritance
of other flags that Andreas Dilger identified as inappropriate to inherit. I'll
follow up shortly with a separate set of patches to prevent flags being set on
inappropriate node types.

Cheers,
Duane.


2008-06-04 12:53:42

by Duane Griffin

[permalink] [raw]
Subject: [PATCH 1/3] ext2: don't inherit inappropriate inode flags from parent

At present BTREE is the only flag that new ext2 inodes do NOT inherit from
their parent. In addition prevent the flags DIRTY, ECOMPR, INDEX, IMAGIC
and TOPDIR from being inherited.

Signed-off-by: Duane Griffin <[email protected]>

diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c
index f597413..a51d4ca 100644
--- a/fs/ext2/ialloc.c
+++ b/fs/ext2/ialloc.c
@@ -565,7 +565,7 @@ got:
inode->i_blocks = 0;
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
memset(ei->i_data, 0, sizeof(ei->i_data));
- ei->i_flags = EXT2_I(dir)->i_flags & ~EXT2_BTREE_FL;
+ ei->i_flags = EXT2_I(dir)->i_flags & EXT2_FL_INHERITED;
if (S_ISLNK(mode))
ei->i_flags &= ~(EXT2_IMMUTABLE_FL|EXT2_APPEND_FL);
/* dirsync is only applied to directories */
diff --git a/include/linux/ext2_fs.h b/include/linux/ext2_fs.h
index 84cec2a..6c87c8e 100644
--- a/include/linux/ext2_fs.h
+++ b/include/linux/ext2_fs.h
@@ -194,6 +194,10 @@ struct ext2_group_desc
#define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
#define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */

+/* Flags that should be inherited by new inodes from their parent. */
+#define EXT2_FL_INHERITED ~(EXT2_DIRTY_FL | EXT2_ECOMPR_FL | EXT2_BTREE_FL |\
+ EXT2_INDEX_FL | EXT2_IMAGIC_FL | EXT2_TOPDIR_FL)
+
/*
* ioctl commands
*/
--
1.5.3.7

2008-06-04 12:53:56

by Duane Griffin

[permalink] [raw]
Subject: [PATCH 2/3] ext3: don't inherit inappropriate inode flags from parent

At present INDEX is the only flag that new ext3 inodes do NOT inherit from
their parent. In addition prevent the flags DIRTY, ECOMPR, IMAGIC and
TOPDIR from being inherited.

Signed-off-by: Duane Griffin <[email protected]>

diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c
index 7712682..1d9fe3f 100644
--- a/fs/ext3/ialloc.c
+++ b/fs/ext3/ialloc.c
@@ -559,7 +559,7 @@ got:
ei->i_dir_start_lookup = 0;
ei->i_disksize = 0;

- ei->i_flags = EXT3_I(dir)->i_flags & ~EXT3_INDEX_FL;
+ ei->i_flags = EXT3_I(dir)->i_flags & EXT3_FL_INHERITED;
if (S_ISLNK(mode))
ei->i_flags &= ~(EXT3_IMMUTABLE_FL|EXT3_APPEND_FL);
/* dirsync only applies to directories */
diff --git a/include/linux/ext3_fs.h b/include/linux/ext3_fs.h
index 36c5403..4f7224a 100644
--- a/include/linux/ext3_fs.h
+++ b/include/linux/ext3_fs.h
@@ -178,6 +178,10 @@ struct ext3_group_desc
#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */

+/* Flags that should be inherited by new inodes from their parent. */
+#define EXT3_FL_INHERITED ~(EXT3_DIRTY_FL | EXT3_ECOMPR_FL | EXT3_INDEX_FL |\
+ EXT3_IMAGIC_FL | EXT3_TOPDIR_FL)
+
/*
* Inode dynamic state flags
*/
--
1.5.3.7

2008-06-04 12:54:20

by Duane Griffin

[permalink] [raw]
Subject: [PATCH 3/3] ext4: don't inherit inappropriate inode flags from parent

At present INDEX and EXTENTS are the only flagis that new ext4 inodes do
NOT inherit from their parent. In addition prevent the flags DIRTY, ECOMPR,
IMAGIC, TOPDIR and HUGE_FILE from being inherited.

Signed-off-by: Duane Griffin <[email protected]>

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 8158083..de07dc7 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -235,6 +235,11 @@ struct ext4_group_desc
#define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
#define EXT4_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */

+/* Flags that should be inherited by new inodes from their parent. */
+#define EXT4_FL_INHERITED ~(EXT4_DIRTY_FL | EXT4_ECOMPR_FL | EXT4_INDEX_FL |\
+ EXT4_IMAGIC_FL | EXT4_TOPDIR_FL |\
+ EXT4_HUGE_FILE_FL | EXT4_EXTENTS_FL)
+
/*
* Inode dynamic state flags
*/
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index c6efbab..ff25d57 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -702,7 +702,7 @@ got:
* newly created directory and file only if -o extent mount option is
* specified
*/
- ei->i_flags = EXT4_I(dir)->i_flags & ~(EXT4_INDEX_FL|EXT4_EXTENTS_FL);
+ ei->i_flags = EXT4_I(dir)->i_flags & EXT4_FL_INHERITED;
if (S_ISLNK(mode))
ei->i_flags &= ~(EXT4_IMMUTABLE_FL|EXT4_APPEND_FL);
/* dirsync only applies to directories */
--
1.5.3.7