summaryrefslogtreecommitdiff
path: root/fs/hfs/catalog.c
diff options
context:
space:
mode:
authorMarcel Ziswiler <marcel.ziswiler@toradex.com>2019-12-19 10:33:36 +0100
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2019-12-19 10:33:36 +0100
commit01956ef82685c0793214d0bd28889304c7ed9068 (patch)
tree8d4ec514ba1c9e88cb0fd90871777d4917ff113f /fs/hfs/catalog.c
parent866ced99cbaa08b8dafdc0b0febf49cd6c3cf5a8 (diff)
parentfa8a03bec68d9ef89da72277bd3501ed3daa6217 (diff)
Merge branch 'github.com/Freescale/linux-fslc/4.14-2.0.x-imx' into toradex_4.14-2.0.x-imx-next
Conflicts: sound/soc/codecs/sgtl5000.c
Diffstat (limited to 'fs/hfs/catalog.c')
-rw-r--r--fs/hfs/catalog.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
index 8a66405b0f8b..d365bf0b8c77 100644
--- a/fs/hfs/catalog.c
+++ b/fs/hfs/catalog.c
@@ -97,6 +97,14 @@ int hfs_cat_create(u32 cnid, struct inode *dir, const struct qstr *str, struct i
if (err)
return err;
+ /*
+ * Fail early and avoid ENOSPC during the btree operations. We may
+ * have to split the root node at most once.
+ */
+ err = hfs_bmap_reserve(fd.tree, 2 * fd.tree->depth);
+ if (err)
+ goto err2;
+
hfs_cat_build_key(sb, fd.search_key, cnid, NULL);
entry_size = hfs_cat_build_thread(sb, &entry, S_ISDIR(inode->i_mode) ?
HFS_CDR_THD : HFS_CDR_FTH,
@@ -295,6 +303,14 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, const struct qstr *src_name,
return err;
dst_fd = src_fd;
+ /*
+ * Fail early and avoid ENOSPC during the btree operations. We may
+ * have to split the root node at most once.
+ */
+ err = hfs_bmap_reserve(src_fd.tree, 2 * src_fd.tree->depth);
+ if (err)
+ goto out;
+
/* find the old dir entry and read the data */
hfs_cat_build_key(sb, src_fd.search_key, src_dir->i_ino, src_name);
err = hfs_brec_find(&src_fd);