fs/ext4/mballoc-test.c
Source file repositories/reference/linux-study-clean/fs/ext4/mballoc-test.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ext4/mballoc-test.c- Extension
.c- Size
- 27602 bytes
- Lines
- 1014
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
kunit/test.hkunit/static_stub.hlinux/fs_context.hlinux/random.hext4.hmballoc.h
Detected Declarations
struct mbt_grp_ctxstruct mbt_ctxstruct mbt_ext4_super_blockstruct mbt_ext4_block_layoutstruct test_rangefunction mbt_free_inodefunction mbt_kill_sbfunction mbt_init_fs_contextfunction mbt_mb_initfunction mbt_mb_releasefunction mbt_setfunction mbt_ext4_free_super_blockfunction mbt_init_sb_layoutfunction mbt_grp_ctx_initfunction mbt_grp_ctx_releasefunction mbt_ctx_mark_usedfunction mbt_ctx_initfunction mbt_ctx_releasefunction ext4_read_block_bitmap_nowait_stubfunction ext4_wait_block_bitmap_stubfunction ext4_get_group_desc_stubfunction ext4_mb_mark_context_stubfunction mbt_kunit_initfunction mbt_kunit_exitfunction test_new_blocks_simplefunction mbt_generate_test_rangesfunction validate_free_blocks_simplefunction test_free_blocks_simple_rangefunction test_free_blocks_simplefunction test_mark_diskspace_used_rangefunction test_mark_diskspace_usedfunction mbt_generate_buddyfunction mbt_validate_group_infofunction do_test_generate_buddyfunction test_mb_generate_buddyfunction test_mb_mark_used_rangefunction test_mb_mark_usedfunction test_mb_free_blocks_rangefunction test_mb_free_blocksfunction test_mb_mark_used_costfunction mbt_show_layout
Annotated Snippet
struct mbt_grp_ctx {
struct buffer_head bitmap_bh;
/* desc and gd_bh are just the place holders for now */
struct ext4_group_desc desc;
struct buffer_head gd_bh;
};
struct mbt_ctx {
struct mbt_grp_ctx *grp_ctx;
};
struct mbt_ext4_super_block {
struct ext4_super_block es;
struct ext4_sb_info sbi;
struct mbt_ctx mbt_ctx;
};
#define MBT_SB(_sb) (container_of((_sb)->s_fs_info, struct mbt_ext4_super_block, sbi))
#define MBT_CTX(_sb) (&MBT_SB(_sb)->mbt_ctx)
#define MBT_GRP_CTX(_sb, _group) (&MBT_CTX(_sb)->grp_ctx[_group])
static struct inode *mbt_alloc_inode(struct super_block *sb)
{
struct ext4_inode_info *ei;
ei = kmalloc_obj(struct ext4_inode_info);
if (!ei)
return NULL;
INIT_LIST_HEAD(&ei->i_orphan);
init_rwsem(&ei->xattr_sem);
init_rwsem(&ei->i_data_sem);
inode_init_once(&ei->vfs_inode);
ext4_fc_init_inode(&ei->vfs_inode);
return &ei->vfs_inode;
}
static void mbt_free_inode(struct inode *inode)
{
kfree(EXT4_I(inode));
}
static const struct super_operations mbt_sops = {
.alloc_inode = mbt_alloc_inode,
.free_inode = mbt_free_inode,
};
static void mbt_kill_sb(struct super_block *sb)
{
generic_shutdown_super(sb);
}
static int mbt_init_fs_context(struct fs_context *fc)
{
return 0;
}
static struct file_system_type mbt_fs_type = {
.name = "mballoc test",
.init_fs_context = mbt_init_fs_context,
.kill_sb = mbt_kill_sb,
};
static int mbt_mb_init(struct super_block *sb)
{
ext4_fsblk_t block;
int ret;
/* needed by ext4_mb_init->bdev_rot(sb->s_bdev) */
sb->s_bdev = kzalloc_obj(*sb->s_bdev);
if (sb->s_bdev == NULL)
return -ENOMEM;
sb->s_bdev->bd_queue = kzalloc_obj(struct request_queue);
if (sb->s_bdev->bd_queue == NULL) {
kfree(sb->s_bdev);
return -ENOMEM;
}
/*
* needed by ext4_mb_init->ext4_mb_init_backend-> sbi->s_buddy_cache =
* new_inode(sb);
*/
INIT_LIST_HEAD(&sb->s_inodes);
sb->s_op = &mbt_sops;
ret = ext4_mb_init(sb);
if (ret != 0)
goto err_out;
Annotation
- Immediate include surface: `kunit/test.h`, `kunit/static_stub.h`, `linux/fs_context.h`, `linux/random.h`, `ext4.h`, `mballoc.h`.
- Detected declarations: `struct mbt_grp_ctx`, `struct mbt_ctx`, `struct mbt_ext4_super_block`, `struct mbt_ext4_block_layout`, `struct test_range`, `function mbt_free_inode`, `function mbt_kill_sb`, `function mbt_init_fs_context`, `function mbt_mb_init`, `function mbt_mb_release`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.