Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 110449
b: refs/heads/master
c: eae9acd
h: refs/heads/master
i:
  110447: 9b17710
v: v3
  • Loading branch information
David Woodhouse authored and Jens Axboe committed Oct 9, 2008
1 parent 1244cca commit 2dbe723
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8c540a96c175bdf55bda8707db04cec78b816454
refs/heads/master: eae9acd13a8d14b50c00a961fa959606f34bbd92
16 changes: 16 additions & 0 deletions trunk/drivers/mtd/mtd_blkdevs.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ struct mtd_blkcore_priv {
spinlock_t queue_lock;
};

static int blktrans_discard_request(struct request_queue *q,
struct request *req)
{
req->cmd_type = REQ_TYPE_LINUX_BLOCK;
req->cmd[0] = REQ_LB_OP_DISCARD;
return 0;
}

static int do_blktrans_request(struct mtd_blktrans_ops *tr,
struct mtd_blktrans_dev *dev,
struct request *req)
Expand All @@ -44,6 +52,10 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr,

buf = req->buffer;

if (req->cmd_type == REQ_TYPE_LINUX_BLOCK &&
req->cmd[0] == REQ_LB_OP_DISCARD)
return !tr->discard(dev, block, nsect);

if (!blk_fs_request(req))
return 0;

Expand Down Expand Up @@ -367,6 +379,10 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)

tr->blkcore_priv->rq->queuedata = tr;
blk_queue_hardsect_size(tr->blkcore_priv->rq, tr->blksize);
if (tr->discard)
blk_queue_set_discard(tr->blkcore_priv->rq,
blktrans_discard_request);

tr->blkshift = ffs(tr->blksize) - 1;

tr->blkcore_priv->thread = kthread_run(mtd_blktrans_thread, tr,
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ enum {
*/
REQ_LB_OP_EJECT = 0x40, /* eject request */
REQ_LB_OP_FLUSH = 0x41, /* flush device */
REQ_LB_OP_DISCARD = 0x42, /* discard sectors */
};

/*
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/mtd/blktrans.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ struct mtd_blktrans_ops {
unsigned long block, char *buffer);
int (*writesect)(struct mtd_blktrans_dev *dev,
unsigned long block, char *buffer);
int (*discard)(struct mtd_blktrans_dev *dev,
unsigned long block, unsigned nr_blocks);

/* Block layer ioctls */
int (*getgeo)(struct mtd_blktrans_dev *dev, struct hd_geometry *geo);
Expand Down

0 comments on commit 2dbe723

Please sign in to comment.