[Devel] [PATCH RHEL7 COMMIT] ploop: Introduce ->fastmap_end_io
Vasily Averin
vvs at virtuozzo.com
Fri Aug 7 09:01:26 MSK 2020
The commit is pushed to "branch-rh7-3.10.0-1127.18.2.vz7.163.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.18.2.vz7.163.1
------>
commit 39bcb0b64e168acaf833504ed725dd8af432ca8e
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Fri Aug 7 09:01:26 2020 +0300
ploop: Introduce ->fastmap_end_io
Patchset descritpyion:
ploop: Protect fastmap against defrag and punch hole
https://jira.sw.ru/browse/PSBM-105347
This protects fastmap against mapped extent disappearance,
which may be a result of extenal actions (move extent and
punch hole) on root.hds. Thus, root.hds becomes more "normal"
file.
Kirill Tkhai (4):
ploop: Introduce ->fastmap_end_io
ploop: Add @write argument to ->fastmap
fs: Export mapping_needs_writeback()
ploop: io_kaio: Protect ->fastmap against EXT4_IOC_MOVE_EXT and punch hole
Current patch description:
[PATCH 1/4] ploop: Introduce ->fastmap_end_io
This will be used in kaio to put inode->i_dio_count
after fastmap IO is ended.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/block/ploop/dev.c | 25 +++++++++++++++++++++++--
include/linux/ploop/ploop.h | 8 ++++++++
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 6ee315b..5f1a0c2 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -692,10 +692,18 @@ static struct ploop_delta * find_delta(struct ploop_device * plo, int level)
DEFINE_BIO_CB(ploop_fast_end_io)
{
unsigned long flags;
+ struct ploop_delta * delta;
struct ploop_device * plo;
struct bio * orig = bio->bi_private;
- plo = orig->bi_bdev->bd_disk->private_data;
+ /* Assigned in bio_fast_map() */
+ delta = (void *)orig->bi_next;
+ orig->bi_next = NULL;
+
+ if (delta->io.ops->fastmap_end_io)
+ delta->io.ops->fastmap_end_io(&delta->io, orig);
+
+ plo = delta->plo;
/* End of fast bio wakes up main process only when this could
* mean exit from ATTENTION state.
@@ -774,6 +782,7 @@ bio_fast_map(struct ploop_device * plo, struct bio * orig_bio, struct bio * bio)
{
struct ploop_delta * delta;
sector_t isector;
+ int ret;
if (orig_bio->bi_size == 0)
delta = ploop_top_delta(plo);
@@ -788,7 +797,19 @@ bio_fast_map(struct ploop_device * plo, struct bio * orig_bio, struct bio * bio)
if (delta->io.ops->fastmap == NULL)
return 1;
- return delta->io.ops->fastmap(&delta->io, orig_bio, bio, isector);
+ ret = delta->io.ops->fastmap(&delta->io, orig_bio, bio, isector);
+
+ if (ret)
+ return 1;
+
+ /*
+ * We reuse orig_bio->bi_next for a while.
+ * ploop_fast_end_io() nullifies it back.
+ */
+ BUG_ON(orig_bio->bi_next);
+ orig_bio->bi_next = (void *)delta;
+
+ return 0;
}
static inline unsigned int block_vecs(struct ploop_device * plo)
diff --git a/include/linux/ploop/ploop.h b/include/linux/ploop/ploop.h
index 0ea069a..3e1b59e 100644
--- a/include/linux/ploop/ploop.h
+++ b/include/linux/ploop/ploop.h
@@ -165,8 +165,16 @@ struct ploop_io_ops
void (*post_submit)(struct ploop_io *, struct ploop_request *);
int (*disable_merge)(struct ploop_io * io, sector_t isector, unsigned int len);
+
+ /*
+ * fastmap maps @isec to the sector on the underlining device.
+ * Before ->fastmap_end_io is called the mapper sector is stable.
+ * I.e., fastmap works as opening protection bracket,
+ * while fastmap_end_io is closing protection bracket.
+ */
int (*fastmap)(struct ploop_io * io, struct bio *orig_bio,
struct bio * bio, sector_t isec);
+ void (*fastmap_end_io)(struct ploop_io *io, struct bio *orig_bio);
void (*read_page)(struct ploop_io * io, struct ploop_request * preq,
struct page * page, sector_t sec);
More information about the Devel
mailing list