aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2008-08-05 13:08:25 -0400
committerJens Axboe <jens.axboe@oracle.com>2008-10-09 02:56:01 -0400
commiteae9acd13a8d14b50c00a961fa959606f34bbd92 (patch)
treecbd16bf7fe9db99f6916408953c6243aca175121
parent8c540a96c175bdf55bda8707db04cec78b816454 (diff)
Support 'discard sectors' operation in translation layer support core
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r--drivers/mtd/mtd_blkdevs.c16
-rw-r--r--include/linux/blkdev.h1
-rw-r--r--include/linux/mtd/blktrans.h2
3 files changed, 19 insertions, 0 deletions
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 9ff007c4962c..681d5aca2af4 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -32,6 +32,14 @@ struct mtd_blkcore_priv {
32 spinlock_t queue_lock; 32 spinlock_t queue_lock;
33}; 33};
34 34
35static int blktrans_discard_request(struct request_queue *q,
36 struct request *req)
37{
38 req->cmd_type = REQ_TYPE_LINUX_BLOCK;
39 req->cmd[0] = REQ_LB_OP_DISCARD;
40 return 0;
41}
42
35static int do_blktrans_request(struct mtd_blktrans_ops *tr, 43static int do_blktrans_request(struct mtd_blktrans_ops *tr,
36 struct mtd_blktrans_dev *dev, 44 struct mtd_blktrans_dev *dev,
37 struct request *req) 45 struct request *req)
@@ -44,6 +52,10 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr,
44 52
45 buf = req->buffer; 53 buf = req->buffer;
46 54
55 if (req->cmd_type == REQ_TYPE_LINUX_BLOCK &&
56 req->cmd[0] == REQ_LB_OP_DISCARD)
57 return !tr->discard(dev, block, nsect);
58
47 if (!blk_fs_request(req)) 59 if (!blk_fs_request(req))
48 return 0; 60 return 0;
49 61
@@ -367,6 +379,10 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
367 379
368 tr->blkcore_priv->rq->queuedata = tr; 380 tr->blkcore_priv->rq->queuedata = tr;
369 blk_queue_hardsect_size(tr->blkcore_priv->rq, tr->blksize); 381 blk_queue_hardsect_size(tr->blkcore_priv->rq, tr->blksize);
382 if (tr->discard)
383 blk_queue_set_discard(tr->blkcore_priv->rq,
384 blktrans_discard_request);
385
370 tr->blkshift = ffs(tr->blksize) - 1; 386 tr->blkshift = ffs(tr->blksize) - 1;
371 387
372 tr->blkcore_priv->thread = kthread_run(mtd_blktrans_thread, tr, 388 tr->blkcore_priv->thread = kthread_run(mtd_blktrans_thread, tr,
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 26ececbbebe2..727886d25c4e 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -81,6 +81,7 @@ enum {
81 */ 81 */
82 REQ_LB_OP_EJECT = 0x40, /* eject request */ 82 REQ_LB_OP_EJECT = 0x40, /* eject request */
83 REQ_LB_OP_FLUSH = 0x41, /* flush device */ 83 REQ_LB_OP_FLUSH = 0x41, /* flush device */
84 REQ_LB_OP_DISCARD = 0x42, /* discard sectors */
84}; 85};
85 86
86/* 87/*
diff --git a/include/linux/mtd/blktrans.h b/include/linux/mtd/blktrans.h
index 310e61606415..8b4aa0523db7 100644
--- a/include/linux/mtd/blktrans.h
+++ b/include/linux/mtd/blktrans.h
@@ -41,6 +41,8 @@ struct mtd_blktrans_ops {
41 unsigned long block, char *buffer); 41 unsigned long block, char *buffer);
42 int (*writesect)(struct mtd_blktrans_dev *dev, 42 int (*writesect)(struct mtd_blktrans_dev *dev,
43 unsigned long block, char *buffer); 43 unsigned long block, char *buffer);
44 int (*discard)(struct mtd_blktrans_dev *dev,
45 unsigned long block, unsigned nr_blocks);
44 46
45 /* Block layer ioctls */ 47 /* Block layer ioctls */
46 int (*getgeo)(struct mtd_blktrans_dev *dev, struct hd_geometry *geo); 48 int (*getgeo)(struct mtd_blktrans_dev *dev, struct hd_geometry *geo);