fs/nilfs2/bmap.c
Source file repositories/reference/linux-study-clean/fs/nilfs2/bmap.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nilfs2/bmap.c- Extension
.c- Size
- 15088 bytes
- Lines
- 569
- 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.
- 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/fs.hlinux/string.hlinux/errno.hnilfs.hbmap.hbtree.hdirect.hbtnode.hmdt.hdat.halloc.h
Detected Declarations
function Copyrightfunction nilfs_bmap_convert_errorfunction nilfs_bmap_lookup_at_levelfunction nilfs_bmap_lookup_contigfunction nilfs_bmap_do_insertfunction nilfs_bmap_insertfunction nilfs_bmap_do_deletefunction nilfs_bmap_seek_keyfunction nilfs_bmap_last_keyfunction nilfs_bmap_deletefunction nilfs_bmap_do_truncatefunction nilfs_bmap_truncatefunction nilfs_bmap_clearfunction nilfs_bmap_propagatefunction nilfs_bmap_lookup_dirty_buffersfunction assignedfunction nilfs_bmap_markfunction nilfs_bmap_test_and_clear_dirtyfunction nilfs_bmap_data_get_keyfunction nilfs_bmap_find_target_seqfunction nilfs_bmap_find_target_in_groupfunction nilfs_bmap_readfunction nilfs_bmap_writefunction nilfs_bmap_init_gcfunction nilfs_bmap_savefunction nilfs_bmap_restore
Annotated Snippet
else if (ret == -ENOENT) {
/*
* If there was no valid entry in DAT for the block
* address obtained by b_ops->bop_lookup, then pass
* internal code -EINVAL to nilfs_bmap_convert_error
* to treat it as metadata corruption.
*/
ret = -EINVAL;
}
}
out:
up_read(&bmap->b_sem);
return nilfs_bmap_convert_error(bmap, __func__, ret);
}
int nilfs_bmap_lookup_contig(struct nilfs_bmap *bmap, __u64 key, __u64 *ptrp,
unsigned int maxblocks)
{
int ret;
down_read(&bmap->b_sem);
ret = bmap->b_ops->bop_lookup_contig(bmap, key, ptrp, maxblocks);
up_read(&bmap->b_sem);
return nilfs_bmap_convert_error(bmap, __func__, ret);
}
static int nilfs_bmap_do_insert(struct nilfs_bmap *bmap, __u64 key, __u64 ptr)
{
__u64 keys[NILFS_BMAP_SMALL_HIGH + 1];
__u64 ptrs[NILFS_BMAP_SMALL_HIGH + 1];
int ret, n;
if (bmap->b_ops->bop_check_insert != NULL) {
ret = bmap->b_ops->bop_check_insert(bmap, key);
if (ret > 0) {
n = bmap->b_ops->bop_gather_data(
bmap, keys, ptrs, NILFS_BMAP_SMALL_HIGH + 1);
if (n < 0)
return n;
ret = nilfs_btree_convert_and_insert(
bmap, key, ptr, keys, ptrs, n);
if (ret == 0)
bmap->b_u.u_flags |= NILFS_BMAP_LARGE;
return ret;
} else if (ret < 0)
return ret;
}
return bmap->b_ops->bop_insert(bmap, key, ptr);
}
/**
* nilfs_bmap_insert - insert a new key-record pair into a bmap
* @bmap: bmap
* @key: key
* @rec: record
*
* Description: nilfs_bmap_insert() inserts the new key-record pair specified
* by @key and @rec into @bmap.
*
* Return: 0 on success, or one of the following negative error codes on
* failure:
* * %-EEXIST - A record associated with @key already exists.
* * %-EIO - I/O error (including metadata corruption).
* * %-ENOMEM - Insufficient memory available.
*/
int nilfs_bmap_insert(struct nilfs_bmap *bmap, __u64 key, unsigned long rec)
{
int ret;
down_write(&bmap->b_sem);
ret = nilfs_bmap_do_insert(bmap, key, rec);
up_write(&bmap->b_sem);
return nilfs_bmap_convert_error(bmap, __func__, ret);
}
static int nilfs_bmap_do_delete(struct nilfs_bmap *bmap, __u64 key)
{
__u64 keys[NILFS_BMAP_LARGE_LOW + 1];
__u64 ptrs[NILFS_BMAP_LARGE_LOW + 1];
int ret, n;
if (bmap->b_ops->bop_check_delete != NULL) {
ret = bmap->b_ops->bop_check_delete(bmap, key);
if (ret > 0) {
n = bmap->b_ops->bop_gather_data(
Annotation
- Immediate include surface: `linux/fs.h`, `linux/string.h`, `linux/errno.h`, `nilfs.h`, `bmap.h`, `btree.h`, `direct.h`, `btnode.h`.
- Detected declarations: `function Copyright`, `function nilfs_bmap_convert_error`, `function nilfs_bmap_lookup_at_level`, `function nilfs_bmap_lookup_contig`, `function nilfs_bmap_do_insert`, `function nilfs_bmap_insert`, `function nilfs_bmap_do_delete`, `function nilfs_bmap_seek_key`, `function nilfs_bmap_last_key`, `function nilfs_bmap_delete`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
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.