Proposed blksnap mechanism for creating snapshots of block devices in Linux

The company Veeam, which produces software for backup and disaster recovery, proposed the blksnap module for inclusion in the Linux kernel with the implementation of the mechanism for creating snapshots of block devices and tracking changes in block devices. To work with snapshots, the blksnap command line utility and the blksnap.so library have been prepared, allowing you to interact with the kernel module through ioctl calls from user space.

The purpose of creating the module is to organize backup of drives and virtual disks without stopping work - the module allows you to capture the current state of the entire block device in a snapshot, providing an isolated slice for backup that does not depend on ongoing changes. An important feature of blksnap is the ability to simultaneously create snapshots for several block devices at once, which allows not only to ensure data integrity at the block device level, but also to achieve consistency in the state of different block devices in the backup.

To track changes to the block device subsystem (bdev), the ability to attach filters that allow you to intercept I / O requests has been added. blksnap implements a filter that intercepts write requests, reads the old value, and saves it in a separate list of changes that determines the state of the snapshot. With this approach, the logic of working with a block device does not change, the recording in the original block device is performed as is, regardless of snapshots, which eliminates the possibility of data corruption and avoids problems even in the event of unpredictable critical errors in blksnap and overflow of the space allocated for changes.

The module also allows you to determine which blocks were changed between the last and any previous snapshot, which can be useful for implementing incremental backups. To save changes, relative to the state of the snapshot, an arbitrary range of sectors can be allocated on any block device, which allows you to save changes to separate files within the FS on block devices. The size of the area for storing changes can be increased at any time, even after the snapshot has been created.

Blksnap is based on the code of the veeamsnap module, which is part of the Veeam Agent for Linux product, but redesigned for the specifics of delivery in the main part of the Linux kernel. The conceptual difference between blksnap and veeamsnap is the use of a system of filters attached to a block device, instead of a separate bdevfilter component that intercepts I/O.

Source: opennet.ru

Add a comment