mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Josef Bacik <jbacik@fb.com>
To: Ming Lin <mlin@kernel.org>
Cc: "nbd-general@lists.sourceforge.net" 
	<nbd-general@lists.sourceforge.net>,
	Ratna Manoj Bolla <manoj.br@gmail.com>,
	lkml <linux-kernel@vger.kernel.org>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"jianshu.ljs@alibaba-inc.com" <jianshu.ljs@alibaba-inc.com>,
	"LIU, Fei" <james.liu@alibaba-inc.com>,
	Markus Pargmann <mpa@pengutronix.de>,
	"xiongwei.jiang@alibaba-inc.com" <xiongwei.jiang@alibaba-inc.com>
Subject: Re: [Nbd] [RFC PATCH 1/1] nbd: replace kill_bdev() with __invalidate_device()
Date: Wed, 22 Mar 2017 21:43:27 +0000	[thread overview]
Message-ID: <D98734E2-B906-48F8-9EA2-E4F5DBFBD93F@fb.com> (raw)
In-Reply-To: <CAF1ivSb2nwBAKjbsFhca3cvJk=-B_gtu-ZdqkyAetJSer5CuYw@mail.gmail.com>

Hey sorry I just got back from LSF, I’ll look at this in the morning.  Thanks,

Josef

On 3/22/17, 4:48 PM, "Ming Lin" <mlin@kernel.org> wrote:

On Mon, Mar 20, 2017 at 3:58 PM, Ming Lin <mlin@kernel.org> wrote:
> From: Ratna Manoj Bolla <manoj.br@gmail.com>
>
> When a filesystem is mounted on a nbd device and on a disconnect, because
> of kill_bdev(), and resetting bdev size to zero, buffer_head mappings are
> getting destroyed under mounted filesystem.
>
> After a bdev size reset(i.e bdev->bd_inode->i_size = 0) on a disconnect,
> followed by a sys_umount(),
>         generic_shutdown_super()->...
>         ->__sync_blockdev()->...
>         -blkdev_writepages()->...
>         ->do_invalidatepage()->...
>         -discard_buffer()   is discarding superblock buffer_head assumed
> to be in mapped state by ext4_commit_super().
>
> [mlin: ported to 4.11-rc2]
> Signed-off-by: Ratna Manoj Bolla <manoj.br@gmail.com
> ---
>  drivers/block/nbd.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index cb4ccfc..a6a3643 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -125,7 +125,8 @@ static const char *nbdcmd_to_ascii(int cmd)
>
>  static int nbd_size_clear(struct nbd_device *nbd, struct block_device *bdev)
>  {
> -       bd_set_size(bdev, 0);
> +       if (bdev->bd_openers <= 1)
> +               bd_set_size(bdev, 0);
>         set_capacity(nbd->disk, 0);
>         kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE);
>
> @@ -603,6 +604,8 @@ static void nbd_reset(struct nbd_device *nbd)
>
>  static void nbd_bdev_reset(struct block_device *bdev)
>  {
> +       if (bdev->bd_openers > 1)
> +               return;
>         set_device_ro(bdev, false);
>         bdev->bd_inode->i_size = 0;
>         if (max_part > 0) {
> @@ -666,7 +669,8 @@ static int nbd_clear_sock(struct nbd_device *nbd, struct block_device *bdev)
>  {
>         sock_shutdown(nbd);
>         nbd_clear_que(nbd);
> -       kill_bdev(bdev);
> +
> +       __invalidate_device(bdev, true);
>         nbd_bdev_reset(bdev);
>         /*
>          * We want to give the run thread a chance to wait for everybody
> --
> 1.8.3.1

Hi Josef,

Any comments?

Thanks,
Ming

  reply	other threads:[~2017-03-22 21:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-20 22:58 [RFC PATCH 0/1] nbd: fix crash when unmaping nbd device with fs still mounted Ming Lin
2017-03-20 22:58 ` [RFC PATCH 1/1] nbd: replace kill_bdev() with __invalidate_device() Ming Lin
2017-03-22 20:48   ` [Nbd] " Ming Lin
2017-03-22 21:43     ` Josef Bacik [this message]
2017-03-23 17:51   ` Josef Bacik
2017-03-23 20:58     ` Ming Lin

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=D98734E2-B906-48F8-9EA2-E4F5DBFBD93F@fb.com \
    --to=jbacik@fb.com \
    --cc=james.liu@alibaba-inc.com \
    --cc=jianshu.ljs@alibaba-inc.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manoj.br@gmail.com \
    --cc=mlin@kernel.org \
    --cc=mpa@pengutronix.de \
    --cc=nbd-general@lists.sourceforge.net \
    --cc=xiongwei.jiang@alibaba-inc.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®