summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
authorShreyas Siravara <sshreyas@fb.com>2017-09-02 21:12:42 -0700
committerShreyas Siravara <sshreyas@fb.com>2017-09-03 04:30:49 +0000
commita87e690e2b883b06240e01828dd83c86cbcd950f (patch)
treefe56c5a3fb0d19c0b3978752557adaaf1506f093 /xlators/cluster
parentc547fc214dfe280374f23f8063a1bf0b794f4977 (diff)
cluster/afr: Fix gfid unsplit code when renamed filename exceeds NAME_MAX
Summary: - We noticed some folks name their files all the way up to NAME_MAX (usually 255) and when split-brain is encountered, we fail to heal the file. - This diff puts an upper bound on the number of bytes we will snprintf into the buffer so that we do not fail the rename. - This is a port of D3646254 to 3.8 Test Plan: Prove test -- can show it fails without patch as well. Reviewers: #posix_storage, rwareing Reviewed By: rwareing Change-Id: I51c6b28374d4a3f21e29044cb727b4b1da7b69e1 Reviewed-on: https://review.gluster.org/18194 Reviewed-by: Shreyas Siravara <sshreyas@fb.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'xlators/cluster')
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-name.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-name.c b/xlators/cluster/afr/src/afr-self-heal-name.c
index 9ca56f8bd9d..8e5546a702f 100644
--- a/xlators/cluster/afr/src/afr-self-heal-name.c
+++ b/xlators/cluster/afr/src/afr-self-heal-name.c
@@ -84,6 +84,19 @@ _afr_sh_create_unsplit_loc (struct afr_reply *replies, const int child_idx,
ret = ENOMEM;
goto err;
}
+
+ /*
+ * Attempting to do a rename on a file that is too long
+ * will return ENAMETOOLONG and heals will fail. Therefore
+ * we should just limit the name to NAME_MAX
+ * knowing that the filename will be truncated.
+ */
+ if (new_name_len > NAME_MAX) {
+ gf_log ("afr", GF_LOG_WARNING,
+ "Filename too long, truncating to %d bytes.", NAME_MAX);
+ new_name_len = NAME_MAX;
+ }
+
snprintf (new_name, new_name_len, ".unsplit_%s_%s", tmp_gfid_str,
loc->name);
unsplit_loc->name = new_name;
@@ -376,7 +389,7 @@ __afr_selfheal_assign_gfid (xlator_t *this, inode_t *parent, uuid_t pargfid,
continue;
}
gf_log (this->name, GF_LOG_WARNING,
- "type[%d] = %d (not %d)", i,
+ "type[%d] = %d (not %d)", i,
replies[i].poststat.ia_type, ia_type);
if (ia_type != IA_INVAL) {
ret = -EIO;