Skip to content

Commit

Permalink
Merge pull request #10774 from renhwztetecs/renhw-wip-cephfs-python-u…
Browse files Browse the repository at this point in the history
…mount

libcephfs: add unmount function in cephfs.pyx

Reviewed-by: John Spray <john.spray@redhat.com>
Reviewed-by: Ramana Raja <rraja@redhat.com>
  • Loading branch information
John Spray committed Sep 6, 2016
2 parents 4a3085b + 3091fa3 commit 9fda6d1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
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()

0 comments on commit 9fda6d1

Please sign in to comment.