lkml.org 
[lkml]   [2006]   [Nov]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectHow to cleanly shut down a block device
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.

Rgds
--
-- Pierre Ossman

Linux kernel, MMC maintainer http://www.kernel.org
PulseAudio, core developer http://pulseaudio.org
rdesktop, core developer http://www.rdesktop.org
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-11-14 08:05    [W:0.334 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site