aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@sandeen.net>2014-09-08 21:57:52 -0400
committerDave Chinner <david@fromorbit.com>2014-09-08 21:57:52 -0400
commit94f3cad555d66048906deade06a764f7ea2c6e4d (patch)
tree537cfbb0bcdacfb55f027cac223d6a2e35e358d5
parent970fd3f04d5949a4b5f6d0a5fea8e4b6797a5992 (diff)
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: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r--fs/xfs/libxfs/xfs_dir2.c7
-rw-r--r--fs/xfs/libxfs/xfs_dir2.h2
-rw-r--r--fs/xfs/xfs_inode.c24
-rw-r--r--fs/xfs/xfs_symlink.c8
4 files changed, 22 insertions, 19 deletions
diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
index 6cef22152fd6..ea84e1c47284 100644
--- a/fs/xfs/libxfs/xfs_dir2.c
+++ b/fs/xfs/libxfs/xfs_dir2.c
@@ -535,22 +535,17 @@ out_free:
535 535
536/* 536/*
537 * See if this entry can be added to the directory without allocating space. 537 * See if this entry can be added to the directory without allocating space.
538 * First checks that the caller couldn't reserve enough space (resblks = 0).
539 */ 538 */
540int 539int
541xfs_dir_canenter( 540xfs_dir_canenter(
542 xfs_trans_t *tp, 541 xfs_trans_t *tp,
543 xfs_inode_t *dp, 542 xfs_inode_t *dp,
544 struct xfs_name *name, /* name of entry to add */ 543 struct xfs_name *name) /* name of entry to add */
545 uint resblks)
546{ 544{
547 struct xfs_da_args *args; 545 struct xfs_da_args *args;
548 int rval; 546 int rval;
549 int v; /* type-checking value */ 547 int v; /* type-checking value */
550 548
551 if (resblks)
552 return 0;
553
554 ASSERT(S_ISDIR(dp->i_d.di_mode)); 549 ASSERT(S_ISDIR(dp->i_d.di_mode));
555 550
556 args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS); 551 args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS);
diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h
index c8e86b0b5e99..4dff261e6ed5 100644
--- a/fs/xfs/libxfs/xfs_dir2.h
+++ b/fs/xfs/libxfs/xfs_dir2.h
@@ -136,7 +136,7 @@ extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp,
136 xfs_fsblock_t *first, 136 xfs_fsblock_t *first,
137 struct xfs_bmap_free *flist, xfs_extlen_t tot); 137 struct xfs_bmap_free *flist, xfs_extlen_t tot);
138extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp, 138extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp,
139 struct xfs_name *name, uint resblks); 139 struct xfs_name *name);
140 140
141/* 141/*
142 * Direct call from the bmap code, bypassing the generic directory layer. 142 * Direct call from the bmap code, bypassing the generic directory layer.
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index fea3c92fb3f0..c92cb48617d1 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1153,9 +1153,11 @@ xfs_create(
1153 if (error) 1153 if (error)
1154 goto out_trans_cancel; 1154 goto out_trans_cancel;
1155 1155
1156 error = xfs_dir_canenter(tp, dp, name, resblks); 1156 if (!resblks) {
1157 if (error) 1157 error = xfs_dir_canenter(tp, dp, name);
1158 goto out_trans_cancel; 1158 if (error)
1159 goto out_trans_cancel;
1160 }
1159 1161
1160 /* 1162 /*
1161 * A newly created regular or special file just has one directory 1163 * A newly created regular or special file just has one directory
@@ -1421,9 +1423,11 @@ xfs_link(
1421 goto error_return; 1423 goto error_return;
1422 } 1424 }
1423 1425
1424 error = xfs_dir_canenter(tp, tdp, target_name, resblks); 1426 if (!resblks) {
1425 if (error) 1427 error = xfs_dir_canenter(tp, tdp, target_name);
1426 goto error_return; 1428 if (error)
1429 goto error_return;
1430 }
1427 1431
1428 xfs_bmap_init(&free_list, &first_block); 1432 xfs_bmap_init(&free_list, &first_block);
1429 1433
@@ -2759,9 +2763,11 @@ xfs_rename(
2759 * If there's no space reservation, check the entry will 2763 * If there's no space reservation, check the entry will
2760 * fit before actually inserting it. 2764 * fit before actually inserting it.
2761 */ 2765 */
2762 error = xfs_dir_canenter(tp, target_dp, target_name, spaceres); 2766 if (!spaceres) {
2763 if (error) 2767 error = xfs_dir_canenter(tp, target_dp, target_name);
2764 goto error_return; 2768 if (error)
2769 goto error_return;
2770 }
2765 /* 2771 /*
2766 * If target does not exist and the rename crosses 2772 * If target does not exist and the rename crosses
2767 * directories, adjust the target directory link count 2773 * directories, adjust the target directory link count
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index 6a944a2cd36f..02ae62a998e0 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -269,9 +269,11 @@ xfs_symlink(
269 /* 269 /*
270 * Check for ability to enter directory entry, if no space reserved. 270 * Check for ability to enter directory entry, if no space reserved.
271 */ 271 */
272 error = xfs_dir_canenter(tp, dp, link_name, resblks); 272 if (!resblks) {
273 if (error) 273 error = xfs_dir_canenter(tp, dp, link_name);
274 goto error_return; 274 if (error)
275 goto error_return;
276 }
275 /* 277 /*
276 * Initialize the bmap freelist prior to calling either 278 * Initialize the bmap freelist prior to calling either
277 * bmapi or the directory create code. 279 * bmapi or the directory create code.