Thread (38 messages) 38 messages, 1 author, 2021-02-18
STALE1973d REVIEWED: 1 (0M)
Revisions (4)
  1. v12 [diff vs current]
  2. v13 [diff vs current]
  3. v14 [diff vs current]
  4. v15 current

[PATCH v15 05/37] xfsprogs: Check for extent overflow when adding dir entries

From: Allison Henderson <hidden>
Date: 2021-02-18 18:46:30
Subsystem: the rest · Maintainer: Linus Torvalds

From: Chandan Babu R <redacted>

Source kernel commit: f5d92749191402c50e32ac83dd9da3b910f5680f

Directory entry addition can cause the following,
1. Data block can be added/removed.
A new extent can cause extent count to increase by 1.
2. Free disk block can be added/removed.
Same behaviour as described above for Data block.
3. Dabtree blocks.
XFS_DA_NODE_MAXDEPTH blocks can be added. Each of these
can be new extents. Hence extent count can increase by
XFS_DA_NODE_MAXDEPTH.

Signed-off-by: Chandan Babu R <redacted>
Reviewed-by: Darrick J. Wong <redacted>
Signed-off-by: Darrick J. Wong <redacted>
Signed-off-by: Allison Henderson <redacted>
---
 libxfs/xfs_inode_fork.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff --git a/libxfs/xfs_inode_fork.h b/libxfs/xfs_inode_fork.h
index bcac769..ea1a9dd 100644
--- a/libxfs/xfs_inode_fork.h
+++ b/libxfs/xfs_inode_fork.h
@@ -48,6 +48,19 @@ struct xfs_ifork {
 #define XFS_IEXT_PUNCH_HOLE_CNT		(1)
 
 /*
+ * Directory entry addition can cause the following,
+ * 1. Data block can be added/removed.
+ *    A new extent can cause extent count to increase by 1.
+ * 2. Free disk block can be added/removed.
+ *    Same behaviour as described above for Data block.
+ * 3. Dabtree blocks.
+ *    XFS_DA_NODE_MAXDEPTH blocks can be added. Each of these can be new
+ *    extents. Hence extent count can increase by XFS_DA_NODE_MAXDEPTH.
+ */
+#define XFS_IEXT_DIR_MANIP_CNT(mp) \
+	((XFS_DA_NODE_MAXDEPTH + 1 + 1) * (mp)->m_dir_geo->fsbcount)
+
+/*
  * Fork handling.
  */
 
-- 
2.7.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help