fs/xfs/libxfs/xfs_attr_remote.c
Source file repositories/reference/linux-study-clean/fs/xfs/libxfs/xfs_attr_remote.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/libxfs/xfs_attr_remote.c- Extension
.c- Size
- 18303 bytes
- Lines
- 739
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
xfs_platform.hxfs_fs.hxfs_shared.hxfs_format.hxfs_log_format.hxfs_trans_resv.hxfs_bit.hxfs_mount.hxfs_defer.hxfs_da_format.hxfs_da_btree.hxfs_inode.hxfs_trans.hxfs_bmap.hxfs_attr.hxfs_attr_remote.hxfs_trace.hxfs_error.hxfs_health.h
Detected Declarations
function lengthfunction xfs_attr3_rmt_blocksfunction xfs_attr3_rmt_hdr_okfunction xfs_attr3_rmt_verifyfunction __xfs_attr3_rmt_read_verifyfunction xfs_attr3_rmt_read_verifyfunction xfs_attr3_rmt_verify_structfunction xfs_attr3_rmt_write_verifyfunction xfs_attr3_rmt_hdr_setfunction xfs_attr3_rmt_hdr_setfunction xfs_attr_rmtval_copyoutfunction xfs_attr_rmtval_copyinfunction xfs_attr_rmtval_getfunction xfs_attr_rmt_find_holefunction xfs_attr_rmtval_set_valuefunction xfs_attr_rmtval_stalefunction xfs_attr_rmtval_find_spacefunction xfs_attr_rmtval_set_blkfunction xfs_attr_rmtval_invalidatefunction xfs_attr_rmtval_remove
Annotated Snippet
if (fa) {
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
return;
}
/*
* Ensure we aren't writing bogus LSNs to disk. See
* xfs_attr3_rmt_hdr_set() for the explanation.
*/
if (rmt->rm_lsn != cpu_to_be64(NULLCOMMITLSN)) {
xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
return;
}
xfs_update_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF);
len -= blksize;
ptr += blksize;
bno += BTOBB(blksize);
}
if (len != 0)
xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
}
const struct xfs_buf_ops xfs_attr3_rmt_buf_ops = {
.name = "xfs_attr3_rmt",
.magic = { 0, cpu_to_be32(XFS_ATTR3_RMT_MAGIC) },
.verify_read = xfs_attr3_rmt_read_verify,
.verify_write = xfs_attr3_rmt_write_verify,
.verify_struct = xfs_attr3_rmt_verify_struct,
};
STATIC int
xfs_attr3_rmt_hdr_set(
struct xfs_mount *mp,
void *ptr,
xfs_ino_t ino,
uint32_t offset,
uint32_t size,
xfs_daddr_t bno)
{
struct xfs_attr3_rmt_hdr *rmt = ptr;
if (!xfs_has_crc(mp))
return 0;
rmt->rm_magic = cpu_to_be32(XFS_ATTR3_RMT_MAGIC);
rmt->rm_offset = cpu_to_be32(offset);
rmt->rm_bytes = cpu_to_be32(size);
uuid_copy(&rmt->rm_uuid, &mp->m_sb.sb_meta_uuid);
rmt->rm_owner = cpu_to_be64(ino);
rmt->rm_blkno = cpu_to_be64(bno);
/*
* Remote attribute blocks are written synchronously, so we don't
* have an LSN that we can stamp in them that makes any sense to log
* recovery. To ensure that log recovery handles overwrites of these
* blocks sanely (i.e. once they've been freed and reallocated as some
* other type of metadata) we need to ensure that the LSN has a value
* that tells log recovery to ignore the LSN and overwrite the buffer
* with whatever is in it's log. To do this, we use the magic
* NULLCOMMITLSN to indicate that the LSN is invalid.
*/
rmt->rm_lsn = cpu_to_be64(NULLCOMMITLSN);
return sizeof(struct xfs_attr3_rmt_hdr);
}
/*
* Helper functions to copy attribute data in and out of the one disk extents
*/
STATIC int
xfs_attr_rmtval_copyout(
struct xfs_mount *mp,
struct xfs_buf *bp,
struct xfs_inode *dp,
xfs_ino_t owner,
unsigned int *offset,
unsigned int *valuelen,
uint8_t **dst)
{
char *src = bp->b_addr;
xfs_daddr_t bno = xfs_buf_daddr(bp);
unsigned int len = BBTOB(bp->b_length);
unsigned int blksize = mp->m_attr_geo->blksize;
ASSERT(len >= blksize);
while (len > 0 && *valuelen > 0) {
unsigned int hdr_size = 0;
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_log_format.h`, `xfs_trans_resv.h`, `xfs_bit.h`, `xfs_mount.h`.
- Detected declarations: `function length`, `function xfs_attr3_rmt_blocks`, `function xfs_attr3_rmt_hdr_ok`, `function xfs_attr3_rmt_verify`, `function __xfs_attr3_rmt_read_verify`, `function xfs_attr3_rmt_read_verify`, `function xfs_attr3_rmt_verify_struct`, `function xfs_attr3_rmt_write_verify`, `function xfs_attr3_rmt_hdr_set`, `function xfs_attr3_rmt_hdr_set`.
- 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.