Commit dee0f2b2 authored by Eric Sandeen's avatar Eric Sandeen Committed by Stephen Lord

[XFS] Last of the dir2 backmerges from Irix

SGI Modid: 2.5.x-xfs:slinx:140918a
parent 2af62e92
...@@ -1512,7 +1512,7 @@ xfs_dir2_node_addname_int( ...@@ -1512,7 +1512,7 @@ xfs_dir2_node_addname_int(
* If we don't have a data block, we need to allocate one and make * If we don't have a data block, we need to allocate one and make
* the freespace entries refer to it. * the freespace entries refer to it.
*/ */
if (dbno == -1) { if (unlikely(dbno == -1)) {
/* /*
* Not allowed to allocate, return failure. * Not allowed to allocate, return failure.
*/ */
...@@ -1521,7 +1521,7 @@ xfs_dir2_node_addname_int( ...@@ -1521,7 +1521,7 @@ xfs_dir2_node_addname_int(
* Drop the freespace buffer unless it came from our * Drop the freespace buffer unless it came from our
* caller. * caller.
*/ */
if (fblk == NULL || fblk->bp == NULL) if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
xfs_da_buf_done(fbp); xfs_da_buf_done(fbp);
return XFS_ERROR(ENOSPC); return XFS_ERROR(ENOSPC);
} }
...@@ -1535,7 +1535,7 @@ xfs_dir2_node_addname_int( ...@@ -1535,7 +1535,7 @@ xfs_dir2_node_addname_int(
* Drop the freespace buffer unless it came from our * Drop the freespace buffer unless it came from our
* caller. * caller.
*/ */
if (fblk == NULL || fblk->bp == NULL) if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
xfs_da_buf_done(fbp); xfs_da_buf_done(fbp);
return error; return error;
} }
...@@ -1552,7 +1552,7 @@ xfs_dir2_node_addname_int( ...@@ -1552,7 +1552,7 @@ xfs_dir2_node_addname_int(
fblk->bp = NULL; fblk->bp = NULL;
fbno = XFS_DIR2_DB_TO_FDB(mp, dbno); fbno = XFS_DIR2_DB_TO_FDB(mp, dbno);
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))) {
xfs_da_buf_done(dbp); xfs_da_buf_done(dbp);
return error; return error;
...@@ -1659,16 +1659,17 @@ xfs_dir2_node_addname_int( ...@@ -1659,16 +1659,17 @@ xfs_dir2_node_addname_int(
* If just checking, we succeeded. * If just checking, we succeeded.
*/ */
if (args->justcheck) { if (args->justcheck) {
if (fblk == NULL || fblk->bp == NULL) if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
xfs_da_buf_done(fbp); xfs_da_buf_done(fbp);
return 0; return 0;
} }
/* /*
* Read the data block in. * Read the data block in.
*/ */
if ((error = xfs_da_read_buf(tp, dp, XFS_DIR2_DB_TO_DA(mp, dbno), if (unlikely(
error = xfs_da_read_buf(tp, dp, XFS_DIR2_DB_TO_DA(mp, dbno),
-1, &dbp, XFS_DATA_FORK))) { -1, &dbp, XFS_DATA_FORK))) {
if (fblk == NULL || fblk->bp == NULL) if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
xfs_da_buf_done(fbp); xfs_da_buf_done(fbp);
return error; return error;
} }
...@@ -1723,7 +1724,7 @@ xfs_dir2_node_addname_int( ...@@ -1723,7 +1724,7 @@ xfs_dir2_node_addname_int(
/* /*
* If the caller didn't hand us the freespace block, drop it. * If the caller didn't hand us the freespace block, drop it.
*/ */
if (fblk == NULL || fblk->bp == NULL) if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
xfs_da_buf_done(fbp); xfs_da_buf_done(fbp);
/* /*
* Return the data block and offset in args, then drop the data block. * Return the data block and offset in args, then drop the data block.
...@@ -1951,10 +1952,18 @@ xfs_dir2_node_trim_free( ...@@ -1951,10 +1952,18 @@ xfs_dir2_node_trim_free(
/* /*
* Read the freespace block. * Read the freespace block.
*/ */
if ((error = xfs_da_read_buf(tp, dp, (xfs_dablk_t)fo, -1, &bp, if (unlikely(error = xfs_da_read_buf(tp, dp, (xfs_dablk_t)fo, -2, &bp,
XFS_DATA_FORK))) { XFS_DATA_FORK))) {
return error; return error;
} }
/*
* There can be holes in freespace. If fo is a hole, there's
* nothing to do.
*/
if (bp == NULL) {
return 0;
}
free = bp->data; free = bp->data;
ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC);
/* /*
......
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