summaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorMike Snitzer <snitzer@redhat.com>2021-07-12 16:58:49 -0400
committerMike Snitzer <snitzer@redhat.com>2021-08-10 13:27:48 -0400
commit4d020b3a290707b19a3974fe8bc356f0b01b6928 (patch)
tree1e6b12d25c713ace83ab56a55738213682208a21 /drivers/md
parentcdd4d7832d51e0414472eb2863b294b783597e5e (diff)
downloadlinux-4d020b3a290707b19a3974fe8bc356f0b01b6928.tar.bz2
dm writecache: factor out writecache_map_remap_origin()
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-writecache.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c
index 53076c7f4a34..2a920e95975a 100644
--- a/drivers/md/dm-writecache.c
+++ b/drivers/md/dm-writecache.c
@@ -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;
@@ -1323,13 +1336,7 @@ read_next_block:
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;
@@ -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;