lib/Kernel/nfs.pm

SYNOPSIS

Utils and helpers for nfs testing

create_export

create_export();

Create an NFS share and export it with specified settings: - path: Filesystem path to export - cl: client IP/hostname to create the share for - options: options to record in /etc/exports

get_export_paths

my @paths = get_export_paths();

Returns the paths exported in /etc/exports, each path once, in the order of the file. Comments and empty lines are skipped.

setup_pnfs_client

setup_pnfs_client();

Prepare a client for a pNFS block layout. Enable nfs-blkmap.service, blkmapd is required to resolve the block devices of a layout, and blacklist the flexfiles layout driver so it never silently replaces the block layout.

verify_pnfs_block_layout

verify_pnfs_block_layout($server, $export, $mountpoint, $dev);

Verify that a pNFS block layout carries the data. Write a 4K probe file over NFS while capturing both the NFS traffic and the requests of the block device backing the export, then record the counters: - server: NFS server to mount from - export: exported path to mount - mountpoint: where to mount it, has to be free again afterwards - dev: block device backing the export

With a working block layout the client writes to the block device on its own and only the layout operations reach the server, so no NFS WRITE operation must show up while the block device must see the write. The check has to run after the NFS grace period, during the grace LAYOUTGET is answered with NFS4ERR_GRACE and the client falls back to regular NFS writes.

Products without the capture tools are reported and skipped.

kernel_supports_nfs_krb5

my $supported = kernel_supports_nfs_krb5();

Return 1 if the running kernel supports RPCSEC_GSS with Kerberos (CONFIG_RPCSEC_GSS_KRB5), else 0. Kerberos works with all NFS versions, the caller decides which versions to test.

setup_nfs_krb5_server

setup_nfs_krb5_server([%realm_settings]);

Prepare this node as KDC and Kerberos NFS server. Set up the realm with this node as KDC, add the nfs service principals of this node and start the server side GSS service. Optional realm settings are passed to Kernel::krb5, see there. Call it before nfs-server starts, so nfsd uses the GSS service from the start.

The GSS service is gssproxy where it is installed, else rpc-svcgssd. Only one of them runs, else the kernel can use either of them. Both need the auth_rpcgss module loaded when they start: rpc.svcgssd exits without it, and gssproxy needs it to make the kernel use it instead of rpc-svcgssd.

The function makes sure that the GSS service runs and, for gssproxy, that the kernel uses it. A restart alone does not show this: the service units ignore a failed start (ExecStart=-) and are skipped without a keytab.

setup_nfs_krb5_client

setup_nfs_krb5_client($kdc [, %realm_settings]);

Prepare this node as Kerberos NFS client of the realm on kdc. Add the nfs service principals of this node through kadmind on kdc and restart rpc-gssd and make sure that it runs. The KDC has to be ready, see setup_nfs_krb5_server(). Pass the same realm settings as on the server.

Before the mounts, check the Kerberos setup in user space: get a ticket with the key of this node and a service ticket for nfs/kdc. Thus a failure in the realm setup fails here, not as a failed mount that looks like a kernel issue. kdc must be the name that the client mounts the server by.

upload_nfs_krb5_logs

upload_nfs_krb5_logs();

Upload the logs to debug NFS with Kerberos: the keytab entries, the journal of the GSS and Kerberos services and the KDC and kadmind logs. Missing logs are skipped, thus it works on the server and on the client, also in a post_fail_hook.