]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
libcephfs: provide API to mutate snapshot metadata
authorRishabh Dave <ridave@redhat.com>
Mon, 17 Nov 2025 12:23:56 +0000 (17:53 +0530)
committerRishabh Dave <ridave@redhat.com>
Thu, 18 Jun 2026 06:27:45 +0000 (11:57 +0530)
Fixes: https://tracker.ceph.com/issues/66293
Signed-off-by: Rishabh Dave <ridave@redhat.com>
src/include/cephfs/libcephfs.h
src/libcephfs.cc

index 12c202ae12eabb5f3596bfd59f694e96e19b5bd8..237cbbec0cd2d9e64c6b940f0148cf2a42dc34c0 100644 (file)
@@ -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.
  *
index 0eeddd7167e02f442846cbac85df4fcec8d0449a..add7e30ad3ae4794df753844aa2681d8febc71c1 100644 (file)
@@ -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())