ext4l: Add inode-tracking lists

U-Boot does not track allocated inodes, causing memory leaks when
remounting filesystems.

Add s_inodes list to super_block and i_sb_list to inode structures to
track all allocated inodes, allowing proper eviction on unmount.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
Simon Glass
2025-12-31 09:09:58 -07:00
parent 142ffe2c65
commit f7db5fb482
2 changed files with 14 additions and 0 deletions

View File

@@ -682,6 +682,9 @@ struct super_block {
const struct export_operations *s_export_op;
const struct xattr_handler * const *s_xattr;
struct dentry *d_sb; /* Parent dentry - stub */
/* U-Boot: list of all inodes, for freeing on unmount */
struct list_head s_inodes;
};
/* Block device read-only check - stub */
@@ -859,6 +862,9 @@ struct inode {
struct rw_semaphore i_rwsem; /* inode lock */
const char *i_link; /* Symlink target for fast symlinks */
unsigned short i_write_hint; /* Write life time hint */
/* U-Boot: linkage into super_block s_inodes list */
struct list_head i_sb_list;
};
/* Inode time accessors */

View File

@@ -126,6 +126,10 @@ struct inode *iget_locked(struct super_block *sb, unsigned long ino)
inode->i_mapping = &inode->i_data;
inode->i_data.host = inode;
INIT_LIST_HEAD(&ei->i_es_list);
INIT_LIST_HEAD(&inode->i_sb_list);
/* Add to superblock's inode list for eviction on unmount */
list_add(&inode->i_sb_list, &sb->s_inodes);
return inode;
}
@@ -154,6 +158,10 @@ struct inode *new_inode(struct super_block *sb)
inode->i_mapping = &inode->i_data;
inode->i_data.host = inode;
INIT_LIST_HEAD(&ei->i_es_list);
INIT_LIST_HEAD(&inode->i_sb_list);
/* Add to superblock's inode list for eviction on unmount */
list_add(&inode->i_sb_list, &sb->s_inodes);
return inode;
}