LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Jeff Layton <jlayton@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	esandeen@redhat.com, aviro@redhat.com
Subject: Re: [PATCH 2/3] change libfs sb creation routines to avoid collisions with their root inodes
Date: Wed, 10 Jan 2007 21:22:15 +0000	[thread overview]
Message-ID: <20070110212215.GB4425@infradead.org> (raw)
In-Reply-To: <200701082047.l08KlDCa001921@dantu.rdu.redhat.com>

On Mon, Jan 08, 2007 at 03:47:13PM -0500, Jeff Layton wrote:
> This changes the superblock creation routines that call new_inode to take steps
> to avoid later collisions with other inodes that get created. I took the
> approach here of not hashing things unless is was strictly necessary, though
> that does mean that filesystem authors need to be careful to avoid collisions
> by calling iunique properly.
> 
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> 
> diff --git a/fs/libfs.c b/fs/libfs.c
> index 503898d..5bdaf00 100644
> --- a/fs/libfs.c
> +++ b/fs/libfs.c
> @@ -217,6 +217,12 @@ int get_sb_pseudo(struct file_system_type *fs_type, char *name,
>  	root = new_inode(s);
>  	if (!root)
>  		goto Enomem;
> +	/*
> +	 * since this is the first inode, make it number 1. New inodes created
> +         * after this must take care not to collide with it (by passing
> +	 * max_reserved of 1 to iunique).
> +	 */
> +	root->i_ino = 1;

Ok.

>  		return -ENOMEM;
> +	/* set to high value to try and avoid collisions with loop below */
> +	inode->i_ino = 0xffffffff;
> +	insert_inode_hash(inode);

This is odd.  Can't we just add some constant base to the loop below?

>  	inode->i_mode = S_IFDIR | 0755;
>  	inode->i_uid = inode->i_gid = 0;
>  	inode->i_blocks = 0;
> @@ -399,6 +408,11 @@ int simple_fill_super(struct super_block *s, int magic, struct tree_descr *files
>  		inode->i_blocks = 0;
>  		inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
>  		inode->i_fop = files->ops;
> +		/*
> +		 * no need to hash these, but you need to make sure that any
> +		 * calls to iunique on this mount call it with a max_reserved
> +		 * value high enough to avoid collisions with these inodes.
> +		 */
>  		inode->i_ino = i;
>  		d_add(dentry, inode);

  reply	other threads:[~2007-01-10 21:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-08 20:47 Jeff Layton
2007-01-10 21:22 ` Christoph Hellwig [this message]
2007-01-10 21:51   ` Eric Sandeen
2007-01-11 16:46     ` Jeff Layton
  -- strict thread matches above, loose matches on Subject: below --
2007-01-16 18:57 Jeff Layton
2007-01-11 20:15 Jeff Layton
2007-01-11 20:08 Jeff Layton
2007-01-11 19:43 Jeff Layton
2006-12-29 19:11 Jeff Layton

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=20070110212215.GB4425@infradead.org \
    --to=hch@infradead.org \
    --cc=aviro@redhat.com \
    --cc=esandeen@redhat.com \
    --cc=jlayton@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH 2/3] change libfs sb creation routines to avoid collisions with their root inodes' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).