Re: [PATCH] Copy i_flags to ext3 inode flags on write (version 2)
On Tue, 2007-04-24 at 17:35 +0200, Jan Kara wrote: On Tue 24-04-07 10:14:37, Dave Kleikamp wrote: I think you need a call to ext3_get_inode_flags in one more place. In ext3_ioctl(), EXT3_IOC_SETFLAGS modifies the flags based on what is in ei-i_flags, so this code should make sure that ei-i_flags is in sync with inode-i_flags. Hmm, I don't think so. The code does: flags = flags EXT3_FL_USER_MODIFIABLE; flags |= oldflags ~EXT3_FL_USER_MODIFIABLE; ei-i_flags = flags; So all EXT3_FL_USER_MODIFIABLE are overwritten by what user has supplied, which happens to be a superset of flags influenced by ext3_get_inode_flags(). On the other hand, from some point of view, after your change the code is safer (in case we add some new unmodifiable flags) so I don't object against adding the call. I just wanted to point out, that currently there's no difference... Okay. I see that that's the case. I was thinking that individual flags could be set through the ioctl, but it takes the whole set. I don't really see the need to keep my patch from a safety perspective, but do what you want. Thanks, Shaggy -- David Kleikamp IBM Linux Technology Center - 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] Copy i_flags to ext3 inode flags on write (version 2)
On Tue, 17 Apr 2007 12:38:55 +0200 Jan Kara [EMAIL PROTECTED] wrote: attached is a second version of a patch that stores inode flags such as S_IMMUTABLE, S_APPEND, etc. from i_flags to EXT3_I(inode)-i_flags when inode is written to disk. The same thing is done on GETFLAGS ioctl. Quota code changes these flags on quota files (to make it harder for sysadmin to screw himself) and these changes were not correctly propagated into the filesystem (especially, lsattr did not show them and users were wondering...). Andrew, could you please put the patch into your queue? Thanks. umm, OK. What about ext2 and all the zillions of others? - 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] Copy i_flags to ext3 inode flags on write
On Mon 16-04-07 12:14:21, Andreas Dilger wrote: On Apr 16, 2007 19:05 +0200, Jan Kara wrote: attached is a patch that stores inode flags such as S_IMMUTABLE, S_APPEND, etc. from i_flags to EXT3_I(inode)-i_flags when inode is written to disk. The same thing is done on GETFLAGS ioctl. Quota code changes these flags on quota files (to make it harder for sysadmin to screw himself) and these changes were not correctly propagated into the filesystem (especially, lsattr did not show them and users were wondering...). +/* Propagate flags from i_flags to EXT3_I(inode)-i_flags */ +void ext3_get_inode_flags(struct inode *inode) +{ + unsigned int flags = inode-i_flags; + + EXT3_I(inode)-i_flags = ~(EXT3_SYNC_FL|EXT3_APPEND_FL| + EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL); + if (flags S_SYNC) + EXT3_I(inode)-i_flags |= EXT3_SYNC_FL; + if (flags S_APPEND) + EXT3_I(inode)-i_flags |= EXT3_APPEND_FL; + if (flags S_IMMUTABLE) + EXT3_I(inode)-i_flags |= EXT3_IMMUTABLE_FL; + if (flags S_NOATIME) + EXT3_I(inode)-i_flags |= EXT3_NOATIME_FL; + if (flags S_DIRSYNC) + EXT3_I(inode)-i_flags |= EXT3_DIRSYNC_FL; +} It probably makes sense to pass struct ext3_inode_info *ei to this function, which is available at both callsites and avoids some pointer math for each access. OK, makes sence. Will resend the patch in a while. void ext3_read_inode(struct inode * inode) { struct ext3_iloc iloc; @@ -2736,6 +2755,7 @@ static int ext3_do_update_inode(handle_t if (ei-i_state EXT3_STATE_NEW) memset(raw_inode, 0, EXT3_SB(inode-i_sb)-s_inode_size); + ext3_get_inode_flags(inode); raw_inode-i_mode = cpu_to_le16(inode-i_mode); if(!(test_opt(inode-i_sb, NO_UID32))) { raw_inode-i_uid_low = cpu_to_le16(low_16_bits(inode-i_uid)); diff -rupX /home/jack/.kerndiffexclude linux-2.6.21-rc6/fs/ext3/ioctl.c linux-2.6.21-rc6-1-ext3_flags_update/fs/ext3/ioctl.c --- linux-2.6.21-rc6/fs/ext3/ioctl.c2007-02-07 12:03:23.0 +0100 +++ linux-2.6.21-rc6-1-ext3_flags_update/fs/ext3/ioctl.c2007-04-12 18:22:54.0 +0200 @@ -28,6 +28,7 @@ int ext3_ioctl (struct inode * inode, st switch (cmd) { case EXT3_IOC_GETFLAGS: + ext3_get_inode_flags(inode); flags = ei-i_flags EXT3_FL_USER_VISIBLE; return put_user(flags, (int __user *) arg); case EXT3_IOC_SETFLAGS: { Looks fine otherwise - there is already ext3_set_inode_flags() which sets the VFS inode flags properly in ext3_read_inode(). Yes, I know :). Honza -- Jan Kara [EMAIL PROTECTED] SuSE CR Labs - 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] Copy i_flags to ext3 inode flags on write (version 2)
Hi, attached is a second version of a patch that stores inode flags such as S_IMMUTABLE, S_APPEND, etc. from i_flags to EXT3_I(inode)-i_flags when inode is written to disk. The same thing is done on GETFLAGS ioctl. Quota code changes these flags on quota files (to make it harder for sysadmin to screw himself) and these changes were not correctly propagated into the filesystem (especially, lsattr did not show them and users were wondering...). Andrew, could you please put the patch into your queue? Thanks. Honza -- Jan Kara [EMAIL PROTECTED] SuSE CR Labs Propagate flags such as S_APPEND, S_IMMUTABLE, etc. from i_flags into ext3-specific i_flags. Hence, when someone sets these flags via a different interface than ioctl, they are stored correctly. Signed-off-by: Jan Kara [EMAIL PROTECTED] diff -rupX /home/jack/.kerndiffexclude linux-2.6.21-rc6/fs/ext3/inode.c linux-2.6.21-rc6-1-ext3_flags_update/fs/ext3/inode.c --- linux-2.6.21-rc6/fs/ext3/inode.c 2007-04-10 17:09:55.0 +0200 +++ linux-2.6.21-rc6-1-ext3_flags_update/fs/ext3/inode.c 2007-04-17 11:24:28.0 +0200 @@ -2581,6 +2581,25 @@ void ext3_set_inode_flags(struct inode * inode-i_flags |= S_DIRSYNC; } +/* Propagate flags from i_flags to EXT3_I(inode)-i_flags */ +void ext3_get_inode_flags(struct ext3_inode_info *ei) +{ + unsigned int flags = ei-vfs_inode.i_flags; + + ei-i_flags = ~(EXT3_SYNC_FL|EXT3_APPEND_FL| + EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL); + if (flags S_SYNC) + ei-i_flags |= EXT3_SYNC_FL; + if (flags S_APPEND) + ei-i_flags |= EXT3_APPEND_FL; + if (flags S_IMMUTABLE) + ei-i_flags |= EXT3_IMMUTABLE_FL; + if (flags S_NOATIME) + ei-i_flags |= EXT3_NOATIME_FL; + if (flags S_DIRSYNC) + ei-i_flags |= EXT3_DIRSYNC_FL; +} + void ext3_read_inode(struct inode * inode) { struct ext3_iloc iloc; @@ -2736,6 +2755,7 @@ static int ext3_do_update_inode(handle_t if (ei-i_state EXT3_STATE_NEW) memset(raw_inode, 0, EXT3_SB(inode-i_sb)-s_inode_size); + ext3_get_inode_flags(ei); raw_inode-i_mode = cpu_to_le16(inode-i_mode); if(!(test_opt(inode-i_sb, NO_UID32))) { raw_inode-i_uid_low = cpu_to_le16(low_16_bits(inode-i_uid)); diff -rupX /home/jack/.kerndiffexclude linux-2.6.21-rc6/fs/ext3/ioctl.c linux-2.6.21-rc6-1-ext3_flags_update/fs/ext3/ioctl.c --- linux-2.6.21-rc6/fs/ext3/ioctl.c 2007-02-07 12:03:23.0 +0100 +++ linux-2.6.21-rc6-1-ext3_flags_update/fs/ext3/ioctl.c 2007-04-17 11:24:39.0 +0200 @@ -28,6 +28,7 @@ int ext3_ioctl (struct inode * inode, st switch (cmd) { case EXT3_IOC_GETFLAGS: + ext3_get_inode_flags(ei); flags = ei-i_flags EXT3_FL_USER_VISIBLE; return put_user(flags, (int __user *) arg); case EXT3_IOC_SETFLAGS: { diff -rupX /home/jack/.kerndiffexclude linux-2.6.21-rc6/include/linux/ext3_fs.h linux-2.6.21-rc6-1-ext3_flags_update/include/linux/ext3_fs.h --- linux-2.6.21-rc6/include/linux/ext3_fs.h 2007-04-10 17:09:58.0 +0200 +++ linux-2.6.21-rc6-1-ext3_flags_update/include/linux/ext3_fs.h 2007-04-17 11:25:23.0 +0200 @@ -824,6 +824,7 @@ extern int ext3_change_inode_journal_fla extern int ext3_get_inode_loc(struct inode *, struct ext3_iloc *); extern void ext3_truncate (struct inode *); extern void ext3_set_inode_flags(struct inode *); +extern void ext3_get_inode_flags(struct ext3_inode_info *); extern void ext3_set_aops(struct inode *inode); /* ioctl.c */
[PATCH] Copy i_flags to ext3 inode flags on write
Hello, attached is a patch that stores inode flags such as S_IMMUTABLE, S_APPEND, etc. from i_flags to EXT3_I(inode)-i_flags when inode is written to disk. The same thing is done on GETFLAGS ioctl. Quota code changes these flags on quota files (to make it harder for sysadmin to screw himself) and these changes were not correctly propagated into the filesystem (especially, lsattr did not show them and users were wondering...). If people agree that this patch is fine, I can also rediff it for ext4. Honza -- Jan Kara [EMAIL PROTECTED] SuSE CR Labs Propagate flags such as S_APPEND, S_IMMUTABLE, etc. from i_flags into ext3-specific i_flags. Hence, when someone sets these flags via a different interface than ioctl, they are stored correctly. Signed-off-by: Jan Kara [EMAIL PROTECTED] diff -rupX /home/jack/.kerndiffexclude linux-2.6.21-rc6/fs/ext3/inode.c linux-2.6.21-rc6-1-ext3_flags_update/fs/ext3/inode.c --- linux-2.6.21-rc6/fs/ext3/inode.c2007-04-10 17:09:55.0 +0200 +++ linux-2.6.21-rc6-1-ext3_flags_update/fs/ext3/inode.c2007-04-12 18:19:29.0 +0200 @@ -2581,6 +2581,25 @@ void ext3_set_inode_flags(struct inode * inode-i_flags |= S_DIRSYNC; } +/* Propagate flags from i_flags to EXT3_I(inode)-i_flags */ +void ext3_get_inode_flags(struct inode *inode) +{ + unsigned int flags = inode-i_flags; + + EXT3_I(inode)-i_flags = ~(EXT3_SYNC_FL|EXT3_APPEND_FL| + EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL); + if (flags S_SYNC) + EXT3_I(inode)-i_flags |= EXT3_SYNC_FL; + if (flags S_APPEND) + EXT3_I(inode)-i_flags |= EXT3_APPEND_FL; + if (flags S_IMMUTABLE) + EXT3_I(inode)-i_flags |= EXT3_IMMUTABLE_FL; + if (flags S_NOATIME) + EXT3_I(inode)-i_flags |= EXT3_NOATIME_FL; + if (flags S_DIRSYNC) + EXT3_I(inode)-i_flags |= EXT3_DIRSYNC_FL; +} + void ext3_read_inode(struct inode * inode) { struct ext3_iloc iloc; @@ -2736,6 +2755,7 @@ static int ext3_do_update_inode(handle_t if (ei-i_state EXT3_STATE_NEW) memset(raw_inode, 0, EXT3_SB(inode-i_sb)-s_inode_size); + ext3_get_inode_flags(inode); raw_inode-i_mode = cpu_to_le16(inode-i_mode); if(!(test_opt(inode-i_sb, NO_UID32))) { raw_inode-i_uid_low = cpu_to_le16(low_16_bits(inode-i_uid)); diff -rupX /home/jack/.kerndiffexclude linux-2.6.21-rc6/fs/ext3/ioctl.c linux-2.6.21-rc6-1-ext3_flags_update/fs/ext3/ioctl.c --- linux-2.6.21-rc6/fs/ext3/ioctl.c2007-02-07 12:03:23.0 +0100 +++ linux-2.6.21-rc6-1-ext3_flags_update/fs/ext3/ioctl.c2007-04-12 18:22:54.0 +0200 @@ -28,6 +28,7 @@ int ext3_ioctl (struct inode * inode, st switch (cmd) { case EXT3_IOC_GETFLAGS: + ext3_get_inode_flags(inode); flags = ei-i_flags EXT3_FL_USER_VISIBLE; return put_user(flags, (int __user *) arg); case EXT3_IOC_SETFLAGS: {
Re: [PATCH] Copy i_flags to ext3 inode flags on write
On Apr 16, 2007 19:05 +0200, Jan Kara wrote: attached is a patch that stores inode flags such as S_IMMUTABLE, S_APPEND, etc. from i_flags to EXT3_I(inode)-i_flags when inode is written to disk. The same thing is done on GETFLAGS ioctl. Quota code changes these flags on quota files (to make it harder for sysadmin to screw himself) and these changes were not correctly propagated into the filesystem (especially, lsattr did not show them and users were wondering...). +/* Propagate flags from i_flags to EXT3_I(inode)-i_flags */ +void ext3_get_inode_flags(struct inode *inode) +{ + unsigned int flags = inode-i_flags; + + EXT3_I(inode)-i_flags = ~(EXT3_SYNC_FL|EXT3_APPEND_FL| + EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL); + if (flags S_SYNC) + EXT3_I(inode)-i_flags |= EXT3_SYNC_FL; + if (flags S_APPEND) + EXT3_I(inode)-i_flags |= EXT3_APPEND_FL; + if (flags S_IMMUTABLE) + EXT3_I(inode)-i_flags |= EXT3_IMMUTABLE_FL; + if (flags S_NOATIME) + EXT3_I(inode)-i_flags |= EXT3_NOATIME_FL; + if (flags S_DIRSYNC) + EXT3_I(inode)-i_flags |= EXT3_DIRSYNC_FL; +} It probably makes sense to pass struct ext3_inode_info *ei to this function, which is available at both callsites and avoids some pointer math for each access. void ext3_read_inode(struct inode * inode) { struct ext3_iloc iloc; @@ -2736,6 +2755,7 @@ static int ext3_do_update_inode(handle_t if (ei-i_state EXT3_STATE_NEW) memset(raw_inode, 0, EXT3_SB(inode-i_sb)-s_inode_size); + ext3_get_inode_flags(inode); raw_inode-i_mode = cpu_to_le16(inode-i_mode); if(!(test_opt(inode-i_sb, NO_UID32))) { raw_inode-i_uid_low = cpu_to_le16(low_16_bits(inode-i_uid)); diff -rupX /home/jack/.kerndiffexclude linux-2.6.21-rc6/fs/ext3/ioctl.c linux-2.6.21-rc6-1-ext3_flags_update/fs/ext3/ioctl.c --- linux-2.6.21-rc6/fs/ext3/ioctl.c 2007-02-07 12:03:23.0 +0100 +++ linux-2.6.21-rc6-1-ext3_flags_update/fs/ext3/ioctl.c 2007-04-12 18:22:54.0 +0200 @@ -28,6 +28,7 @@ int ext3_ioctl (struct inode * inode, st switch (cmd) { case EXT3_IOC_GETFLAGS: + ext3_get_inode_flags(inode); flags = ei-i_flags EXT3_FL_USER_VISIBLE; return put_user(flags, (int __user *) arg); case EXT3_IOC_SETFLAGS: { Looks fine otherwise - there is already ext3_set_inode_flags() which sets the VFS inode flags properly in ext3_read_inode(). 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