mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 10:04:04 +02:00
zram: make zram_bio_discard more self-contained
Derive the index and offset variables inside the function, and complete the bio directly in preparation for cleaning up the I/O path. Link: https://lkml.kernel.org/r/20230411171459.567614-4-hch@lst.de Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org> Acked-by: Minchan Kim <minchan@kernel.org> Cc: Jens Axboe <axboe@kernel.dk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
9fe95babc7
commit
0120dd6e4e
|
|
@ -1890,15 +1890,12 @@ static ssize_t recompress_store(struct device *dev,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
static void zram_bio_discard(struct zram *zram, struct bio *bio)
|
||||||
* zram_bio_discard - handler on discard request
|
|
||||||
* @index: physical block index in PAGE_SIZE units
|
|
||||||
* @offset: byte offset within physical block
|
|
||||||
*/
|
|
||||||
static void zram_bio_discard(struct zram *zram, u32 index,
|
|
||||||
int offset, struct bio *bio)
|
|
||||||
{
|
{
|
||||||
size_t n = bio->bi_iter.bi_size;
|
size_t n = bio->bi_iter.bi_size;
|
||||||
|
u32 index = bio->bi_iter.bi_sector >> SECTORS_PER_PAGE_SHIFT;
|
||||||
|
u32 offset = (bio->bi_iter.bi_sector & (SECTORS_PER_PAGE - 1)) <<
|
||||||
|
SECTOR_SHIFT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* zram manages data in physical block size units. Because logical block
|
* zram manages data in physical block size units. Because logical block
|
||||||
|
|
@ -1926,6 +1923,8 @@ static void zram_bio_discard(struct zram *zram, u32 index,
|
||||||
index++;
|
index++;
|
||||||
n -= PAGE_SIZE;
|
n -= PAGE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bio_endio(bio);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -1974,8 +1973,7 @@ static void __zram_make_request(struct zram *zram, struct bio *bio)
|
||||||
switch (bio_op(bio)) {
|
switch (bio_op(bio)) {
|
||||||
case REQ_OP_DISCARD:
|
case REQ_OP_DISCARD:
|
||||||
case REQ_OP_WRITE_ZEROES:
|
case REQ_OP_WRITE_ZEROES:
|
||||||
zram_bio_discard(zram, index, offset, bio);
|
zram_bio_discard(zram, bio);
|
||||||
bio_endio(bio);
|
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user