Commit 60fe791f authored by Glen Overby's avatar Glen Overby Committed by Stephen Lord

[XFS] Fix freespace entry search to handle holes in the freespace area correctly.

SGI Modid: 2.5.x-xfs:slinx:133509a
parent 2ed1e312
...@@ -1348,6 +1348,7 @@ xfs_dir2_node_addname_int( ...@@ -1348,6 +1348,7 @@ xfs_dir2_node_addname_int(
int findex; /* freespace entry index */ int findex; /* freespace entry index */
xfs_dir2_db_t foundbno=0; /* found freespace block no */ xfs_dir2_db_t foundbno=0; /* found freespace block no */
int foundindex=0; /* found freespace entry idx */ int foundindex=0; /* found freespace entry idx */
int foundhole; /* found hole in freespace */
xfs_dir2_free_t *free=NULL; /* freespace block structure */ xfs_dir2_free_t *free=NULL; /* freespace block structure */
xfs_dir2_db_t ifbno; /* initial freespace block no */ xfs_dir2_db_t ifbno; /* initial freespace block no */
xfs_dir2_db_t lastfbno=0; /* highest freespace block no */ xfs_dir2_db_t lastfbno=0; /* highest freespace block no */
...@@ -1363,6 +1364,7 @@ xfs_dir2_node_addname_int( ...@@ -1363,6 +1364,7 @@ xfs_dir2_node_addname_int(
mp = dp->i_mount; mp = dp->i_mount;
tp = args->trans; tp = args->trans;
length = XFS_DIR2_DATA_ENTSIZE(args->namelen); length = XFS_DIR2_DATA_ENTSIZE(args->namelen);
foundhole = 0;
/* /*
* If we came in with a freespace block that means that lookup * If we came in with a freespace block that means that lookup
* found an entry with our hash value. This is the freespace * found an entry with our hash value. This is the freespace
...@@ -1452,11 +1454,12 @@ xfs_dir2_node_addname_int( ...@@ -1452,11 +1454,12 @@ xfs_dir2_node_addname_int(
* to avoid it. * to avoid it.
*/ */
if ((error = xfs_da_read_buf(tp, dp, if ((error = xfs_da_read_buf(tp, dp,
XFS_DIR2_DB_TO_DA(mp, fbno), -1, &fbp, XFS_DIR2_DB_TO_DA(mp, fbno), -2, &fbp,
XFS_DATA_FORK))) { XFS_DATA_FORK))) {
return error; return error;
} }
if (fbp == NULL) { if (unlikely(fbp == NULL)) {
foundhole = 1;
continue; continue;
} }
free = fbp->data; free = fbp->data;
...@@ -1475,7 +1478,7 @@ xfs_dir2_node_addname_int( ...@@ -1475,7 +1478,7 @@ xfs_dir2_node_addname_int(
* one is empty, remember this slot. * one is empty, remember this slot.
*/ */
if (foundindex == -1 && if (foundindex == -1 &&
INT_GET(free->bests[findex], ARCH_CONVERT) == NULLDATAOFF) { INT_GET(free->bests[findex], ARCH_CONVERT) == NULLDATAOFF && !foundhole) {
foundindex = findex; foundindex = findex;
foundbno = fbno; foundbno = fbno;
} }
...@@ -1489,7 +1492,8 @@ xfs_dir2_node_addname_int( ...@@ -1489,7 +1492,8 @@ xfs_dir2_node_addname_int(
* remember this slot. * remember this slot.
*/ */
if (foundindex == -1 && if (foundindex == -1 &&
findex < XFS_DIR2_MAX_FREE_BESTS(mp)) { findex < XFS_DIR2_MAX_FREE_BESTS(mp) &&
!foundhole) {
foundindex = findex; foundindex = findex;
foundbno = fbno; foundbno = fbno;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment