Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Apr 2011 08:09:32 -0400 (EDT)
From:      Rick Macklem <rmacklem@uoguelph.ca>
To:        Pawel Jakub Dawidek <pjd@FreeBSD.org>
Cc:        svn-src-head@freebsd.org, Rick Macklem <rmacklem@FreeBSD.org>, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r220877 - head/sys/fs/nfsclient
Message-ID:  <630616771.329277.1303301372199.JavaMail.root@erie.cs.uoguelph.ca>
In-Reply-To: <20110420054655.GD1826@garage.freebsd.pl>

next in thread | previous in thread | raw e-mail | index | archive | help
> > + tmp_off = uio->uio_offset + uio->uio_resid;
> > + mtx_lock(&nmp->nm_mtx);
> > + if (tmp_off > nmp->nm_maxfilesize || tmp_off < uio->uio_offset) {
> > + mtx_unlock(&nmp->nm_mtx);
> >  		return (EFBIG);
> > + }
> > + mtx_unlock(&nmp->nm_mtx);
> 
> I don't think you need the lock to protect nm_maxfilesize. Can it
> change
> from under us? My guess is that it is set on mount time and is not
> modified afterwards.
> 
Good question.
For NFSv3 - it is only modified by the first fsinfo RPC and that normally
    happens at mount time, as you guessed above. (This is consistent with
    RFC1813, which defines the fsinfo RPC as getting non-volatile information.)
For NFSv4 - it gets it each time VFS_STATFS() happens. I am not sure that
    this is correct, but I don't know of anywhere in RFC3530 where it states
    that this attribute will not change. In practice, I suspect that servers
    seldom, if ever, change it.

So, it is unlikely to change and I'd be comfortable taking the mutex lock
off the check for it, if others are? (As you might be aware, I started a
thread on hackers-freebsd@ where my question was basically "do you need to
mutex lock when you read a global variable". My main concern there was a
case that I'm working on w.r.t. forced dismounts. jhb@ suggested that he
thinks it is good practice to always lock, to play it safe. At least that
was my interpretation?)

rick



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?630616771.329277.1303301372199.JavaMail.root>