diff mbox series

[f2fs-dev] f2fs-tools: support inline tail

Message ID 20240903075931.3339584-1-bo.wu@vivo.com (mailing list archive)
State New
Headers show
Series [f2fs-dev] f2fs-tools: support inline tail | expand

Commit Message

Wu Bo Sept. 3, 2024, 7:59 a.m. UTC
To maximize the utilization of inode space, we introduced the inline
tail feature. This feature modifies the inode structure, requiring
support from the f2fs tools.

The inode layout /w inline tail:
| inode block     | 4096 |     inline tail enable    |
| --------------- | ---- | --------------------------|
| inode info      | 360  |                           |
| --------------- | ---- | --------------------------|
|                 |      | extra info         | 0~36 |
|                 |      | **compact_addr[16] | 64   |
| addr table[923] | 3692 | reserved           | 4    |
|                 |      | **tail data        |      |
|                 |      | inline_xattr       | 200  |
| --------------- | ---- | --------------------------|
| nid table[5]    | 20   |
| node footer     | 24   |

Change-Id: I1b7bc47f4567a6b6d433379e80ca1e76d678a104
Signed-off-by: Wu Bo <bo.wu@vivo.com>
---
 fsck/fsck.c       | 24 ++++++++++++++++--------
 fsck/fsck.h       |  1 +
 include/f2fs_fs.h | 14 +++++++++++++-
 3 files changed, 30 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/fsck/fsck.c b/fsck/fsck.c
index a18bee9d0c3b..a794b8661ed7 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -1123,14 +1123,22 @@  check_next:
 	}
 
 	/* check data blocks in inode */
-	addrs = ADDRS_PER_INODE(&node_blk->i);
-	if (cur_qtype != -1) {
-		u64 addrs_per_blk = (u64)ADDRS_PER_BLOCK(&node_blk->i);
-		qf_szchk_type[cur_qtype] = QF_SZCHK_REGFILE;
-		qf_maxsize[cur_qtype] = (u64)(addrs + 2 * addrs_per_blk +
-				2 * addrs_per_blk * NIDS_PER_BLOCK +
-				addrs_per_blk * NIDS_PER_BLOCK *
-				NIDS_PER_BLOCK) * F2FS_BLKSIZE;
+	if (node_blk->i.i_flags & cpu_to_le32(F2FS_INLINE_TAIL)) {
+		DBG(3, "ino[0x%x] has inline tail data!\n", nid);
+		child.state |= FSCK_INLINE_TAIL;
+		addrs = COMPACT_ADDRS_PER_INODE;
+		if (cur_qtype != -1)
+			qf_szchk_type[cur_qtype] = QF_SZCHK_INLINE;
+	} else {
+		addrs = ADDRS_PER_INODE(&node_blk->i);
+		if (cur_qtype != -1) {
+			u64 addrs_per_blk = (u64)ADDRS_PER_BLOCK(&node_blk->i);
+			qf_szchk_type[cur_qtype] = QF_SZCHK_REGFILE;
+			qf_maxsize[cur_qtype] = (u64)(addrs + 2 * addrs_per_blk +
+					2 * addrs_per_blk * NIDS_PER_BLOCK +
+					addrs_per_blk * NIDS_PER_BLOCK *
+					NIDS_PER_BLOCK) * F2FS_BLKSIZE;
+		}
 	}
 	for (idx = 0; idx < addrs; idx++, child.pgofs++) {
 		block_t blkaddr = le32_to_cpu(node_blk->i.i_addr[ofs + idx]);
diff --git a/fsck/fsck.h b/fsck/fsck.h
index a8f187e07fe6..db7791ce7016 100644
--- a/fsck/fsck.h
+++ b/fsck/fsck.h
@@ -28,6 +28,7 @@  struct quota_ctx;
 
 #define FSCK_UNMATCHED_EXTENT		0x00000001
 #define FSCK_INLINE_INODE		0x00000002
+#define FSCK_INLINE_TAIL		0x00000004
 
 enum {
 	PREEN_MODE_0,
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 15a1c82ae18f..e7c548ef3c2a 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -666,6 +666,7 @@  enum {
 #define F2FS_IMMUTABLE_FL		0x00000010 /* Immutable file */
 #define F2FS_NOATIME_FL			0x00000080 /* do not update atime */
 #define F2FS_CASEFOLD_FL		0x40000000 /* Casefolded file */
+#define F2FS_INLINE_TAIL		0x80000000 /* Has inline tail */
 
 #define F2FS_ENC_UTF8_12_1	1
 #define F2FS_ENC_STRICT_MODE_FL	(1 << 0)
@@ -962,7 +963,7 @@  static_assert(sizeof(struct node_footer) == 24, "");
 				(DEF_ADDRS_PER_INODE -			\
 				get_inline_xattr_addrs(&node->i) -	\
 				get_extra_isize(node) -			\
-				DEF_INLINE_RESERVED_SIZE))
+				get_reserved_addrs(&node->i)))
 #define DEF_MAX_INLINE_DATA	(sizeof(__le32) *			\
 				(DEF_ADDRS_PER_INODE -			\
 				DEFAULT_INLINE_XATTR_ADDRS -		\
@@ -1400,6 +1401,7 @@  struct f2fs_dentry_block {
 
 /* for inline stuff */
 #define DEF_INLINE_RESERVED_SIZE	1
+#define COMPACT_ADDRS_PER_INODE         16
 
 /* for inline dir */
 #define NR_INLINE_DENTRY(node)	(MAX_INLINE_DATA(node) * BITS_PER_BYTE / \
@@ -1660,6 +1662,16 @@  static inline int get_inline_xattr_addrs(struct f2fs_inode *inode)
 		return 0;
 }
 
+static inline int get_reserved_addrs(struct f2fs_inode *inode)
+{
+	int size = DEF_INLINE_RESERVED_SIZE;
+
+	if (inode->i_flags & cpu_to_le32(F2FS_INLINE_TAIL))
+		size += COMPACT_ADDRS_PER_INODE;
+
+	return size;
+}
+
 #define get_extra_isize(node)	__get_extra_isize(&node->i)
 
 #define F2FS_ZONED_NONE		0