* Fix ea-in-inode default ACL creation
@ 2005-01-20 18:22 Andreas Gruenbacher
2005-01-20 18:56 ` Valdis.Kletnieks
2005-01-21 21:36 ` Stephen C. Tweedie
0 siblings, 2 replies; 8+ messages in thread
From: Andreas Gruenbacher @ 2005-01-20 18:22 UTC (permalink / raw)
To: Andrew Morton, Linus Torvalds
Cc: Andrew Tridgell, Stephen C. Tweedie, Andreas Dilger, Alex Tomas,
linux-kernel
Hello,
here is another nastiness.
When a new inode is created, ext3_new_inode sets the EXT3_STATE_NEW
flag, which tells ext3_do_update_inode to zero out the inode before
filling in the inode's data. When a file is created in a directory with
a default acl, the new inode inherits the directory's default acl; this
generates attributes. The attributes are created before
ext3_do_update_inode is called to write out the inode. In case of
in-inode attributes, the new inode's attributes are written, and then
zeroed out again by ext3_do_update_inode. Bad thing.
Fix this by recognizing the EXT3_STATE_NEW case in
ext3_xattr_set_handle, and zeroing out the inode there already when
necessary.
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
Index: linux-2.6.11-latest/fs/ext3/xattr.c
===================================================================
--- linux-2.6.11-latest.orig/fs/ext3/xattr.c
+++ linux-2.6.11-latest/fs/ext3/xattr.c
@@ -954,6 +954,13 @@ ext3_xattr_set_handle(handle_t *handle,
error = ext3_get_inode_loc(inode, &is.iloc);
if (error)
goto cleanup;
+
+ if (EXT3_I(inode)->i_state & EXT3_STATE_NEW) {
+ struct ext3_inode *raw_inode = ext3_raw_inode(&is.iloc);
+ memset(raw_inode, 0, EXT3_SB(inode->i_sb)->s_inode_size);
+ EXT3_I(inode)->i_state &= ~EXT3_STATE_NEW;
+ }
+
error = ext3_xattr_ibody_find(inode, &i, &is);
if (error)
goto cleanup;
--
Andreas Gruenbacher <agruen@suse.de>
SUSE Labs, SUSE LINUX GMBH
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fix ea-in-inode default ACL creation
2005-01-20 18:22 Fix ea-in-inode default ACL creation Andreas Gruenbacher
@ 2005-01-20 18:56 ` Valdis.Kletnieks
2005-01-20 19:07 ` Andreas Dilger
2005-01-20 19:09 ` Andreas Gruenbacher
2005-01-21 21:36 ` Stephen C. Tweedie
1 sibling, 2 replies; 8+ messages in thread
From: Valdis.Kletnieks @ 2005-01-20 18:56 UTC (permalink / raw)
To: Andreas Gruenbacher
Cc: Andrew Morton, Linus Torvalds, Andrew Tridgell,
Stephen C. Tweedie, Andreas Dilger, Alex Tomas, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1800 bytes --]
On Thu, 20 Jan 2005 19:22:25 +0100, Andreas Gruenbacher said:
> When a new inode is created, ext3_new_inode sets the EXT3_STATE_NEW
> flag, which tells ext3_do_update_inode to zero out the inode before
> filling in the inode's data. When a file is created in a directory with
> a default acl, the new inode inherits the directory's default acl; this
> generates attributes. The attributes are created before
> ext3_do_update_inode is called to write out the inode. In case of
> in-inode attributes, the new inode's attributes are written, and then
> zeroed out again by ext3_do_update_inode. Bad thing.
>
> Fix this by recognizing the EXT3_STATE_NEW case in
> ext3_xattr_set_handle, and zeroing out the inode there already when
> necessary.
>
> Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
>
> Index: linux-2.6.11-latest/fs/ext3/xattr.c
> ===================================================================
> --- linux-2.6.11-latest.orig/fs/ext3/xattr.c
> +++ linux-2.6.11-latest/fs/ext3/xattr.c
> @@ -954,6 +954,13 @@ ext3_xattr_set_handle(handle_t *handle,
> error = ext3_get_inode_loc(inode, &is.iloc);
> if (error)
> goto cleanup;
> +
> + if (EXT3_I(inode)->i_state & EXT3_STATE_NEW) {
> + struct ext3_inode *raw_inode = ext3_raw_inode(&is.iloc);
> + memset(raw_inode, 0, EXT3_SB(inode->i_sb)->s_inode_size);
> + EXT3_I(inode)->i_state &= ~EXT3_STATE_NEW;
> + }
> +
> error = ext3_xattr_ibody_find(inode, &i, &is);
> if (error)
> goto cleanup;
Maybe I'm a total idiot, but I'm failing to see how adding *another* zero
operation (although quite likely needed at that point) is going to help the
fact that we zero something out after we've stored data we want to keep in it.
Is there a missing hunk that *removes* the too-late memset-to-zero in
ext3_do_update_inode?
[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fix ea-in-inode default ACL creation
2005-01-20 18:56 ` Valdis.Kletnieks
@ 2005-01-20 19:07 ` Andreas Dilger
2005-01-20 19:09 ` Andreas Gruenbacher
1 sibling, 0 replies; 8+ messages in thread
From: Andreas Dilger @ 2005-01-20 19:07 UTC (permalink / raw)
To: Valdis.Kletnieks
Cc: Andreas Gruenbacher, Andrew Morton, Linus Torvalds,
Andrew Tridgell, Stephen C. Tweedie, Alex Tomas, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1244 bytes --]
On Jan 20, 2005 13:56 -0500, Valdis.Kletnieks@vt.edu wrote:
> On Thu, 20 Jan 2005 19:22:25 +0100, Andreas Gruenbacher said:
> > ===================================================================
> > --- linux-2.6.11-latest.orig/fs/ext3/xattr.c
> > +++ linux-2.6.11-latest/fs/ext3/xattr.c
> > @@ -954,6 +954,13 @@ ext3_xattr_set_handle(handle_t *handle,
> > + if (EXT3_I(inode)->i_state & EXT3_STATE_NEW) {
> > + struct ext3_inode *raw_inode = ext3_raw_inode(&is.iloc);
> > + memset(raw_inode, 0, EXT3_SB(inode->i_sb)->s_inode_size);
> > + EXT3_I(inode)->i_state &= ~EXT3_STATE_NEW;
> > + }
>
> Maybe I'm a total idiot, but I'm failing to see how adding *another* zero
> operation (although quite likely needed at that point) is going to help the
> fact that we zero something out after we've stored data we want to keep in it.
> Is there a missing hunk that *removes* the too-late memset-to-zero in
> ext3_do_update_inode?
Yes, as you can see above the EXT3_STATE_NEW flag is cleared so the later
check in ext3_new_inode() will not again zero the inode
Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://members.shaw.ca/adilger/ http://members.shaw.ca/golinux/
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fix ea-in-inode default ACL creation
2005-01-20 18:56 ` Valdis.Kletnieks
2005-01-20 19:07 ` Andreas Dilger
@ 2005-01-20 19:09 ` Andreas Gruenbacher
2005-01-20 19:21 ` Valdis.Kletnieks
1 sibling, 1 reply; 8+ messages in thread
From: Andreas Gruenbacher @ 2005-01-20 19:09 UTC (permalink / raw)
To: Valdis.Kletnieks; +Cc: linux-kernel@vger.kernel.org
On Thu, 2005-01-20 at 19:56, Valdis.Kletnieks@vt.edu wrote:
> [...] I'm failing to see how adding *another* zero operation [...] is going to help the
> fact [...]
It's an ancient kernel hackers trick: ;)
> + EXT3_I(inode)->i_state &= ~EXT3_STATE_NEW;
Regards,
--
Andreas Gruenbacher <agruen@suse.de>
SUSE Labs, SUSE LINUX GMBH
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fix ea-in-inode default ACL creation
2005-01-20 19:09 ` Andreas Gruenbacher
@ 2005-01-20 19:21 ` Valdis.Kletnieks
0 siblings, 0 replies; 8+ messages in thread
From: Valdis.Kletnieks @ 2005-01-20 19:21 UTC (permalink / raw)
To: Andreas Gruenbacher; +Cc: linux-kernel@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 548 bytes --]
On Thu, 20 Jan 2005 20:09:24 +0100, Andreas Gruenbacher said:
> On Thu, 2005-01-20 at 19:56, Valdis.Kletnieks@vt.edu wrote:
> > [...] I'm failing to see how adding *another* zero operation [...] is going to help the
> > fact [...]
>
> It's an ancient kernel hackers trick: ;)
> > + EXT3_I(inode)->i_state &= ~EXT3_STATE_NEW;
Damn. I saw every *other* line of the patch but that one. Literally.
(Make note to self - if a cold is making your eyes water and itch too
much to wear your contacts, you probably can't see well enough to read code ;)
[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fix ea-in-inode default ACL creation
2005-01-20 18:22 Fix ea-in-inode default ACL creation Andreas Gruenbacher
2005-01-20 18:56 ` Valdis.Kletnieks
@ 2005-01-21 21:36 ` Stephen C. Tweedie
2005-01-21 21:48 ` Andreas Gruenbacher
1 sibling, 1 reply; 8+ messages in thread
From: Stephen C. Tweedie @ 2005-01-21 21:36 UTC (permalink / raw)
To: Andreas Gruenbacher
Cc: Andrew Morton, Linus Torvalds, Andrew Tridgell, Andreas Dilger,
Alex Tomas, linux-kernel, Stephen Tweedie
Hi,
On Thu, 2005-01-20 at 18:22, Andreas Gruenbacher wrote:
> When a new inode is created, ext3_new_inode sets the EXT3_STATE_NEW
> flag, which tells ext3_do_update_inode to zero out the inode before
> filling in the inode's data. When a file is created in a directory with
> a default acl, the new inode inherits the directory's default acl; this
> generates attributes. The attributes are created before
> ext3_do_update_inode is called to write out the inode. In case of
> in-inode attributes, the new inode's attributes are written, and then
> zeroed out again by ext3_do_update_inode. Bad thing.
>
> Fix this by recognizing the EXT3_STATE_NEW case in
> ext3_xattr_set_handle, and zeroing out the inode there already when
> necessary.
Ugh. It feels horrible to have to do this, but we _do_ want to clear
the raw inode, and we only want to do it once, and we have to do it on
first access to the on-disk structures. I can't see an easy way round
it that doesn't add more overhead.
Looks reasonable to me.
--Stephen
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fix ea-in-inode default ACL creation
2005-01-21 21:36 ` Stephen C. Tweedie
@ 2005-01-21 21:48 ` Andreas Gruenbacher
2005-01-21 22:06 ` Stephen C. Tweedie
0 siblings, 1 reply; 8+ messages in thread
From: Andreas Gruenbacher @ 2005-01-21 21:48 UTC (permalink / raw)
To: Stephen C. Tweedie
Cc: Andrew Morton, Linus Torvalds, Andrew Tridgell, Andreas Dilger,
Alex Tomas, linux-kernel
On Fri, 2005-01-21 at 22:36, Stephen C. Tweedie wrote:
> Ugh. It feels horrible to have to do this, but we _do_ want to clear
> the raw inode, and we only want to do it once, and we have to do it on
> first access to the on-disk structures. I can't see an easy way round
> it that doesn't add more overhead.
Well, we could split EXT3_STATE_NEW into a "GOOD_OLD_NEW" flag for the
first 128 bytes and a "BIG_INODE_NEW" flag for the rest, and only
initialize the rest in the xattr code when necessary. Not any better it
I suppose. Note that this change has no effect except with default ACLs
anyway.
-- Andreas.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fix ea-in-inode default ACL creation
2005-01-21 21:48 ` Andreas Gruenbacher
@ 2005-01-21 22:06 ` Stephen C. Tweedie
0 siblings, 0 replies; 8+ messages in thread
From: Stephen C. Tweedie @ 2005-01-21 22:06 UTC (permalink / raw)
To: Andreas Gruenbacher
Cc: Andrew Morton, Linus Torvalds, Andrew Tridgell, Andreas Dilger,
Alex Tomas, linux-kernel
Hi,
On Fri, 2005-01-21 at 21:48, Andreas Gruenbacher wrote:
> Well, we could split EXT3_STATE_NEW into a "GOOD_OLD_NEW" flag for the
> first 128 bytes and a "BIG_INODE_NEW" flag for the rest, and only
> initialize the rest in the xattr code when necessary. Not any better it
> I suppose.
Agreed. :-)
--Stephen
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2005-01-21 22:20 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-20 18:22 Fix ea-in-inode default ACL creation Andreas Gruenbacher
2005-01-20 18:56 ` Valdis.Kletnieks
2005-01-20 19:07 ` Andreas Dilger
2005-01-20 19:09 ` Andreas Gruenbacher
2005-01-20 19:21 ` Valdis.Kletnieks
2005-01-21 21:36 ` Stephen C. Tweedie
2005-01-21 21:48 ` Andreas Gruenbacher
2005-01-21 22:06 ` Stephen C. Tweedie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox