fs/netfs/fscache_cookie.c
Source file repositories/reference/linux-study-clean/fs/netfs/fscache_cookie.c
File Facts
- System
- Linux kernel
- Corpus path
fs/netfs/fscache_cookie.c- Extension
.c- Size
- 35139 bytes
- Lines
- 1185
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/module.hlinux/slab.hinternal.h
Detected Declarations
function fscache_print_cookiefunction fscache_free_cookiefunction __fscache_queue_cookiefunction fscache_queue_cookiefunction fscache_init_access_gatefunction fscache_end_cookie_accessfunction __fscache_begin_cookie_accessfunction fscache_begin_cookie_accessfunction wake_up_cookie_statefunction fscache_cookie_statefunction fscache_set_cookie_statefunction fscache_cookie_lookup_negativefunction fscache_resume_after_invalidationfunction fscache_caching_failedfunction fscache_set_keyfunction fscache_cookie_samefunction fscache_cookie_is_droppedfunction fscache_wait_on_collisionfunction fscache_hash_cookiefunction fscache_prepare_to_writefunction fscache_perform_lookupfunction fscache_begin_lookupfunction __fscache_use_cookiefunction fscache_unuse_cookie_lockedfunction __fscache_unuse_cookiefunction fscache_cookie_state_machinefunction fscache_use_cookiefunction fscache_cookie_workerfunction __fscache_withdraw_cookiefunction fscache_cookie_lru_do_onefunction time_beforefunction fscache_cookie_lru_workerfunction fscache_cookie_lru_timed_outfunction fscache_cookie_drop_from_lrufunction fscache_unhash_cookiefunction fscache_drop_withdraw_cookiefunction fscache_withdraw_cookiefunction __fscache_relinquish_cookiefunction fscache_put_cookiefunction fscache_perform_invalidationfunction __fscache_invalidatefunction fscache_cookies_seq_showfunction fscache_cookies_seq_stopexport fscache_end_cookie_accessexport fscache_cookie_lookup_negativeexport fscache_resume_after_invalidationexport fscache_caching_failedexport __fscache_acquire_cookie
Annotated Snippet
if (fscache_cookie_same(candidate, cursor)) {
if (!test_bit(FSCACHE_COOKIE_RELINQUISHED, &cursor->flags))
goto collision;
wait_for = fscache_get_cookie(cursor,
fscache_cookie_get_hash_collision);
break;
}
}
fscache_get_volume(candidate->volume, fscache_volume_get_cookie);
atomic_inc(&candidate->volume->n_cookies);
hlist_bl_add_head(&candidate->hash_link, h);
set_bit(FSCACHE_COOKIE_IS_HASHED, &candidate->flags);
hlist_bl_unlock(h);
if (wait_for) {
fscache_wait_on_collision(candidate, wait_for);
fscache_put_cookie(wait_for, fscache_cookie_put_hash_collision);
}
return true;
collision:
trace_fscache_cookie(cursor->debug_id, refcount_read(&cursor->ref),
fscache_cookie_collision);
pr_err("Duplicate cookie detected\n");
fscache_print_cookie(cursor, 'O');
fscache_print_cookie(candidate, 'N');
hlist_bl_unlock(h);
return false;
}
/*
* Request a cookie to represent a data storage object within a volume.
*
* We never let on to the netfs about errors. We may set a negative cookie
* pointer, but that's okay
*/
struct fscache_cookie *__fscache_acquire_cookie(
struct fscache_volume *volume,
u8 advice,
const void *index_key, size_t index_key_len,
const void *aux_data, size_t aux_data_len,
loff_t object_size)
{
struct fscache_cookie *cookie;
_enter("V=%x", volume->debug_id);
if (!index_key || !index_key_len || index_key_len > 255 || aux_data_len > 255)
return NULL;
if (!aux_data || !aux_data_len) {
aux_data = NULL;
aux_data_len = 0;
}
fscache_stat(&fscache_n_acquires);
cookie = fscache_alloc_cookie(volume, advice,
index_key, index_key_len,
aux_data, aux_data_len,
object_size);
if (!cookie) {
fscache_stat(&fscache_n_acquires_oom);
return NULL;
}
if (!fscache_hash_cookie(cookie)) {
fscache_see_cookie(cookie, fscache_cookie_discard);
fscache_free_cookie(cookie);
return NULL;
}
trace_fscache_acquire(cookie);
fscache_stat(&fscache_n_acquires_ok);
_leave(" = c=%08x", cookie->debug_id);
return cookie;
}
EXPORT_SYMBOL(__fscache_acquire_cookie);
/*
* Prepare a cache object to be written to.
*/
static void fscache_prepare_to_write(struct fscache_cookie *cookie)
{
cookie->volume->cache->ops->prepare_to_write(cookie);
}
/*
* Look up a cookie in the cache.
*/
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `internal.h`.
- Detected declarations: `function fscache_print_cookie`, `function fscache_free_cookie`, `function __fscache_queue_cookie`, `function fscache_queue_cookie`, `function fscache_init_access_gate`, `function fscache_end_cookie_access`, `function __fscache_begin_cookie_access`, `function fscache_begin_cookie_access`, `function wake_up_cookie_state`, `function fscache_cookie_state`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration 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.