fs/gfs2/aops.c
Source file repositories/reference/linux-study-clean/fs/gfs2/aops.c
File Facts
- System
- Linux kernel
- Corpus path
fs/gfs2/aops.c- Extension
.c- Size
- 19268 bytes
- Lines
- 744
- 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/pagemap.hlinux/folio_batch.hlinux/mpage.hlinux/fs.hlinux/writeback.hlinux/swap.hlinux/gfs2_ondisk.hlinux/backing-dev.hlinux/uio.htrace/events/writeback.hlinux/sched/signal.hgfs2.hincore.hbmap.hglock.hinode.hlog.hmeta_io.hquota.htrans.hrgrp.hsuper.hutil.hglops.haops.h
Detected Declarations
function Copyrightfunction gfs2_write_jdata_foliofunction __gfs2_jdata_write_foliofunction gfs2_jdata_writebackfunction gfs2_writepagesfunction gfs2_write_jdata_batchfunction gfs2_write_cache_jdatafunction gfs2_jdata_writepagesfunction stuffed_read_foliofunction gfs2_read_foliofunction gfs2_internal_readfunction inconvenientfunction adjust_fs_spacefunction gfs2_jdata_dirty_foliofunction gfs2_bmapfunction gfs2_discardfunction gfs2_invalidate_foliofunction try_to_free_buffersfunction gfs2_set_aops
Annotated Snippet
if (!folio_buffers(folio)) {
create_empty_buffers(folio,
inode->i_sb->s_blocksize,
BIT(BH_Dirty)|BIT(BH_Uptodate));
}
gfs2_trans_add_databufs(ip->i_gl, folio, 0, folio_size(folio));
}
return gfs2_write_jdata_folio(folio, wbc);
}
/**
* gfs2_jdata_writeback - Write jdata folios to the log
* @mapping: The mapping to write
* @wbc: The writeback control
*
* Returns: errno
*/
int gfs2_jdata_writeback(struct address_space *mapping, struct writeback_control *wbc)
{
struct inode *inode = mapping->host;
struct gfs2_inode *ip = GFS2_I(inode);
struct gfs2_sbd *sdp = GFS2_SB(mapping->host);
struct folio *folio = NULL;
int error;
BUG_ON(current->journal_info);
if (gfs2_assert_withdraw(sdp, ip->i_gl->gl_state == LM_ST_EXCLUSIVE))
return 0;
while ((folio = writeback_iter(mapping, wbc, folio, &error))) {
if (folio_test_checked(folio)) {
folio_redirty_for_writepage(wbc, folio);
folio_unlock(folio);
continue;
}
error = __gfs2_jdata_write_folio(folio, wbc);
}
return error;
}
/**
* gfs2_writepages - Write a bunch of dirty pages back to disk
* @mapping: The mapping to write
* @wbc: Write-back control
*
* Used for both ordered and writeback modes.
*/
static int gfs2_writepages(struct address_space *mapping,
struct writeback_control *wbc)
{
struct gfs2_sbd *sdp = gfs2_mapping2sbd(mapping);
long initial_nr_to_write = wbc->nr_to_write;
struct iomap_writepage_ctx wpc = {
.inode = mapping->host,
.wbc = wbc,
.ops = &gfs2_writeback_ops,
};
int ret;
/*
* Even if we didn't write any pages here, we might still be holding
* dirty pages in the ail. We forcibly flush the ail because we don't
* want balance_dirty_pages() to loop indefinitely trying to write out
* pages held in the ail that it can't find.
*/
ret = iomap_writepages(&wpc);
if (ret == 0 && wbc->nr_to_write == initial_nr_to_write)
set_bit(SDF_FORCE_AIL_FLUSH, &sdp->sd_flags);
return ret;
}
/**
* gfs2_write_jdata_batch - Write back a folio batch's worth of folios
* @mapping: The mapping
* @wbc: The writeback control
* @fbatch: The batch of folios
* @done_index: Page index
*
* Returns: non-zero if loop should terminate, zero otherwise
*/
static int gfs2_write_jdata_batch(struct address_space *mapping,
struct writeback_control *wbc,
struct folio_batch *fbatch,
pgoff_t *done_index)
{
struct inode *inode = mapping->host;
struct gfs2_sbd *sdp = GFS2_SB(inode);
unsigned nrblocks;
Annotation
- Immediate include surface: `linux/sched.h`, `linux/slab.h`, `linux/spinlock.h`, `linux/completion.h`, `linux/buffer_head.h`, `linux/pagemap.h`, `linux/folio_batch.h`, `linux/mpage.h`.
- Detected declarations: `function Copyright`, `function gfs2_write_jdata_folio`, `function __gfs2_jdata_write_folio`, `function gfs2_jdata_writeback`, `function gfs2_writepages`, `function gfs2_write_jdata_batch`, `function gfs2_write_cache_jdata`, `function gfs2_jdata_writepages`, `function stuffed_read_folio`, `function gfs2_read_folio`.
- 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.