fs/ceph/xattr.c
Source file repositories/reference/linux-study-clean/fs/ceph/xattr.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ceph/xattr.c- Extension
.c- Size
- 39353 bytes
- Lines
- 1486
- 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.
- 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/ceph/ceph_debug.hlinux/ceph/pagelist.hsuper.hmds_client.hlinux/ceph/decode.hlinux/xattr.hlinux/security.hlinux/posix_acl_xattr.hlinux/slab.h
Detected Declarations
struct ceph_vxattrfunction ceph_is_valid_xattrfunction ceph_vxattrcb_layout_existsfunction ceph_vxattrcb_layoutfunction __printffunction ceph_vxattrcb_layout_stripe_unitfunction ceph_vxattrcb_layout_stripe_countfunction ceph_vxattrcb_layout_object_sizefunction ceph_vxattrcb_layout_poolfunction ceph_vxattrcb_layout_pool_namespacefunction ceph_vxattrcb_dir_entriesfunction ceph_vxattrcb_dir_filesfunction ceph_vxattrcb_dir_subdirsfunction ceph_vxattrcb_dir_rentriesfunction ceph_vxattrcb_dir_rfilesfunction ceph_vxattrcb_dir_rsubdirsfunction ceph_vxattrcb_dir_rsnapsfunction ceph_vxattrcb_dir_rbytesfunction ceph_vxattrcb_dir_rctimefunction ceph_vxattrcb_dir_pin_existsfunction ceph_vxattrcb_dir_pinfunction ceph_vxattrcb_quota_existsfunction ceph_vxattrcb_quotafunction ceph_vxattrcb_quota_max_bytesfunction ceph_vxattrcb_quota_max_filesfunction ceph_vxattrcb_snap_btime_existsfunction ceph_vxattrcb_snap_btimefunction ceph_vxattrcb_cluster_fsidfunction ceph_vxattrcb_client_idfunction ceph_vxattrcb_capsfunction ceph_vxattrcb_auth_mdsfunction ceph_vxattrcb_fscrypt_auth_existsfunction ceph_vxattrcb_fscrypt_authfunction __set_xattrfunction __free_xattrfunction __remove_xattrfunction __ceph_destroy_xattrsfunction __build_xattrsfunction __get_required_blob_sizefunction __get_request_maskfunction __ceph_getxattrfunction ceph_listxattrfunction ceph_sync_setxattrfunction __ceph_setxattrfunction ceph_get_xattr_handlerfunction ceph_set_xattr_handlerfunction ceph_security_xattr_wantedfunction ceph_security_xattr_deadlock
Annotated Snippet
struct ceph_vxattr {
char *name;
size_t name_size; /* strlen(name) + 1 (for '\0') */
ssize_t (*getxattr_cb)(struct ceph_inode_info *ci, char *val,
size_t size);
bool (*exists_cb)(struct ceph_inode_info *ci);
unsigned int flags;
};
#define VXATTR_FLAG_READONLY (1<<0)
#define VXATTR_FLAG_HIDDEN (1<<1)
#define VXATTR_FLAG_RSTAT (1<<2)
#define VXATTR_FLAG_DIRSTAT (1<<3)
/* layouts */
static bool ceph_vxattrcb_layout_exists(struct ceph_inode_info *ci)
{
struct ceph_file_layout *fl = &ci->i_layout;
return (fl->stripe_unit > 0 || fl->stripe_count > 0 ||
fl->object_size > 0 || fl->pool_id >= 0 ||
rcu_dereference_raw(fl->pool_ns) != NULL);
}
static ssize_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val,
size_t size)
{
struct ceph_fs_client *fsc = ceph_sb_to_fs_client(ci->netfs.inode.i_sb);
struct ceph_client *cl = fsc->client;
struct ceph_osd_client *osdc = &fsc->client->osdc;
struct ceph_string *pool_ns;
s64 pool = ci->i_layout.pool_id;
const char *pool_name;
const char *ns_field = " pool_namespace=";
char buf[128];
size_t len, total_len = 0;
ssize_t ret;
pool_ns = ceph_try_get_string(ci->i_layout.pool_ns);
doutc(cl, "%p\n", &ci->netfs.inode);
down_read(&osdc->lock);
pool_name = ceph_pg_pool_name_by_id(osdc->osdmap, pool);
if (pool_name) {
len = snprintf(buf, sizeof(buf),
"stripe_unit=%u stripe_count=%u object_size=%u pool=",
ci->i_layout.stripe_unit, ci->i_layout.stripe_count,
ci->i_layout.object_size);
total_len = len + strlen(pool_name);
} else {
len = snprintf(buf, sizeof(buf),
"stripe_unit=%u stripe_count=%u object_size=%u pool=%lld",
ci->i_layout.stripe_unit, ci->i_layout.stripe_count,
ci->i_layout.object_size, pool);
total_len = len;
}
if (pool_ns)
total_len += strlen(ns_field) + pool_ns->len;
ret = total_len;
if (size >= total_len) {
memcpy(val, buf, len);
ret = len;
if (pool_name) {
len = strlen(pool_name);
memcpy(val + ret, pool_name, len);
ret += len;
}
if (pool_ns) {
len = strlen(ns_field);
memcpy(val + ret, ns_field, len);
ret += len;
memcpy(val + ret, pool_ns->str, pool_ns->len);
ret += pool_ns->len;
}
}
up_read(&osdc->lock);
ceph_put_string(pool_ns);
return ret;
}
/*
* The convention with strings in xattrs is that they should not be NULL
* terminated, since we're returning the length with them. snprintf always
* NULL terminates however, so call it on a temporary buffer and then memcpy
* the result into place.
*/
static __printf(3, 4)
int ceph_fmt_xattr(char *val, size_t size, const char *fmt, ...)
Annotation
- Immediate include surface: `linux/ceph/ceph_debug.h`, `linux/ceph/pagelist.h`, `super.h`, `mds_client.h`, `linux/ceph/decode.h`, `linux/xattr.h`, `linux/security.h`, `linux/posix_acl_xattr.h`.
- Detected declarations: `struct ceph_vxattr`, `function ceph_is_valid_xattr`, `function ceph_vxattrcb_layout_exists`, `function ceph_vxattrcb_layout`, `function __printf`, `function ceph_vxattrcb_layout_stripe_unit`, `function ceph_vxattrcb_layout_stripe_count`, `function ceph_vxattrcb_layout_object_size`, `function ceph_vxattrcb_layout_pool`, `function ceph_vxattrcb_layout_pool_namespace`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source 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.