Skip to content

Commit 4bf6e72

Browse files
authored
Merge pull request ceph#64345 from dparmar18/i71740
mds, client, mgr/volumes: toggle snapshot visibility for subvolume based paths Reviewed-by: Patrick Donnelly <[email protected]> Reviewed-by: Venky Shankar <[email protected]>
2 parents a0061bb + c31990d commit 4bf6e72

File tree

23 files changed

+1569
-17
lines changed

23 files changed

+1569
-17
lines changed

doc/cephfs/client-config-ref.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Client Config Reference
5656
.. confval:: client_readahead_max_periods
5757
.. confval:: client_readahead_min
5858
.. confval:: client_reconnect_stale
59+
.. confval:: client_respect_subvolume_snapshot_visibility
5960
.. confval:: client_snapdir
6061
.. confval:: client_tick_interval
6162
.. confval:: client_use_random_mds

doc/cephfs/fs-volumes.rst

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,97 @@ following command.
10701070

10711071
.. _subvol-pinning:
10721072

1073+
Controlling Subvolume Snapshot Visibility
1074+
-----------------------------------------
1075+
1076+
.. note:: This functionality is currently supported only for FUSE/libcephfs clients.
1077+
Kernel client support is planned: progress can be tracked at
1078+
https://tracker.ceph.com/issues/72589.
1079+
1080+
Snapshots of a subvolume can be hidden from compatible clients by
1081+
performing two actions:
1082+
1) Set the subvolume's ``snapshot_visibility`` flag to ``false`` (default is ``true``).
1083+
2) Set the client-side configuration option ``client_respect_subvolume_snapshot_visibility``
1084+
to ``true`` for the intended client(s) (default is ``false``).
1085+
1086+
The CLI command for toggling ``snapshot_visibility`` is as follows:
1087+
1088+
.. prompt:: bash #
1089+
1090+
ceph fs subvolume snapshot_visibility set <vol_name> <sub_volname> [--group-name <subvol_group_name>] <true|false>
1091+
1092+
This command updates the internal vxattr ``ceph.dir.subvolume.snaps.visible``
1093+
and sets the ``is_snapdir_visible`` flag within the dirinode(i.e. subvolume’s)
1094+
SnapRealm.
1095+
1096+
.. note:: Although direct modification is possible, using the subvolume API is
1097+
recommended. It is more convenient and avoids potential ``EPERM``
1098+
(Permission Denied) errors when setting vxattrs, especially if the
1099+
client lacks the required capabilities. The way to set this vxattr
1100+
is:
1101+
1102+
.. prompt:: bash #
1103+
1104+
setfattr -n ceph.dir.subvolume.snaps.visible -v 0|1 <subvolume_path>
1105+
1106+
The ``client_respect_subvolume_snapshot_visibility`` setting determines whether
1107+
a client honors the subvolume's visibility flag. This can be set per-client
1108+
using:
1109+
1110+
.. prompt:: bash #
1111+
1112+
ceph config set client.<id> client_respect_subvolume_snapshot_visibility <true|false>
1113+
1114+
.. note:: The `id` over here is a CephX user.
1115+
1116+
To set the ``client_respect_subvolume_snapshot_visibility`` config globally
1117+
across all the clients, issue the command without specifying an ``id``:
1118+
1119+
.. prompt:: bash #
1120+
1121+
ceph config set client client_respect_subvolume_snapshot_visibility <true|false>
1122+
1123+
.. note:: The MGR daemon operates as a privileged CephFS client and therefore
1124+
bypasses snapshot visibility restrictions. This behavior is required
1125+
to ensure the reliable execution of operations such as snap-schedule
1126+
and snapshot cloning. As a result, modifying the
1127+
``client_respect_subvolume_snapshot_visibility`` configuration option
1128+
has no effect on the CephFS instance running within the MGR daemon.
1129+
1130+
How to disable snapshot visibility on a subvolume?
1131+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1132+
1133+
Say, for instance, to prevent snapshots of subvolume ``sv1`` under a volume
1134+
``vol1`` from being visible to a client authenticated with the CephX user
1135+
``client.user1``, first disable the ``snapshot_visibility`` flag on ``sv1``
1136+
using:
1137+
1138+
.. prompt:: bash #
1139+
1140+
ceph fs subvolume snapshot_visibility set vol1 sv1 false
1141+
1142+
Then toggle the client config using:
1143+
1144+
.. prompt:: bash #
1145+
1146+
ceph config set client.user1 client_respect_subvolume_snapshot_visibility true
1147+
1148+
This effectively prevents the client mounted using ``client.user1`` from
1149+
performing a ``lookup()`` call on the ``.snap`` directory of the ``sv1``
1150+
subvolume, thereby hiding its snapshots.
1151+
1152+
.. note:: When a subvolume's snapshot visibility is disabled, any snapshot
1153+
operations including snapshot creation, deletion, or renaming are
1154+
prevented, since they rely on a successful ``.snap`` directory
1155+
lookup.
1156+
1157+
.. note:: A subvolume’s snapshot visibility is determined entirely by whether
1158+
the client is configured to respect the subvolume’s ``snapshot_visibility``
1159+
flag. That is, regardless of whether the flag is set to ``true`` or
1160+
``false`` on the subvolume, it will be ignored unless the client’s
1161+
``client_respect_subvolume_snapshot_visibility`` setting is
1162+
explicitly set to ``true``.
1163+
10731164
Pinning Subvolumes and Subvolume Groups
10741165
---------------------------------------
10751166

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
tasks:
2+
- cephfs_test_runner:
3+
fail_on_skip: false
4+
modules:
5+
- tasks.cephfs.test_volumes.TestSubvolumeSnapshotVisibilityBasic
6+
- tasks.cephfs.test_volumes.TestSubvolumeSnapshotVisibility
7+
- tasks.cephfs.test_volumes.TestSubvolumeSnapshotVisibilityMgr

0 commit comments

Comments
 (0)