path: root/tests/bugs/rpc/bug-954057.t
diff options
authorEmmanuel Dreyfus <>2015-04-29 15:52:37 +0200
committerVijay Bellur <>2015-05-07 04:37:56 -0700
commitaa938247e19afa419476fb2d0b7cb2d054c6dd47 (patch)
tree5fdf28179cb907f4e29b7246799fef61b0f1c16d /tests/bugs/rpc/bug-954057.t
parentf93bf09cdb417cf5e09206164a16ad9435285b45 (diff)
Tests: use a portable way to flush kernel cache
On Linux, kernel cache can be flushed using echo 3 > /proc/sys/vm/drop_caches This non-portable approach can be replaced by an on-purpose failed attempt to unmount: if the mount point is the current directory and umount is called, the kernel will flush inodes until it realize it cannot complete the operation because root of filesystem is busy: ( cd $M0 ; umount $M0 ) Unfortunately this does not flush everything. Entries may still be present in the kenrel FUSE cache. Using $GFS to mount the filesystem ensure --entry-timeout=0 and clears this problem. Some stall information may also remain in glusterfs caches, and that may have to be adressed by appropriate volume option. For instance tests/bugs/rpc/bug-954057.t needs to disable performance.stat-prefetch. Qtherwise, root's new credentials are not evaluated after root-quash is enabled. The test could also be done with performance.stat-prefetch enabled using various tricks: copying the file to read, creating a hard link on it, or just waiting long enough for metadata cache to expire. BUG: 1129939 Change-Id: I54929e899d55c04dcd9d947809133549f01fd0e1 Signed-off-by: Emmanuel Dreyfus <> Reviewed-on: Reviewed-by: Dan Lambright <> Tested-by: Gluster Build System <> Reviewed-by: Vijay Bellur <>
Diffstat (limited to 'tests/bugs/rpc/bug-954057.t')
1 files changed, 16 insertions, 5 deletions
diff --git a/tests/bugs/rpc/bug-954057.t b/tests/bugs/rpc/bug-954057.t
index 9c48207..faaf261 100755
--- a/tests/bugs/rpc/bug-954057.t
+++ b/tests/bugs/rpc/bug-954057.t
@@ -3,15 +3,25 @@
. $(dirname $0)/../../include.rc
. $(dirname $0)/../../volume.rc
-#This script checks if use-readdirp option works as accepted in mount options
+# This script checks if use-readdirp option works as accepted in mount options
+# Note on re-reading $M0/new after enabling root-squash:
+# Since we have readen it once, the file is present in various caches.
+# In order to actually fail on second attempt we must:
+# 1) drop kernel cache, by ( cd $M0 ; umount $M0 )
+# 2) make sure FUSE does not cache the entry. This is also
+# in the kernel, but not flushed by a failed umount.
+# Using $GFS enforces this because it sets --entry-timeout=0
+# 3) make sure reading new permissins does not produce stale
+# information from glusterfs metadata cache. Setting volume
+# option performance.stat-prefetch off enforces that.
TEST glusterd
TEST pidof glusterd
TEST $CLI volume create $V0 $H0:$B0/${V0}
TEST $CLI volume start $V0
-TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0
TEST mkdir $M0/dir
TEST mkdir $M0/nobody
@@ -21,8 +31,9 @@ TEST cp $M0/file $M0/new
TEST chmod 700 $M0/new
TEST cat $M0/new
+TEST $CLI volume set $V0 performance.stat-prefetch off
TEST $CLI volume set $V0 server.root-squash enable
-TEST `echo 3 > /proc/sys/vm/drop_caches`
+( cd $M0 ; umount $M0 ) # fails but drops kernel cache
TEST ! mkdir $M0/other
TEST mkdir $M0/nobody/other
TEST cat $M0/file
@@ -30,7 +41,7 @@ TEST ! cat $M0/new
TEST `echo "nobody" >> $M0/nobody/file`
#mount the client without root-squashing
-TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 --no-root-squash=yes $M1
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 --no-root-squash=yes $M1
TEST mkdir $M1/m1_dir
TEST `echo "file" >> $M1/m1_file`
TEST cp $M0/file $M1/new