[Patch] nfs: Make sure check_new_cache() is looking in the right place

Neil Brown neilb at suse.de
Sun Jun 22 20:35:52 EDT 2008


On Friday June 20, Guillaume.Rousse at inria.fr wrote:
> And old patch still present in mandriva nfs-utils package, from an 
> unknown author
> -- 
> Guillaume Rousse
> Moyens Informatiques - INRIA Futurs
> Tel: 01 69 35 69 62
> #
> # Make sure check_new_cache() is looking in the right place
> #
> --- src/support/nfs/cacheio.c.org	2003-08-04 00:12:16.000000000 -0400
> +++ src/support/nfs/cacheio.c	2004-03-22 18:12:55.163534208 -0500
> @@ -223,12 +223,23 @@ int readline(int fd, char **buf, int *le
>   * This succeeds iff the "nfsd" filesystem is mounted on
>   * /proc/fs/nfs
>   */
> +static char *cachelist[] = {
> +	{ "auth.unix.ip" }, { "nfsd.export" }, { "nfsd.fh" }, 
> +	{ NULL, NULL }
> +};
>  int
>  check_new_cache(void)
>  {
>  	struct stat stb;
> -	return	(stat("/proc/fs/nfs/filehandle", &stb) == 0) ||
> -		(stat("/proc/fs/nfsd/filehandle", &stb) == 0);
> +	char path[64];
> +	int i;
> +
> +	for (i=0; cachelist[i]; i++ ){
> +		sprintf(path, "/proc/net/rpc/%s/channel", cachelist[i]);
> +		if (stat(path, &stb) < 0)
> +			return 0;
> +	}
> +	return 1;
>  }	
> 

This patch is wrong.

The thing that "check_new_cache" is meant to check is whether or not
the nfsd filesystem is mounted, whether on /proc/fs/nfs or /proc/fs/nfsd.

Checking for stuff in /proc/net/rpc is not useful, as those files are
not sufficient to provide the "new_cache" functionality.

If the nfsd filesystem even exists, then the required bits will be in
/proc/net/rpc and there is no need to check them.

One wonders why patches like this were ever included without being
discussed with upstream (we've always tried to be very responsive),
but thank you very much for taking the trouble to get these resolved
now!

NeilBrown


More information about the NFSv4 mailing list