public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@clusterfs.com>
To: Andreas Gruenbacher <agruen@suse.de>
Cc: Andrew Morton <akpm@osdl.org>, Linus Torvalds <torvalds@osdl.org>,
	"Theodore Ts'o" <tytso@mit.edu>,
	Andrew Tridgell <tridge@osdl.org>,
	"Stephen C. Tweedie" <sct@redhat.com>,
	Alex Tomas <alex@clusterfs.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [patch 5/5] Disallow in-inode attributes for reserved inodes
Date: Thu, 20 Jan 2005 05:16:06 -0700	[thread overview]
Message-ID: <20050120121606.GF22715@schnapps.adilger.int> (raw)
In-Reply-To: <20050120032510.917200000@suse.de>

[-- Attachment #1: Type: text/plain, Size: 3922 bytes --]

On Jan 20, 2005  03:01 +0100, Andreas Gruenbacher wrote:
> When creating a filesystem with inodes bigger than 128 bytes, mke2fs
> fails to clear out bytes beyond EXT3_GOOD_OLD_INODE_SIZE in all inodes
> it creates (the journal, the filesystem root, and lost+found). We would
> require a zeroed-out i_extra_isize field but we don't get it, so
> disallow in-inode attributes for those inodes.
> 
> Add an i_extra_isize sanity check.

I'm not sure I agree with this patch.  It definitely resolves a problem
I had with the previous patch (4/5), namely that for inodes that were
created in a large-inode filesystem using a kernel w/o the large-inode
patch we didn't save EAs into the large-inode space at all.  With this
patch we will start using that space.

It is debatable whether we should mark inodes bad if the i_extra_isize
field is bad, or if we should just initialize i_extra_isize in that case.
On one hand there is very little else we can use to validate the on-disk
inodes, but on the other hand the EA data isn't critical to reading the
inode so this would seem to introduce additional failure cases.

I'm not sure whether an old e2fsck will also clear out the space in a
large inode that it writes or not (I know that the patched one we use
validates i_extra_isize).  If it doesn't it may be that there would be a
largish number of inodes that are marked bad because of this, so having
the kernel fix this would be good.  If the old e2fsck zeroes the large
inodes properly it would be prudent to have an ext3_error() here so that
the disk corruption triggers an e2fsck the next time the system starts.

For the root and lost+found inodes it looks like we can never store an
EA in the extra part of the inode regardless of whether i_extra_isize is
good or not.  If a bad value is found we could just initialize it and
start using that space (though not print an ext3_error() in that case,
an ext3_warning() if anything since this is probably the fault of mke2fs).

> Index: linux-2.6.11-latest/fs/ext3/inode.c
> ===================================================================
> --- linux-2.6.11-latest.orig/fs/ext3/inode.c
> +++ linux-2.6.11-latest/fs/ext3/inode.c
> @@ -2493,15 +2493,30 @@ void ext3_read_inode(struct inode * inod
>  		ei->i_data[block] = raw_inode->i_block[block];
>  	INIT_LIST_HEAD(&ei->i_orphan);
>  
> -	ei->i_extra_isize =
> -		(EXT3_INODE_SIZE(inode->i_sb) > EXT3_GOOD_OLD_INODE_SIZE) ?
> -		le16_to_cpu(raw_inode->i_extra_isize) : 0;
> -	if (ei->i_extra_isize) {
> -		__le32 *magic = (void *)raw_inode + EXT3_GOOD_OLD_INODE_SIZE +
> -				ei->i_extra_isize;
> -		if (le32_to_cpu(*magic))
> -			 ei->i_state |= EXT3_STATE_XATTR;
> -	}
> +	if (inode->i_ino >= EXT3_FIRST_INO(inode->i_sb) + 1 &&
> +	    EXT3_INODE_SIZE(inode->i_sb) > EXT3_GOOD_OLD_INODE_SIZE) {
> +		/*
> +		 * When mke2fs creates big inodes it does not zero out
> +		 * the unused bytes above EXT3_GOOD_OLD_INODE_SIZE,
> +		 * so ignore those first few inodes.
> +		 */
> +		ei->i_extra_isize = le16_to_cpu(raw_inode->i_extra_isize);
> +		if (EXT3_GOOD_OLD_INODE_SIZE + ei->i_extra_isize >
> +		    EXT3_INODE_SIZE(inode->i_sb))
> +			goto bad_inode;
> +		if (ei->i_extra_isize == 0) {
> +			/* The extra space is currently unused. Use it. */
> +			ei->i_extra_isize = sizeof(struct ext3_inode) -
> +					    EXT3_GOOD_OLD_INODE_SIZE;
> +		} else {
> +			__le32 *magic = (void *)raw_inode +
> +					EXT3_GOOD_OLD_INODE_SIZE +
> +					ei->i_extra_isize;
> +			if (*magic == cpu_to_le32(EXT3_XATTR_MAGIC))
> +				 ei->i_state |= EXT3_STATE_XATTR;
> +		}
> +	} else
> +		ei->i_extra_isize = 0;
>  
>  	if (S_ISREG(inode->i_mode)) {
>  		inode->i_op = &ext3_file_inode_operations;

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

  reply	other threads:[~2005-01-20 12:16 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-20  2:01 [ea-in-inode 0/5] Further fixes Andreas Gruenbacher
2005-01-20  2:01 ` [patch 2/5] Set the EXT3_FEATURE_COMPAT_EXT_ATTR for in-inode xattrs Andreas Gruenbacher
2005-01-20  2:01 ` [patch 5/5] Disallow in-inode attributes for reserved inodes Andreas Gruenbacher
2005-01-20 12:16   ` Andreas Dilger [this message]
2005-01-20 13:29     ` Andreas Gruenbacher
2005-01-20 23:05       ` Andreas Dilger
2005-01-21  0:36         ` Andreas Gruenbacher
2005-01-20  2:01 ` [patch 3/5] Documentation fix Andreas Gruenbacher
2005-01-20  2:01 ` [patch 4/5] Fix i_extra_isize check Andreas Gruenbacher
2005-01-20  2:01 ` [patch 1/5] No lock needed when freeing inode Andreas Gruenbacher
2005-01-21 22:58 ` [ea-in-inode 0/5] Further fixes Stephen C. Tweedie
2005-01-21 23:46   ` Andreas Gruenbacher
2005-01-23 13:22     ` Andrew Tridgell
2005-01-23 22:09     ` Andrew Tridgell
2005-01-23 22:58       ` Andreas Gruenbacher
2005-01-23 23:32         ` Andreas Gruenbacher
2005-01-24 11:24           ` Andrew Tridgell
2005-01-24 11:42             ` Christoph Hellwig
2005-01-24 14:11             ` Andreas Gruenbacher
2005-01-25  3:19             ` memory leak in 2.6.11-rc2 Andrew Tridgell
2005-01-25  3:20               ` Randy.Dunlap
2005-01-25  3:31                 ` Andrew Tridgell
2005-01-25  4:48                   ` Andrew Tridgell
2005-01-25  6:06                     ` Andrew Morton
2005-01-25 11:35                       ` Andrew Tridgell
2005-01-25 12:11                         ` Nick Piggin
2005-01-25  3:45               ` Dave Jones
2005-01-25 12:51                 ` Andrea Arcangeli
2005-01-25 13:31                   ` Andreas Gruenbacher
2005-01-25 13:55                     ` Andrea Arcangeli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050120121606.GF22715@schnapps.adilger.int \
    --to=adilger@clusterfs.com \
    --cc=agruen@suse.de \
    --cc=akpm@osdl.org \
    --cc=alex@clusterfs.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sct@redhat.com \
    --cc=torvalds@osdl.org \
    --cc=tridge@osdl.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox