Subject: Re: Proposal: File system suspension - prerequisite for snapshots
To: Juergen Hannken-Illjes <hannken@eis.cs.tu-bs.de>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 08/13/2003 14:42:33
On Wed, 13 Aug 2003, Juergen Hannken-Illjes wrote:

> On Wed, Aug 13, 2003 at 12:02:01PM -0700, Bill Studenmund wrote:
> > On Tue, 12 Aug 2003, Juergen Hannken-Illjes wrote:
> >
> > > restart:
> > > 	prepare_a_write_operation
> > > 	if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) {
> > > 		abort_current_preparation
> > > 		if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0)
> > > 			return (error);
> > > 		goto restart;
> > > 	}
> > > 	do_the_write_operation
> > > 	vn_finished_write(mp);
> > >
> > > Doing it this way guarantees that no operation sleeps with locked vnodes.
> >
> > Note: don't you end up calling vn_start_write() _after_ you've been told
> > it's ok to start? :-) If you _want_ that to be part of the interface, we
> > need to document it. For one, it prevents a simple reference counting
> > mechanism to determine if writes are in progress.
>
> vn_start_write(..., V_NOWAIT) will return zero on success.  If the result
> is non-zero it means it's NOT ok to start.  So we have to abort and wait
> until it is ok (the second vn_start_write(..., V_XSLEEP | PCATCH)) and
> restart the syscall.

Yes, but you will fall through the vn_start_write() AGAIN. _THAT_ is the
second call. :-)

i.e. it will be:

vn_start_write(..., V_NOWAIT) == error
vn_start_write(..., V_XSLEEP | PCATCH) == no error
vn_start_write(..., V_NOWAIT) == no error I assume <- second success call

Take care,

Bill