block: use normal I/O path for discard requests
authorChristoph Hellwig <hch@infradead.org>
Wed, 30 Sep 2009 11:52:12 +0000 (13:52 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 1 Oct 2009 19:15:46 +0000 (21:15 +0200)
commit1122a26f2abe4245ccdaed95ec23f63fe086b332
treead06f119f283cf8a6313681055e8132ba2851ddb
parent3bd0f0c763e497c8674b28e3df2732f48683dabd
block: use normal I/O path for discard requests

prepare_discard_fn() was being called in a place where memory allocation
was effectively impossible.  This makes it inappropriate for all but
the most trivial translations of Linux's DISCARD operation to the block
command set.  Additionally adding a payload there makes the ownership
of the bio backing unclear as it's now allocated by the device driver
and not the submitter as usual.

It is replaced with QUEUE_FLAG_DISCARD which is used to indicate whether
the queue supports discard operations or not.  blkdev_issue_discard now
allocates a one-page, sector-length payload which is the right thing
for the common ATA and SCSI implementations.

The mtd implementation of prepare_discard_fn() is replaced with simply
checking for the request being a discard.

Largely based on a previous patch from Matthew Wilcox <matthew@wil.cx>
which did the prepare_discard_fn but not the different payload allocation
yet.

Signed-off-by: Christoph Hellwig <hch@lst.de>
block/blk-barrier.c
block/blk-core.c
block/blk-settings.c
drivers/mtd/mtd_blkdevs.c
drivers/staging/dst/dcore.c
include/linux/blkdev.h