lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 13 Apr 2007 11:42:14 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Jeffrey Layton <jlayton@...hat.com>
Cc:	hch@...radead.org, linux-kernel@...r.kernel.org,
	linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH] make iunique use a do/while loop rather than its
 obscure goto loop

On Wed, 11 Apr 2007 17:58:56 -0400
Jeffrey Layton <jlayton@...hat.com> wrote:

> 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@...hat.com>
> 
> diff --git a/fs/inode.c b/fs/inode.c
> index 23fc1fd..90e7587 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -689,21 +689,18 @@ ino_t iunique(struct super_block *sb, ino_t max_reserved)
>  	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);
> +	do {
> +		if (counter <= max_reserved)
> +			counter = max_reserved + 1;
>  		res = counter++;
> +		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;
> -	}
> -	goto retry;
> -	
> +	} while (inode != NULL);
> +	spin_unlock(&inode_lock);
> +
> +	return res;
>  }
>  

hm.

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);
	do {
		if (counter <= max_reserved)
			counter = max_reserved + 1;
		res = counter++;
		head = inode_hashtable + hash(sb, res);
		inode = find_inode_fast(sb, head, res);
	} while (inode != NULL);
	spin_unlock(&inode_lock);

	return res;
}

The counter-vs-max_reserved test can be moved outside the loop, can't it?

Shouldn't counter be per-sb?

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ