[Concept,6/9] fs: ext4l: Use EXT4_MAX_ORPHAN_FILE_BLOCKS in orphan.c
Commit Message
From: Simon Glass <simon.glass@canonical.com>
Add the EXT4_MAX_ORPHAN_FILE_BLOCKS constant (512) and use it in the
orphan file size check, matching the Linux kernel implementation.
The previous hardcoded value of (8 << 20) assumed 16KB blocks to get
512 blocks, but the proper calculation uses the actual block size
from the inode.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
fs/ext4l/orphan.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
@@ -7,6 +7,8 @@
#include "ext4.h"
#include "ext4_jbd2.h"
+#define EXT4_MAX_ORPHAN_FILE_BLOCKS 512
+
static int ext4_orphan_file_add(handle_t *handle, struct inode *inode)
{
int i, j, start;
@@ -596,7 +598,7 @@ int ext4_init_orphan_info(struct super_block *sb)
* consuming absurd amounts of memory when pinning blocks of orphan
* file in memory.
*/
- if (inode->i_size > 8 << 20) {
+ if (inode->i_size > (EXT4_MAX_ORPHAN_FILE_BLOCKS << inode->i_blkbits)) {
ext4_msg(sb, KERN_ERR, "orphan file too big: %llu",
(unsigned long long)inode->i_size);
ret = -EFSCORRUPTED;