From: Josh Durgin Date: Sat, 24 Jan 2015 21:38:24 +0000 (-0800) Subject: rbd-fuse: clean up when shutdown X-Git-Tag: v0.93~134^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4e88414468eb403951877c36537c115155d5d528;p=ceph.git rbd-fuse: clean up when shutdown 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 --- diff --git a/src/rbd_fuse/rbd-fuse.cc b/src/rbd_fuse/rbd-fuse.cc index 56e01975c7a4..1fbe2781bcf6 100644 --- a/src/rbd_fuse/rbd-fuse.cc +++ b/src/rbd_fuse/rbd-fuse.cc @@ -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 */