mirror of
https://github.com/ceph/ceph
synced 2025-02-22 02:27:29 +00:00
client: add ceph_release, ceph_shutdown
Notes that ceph_shutdown() is now deprecated. Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
This commit is contained in:
parent
f1eef53200
commit
67bc92aa54
@ -108,8 +108,29 @@ int ceph_create_with_context(struct ceph_mount_info **cmount, struct CephContext
|
||||
int ceph_mount(struct ceph_mount_info *cmount, const char *root);
|
||||
|
||||
/**
|
||||
* Destroy the ceph mount handle. This should be called on completion of all
|
||||
* libcephfs functions.
|
||||
* Unmount a mount handle.
|
||||
*
|
||||
* @param cmount the mount handle
|
||||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
int ceph_unmount(struct ceph_mount_info *cmount);
|
||||
|
||||
/**
|
||||
* Destroy the mount handle.
|
||||
*
|
||||
* The handle should not be mounted. This should be called on completion of
|
||||
* all libcephfs functions.
|
||||
*
|
||||
* @param cmount the mount handle
|
||||
* @return 0 on success, negative error code on failure.
|
||||
*/
|
||||
int ceph_release(struct ceph_mount_info *cmount);
|
||||
|
||||
/**
|
||||
* Deprecated. Unmount and destroy the ceph mount handle. This should be
|
||||
* called on completion of all libcephfs functions.
|
||||
*
|
||||
* Equivalent to ceph_unmount() + ceph_release() without error handling.
|
||||
*
|
||||
* @param cmount the mount handle to shutdown
|
||||
*/
|
||||
|
@ -106,6 +106,14 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int unmount()
|
||||
{
|
||||
if (!mounted)
|
||||
return -ENOTCONN;
|
||||
shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void shutdown()
|
||||
{
|
||||
if (mounted) {
|
||||
@ -235,6 +243,19 @@ extern "C" int ceph_create(struct ceph_mount_info **cmount, const char * const i
|
||||
return ceph_create_with_context(cmount, cct);
|
||||
}
|
||||
|
||||
extern "C" int ceph_unmount(struct ceph_mount_info *cmount)
|
||||
{
|
||||
return cmount->unmount();
|
||||
}
|
||||
|
||||
extern "C" int ceph_release(struct ceph_mount_info *cmount)
|
||||
{
|
||||
if (cmount->is_mounted())
|
||||
return -EISCONN;
|
||||
delete cmount;
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" void ceph_shutdown(struct ceph_mount_info *cmount)
|
||||
{
|
||||
cmount->shutdown();
|
||||
|
@ -79,6 +79,63 @@ TEST(LibCephFS, Mount_double) {
|
||||
ceph_shutdown(cmount);
|
||||
}
|
||||
|
||||
TEST(LibCephFS, Mount_remount) {
|
||||
|
||||
struct ceph_mount_info *cmount;
|
||||
|
||||
ASSERT_EQ(0, ceph_create(&cmount, NULL));
|
||||
ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL));
|
||||
|
||||
CephContext *cct = ceph_get_mount_context(cmount);
|
||||
ASSERT_EQ(0, ceph_mount(cmount, "/"));
|
||||
ASSERT_EQ(0, ceph_unmount(cmount));
|
||||
|
||||
ASSERT_EQ(0, ceph_mount(cmount, "/"));
|
||||
ASSERT_EQ(cct, ceph_get_mount_context(cmount));
|
||||
|
||||
ceph_shutdown(cmount);
|
||||
}
|
||||
|
||||
TEST(LibCephFS, Unmount_unmounted) {
|
||||
|
||||
struct ceph_mount_info *cmount;
|
||||
|
||||
ASSERT_EQ(0, ceph_create(&cmount, NULL));
|
||||
ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL));
|
||||
ASSERT_EQ(-ENOTCONN, ceph_unmount(cmount));
|
||||
}
|
||||
|
||||
TEST(LibCephFS, Release_unmounted) {
|
||||
|
||||
struct ceph_mount_info *cmount;
|
||||
|
||||
ASSERT_EQ(0, ceph_create(&cmount, NULL));
|
||||
ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL));
|
||||
ASSERT_EQ(0, ceph_release(cmount));
|
||||
}
|
||||
|
||||
TEST(LibCephFS, Release_mounted) {
|
||||
|
||||
struct ceph_mount_info *cmount;
|
||||
|
||||
ASSERT_EQ(0, ceph_create(&cmount, NULL));
|
||||
ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL));
|
||||
ASSERT_EQ(0, ceph_mount(cmount, "/"));
|
||||
ASSERT_EQ(-EISCONN, ceph_release(cmount));
|
||||
ceph_shutdown(cmount);
|
||||
}
|
||||
|
||||
TEST(LibCephFS, Unmount_release) {
|
||||
|
||||
struct ceph_mount_info *cmount;
|
||||
|
||||
ASSERT_EQ(0, ceph_create(&cmount, NULL));
|
||||
ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL));
|
||||
ASSERT_EQ(0, ceph_mount(cmount, "/"));
|
||||
ASSERT_EQ(0, ceph_unmount(cmount));
|
||||
ASSERT_EQ(0, ceph_release(cmount));
|
||||
}
|
||||
|
||||
TEST(LibCephFS, Mount) {
|
||||
struct ceph_mount_info *cmount;
|
||||
ASSERT_EQ(ceph_create(&cmount, NULL), 0);
|
||||
|
Loading…
Reference in New Issue
Block a user