lkml.org 
[lkml]   [2012]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[patch 2/7] md: linear supports TRIM
    This makes md linear support TRIM.

    Signed-off-by: Shaohua Li <shli@fusionio.com>
    ---
    drivers/md/linear.c | 16 ++++++++++++++++
    1 file changed, 16 insertions(+)

    Index: linux/drivers/md/linear.c
    ===================================================================
    --- linux.orig/drivers/md/linear.c 2012-03-09 16:56:41.173790011 +0800
    +++ linux/drivers/md/linear.c 2012-03-12 10:15:44.916611071 +0800
    @@ -129,6 +129,7 @@ static struct linear_conf *linear_conf(s
    struct linear_conf *conf;
    struct md_rdev *rdev;
    int i, cnt;
    + bool discard_supported = false;

    conf = kzalloc (sizeof (*conf) + raid_disks*sizeof(struct dev_info),
    GFP_KERNEL);
    @@ -171,6 +172,8 @@ static struct linear_conf *linear_conf(s
    conf->array_sectors += rdev->sectors;
    cnt++;

    + if (blk_queue_discard(bdev_get_queue(rdev->bdev)))
    + discard_supported = true;
    }
    if (cnt != raid_disks) {
    printk(KERN_ERR "md/linear:%s: not enough drives present. Aborting!\n",
    @@ -178,6 +181,11 @@ static struct linear_conf *linear_conf(s
    goto out;
    }

    + if (!discard_supported)
    + queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, mddev->queue);
    + else
    + queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, mddev->queue);
    +
    /*
    * Here we calculate the device offsets.
    */
    @@ -319,6 +327,14 @@ static void linear_make_request(struct m
    bio->bi_sector = bio->bi_sector - start_sector
    + tmp_dev->rdev->data_offset;
    rcu_read_unlock();
    +
    + if (unlikely((bio->bi_rw & REQ_DISCARD) &&
    + !blk_queue_discard(bdev_get_queue(bio->bi_bdev)))) {
    + /* Just ignore it */
    + bio_endio(bio, 0);
    + return;
    + }
    +
    generic_make_request(bio);
    }



    \
     
     \ /
      Last update: 2012-03-12 04:17    [W:2.627 / U:0.020 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site