Feature #48953
opencephfs-mirror: suppport snapshot mirror of subdirectories and/or ancestors of a mirrored directory
0%
Description
mgr/mirroring assigns directory paths to `cephfs-mirror` daemon instances. Right now, only a single mirror daemon is supported. So, all directories are assigned to one mirror instance. Snapshot synchronization in the mirror daemon is multithreaded. To support ancestor/subdir snapshot mirroring, mgr/mirroring can accept subdirectories or ancestors of already mirrored directories. However, the synchronization threads in the mirror daemon should guard picking a conflicting directory. Conflicting directories are either a subdirectory or an ancestor of a directory which is under synchronization -- E.g., if `/a/b/c` is under synchronization, then `/a/b` (upto /) and `/a/b/c/d` (i.e., anything under /a/b/c) are conflicting directories (note that `/a/b/c/` and `/a/b/cc/` are not conflicting dirs).
However, CephFS plans to support multiple mirror daemons for HA and concurrent synchronization. mgr/mirroring would distribute directories amongst mirror daemon instances, thereby possibly mapping subdirectories /a/b and /a/b/c/ to different mirror daemon instances. This is a problem. One way to fix this could be to map an entire subtree to a mirror daemon and have mirror daemons not choose conflicting directories. This "pinning" of an entire subtree to a mirror daemon instance may not be optimal. Another possible way would be to let mgr/mirroring assign directories to mirror instances without worrying about ancestor/subdir relation and have the mirror daemons coordinate amongst themselves when picking directories. This coordination can be based on acquiring locks at each path component of a directory. Something like acquiring a shared lock for each path component (except last) and finally an exclusive lock on the last component would ensure that a mirror daemon does not mirror a directory that conflicts across other mirror instances.