make iunique use a do/while loop rather than its obscure goto loop
A while back, Christoph mentioned that he thought that iunique ought to be cleaned up to use a more conventional loop construct. This patch does that, turning the strange goto loop into a do/while. Signed-off-by: Jeff Layton <jlayton@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
9d0633cfed
commit
3361c7bebb
24
fs/inode.c
24
fs/inode.c
|
@ -685,25 +685,21 @@ ino_t iunique(struct super_block *sb, ino_t max_reserved)
|
||||||
{
|
{
|
||||||
static ino_t counter;
|
static ino_t counter;
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
struct hlist_head * head;
|
struct hlist_head *head;
|
||||||
ino_t res;
|
ino_t res;
|
||||||
|
|
||||||
spin_lock(&inode_lock);
|
spin_lock(&inode_lock);
|
||||||
retry:
|
do {
|
||||||
if (counter > max_reserved) {
|
if (counter <= max_reserved)
|
||||||
head = inode_hashtable + hash(sb,counter);
|
|
||||||
res = counter++;
|
|
||||||
inode = find_inode_fast(sb, head, res);
|
|
||||||
if (!inode) {
|
|
||||||
spin_unlock(&inode_lock);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
counter = max_reserved + 1;
|
counter = max_reserved + 1;
|
||||||
}
|
res = counter++;
|
||||||
goto retry;
|
head = inode_hashtable + hash(sb, res);
|
||||||
|
inode = find_inode_fast(sb, head, res);
|
||||||
|
} while (inode != NULL);
|
||||||
|
spin_unlock(&inode_lock);
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(iunique);
|
EXPORT_SYMBOL(iunique);
|
||||||
|
|
||||||
struct inode *igrab(struct inode *inode)
|
struct inode *igrab(struct inode *inode)
|
||||||
|
|
Loading…
Reference in New Issue