[LTP] [PATCH] Add test for file truncation over NFS
Petr Vorel
pvorel@suse.cz
Tue Feb 13 17:48:47 CET 2024
Hi Martin,
Merged, thank you!
> Some older kernels have a bug in NFS where the client caches that
> a file does not exist after unsuccessful access to it and then
> does not pass O_TRUNC flag to the server even though the file may
> have been created by another client in the mean time. This may result
> in new data being merged with old file contents instead of replacing
> them.
...
> +++ b/runtest/net.nfs
> @@ -83,6 +83,17 @@ nfs08_v40_ip6t nfs08.sh -6 -v 4 -t tcp
> nfs08_v41_ip6t nfs08.sh -6 -v 4.1 -t tcp
> nfs08_v42_ip6t nfs08.sh -6 -v 4.2 -t tcp
> +nfs09_v30_ip4u nfs09.sh -v 3 -t udp
> +nfs09_v30_ip4t nfs09.sh -v 3 -t tcp
For a record, this is the test which fails. And NFSv3 is affected on all
kernels, including latest stable 6.7.4 and 6.8.0-rc1 (both openSUSE packages).
> +nfs09_v40_ip4t nfs09.sh -v 4 -t tcp
> +nfs09_v41_ip4t nfs09.sh -v 4.1 -t tcp
> +nfs09_v42_ip4t nfs09.sh -v 4.2 -t tcp
> +nfs09_v30_ip6u nfs09.sh -6 -v 3 -t udp
> +nfs09_v30_ip6t nfs09.sh -6 -v 3 -t tcp
> +nfs09_v40_ip6t nfs09.sh -6 -v 4 -t tcp
> +nfs09_v41_ip6t nfs09.sh -6 -v 4.1 -t tcp
> +nfs09_v42_ip6t nfs09.sh -6 -v 4.2 -t tcp
...
> +++ b/testcases/network/nfs/nfs_stress/nfs09.sh
...
> +do_test()
> +{
> + local local_file="testfile"
> + local remote_file="$(nfs_get_remote_path)/$local_file"
> + local testmsg='File truncated'
> + local data
> +
> + EXPECT_FAIL "ls -l '$local_file'"
> + tst_rhost_run -c "echo -n 'File rewritten not' >'$remote_file'"
> + echo -n "$testmsg" >"$local_file"
echo is considered unportable (printf is preferred), but "echo -n" should be
hopefully safe nowadays.
Kind regards,
Petr
More information about the ltp
mailing list