From: Rishabh Dave Date: Mon, 17 Nov 2025 12:23:56 +0000 (+0530) Subject: libcephfs: provide API to mutate snapshot metadata X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5726edbcf37ed9c3cf7835bdc3447c7a4fecec55;p=ceph.git libcephfs: provide API to mutate snapshot metadata Fixes: https://tracker.ceph.com/issues/66293 Signed-off-by: Rishabh Dave --- diff --git a/src/include/cephfs/libcephfs.h b/src/include/cephfs/libcephfs.h index 12c202ae12e..237cbbec0cd 100644 --- a/src/include/cephfs/libcephfs.h +++ b/src/include/cephfs/libcephfs.h @@ -861,6 +861,22 @@ int ceph_mksnap(struct ceph_mount_info *cmount, const char *path, const char *na */ int ceph_rmsnap(struct ceph_mount_info *cmount, const char *path, const char *name); +/** + * Add, update or remove snapshot metadata. + * + * @param cmount the ceph mount handle to use for making the directory. + * @param path the path of the snapshot. This must be either an absolute + * path or a path relative to CWD. + * @param mds_key key for the key-value pair in snapshot metadata. + * @param mds_val value for the key-value pair in snapshot metadata. + * @param op_flag unsigned integer to indicate whether metadata op is create, + * update or remove. + * @returns 0 on success or a negative return value on error. + */ +int ceph_do_snap_md_op(struct ceph_mount_info* cmount, const char* path, + const char* md_key, const char* md_val, + const unsigned int op_flag); + /** * Create multiple directories at once. * diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 0eeddd7167e..add7e30ad3a 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -1077,6 +1077,18 @@ extern "C" int ceph_rmsnap(struct ceph_mount_info *cmount, const char *path, con return cmount->get_client()->rmsnap(path, name, cmount->default_perms, true); } +extern "C" int ceph_do_snap_md_op(struct ceph_mount_info* cmount, + const char* path, const char* md_key, + const char* md_val, + const unsigned int op_flag) +{ + if (!cmount->is_mounted()) + return -ENOTCONN; + + return cmount->get_client()->do_snap_md_op(path, md_key, md_val, op_flag, + cmount->default_perms); +} + extern "C" int ceph_mkdirs(struct ceph_mount_info *cmount, const char *path, mode_t mode) { if (!cmount->is_mounted())