linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Jeffrey Layton <jlayton@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	hch@infradead.org
Subject: Re: [PATCH] make iunique use a do/while loop rather than its obscure goto loop
Date: Wed, 31 Jan 2007 08:16:49 +0000	[thread overview]
Message-ID: <20070131081649.GA25032@infradead.org> (raw)
In-Reply-To: <200701301545.l0UFjsCw027749@dantu.rdu.redhat.com>

On Tue, Jan 30, 2007 at 10:45:54AM -0500, Jeffrey Layton wrote:
> While working on a case, 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>
> 
> 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;

Looks good, thanks

  reply	other threads:[~2007-01-31  8:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-30 15:45 [PATCH] make iunique use a do/while loop rather than its obscure goto loop Jeffrey Layton
2007-01-31  8:16 ` Christoph Hellwig [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-04-11 21:58 Jeffrey Layton
2007-04-13 18:42 ` Andrew Morton
2007-04-13 19:08   ` Jeff Layton
2007-04-13 19:55     ` Andrew Morton
2007-06-23  8:08 ` Christoph Hellwig

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=20070131081649.GA25032@infradead.org \
    --to=hch@infradead.org \
    --cc=jlayton@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).