fs/gfs2/meta_io.c
Source file repositories/reference/linux-study-clean/fs/gfs2/meta_io.c
File Facts
- System
- Linux kernel
- Corpus path
fs/gfs2/meta_io.c- Extension
.c- Size
- 12073 bytes
- Lines
- 517
- 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/sched.hlinux/slab.hlinux/spinlock.hlinux/completion.hlinux/buffer_head.hlinux/mm.hlinux/pagemap.hlinux/writeback.hlinux/swap.hlinux/delay.hlinux/bio.hlinux/gfs2_ondisk.hgfs2.hincore.hglock.hglops.hinode.hlog.hlops.hmeta_io.hrgrp.htrans.hutil.htrace_gfs2.h
Detected Declarations
function Copyrightfunction gfs2_aspace_writepagesfunction meta_prep_newfunction gfs2_meta_read_endiofunction bio_for_each_folio_allfunction gfs2_submit_bhsfunction gfs2_meta_readfunction gfs2_meta_waitfunction gfs2_ail1_wipefunction list_for_each_entry_safefunction gfs2_journal_wipefunction gfs2_meta_buffer
Annotated Snippet
if (wbc->sync_mode != WB_SYNC_NONE) {
lock_buffer(bh);
} else if (!trylock_buffer(bh)) {
folio_redirty_for_writepage(wbc, folio);
continue;
}
if (test_clear_buffer_dirty(bh)) {
set_buffer_async_write(bh);
} else {
unlock_buffer(bh);
}
} while ((bh = bh->b_this_page) != head);
/*
* The folio and its buffers are protected from truncation by
* the writeback flag, so we can drop the bh refcounts early.
*/
BUG_ON(folio_test_writeback(folio));
folio_start_writeback(folio);
do {
struct buffer_head *next = bh->b_this_page;
if (buffer_async_write(bh)) {
bh_submit(bh, REQ_OP_WRITE | write_flags,
bh_end_async_write);
nr_underway++;
}
bh = next;
} while (bh != head);
folio_unlock(folio);
if (nr_underway == 0)
folio_end_writeback(folio);
}
static int gfs2_aspace_writepages(struct address_space *mapping,
struct writeback_control *wbc)
{
struct folio *folio = NULL;
int error;
while ((folio = writeback_iter(mapping, wbc, folio, &error)))
gfs2_aspace_write_folio(folio, wbc);
return error;
}
const struct address_space_operations gfs2_meta_aops = {
.dirty_folio = block_dirty_folio,
.invalidate_folio = block_invalidate_folio,
.writepages = gfs2_aspace_writepages,
.release_folio = gfs2_release_folio,
.migrate_folio = buffer_migrate_folio_norefs,
};
const struct address_space_operations gfs2_rgrp_aops = {
.dirty_folio = block_dirty_folio,
.invalidate_folio = block_invalidate_folio,
.writepages = gfs2_aspace_writepages,
.release_folio = gfs2_release_folio,
.migrate_folio = buffer_migrate_folio_norefs,
};
/**
* gfs2_getbuf - Get a buffer with a given address space
* @gl: the glock
* @blkno: the block number (filesystem scope)
* @create: 1 if the buffer should be created
*
* Returns: the buffer
*/
struct buffer_head *gfs2_getbuf(struct gfs2_glock *gl, u64 blkno, int create)
{
struct address_space *mapping = gfs2_glock2aspace(gl);
struct gfs2_sbd *sdp = glock_sbd(gl);
struct folio *folio;
struct buffer_head *bh;
unsigned int shift;
unsigned long index;
unsigned int bufnum;
if (mapping == NULL)
mapping = gfs2_aspace(sdp);
shift = PAGE_SHIFT - sdp->sd_sb.sb_bsize_shift;
index = blkno >> shift; /* convert block to page */
bufnum = blkno - (index << shift); /* block buf index within page */
if (create) {
Annotation
- Immediate include surface: `linux/sched.h`, `linux/slab.h`, `linux/spinlock.h`, `linux/completion.h`, `linux/buffer_head.h`, `linux/mm.h`, `linux/pagemap.h`, `linux/writeback.h`.
- Detected declarations: `function Copyright`, `function gfs2_aspace_writepages`, `function meta_prep_new`, `function gfs2_meta_read_endio`, `function bio_for_each_folio_all`, `function gfs2_submit_bhs`, `function gfs2_meta_read`, `function gfs2_meta_wait`, `function gfs2_ail1_wipe`, `function list_for_each_entry_safe`.
- 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.