fs/ufs/util.c
Source file repositories/reference/linux-study-clean/fs/ufs/util.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ufs/util.c- Extension
.c- Size
- 4954 bytes
- Lines
- 224
- 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/string.hlinux/slab.hlinux/buffer_head.hufs_fs.hufs.hswab.hutil.h
Detected Declarations
function Copyrightfunction ubh_bread_uspifunction ubh_brelsefunction ubh_brelse_uspifunction ubh_mark_buffer_dirtyfunction ubh_sync_blockfunction ubh_bforgetfunction ubh_buffer_dirtyfunction ufs_get_inode_devfunction ufs_set_inode_devfunction ufs_get_locked_folio
Annotated Snippet
if ((fs32 & 0xffff8000) == 0) {
fs32 = old_encode_dev(dev);
}
break;
default:
fs32 = old_encode_dev(dev);
break;
}
if ((UFS_SB(sb)->s_flags & UFS_ST_MASK) == UFS_ST_SUNx86)
ufsi->i_u1.i_data[1] = cpu_to_fs32(sb, fs32);
else
ufsi->i_u1.i_data[0] = cpu_to_fs32(sb, fs32);
}
/**
* ufs_get_locked_folio() - locate, pin and lock a pagecache folio, if not exist
* read it from disk.
* @mapping: the address_space to search
* @index: the page index
*
* Locates the desired pagecache folio, if not exist we'll read it,
* locks it, increments its reference
* count and returns its address.
*
*/
struct folio *ufs_get_locked_folio(struct address_space *mapping,
pgoff_t index)
{
struct inode *inode = mapping->host;
struct folio *folio = filemap_lock_folio(mapping, index);
if (IS_ERR(folio)) {
folio = read_mapping_folio(mapping, index, NULL);
if (IS_ERR(folio)) {
printk(KERN_ERR "ufs_change_blocknr: read_mapping_folio error: ino %llu, index: %lu\n",
mapping->host->i_ino, index);
return folio;
}
folio_lock(folio);
if (unlikely(folio->mapping == NULL)) {
/* Truncate got there first */
folio_unlock(folio);
folio_put(folio);
return NULL;
}
}
if (!folio_buffers(folio))
create_empty_buffers(folio, 1 << inode->i_blkbits, 0);
return folio;
}
Annotation
- Immediate include surface: `linux/string.h`, `linux/slab.h`, `linux/buffer_head.h`, `ufs_fs.h`, `ufs.h`, `swab.h`, `util.h`.
- Detected declarations: `function Copyright`, `function ubh_bread_uspi`, `function ubh_brelse`, `function ubh_brelse_uspi`, `function ubh_mark_buffer_dirty`, `function ubh_sync_block`, `function ubh_bforget`, `function ubh_buffer_dirty`, `function ufs_get_inode_dev`, `function ufs_set_inode_dev`.
- 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.