%{_includedir}/cephfs/dump.h
%{_includedir}/cephfs/json.h
%{_includedir}/cephfs/keys_and_values.h
+%{_includedir}/cephfs/snap_types.h
%{_libdir}/libcephfs.so
%{_libdir}/libcephfs_proxy.so
%{_libdir}/pkgconfig/cephfs.pc
return _rmdir(snapdir.get(), name, perms, check_perms);
}
+int Client::do_snap_md_op(const char* path, const string& md_key,
+ const string& md_val, const unsigned int op_flag,
+ const UserPerm &perms)
+{
+ if (op_flag != CEPH_SNAP_MD_OP_CREATE &&
+ op_flag != (CEPH_SNAP_MD_OP_CREATE | CEPH_SNAP_MD_OP_EXCL) &&
+ op_flag != CEPH_SNAP_MD_OP_REMOVE) {
+ return -EINVAL;
+ }
+
+ RWRef_t mref_reader(mount_state, CLIENT_MOUNTING);
+ if (!mref_reader.is_state_satisfied())
+ return -ENOTCONN;
+
+ std::scoped_lock l(client_lock);
+
+ walk_dentry_result wdr;
+ if (int rc = path_walk(cwd, filepath(path), &wdr, perms, {}); rc < 0) {
+ return rc;
+ }
+
+ if (wdr.target->snapid == CEPH_NOSNAP) {
+ return -EINVAL;
+ }
+
+ MetaRequest *req = new MetaRequest(CEPH_MDS_OP_SNAP_METADATA);
+ req->set_filepath(wdr.getpath());
+ req->set_inode(wdr.diri);
+ req->set_dentry(wdr.dn);
+ req->dentry_drop = CEPH_CAP_FILE_SHARED;
+ req->dentry_unless = CEPH_CAP_FILE_EXCL;
+
+ bufferlist bl;
+ encode(md_key, bl);
+ encode(md_val, bl);
+ encode(op_flag, bl);
+ req->set_data(bl);
+
+ ldout(cct, 10) << __func__ << ": making request" << dendl;
+ int res = make_request(req, perms, &wdr.target);
+ ldout(cct, 10) << __func__ << ": result is " << res << dendl;
+
+ trim_cache();
+
+ ldout(cct, 8) << __func__ << "(" << wdr.getpath() << ", " << perms
+ << ") = " << res << dendl;
+
+ return res;
+}
+
// =============================
// expose caps
int mksnap(const char *path, const char *name, const UserPerm& perm,
mode_t mode=0, const std::map<std::string, std::string> &metadata={});
int rmsnap(const char *path, const char *name, const UserPerm& perm, bool check_perms=false);
+ int do_snap_md_op(const char* path, const std::string& md_key,
+ const std::string& md_val, const unsigned int op_flag,
+ const UserPerm &perms);
// cephx mds auth caps checking
int mds_check_access(std::string& path, const UserPerm& perms, int mask);
#include "msgr.h"
#include "rados.h"
#include "include/buffer.h" // for ceph::buffer::list
+#include "include/cephfs/snap_types.h"
/*
* The data structures defined here are shared between Linux kernel and
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*-
+// vim: ts=8 sw=2 sts=2 expandtab
+
+/*
+ * snap_types.h - Contains types associated with CephFS snapshots that needs
+ * to be imported in Cython (Python bindings). Placing these types in ceph_fs.h
+ * (where it was initially place) causes an Cython import error.
+ *
+ * LGPL-2.1 or LGPL-3.0
+ */
+
+
+/*
+ * snapshot metadata operations
+ *
+ * XXX: DON'T FORGET to update cephfs.pyx if any changes are made to this enum.
+ */
+enum {
+ // allows both, snap MD create and update
+ CEPH_SNAP_MD_OP_CREATE = (1 << 0),
+ // when passed with CREATE, allows only snap MD create and rejects
+ // update
+ CEPH_SNAP_MD_OP_EXCL = (1 << 1),
+ CEPH_SNAP_MD_OP_REMOVE = (1 << 2),
+};