xfs: reinstate the ilock in xfs_readdir
Although it was removed in commit 051e7cd44a
, ilock needs to be taken in
xfs_readdir because we might have to read the extent list in from disk. This
keeps other threads from reading from or writing to the extent list while it is
being read in and is still in a transitional state.
This has been associated with "Access to block zero" messages on directories
with large numbers of extents resulting from excessive filesytem fragmentation,
as well as extent list corruption. Unfortunately no test case at this point.
Signed-off-by: Ben Myers <bpm@sgi.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
This commit is contained in:
parent
efa70be165
commit
40194ecc6d
|
@ -674,6 +674,7 @@ xfs_readdir(
|
||||||
{
|
{
|
||||||
int rval; /* return value */
|
int rval; /* return value */
|
||||||
int v; /* type-checking value */
|
int v; /* type-checking value */
|
||||||
|
uint lock_mode;
|
||||||
|
|
||||||
trace_xfs_readdir(dp);
|
trace_xfs_readdir(dp);
|
||||||
|
|
||||||
|
@ -683,6 +684,7 @@ xfs_readdir(
|
||||||
ASSERT(S_ISDIR(dp->i_d.di_mode));
|
ASSERT(S_ISDIR(dp->i_d.di_mode));
|
||||||
XFS_STATS_INC(xs_dir_getdents);
|
XFS_STATS_INC(xs_dir_getdents);
|
||||||
|
|
||||||
|
lock_mode = xfs_ilock_data_map_shared(dp);
|
||||||
if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL)
|
if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL)
|
||||||
rval = xfs_dir2_sf_getdents(dp, ctx);
|
rval = xfs_dir2_sf_getdents(dp, ctx);
|
||||||
else if ((rval = xfs_dir2_isblock(NULL, dp, &v)))
|
else if ((rval = xfs_dir2_isblock(NULL, dp, &v)))
|
||||||
|
@ -691,5 +693,7 @@ xfs_readdir(
|
||||||
rval = xfs_dir2_block_getdents(dp, ctx);
|
rval = xfs_dir2_block_getdents(dp, ctx);
|
||||||
else
|
else
|
||||||
rval = xfs_dir2_leaf_getdents(dp, ctx, bufsize);
|
rval = xfs_dir2_leaf_getdents(dp, ctx, bufsize);
|
||||||
|
xfs_iunlock(dp, lock_mode);
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue