fs/gfs2/log.c
Source file repositories/reference/linux-study-clean/fs/gfs2/log.c
File Facts
- System
- Linux kernel
- Corpus path
fs/gfs2/log.c- Extension
.c- Size
- 38650 bytes
- Lines
- 1386
- 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.
- 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/gfs2_ondisk.hlinux/crc32.hlinux/crc32c.hlinux/delay.hlinux/kthread.hlinux/freezer.hlinux/bio.hlinux/blkdev.hlinux/writeback.hlinux/list_sort.hgfs2.hincore.hbmap.hglock.hlog.hlops.hmeta_io.hutil.hdir.htrace_gfs2.htrans.haops.h
Detected Declarations
function gfs2_struct2blkfunction gfs2_remove_from_ailfunction gfs2_ail1_start_onefunction list_for_each_entry_safe_reversefunction dump_ail_listfunction list_for_each_entry_reversefunction gfs2_ail1_flushfunction gfs2_ail1_startfunction gfs2_log_update_flush_tailfunction gfs2_log_update_headfunction gfs2_ail_empty_trfunction gfs2_ail1_empty_onefunction list_for_each_entry_safe_reversefunction gfs2_ail1_emptyfunction gfs2_ail1_waitfunction list_for_each_entryfunction __ail2_emptyfunction ail2_emptyfunction list_for_each_entry_safefunction list_for_each_entry_safefunction gfs2_log_is_emptyfunction __gfs2_log_try_reserve_revokesfunction gfs2_log_release_revokesfunction gfs2_log_releasefunction __gfs2_log_reservefunction __gfs2_log_reservefunction gfs2_log_try_reservefunction gfs2_log_reservefunction distancefunction blocksfunction log_pull_tailfunction log_flush_waitfunction ip_cmpfunction __ordered_del_inodefunction gfs2_ordered_writefunction gfs2_ordered_waitfunction gfs2_ordered_del_inodefunction gfs2_add_revokefunction gfs2_glock_remove_revokefunction gfs2_flush_revokesfunction gfs2_write_log_headerfunction log_write_headerfunction gfs2_ail_drainfunction empty_ail1_listfunction gfs2_trans_drain_listfunction gfs2_trans_drainfunction gfs2_remove_from_journalfunction __gfs2_log_flush
Annotated Snippet
if (!buffer_busy(bh)) {
if (buffer_uptodate(bh)) {
list_move(&bd->bd_ail_st_list,
&tr->tr_ail2_list);
continue;
}
if (!cmpxchg(&sdp->sd_log_error, 0, -EIO))
gfs2_io_error_bh(sdp, bh);
}
if (gfs2_withdrawn(sdp)) {
gfs2_remove_from_ail(bd);
continue;
}
if (!buffer_dirty(bh))
continue;
if (gl == bd->bd_gl)
continue;
gl = bd->bd_gl;
list_move(&bd->bd_ail_st_list, &tr->tr_ail1_list);
mapping = bh->b_folio->mapping;
if (!mapping)
continue;
spin_unlock(&sdp->sd_ail_lock);
BUG_ON(GFS2_SB(mapping->host) != sdp);
if (gfs2_is_jdata(GFS2_I(mapping->host)))
ret = gfs2_jdata_writeback(mapping, wbc);
else
ret = mapping->a_ops->writepages(mapping, wbc);
if (need_resched()) {
blk_finish_plug(plug);
cond_resched();
blk_start_plug(plug);
}
spin_lock(&sdp->sd_ail_lock);
if (ret == -ENODATA) /* if a jdata write into a new hole */
ret = 0; /* ignore it */
mapping_set_error(mapping, ret);
if (ret || wbc->nr_to_write <= 0)
break;
return -EBUSY;
}
return ret;
}
static void dump_ail_list(struct gfs2_sbd *sdp)
{
struct gfs2_trans *tr;
struct gfs2_bufdata *bd;
struct buffer_head *bh;
list_for_each_entry_reverse(tr, &sdp->sd_ail1_list, tr_list) {
list_for_each_entry_reverse(bd, &tr->tr_ail1_list,
bd_ail_st_list) {
bh = bd->bd_bh;
fs_err(sdp, "bd %p: blk:0x%llx bh=%p ", bd,
(unsigned long long)bd->bd_blkno, bh);
if (!bh) {
fs_err(sdp, "\n");
continue;
}
fs_err(sdp, "0x%llx up2:%d dirt:%d lkd:%d req:%d "
"map:%d new:%d ar:%d aw:%d delay:%d "
"io err:%d unwritten:%d dfr:%d pin:%d esc:%d\n",
(unsigned long long)bh->b_blocknr,
buffer_uptodate(bh), buffer_dirty(bh),
buffer_locked(bh), buffer_req(bh),
buffer_mapped(bh), buffer_new(bh),
buffer_async_read(bh), buffer_async_write(bh),
buffer_delay(bh), buffer_write_io_error(bh),
buffer_unwritten(bh),
buffer_defer_completion(bh),
buffer_pinned(bh), buffer_escaped(bh));
}
}
}
/**
* gfs2_ail1_flush - start writeback of some ail1 entries
* @sdp: The super block
* @wbc: The writeback control structure
*
* Writes back some ail1 entries, according to the limits in the
* writeback control structure
*/
void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc)
{
struct list_head *head = &sdp->sd_ail1_list;
Annotation
- Immediate include surface: `linux/sched.h`, `linux/slab.h`, `linux/spinlock.h`, `linux/completion.h`, `linux/buffer_head.h`, `linux/gfs2_ondisk.h`, `linux/crc32.h`, `linux/crc32c.h`.
- Detected declarations: `function gfs2_struct2blk`, `function gfs2_remove_from_ail`, `function gfs2_ail1_start_one`, `function list_for_each_entry_safe_reverse`, `function dump_ail_list`, `function list_for_each_entry_reverse`, `function gfs2_ail1_flush`, `function gfs2_ail1_start`, `function gfs2_log_update_flush_tail`, `function gfs2_log_update_head`.
- 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.