Patchwork [BUG:1475] mgmt/glusterd: remove volfile, brick file upon remove-brick

login
register
Submitter Pranith K
Date 2010-08-30 06:46:05
Message ID <20100830064605.GA29858@dev.gluster.com>
Download mbox | patch
Permalink /patch/4369/
State Accepted
Delegated to: Anand Avati
Headers show

Comments

Pranith K - 2010-08-30 06:46:05
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
---
 xlators/mgmt/glusterd/src/glusterd-op-sm.c  |    2 ++
 xlators/mgmt/glusterd/src/glusterd-store.h  |    3 +++
 xlators/mgmt/glusterd/src/glusterd-volgen.c |   19 +++++++++++++++++++
 xlators/mgmt/glusterd/src/glusterd-volgen.h |    4 ++++
 4 files changed, 28 insertions(+), 0 deletions(-)

Patch

diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index cb8acbe..20a5766 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -1917,6 +1917,8 @@  glusterd_op_remove_brick (gd1_mgmt_stage_op_req *req)
                         mybrick++;
                 }
 
+                glusterd_delete_volfile (volinfo, brickinfo);
+                glusterd_store_delete_brick (volinfo, brickinfo);
                 glusterd_brickinfo_delete (brickinfo);
                 volinfo->brick_count--;
 
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.h b/xlators/mgmt/glusterd/src/glusterd-store.h
index 10fb4a3..29caa89 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.h
+++ b/xlators/mgmt/glusterd/src/glusterd-store.h
@@ -100,5 +100,8 @@  int32_t
 glusterd_store_delete_peerinfo (glusterd_peerinfo_t *peerinfo);
 
 int32_t
+glusterd_store_delete_brick (glusterd_volinfo_t *volinfo,
+                             glusterd_brickinfo_t *brickinfo);
+int32_t
 glusterd_restore ();
 #endif
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 4a8bc6d..b8f2cb9 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -1688,3 +1688,22 @@  glusterd_create_volfiles (glusterd_volinfo_t *volinfo)
 out:
         return ret;
 }
+
+int
+glusterd_delete_volfile (glusterd_volinfo_t *volinfo,
+                         glusterd_brickinfo_t *brickinfo)
+{
+        char                    *filename  = NULL;
+
+        GF_ASSERT (volinfo);
+        GF_ASSERT (brickinfo);
+
+        filename = get_brick_filename (volinfo, brickinfo);
+
+        if (filename)
+                unlink (filename);
+
+        if (filename)
+                GF_FREE (filename);
+        return 0;
+}
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.h b/xlators/mgmt/glusterd/src/glusterd-volgen.h
index 24823d5..0ec8cc7 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.h
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.h
@@ -123,6 +123,10 @@ 
 int
 glusterd_create_volfiles (glusterd_volinfo_t *volinfo);
 
+int
+glusterd_delete_volfile (glusterd_volinfo_t *volinfo,
+                         glusterd_brickinfo_t *brickinfo);
+
 int32_t
 glusterd_default_xlator_options (glusterd_volinfo_t *volinfo);