Skip to content

Commit b9bc4b8

Browse files
Merge pull request #298 from cybozu-go/add-technical-note-2
Add technical notes for zeroout job
2 parents eb9fffa + dea3ab9 commit b9bc4b8

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

internal/controller/mantlebackup_controller.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,6 +2326,12 @@ func (r *MantleBackupReconciler) reconcileZeroOutJob(
23262326
return ctrl.Result{}, nil
23272327
}
23282328

2329+
// To run the zeroout job, the backup target volume must be accessed as a block device.
2330+
// In most cases, the backup target volume is accessed via filesystem type PV, and it
2331+
// cannot be accesses as a block device. Therefore, we use ceph-csi static PVC/PV
2332+
// to create a separate PVC/PV that accesses the same underlying RBD image as
2333+
// a block device.
2334+
// ref. https://github.com/ceph/ceph-csi/blob/8a82b6e76f2c620fceec2d49659d00c97c6ddbbe/docs/static-pvc.md
23292335
if err := r.createStaticPVIfNotExists(
23302336
ctx,
23312337
snapshotTarget.pv,
@@ -2499,6 +2505,17 @@ func (r *MantleBackupReconciler) createStaticPVCIfNotExists(
24992505
return nil
25002506
}
25012507

2508+
// createOrUpdateZeroOutJob creates or updates a Job that runs `blkdiscard -z`
2509+
// on the backup target volume before a full backup. This achieves the following:
2510+
// - Zero-fills the volume to erase any stale data that existed before the backup.
2511+
// - Releases the storage space that was allocated for that stale data.
2512+
// - Eliminates the risk of stale data causing issues in subsequent processing.
2513+
//
2514+
// The reason `blkdiscard -z` is used instead of plain `blkdiscard`:
2515+
// - `blkdiscard` does not guarantee that existing data is actually erased.
2516+
// - `blkdiscard -z`, like `blkdiscard`, releases all regions, but also zero-fills them.
2517+
//
2518+
// ref. https://www.spinics.net/lists/ceph-devel/msg61800.html
25022519
func (r *MantleBackupReconciler) createOrUpdateZeroOutJob(
25032520
ctx context.Context,
25042521
backup *mantlev1.MantleBackup,

0 commit comments

Comments
 (0)