summaryrefslogtreecommitdiffstats
path: root/xlators/storage
diff options
context:
space:
mode:
authorMohammed Rafi KC <rkavunga@redhat.com>2015-11-30 19:02:54 +0530
committerDan Lambright <dlambrig@redhat.com>2016-02-22 06:50:54 -0800
commit6a565219fb1631e9b14c676458c8c04251886494 (patch)
tree28f02e728c851b95e61865f4ad882b612d09bb4e /xlators/storage
parentd48f1640b7c3932e0dfa979df8f25a5062ec4c37 (diff)
tier:unlink during migration
files deleted during promotion were not deleting as the files are moving from hashed to non-hashed On deleting a file that is undergoing promotion, the unlink call is not sent to the dst file as the hashed subvol == cached subvol. This causes the file to reappear once the migration is complete. This patch also fixes a problem with stale linkfile deleting. Backport of> >Change-Id: I4b02a498218c9d8eeaa4556fa4219e91e7fa71e5 >BUG: 1282390 >Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com> >Reviewed-on: http://review.gluster.org/12829 >Tested-by: NetBSD Build System <jenkins@build.gluster.org> >Tested-by: Gluster Build System <jenkins@build.gluster.com> >Reviewed-by: Dan Lambright <dlambrig@redhat.com> >Tested-by: Dan Lambright <dlambrig@redhat.com> (cherry picked from commit b5de382afa8c5777e455c7a376fc4f1f01d782d1) Change-Id: I951adb4d929926bcd646dd7574f7a2d41d57479d BUG: 1282388 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com> Reviewed-on: http://review.gluster.org/12991 Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Dan Lambright <dlambrig@redhat.com>
Diffstat (limited to 'xlators/storage')
-rw-r--r--xlators/storage/posix/src/posix.c159
-rw-r--r--xlators/storage/posix/src/posix.h6
2 files changed, 107 insertions, 58 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index bf3f8bd9b0b..473d73994e0 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -1607,6 +1607,66 @@ err:
return -1;
}
+static
+int32_t posix_set_iatt_in_dict (dict_t *dict, struct iatt *in_stbuf)
+{
+ int ret = -1;
+ struct iatt *stbuf = NULL;
+ int32_t len = sizeof(struct iatt);
+
+ if (!dict || !in_stbuf)
+ return ret;
+
+ stbuf = GF_CALLOC (1, len, gf_common_mt_char);
+ if (!stbuf)
+ return ret;
+
+ memcpy (stbuf, in_stbuf, len);
+
+ ret = dict_set_bin (dict, DHT_IATT_IN_XDATA_KEY, stbuf, len);
+ if (ret)
+ GF_FREE (stbuf);
+
+ return ret;
+}
+
+gf_boolean_t
+posix_skip_non_linkto_unlink (dict_t *xdata, loc_t *loc, char *key,
+ const char *linkto_xattr, struct iatt *stbuf,
+ const char *real_path)
+{
+ gf_boolean_t skip_unlink = _gf_false;
+ gf_boolean_t is_dht_linkto_file = _gf_false;
+ int unlink_if_linkto = 0;
+ ssize_t xattr_size = -1;
+ int op_ret = -1;
+
+ op_ret = dict_get_int32 (xdata, key,
+ &unlink_if_linkto);
+
+ if (!op_ret && unlink_if_linkto) {
+
+ is_dht_linkto_file = IS_DHT_LINKFILE_MODE (stbuf);
+ if (!is_dht_linkto_file)
+ return _gf_true;
+
+ LOCK (&loc->inode->lock);
+
+ xattr_size = sys_lgetxattr (real_path, linkto_xattr, NULL, 0);
+
+ if (xattr_size <= 0)
+ skip_unlink = _gf_true;
+
+ UNLOCK (&loc->inode->lock);
+
+ gf_msg ("posix", GF_LOG_INFO, 0, P_MSG_XATTR_STATUS,
+ "linkto_xattr status: %"PRIu32" for %s", skip_unlink,
+ real_path);
+ }
+ return skip_unlink;
+
+}
+
int32_t
posix_unlink (call_frame_t *frame, xlator_t *this,
loc_t *loc, int xflag, dict_t *xdata)
@@ -1617,6 +1677,7 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
char *par_path = NULL;
int32_t fd = -1;
struct iatt stbuf = {0,};
+ struct iatt postbuf = {0,};
struct posix_private *priv = NULL;
struct iatt preparent = {0,};
struct iatt postparent = {0,};
@@ -1625,6 +1686,7 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
int32_t unlink_if_linkto = 0;
int32_t check_open_fd = 0;
int32_t skip_unlink = 0;
+ int32_t fdstat_requested = 0;
int32_t ctr_link_req = 0;
ssize_t xattr_size = -1;
int32_t is_dht_linkto_file = 0;
@@ -1678,40 +1740,30 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
goto out;
}
}
-
-
- op_ret = dict_get_int32 (xdata, DHT_SKIP_NON_LINKTO_UNLINK,
- &unlink_if_linkto);
-
- if (!op_ret && unlink_if_linkto) {
-
- LOCK (&loc->inode->lock);
-
- xattr_size = sys_lgetxattr (real_path, LINKTO, NULL, 0);
-
- if (xattr_size <= 0) {
- skip_unlink = 1;
- } else {
- is_dht_linkto_file = IS_DHT_LINKFILE_MODE (&stbuf);
- if (!is_dht_linkto_file)
- skip_unlink = 1;
- }
-
- UNLOCK (&loc->inode->lock);
-
- gf_msg (this->name, GF_LOG_INFO, 0, P_MSG_XATTR_STATUS,
- "linkto_xattr status: %"PRIu32" for %s", skip_unlink,
- real_path);
-
- if (skip_unlink) {
- op_ret = -1;
- op_errno = EBUSY;
- goto out;
- }
+ /*
+ * If either of the function return true, skip_unlink.
+ * If first first function itself return true,
+ * we don't need to call second function, skip unlink.
+ */
+ skip_unlink = posix_skip_non_linkto_unlink (xdata, loc,
+ DHT_SKIP_NON_LINKTO_UNLINK,
+ DHT_LINKTO, &stbuf,
+ real_path);
+ skip_unlink = skip_unlink || posix_skip_non_linkto_unlink (xdata, loc,
+ TIER_SKIP_NON_LINKTO_UNLINK,
+ TIER_LINKTO, &stbuf,
+ real_path);
+ if (skip_unlink) {
+ op_ret = -1;
+ op_errno = EBUSY;
+ goto out;
}
+ if (xdata && dict_get (xdata, DHT_IATT_IN_XDATA_KEY)) {
+ fdstat_requested = 1;
+ }
- if (priv->background_unlink) {
+ if (priv->background_unlink || fdstat_requested) {
if (IA_ISREG (loc->inode->ia_type)) {
fd = open (real_path, O_RDONLY);
if (fd == -1) {
@@ -1754,6 +1806,24 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
goto out;
}
+ unwind_dict = dict_new ();
+ if (!unwind_dict) {
+ op_errno = -ENOMEM;
+ op_ret = -1;
+ goto out;
+ }
+ if (fdstat_requested) {
+ op_ret = posix_fdstat (this, fd, &postbuf);
+ if (op_ret == -1) {
+ op_errno = errno;
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ P_MSG_FSTAT_FAILED, "post operation "
+ "fstat failed on fd=%d", fd);
+ goto out;
+ }
+ op_ret = posix_set_iatt_in_dict (unwind_dict, &postbuf);
+ }
+
op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
if (op_ret == -1) {
op_errno = errno;
@@ -1763,7 +1833,7 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
goto out;
}
- unwind_dict = posix_dict_set_nlink (xdata, NULL, stbuf.ia_nlink);
+ unwind_dict = posix_dict_set_nlink (xdata, unwind_dict, stbuf.ia_nlink);
op_ret = 0;
out:
SET_TO_OLD_FS_ID ();
@@ -3362,31 +3432,6 @@ map_xattr_flags(int flags)
}
#endif
-static
-int32_t posix_set_iatt_in_dict (dict_t *dict, struct iatt *in_stbuf)
-{
- int ret = -1;
- struct iatt *stbuf = NULL;
- int32_t len = sizeof(struct iatt);
-
- if (!dict || !in_stbuf)
- return ret;
-
- stbuf = GF_CALLOC (1, len, gf_common_mt_char);
- if (!stbuf)
- return ret;
-
- memcpy (stbuf, in_stbuf, len);
-
- ret = dict_set_bin (dict, DHT_IATT_IN_XDATA_KEY, stbuf, len);
- if (ret)
- GF_FREE (stbuf);
-
- return ret;
-}
-
-
-
int32_t
posix_setxattr (call_frame_t *frame, xlator_t *this,
loc_t *loc, dict_t *dict, int flags, dict_t *xdata)
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
index 9ed82fc4bbc..80ddab64b50 100644
--- a/xlators/storage/posix/src/posix.h
+++ b/xlators/storage/posix/src/posix.h
@@ -55,7 +55,11 @@
#define ACL_BUFFER_MAX 4096 /* size of character buffer */
-#define LINKTO "trusted.glusterfs.dht.linkto"
+#define DHT_LINKTO "trusted.glusterfs.dht.linkto"
+/*
+ * TIER_MODE need to be changed when we stack tiers
+ */
+#define TIER_LINKTO "trusted.tier.tier-dht.linkto"
#define POSIX_GFID_HANDLE_SIZE(base_path_len) (base_path_len + SLEN("/") \
+ SLEN(GF_HIDDEN_PATH) + SLEN("/") \