include/linux/ceph/decode.h

Source file repositories/reference/linux-study-clean/include/linux/ceph/decode.h

File Facts

System
Linux kernel
Corpus path
include/linux/ceph/decode.h
Extension
.h
Size
10174 bytes
Lines
399
Domain
Core OS
Bucket
Core Kernel Interface
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

while (len--) {					\
			ceph_decode_skip_##ktype(p, end, bad);	\
			ceph_decode_skip_##vtype(p, end, bad);	\
		}						\
	} while (0)

#define ceph_decode_skip_map_of_map(p, end, ktype1, ktype2, vtype2, bad) \
	do {							\
		u32 len;					\
								\
		ceph_decode_32_safe(p, end, len, bad);		\
		while (len--) {					\
			ceph_decode_skip_##ktype1(p, end, bad);	\
			ceph_decode_skip_map(p, end, ktype2, vtype2, bad); \
		}						\
	} while (0)

/*
 * struct ceph_timespec <-> struct timespec64
 */
static inline void ceph_decode_timespec64(struct timespec64 *ts,
					  const struct ceph_timespec *tv)
{
	/*
	 * This will still overflow in year 2106.  We could extend
	 * the protocol to steal two more bits from tv_nsec to
	 * add three more 136 year epochs after that the way ext4
	 * does if necessary.
	 */
	ts->tv_sec = (time64_t)le32_to_cpu(tv->tv_sec);
	ts->tv_nsec = (long)le32_to_cpu(tv->tv_nsec);
}
static inline void ceph_encode_timespec64(struct ceph_timespec *tv,
					  const struct timespec64 *ts)
{
	tv->tv_sec = cpu_to_le32((u32)ts->tv_sec);
	tv->tv_nsec = cpu_to_le32((u32)ts->tv_nsec);
}

/*
 * sockaddr_storage <-> ceph_sockaddr
 */
#define CEPH_ENTITY_ADDR_TYPE_NONE	0
#define CEPH_ENTITY_ADDR_TYPE_LEGACY	__cpu_to_le32(1)
#define CEPH_ENTITY_ADDR_TYPE_MSGR2	__cpu_to_le32(2)
#define CEPH_ENTITY_ADDR_TYPE_ANY	__cpu_to_le32(3)

static inline void ceph_encode_banner_addr(struct ceph_entity_addr *a)
{
	__be16 ss_family = htons(a->in_addr.ss_family);
	a->in_addr.ss_family = *(__u16 *)&ss_family;

	/* Banner addresses require TYPE_NONE */
	a->type = CEPH_ENTITY_ADDR_TYPE_NONE;
}
static inline void ceph_decode_banner_addr(struct ceph_entity_addr *a)
{
	__be16 ss_family = *(__be16 *)&a->in_addr.ss_family;
	a->in_addr.ss_family = ntohs(ss_family);
	WARN_ON(a->in_addr.ss_family == 512);
	a->type = CEPH_ENTITY_ADDR_TYPE_LEGACY;
}

extern int ceph_decode_entity_addr(void **p, void *end,
				   struct ceph_entity_addr *addr);
int ceph_decode_entity_addrvec(void **p, void *end, bool msgr2,
			       struct ceph_entity_addr *addr);

int ceph_entity_addr_encoding_len(const struct ceph_entity_addr *addr);
void ceph_encode_entity_addr(void **p, const struct ceph_entity_addr *addr);

/*
 * encoders
 */
static inline void ceph_encode_64(void **p, u64 v)
{
	put_unaligned_le64(v, (__le64 *)*p);
	*p += sizeof(u64);
}
static inline void ceph_encode_32(void **p, u32 v)
{
	put_unaligned_le32(v, (__le32 *)*p);
	*p += sizeof(u32);
}
static inline void ceph_encode_16(void **p, u16 v)
{
	put_unaligned_le16(v, (__le16 *)*p);
	*p += sizeof(u16);
}
static inline void ceph_encode_8(void **p, u8 v)

Annotation

Implementation Notes