Date: Wed, 23 Aug 2006 15:47:18 +0000 (UTC) From: Tor Egge <Tor.Egge@cvsup.no.freebsd.org> To: kostikbel@gmail.com Cc: freebsd-fs@freebsd.org Subject: Re: Deadlock between nfsd and snapshots. Message-ID: <20060823.154718.126633648.Tor.Egge@cvsup.no.freebsd.org> In-Reply-To: <20060823110808.GD64800@deviant.kiev.zoral.com.ua> References: <20060822.214638.74697110.Tor.Egge@cvsup.no.freebsd.org> <20060823044043.GA64800@deviant.kiev.zoral.com.ua> <20060823110808.GD64800@deviant.kiev.zoral.com.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
> I have at least one questions: > > > > Protecting the existing i_flag and the timestamps with the vnode > > > interlock when the current thread only has a shared vnode lock should > > > be sufficient to protect against the races, removing the need for #3, > > > #4 and #4 below. > Could you, please, explain this point ? I did not wrap all accesses to > i_flag and timestamps with vnode interlock, only ufs_itimes, ufs_lazyaccess > and ufs_getattr for now. As long as i_flag and the timstamps are never accessed without holding a shared or exclusive vnode lock, the vnode interlock can be used to serialize access for those holding a shared vnode lock. Access is already serialized for those holding an exclusive vnode lock, since no other thread can hold a shared or exclusive lock for the same vnode at the same time. An alternate locking protocol is to always use the vnode interlock to serialize access to i_flag and the timestamps. That increases the cost of accessing the fields in code that uses an exclusive vnode lock, but can temporarily lower the cost in other parts of the code (e.g. when scanning all the vnodes belonging to a mount point looking for dirty vnodes) since the vnode lock would no longer be needed to access i_flag and the timestamps. Problems with your suggested patch: ufs_lazyaccess() changes i_flags with only the vnode interlock held. The vnode interlock is not sufficient by itself to access i_flags without switching to the alternate locking protocol. ufs_itimes() doesn't optimize the common case where none of the flags are set. - Tor Egge
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060823.154718.126633648.Tor.Egge>