Commit 67a7b9a5 authored by Bart Van Assche's avatar Bart Van Assche Committed by Jens Axboe

dm/ebs: Change 'int rw' into 'enum req_op op'

Improve static type checking by using type 'enum req_op' instead of 'int'.
Make the role of the 'rw' arguments more clear by renaming these into
'op' (operation). This patch does not change any functionality since
REQ_OP_READ = READ = 0 and REQ_OP_WRITE = WRITE = 1.

Cc: Alasdair Kergon <agk@redhat.com>
Cc: Mike Snitzer <snitzer@kernel.org>
Cc: Heinz Mauelshagen <heinzm@redhat.com>
Cc: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20220714180729.1065367-25-bvanassche@acm.orgSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent a3282b43
...@@ -61,7 +61,8 @@ static inline bool __ebs_check_bs(unsigned int bs) ...@@ -61,7 +61,8 @@ static inline bool __ebs_check_bs(unsigned int bs)
* *
* copy blocks between bufio blocks and bio vector's (partial/overlapping) pages. * copy blocks between bufio blocks and bio vector's (partial/overlapping) pages.
*/ */
static int __ebs_rw_bvec(struct ebs_c *ec, int rw, struct bio_vec *bv, struct bvec_iter *iter) static int __ebs_rw_bvec(struct ebs_c *ec, enum req_op op, struct bio_vec *bv,
struct bvec_iter *iter)
{ {
int r = 0; int r = 0;
unsigned char *ba, *pa; unsigned char *ba, *pa;
...@@ -81,7 +82,7 @@ static int __ebs_rw_bvec(struct ebs_c *ec, int rw, struct bio_vec *bv, struct bv ...@@ -81,7 +82,7 @@ static int __ebs_rw_bvec(struct ebs_c *ec, int rw, struct bio_vec *bv, struct bv
cur_len = min(dm_bufio_get_block_size(ec->bufio) - buf_off, bv_len); cur_len = min(dm_bufio_get_block_size(ec->bufio) - buf_off, bv_len);
/* Avoid reading for writes in case bio vector's page overwrites block completely. */ /* Avoid reading for writes in case bio vector's page overwrites block completely. */
if (rw == READ || buf_off || bv_len < dm_bufio_get_block_size(ec->bufio)) if (op == REQ_OP_READ || buf_off || bv_len < dm_bufio_get_block_size(ec->bufio))
ba = dm_bufio_read(ec->bufio, block, &b); ba = dm_bufio_read(ec->bufio, block, &b);
else else
ba = dm_bufio_new(ec->bufio, block, &b); ba = dm_bufio_new(ec->bufio, block, &b);
...@@ -95,7 +96,7 @@ static int __ebs_rw_bvec(struct ebs_c *ec, int rw, struct bio_vec *bv, struct bv ...@@ -95,7 +96,7 @@ static int __ebs_rw_bvec(struct ebs_c *ec, int rw, struct bio_vec *bv, struct bv
} else { } else {
/* Copy data to/from bio to buffer if read/new was successful above. */ /* Copy data to/from bio to buffer if read/new was successful above. */
ba += buf_off; ba += buf_off;
if (rw == READ) { if (op == REQ_OP_READ) {
memcpy(pa, ba, cur_len); memcpy(pa, ba, cur_len);
flush_dcache_page(bv->bv_page); flush_dcache_page(bv->bv_page);
} else { } else {
...@@ -117,14 +118,14 @@ static int __ebs_rw_bvec(struct ebs_c *ec, int rw, struct bio_vec *bv, struct bv ...@@ -117,14 +118,14 @@ static int __ebs_rw_bvec(struct ebs_c *ec, int rw, struct bio_vec *bv, struct bv
} }
/* READ/WRITE: iterate bio vector's copying between (partial) pages and bufio blocks. */ /* READ/WRITE: iterate bio vector's copying between (partial) pages and bufio blocks. */
static int __ebs_rw_bio(struct ebs_c *ec, int rw, struct bio *bio) static int __ebs_rw_bio(struct ebs_c *ec, enum req_op op, struct bio *bio)
{ {
int r = 0, rr; int r = 0, rr;
struct bio_vec bv; struct bio_vec bv;
struct bvec_iter iter; struct bvec_iter iter;
bio_for_each_bvec(bv, bio, iter) { bio_for_each_bvec(bv, bio, iter) {
rr = __ebs_rw_bvec(ec, rw, &bv, &iter); rr = __ebs_rw_bvec(ec, op, &bv, &iter);
if (rr) if (rr)
r = rr; r = rr;
} }
...@@ -205,10 +206,10 @@ static void __ebs_process_bios(struct work_struct *ws) ...@@ -205,10 +206,10 @@ static void __ebs_process_bios(struct work_struct *ws)
bio_list_for_each(bio, &bios) { bio_list_for_each(bio, &bios) {
r = -EIO; r = -EIO;
if (bio_op(bio) == REQ_OP_READ) if (bio_op(bio) == REQ_OP_READ)
r = __ebs_rw_bio(ec, READ, bio); r = __ebs_rw_bio(ec, REQ_OP_READ, bio);
else if (bio_op(bio) == REQ_OP_WRITE) { else if (bio_op(bio) == REQ_OP_WRITE) {
write = true; write = true;
r = __ebs_rw_bio(ec, WRITE, bio); r = __ebs_rw_bio(ec, REQ_OP_WRITE, bio);
} else if (bio_op(bio) == REQ_OP_DISCARD) { } else if (bio_op(bio) == REQ_OP_DISCARD) {
__ebs_forget_bio(ec, bio); __ebs_forget_bio(ec, bio);
r = __ebs_discard_bio(ec, bio); r = __ebs_discard_bio(ec, bio);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment