|
|
d1681e |
From 5b628662aa823770179c5592c182dd8b6acc9b1d Mon Sep 17 00:00:00 2001
|
|
|
d1681e |
From: N Balachandran <nbalacha@redhat.com>
|
|
|
d1681e |
Date: Thu, 23 Aug 2018 18:38:01 +0530
|
|
|
d1681e |
Subject: [PATCH 359/359] storage/posix: Increment trusted.pgfid in posix_mknod
|
|
|
d1681e |
|
|
|
d1681e |
The value of trusted.pgfid.xx was always set to 1
|
|
|
d1681e |
in posix_mknod. This is incorrect if posix_mknod
|
|
|
d1681e |
calls posix_create_link_if_gfid_exists.
|
|
|
d1681e |
|
|
|
d1681e |
upstream patch: https://review.gluster.org/#/c/glusterfs/+/20875/
|
|
|
d1681e |
|
|
|
d1681e |
> Change-Id: Ibe87ca6f155846b9a7c7abbfb1eb8b6a99a5eb68
|
|
|
d1681e |
> fixes: bz#1619720
|
|
|
d1681e |
> Signed-off-by: N Balachandran <nbalacha@redhat.com>
|
|
|
d1681e |
|
|
|
d1681e |
Change-Id: Iaa7ad44b918eed28718f62c312f2d8edf01b9256
|
|
|
d1681e |
BUG: 1620765
|
|
|
d1681e |
Signed-off-by: N Balachandran <nbalacha@redhat.com>
|
|
|
d1681e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/147891
|
|
|
d1681e |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
d1681e |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
d1681e |
---
|
|
|
d1681e |
tests/bugs/posix/bug-1619720.t | 57 +++++++++++++++++++++++++++++++++++++++
|
|
|
d1681e |
xlators/storage/posix/src/posix.c | 18 ++++++++++---
|
|
|
d1681e |
2 files changed, 71 insertions(+), 4 deletions(-)
|
|
|
d1681e |
create mode 100755 tests/bugs/posix/bug-1619720.t
|
|
|
d1681e |
|
|
|
d1681e |
diff --git a/tests/bugs/posix/bug-1619720.t b/tests/bugs/posix/bug-1619720.t
|
|
|
d1681e |
new file mode 100755
|
|
|
d1681e |
index 0000000..5e0d0f7
|
|
|
d1681e |
--- /dev/null
|
|
|
d1681e |
+++ b/tests/bugs/posix/bug-1619720.t
|
|
|
d1681e |
@@ -0,0 +1,57 @@
|
|
|
d1681e |
+#!/bin/bash
|
|
|
d1681e |
+
|
|
|
d1681e |
+. $(dirname $0)/../../include.rc
|
|
|
d1681e |
+. $(dirname $0)/../../dht.rc
|
|
|
d1681e |
+
|
|
|
d1681e |
+cleanup;
|
|
|
d1681e |
+
|
|
|
d1681e |
+
|
|
|
d1681e |
+# Test steps:
|
|
|
d1681e |
+# The test checks to make sure that the trusted.pgfid.xx xattr is set on
|
|
|
d1681e |
+# both the linkto and data files post the final rename.
|
|
|
d1681e |
+# The test creates files file-1 and file-3 so that src_hashed = dst_hashed,
|
|
|
d1681e |
+# src_cached = dst_cached and xxx_hashed != xxx_cached.
|
|
|
d1681e |
+# It then renames file-1 to file-3 which triggers the posix_mknod call
|
|
|
d1681e |
+# which updates the trusted.pgfid.xx xattr.
|
|
|
d1681e |
+
|
|
|
d1681e |
+
|
|
|
d1681e |
+TEST glusterd
|
|
|
d1681e |
+TEST pidof glusterd
|
|
|
d1681e |
+
|
|
|
d1681e |
+TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1
|
|
|
d1681e |
+TEST $CLI volume start $V0
|
|
|
d1681e |
+TEST $CLI volume set $V0 storage.build-pgfid on
|
|
|
d1681e |
+
|
|
|
d1681e |
+## Mount FUSE
|
|
|
d1681e |
+TEST glusterfs -s $H0 --volfile-id $V0 $M0;
|
|
|
d1681e |
+
|
|
|
d1681e |
+TEST mkdir $M0/tmp
|
|
|
d1681e |
+
|
|
|
d1681e |
+
|
|
|
d1681e |
+
|
|
|
d1681e |
+# Not the best way to do this but I need files which hash to the same subvol and
|
|
|
d1681e |
+# whose cached subvols are the same.
|
|
|
d1681e |
+# In a 2 subvol distributed volume, file-{1,3} hash to the same subvol.
|
|
|
d1681e |
+# file-2 will hash to the other subvol
|
|
|
d1681e |
+
|
|
|
d1681e |
+TEST touch $M0/tmp/file-2
|
|
|
d1681e |
+pgfid_xattr_name=$(getfattr -m "trusted.pgfid.*" $B0/${V0}1/tmp/file-2 | grep "trusted.pgfid")
|
|
|
d1681e |
+echo $pgfid_xattr_name
|
|
|
d1681e |
+
|
|
|
d1681e |
+
|
|
|
d1681e |
+TEST mv $M0/tmp/file-2 $M0/tmp/file-1
|
|
|
d1681e |
+TEST touch $M0/tmp/file-2
|
|
|
d1681e |
+TEST mv $M0/tmp/file-2 $M0/tmp/file-3
|
|
|
d1681e |
+
|
|
|
d1681e |
+# At this point, both the file-1 and file-3 data files exist on one subvol
|
|
|
d1681e |
+# and both linkto files on the other
|
|
|
d1681e |
+
|
|
|
d1681e |
+TEST mv -f $M0/tmp/file-1 $M0/tmp/file-3
|
|
|
d1681e |
+
|
|
|
d1681e |
+TEST getfattr -n $pgfid_xattr_name $B0/${V0}0/tmp/file-3
|
|
|
d1681e |
+TEST getfattr -n $pgfid_xattr_name $B0/${V0}1/tmp/file-3
|
|
|
d1681e |
+
|
|
|
d1681e |
+# Not required for the test but an extra check if required.
|
|
|
d1681e |
+# The linkto file was not renamed Without the fix.
|
|
|
d1681e |
+#TEST mv $M0/tmp/file-3 $M0/tmp/file-6
|
|
|
d1681e |
+cleanup;
|
|
|
d1681e |
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
|
|
|
d1681e |
index 28d2e6f..5088469 100644
|
|
|
d1681e |
--- a/xlators/storage/posix/src/posix.c
|
|
|
d1681e |
+++ b/xlators/storage/posix/src/posix.c
|
|
|
d1681e |
@@ -1427,6 +1427,7 @@ posix_mknod (call_frame_t *frame, xlator_t *this,
|
|
|
d1681e |
gf_boolean_t entry_created = _gf_false, gfid_set = _gf_false;
|
|
|
d1681e |
gf_boolean_t linked = _gf_false;
|
|
|
d1681e |
gf_loglevel_t level = GF_LOG_NONE;
|
|
|
d1681e |
+ posix_inode_ctx_t *ctx = NULL;
|
|
|
d1681e |
|
|
|
d1681e |
DECLARE_OLD_FS_ID_VAR;
|
|
|
d1681e |
|
|
|
d1681e |
@@ -1556,10 +1557,20 @@ post_op:
|
|
|
d1681e |
if (priv->update_pgfid_nlinks) {
|
|
|
d1681e |
MAKE_PGFID_XATTR_KEY (pgfid_xattr_key, PGFID_XATTR_KEY_PREFIX,
|
|
|
d1681e |
loc->pargfid);
|
|
|
d1681e |
- nlink_samepgfid = 1;
|
|
|
d1681e |
+ op_ret = posix_inode_ctx_get_all (loc->inode, this, &ctx;;
|
|
|
d1681e |
+ if (op_ret < 0) {
|
|
|
d1681e |
+ op_errno = ENOMEM;
|
|
|
d1681e |
+ goto out;
|
|
|
d1681e |
+ }
|
|
|
d1681e |
|
|
|
d1681e |
- SET_PGFID_XATTR (real_path, pgfid_xattr_key, nlink_samepgfid,
|
|
|
d1681e |
- XATTR_CREATE, op_ret, this, ignore);
|
|
|
d1681e |
+ pthread_mutex_lock (&ctx->pgfid_lock);
|
|
|
d1681e |
+ {
|
|
|
d1681e |
+ LINK_MODIFY_PGFID_XATTR (real_path, pgfid_xattr_key,
|
|
|
d1681e |
+ nlink_samepgfid, 0, op_ret,
|
|
|
d1681e |
+ this, unlock);
|
|
|
d1681e |
+ }
|
|
|
d1681e |
+unlock:
|
|
|
d1681e |
+ pthread_mutex_unlock (&ctx->pgfid_lock);
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
if (priv->gfid2path) {
|
|
|
d1681e |
@@ -1567,7 +1578,6 @@ post_op:
|
|
|
d1681e |
loc->name);
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
-ignore:
|
|
|
d1681e |
op_ret = posix_entry_create_xattr_set (this, real_path, xdata);
|
|
|
d1681e |
if (op_ret) {
|
|
|
d1681e |
if (errno != EEXIST)
|
|
|
d1681e |
--
|
|
|
d1681e |
1.8.3.1
|
|
|
d1681e |
|