All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: Pierre Ossman <drzeus-list@drzeus.cx>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: How to cleanly shut down a block device
Date: Tue, 14 Nov 2006 08:56:49 +0100	[thread overview]
Message-ID: <20061114075648.GK15031@kernel.dk> (raw)
In-Reply-To: <455969F2.80401@drzeus.cx>

On Tue, Nov 14 2006, Pierre Ossman wrote:
> Hi Jens,
> 
> I've been trying to sort out some bugs in the MMC layer's block driver,
> but my knowledge about the block layer is severely lacking. So I was
> hoping you could educate me a bit. :)
> 
> Upon creation, the following happens:
> 
> alloc_disk()
> spin_lock_init()
> blk_init_queue()
> blk_queue_*() (Set up limits)
> disk->* = * (assign members)
> blk_queue_hardsect_size()
> set_capacity()
> add_disk()
> 
> And on a clean removal, where there are no users of a card when it is
> removed:
> 
> del_gendisk()
> put_disk()
> blk_cleanup_queue()
> 
> So far everything seems nice and peachy. The question is what to do when
> a card is removed when the device is open.
> 
> In that case, del_gendisk() will be called, which seems to be documented
> as blocking any new requests to be added to the queue. But there will be
> a lot of outstanding requests in the queue.
> 
> Is it up to each block device to iterate and fail these or can I tell
> the kernel "I'm broken, go away!"?
> 
> When the queue eventually drains (without too many oopses) and the user
> calls close(), then put_disk() and blk_cleanup_queue() will be called.

There is no helper to kill already queued requests when a device is
removed, if you look at SCSI you'll see that it handles this "manually"
as well in the request_fn handler. So you'll need a "device dead or
gone" check in your request_fn handler, and do it from there.

-- 
Jens Axboe


  reply	other threads:[~2006-11-14  7:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-14  7:02 How to cleanly shut down a block device Pierre Ossman
2006-11-14  7:56 ` Jens Axboe [this message]
2006-11-14  8:15   ` Pierre Ossman
2006-11-14  8:45     ` Jens Axboe
2006-11-14  8:54       ` Pierre Ossman
2006-11-14 10:24         ` Jens Axboe
2006-11-14 10:48         ` Russell King
2006-11-14 11:33           ` Pierre Ossman
2006-11-14 11:41             ` Jens Axboe
2006-11-14 11:52               ` Pierre Ossman
2006-11-14 14:34               ` Pierre Ossman
2006-11-14 20:48                 ` Pierre Ossman
2006-11-23 21:03                 ` Russell King
2006-11-23 21:19                   ` Pierre Ossman
2006-11-14 11:48             ` Russell King

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=20061114075648.GK15031@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=drzeus-list@drzeus.cx \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.