return 0;
}
+int64_t Client::get_default_pool_id()
+{
+ Mutex::Locker lock(client_lock);
+ /* first data pool is the default */
+ return mdsmap->get_first_data_pool();
+}
// expose osdmap
int get_file_stripe_address(int fd, loff_t offset, vector<entity_addr_t>& address);
int get_file_extent_osds(int fd, loff_t off, loff_t *len, vector<int>& osds);
int get_osd_addr(int osd, entity_addr_t& addr);
+
+ // expose mdsmap
+ int64_t get_default_pool_id();
// expose osdmap
int get_local_osd();
*/
int ceph_get_path_pool_name(struct ceph_mount_info *cmount, const char *path, char *buf, size_t buflen);
+/**
+ * Get the default pool name of cephfs
+ * Write the name of the default pool to the buffer. If buflen is 0, return
+ * a suggested length for the buffer.
+ * @param cmount the ceph mount handle to use.
+ * @param buf buffer to store the name in
+ * @param buflen size of the buffer
+ * @returns length in bytes of the pool name, or -ERANGE if the buffer is not large enough.
+ */
+int ceph_get_default_data_pool_name(struct ceph_mount_info *cmount, char *buf, size_t buflen);
+
/**
* Get the file layout from an open file descriptor.
*
}
private static native String native_ceph_get_file_pool_name(long mountp, int fd);
+
+ /**
+ * Get the default data pool of cephfs.
+ *
+ * @return The pool name.
+ */
+ public String get_default_data_pool_name() {
+ rlock.lock();
+ try {
+ return native_ceph_get_default_data_pool_name(instance_ptr);
+ } finally {
+ rlock.unlock();
+ }
+ }
+
+ private static native String native_ceph_get_default_data_pool_name(long mountp);
/**
* Get the replication of a file.
return pool;
}
+/**
+ * Class: com_ceph_fs_CephMount
+ * Method: native_ceph_get_default_data_pool_name
+ * Signature: (J)Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_com_ceph_fs_CephMount_native_1ceph_1get_1default_1data_1pool_1name
+ (JNIEnv *env, jclass clz, jlong j_mntp)
+{
+ struct ceph_mount_info *cmount = get_ceph_mount(j_mntp);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ jstring pool = NULL;
+ int ret, buflen = 0;
+ char *buf = NULL;
+
+ CHECK_MOUNTED(cmount, NULL);
+
+ ldout(cct, 10) << "jni: get_default_data_pool_name" << dendl;
+
+ ret = ceph_get_default_data_pool_name(cmount, NULL, 0);
+ if (ret < 0)
+ goto out;
+ buflen = ret;
+ buf = new (std::nothrow) char[buflen+1]; /* +1 for '\0' */
+ if (!buf) {
+ cephThrowOutOfMemory(env, "head allocation failed");
+ goto out;
+ }
+ memset(buf, 0, (buflen+1)*sizeof(*buf));
+ ret = ceph_get_default_data_pool_name(cmount, buf, buflen);
+
+ ldout(cct, 10) << "jni: get_default_data_pool_name: ret " << ret << dendl;
+
+ if (ret < 0)
+ handle_error(env, ret);
+ else
+ pool = env->NewStringUTF(buf);
+
+out:
+ if (buf)
+ delete [] buf;
+
+ return pool;
+}
+
+
/*
* Class: com_ceph_fs_CephMount
* Method: native_ceph_localize_reads
return name.length();
}
+extern "C" int ceph_get_default_data_pool_name(struct ceph_mount_info *cmount, char *buf, size_t len)
+{
+ if (!cmount->is_mounted())
+ return -ENOTCONN;
+ int64_t pool_id = cmount->get_client()->get_default_pool_id();
+
+ string name = cmount->get_client()->get_pool_name(pool_id);
+ if (len == 0)
+ return name.length();
+ if (name.length() > len)
+ return -ERANGE;
+ strncpy(buf, name.c_str(), len);
+ return name.length();
+}
+
extern "C" int ceph_get_file_layout(struct ceph_mount_info *cmount, int fh, int *stripe_unit, int *stripe_count, int *object_size, int *pg_pool)
{
file_layout_t l;