Skip to contentSkip to conversation

common/rc: improve _fstyp_has_non_default_seek_data_hole()

PATCH Superseded Jeffle Xu 2 participants 2 messages May 13, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jeffle Xu

author
#0 lore raw

PATCH 1/1 common/rc: improve _fstyp_has_non_default_seek_data_hole()

commit 34081087 adds more sanity to seek_sanity_test(), where some kinds of filesystem type should not only support default behavior of SEEK_HOLE, that is, always returns EOF. A hardcoded whitelist is maintained to distinguish whether a filesystem type is allowed to only support default behavior or not.

In this whitelist, NFS is not allowed to support default behavior only. However as far as I know, nfsv2 and nfsv3 only support default behavior of SEEK_HOLE in linux.

On the other hand, xfstests uses "mount -t nfs ..." to mount a NFS mount point. Normally the mount point is mounted on nfsv4, but it can be mounted mandatorily on nfsv3 if we specify "Nfsvers=3" in /etc/nfsmount.conf. And in this case, a series of tests fail (including generic/285, generic/448, generic/490, et cetera) with error message "Default behavior is not allowed. Aborting."

So I just make some special handling for NFS in _fstyp_has_non_default_seek_data_hole(), that is, default behavior of SEEK_HOLE is acceptable for nfsv2 and nfsv3.

I'm not sure how nfsv2 and nfsv3 behave SEEK_HOLE in other OS other than linux, and any comment is welcomed if I misunderstand the SEEK_HOLE behavior of nfsv2/nfsv3 in linux.

Thanks.

---
 common/rc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
common/rc +7 -1
index cbd3c59..83e9729 100644
@@ -2315,9 +2315,15 @@ _fstyp_has_non_default_seek_data_hole()
 	fi
 
 	case "$fstyp" in
-	btrfs|ext4|xfs|ceph|cifs|f2fs|gfs2|nfs*|ocfs2|tmpfs)
+	btrfs|ext4|xfs|ceph|cifs|f2fs|gfs2|ocfs2|tmpfs)
 		return 0
 		;;
+	nfs*)
+		# NFSv2 and NFSv3 only support default behavior of SEEK_HOLE,
+		# while NFSv4 supports non-default behavior
+		local nfsvers=`_df_device $TEST_DEV | $AWK_PROG '{ print $2 }'`
+		[ "$nfsvers" = "nfs4" ] && return 0 || return 1
+		;;
 	overlay)
 		if [ ! -z $OVL_BASE_FSTYP -a $OVL_BASE_FSTYP != "overlay" ]; then
 			_fstyp_has_non_default_seek_data_hole $OVL_BASE_FSTYP
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 6 lines · Jeffle Xu

commit 34081087 adds more sanity to seek_sanity_test(), where some kinds of filesystem type should not only support default behavior of SEEK_HOLE, that is, always returns EOF. A hardcoded whitelist is maintained to distinguish whether a filesystem type is allowed to only support default behavior or not.

Its the other way around.
The whitelist is for filesystems that are allowed to support only "non default" behavior.
A filesystem that is not whitelisted can support either default or non-default behavior as far as the test is concerned.

Quoted 4 lines

In this whitelist, NFS is not allowed to support default behavior only. However as far as I know, nfsv2 and nfsv3 only support default behavior of SEEK_HOLE in linux.

Correct.

Quoted 9 lines

On the other hand, xfstests uses "mount -t nfs ..." to mount a NFS mount point. Normally the mount point is mounted on nfsv4, but it can be mounted mandatorily on nfsv3 if we specify "Nfsvers=3" in /etc/nfsmount.conf. And in this case, a series of tests fail (including generic/285, generic/448, generic/490, et cetera) with error message "Default behavior is not allowed. Aborting."

Quoted 7 lines

So I just make some special handling for NFS in _fstyp_has_non_default_seek_data_hole(), that is, default behavior of SEEK_HOLE is acceptable for nfsv2 and nfsv3.

I'm not sure how nfsv2 and nfsv3 behave SEEK_HOLE in other OS other than linux, and any comment is welcomed if I misunderstand the SEEK_HOLE behavior of nfsv2/nfsv3 in linux.

I think you understood well (CC NFS list).
xfstests does not support non Linux OS anymore.

Quoted 15 lines

Thanks.

---
 common/rc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
common/rc +0 -0
index cbd3c59..83e9729 100644
@@ -2315,9 +2315,15 @@ _fstyp_has_non_default_seek_data_hole()
        fi
 

common/rc _fstyp_has_non_default_seek_data_hole() · line 2325

Quoted 10 lines
common/rc +6 -1
        case "$fstyp" in
-       btrfs|ext4|xfs|ceph|cifs|f2fs|gfs2|nfs*|ocfs2|tmpfs)
+       btrfs|ext4|xfs|ceph|cifs|f2fs|gfs2|ocfs2|tmpfs)
                return 0
                ;;
+       nfs*)
+               # NFSv2 and NFSv3 only support default behavior of SEEK_HOLE,
+               # while NFSv4 supports non-default behavior
+               local nfsvers=`_df_device $TEST_DEV | $AWK_PROG '{ print $2 }'`
+               [ "$nfsvers" = "nfs4" ] && return 0 || return 1
               [ "$nfsvers" = "nfs4" ]
               return $?

Thanks,
Amir.