Skip to content

CP-312874 SMAPIv3 storage-layer engine for SXM v3 snapshot migration - #7223

Open
LunfanZhang wants to merge 1 commit into
xapi-project:feature/sxm-v3from
LunfanZhang:private/luzhan/sxm-v3-p2-engine
Open

CP-312874 SMAPIv3 storage-layer engine for SXM v3 snapshot migration#7223
LunfanZhang wants to merge 1 commit into
xapi-project:feature/sxm-v3from
LunfanZhang:private/luzhan/sxm-v3-p2-engine

Conversation

@LunfanZhang

Copy link
Copy Markdown
Collaborator

Implement the new SXM v3 storage-layer migration for SMAPIv3 SRs, enabling a VDI to be mirrored together with its snapshot chain, including reverted/nested snapshot structures.

storage_smapiv3_migrate gains snapshot-tree discovery get_snapshot_tree, the DFS walk that mirrors/clones each node while keeping the storage chain advancing on the same leaf, NBD proxy export, and the send_start orchestration that drives the per-node mirroring. storage_migrate_helper.State is extended with a snapshot_relation type and set/get/remove_snapshot_mappings so the source->destination snapshot pairings recorded during mirroring can be retrieved later to restore snapshot metadata on the destination.

Design refer: https://github.com/xapi-project/xen-api/blob/feature/sxm-v3/doc/content/xapi/storage/sxm/sxm-v3-with-snapshot.md

Comment thread ocaml/xapi/storage_smapiv3_migrate.ml Outdated
~dest_sr:ctx.dest_sr ~mirror_vdi:working_vdi ~mirror_datapath:working_dp
~verify_dest:ctx.verify_dest
in
Unix.sleepf mirror_poll_interval ;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think it is better to use a new var here as it is not in a poll. It just waits a while for readiness.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

in
D.info "%s nbd_proxy_path: %s nbd_url %s" __FUNCTION__ nbd_proxy_path
nbd_uri ;
let mk = Local.DATA.mirror dbg sr vdi image_format live_vm nbd_uri in

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a sleep here like line 414?

@LunfanZhang LunfanZhang Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's last round of MIRROR, so it is fine to without sleep.

module MIRROR : SMAPIv2_MIRROR = struct
type context = unit

let send_start _ctx ~dbg ~task_id:_ ~dp ~sr ~vdi ~image_format ~mirror_vm

@changlei-li changlei-li Aug 14, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

send_start now blocks synchronously for the whole tree. Have you estimated the time it takes is acceptable when the tree is deep and wide?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QEMU mirror has better performance, so when the tree is deep and wide, the new SMAPIv3 will much faster then SMAPIv1.
fig1_snapshots

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were confounding removed from the comparison? Like using different hardware disks for both tests

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question - Both sources are now local SSD on hardware-identical hosts. The two hosts are the same model throughout: AMD EPYC 9124 16-Core (32 CPU, 3.0 GHz), 137 GB RAM, XenServer 9.0.0 same build, and — directly on your point — the local SR on both hosts is the same disk, sda = PERC H755N Front, 1.5 TB, non-rotational, behind an identical Broadcom MegaRAID SAS39xx controller. The xfs (V3) and ext4 (V1) SRs are filesystems on the same disk model and controller, not different hardware tiers.

Implement the new SXM v3 storage-layer migration for SMAPIv3 SRs,
enabling a VDI to be mirrored together with its snapshot chain,
including reverted/nested snapshot structures.

storage_smapiv3_migrate gains snapshot-tree discovery
(get_snapshot_tree), the DFS walk that mirrors/clones each node while
keeping the storage chain advancing on the same leaf, NBD proxy
export, and the send_start orchestration that drives the per-node
mirroring. storage_migrate_helper.State is extended with a
snapshot_relation type and set/get/remove_snapshot_mappings so the
source->destination snapshot pairings recorded during mirroring can
be retrieved later to restore snapshot metadata on the destination.

Signed-off-by: Lunfan Zhang[Lunfan.Zhang] <Lunfan.Zhang@cloud.com>
@LunfanZhang
LunfanZhang force-pushed the private/luzhan/sxm-v3-p2-engine branch from f687782 to c91f92c Compare August 17, 2026 05:38
Comment on lines +328 to +341
let set_snapshot_mappings mirror_id relations =
Xapi_stdext_threads.Threadext.Mutex.execute mutex (fun () ->
Hashtbl.replace snapshot_mappings mirror_id relations
)

let get_snapshot_mappings mirror_id =
Xapi_stdext_threads.Threadext.Mutex.execute mutex (fun () ->
Hashtbl.find_opt snapshot_mappings mirror_id |> Option.value ~default:[]
)

let remove_snapshot_mappings mirror_id =
Xapi_stdext_threads.Threadext.Mutex.execute mutex (fun () ->
Hashtbl.remove snapshot_mappings mirror_id
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we create a separate mutex for the snapshot_mappings table, rather than reuse the access_table mutex? It seems to me that they are independent, and this creates unnecessary contention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants