From: Jeff Layton <jlayton@redhat.com>
To: "Jörn Engel" <joern@wohnheim.fh-wedel.de>
Cc: Eric Sandeen <sandeen@redhat.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] make last_inode counter in new_inode 32-bit on kernels that offer x86 compatability
Date: Tue, 07 Nov 2006 13:01:28 -0500 [thread overview]
Message-ID: <1162922488.28425.51.camel@dantu.rdu.redhat.com> (raw)
In-Reply-To: <20061107172835.GB15629@wohnheim.fh-wedel.de>
On Tue, 2006-11-07 at 18:28 +0100, Jörn Engel wrote:
> Looking at the callers, it seemed a bit more natural to me to call
> new_inode_autonum(sb) than new_inode_autonum(sb, 1). Would you mind
> turning new_inode_autonum() in a wrapper like new_inode() and putting
> the actual code into a static helper?
>
> Anyway, here is a first patch converting some callers that looked
> obvious.
>
> Jörn
Thanks for the feedback. Yeah, I held back on converting any filesystems
until I had some comments. Thanks for doing the legwork on that part.
Here's a respun patch with the suggested modification to
new_inode_autonum. This also adds it to fs.h.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
diff --git a/fs/inode.c b/fs/inode.c
index 26cdb11..dd96799 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -517,14 +517,14 @@ repeat:
}
/**
- * new_inode - obtain an inode
+ * __new_inode - obtain an inode
* @sb: superblock
+ * @autonum: if true, make sure that i_ino is unique
*
* Allocates a new inode for given superblock.
*/
-struct inode *new_inode(struct super_block *sb)
+static struct inode *__new_inode(struct super_block *sb, int autonum)
{
- static unsigned long last_ino;
struct inode * inode;
spin_lock_prefetch(&inode_lock);
@@ -535,13 +535,42 @@ struct inode *new_inode(struct super_blo
inodes_stat.nr_inodes++;
list_add(&inode->i_list, &inode_in_use);
list_add(&inode->i_sb_list, &sb->s_inodes);
- inode->i_ino = ++last_ino;
+ if (autonum)
+ inode->i_ino = iunique(sb, 0);
+ else
+ inode->i_ino = ++sb->s_lastino;
inode->i_state = 0;
spin_unlock(&inode_lock);
}
return inode;
}
+/**
+ * new_inode_autonum - obtain an inode with a unique i_ino value
+ * @sb: superblock
+ *
+ * Allocates a new inode for given superblock. Ensures that i_ino is
+ * unique on the filesystem.
+ */
+struct inode *new_inode_autonum(struct super_block *sb)
+{
+ return __new_inode(sb, 1);
+}
+
+EXPORT_SYMBOL(new_inode_autonum);
+
+/**
+ * new_inode - obtain an inode -- i_ino not guaranteed unique
+ * @sb: superblock
+ *
+ * Allocates a new inode for given superblock. i_ino is not guaranteed to
+ * be unique. Should only be used when i_ino is going to be clobbered.
+ */
+struct inode *new_inode(struct super_block *sb)
+{
+ return __new_inode(sb, 0);
+}
+
EXPORT_SYMBOL(new_inode);
void unlock_new_inode(struct inode *inode)
@@ -683,22 +712,21 @@ static unsigned long hash(struct super_b
*/
ino_t iunique(struct super_block *sb, ino_t max_reserved)
{
- static ino_t counter;
struct inode *inode;
struct hlist_head * head;
ino_t res;
spin_lock(&inode_lock);
retry:
- if (counter > max_reserved) {
- head = inode_hashtable + hash(sb,counter);
- res = counter++;
+ if (sb->s_lastino >= max_reserved) {
+ res = ++sb->s_lastino;
+ head = inode_hashtable + hash(sb,res);
inode = find_inode_fast(sb, head, res);
if (!inode) {
spin_unlock(&inode_lock);
return res;
}
} else {
- counter = max_reserved + 1;
+ sb->s_lastino = max_reserved;
}
goto retry;
diff --git a/fs/super.c b/fs/super.c
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2fe6e3f..d85c7ba 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -961,6 +961,14 @@ #endif
/* Granularity of c/m/atime in ns.
Cannot be worse than a second */
u32 s_time_gran;
+
+ /* per-sb inode counter for new_inode. Make it a 32-bit counter when
+ we have the possibility of dealing with 32-bit apps */
+#ifdef CONFIG_COMPAT
+ unsigned int s_lastino;
+#else
+ unsigned long s_lastino;
+#endif
};
extern struct timespec current_fs_time(struct super_block *sb);
@@ -1712,6 +1720,7 @@ extern void __iget(struct inode * inode)
extern void clear_inode(struct inode *);
extern void destroy_inode(struct inode *);
extern struct inode *new_inode(struct super_block *);
+extern struct inode *new_inode_autonum(struct super_block *);
extern int __remove_suid(struct dentry *, int);
extern int should_remove_suid(struct dentry *);
extern int remove_suid(struct dentry *);
next prev parent reply other threads:[~2006-11-07 18:01 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-06 18:12 [PATCH] make last_inode counter in new_inode 32-bit on kernels that offer x86 compatability Jeff Layton
2006-11-06 18:22 ` Matthew Wilcox
2006-11-06 18:31 ` Jeff Layton
2006-11-06 18:47 ` Jeff Layton
2006-11-06 20:23 ` Jörn Engel
2006-11-06 20:31 ` Eric Dumazet
2006-11-06 20:56 ` Jeff Layton
2006-11-06 20:50 ` Eric Sandeen
2006-11-06 21:11 ` Jörn Engel
2006-11-06 21:36 ` Eric Sandeen
2006-11-06 22:01 ` Andreas Dilger
2006-11-07 15:56 ` Jeff Layton
2006-11-07 16:07 ` Jeff Layton
2006-11-07 16:10 ` Matthew Wilcox
2006-11-07 17:04 ` Jörn Engel
2006-11-07 17:28 ` Jörn Engel
2006-11-07 17:42 ` Jörn Engel
2006-11-07 17:53 ` Dave Kleikamp
2006-11-07 18:07 ` Jörn Engel
2006-11-07 17:56 ` Jörn Engel
2006-11-07 18:01 ` Jörn Engel
2006-11-07 18:10 ` Eric Sandeen
2006-11-07 19:41 ` Jeff Layton
2006-11-07 20:41 ` Jörn Engel
2006-11-07 21:13 ` Jeff Layton
2006-11-07 21:20 ` Matthew Wilcox
2006-11-07 22:09 ` Jeff Layton
2006-11-07 18:01 ` Jeff Layton [this message]
2006-11-07 18:14 ` Jörn Engel
2006-11-07 18:23 ` 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=1162922488.28425.51.camel@dantu.rdu.redhat.com \
--to=jlayton@redhat.com \
--cc=joern@wohnheim.fh-wedel.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sandeen@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).