Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
dm-qcow2: Introduce driver to create block devices over QCOW2 files
Driver for attaching QCOW2 files as block devices. It cares
about performance-critical actions like actual IO and
snapshot COW and merge, while complex and fast metadata-related
service actions (e.g., snapshot creation and resize)
are delegated to userspace.

Suspend/resume is a barrier between the driver and userspace.
On suspend the driver brings QCOW2 images in consistent state,
while on resume it re-reads metadata from QCOW2 images.
Userspace proceeds metadata-related service actions while
device is suspended, and it never does this on running device.
This demarcation allows driver code to be pretty small.

Implemented full support for QCOW2 format: compressed clusters,
internal snapshots, backing files and extended L2 table.
Current limitations: the lowest backing file must be QCOW2
(RAW backing files are not supported), cluster and subcluster
sizes for all backing files in chain must be equal (I'm going
to change this in the future).

Also, implemented backward merge (from top image to its backing file).

The driver is request based, since this allows to use blk-mq
merging of request. Driver splits requests itself, and every
request (i.e., qio) after splitting fits a single cluster.
(In some cases it is worth to create bigger splits, and this
is a subject of further optimizations).

Signed-off-by: Kirill Tkhai <kirill.tkhai@openvz.org>
  • Loading branch information
Kirill Tkhai authored and intel-lab-lkp committed Mar 28, 2022
1 parent 9e3a5b6 commit c41a15c
Show file tree
Hide file tree
Showing 6 changed files with 6,052 additions and 0 deletions.
17 changes: 17 additions & 0 deletions drivers/md/Kconfig
Expand Up @@ -653,4 +653,21 @@ config DM_AUDIT
Enables audit logging of several security relevant events in the
particular device-mapper targets, especially the integrity target.

config DM_QCOW2
tristate "QCOW2 target support"
depends on BLK_DEV_DM
depends on ZLIB_INFLATE
help
Driver for attaching QCOW2 files as block devices. It cares
about performance-critical actions like actual IO and
snapshot COW and merge, while complex and fast metadata-related
service actions (e.g., snapshot creation and resize)
are delegated to userspace.

Suspend/resume is a barrier between the driver and userspace.
On suspend the driver brings QCOW2 images in consistent state,
while on resume it re-reads metadata from QCOW2 images. Thus,
userspace proceeds metadata-related service actions, while
device is suspended.

endif # MD
2 changes: 2 additions & 0 deletions drivers/md/Makefile
Expand Up @@ -26,6 +26,7 @@ dm-era-y += dm-era-target.o
dm-clone-y += dm-clone-target.o dm-clone-metadata.o
dm-verity-y += dm-verity-target.o
dm-zoned-y += dm-zoned-target.o dm-zoned-metadata.o dm-zoned-reclaim.o
dm-qcow2-y += dm-qcow2-target.o dm-qcow2-map.o dm-qcow2-cmd.o

md-mod-y += md.o md-bitmap.o
raid456-y += raid5.o raid5-cache.o raid5-ppl.o
Expand Down Expand Up @@ -83,6 +84,7 @@ obj-$(CONFIG_DM_LOG_WRITES) += dm-log-writes.o
obj-$(CONFIG_DM_INTEGRITY) += dm-integrity.o
obj-$(CONFIG_DM_ZONED) += dm-zoned.o
obj-$(CONFIG_DM_WRITECACHE) += dm-writecache.o
obj-$(CONFIG_DM_QCOW2) += dm-qcow2.o

ifeq ($(CONFIG_DM_INIT),y)
dm-mod-objs += dm-init.o
Expand Down

0 comments on commit c41a15c

Please sign in to comment.