Patchwork [BUG:2042] mgmt/glusterd: Honor log filename set during add-brick

login
register
Submitter Vijay Bellur
Date 2010-10-30 17:41:36
Message ID <20101030174136.GA31621@dev.gluster.com>
Download mbox | patch
Permalink /patch/5606/
State Accepted
Headers show

Comments

Vijay Bellur - 2010-10-30 17:41:36
Signed-off-by: Vijay Bellur <vijay@gluster.com>
---
 xlators/mgmt/glusterd/src/glusterd-op-sm.c |   18 +++++++++++++-----
 xlators/mgmt/glusterd/src/glusterd-utils.c |    8 +++++++-
 xlators/mgmt/glusterd/src/glusterd.h       |    1 +
 3 files changed, 21 insertions(+), 6 deletions(-)

Patch

diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index bc9cb33..681cba9 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -3560,9 +3560,20 @@  glusterd_op_log_filename (gd1_mgmt_stage_op_req *req)
         if (ret)
                 goto out;
 
-        if (!strchr (brick, ':'))
+        ret  = glusterd_volinfo_find (volname, &volinfo);
+        if (ret)
+                goto out;
+
+        if (!strchr (brick, ':')) {
                 brick = NULL;
-        else {
+                ret = stat (path, &stbuf);
+                if (ret || !S_ISDIR (stbuf.st_mode)) {
+                        ret = -1;
+                        gf_log ("", GF_LOG_ERROR, "not a directory");
+                        goto out;
+                }
+                volinfo->logdir = gf_strdup (path);
+        } else {
                 ret = glusterd_brickinfo_from_brick (brick, &tmpbrkinfo);
                 if (ret) {
                         gf_log ("glusterd", GF_LOG_ERROR,
@@ -3571,9 +3582,6 @@  glusterd_op_log_filename (gd1_mgmt_stage_op_req *req)
                 }
         }
 
-        ret  = glusterd_volinfo_find (volname, &volinfo);
-        if (ret)
-                goto out;
 
         ret = -1;
         list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index cffd9db..d5209f4 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -574,6 +574,8 @@  glusterd_volinfo_delete (glusterd_volinfo_t *volinfo)
         if (ret)
                 goto out;
         dict_unref (volinfo->dict);
+        if (volinfo->logdir)
+                GF_FREE (volinfo->logdir);
 
         GF_FREE (volinfo);
         ret = 0;
@@ -971,7 +973,11 @@  glusterd_volume_start_glusterfs (glusterd_volinfo_t  *volinfo,
         snprintf (volfile, PATH_MAX, "%s.%s.%s", volinfo->volname,
                   brickinfo->hostname, exp_path);
 
-        if (!brickinfo->logfile) {
+        if (!brickinfo->logfile && volinfo->logdir) {
+                snprintf (logfile, PATH_MAX, "%s/%s.log", volinfo->logdir,
+                                                          exp_path);
+                brickinfo->logfile = gf_strdup (logfile);
+        } else if (!brickinfo->logfile) {
                 snprintf (logfile, PATH_MAX, "%s/logs/bricks/%s.log",
                           priv->workdir, exp_path);
                 brickinfo->logfile = gf_strdup (logfile);
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index 11774a3..185d362 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -192,6 +192,7 @@  struct glusterd_volinfo_ {
         dict_t                  *dict;
 
         uuid_t                  volume_id;
+        char                    *logdir;
 };
 
 typedef struct glusterd_volinfo_ glusterd_volinfo_t;