[lkml]   [2014]   [Feb]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] zram: support REQ_DISCARD
2014-02-24 22:36 GMT+09:00 Jerome Marchand <>:
> On 02/24/2014 06:51 AM, Joonsoo Kim wrote:
>> zram is ram based block device and can be used by backend of filesystem.
>> When filesystem deletes a file, it normally doesn't do anything on data
>> block of that file. It just marks on metadata of that file. This behavior
>> has no problem on disk based block device, but has problems on ram based
>> block device, since we can't free memory used for data block. To overcome
>> this disadvantage, there is REQ_DISCARD functionality. If block device
>> support REQ_DISCARD and filesystem is mounted with discard option,
>> filesystem sends REQ_DISCARD to block device whenever some data blocks are
>> discarded. All we have to do is to handle this request.
>> This patch implements to flag up QUEUE_FLAG_DISCARD and handle this
>> REQ_DISCARD request. With it, we can free memory used by zram if it isn't
>> used.
>> Signed-off-by: Joonsoo Kim <>
>> ---
>> This patch is based on master branch of linux-next tree.
>> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
>> index 5ec61be..cff2c0e 100644
>> --- a/drivers/block/zram/zram_drv.c
>> +++ b/drivers/block/zram/zram_drv.c
>> @@ -501,6 +501,20 @@ static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index,
>> return ret;
>> }
>> +static void zram_bio_discard(struct zram *zram, struct bio *bio)
>> +{
>> + u32 index = bio->bi_iter.bi_sector >> SECTORS_PER_PAGE_SHIFT;
> Hi Joonsoo,
> If bi_sector is not aligned on a page size, we might end up discarding
> a page that still contain valid data.

Hello, Jerome.

Is it possible that request isn't aligned on a page size if
logical/physical block size
is PAGE_SIZE? When I tested it, I didn't find any invalid io.
If we meet any misaligned request, it would be filtered by
valid_io_request(). :)


 \ /
  Last update: 2014-02-24 16:41    [W:0.085 / U:0.796 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site