fs/ceph/caps.c
Source file repositories/reference/linux-study-clean/fs/ceph/caps.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ceph/caps.c- Extension
.c- Size
- 142306 bytes
- Lines
- 5103
- 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/fs.hlinux/kernel.hlinux/sched/signal.hlinux/slab.hlinux/vmalloc.hlinux/wait.hlinux/writeback.hlinux/iversion.hlinux/filelock.hlinux/jiffies.hsuper.hmds_client.hcache.hcrypto.hlinux/ceph/decode.hlinux/ceph/messenger.htrace/events/ceph.h
Detected Declarations
struct cap_msg_argsstruct cap_extra_infoenum put_cap_refs_modefunction ceph_caps_initfunction ceph_caps_finalizefunction ceph_adjust_caps_max_minfunction __ceph_unreserve_capsfunction ceph_reserve_capsfunction ceph_unreserve_capsfunction ceph_put_capfunction aroundfunction ceph_reservation_statusfunction __insert_cap_nodefunction __cap_set_timeoutsfunction __cap_delay_requeuefunction __cap_delay_requeue_frontfunction __cap_delay_cancelfunction __check_cap_issuefunction change_auth_cap_sesfunction snap_rwsemfunction handle_cap_exportfunction sessionfunction __ceph_caps_issuedfunction __ceph_caps_issued_otherfunction LRUfunction __ceph_caps_issued_maskfunction __ceph_caps_issued_mask_metricfunction __ceph_caps_revoking_otherfunction __ceph_caps_usedfunction __ceph_caps_file_wantedfunction __ceph_caps_wantedfunction MDSfunction ceph_is_any_capsfunction __ceph_remove_capfunction ceph_remove_capfunction encode_cap_msgfunction __ceph_remove_capsfunction __prep_capfunction list_for_each_entry_reversefunction WARN_ON_ONCEfunction cap_msg_sizefunction cap_msg_sizefunction snap_rwsemfunction __send_flush_snapfunction __ceph_flush_snapsfunction list_for_each_entryfunction list_for_each_entryfunction ceph_flush_snaps
Annotated Snippet
struct cap_msg_args {
struct ceph_mds_session *session;
u64 ino, cid, follows;
u64 flush_tid, oldest_flush_tid, size, max_size;
u64 xattr_version;
u64 change_attr;
struct ceph_buffer *xattr_buf;
struct ceph_buffer *old_xattr_buf;
struct timespec64 atime, mtime, ctime, btime;
int op, caps, wanted, dirty;
u32 seq, issue_seq, mseq, time_warp_seq;
u32 flags;
kuid_t uid;
kgid_t gid;
umode_t mode;
bool inline_data;
bool wake;
bool encrypted;
u32 fscrypt_auth_len;
u8 fscrypt_auth[sizeof(struct ceph_fscrypt_auth)]; // for context
};
/* Marshal up the cap msg to the MDS */
static void encode_cap_msg(struct ceph_msg *msg, struct cap_msg_args *arg)
{
struct ceph_mds_caps *fc;
void *p;
struct ceph_mds_client *mdsc = arg->session->s_mdsc;
struct ceph_osd_client *osdc = &mdsc->fsc->client->osdc;
doutc(mdsc->fsc->client,
"%s %llx %llx caps %s wanted %s dirty %s seq %u/%u"
" tid %llu/%llu mseq %u follows %lld size %llu/%llu"
" xattr_ver %llu xattr_len %d\n",
ceph_cap_op_name(arg->op), arg->cid, arg->ino,
ceph_cap_string(arg->caps), ceph_cap_string(arg->wanted),
ceph_cap_string(arg->dirty), arg->seq, arg->issue_seq,
arg->flush_tid, arg->oldest_flush_tid, arg->mseq, arg->follows,
arg->size, arg->max_size, arg->xattr_version,
arg->xattr_buf ? (int)arg->xattr_buf->vec.iov_len : 0);
msg->hdr.version = cpu_to_le16(12);
msg->hdr.tid = cpu_to_le64(arg->flush_tid);
fc = msg->front.iov_base;
memset(fc, 0, sizeof(*fc));
fc->cap_id = cpu_to_le64(arg->cid);
fc->op = cpu_to_le32(arg->op);
fc->seq = cpu_to_le32(arg->seq);
fc->issue_seq = cpu_to_le32(arg->issue_seq);
fc->migrate_seq = cpu_to_le32(arg->mseq);
fc->caps = cpu_to_le32(arg->caps);
fc->wanted = cpu_to_le32(arg->wanted);
fc->dirty = cpu_to_le32(arg->dirty);
fc->ino = cpu_to_le64(arg->ino);
fc->snap_follows = cpu_to_le64(arg->follows);
#if IS_ENABLED(CONFIG_FS_ENCRYPTION)
if (arg->encrypted)
fc->size = cpu_to_le64(round_up(arg->size,
CEPH_FSCRYPT_BLOCK_SIZE));
else
#endif
fc->size = cpu_to_le64(arg->size);
fc->max_size = cpu_to_le64(arg->max_size);
ceph_encode_timespec64(&fc->mtime, &arg->mtime);
ceph_encode_timespec64(&fc->atime, &arg->atime);
ceph_encode_timespec64(&fc->ctime, &arg->ctime);
fc->time_warp_seq = cpu_to_le32(arg->time_warp_seq);
fc->uid = cpu_to_le32(from_kuid(&init_user_ns, arg->uid));
fc->gid = cpu_to_le32(from_kgid(&init_user_ns, arg->gid));
fc->mode = cpu_to_le32(arg->mode);
fc->xattr_version = cpu_to_le64(arg->xattr_version);
if (arg->xattr_buf) {
msg->middle = ceph_buffer_get(arg->xattr_buf);
fc->xattr_len = cpu_to_le32(arg->xattr_buf->vec.iov_len);
msg->hdr.middle_len = cpu_to_le32(arg->xattr_buf->vec.iov_len);
}
p = fc + 1;
/* flock buffer size (version 2) */
ceph_encode_32(&p, 0);
/* inline version (version 4) */
ceph_encode_64(&p, arg->inline_data ? 0 : CEPH_INLINE_NONE);
/* inline data size */
ceph_encode_32(&p, 0);
/*
Annotation
- Immediate include surface: `linux/ceph/ceph_debug.h`, `linux/fs.h`, `linux/kernel.h`, `linux/sched/signal.h`, `linux/slab.h`, `linux/vmalloc.h`, `linux/wait.h`, `linux/writeback.h`.
- Detected declarations: `struct cap_msg_args`, `struct cap_extra_info`, `enum put_cap_refs_mode`, `function ceph_caps_init`, `function ceph_caps_finalize`, `function ceph_adjust_caps_max_min`, `function __ceph_unreserve_caps`, `function ceph_reserve_caps`, `function ceph_unreserve_caps`, `function ceph_put_cap`.
- 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.