fs/jfs/jfs_metapage.c
Source file repositories/reference/linux-study-clean/fs/jfs/jfs_metapage.c
File Facts
- System
- Linux kernel
- Corpus path
fs/jfs/jfs_metapage.c- Extension
.c- Size
- 22222 bytes
- Lines
- 954
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
linux/blkdev.hlinux/fs.hlinux/mm.hlinux/module.hlinux/bio.hlinux/slab.hlinux/init.hlinux/buffer_head.hlinux/mempool.hlinux/seq_file.hlinux/writeback.hlinux/migrate.hjfs_incore.hjfs_superblock.hjfs_filsys.hjfs_metapage.hjfs_txnmgr.hjfs_debug.h
Detected Declarations
struct meta_anchorfunction unlock_metapagefunction __lock_metapagefunction lock_metapagefunction insert_metapagefunction remove_metapagefunction inc_iofunction dec_iofunction __metapage_migrate_foliofunction insert_metapagefunction remove_metapagefunction __metapage_migrate_foliofunction free_metapagefunction metapage_initfunction metapage_exitfunction drop_metapagefunction metapage_get_blocksfunction last_read_completefunction metapage_read_end_iofunction remove_from_logsyncfunction last_write_completefunction metapage_write_end_iofunction metapage_write_foliofunction metapage_writepagesfunction metapage_read_foliofunction metapage_release_foliofunction metapage_migrate_foliofunction metapage_invalidate_foliofunction grab_metapagefunction metapage_write_onefunction force_metapagefunction hold_metapagefunction put_metapagefunction release_metapagefunction __invalidate_metapagesfunction jfs_mpstat_proc_show
Annotated Snippet
struct meta_anchor {
int mp_count;
atomic_t io_count;
blk_status_t status;
struct metapage *mp[MPS_PER_PAGE];
};
static inline struct metapage *folio_to_mp(struct folio *folio, int offset)
{
struct meta_anchor *anchor = folio->private;
if (!anchor)
return NULL;
return anchor->mp[offset >> L2PSIZE];
}
static inline int insert_metapage(struct folio *folio, struct metapage *mp)
{
struct meta_anchor *a;
int index;
int l2mp_blocks; /* log2 blocks per metapage */
a = folio->private;
if (!a) {
a = kzalloc_obj(struct meta_anchor, GFP_NOFS);
if (!a)
return -ENOMEM;
folio_attach_private(folio, a);
kmap(&folio->page);
}
if (mp) {
l2mp_blocks = L2PSIZE - folio->mapping->host->i_blkbits;
index = (mp->index >> l2mp_blocks) & (MPS_PER_PAGE - 1);
a->mp_count++;
a->mp[index] = mp;
}
return 0;
}
static inline void remove_metapage(struct folio *folio, struct metapage *mp)
{
struct meta_anchor *a = folio->private;
int l2mp_blocks = L2PSIZE - folio->mapping->host->i_blkbits;
int index;
index = (mp->index >> l2mp_blocks) & (MPS_PER_PAGE - 1);
BUG_ON(a->mp[index] != mp);
a->mp[index] = NULL;
if (--a->mp_count == 0) {
kfree(a);
folio_detach_private(folio);
kunmap(&folio->page);
}
}
static inline void inc_io(struct folio *folio)
{
struct meta_anchor *anchor = folio->private;
atomic_inc(&anchor->io_count);
}
static inline void dec_io(struct folio *folio, blk_status_t status,
void (*handler)(struct folio *, blk_status_t))
{
struct meta_anchor *anchor = folio->private;
if (anchor->status == BLK_STS_OK)
anchor->status = status;
if (atomic_dec_and_test(&anchor->io_count))
handler(folio, anchor->status);
}
#ifdef CONFIG_MIGRATION
static int __metapage_migrate_folio(struct address_space *mapping,
struct folio *dst, struct folio *src,
enum migrate_mode mode)
{
struct meta_anchor *src_anchor = src->private;
struct metapage *mps[MPS_PER_PAGE] = {0};
struct metapage *mp;
int i, rc;
for (i = 0; i < MPS_PER_PAGE; i++) {
mp = src_anchor->mp[i];
Annotation
- Immediate include surface: `linux/blkdev.h`, `linux/fs.h`, `linux/mm.h`, `linux/module.h`, `linux/bio.h`, `linux/slab.h`, `linux/init.h`, `linux/buffer_head.h`.
- Detected declarations: `struct meta_anchor`, `function unlock_metapage`, `function __lock_metapage`, `function lock_metapage`, `function insert_metapage`, `function remove_metapage`, `function inc_io`, `function dec_io`, `function __metapage_migrate_folio`, `function insert_metapage`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.