mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Anatol Pomozov <anatol.pomozov@gmail.com>
Cc: torvalds@linux-foundation.org, linux-kernel@vger.kernel.org,
	tytso@mit.edu, sqazi@google.com, yan@linux.vnet.ibm.com
Subject: Re: [PATCH] loop: prevent bdev freeing while device in use
Date: Mon, 1 Apr 2013 17:28:00 +0100	[thread overview]
Message-ID: <20130401162800.GB21522@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1364817485-19676-1-git-send-email-anatol.pomozov@gmail.com>

On Mon, Apr 01, 2013 at 04:58:05AM -0700, Anatol Pomozov wrote:
>  		lo->lo_flags |= LO_FLAGS_PARTSCAN;
>  	if (lo->lo_flags & LO_FLAGS_PARTSCAN)
>  		ioctl_by_bdev(bdev, BLKRRPART, 0);
> +
> +	/* bdev lifecycle is defined by its bd_inode (see
> +	 * struct bdev_inode usage). In case of loop device we need to make
> +	 * sure that bdev deallocation will not happen between loop_set_fd()
> +	 * and loop_clr_fd() invocations. To do this we need to hold
> +	 * bdev inode here and put it later in loop_clr_fd().
> +	 */
> +	ihold(bdev->bd_inode);

That's open-coded bdgrab()

> +	if (bdev) {
> +		BUG_ON(atomic_read(&bdev->bd_inode->i_count) < 2);
> +		iput(bdev->bd_inode);

... and that - bdput() (I'd drop that BUG_ON())

  parent reply	other threads:[~2013-04-01 16:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-01 11:58 Anatol Pomozov
2013-04-01 15:16 ` Linus Torvalds
2013-04-01 17:00   ` Anatol Pomozov
2013-04-01 22:53     ` Linus Torvalds
2013-04-02  5:58       ` Anatol Pomozov
2013-04-02  6:08         ` Al Viro
2013-04-01 16:28 ` Al Viro [this message]
2013-04-01 16:49   ` Anatol Pomozov
2013-04-01 16:47 ` Anatol Pomozov

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=20130401162800.GB21522@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=anatol.pomozov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sqazi@google.com \
    --cc=torvalds@linux-foundation.org \
    --cc=tytso@mit.edu \
    --cc=yan@linux.vnet.ibm.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

all inboxes | Powered by JetHome®