diff options
| author | Ravishankar N <ravishankar@redhat.com> | 2015-08-17 10:29:19 +0000 | 
|---|---|---|
| committer | Vijay Bellur <vbellur@redhat.com> | 2015-08-27 01:20:12 -0700 | 
| commit | 2208ed44a689b95bf236e6e492aa85f9bbb549a5 (patch) | |
| tree | 2a95ba1c5b7ca62b0b9f21a422478a741e3c8808 | |
| parent | 6aa0e72198e83d6dd849027fd3d0038037810065 (diff) | |
heal: Add check for healing directories in split-brain
Backport of http://review.gluster.org/#/c/11937/
1. Healing using  `bigger-file' option does not make much sense for directories,
hence disallow it and notify the user.
2. Healing using 'source-brick' option for directories performs a conservative
merge. Notify the user about it.
Change-Id: I0acff7b438bdb256615ed0f40d45694f37a77dd5
BUG: 1256605
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
(cherry picked from commit 97bae6371b5e841f03a61d6700033f40afd5cdc7)
Reviewed-on: http://review.gluster.org/12007
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
| -rw-r--r-- | heal/src/glfs-heal.c | 28 | 
1 files changed, 27 insertions, 1 deletions
diff --git a/heal/src/glfs-heal.c b/heal/src/glfs-heal.c index bc76518d539..3b3003ece67 100644 --- a/heal/src/glfs-heal.c +++ b/heal/src/glfs-heal.c @@ -535,6 +535,27 @@ glfsh_gather_heal_info (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc,  }  int +_validate_directory (dict_t *xattr_req, char *file) +{ +        int heal_op = -1; +        int ret = 0; + +        ret = dict_get_int32 (xattr_req, "heal-op", &heal_op); +        if (ret) +                return ret; + +        if (heal_op == GF_SHD_OP_SBRAIN_HEAL_FROM_BIGGER_FILE) { +                printf ("'bigger-file' not a valid option for directories.\n"); +                ret = -1; +        } else if (heal_op == GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK) { +                printf ("'source-brick' option used on a directory (%s). " +                        "Performing conservative merge.\n", file); +        } + +        return ret; +} + +int  glfsh_heal_splitbrain_file (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc,                             char *file, dict_t *xattr_req)  { @@ -556,7 +577,7 @@ glfsh_heal_splitbrain_file (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc,                  gf_uuid_parse (path, loc.gfid);                  loc.path = gf_strdup (uuid_utoa (loc.gfid));                  loc.inode = inode_new (rootloc->inode->table); -                ret = syncop_lookup (xl, &loc, 0, 0, xattr_req, &xattr_rsp); +                ret = syncop_lookup (xl, &loc, &iatt, 0, xattr_req, &xattr_rsp);                  if (ret) {                          op_errno = -ret;                          printf ("Lookup failed on %s:%s.\n", file, @@ -580,6 +601,11 @@ retry:                  }          } +        if (iatt.ia_type == IA_IFDIR) { +                ret = _validate_directory (xattr_req, file); +                if (ret) +                        goto out; +        }          ret = syncop_getxattr (xl, &loc, &xattr_rsp, GF_AFR_HEAL_SBRAIN,                                 xattr_req, NULL);          if (ret) {  | 
