LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jeff Layton <jlayton@redhat.com>
To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: esandeen@redhat.com, aviro@redhat.com
Subject: [PATCH 2/3] change libfs sb creation routines to avoid collisions with their root inodes
Date: Mon, 8 Jan 2007 15:47:13 -0500	[thread overview]
Message-ID: <200701082047.l08KlDCa001921@dantu.rdu.redhat.com> (raw)

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;
 	root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR;
 	root->i_uid = root->i_gid = 0;
 	root->i_atime = root->i_mtime = root->i_ctime = CURRENT_TIME;
@@ -373,6 +379,9 @@ int simple_fill_super(struct super_block *s, int magic, struct tree_descr *files
 	inode = new_inode(s);
 	if (!inode)
 		return -ENOMEM;
+	/* set to high value to try and avoid collisions with loop below */
+	inode->i_ino = 0xffffffff;
+	insert_inode_hash(inode);
 	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-08 20:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-08 20:47 Jeff Layton [this message]
2007-01-10 21:22 ` Christoph Hellwig
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=200701082047.l08KlDCa001921@dantu.rdu.redhat.com \
    --to=jlayton@redhat.com \
    --cc=aviro@redhat.com \
    --cc=esandeen@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).