aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2014-05-06 18:05:52 -0400
committerDave Chinner <david@fromorbit.com>2014-05-06 18:05:52 -0400
commit8cfcc3e565bf15870efe801368a25ca98092e6e7 (patch)
tree87fd37e53b238733e3e214d35f799aabe7286127 /fs/xfs
parentac983517ec5941da0c58cacdbad10a231dc4e001 (diff)
xfs: fix directory readahead offset off-by-one
Directory readahead can throw loud scary but harmless warnings when multiblock directories are in use a specific pattern of discontiguous blocks are found in the directory. That is, if a hole follows a discontiguous block, it will throw a warning like: XFS (dm-1): xfs_da_do_buf: bno 637 dir: inode 34363923462 XFS (dm-1): [00] br_startoff 637 br_startblock 1917954575 br_blockcount 1 br_state 0 XFS (dm-1): [01] br_startoff 638 br_startblock -2 br_blockcount 1 br_state 0 And dump a stack trace. This is because the readahead offset increment loop does a double increment of the block index - it does an increment for the loop iteration as well as increase the loop counter by the number of blocks in the extent. As a result, the readahead offset does not get incremented correctly for discontiguous blocks and hence can ask for readahead of a directory block from an offset part way through a directory block. If that directory block is followed by a hole, it will trigger a mapping warning like the above. The bad readahead will be ignored, though, because the main directory block read loop uses the correct mapping offsets rather than the readahead offset and so will ignore the bad readahead altogether. Fix the warning by ensuring that the readahead offset is correctly incremented. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_dir2_readdir.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
index aead369e1c30..a312e1a9a155 100644
--- a/fs/xfs/xfs_dir2_readdir.c
+++ b/fs/xfs/xfs_dir2_readdir.c
@@ -456,7 +456,7 @@ xfs_dir2_leaf_readbuf(
456 /* 456 /*
457 * Advance offset through the mapping table. 457 * Advance offset through the mapping table.
458 */ 458 */
459 for (j = 0; j < mp->m_dirblkfsbs; j++) { 459 for (j = 0; j < mp->m_dirblkfsbs; j += length ) {
460 /* 460 /*
461 * The rest of this extent but not more than a dir 461 * The rest of this extent but not more than a dir
462 * block. 462 * block.
@@ -464,7 +464,6 @@ xfs_dir2_leaf_readbuf(
464 length = min_t(int, mp->m_dirblkfsbs, 464 length = min_t(int, mp->m_dirblkfsbs,
465 map[mip->ra_index].br_blockcount - 465 map[mip->ra_index].br_blockcount -
466 mip->ra_offset); 466 mip->ra_offset);
467 j += length;
468 mip->ra_offset += length; 467 mip->ra_offset += length;
469 468
470 /* 469 /*