diff options
| author | Emmanuel Dreyfus <manu@netbsd.org> | 2014-12-17 10:41:05 +0100 | 
|---|---|---|
| committer | Raghavendra Bhat <raghavendra@redhat.com> | 2014-12-17 03:48:22 -0800 | 
| commit | e398f99d9ac7ca5c83004b814a4e8561916187f0 (patch) | |
| tree | d74d7fe7dc7e45aa37b12fb88557c5ecab4a68b4 /tests | |
| parent | 466a6f37ebaaad746e2eae045ebd249e28673717 (diff) | |
telldir()/seekdir() portability fixes
POSIX says that an offset obtained from telldir() can only be used
on the same DIR *. Linux is abls to reuse the offset accross
closedir()/opendir() for a given directory, but this is not portable
and such a behavior should be fixed.
An incomplete fix for the posix xlator was merged in
http://review.gluster.com/8926
This change set completes it.
- Perform the same fix index xlator.
- Use appropriate casts and variable types so that 32 bit signed
  offsets obtained by telldir() do not get clobbered when copied into
  64 bit signed types.
- modify glfs-heal.c and afr-self-heald.c so that they do not use
  anonymous fd, since this will cause closedir()/opendir() between
  each syncop_readdir(). On failure we fallback to anonymous fs
  only for Linux so that we can cope with updated client vs not
  updated brick.
- Avoid sending an EINVAL when the client request for the EOF offset.
  Here we fix an error in previous fix for posix xlator: since we
  fill each directory entry with the offset of the next entry, we
  must consider as EOF the offset of the last entry, and not the
  value of telldir() after we read it.
- Add checks in regression tests that we do not hit cases where
  offsets fed to seekdir() are wrong. Introduce log_newer() shell
  function to check for messages produced by the current script.
This fix gather changes from http://review.gluster.org/9047
and http://review.gluster.org/8936 making them obsolete.
BUG: 1129939
Change-Id: I59fb7f06a872c4f98987105792d648141c258c6a
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/9071
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Tested-by: Raghavendra Bhat <raghavendra@redhat.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/basic/afr/self-heald.t | 4 | ||||
| -rw-r--r-- | tests/basic/pump.t | 4 | ||||
| -rw-r--r-- | tests/include.rc | 18 | 
3 files changed, 26 insertions, 0 deletions
diff --git a/tests/basic/afr/self-heald.t b/tests/basic/afr/self-heald.t index 37e10b254c1..6937cf227d7 100644 --- a/tests/basic/afr/self-heald.t +++ b/tests/basic/afr/self-heald.t @@ -4,6 +4,7 @@  . $(dirname $0)/../../volume.rc  cleanup; +START_TIMESTAMP=`date +%s`  function disconnected_brick_count {          local vol=$1 @@ -162,4 +163,7 @@ TEST $CLI volume create $V0 $H0:$B0/${V0}{6}  TEST $CLI volume start $V0  TEST ! $CLI volume heal $V0 info +# Check for non Linux systems that we did not mess with directory offsets +TEST ! log_newer $START_TIMESTAMP "offset reused from another DIR" +  cleanup diff --git a/tests/basic/pump.t b/tests/basic/pump.t index 6e81ddde6cd..e9e54a7a9ea 100644 --- a/tests/basic/pump.t +++ b/tests/basic/pump.t @@ -4,6 +4,7 @@  . $(dirname $0)/../volume.rc  cleanup; +START_TIMESTAMP=`date +%s`  TEST glusterd  TEST pidof glusterd @@ -41,4 +42,7 @@ done  EXPECT "" echo $files +# Check for non Linux systems that we did not mess with directory offsets +TEST ! log_newer $START_TIMESTAMP "offset reused from another DIR" +  cleanup diff --git a/tests/include.rc b/tests/include.rc index 75db2d10d0e..7c31eb65402 100644 --- a/tests/include.rc +++ b/tests/include.rc @@ -783,6 +783,24 @@ function MKFS_LOOP ()    esac  } +# usage: log_newer timestamp "string" +# search in glusterfs logs for "string" logged after timestamp seconds +# since the Epoch (usually obtained by date +%s) +log_newer() +{ +        ts=$1 +        msg=$2 +        logdir=`$CLI --print-logdir` + +        IFS="[" +        for date in `grep -hr "$msg" $logdir | awk -F '[\]]' '{print $1}'` ; do +                if [ `date -d "$date" +%s` -gt $ts ] ; then +                        return 0; +                fi +        done 2>/dev/null +        return 1 +} +  function MOUNT_LOOP ()  {    if [ $# != 2 ] ; then  | 
