Skip to content

Commit

Permalink
xfstests: Support test pNFS
Browse files Browse the repository at this point in the history
- pNFS is based on nfs4.1. Add version check for pNFS, also add related
configuration setting before a test.
- /srv/pnfs_data is the real storage place for pNFS, but the test will not
directly on it, and its content will keep updating when nfs mount dir
has changes.
- Setup XFSTEST_NFS_VERSION=pnfs could enable pNFS in xfstests
  • Loading branch information
SeroSun committed Jan 3, 2025
1 parent 4fa856b commit b5218db
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions tests/xfstests/partition.pm
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,12 @@ sub set_config {
script_run("echo export TEST_DIR=/opt/nfs/test >> $CONFIG_FILE");
script_run("echo export SCRATCH_DEV=$NFS_SERVER_IP:/opt/export/scratch >> $CONFIG_FILE");
script_run("echo export SCRATCH_MNT=/opt/nfs/scratch >> $CONFIG_FILE");
script_run("echo export NFS_MOUNT_OPTIONS='\"-o rw,relatime,vers=$NFS_VERSION\"' >> $CONFIG_FILE");
if ($NFS_VERSION =~ 'pnfs') {
script_run("echo export NFS_MOUNT_OPTIONS='\"-o rw,relatime,vers=4.1,minorversion=1\"' >> $CONFIG_FILE");
}
else {
script_run("echo export NFS_MOUNT_OPTIONS='\"-o rw,relatime,vers=$NFS_VERSION\"' >> $CONFIG_FILE");
}
}
record_info('Config file', script_output("cat $CONFIG_FILE"));
}
Expand Down Expand Up @@ -371,8 +376,12 @@ sub install_dependencies_overlayfs {

sub setup_nfs_server {
my $nfsversion = shift;
assert_script_run('mkdir -p /opt/export/test /opt/export/scratch /opt/nfs/test /opt/nfs/scratch && chown nobody:nogroup /opt/export/test /opt/export/scratch && echo \'/opt/export/test *(rw,no_subtree_check,no_root_squash)\' >> /etc/exports && echo \'/opt/export/scratch *(rw,no_subtree_check,no_root_squash,fsid=1)\' >> /etc/exports');

if ($nfsversion =~ 'pnfs') {
assert_script_run('mkdir -p /opt/export/test /opt/export/scratch /opt/nfs/test /opt/nfs/scratch && chown nobody:nogroup /opt/export/test /opt/export/scratch && echo \'/opt/export/test *(rw,pnfs,no_subtree_check,no_root_squash,fsid=1)\' >> /etc/exports && echo \'/opt/export/scratch *(rw,pnfs,no_subtree_check,no_root_squash,fsid=2)\' >> /etc/exports');
}
else {
assert_script_run('mkdir -p /opt/export/test /opt/export/scratch /opt/nfs/test /opt/nfs/scratch && chown nobody:nogroup /opt/export/test /opt/export/scratch && echo \'/opt/export/test *(rw,no_subtree_check,no_root_squash,fsid=1)\' >> /etc/exports && echo \'/opt/export/scratch *(rw,no_subtree_check,no_root_squash,fsid=2)\' >> /etc/exports');
}
my $nfsgrace = get_var('NFS_GRACE_TIME', 15);
assert_script_run("echo 'options lockd nlm_grace_period=$nfsgrace' >> /etc/modprobe.d/lockd.conf && echo 'options lockd nlm_timeout=5' >> /etc/modprobe.d/lockd.conf");

Expand All @@ -385,9 +394,25 @@ sub setup_nfs_server {
else {
assert_script_run("sed -i 's/NFSV4LEASETIME=\"\"/NFSV4LEASETIME=\"$nfsgrace\"/' /etc/sysconfig/nfs");
assert_script_run("echo -e '[nfsd]\\ngrace-time=$nfsgrace\\nlease-time=$nfsgrace' > /etc/nfs.conf.local");
if ($nfsversion =~ 'pnfs') {
assert_script_run('mkdir -p /srv/pnfs_data && chown nobody:nogroup /srv/pnfs_data && echo \'/srv/pnfs_data *(rw,pnfs,no_subtree_check,no_root_squash,fsid=10)\' >> /etc/exports');
assert_script_run('sed -i \'/^\[nfsd\\]$/a pnfs_dlm_device = localhost:/srv/pnfs_data\' /etc/nfs.conf');
assert_script_run("echo '[NFSMount_Global_Options]' >> /etc/nfsmount.conf && echo 'Defaultvers=4.1' >> /etc/nfsmount.conf && echo 'Nfsvers=4.1' >> /etc/nfsmount.conf");
}
}
assert_script_run('exportfs -a && systemctl restart rpcbind && systemctl enable nfs-server.service && systemctl restart nfs-server');

if ($nfsversion =~ 'pnfs'){
script_run('mount -t nfs4 -o vers=4.1,minorversion=1 localhost:/opt/export/test /opt/nfs/test');
}
elsif ($nfsversion =~ '4') {
script_run("mount -t nfs4 -o vers=$nfsversion localhost:/opt/export/test /opt/nfs/test");
}
else {
script_run("mount -t nfs -o vers=$nfsversion localhost:/opt/export/test /opt/nfs/test");
}
record_info('mountstats', script_output('cat /proc/self/mountstat', proceed_on_failure => 1));
record_info('nfsstat -m', script_output('nfsstat -m', proceed_on_failure => 1));
script_run('umount /opt/nfs/test');

# There's a graceful time we need to wait before using the NFS server
my $gracetime = script_output('cat /proc/fs/nfsd/nfsv4gracetime;');
Expand Down

0 comments on commit b5218db

Please sign in to comment.