Re: [PATCH 06/12] repair: use recursive buffer locking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 13, 2011 at 01:22:08PM +1100, Dave Chinner wrote:
> >  	if (use_xfs_buf_lock) {
> > -		if (flags & LIBXFS_GETBUF_TRYLOCK) {
> > -			int ret;
> > +		int ret;
> >  
> > -			ret = pthread_mutex_trylock(&bp->b_lock);
> > -			if (ret) {
> > -				ASSERT(ret == EAGAIN);
> > -				cache_node_put(libxfs_bcache, (struct cache_node *)bp);
> > -				return NULL;
> > +		ret = pthread_mutex_trylock(&bp->b_lock);
> > +		if (ret) {
> > +			ASSERT(ret == EAGAIN);
> > +			if (flags & LIBXFS_GETBUF_TRYLOCK)
> > +				goto out_put;
> > +
> > +			if (pthread_equal(bp->b_holder, pthread_self())) {
> > +				fprintf(stderr,
> > +	_("recursive buffer locking detected\n"));
> 
> "Warning: recursive buffer locking @ bno %lld detected"
> 
> might be more informative, especially to do with the severity of the
> issue.

Ok, I'll make it print the block number.

> 
> > +				bp->b_recur++;
> > +			} else {
> > +				pthread_mutex_lock(&bp->b_lock);
> >  			}
> > -		} else {
> > -			pthread_mutex_lock(&bp->b_lock);
> >  		}
> > +
> > +		bp->b_holder = pthread_self();
> 
> That should probably only be written in the branch where the lock is
> taken not every time through here.

We actually should return the buffer just after incrementing the
recursion count, else we might add it to the global list of buffers
twice.

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs


[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux