fs/netfs/fscache_volume.c
Source file repositories/reference/linux-study-clean/fs/netfs/fscache_volume.c
File Facts
- System
- Linux kernel
- Corpus path
fs/netfs/fscache_volume.c- Extension
.c- Size
- 15257 bytes
- Lines
- 533
- 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/export.hlinux/slab.hinternal.h
Detected Declarations
function fscache_see_volumefunction __fscache_begin_volume_accessfunction fscache_begin_volume_accessfunction fscache_end_volume_accessfunction fscache_volume_samefunction fscache_is_acquire_pendingfunction fscache_wait_on_volume_collisionfunction fscache_hash_volumefunction fscache_create_volume_workfunction fscache_create_volumefunction afunction fscache_wake_pending_volumefunction hlist_bl_for_each_entryfunction fscache_unhash_volumefunction fscache_free_volumefunction fscache_put_volumefunction __fscache_relinquish_volumefunction fscache_withdraw_volumefunction fscache_volumes_seq_showfunction fscache_volumes_seq_stopexport fscache_try_get_volumeexport fscache_end_volume_accessexport __fscache_acquire_volumeexport fscache_put_volumeexport __fscache_relinquish_volumeexport fscache_withdraw_volume
Annotated Snippet
if (fscache_volume_same(candidate, cursor)) {
if (!test_bit(FSCACHE_VOLUME_RELINQUISHED, &cursor->flags))
goto collision;
fscache_see_volume(cursor, fscache_volume_get_hash_collision);
set_bit(FSCACHE_VOLUME_COLLIDED_WITH, &cursor->flags);
set_bit(FSCACHE_VOLUME_ACQUIRE_PENDING, &candidate->flags);
collidee_debug_id = cursor->debug_id;
break;
}
}
hlist_bl_add_head(&candidate->hash_link, h);
hlist_bl_unlock(h);
if (fscache_is_acquire_pending(candidate))
fscache_wait_on_volume_collision(candidate, collidee_debug_id);
return true;
collision:
fscache_see_volume(cursor, fscache_volume_collision);
hlist_bl_unlock(h);
return false;
}
/*
* Allocate and initialise a volume representation cookie.
*/
static struct fscache_volume *fscache_alloc_volume(const char *volume_key,
const char *cache_name,
const void *coherency_data,
size_t coherency_len)
{
struct fscache_volume *volume;
struct fscache_cache *cache;
size_t klen, hlen;
u8 *key;
klen = strlen(volume_key);
if (klen > NAME_MAX)
return NULL;
if (!coherency_data)
coherency_len = 0;
cache = fscache_lookup_cache(cache_name, false);
if (IS_ERR(cache))
return NULL;
volume = kzalloc_flex(*volume, coherency, coherency_len);
if (!volume)
goto err_cache;
volume->cache = cache;
volume->coherency_len = coherency_len;
if (coherency_data)
memcpy(volume->coherency, coherency_data, coherency_len);
INIT_LIST_HEAD(&volume->proc_link);
INIT_WORK(&volume->work, fscache_create_volume_work);
refcount_set(&volume->ref, 1);
spin_lock_init(&volume->lock);
/* Stick the length on the front of the key and pad it out to make
* hashing easier.
*/
hlen = round_up(1 + klen + 1, sizeof(__le32));
key = kzalloc(hlen, GFP_KERNEL);
if (!key)
goto err_vol;
key[0] = klen;
memcpy(key + 1, volume_key, klen);
volume->key = key;
volume->key_hash = fscache_hash(0, key, hlen);
volume->debug_id = atomic_inc_return(&fscache_volume_debug_id);
down_write(&fscache_addremove_sem);
atomic_inc(&cache->n_volumes);
list_add_tail(&volume->proc_link, &fscache_volumes);
fscache_see_volume(volume, fscache_volume_new_acquire);
fscache_stat(&fscache_n_volumes);
up_write(&fscache_addremove_sem);
_leave(" = v=%x", volume->debug_id);
return volume;
err_vol:
kfree(volume);
err_cache:
fscache_put_cache(cache, fscache_cache_put_alloc_volume);
fscache_stat(&fscache_n_volumes_nomem);
return NULL;
Annotation
- Immediate include surface: `linux/export.h`, `linux/slab.h`, `internal.h`.
- Detected declarations: `function fscache_see_volume`, `function __fscache_begin_volume_access`, `function fscache_begin_volume_access`, `function fscache_end_volume_access`, `function fscache_volume_same`, `function fscache_is_acquire_pending`, `function fscache_wait_on_volume_collision`, `function fscache_hash_volume`, `function fscache_create_volume_work`, `function fscache_create_volume`.
- 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.