From: "Darrick J. Wong" <djwong@kernel.org>
To: Zorro Lang <zlang@redhat.com>
Cc: fstests@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/4] src/t_rename_overwrite: fsync to flush the rename operation result
Date: Wed, 20 Apr 2022 10:13:19 -0700 [thread overview]
Message-ID: <20220420171319.GP17025@magnolia> (raw)
In-Reply-To: <20220420083653.1031631-2-zlang@redhat.com>
On Wed, Apr 20, 2022 at 04:36:50PM +0800, Zorro Lang wrote:
> The generic/035 fails on glusterfs due to glusterfs (or others like
> it), the file state can't be updated in time in client side, there's
> time delay. So call fsync to get the right file state after rename.
>
> Signed-off-by: Zorro Lang <zlang@redhat.com>
> ---
> src/t_rename_overwrite.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/src/t_rename_overwrite.c b/src/t_rename_overwrite.c
> index c5cdd1db..8dcf8d46 100644
> --- a/src/t_rename_overwrite.c
> +++ b/src/t_rename_overwrite.c
> @@ -2,6 +2,7 @@
> #include <fcntl.h>
> #include <err.h>
> #include <sys/stat.h>
> +#include <unistd.h>
>
> int main(int argc, char *argv[])
> {
> @@ -25,6 +26,7 @@ int main(int argc, char *argv[])
> res = rename(path1, path2);
> if (res == -1)
> err(1, "rename(\"%s\", \"%s\")", path1, path2);
> + fsync(fd);
The callsite needs error checking, right?
Also, what's going on with glusterfs? We unlinked path2 from its parent
directory, which means that it's now an unlinked open file. The next
code chunk in this file checks st_nlink != 0. Does the fsync force the
operation to the server so that the fstat call pulls data from the
server? Or put another way, does the fstat call return stale stat data
after a rename?
--D
>
> res = fstat(fd, &stbuf);
> if (res == -1)
> --
> 2.31.1
>
next prev parent reply other threads:[~2022-04-20 17:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-20 8:36 [PATCH 0/4] several long time unmerged patches from zlang Zorro Lang
2022-04-20 8:36 ` [PATCH 1/4] src/t_rename_overwrite: fsync to flush the rename operation result Zorro Lang
2022-04-20 17:13 ` Darrick J. Wong [this message]
2022-04-20 8:36 ` [PATCH 2/4] fstests: avoid dedupe testing blocked on large fs long time Zorro Lang
2022-04-20 8:36 ` [PATCH 3/4] generic: test data corruption when blocksize < pagesize for mmaped data Zorro Lang
2022-04-20 17:25 ` Darrick J. Wong
2022-04-20 8:36 ` [PATCH 4/4] fstests: test xfs swapext log replay Zorro Lang
2022-04-20 18:08 ` Darrick J. Wong
2022-04-20 22:06 ` Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220420171319.GP17025@magnolia \
--to=djwong@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=zlang@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox