zram: directly call zram_read_page in writeback_store
writeback_store always reads a full page, so just call zram_read_page directly and bypass the boune buffer handling. Link: https://lkml.kernel.org/r/20230411171459.567614-11-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
ffb0a9e665
commit
79c744eeaa
|
@ -54,9 +54,8 @@ static size_t huge_class_size;
|
||||||
static const struct block_device_operations zram_devops;
|
static const struct block_device_operations zram_devops;
|
||||||
|
|
||||||
static void zram_free_page(struct zram *zram, size_t index);
|
static void zram_free_page(struct zram *zram, size_t index);
|
||||||
static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec,
|
static int zram_read_page(struct zram *zram, struct page *page, u32 index,
|
||||||
u32 index, int offset, struct bio *bio);
|
struct bio *bio, bool partial_io);
|
||||||
|
|
||||||
|
|
||||||
static int zram_slot_trylock(struct zram *zram, u32 index)
|
static int zram_slot_trylock(struct zram *zram, u32 index)
|
||||||
{
|
{
|
||||||
|
@ -672,10 +671,6 @@ static ssize_t writeback_store(struct device *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; nr_pages != 0; index++, nr_pages--) {
|
for (; nr_pages != 0; index++, nr_pages--) {
|
||||||
struct bio_vec bvec;
|
|
||||||
|
|
||||||
bvec_set_page(&bvec, page, PAGE_SIZE, 0);
|
|
||||||
|
|
||||||
spin_lock(&zram->wb_limit_lock);
|
spin_lock(&zram->wb_limit_lock);
|
||||||
if (zram->wb_limit_enable && !zram->bd_wb_limit) {
|
if (zram->wb_limit_enable && !zram->bd_wb_limit) {
|
||||||
spin_unlock(&zram->wb_limit_lock);
|
spin_unlock(&zram->wb_limit_lock);
|
||||||
|
@ -719,7 +714,7 @@ static ssize_t writeback_store(struct device *dev,
|
||||||
/* Need for hugepage writeback racing */
|
/* Need for hugepage writeback racing */
|
||||||
zram_set_flag(zram, index, ZRAM_IDLE);
|
zram_set_flag(zram, index, ZRAM_IDLE);
|
||||||
zram_slot_unlock(zram, index);
|
zram_slot_unlock(zram, index);
|
||||||
if (zram_bvec_read(zram, &bvec, index, 0, NULL)) {
|
if (zram_read_page(zram, page, index, NULL, false)) {
|
||||||
zram_slot_lock(zram, index);
|
zram_slot_lock(zram, index);
|
||||||
zram_clear_flag(zram, index, ZRAM_UNDER_WB);
|
zram_clear_flag(zram, index, ZRAM_UNDER_WB);
|
||||||
zram_clear_flag(zram, index, ZRAM_IDLE);
|
zram_clear_flag(zram, index, ZRAM_IDLE);
|
||||||
|
@ -730,9 +725,8 @@ static ssize_t writeback_store(struct device *dev,
|
||||||
bio_init(&bio, zram->bdev, &bio_vec, 1,
|
bio_init(&bio, zram->bdev, &bio_vec, 1,
|
||||||
REQ_OP_WRITE | REQ_SYNC);
|
REQ_OP_WRITE | REQ_SYNC);
|
||||||
bio.bi_iter.bi_sector = blk_idx * (PAGE_SIZE >> 9);
|
bio.bi_iter.bi_sector = blk_idx * (PAGE_SIZE >> 9);
|
||||||
|
bio_add_page(&bio, page, PAGE_SIZE, 0);
|
||||||
|
|
||||||
bio_add_page(&bio, bvec.bv_page, bvec.bv_len,
|
|
||||||
bvec.bv_offset);
|
|
||||||
/*
|
/*
|
||||||
* XXX: A single page IO would be inefficient for write
|
* XXX: A single page IO would be inefficient for write
|
||||||
* but it would be not bad as starter.
|
* but it would be not bad as starter.
|
||||||
|
|
Loading…
Reference in New Issue