Commit 346c1d46 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Carlos Maiolino

xfs: return bool from xfs_attr3_leaf_add

xfs_attr3_leaf_add only has two potential return values, indicating if the
entry could be added or not.  Replace the errno return with a bool so that
ENOSPC from it can't easily be confused with a real ENOSPC.

Remove the return value from the xfs_attr3_leaf_add_work helper entirely,
as it always return 0.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarCarlos Maiolino <cem@kernel.org>
parent b1c649da
...@@ -557,10 +557,7 @@ xfs_attr_leaf_addname( ...@@ -557,10 +557,7 @@ xfs_attr_leaf_addname(
* or perform more xattr manipulations. Otherwise there is nothing more * or perform more xattr manipulations. Otherwise there is nothing more
* to do and we can return success. * to do and we can return success.
*/ */
error = xfs_attr3_leaf_add(bp, args); if (!xfs_attr3_leaf_add(bp, args)) {
if (error) {
if (error != -ENOSPC)
return error;
error = xfs_attr3_leaf_to_node(args); error = xfs_attr3_leaf_to_node(args);
if (error) if (error)
return error; return error;
...@@ -574,7 +571,7 @@ xfs_attr_leaf_addname( ...@@ -574,7 +571,7 @@ xfs_attr_leaf_addname(
} }
trace_xfs_attr_leaf_addname_return(attr->xattri_dela_state, args->dp); trace_xfs_attr_leaf_addname_return(attr->xattri_dela_state, args->dp);
return error; return 0;
out_brelse: out_brelse:
xfs_trans_brelse(args->trans, bp); xfs_trans_brelse(args->trans, bp);
...@@ -1399,21 +1396,21 @@ xfs_attr_node_try_addname( ...@@ -1399,21 +1396,21 @@ xfs_attr_node_try_addname(
{ {
struct xfs_da_state *state = attr->xattri_da_state; struct xfs_da_state *state = attr->xattri_da_state;
struct xfs_da_state_blk *blk; struct xfs_da_state_blk *blk;
int error; int error = 0;
trace_xfs_attr_node_addname(state->args); trace_xfs_attr_node_addname(state->args);
blk = &state->path.blk[state->path.active-1]; blk = &state->path.blk[state->path.active-1];
ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC);
error = xfs_attr3_leaf_add(blk->bp, state->args); if (!xfs_attr3_leaf_add(blk->bp, state->args)) {
if (error == -ENOSPC) {
if (state->path.active == 1) { if (state->path.active == 1) {
/* /*
* Its really a single leaf node, but it had * Its really a single leaf node, but it had
* out-of-line values so it looked like it *might* * out-of-line values so it looked like it *might*
* have been a b-tree. Let the caller deal with this. * have been a b-tree. Let the caller deal with this.
*/ */
error = -ENOSPC;
goto out; goto out;
} }
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
*/ */
STATIC int xfs_attr3_leaf_create(struct xfs_da_args *args, STATIC int xfs_attr3_leaf_create(struct xfs_da_args *args,
xfs_dablk_t which_block, struct xfs_buf **bpp); xfs_dablk_t which_block, struct xfs_buf **bpp);
STATIC int xfs_attr3_leaf_add_work(struct xfs_buf *leaf_buffer, STATIC void xfs_attr3_leaf_add_work(struct xfs_buf *leaf_buffer,
struct xfs_attr3_icleaf_hdr *ichdr, struct xfs_attr3_icleaf_hdr *ichdr,
struct xfs_da_args *args, int freemap_index); struct xfs_da_args *args, int freemap_index);
STATIC void xfs_attr3_leaf_compact(struct xfs_da_args *args, STATIC void xfs_attr3_leaf_compact(struct xfs_da_args *args,
...@@ -995,10 +995,8 @@ xfs_attr_shortform_to_leaf( ...@@ -995,10 +995,8 @@ xfs_attr_shortform_to_leaf(
xfs_attr_sethash(&nargs); xfs_attr_sethash(&nargs);
error = xfs_attr3_leaf_lookup_int(bp, &nargs); /* set a->index */ error = xfs_attr3_leaf_lookup_int(bp, &nargs); /* set a->index */
ASSERT(error == -ENOATTR); ASSERT(error == -ENOATTR);
error = xfs_attr3_leaf_add(bp, &nargs); if (!xfs_attr3_leaf_add(bp, &nargs))
ASSERT(error != -ENOSPC); ASSERT(0);
if (error)
goto out;
sfe = xfs_attr_sf_nextentry(sfe); sfe = xfs_attr_sf_nextentry(sfe);
} }
error = 0; error = 0;
...@@ -1340,8 +1338,9 @@ xfs_attr3_leaf_split( ...@@ -1340,8 +1338,9 @@ xfs_attr3_leaf_split(
struct xfs_da_state_blk *oldblk, struct xfs_da_state_blk *oldblk,
struct xfs_da_state_blk *newblk) struct xfs_da_state_blk *newblk)
{ {
xfs_dablk_t blkno; bool added;
int error; xfs_dablk_t blkno;
int error;
trace_xfs_attr_leaf_split(state->args); trace_xfs_attr_leaf_split(state->args);
...@@ -1376,10 +1375,10 @@ xfs_attr3_leaf_split( ...@@ -1376,10 +1375,10 @@ xfs_attr3_leaf_split(
*/ */
if (state->inleaf) { if (state->inleaf) {
trace_xfs_attr_leaf_add_old(state->args); trace_xfs_attr_leaf_add_old(state->args);
error = xfs_attr3_leaf_add(oldblk->bp, state->args); added = xfs_attr3_leaf_add(oldblk->bp, state->args);
} else { } else {
trace_xfs_attr_leaf_add_new(state->args); trace_xfs_attr_leaf_add_new(state->args);
error = xfs_attr3_leaf_add(newblk->bp, state->args); added = xfs_attr3_leaf_add(newblk->bp, state->args);
} }
/* /*
...@@ -1387,13 +1386,15 @@ xfs_attr3_leaf_split( ...@@ -1387,13 +1386,15 @@ xfs_attr3_leaf_split(
*/ */
oldblk->hashval = xfs_attr_leaf_lasthash(oldblk->bp, NULL); oldblk->hashval = xfs_attr_leaf_lasthash(oldblk->bp, NULL);
newblk->hashval = xfs_attr_leaf_lasthash(newblk->bp, NULL); newblk->hashval = xfs_attr_leaf_lasthash(newblk->bp, NULL);
return error; if (!added)
return -ENOSPC;
return 0;
} }
/* /*
* Add a name to the leaf attribute list structure. * Add a name to the leaf attribute list structure.
*/ */
int bool
xfs_attr3_leaf_add( xfs_attr3_leaf_add(
struct xfs_buf *bp, struct xfs_buf *bp,
struct xfs_da_args *args) struct xfs_da_args *args)
...@@ -1402,6 +1403,7 @@ xfs_attr3_leaf_add( ...@@ -1402,6 +1403,7 @@ xfs_attr3_leaf_add(
struct xfs_attr3_icleaf_hdr ichdr; struct xfs_attr3_icleaf_hdr ichdr;
int tablesize; int tablesize;
int entsize; int entsize;
bool added = true;
int sum; int sum;
int tmp; int tmp;
int i; int i;
...@@ -1430,7 +1432,7 @@ xfs_attr3_leaf_add( ...@@ -1430,7 +1432,7 @@ xfs_attr3_leaf_add(
if (ichdr.freemap[i].base < ichdr.firstused) if (ichdr.freemap[i].base < ichdr.firstused)
tmp += sizeof(xfs_attr_leaf_entry_t); tmp += sizeof(xfs_attr_leaf_entry_t);
if (ichdr.freemap[i].size >= tmp) { if (ichdr.freemap[i].size >= tmp) {
tmp = xfs_attr3_leaf_add_work(bp, &ichdr, args, i); xfs_attr3_leaf_add_work(bp, &ichdr, args, i);
goto out_log_hdr; goto out_log_hdr;
} }
sum += ichdr.freemap[i].size; sum += ichdr.freemap[i].size;
...@@ -1442,7 +1444,7 @@ xfs_attr3_leaf_add( ...@@ -1442,7 +1444,7 @@ xfs_attr3_leaf_add(
* no good and we should just give up. * no good and we should just give up.
*/ */
if (!ichdr.holes && sum < entsize) if (!ichdr.holes && sum < entsize)
return -ENOSPC; return false;
/* /*
* Compact the entries to coalesce free space. * Compact the entries to coalesce free space.
...@@ -1455,24 +1457,24 @@ xfs_attr3_leaf_add( ...@@ -1455,24 +1457,24 @@ xfs_attr3_leaf_add(
* free region, in freemap[0]. If it is not big enough, give up. * free region, in freemap[0]. If it is not big enough, give up.
*/ */
if (ichdr.freemap[0].size < (entsize + sizeof(xfs_attr_leaf_entry_t))) { if (ichdr.freemap[0].size < (entsize + sizeof(xfs_attr_leaf_entry_t))) {
tmp = -ENOSPC; added = false;
goto out_log_hdr; goto out_log_hdr;
} }
tmp = xfs_attr3_leaf_add_work(bp, &ichdr, args, 0); xfs_attr3_leaf_add_work(bp, &ichdr, args, 0);
out_log_hdr: out_log_hdr:
xfs_attr3_leaf_hdr_to_disk(args->geo, leaf, &ichdr); xfs_attr3_leaf_hdr_to_disk(args->geo, leaf, &ichdr);
xfs_trans_log_buf(args->trans, bp, xfs_trans_log_buf(args->trans, bp,
XFS_DA_LOGRANGE(leaf, &leaf->hdr, XFS_DA_LOGRANGE(leaf, &leaf->hdr,
xfs_attr3_leaf_hdr_size(leaf))); xfs_attr3_leaf_hdr_size(leaf)));
return tmp; return added;
} }
/* /*
* Add a name to a leaf attribute list structure. * Add a name to a leaf attribute list structure.
*/ */
STATIC int STATIC void
xfs_attr3_leaf_add_work( xfs_attr3_leaf_add_work(
struct xfs_buf *bp, struct xfs_buf *bp,
struct xfs_attr3_icleaf_hdr *ichdr, struct xfs_attr3_icleaf_hdr *ichdr,
...@@ -1590,7 +1592,6 @@ xfs_attr3_leaf_add_work( ...@@ -1590,7 +1592,6 @@ xfs_attr3_leaf_add_work(
} }
} }
ichdr->usedbytes += xfs_attr_leaf_entsize(leaf, args->index); ichdr->usedbytes += xfs_attr_leaf_entsize(leaf, args->index);
return 0;
} }
/* /*
......
...@@ -76,7 +76,7 @@ int xfs_attr3_leaf_split(struct xfs_da_state *state, ...@@ -76,7 +76,7 @@ int xfs_attr3_leaf_split(struct xfs_da_state *state,
int xfs_attr3_leaf_lookup_int(struct xfs_buf *leaf, int xfs_attr3_leaf_lookup_int(struct xfs_buf *leaf,
struct xfs_da_args *args); struct xfs_da_args *args);
int xfs_attr3_leaf_getvalue(struct xfs_buf *bp, struct xfs_da_args *args); int xfs_attr3_leaf_getvalue(struct xfs_buf *bp, struct xfs_da_args *args);
int xfs_attr3_leaf_add(struct xfs_buf *leaf_buffer, bool xfs_attr3_leaf_add(struct xfs_buf *leaf_buffer,
struct xfs_da_args *args); struct xfs_da_args *args);
int xfs_attr3_leaf_remove(struct xfs_buf *leaf_buffer, int xfs_attr3_leaf_remove(struct xfs_buf *leaf_buffer,
struct xfs_da_args *args); struct xfs_da_args *args);
......
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