Description of problem: Use of force with volume create or volume start, creates brick directory even it is not present Version-Release number of selected component (if applicable): RHGS 3.2 How reproducible: Everytime Steps to Reproduce: 1. Run command gluster v create vol1 xx.xx.xx.xx:/test force 2. Even if /test is not present on xx.xx.xx.xx, it will create this path on root 3.Same thing is reproducible with gluster v start vol1 Actual results: Use of force with volume create or volume start creates brick directory even it is not present Expected results: Use of force should not create brick directory if it is not present Additional info:
While the expectation of creating the directory (even in root partition) with volume create force is valid, but we do have a bug in volume start force codepath where the brick is getting recreated. GlusterD actually doesn't create this brick path. We have an issue in the index xlator here. index_dir_create () int index_dir_create (xlator_t *this, const char *subdir) { int ret = 0; struct stat st = {0}; char fullpath[PATH_MAX] = {0}; char path[PATH_MAX] = {0}; char *dir = NULL; index_priv_t *priv = NULL; size_t len = 0; size_t pathlen = 0; priv = this->private; make_index_dir_path (priv->index_basepath, subdir, fullpath, sizeof (fullpath)); ret = sys_stat (fullpath, &st); if (!ret) { if (!S_ISDIR (st.st_mode)) ret = -2; goto out; } pathlen = strlen (fullpath); if ((pathlen > 1) && fullpath[pathlen - 1] == '/') fullpath[pathlen - 1] = '\0'; dir = strchr (fullpath, '/'); while (dir) { dir = strchr (dir + 1, '/'); if (dir) len = pathlen - strlen (dir); else len = pathlen; strncpy (path, fullpath, len); path[len] = '\0'; ret = sys_mkdir (path, 0600); ====> this is actually creating the brickpath. if (ret && (errno != EEXIST)) goto out; } ret = 0; out: if (ret == -1) { gf_msg (this->name, GF_LOG_ERROR, errno, INDEX_MSG_INDEX_DIR_CREATE_FAILED, "%s/%s: Failed to " "create", priv->index_basepath, subdir); } else if (ret == -2) { gf_msg (this->name, GF_LOG_ERROR, ENOTDIR, INDEX_MSG_INDEX_DIR_CREATE_FAILED, "%s/%s: Failed to " "create, path exists, not a directory ", priv->index_basepath, subdir); } return ret; }
https://review.gluster.org/17426
Downstream patch: https://code.engineering.redhat.com/gerrit/#/c/109354/
BUILD : 3.8.4-32 Creating the volume with force is valid even when the directory is not present. Created a volume and removed the brick by doing "rm -rf /bricks/brick1/testvol_1." Then started the volume with force option. The directory associated the volume is not re-created as expected. Hence marking it as verified
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2017:2774