]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-fuse: clean up when shutdown
authorJosh Durgin <jdurgin@redhat.com>
Sat, 24 Jan 2015 21:38:24 +0000 (13:38 -0800)
committerJosh Durgin <jdurgin@redhat.com>
Sat, 24 Jan 2015 23:39:20 +0000 (15:39 -0800)
Close all open images and librados state. This cleans up watches so we
don't need to wait for them to timeout in tests.

rbd-fuse is still a rough prototype, but this makes it slightly more
usable for testing.

Signed-off-by: Josh Durgin <jdurgin@redhat.com>
src/rbd_fuse/rbd-fuse.cc

index 56e01975c7a4d4db5b3aaaf7beb3e0f0e9df4d88..1fbe2781bcf6147e7065aaefe6c82884de50369e 100644 (file)
@@ -502,6 +502,21 @@ rbdfs_init(struct fuse_conn_info *conn)
        return NULL;
 }
 
+void
+rbdfs_destroy(void *unused)
+{
+       if (!gotrados)
+               return;
+       for (int i = 0; i < MAX_RBD_IMAGES; ++i) {
+               if (opentbl[i].image) {
+                       rbd_close(opentbl[i].image);
+                       opentbl[i].image = NULL;
+               }
+       }
+       rados_ioctx_destroy(ioctx);
+       rados_shutdown(cluster);
+}
+
 // return -errno on error.  fi->fh is not set until open time
 
 int
@@ -670,7 +685,7 @@ const static struct fuse_operations rbdfs_oper = {
   releasedir: rbdfs_releasedir,
   fsyncdir:   0,
   init:              rbdfs_init,
-  destroy:    0,
+  destroy:    rbdfs_destroy,
   access:     0,
   create:     rbdfs_create,
   /* skip unimplemented */