From 80d2dae631369d2e4b5e5f4aa0a102b541c22ad5 Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Tue, 9 Apr 2019 18:23:05 +0530 Subject: posix/ctime: Fix stat(time attributes) inconsistency during readdirp Problem: Creation of tar file on gluster volume throws warning 'file changed as we read it' Cause: During readdirp, for few of the files whose inode is not present, time attributes were served from backend. This caused the ctime of few files to be different between before readdir and after readdir by tar. Solution: If ctime feature is enabled and inode is not present, don't serve the time attributes from backend file, serve it from xattr. Backport of: > Patch: https://review.gluster.org/22540 > BUG: 1698078 > Change-Id: I427ef865f97399475faf5aa6ca495f7e317603ae > Signed-off-by: Kotresh HR (cherry picked from commit c56f102da21c5b69e656a055aaf736281596284d) fixes: bz#1699703 Change-Id: I427ef865f97399475faf5aa6ca495f7e317603ae Signed-off-by: Kotresh HR --- tests/basic/ctime/ctime-readdir.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/basic/ctime/ctime-readdir.c (limited to 'tests/basic/ctime/ctime-readdir.c') diff --git a/tests/basic/ctime/ctime-readdir.c b/tests/basic/ctime/ctime-readdir.c new file mode 100644 index 00000000000..8760db29ae8 --- /dev/null +++ b/tests/basic/ctime/ctime-readdir.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include + +int +main(int argc, char **argv) +{ + DIR *dir = NULL; + struct dirent *entry = NULL; + int ret = 0; + char *path = NULL; + + assert(argc == 2); + path = argv[1]; + + dir = opendir(path); + if (!dir) { + printf("opendir(%s) failed.\n", path); + return -1; + } + + while ((entry = readdir(dir)) != NULL) { + } + if (dir) + closedir(dir); + + return ret; +} -- cgit