pack_generic.c

来自「lustre 1.6.5 source code」· C语言 代码 · 共 1,984 行 · 第 1/5 页

C
1,984
字号
{        switch (msg->lm_magic) {        case LUSTRE_MSG_MAGIC_V1:        case LUSTRE_MSG_MAGIC_V1_SWABBED:                return 1;        default:                return 0;        }}__u32 lustre_msg_get_magic(struct lustre_msg *msg){        switch (msg->lm_magic) {        case LUSTRE_MSG_MAGIC_V1:        case LUSTRE_MSG_MAGIC_V1_SWABBED:        case LUSTRE_MSG_MAGIC_V2:        case LUSTRE_MSG_MAGIC_V2_SWABBED:                return msg->lm_magic;        default:                CERROR("incorrect message magic: %08x\n", msg->lm_magic);                return 0;        }}__u32 lustre_msg_get_timeout(struct lustre_msg *msg){        switch (msg->lm_magic) {        case LUSTRE_MSG_MAGIC_V1:        case LUSTRE_MSG_MAGIC_V1_SWABBED:                return 0;        case LUSTRE_MSG_MAGIC_V2:        case LUSTRE_MSG_MAGIC_V2_SWABBED: {                struct ptlrpc_body *pb;                                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));                if (!pb) {                        CERROR("invalid msg %p: no ptlrpc body!\n", msg);                        return 0;                                        }                return pb->pb_timeout;        }        default:                CERROR("incorrect message magic: %08x\n", msg->lm_magic);                return 0;        }}__u32 lustre_msg_get_service_time(struct lustre_msg *msg){        switch (msg->lm_magic) {        case LUSTRE_MSG_MAGIC_V1:        case LUSTRE_MSG_MAGIC_V1_SWABBED:                return 0;        case LUSTRE_MSG_MAGIC_V2:        case LUSTRE_MSG_MAGIC_V2_SWABBED: {                struct ptlrpc_body *pb;                        pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));                if (!pb) {                        CERROR("invalid msg %p: no ptlrpc body!\n", msg);                        return 0;                                        }                return pb->pb_service_time;        }        default:                CERROR("incorrect message magic: %08x\n", msg->lm_magic);                return 0;        }}__u32 lustre_msg_get_cksum(struct lustre_msg *msg){        switch (msg->lm_magic) {        case LUSTRE_MSG_MAGIC_V1:        case LUSTRE_MSG_MAGIC_V1_SWABBED:                return 0;        case LUSTRE_MSG_MAGIC_V2:        case LUSTRE_MSG_MAGIC_V2_SWABBED:                return msg->lm_cksum;        default:                CERROR("incorrect message magic: %08x\n", msg->lm_magic);                return 0;        }}__u32 lustre_msg_calc_cksum(struct lustre_msg *msg){        switch (msg->lm_magic) {        case LUSTRE_MSG_MAGIC_V1:        case LUSTRE_MSG_MAGIC_V1_SWABBED:                return 0;        case LUSTRE_MSG_MAGIC_V2:        case LUSTRE_MSG_MAGIC_V2_SWABBED: {                struct ptlrpc_body *pb;                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));                LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);                return crc32_le(~(__u32)0, (char *)pb, sizeof(*pb));        }        default:                CERROR("incorrect message magic: %08x\n", msg->lm_magic);                return 0;        }}void lustre_msg_set_handle(struct lustre_msg *msg, struct lustre_handle *handle){        switch (msg->lm_magic) {        case LUSTRE_MSG_MAGIC_V1:                ((struct lustre_msg_v1 *)msg)->lm_handle = *handle;                return;        case LUSTRE_MSG_MAGIC_V2: {                struct ptlrpc_body *pb;                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));                LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);                pb->pb_handle = *handle;                return;        }        default:                LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);        }}void lustre_msg_set_type(struct lustre_msg *msg, __u32 type){        switch (msg->lm_magic) {        case LUSTRE_MSG_MAGIC_V1:                ((struct lustre_msg_v1 *)msg)->lm_type = type;                return;        case LUSTRE_MSG_MAGIC_V2: {                struct ptlrpc_body *pb;                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));                LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);                pb->pb_type = type;                return;        }        default:                LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);        }}void lustre_msg_set_opc(struct lustre_msg *msg, __u32 opc){        switch (msg->lm_magic) {        case LUSTRE_MSG_MAGIC_V1:                ((struct lustre_msg_v1 *)msg)->lm_opc = opc;                return;        case LUSTRE_MSG_MAGIC_V2: {                struct ptlrpc_body *pb;                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));                LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);                pb->pb_opc = opc;                return;        }        default:                LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);        }}void lustre_msg_set_last_xid(struct lustre_msg *msg, __u64 last_xid){        switch (msg->lm_magic) {        case LUSTRE_MSG_MAGIC_V1:                ((struct lustre_msg_v1 *)msg)->lm_last_xid = last_xid;                return;        case LUSTRE_MSG_MAGIC_V2: {                struct ptlrpc_body *pb;                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));                LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);                pb->pb_last_xid = last_xid;                return;        }        default:                LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);        }}void lustre_msg_set_last_committed(struct lustre_msg *msg, __u64 last_committed){        switch (msg->lm_magic) {        case LUSTRE_MSG_MAGIC_V1:                ((struct lustre_msg_v1 *)msg)->lm_last_committed=last_committed;                return;        case LUSTRE_MSG_MAGIC_V2: {                struct ptlrpc_body *pb;                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));                LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);                pb->pb_last_committed = last_committed;                return;        }        default:                LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);        }}void lustre_msg_set_transno(struct lustre_msg *msg, __u64 transno){        switch (msg->lm_magic) {        case LUSTRE_MSG_MAGIC_V1:                ((struct lustre_msg_v1 *)msg)->lm_transno = transno;                return;        case LUSTRE_MSG_MAGIC_V2: {                struct ptlrpc_body *pb;                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));                LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);                pb->pb_transno = transno;                return;        }        default:                LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);        }}void lustre_msg_set_status(struct lustre_msg *msg, __u32 status){        switch (msg->lm_magic) {        case LUSTRE_MSG_MAGIC_V1:                ((struct lustre_msg_v1 *)msg)->lm_status = status;                return;        case LUSTRE_MSG_MAGIC_V2: {                struct ptlrpc_body *pb;                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));                LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);                pb->pb_status = status;                return;        }        default:                LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);        }}void lustre_msg_set_conn_cnt(struct lustre_msg *msg, __u32 conn_cnt){        switch (msg->lm_magic) {        case LUSTRE_MSG_MAGIC_V1:                ((struct lustre_msg_v1 *)msg)->lm_conn_cnt = conn_cnt;                return;        case LUSTRE_MSG_MAGIC_V2: {                struct ptlrpc_body *pb;                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));                LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);                pb->pb_conn_cnt = conn_cnt;                return;        }        default:                LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);        }}void lustre_msg_set_timeout(struct lustre_msg *msg, __u32 timeout){        switch (msg->lm_magic) {        case LUSTRE_MSG_MAGIC_V1:                return;        case LUSTRE_MSG_MAGIC_V2: {                struct ptlrpc_body *pb;                                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));                LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);                pb->pb_timeout = timeout;                return;        }        default:                LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);        }}void lustre_msg_set_service_time(struct lustre_msg *msg, __u32 service_time){        switch (msg->lm_magic) {        case LUSTRE_MSG_MAGIC_V1:                return;        case LUSTRE_MSG_MAGIC_V2: {                struct ptlrpc_body *pb;                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));                LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);                pb->pb_service_time = service_time;                return;        }        default:                LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);        }}void lustre_msg_set_cksum(struct lustre_msg *msg, __u32 cksum){        switch (msg->lm_magic) {        case LUSTRE_MSG_MAGIC_V1:                return;        case LUSTRE_MSG_MAGIC_V2:                msg->lm_cksum = cksum;                return;        default:                LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);        }}/* byte flipping routines for all wire types declared in * lustre_idl.h implemented here. */void lustre_swab_ptlrpc_body(struct ptlrpc_body *b){        __swab32s (&b->pb_type);        __swab32s (&b->pb_version);        __swab32s (&b->pb_opc);        __swab32s (&b->pb_status);        __swab64s (&b->pb_last_xid);        __swab64s (&b->pb_last_seen);        __swab64s (&b->pb_last_committed);        __swab64s (&b->pb_transno);        __swab32s (&b->pb_flags);        __swab32s (&b->pb_op_flags);        __swab32s (&b->pb_conn_cnt);        __swab32s (&b->pb_timeout);        __swab32s (&b->pb_service_time);        __swab64s (&b->pb_slv);        __swab32s (&b->pb_limit);}void lustre_swab_connect(struct obd_connect_data *ocd){        __swab64s(&ocd->ocd_connect_flags);        __swab32s(&ocd->ocd_version);        __swab32s(&ocd->ocd_grant);        __swab32s(&ocd->ocd_index);        __swab32s(&ocd->ocd_brw_size);        __swab64s(&ocd->ocd_ibits_known);        __swab32s(&ocd->ocd_nllu);        __swab32s(&ocd->ocd_nllg);        __swab64s(&ocd->ocd_transno);        __swab32s(&ocd->ocd_group);        __swab32s(&ocd->ocd_cksum_types);        CLASSERT(offsetof(typeof(*ocd), padding1) != 0);        CLASSERT(offsetof(typeof(*ocd), padding2) != 0);}void lustre_swab_obdo (struct obdo  *o){        __swab64s (&o->o_valid);        __swab64s (&o->o_id);        __swab64s (&o->o_gr);        __swab64s (&o->o_fid);        __swab64s (&o->o_size);        __swab64s (&o->o_mtime);        __swab64s (&o->o_atime);        __swab64s (&o->o_ctime);        __swab64s (&o->o_blocks);        __swab64s (&o->o_grant);        __swab32s (&o->o_blksize);        __swab32s (&o->o_mode);        __swab32s (&o->o_uid);        __swab32s (&o->o_gid);        __swab32s (&o->o_flags);        __swab32s (&o->o_nlink);        __swab32s (&o->o_generation);        __swab32s (&o->o_misc);        __swab32s (&o->o_easize);        __swab32s (&o->o_mds);        __swab32s (&o->o_stripe_idx);        __swab32s (&o->o_padding_1);        /* o_inline is opaque */}void lustre_swab_obd_statfs (struct obd_statfs *os){        __swab64s (&os->os_type);        __swab64s (&os->os_blocks);        __swab64s (&os->os_bfree);        __swab64s (&os->os_bavail);        __swab64s (&os->os_files);        __swab64s (&os->os_ffree);        /* no need to swab os_fsid */        __swab32s (&os->os_bsize);        __swab32s (&os->os_namelen);        __swab64s (&os->os_maxbytes);        __swab32s (&os->os_state);        /* no need to swap os_spare */}void lustre_swab_obd_ioobj (struct obd_ioobj *ioo){        __swab64s (&ioo->ioo_id);        __swab64s (&ioo->ioo_gr);        __swab32s (&ioo->ioo_type);        __swab32s (&i

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?