lkml.org 
[lkml]   [2010]   [May]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[PATCH, RFC] addjust discard request to be aligned with hwsect size to support SSDs with larger sector size
    Date
    From
    The currect blkdev_issue_discard() function assumes 512 sector size.
    We have seen some problem when using discard on a SSD that has larger
    sector size. The following patch adjusts the starting address and size of
    a discard request to be aligned with hwsect size.

    Signed-off-by: Jiaying Zhang <jiayingz@google.com>

    diff --git a/block/blk-barrier.c b/block/blk-barrier.c
    index 6d88544..576b7a1 100644
    --- a/block/blk-barrier.c
    +++ b/block/blk-barrier.c
    @@ -376,14 +376,22 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
    DISCARD_BARRIER : DISCARD_NOBARRIER;
    struct bio *bio;
    struct page *page;
    + int hwsect_shift = blksize_bits(bdev_logical_block_size(bdev)) - 9;
    + int hwsect_mask = (1 << hwsect_shift) - 1;
    + sector_t end_sector;
    int ret = 0;

    if (!q)
    return -ENXIO;

    - if (!blk_queue_discard(q))
    + if (!blk_queue_discard(q) || q->limits.max_discard_sectors == 0)
    return -EOPNOTSUPP;

    + if (hwsect_shift > 0) {
    + end_sector = (sector + nr_sects) & ~hwsect_mask;
    + sector = (sector + hwsect_mask) & ~hwsect_mask;
    + nr_sects = end_sector - sector;
    + }
    while (nr_sects && !ret) {
    unsigned int sector_size = q->limits.logical_block_size;
    unsigned int max_discard_sectors =

    \
     
     \ /
      Last update: 2010-05-13 07:23    [W:0.022 / U:126.272 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site