xfs
[Top] [All Lists]

Re: [PATCH 2/2] xfs: push stale, pinned buffers on trylock failures

To: Dave Chinner <david@xxxxxxxxxxxxx>
Subject: Re: [PATCH 2/2] xfs: push stale, pinned buffers on trylock failures
From: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Date: Wed, 24 Nov 2010 12:20:51 -0500
Cc: xfs@xxxxxxxxxxx
In-reply-to: <1290597873-5807-3-git-send-email-david@xxxxxxxxxxxxx>
References: <1290597873-5807-1-git-send-email-david@xxxxxxxxxxxxx> <1290597873-5807-3-git-send-email-david@xxxxxxxxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
> -     /* Attempt to get the semaphore without sleeping,
> -      * if this does not work then we need to drop the
> -      * spinlock and do a hard attempt on the semaphore.
> +     /*
> +      * Attempt to get the semaphore without sleeping first. if we fail then
> +      * do a blocking lock if requested.
>        */

You might as well remove the comment entirely, as it's utterly
pointless.

> -     if (down_trylock(&bp->b_sema)) {
> +     if (xfs_buf_cond_lock(bp)) {
>               if (!(flags & XBF_TRYLOCK)) {
>                       /* wait for buffer ownership */
>                       xfs_buf_lock(bp);
>                       XFS_STATS_INC(xb_get_locked_waited);
>               } else {
> -                     /* We asked for a trylock and failed, no need
> -                      * to look at file offset and length here, we
> -                      * know that this buffer at least overlaps our
> -                      * buffer and is locked, therefore our buffer
> -                      * either does not exist, or is this buffer.
> -                      */
> +                     /* We asked for a trylock and failed.  */
>                       xfs_buf_rele(bp);
>                       XFS_STATS_INC(xb_busy_locked);
>                       return NULL;
>               }

In case we wait for the lock we now do the log force twice, but that
should be fine.

<Prev in Thread] Current Thread [Next in Thread>