summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2014-09-02 09:40:44 +0530
committergluster-ant <bugzilla-bot@gluster.org>2014-09-02 09:40:44 +0530
commitf10590fdaa1a9504a2ff2456f63dc4b1325010e7 (patch)
tree56b7ab42cf281407841de26dd6dc900a412b1326
parentc0399068747d5f4dc8db522f180d778344743dc4 (diff)
downloadglusterfs-f10590fdaa1a9504a2ff2456f63dc4b1325010e7.tar.gz
glusterfs-f10590fdaa1a9504a2ff2456f63dc4b1325010e7.tar.xz
glusterfs-f10590fdaa1a9504a2ff2456f63dc4b1325010e7.zip
storage/posix: Prefer gfid links for inode-handle
Problem: File path could change by other entry operations in-flight so if renames are in progress at the time of other operations like open, it may lead to failures. We observed that this issue can also happen while renames and readdirps/lookups are in progress because dentry-table is going stale sometimes. Fix: Prefer gfid-handles over paths for files. For directory handles prefering gfid-handles hits performance issues because it needs to resolve paths traversing up the symlinks. Tests which test if files are opened should check on gfid path after this change. So changed couple of tests to reflect the same. Note: This patch doesn't fix the issue for directories. I think a complete fix is to come up with an entry operation serialization xlator. Until then lets live with this. Change-Id: I10bda1083036d013f3a12588db7a71039d9da6c3 BUG: 1136159 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/8575 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--tests/bugs/bug-821056.t2
-rw-r--r--tests/bugs/bug-913051.t6
-rw-r--r--xlators/storage/posix/src/posix-handle.h4
3 files changed, 8 insertions, 4 deletions
diff --git a/tests/bugs/bug-821056.t b/tests/bugs/bug-821056.t
index db87993ed7..8c00260106 100644
--- a/tests/bugs/bug-821056.t
+++ b/tests/bugs/bug-821056.t
@@ -43,7 +43,7 @@ for i in {1..1024}; do
echo "open sesame" >&5
done
-EXPECT_WITHIN $REOPEN_TIMEOUT "Y" gf_check_file_opened_in_brick $V0 $H0 $B0/${V0}0 $B0/${V0}0/a
+EXPECT_WITHIN $REOPEN_TIMEOUT "Y" gf_check_file_opened_in_brick $V0 $H0 $B0/${V0}0 "$realpath"
#close the fd
exec 5>&-
diff --git a/tests/bugs/bug-913051.t b/tests/bugs/bug-913051.t
index 1673cc6eaf..69845f7a55 100644
--- a/tests/bugs/bug-913051.t
+++ b/tests/bugs/bug-913051.t
@@ -38,10 +38,12 @@ TEST $CLI volume start $V0 force
EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 0
#check that the files are not opned on brick-0
+TEST stat $M0/dir/a
realpatha=$(gf_get_gfid_backend_file_path $B0/${V0}0 "dir/a")
EXPECT "N" gf_check_file_opened_in_brick $V0 $H0 $B0/${V0}0 "$realpatha"
EXPECT "N" gf_check_file_opened_in_brick $V0 $H0 $B0/${V0}0 $B0/${V0}0/dir/a
+TEST stat $M0/dir/b
realpathb=$(gf_get_gfid_backend_file_path $B0/${V0}0 "dir/b")
EXPECT "N" gf_check_file_opened_in_brick $V0 $H0 $B0/${V0}0 "$realpathb"
EXPECT "N" gf_check_file_opened_in_brick $V0 $H0 $B0/${V0}0 $B0/${V0}0/dir/b
@@ -57,8 +59,8 @@ TEST fd_write $wfd "open sesame"
#trigger readv for attempting open-fd-fix in afr
TEST fd_cat $rfd
-EXPECT_WITHIN $REOPEN_TIMEOUT "Y" gf_check_file_opened_in_brick $V0 $H0 $B0/${V0}0 $B0/${V0}0/dir/a
-EXPECT_WITHIN $REOPEN_TIMEOUT "Y" gf_check_file_opened_in_brick $V0 $H0 $B0/${V0}0 $B0/${V0}0/dir/b
+EXPECT_WITHIN $REOPEN_TIMEOUT "Y" gf_check_file_opened_in_brick $V0 $H0 $B0/${V0}0 "$realpatha"
+EXPECT_WITHIN $REOPEN_TIMEOUT "Y" gf_check_file_opened_in_brick $V0 $H0 $B0/${V0}0 "$realpathb"
TEST fd_close $wfd
TEST fd_close $rfd
diff --git a/xlators/storage/posix/src/posix-handle.h b/xlators/storage/posix/src/posix-handle.h
index 0f596b6069..fec1447982 100644
--- a/xlators/storage/posix/src/posix-handle.h
+++ b/xlators/storage/posix/src/posix-handle.h
@@ -29,6 +29,8 @@
UUID0_STR) + 1)
#define LOC_HAS_ABSPATH(loc) (loc && (loc->path) && (loc->path[0] == '/'))
+#define LOC_IS_DIR(loc) (loc && (loc->inode) && \
+ (loc->inode->ia_type == IA_IFDIR))
#define MAKE_PGFID_XATTR_KEY(var, prefix, pgfid) do { \
var = alloca (strlen (prefix) + UUID_CANONICAL_FORM_LEN + 1); \
@@ -152,7 +154,7 @@
"null gfid for path %s", (loc)->path); \
break; \
} \
- if (LOC_HAS_ABSPATH (loc)) { \
+ if (LOC_IS_DIR (loc) && LOC_HAS_ABSPATH (loc)) { \
MAKE_REAL_PATH (rpath, this, (loc)->path); \
op_ret = posix_pstat (this, (loc)->gfid, rpath, iatt_p); \
break; \