mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Björn Steinbrink" <B.Steinbrink@gmx.de>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] Replace obscure constructs in fs/block_dev.c
Date: Sun, 17 Jun 2007 11:38:55 +0200	[thread overview]
Message-ID: <20070617093855.GA30197@atjola.homenet> (raw)
In-Reply-To: <20070615134632.GA11666@saeurebad.de>

On 2007.06.15 15:46:32 +0200, Johannes Weiner wrote:
> Hi,
> 
> Andrew, I promised it [1], here goes. Patched against Linus' git-tree.
> 
> [1] http://lkml.org/lkml/2007/3/22/226
> 
> This patch replaces some obscure code-paths in fs/block_dev.c with more
> readable versions.
> 
> Signed-off-by: Johannes Weiner <hannes-kernel@saeurebad.de>
> 

> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index ea1480a..1ffbb6d 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -660,26 +660,16 @@ void bd_forget(struct inode *inode)
>  
>  int bd_claim(struct block_device *bdev, void *holder)
>  {
> -	int res;
> +	int res = 0;
>  	spin_lock(&bdev_lock);
>  
> -	/* first decide result */
> -	if (bdev->bd_holder == holder)
> -		res = 0;	 /* already a holder */
> -	else if (bdev->bd_holder != NULL)
> -		res = -EBUSY; 	 /* held by someone else */
> -	else if (bdev->bd_contains == bdev)
> -		res = 0;  	 /* is a whole device which isn't held */
> -
> -	else if (bdev->bd_contains->bd_holder == bd_claim)
> -		res = 0; 	 /* is a partition of a device that is being partitioned */
> -	else if (bdev->bd_contains->bd_holder != NULL)
> -		res = -EBUSY;	 /* is a partition of a held device */
> -	else
> -		res = 0;	 /* is a partition of an un-held device */
> +	/* If already held by someone else or we have a
> +	 * partition of a held device, we do nothing. */
>  
> -	/* now impose change */
> -	if (res==0) {
> +	if (bdev->bd_holder || bdev->bd_contains->bd_holder)
> +		res = -EBUSY;

Hm, that actually ignores the "someone else" part of the comment and
introduces a semantic change. No idea, if it breaks anything though.

Björn

  reply	other threads:[~2007-06-17  9:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-15 13:46 Johannes Weiner
2007-06-17  9:38 ` Björn Steinbrink [this message]
2007-06-17 12:52   ` Johannes Weiner
2007-06-17 15:42   ` Johannes Weiner

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=20070617093855.GA30197@atjola.homenet \
    --to=b.steinbrink@gmx.de \
    --cc=akpm@linux-foundation.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

all inboxes | Powered by JetHome®