Skip to content

Commit

Permalink
dm writecache: factor out writecache_map_remap_origin()
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Snitzer <[email protected]>
  • Loading branch information
snitm committed Aug 10, 2021
1 parent cdd4d78 commit 4d020b3
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions drivers/md/dm-writecache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,19 @@ enum wc_map_op {
WC_MAP_ERROR,
};

static enum wc_map_op writecache_map_remap_origin(struct dm_writecache *wc, struct bio *bio,
struct wc_entry *e)
{
if (e) {
sector_t next_boundary =
read_original_sector(wc, e) - bio->bi_iter.bi_sector;
if (next_boundary < bio->bi_iter.bi_size >> SECTOR_SHIFT)
dm_accept_partial_bio(bio, next_boundary);
}

return WC_MAP_REMAP_ORIGIN;
}

static enum wc_map_op writecache_map_read(struct dm_writecache *wc, struct bio *bio)
{
enum wc_map_op map_op;
Expand All @@ -1323,13 +1336,7 @@ static enum wc_map_op writecache_map_read(struct dm_writecache *wc, struct bio *
map_op = WC_MAP_REMAP;
}
} else {
if (e) {
sector_t next_boundary =
read_original_sector(wc, e) - bio->bi_iter.bi_sector;
if (next_boundary < bio->bi_iter.bi_size >> SECTOR_SHIFT)
dm_accept_partial_bio(bio, next_boundary);
}
map_op = WC_MAP_REMAP_ORIGIN;
map_op = writecache_map_remap_origin(wc, bio, e);
}

return map_op;
Expand Down Expand Up @@ -1417,14 +1424,7 @@ static enum wc_map_op writecache_map_write(struct dm_writecache *wc, struct bio
if (!WC_MODE_PMEM(wc) && !found_entry) {
direct_write:
e = writecache_find_entry(wc, bio->bi_iter.bi_sector, WFE_RETURN_FOLLOWING);
if (e) {
sector_t next_boundary = read_original_sector(wc, e) - bio->bi_iter.bi_sector;
BUG_ON(!next_boundary);
if (next_boundary < bio->bi_iter.bi_size >> SECTOR_SHIFT) {
dm_accept_partial_bio(bio, next_boundary);
}
}
return WC_MAP_REMAP_ORIGIN;
return writecache_map_remap_origin(wc, bio, e);
}
writecache_wait_on_freelist(wc);
continue;
Expand Down

0 comments on commit 4d020b3

Please sign in to comment.