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.

Dependency Surface

Detected Declarations

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

Implementation Notes