fs/gfs2/glops.c
Source file repositories/reference/linux-study-clean/fs/gfs2/glops.c
File Facts
- System
- Linux kernel
- Corpus path
fs/gfs2/glops.c- Extension
.c- Size
- 18415 bytes
- Lines
- 711
- 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/spinlock.hlinux/completion.hlinux/buffer_head.hlinux/gfs2_ondisk.hlinux/bio.hlinux/posix_acl.hlinux/security.hlinux/log2.hgfs2.hincore.hbmap.hglock.hglops.hinode.hlog.hmeta_io.hrecovery.hrgrp.hutil.htrans.hdir.hlops.h
Detected Declarations
function gfs2_ail_errorfunction __gfs2_ail_flushfunction gfs2_ail_empty_glfunction gfs2_ail_flushfunction gfs2_rgrp_metasyncfunction rgrp_go_syncfunction rgrp_go_invalfunction gfs2_rgrp_go_dumpfunction gfs2_clear_glop_pendingfunction gfs2_inode_metasyncfunction inode_go_syncfunction inode_go_invalfunction gfs2_dinode_infunction gfs2_inode_refreshfunction inode_go_instantiatefunction inode_go_heldfunction inode_go_dumpfunction freeze_go_callbackfunction unmountfunction freeze_go_xmote_bhfunction iopen_go_callback
Annotated Snippet
if (bh->b_state & b_state) {
if (fsync)
continue;
gfs2_ail_error(gl, bh);
}
gfs2_trans_add_revoke(sdp, bd);
nr_revokes--;
}
GLOCK_BUG_ON(gl, !fsync && atomic_read(&gl->gl_ail_count));
spin_unlock(&sdp->sd_ail_lock);
spin_unlock(&sdp->sd_log_lock);
}
static int gfs2_ail_empty_gl(struct gfs2_glock *gl)
{
struct gfs2_sbd *sdp = glock_sbd(gl);
struct gfs2_trans tr;
unsigned int revokes;
int ret = 0;
revokes = atomic_read(&gl->gl_ail_count);
if (!revokes) {
bool have_revokes;
bool log_in_flight;
/*
* We have nothing on the ail, but there could be revokes on
* the sdp revoke queue, in which case, we still want to flush
* the log and wait for it to finish.
*
* If the sdp revoke list is empty too, we might still have an
* io outstanding for writing revokes, so we should wait for
* it before returning.
*
* If none of these conditions are true, our revokes are all
* flushed and we can return.
*/
spin_lock(&sdp->sd_log_lock);
have_revokes = !list_empty(&sdp->sd_log_revokes);
log_in_flight = atomic_read(&sdp->sd_log_in_flight);
spin_unlock(&sdp->sd_log_lock);
if (have_revokes)
goto flush;
if (log_in_flight)
log_flush_wait(sdp);
return 0;
}
memset(&tr, 0, sizeof(tr));
set_bit(TR_ONSTACK, &tr.tr_flags);
ret = __gfs2_trans_begin(&tr, sdp, 0, revokes, _RET_IP_);
if (ret) {
fs_err(sdp, "Transaction error %d: Unable to write revokes.", ret);
goto flush;
}
__gfs2_ail_flush(gl, 0, revokes);
gfs2_trans_end(sdp);
flush:
if (!ret)
gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_NORMAL |
GFS2_LFC_AIL_EMPTY_GL);
return ret;
}
void gfs2_ail_flush(struct gfs2_glock *gl, bool fsync)
{
struct gfs2_sbd *sdp = glock_sbd(gl);
unsigned int revokes = atomic_read(&gl->gl_ail_count);
int ret;
if (!revokes)
return;
ret = gfs2_trans_begin(sdp, 0, revokes);
if (ret)
return;
__gfs2_ail_flush(gl, fsync, revokes);
gfs2_trans_end(sdp);
gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_NORMAL |
GFS2_LFC_AIL_FLUSH);
}
/**
* gfs2_rgrp_metasync - sync out the metadata of a resource group
* @gl: the glock protecting the resource group
*
*/
Annotation
- Immediate include surface: `linux/spinlock.h`, `linux/completion.h`, `linux/buffer_head.h`, `linux/gfs2_ondisk.h`, `linux/bio.h`, `linux/posix_acl.h`, `linux/security.h`, `linux/log2.h`.
- Detected declarations: `function gfs2_ail_error`, `function __gfs2_ail_flush`, `function gfs2_ail_empty_gl`, `function gfs2_ail_flush`, `function gfs2_rgrp_metasync`, `function rgrp_go_sync`, `function rgrp_go_inval`, `function gfs2_rgrp_go_dump`, `function gfs2_clear_glop_pending`, `function gfs2_inode_metasync`.
- 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.