]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: clear the buffer error while the buffer is locked
authorDave Chinner <dchinner@redhat.com>
Fri, 11 Jul 2014 02:00:28 +0000 (12:00 +1000)
committerDave Chinner <david@fromorbit.com>
Fri, 11 Jul 2014 02:00:28 +0000 (12:00 +1000)
When releasing a buffer, the error shoul dbe cleared while the lock
is still held on the buffer to avoid racing with a new user of the
buffer.

This was pointed out in review of commit 6af7c1e ("libxfs: reused
invalidated buffers leak state and data") but the version committed
didn't have the fix. Thanks to Christoph Hellwig for checking and
pointing out the oversight.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
libxfs/rdwr.c

index 0294c98dd5af1e87f10a1383c64a0901206da721..9ee89d30fc8cb967b79af2ab803858df5c629b1f 100644 (file)
@@ -648,6 +648,12 @@ libxfs_getbuf_map(struct xfs_buftarg *btp, struct xfs_buf_map *map,
 void
 libxfs_putbuf(xfs_buf_t *bp)
 {
+       /*
+        * ensure that any errors on this use of the buffer don't carry
+        * over to the next user.
+        */
+       bp->b_error = 0;
+
 #ifdef XFS_BUF_TRACING
        pthread_mutex_lock(&libxfs_bcache->c_mutex);
        lock_buf_count--;
@@ -663,11 +669,6 @@ libxfs_putbuf(xfs_buf_t *bp)
                        pthread_mutex_unlock(&bp->b_lock);
                }
        }
-       /*
-        * ensure that any errors on this use of the buffer don't carry
-        * over to the next user.
-        */
-       bp->b_error = 0;
 
        cache_node_put(libxfs_bcache, (struct cache_node *)bp);
 }