Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libcephfs: add unmount function in cephfs.pyx #10774

Merged
merged 2 commits into from Sep 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/pybind/cephfs/cephfs.pyx
Expand Up @@ -108,6 +108,7 @@ cdef extern from "cephfs/libcephfs.h" nogil:
int ceph_conf_set(ceph_mount_info *cmount, const char *option, const char *value)

int ceph_mount(ceph_mount_info *cmount, const char *root)
int ceph_unmount(ceph_mount_info *cmount)
int ceph_fstat(ceph_mount_info *cmount, int fd, stat *stbuf)
int ceph_stat(ceph_mount_info *cmount, const char *path, stat *stbuf)
int ceph_statfs(ceph_mount_info *cmount, const char *path, statvfs *stbuf)
Expand Down Expand Up @@ -479,6 +480,14 @@ cdef class LibCephFS(object):
raise make_ex(ret, "error calling ceph_mount")
self.state = "mounted"

def unmount(self):
self.require_state("mounted")
with nogil:
ret = ceph_unmount(self.cluster)
if ret != 0:
raise make_ex(ret, "error calling ceph_unmount")
self.state = "initialized"

def statfs(self, path):
self.require_state("mounted")
path = cstr(path, 'path')
Expand Down
7 changes: 7 additions & 0 deletions src/test/pybind/test_cephfs.py
Expand Up @@ -206,3 +206,10 @@ def test_flock():
cephfs.close(fd2)

cephfs.close(fd)

@with_setup(setup_test)
def test_mount_unmount():
test_directory()
cephfs.unmount()
cephfs.mount()
test_open()