mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
block: make bdev_ops->rw_page() take a REQ_OP instead of bool
c11f0c0b5b ("block/mm: make bdev_ops->rw_page() take a bool for
read/write") replaced @op with boolean @is_write, which limited the
amount of information going into ->rw_page() and more importantly
page_endio(), which removed the need to expose block internals to mm.
Unfortunately, we want to track discards separately and @is_write
isn't enough information. This patch updates bdev_ops->rw_page() to
take REQ_OP instead but leaves page_endio() to take bool @is_write.
This allows the block part of operations to have enough information
while not leaking it to mm.
Signed-off-by: Tejun Heo <[email protected]>
Cc: Mike Christie <[email protected]>
Cc: Minchan Kim <[email protected]>
Cc: Dan Williams <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
parent
ada94973f1
commit
3f289dcb4b
7 changed files with 34 additions and 33 deletions
|
|
@ -254,20 +254,20 @@ static void copy_from_brd(void *dst, struct brd_device *brd,
|
|||
* Process a single bvec of a bio.
|
||||
*/
|
||||
static int brd_do_bvec(struct brd_device *brd, struct page *page,
|
||||
unsigned int len, unsigned int off, bool is_write,
|
||||
unsigned int len, unsigned int off, unsigned int op,
|
||||
sector_t sector)
|
||||
{
|
||||
void *mem;
|
||||
int err = 0;
|
||||
|
||||
if (is_write) {
|
||||
if (op_is_write(op)) {
|
||||
err = copy_to_brd_setup(brd, sector, len);
|
||||
if (err)
|
||||
goto out;
|
||||
}
|
||||
|
||||
mem = kmap_atomic(page);
|
||||
if (!is_write) {
|
||||
if (!op_is_write(op)) {
|
||||
copy_from_brd(mem + off, brd, sector, len);
|
||||
flush_dcache_page(page);
|
||||
} else {
|
||||
|
|
@ -296,7 +296,7 @@ static blk_qc_t brd_make_request(struct request_queue *q, struct bio *bio)
|
|||
int err;
|
||||
|
||||
err = brd_do_bvec(brd, bvec.bv_page, len, bvec.bv_offset,
|
||||
op_is_write(bio_op(bio)), sector);
|
||||
bio_op(bio), sector);
|
||||
if (err)
|
||||
goto io_error;
|
||||
sector += len >> SECTOR_SHIFT;
|
||||
|
|
@ -310,15 +310,15 @@ io_error:
|
|||
}
|
||||
|
||||
static int brd_rw_page(struct block_device *bdev, sector_t sector,
|
||||
struct page *page, bool is_write)
|
||||
struct page *page, unsigned int op)
|
||||
{
|
||||
struct brd_device *brd = bdev->bd_disk->private_data;
|
||||
int err;
|
||||
|
||||
if (PageTransHuge(page))
|
||||
return -ENOTSUPP;
|
||||
err = brd_do_bvec(brd, page, PAGE_SIZE, 0, is_write, sector);
|
||||
page_endio(page, is_write, err);
|
||||
err = brd_do_bvec(brd, page, PAGE_SIZE, 0, op, sector);
|
||||
page_endio(page, op_is_write(op), err);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1274,17 +1274,17 @@ static void zram_bio_discard(struct zram *zram, u32 index,
|
|||
* Returns 1 if IO request was successfully submitted.
|
||||
*/
|
||||
static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index,
|
||||
int offset, bool is_write, struct bio *bio)
|
||||
int offset, unsigned int op, struct bio *bio)
|
||||
{
|
||||
unsigned long start_time = jiffies;
|
||||
int rw_acct = is_write ? REQ_OP_WRITE : REQ_OP_READ;
|
||||
int rw_acct = op_is_write(op) ? REQ_OP_WRITE : REQ_OP_READ;
|
||||
struct request_queue *q = zram->disk->queue;
|
||||
int ret;
|
||||
|
||||
generic_start_io_acct(q, rw_acct, bvec->bv_len >> SECTOR_SHIFT,
|
||||
&zram->disk->part0);
|
||||
|
||||
if (!is_write) {
|
||||
if (!op_is_write(op)) {
|
||||
atomic64_inc(&zram->stats.num_reads);
|
||||
ret = zram_bvec_read(zram, bvec, index, offset, bio);
|
||||
flush_dcache_page(bvec->bv_page);
|
||||
|
|
@ -1300,7 +1300,7 @@ static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index,
|
|||
zram_slot_unlock(zram, index);
|
||||
|
||||
if (unlikely(ret < 0)) {
|
||||
if (!is_write)
|
||||
if (!op_is_write(op))
|
||||
atomic64_inc(&zram->stats.failed_reads);
|
||||
else
|
||||
atomic64_inc(&zram->stats.failed_writes);
|
||||
|
|
@ -1338,7 +1338,7 @@ static void __zram_make_request(struct zram *zram, struct bio *bio)
|
|||
bv.bv_len = min_t(unsigned int, PAGE_SIZE - offset,
|
||||
unwritten);
|
||||
if (zram_bvec_rw(zram, &bv, index, offset,
|
||||
op_is_write(bio_op(bio)), bio) < 0)
|
||||
bio_op(bio), bio) < 0)
|
||||
goto out;
|
||||
|
||||
bv.bv_offset += bv.bv_len;
|
||||
|
|
@ -1390,7 +1390,7 @@ static void zram_slot_free_notify(struct block_device *bdev,
|
|||
}
|
||||
|
||||
static int zram_rw_page(struct block_device *bdev, sector_t sector,
|
||||
struct page *page, bool is_write)
|
||||
struct page *page, unsigned int op)
|
||||
{
|
||||
int offset, ret;
|
||||
u32 index;
|
||||
|
|
@ -1414,7 +1414,7 @@ static int zram_rw_page(struct block_device *bdev, sector_t sector,
|
|||
bv.bv_len = PAGE_SIZE;
|
||||
bv.bv_offset = 0;
|
||||
|
||||
ret = zram_bvec_rw(zram, &bv, index, offset, is_write, NULL);
|
||||
ret = zram_bvec_rw(zram, &bv, index, offset, op, NULL);
|
||||
out:
|
||||
/*
|
||||
* If I/O fails, just return error(ie, non-zero) without
|
||||
|
|
@ -1429,7 +1429,7 @@ out:
|
|||
|
||||
switch (ret) {
|
||||
case 0:
|
||||
page_endio(page, is_write, 0);
|
||||
page_endio(page, op_is_write(op), 0);
|
||||
break;
|
||||
case 1:
|
||||
ret = 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue