xfs: candidate fixes for 2.6.39-rc4 v2
PATCH 2/4 xfs: don't look forever in xfs_inode_ag_walk during async inode flushes
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
When the underlying inode buffer is locked and xfs_sync_inode_attr() is doing a non-blocking flush, xfs_iflush() can return EAGAIN. When this happenѕ, clear the error rather than returning it to xfs_inode_ag_walk(), as returning EAGAIN will result in the AG walk delaying for a short while and trying again. This can result in background walks getting stuck on the one AG until inode buffer is unlocked by some other means.
This behaviour was noticed when analysing event traces followed by code inspection and verification of the fix via further traces.
--- fs/xfs/linux-2.6/xfs_sync.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
fs/xfs/linux-2.6/xfs_sync.c +10 -0
@@ -267,6 +267,16 @@ xfs_sync_inode_attr( error =xfs_iflush (ip, flags); +/* +* We don't want to try again on non-blocking flushes that can't run +* again immediately. If an inode really must be written, then that's +* what the SYNC_WAIT flag is for. +*/ +if (error ==EAGAIN ) { +ASSERT (!(flags &SYNC_WAIT )); + error =0 ; + } + out_unlock:xfs_iunlock (ip,XFS_ILOCK_SHARED );return error;
Signature · 6 lines
1.7.4.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/4 xfs: fix xfs_itruncate_start tracing
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Variables are ordered incorrectly in trace call.
--- fs/xfs/xfs_inode.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
fs/xfs/xfs_inode.c +1 -1
@@ -1354,7 +1354,7 @@ xfs_itruncate_start(return 0 ; } last_byte =xfs_file_last_byte (ip); -trace_xfs_itruncate_start (ip, flags, new_size, toss_start, last_byte); +trace_xfs_itruncate_start (ip, new_size, flags, toss_start, last_byte);if (last_byte > toss_start) {if (flags &XFS_ITRUNC_DEFINITE ) { xfs_tosspages(ip, toss_start,
Signature · 6 lines
1.7.4.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 3/4 xfs: reset buffer pointers before freeing them
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
When we free a vmapped buffer, we need to ensure the vmap address and length we free is the same as when it was allocated. In various places in the log code we change the memory the buffer is pointing to before issuing IO, but we never reset the buffer to point back to it's original memory (or no memory, if that is the case for the buffer).
As a result, when we free the buffer it points to memory that is owned by something else and attempts to unmap and free it. Because the range does not match any known mapped range, it can trigger BUG_ON() traps in the vmap code, and potentially corrupt the vmap area tracking.
Fix this by always resetting these buffers to their original state before freeing them.
--- fs/xfs/linux-2.6/xfs_buf.c | 21 ++++++++++++ fs/xfs/linux-2.6/xfs_buf.h | 1 + fs/xfs/xfs_log.c | 8 ++++- fs/xfs/xfs_log_recover.c | 75 ++++++++++++++++++++++--------------------- 4 files changed, 67 insertions(+), 38 deletions(-)
fs/xfs/linux-2.6/xfs_buf.c +21 -0
@@ -709,6 +709,27 @@ xfs_buf_get_empty(return bp; } +/* +* Return a buffer allocated as an empty buffer and associated to external +* memory via xfs_buf_associate_memory() back to it's empty state. +*/ +void +xfs_buf_set_empty ( +struct xfs_buf *bp, +size_t len) +{ +if (bp->b_pages) +_xfs_buf_free_pages (bp); + + bp->b_pages =NULL ; + bp->b_page_count =0 ; + bp->b_addr =NULL ; + bp->b_file_offset =0 ; + bp->b_buffer_length = bp->b_count_desired = len; + bp->b_bn =XFS_BUF_DADDR_NULL ; + bp->b_flags &= ~XBF_MAPPED ; +} +static inline struct page *mem_to_page (void *addr)
fs/xfs/linux-2.6/xfs_buf.h +1 -0
@@ -178,6 +178,7 @@ extern xfs_buf_t *xfs_buf_read(xfs_buftarg_t *, xfs_off_t, size_t, xfs_buf_flags_t);extern xfs_buf_t *xfs_buf_get_empty (size_t ,xfs_buftarg_t *); +extern void xfs_buf_set_empty (struct xfs_buf *bp,size_t len);extern xfs_buf_t *xfs_buf_get_uncached (struct xfs_buftarg *,size_t ,int );extern int xfs_buf_associate_memory (xfs_buf_t *,void *,size_t );extern void xfs_buf_hold (xfs_buf_t *);
fs/xfs/xfs_log.c +7 -1
@@ -1449,6 +1449,13 @@ xlog_dealloc_log(xlog_t *log)xlog_cil_destroy (log); +/* +* always need to ensure that the extra buffer does not point to memory +* owned by another log buffer before we free it. +*/ +xfs_buf_set_empty (log->l_xbuf, log->l_iclog_size); +xfs_buf_free (log->l_xbuf); + iclog = log->l_iclog;for (i=0 ; i<log->l_iclog_bufs; i++) {xfs_buf_free (iclog->ic_bp);
@@ -1458,7 +1465,6 @@ xlog_dealloc_log(xlog_t *log) }spinlock_destroy (&log->l_icloglock); -xfs_buf_free (log->l_xbuf); log->l_mp->m_log =NULL ;kmem_free (log); }/* xlog_dealloc_log */
fs/xfs/xfs_log_recover.c +38 -37
102 lines not on this page · raw message
Signature · 6 lines
1.7.4.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
cover xfs: candidate fixes for 2.6.39-rc4 v2
Candidate bug fix patch stack. Updated to fix minor issues Lachlan and Christoph noticed in the first version.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 4/4 xfs: obey minleft values during extent allocation correctly.
From: Dave Chinner <[email protected]>
When allocating an extent that is long enough to consume the remaining free space in an AG, we need to ensure that the allocation leaves enough space in the AG for any subsequent bmap btree blocks that are needed to track the new extent. These have to be allocated in the same AG as we only reserve enough blocks in an allocation transaction for modification of the freespace trees in a single AG.
xfs_alloc_fix_minleft() has been considering blocks on the AGFL as free blocks available for extent and bmbt block allocation, which is not correct - blocks on the AGFL are there exclusively for the use of the free space btrees. As a result, when minleft is less than the number of blocks on the AGFL, xfs_alloc_fix_minleft() does not trim the given extent to leave minleft blocks available for bmbt allocation, and hence we can fail allocation during bmbt record insertion.
--- fs/xfs/xfs_alloc.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
fs/xfs/xfs_alloc.c +0 -1
@@ -280,7 +280,6 @@ xfs_alloc_fix_minleft(return 1 ; agf =XFS_BUF_TO_AGF (args->agbp); diff =be32_to_cpu (agf->agf_freeblks) - +be32_to_cpu (agf->agf_flcount) - args->len - args->minleft;if (diff >=0 )return 1 ;
Signature · 6 lines
1.7.4.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 4/4] xfs: obey minleft values during extent allocation correctly.
ping?
Quoted 43 lines · Dave Chinner
From: Dave Chinner <[email protected]>
When allocating an extent that is long enough to consume the remaining free space in an AG, we need to ensure that the allocation leaves enough space in the AG for any subsequent bmap btree blocks that are needed to track the new extent. These have to be allocated in the same AG as we only reserve enough blocks in an allocation transaction for modification of the freespace trees in a single AG.
xfs_alloc_fix_minleft()has been considering blocks on the AGFL as free blocks available for extent and bmbt block allocation, which is not correct - blocks on the AGFL are there exclusively for the use of the free space btrees. As a result, when minleft is less than the number of blocks on the AGFL,xfs_alloc_fix_minleft()does not trim the given extent to leave minleft blocks available for bmbt allocation, and hence we can fail allocation during bmbt record insertion.Signed-off-by Dave Chinner <[email protected]>--- fs/xfs/xfs_alloc.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)fs/xfs/xfs_alloc.c +0
-1@@ -280,7 +280,6 @@ xfs_alloc_fix_minleft(return 1 ; agf =XFS_BUF_TO_AGF (args->agbp); diff =be32_to_cpu (agf->agf_freeblks) - +be32_to_cpu (agf->agf_flcount) - args->len - args->minleft;if (diff >=0 )return 1 ;Signature · 6 lines
1.7.4.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 4/4] xfs: obey minleft values during extent allocation correctly.
In reply to Dave ChinnerLooks good,
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs