xfs
[Top] [All Lists]

[PATCH 1/2] libxfs: clear the buffer error while the buffer is locked

To: xfs@xxxxxxxxxxx
Subject: [PATCH 1/2] libxfs: clear the buffer error while the buffer is locked
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Wed, 9 Jul 2014 09:41:39 +1000
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1404862900-3369-1-git-send-email-david@xxxxxxxxxxxxx>
References: <1404862900-3369-1-git-send-email-david@xxxxxxxxxxxxx>
From: Dave Chinner <dchinner@xxxxxxxxxx>

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@xxxxxx>
Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
---
 libxfs/rdwr.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index 0294c98..9ee89d3 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -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);
 }
-- 
2.0.0

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