diff options
| author | Anand Avati <avati@redhat.com> | 2013-08-28 18:05:03 -0700 | 
|---|---|---|
| committer | Anand Avati <avati@redhat.com> | 2013-09-19 14:28:50 -0700 | 
| commit | 35b09786463629352ba10657a7888bc7da918474 (patch) | |
| tree | 6e7c5fc5ec758eb2e770a55d5bcaed4f7f21d4f4 /api/src/glfs.c | |
| parent | 999c177ffba9b940d977901ede3aaf55c236e255 (diff) | |
gfapi: implement a minimial glfs_fini()
At the very least, we should PARENT_DOWN on the currently active
graph and disconnect ourselves from glusterd.
Further cleanups underway.
Change-Id: I9276686a84b0975b5ce272b4cbec1b80920d5c5c
BUG: 1004519
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5903
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'api/src/glfs.c')
| -rw-r--r-- | api/src/glfs.c | 48 | 
1 files changed, 44 insertions, 4 deletions
diff --git a/api/src/glfs.c b/api/src/glfs.c index efda6b67eae..f93ebee4442 100644 --- a/api/src/glfs.c +++ b/api/src/glfs.c @@ -20,7 +20,6 @@    - handle SEEK_END failure in _lseek()    - handle umask (per filesystem?)    - make itables LRU based -  - implement glfs_fini()    - 0-copy for readv/writev    - reconcile the open/creat mess  */ @@ -51,6 +50,7 @@  #include "glfs.h"  #include "glfs-internal.h"  #include "hashfn.h" +#include "rpc-clnt.h"  static gf_boolean_t @@ -594,7 +594,47 @@ glfs_init (struct glfs *fs)  int  glfs_fini (struct glfs *fs)  { -	int  ret = -1; - -	return ret; +        int  ret = -1; +        xlator_t *subvol = NULL; +        glusterfs_ctx_t *ctx = NULL; +        call_pool_t *call_pool = NULL; +        int countdown = 100; + +        ctx = fs->ctx; + +        if (ctx->mgmt) { +                rpc_clnt_disable (ctx->mgmt); +                ctx->mgmt = NULL; +        } + +        __glfs_entry_fs (fs); + +        call_pool = fs->ctx->pool; + +        while (countdown--) { +                /* give some time for background frames to finish */ +                if (!call_pool->cnt) +                        break; +                usleep (100000); +        } +        /* leaked frames may exist, we ignore */ + +        subvol = glfs_active_subvol (fs); +        if (subvol) { +                /* PARENT_DOWN within glfs_subvol_done() is issued only +                   on graph switch (new graph should activiate and +                   decrement the extra @winds count taken in glfs_graph_setup() + +                   Since we are explicitly destroying, PARENT_DOWN is necessary +                */ +                xlator_notify (subvol, GF_EVENT_PARENT_DOWN, subvol, 0); +                /* TBD: wait for CHILD_DOWN before exiting, in case of +                   asynchronous cleanup like graceful socket disconnection +                   in the future. +                */ +        } + +        glfs_subvol_done (fs, subvol); + +        return ret;  }  | 
