提交 94f3cad5 编写于 作者: E Eric Sandeen 提交者: Dave Chinner

xfs: check resblks before calling xfs_dir_canenter

Move the resblks test out of the xfs_dir_canenter,
and into the caller.

This makes a little more sense on the face of it;
xfs_dir_canenter immediately returns if resblks !=0;
and given some of the comments preceding the calls:

 * Check for ability to enter directory entry, if no space reserved.

even more so.

It also facilitates the next patch.
Signed-off-by: NEric Sandeen <sandeen@redhat.com>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NBrian Foster <bfoster@redhat.com>
Signed-off-by: NDave Chinner <david@fromorbit.com>
上级 970fd3f0
...@@ -535,22 +535,17 @@ xfs_dir_replace( ...@@ -535,22 +535,17 @@ xfs_dir_replace(
/* /*
* See if this entry can be added to the directory without allocating space. * See if this entry can be added to the directory without allocating space.
* First checks that the caller couldn't reserve enough space (resblks = 0).
*/ */
int int
xfs_dir_canenter( xfs_dir_canenter(
xfs_trans_t *tp, xfs_trans_t *tp,
xfs_inode_t *dp, xfs_inode_t *dp,
struct xfs_name *name, /* name of entry to add */ struct xfs_name *name) /* name of entry to add */
uint resblks)
{ {
struct xfs_da_args *args; struct xfs_da_args *args;
int rval; int rval;
int v; /* type-checking value */ int v; /* type-checking value */
if (resblks)
return 0;
ASSERT(S_ISDIR(dp->i_d.di_mode)); ASSERT(S_ISDIR(dp->i_d.di_mode));
args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS); args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS);
......
...@@ -136,7 +136,7 @@ extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp, ...@@ -136,7 +136,7 @@ extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp,
xfs_fsblock_t *first, xfs_fsblock_t *first,
struct xfs_bmap_free *flist, xfs_extlen_t tot); struct xfs_bmap_free *flist, xfs_extlen_t tot);
extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp, extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp,
struct xfs_name *name, uint resblks); struct xfs_name *name);
/* /*
* Direct call from the bmap code, bypassing the generic directory layer. * Direct call from the bmap code, bypassing the generic directory layer.
......
...@@ -1153,9 +1153,11 @@ xfs_create( ...@@ -1153,9 +1153,11 @@ xfs_create(
if (error) if (error)
goto out_trans_cancel; goto out_trans_cancel;
error = xfs_dir_canenter(tp, dp, name, resblks); if (!resblks) {
if (error) error = xfs_dir_canenter(tp, dp, name);
goto out_trans_cancel; if (error)
goto out_trans_cancel;
}
/* /*
* A newly created regular or special file just has one directory * A newly created regular or special file just has one directory
...@@ -1421,9 +1423,11 @@ xfs_link( ...@@ -1421,9 +1423,11 @@ xfs_link(
goto error_return; goto error_return;
} }
error = xfs_dir_canenter(tp, tdp, target_name, resblks); if (!resblks) {
if (error) error = xfs_dir_canenter(tp, tdp, target_name);
goto error_return; if (error)
goto error_return;
}
xfs_bmap_init(&free_list, &first_block); xfs_bmap_init(&free_list, &first_block);
...@@ -2759,9 +2763,11 @@ xfs_rename( ...@@ -2759,9 +2763,11 @@ xfs_rename(
* If there's no space reservation, check the entry will * If there's no space reservation, check the entry will
* fit before actually inserting it. * fit before actually inserting it.
*/ */
error = xfs_dir_canenter(tp, target_dp, target_name, spaceres); if (!spaceres) {
if (error) error = xfs_dir_canenter(tp, target_dp, target_name);
goto error_return; if (error)
goto error_return;
}
/* /*
* If target does not exist and the rename crosses * If target does not exist and the rename crosses
* directories, adjust the target directory link count * directories, adjust the target directory link count
......
...@@ -269,9 +269,11 @@ xfs_symlink( ...@@ -269,9 +269,11 @@ xfs_symlink(
/* /*
* Check for ability to enter directory entry, if no space reserved. * Check for ability to enter directory entry, if no space reserved.
*/ */
error = xfs_dir_canenter(tp, dp, link_name, resblks); if (!resblks) {
if (error) error = xfs_dir_canenter(tp, dp, link_name);
goto error_return; if (error)
goto error_return;
}
/* /*
* Initialize the bmap freelist prior to calling either * Initialize the bmap freelist prior to calling either
* bmapi or the directory create code. * bmapi or the directory create code.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册