fs/ubifs/replay.c
Source file repositories/reference/linux-study-clean/fs/ubifs/replay.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ubifs/replay.c- Extension
.c- Size
- 34235 bytes
- Lines
- 1253
- 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
ubifs.hlinux/list_sort.hcrypto/hash.h
Detected Declarations
struct replay_entrystruct bud_entryfunction set_bud_lpropsfunction set_buds_lpropsfunction list_for_each_entryfunction trun_remove_rangefunction inode_still_linkedfunction apply_replay_entryfunction replay_entries_cmpfunction apply_replay_listfunction list_for_each_entryfunction destroy_replay_listfunction list_for_each_entry_safefunction insert_nodefunction insert_dentfunction ubifs_validate_entryfunction is_last_budfunction authenticate_sleb_hashfunction authenticate_slebfunction list_for_each_entryfunction replay_budfunction spacefunction replay_budsfunction list_for_each_entryfunction destroy_bud_listfunction add_replay_budfunction validate_reffunction replay_log_lebfunction list_for_each_entryfunction take_iheadfunction built
Annotated Snippet
struct replay_entry {
int lnum;
int offs;
int len;
u8 hash[UBIFS_HASH_ARR_SZ];
unsigned int deletion:1;
unsigned long long sqnum;
struct list_head list;
union ubifs_key key;
union {
struct fscrypt_name nm;
struct {
loff_t old_size;
loff_t new_size;
};
};
};
/**
* struct bud_entry - entry in the list of buds to replay.
* @list: next bud in the list
* @bud: bud description object
* @sqnum: reference node sequence number
* @free: free bytes in the bud
* @dirty: dirty bytes in the bud
*/
struct bud_entry {
struct list_head list;
struct ubifs_bud *bud;
unsigned long long sqnum;
int free;
int dirty;
};
/**
* set_bud_lprops - set free and dirty space used by a bud.
* @c: UBIFS file-system description object
* @b: bud entry which describes the bud
*
* This function makes sure the LEB properties of bud @b are set correctly
* after the replay. Returns zero in case of success and a negative error code
* in case of failure.
*/
static int set_bud_lprops(struct ubifs_info *c, struct bud_entry *b)
{
const struct ubifs_lprops *lp;
int err = 0, dirty;
ubifs_get_lprops(c);
lp = ubifs_lpt_lookup_dirty(c, b->bud->lnum);
if (IS_ERR(lp)) {
err = PTR_ERR(lp);
goto out;
}
dirty = lp->dirty;
if (b->bud->start == 0 && (lp->free != c->leb_size || lp->dirty != 0)) {
/*
* The LEB was added to the journal with a starting offset of
* zero which means the LEB must have been empty. The LEB
* property values should be @lp->free == @c->leb_size and
* @lp->dirty == 0, but that is not the case. The reason is that
* the LEB had been garbage collected before it became the bud,
* and there was no commit in between. The garbage collector
* resets the free and dirty space without recording it
* anywhere except lprops, so if there was no commit then
* lprops does not have that information.
*
* We do not need to adjust free space because the scan has told
* us the exact value which is recorded in the replay entry as
* @b->free.
*
* However we do need to subtract from the dirty space the
* amount of space that the garbage collector reclaimed, which
* is the whole LEB minus the amount of space that was free.
*/
dbg_mnt("bud LEB %d was GC'd (%d free, %d dirty)", b->bud->lnum,
lp->free, lp->dirty);
dbg_gc("bud LEB %d was GC'd (%d free, %d dirty)", b->bud->lnum,
lp->free, lp->dirty);
dirty -= c->leb_size - lp->free;
/*
* If the replay order was perfect the dirty space would now be
* zero. The order is not perfect because the journal heads
* race with each other. This is not a problem but is does mean
* that the dirty space may temporarily exceed c->leb_size
* during the replay.
*/
if (dirty != 0)
Annotation
- Immediate include surface: `ubifs.h`, `linux/list_sort.h`, `crypto/hash.h`.
- Detected declarations: `struct replay_entry`, `struct bud_entry`, `function set_bud_lprops`, `function set_buds_lprops`, `function list_for_each_entry`, `function trun_remove_range`, `function inode_still_linked`, `function apply_replay_entry`, `function replay_entries_cmp`, `function apply_replay_list`.
- 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.