#ifndef _LUSTRE_IDL_H_
#define _LUSTRE_IDL_H_
+#include <libcfs/kp30.h>
+
#if defined(__linux__)
#include <linux/lustre_types.h>
#elif defined(__APPLE__)
#define PTL_RPC_MSG_ERR 4712
#define PTL_RPC_MSG_REPLY 4713
-#define PTLRPC_MSG_MAGIC 0x0BD00BD0
+/* DON'T use swabbed values of MAGIC as magic! */
+#define LUSTRE_MSG_MAGIC_V1 0x0BD00BD0
+#define LUSTRE_MSG_MAGIC_V2 0x0BD00BD2
+
+#define LUSTRE_MSG_MAGIC_V1_SWABBED 0xD00BD00B
+#define LUSTRE_MSG_MAGIC_V2_SWABBED 0xD20BD00B
+#define LUSTRE_MSG_MAGIC LUSTRE_MSG_MAGIC_V2
#define PTLRPC_MSG_VERSION 0x00000003
#define LUSTRE_VERSION_MASK 0xffff0000
/* we depend on this structure to be 8-byte aligned */
/* this type is only endian-adjusted in lustre_unpack_msg() */
-struct lustre_msg {
- struct lustre_handle handle;
- __u32 magic;
- __u32 type;
- __u32 version;
- __u32 opc;
- __u64 last_xid;
- __u64 last_committed;
- __u64 transno;
- __u32 status;
- __u32 flags;
- __u32 conn_cnt;
- __u32 bufcount;
- __u32 buflens[0];
+struct lustre_msg_v1 {
+ struct lustre_handle lm_handle;
+ __u32 lm_magic;
+ __u32 lm_type;
+ __u32 lm_version;
+ __u32 lm_opc;
+ __u64 lm_last_xid;
+ __u64 lm_last_committed;
+ __u64 lm_transno;
+ __u32 lm_status;
+ __u32 lm_flags;
+ __u32 lm_conn_cnt;
+ __u32 lm_bufcount;
+ __u32 lm_buflens[0];
+};
+
+#define lustre_msg lustre_msg_v2
+/* we depend on this structure to be 8-byte aligned */
+/* this type is only endian-adjusted in lustre_unpack_msg() */
+struct lustre_msg_v2 {
+ __u32 lm_bufcount;
+ __u32 lm_secflvr;
+ __u32 lm_magic;
+ __u32 lm_repsize;
+ __u32 lm_buflens[0];
+};
+
+/* without security, ptlrpc_body is put in the first buffer. */
+struct ptlrpc_body {
+ struct lustre_handle pb_handle;
+ __u32 pb_type;
+ __u32 pb_version;
+ __u32 pb_opc;
+ __u32 pb_status;
+ __u64 pb_last_xid;
+ __u64 pb_last_committed;
+ __u64 pb_transno;
+ __u32 pb_flags;
+ __u32 pb_op_flags;
+ __u32 pb_conn_cnt;
+ __u32 pb_paddings[3];
};
+extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
+
+/* message body offset for lustre_msg_v2 */
+/* ptlrpc body offset in all request/reply messages */
+#define MSG_PTLRPC_BODY_OFF 0
+
+/* normal request/reply message record offset */
+#define REQ_REC_OFF 1
+#define REPLY_REC_OFF 1
+
+/* ldlm request message body offset */
+#define DLM_LOCKREQ_OFF 1 /* lockreq offset */
+#define DLM_REQ_REC_OFF 2 /* normal dlm request record offset */
+
+/* ldlm intent lock message body offset */
+#define DLM_INTENT_IT_OFF 2 /* intent lock it offset */
+#define DLM_INTENT_REC_OFF 3 /* intent lock record offset */
+
+/* ldlm reply message body offset */
+#define DLM_LOCKREPLY_OFF 1 /* lockrep offset */
+#define DLM_REPLY_REC_OFF 2 /* reply record offset */
+
/* Flags that are operation-specific go in the top 16 bits. */
#define MSG_OP_FLAG_MASK 0xffff0000
#define MSG_OP_FLAG_SHIFT 16
#define MSG_RESENT 2
#define MSG_REPLAY 4
-static inline int lustre_msg_get_flags(struct lustre_msg *msg)
-{
- return (msg->flags & MSG_GEN_FLAG_MASK);
-}
-
-static inline void lustre_msg_add_flags(struct lustre_msg *msg, int flags)
-{
- msg->flags |= MSG_GEN_FLAG_MASK & flags;
-}
-
-static inline void lustre_msg_set_flags(struct lustre_msg *msg, int flags)
-{
- msg->flags &= ~MSG_GEN_FLAG_MASK;
- lustre_msg_add_flags(msg, flags);
-}
-
-static inline void lustre_msg_clear_flags(struct lustre_msg *msg, int flags)
-{
- msg->flags &= ~(MSG_GEN_FLAG_MASK & flags);
-}
-
-static inline int lustre_msg_get_op_flags(struct lustre_msg *msg)
-{
- return (msg->flags >> MSG_OP_FLAG_SHIFT);
-}
-
-static inline void lustre_msg_add_op_flags(struct lustre_msg *msg, int flags)
-{
- msg->flags |= ((flags & MSG_GEN_FLAG_MASK) << MSG_OP_FLAG_SHIFT);
-}
-
-static inline void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags)
-{
- msg->flags &= ~MSG_OP_FLAG_MASK;
- lustre_msg_add_op_flags(msg, flags);
-}
-
/*
* Flags for all connect opcodes (MDS_CONNECT, OST_CONNECT)
*/
#define MSG_CONNECT_LIBCLIENT 0x10
#define MSG_CONNECT_INITIAL 0x20
#define MSG_CONNECT_ASYNC 0x40
+#define MSG_CONNECT_NEXT_VER 0x80 /* use next version of lustre_msg */
/* Connect flags */
#define OBD_CONNECT_RDONLY 0x1ULL /* client allowed read-only access */
spinlock_t imp_lock;
/* flags */
- unsigned int
- imp_invalid:1, /* evicted */
- imp_replayable:1, /* try to recover the import */
- imp_dlm_fake:1, /* don't run recovery (timeout instead) */
- imp_server_timeout:1, /* use 1/2 timeout on MDS' OSCs */
- imp_initial_recov:1, /* retry the initial connection */
- imp_initial_recov_bk:1, /* turn off init_recov after trying all failover nids */
- imp_force_verify:1, /* force an immidiate ping */
- imp_pingable:1, /* pingable */
- imp_resend_replay:1, /* resend for replay */
- imp_deactive:1; /* administratively disabled */
+ unsigned int imp_invalid:1, /* evicted */
+ imp_replayable:1, /* try to recover the import */
+ imp_dlm_fake:1, /* don't run recovery (timeout instead) */
+ imp_server_timeout:1, /* use 1/2 timeout on MDS' OSCs */
+ imp_initial_recov:1, /* retry the initial connection */
+ imp_initial_recov_bk:1, /* turn off init_recov after trying all failover nids */
+ imp_force_verify:1, /* force an immidiate ping */
+ imp_pingable:1, /* pingable */
+ imp_resend_replay:1, /* resend for replay */
+ imp_deactive:1; /* administratively disabled */
__u32 imp_connect_op;
struct obd_connect_data imp_connect_data;
__u64 imp_connect_flags_orig;
+ __u32 imp_msg_magic;
+
struct ptlrpc_request_pool *imp_rq_pool; /* emergency request pool */
};
/* unpacking: assert idx not unpacked already */
#define LASSERT_REQSWAB(rq, idx) \
do { \
- LASSERT ((idx) < sizeof ((rq)->rq_req_swab_mask) * 8); \
- LASSERT (((rq)->rq_req_swab_mask & (1 << (idx))) == 0); \
+ LASSERT((idx) < sizeof((rq)->rq_req_swab_mask) * 8); \
+ LASSERT(((rq)->rq_req_swab_mask & (1 << (idx))) == 0); \
(rq)->rq_req_swab_mask |= (1 << (idx)); \
} while (0)
#define LASSERT_REPSWAB(rq, idx) \
do { \
- LASSERT ((idx) < sizeof ((rq)->rq_rep_swab_mask) * 8); \
- LASSERT (((rq)->rq_rep_swab_mask & (1 << (idx))) == 0); \
+ LASSERT((idx) < sizeof((rq)->rq_rep_swab_mask) * 8); \
+ LASSERT(((rq)->rq_rep_swab_mask & (1 << (idx))) == 0); \
(rq)->rq_rep_swab_mask |= (1 << (idx)); \
} while (0)
/* just looking: assert idx already unpacked */
-#define LASSERT_REQSWABBED(rq, idx) \
-LASSERT ((idx) < sizeof ((rq)->rq_req_swab_mask) * 8 && \
- ((rq)->rq_req_swab_mask & (1 << (idx))) != 0)
+#define LASSERT_REQSWABBED(rq, idx) \
+LASSERT((idx) < sizeof((rq)->rq_req_swab_mask) * 8 && \
+ ((rq)->rq_req_swab_mask & (1 << (idx))) != 0); \
+
+#define LASSERT_REPSWABBED(rq, idx) \
+LASSERT((idx) < sizeof((rq)->rq_rep_swab_mask) * 8 && \
+ ((rq)->rq_rep_swab_mask & (1 << (idx))) != 0); \
-#define LASSERT_REPSWABBED(rq, idx) \
-LASSERT ((idx) < sizeof ((rq)->rq_rep_swab_mask) * 8 && \
- ((rq)->rq_rep_swab_mask & (1 << (idx))) != 0)
#else
#define LASSERT_REQSWAB(rq, idx)
#define LASSERT_REPSWAB(rq, idx)
struct lustre_handle rs_locks[RS_MAX_LOCKS];
ldlm_mode_t rs_modes[RS_MAX_LOCKS];
/* last member: variable sized reply message */
- struct lustre_msg rs_msg;
+ struct lustre_msg *rs_msg;
};
struct ptlrpc_thread;
" req@%p x"LPD64"/t"LPD64" o%d->%s@%s:%d lens %d/%d ref %d fl " \
REQ_FLAGS_FMT"/%x/%x rc %d/%d\n" , ## args, req, req->rq_xid, \
req->rq_transno, \
- req->rq_reqmsg ? req->rq_reqmsg->opc : -1, \
- req->rq_import ? obd2cli_tgt(req->rq_import->imp_obd) : "<?>", \
+ req->rq_reqmsg ? lustre_msg_get_opc(req->rq_reqmsg) : -1, \
+ req->rq_import ? obd2cli_tgt(req->rq_import->imp_obd) : "<?>", \
req->rq_import ? \
(char *)req->rq_import->imp_connection->c_remote_uuid.uuid : "<?>", \
(req->rq_import && req->rq_import->imp_client) ? \
req->rq_reqlen, req->rq_replen, \
atomic_read(&req->rq_refcount), \
DEBUG_REQ_FLAGS(req), \
- req->rq_reqmsg ? req->rq_reqmsg->flags : 0, \
- req->rq_repmsg ? req->rq_repmsg->flags : 0, \
- req->rq_status, req->rq_repmsg ? req->rq_repmsg->status : 0)
+ req->rq_reqmsg ? lustre_msg_get_flags(req->rq_reqmsg) : 0, \
+ req->rq_repmsg ? lustre_msg_get_flags(req->rq_repmsg) : 0, \
+ req->rq_status, req->rq_repmsg ? lustre_msg_get_status(req->rq_repmsg) : 0)
/* for most callers (level is a constant) this is resolved at compile time */
#define DEBUG_REQ(level, req, fmt, args...) \
struct ptlrpc_request_pool *ptlrpc_init_rq_pool(int, int,
void (*populate_pool)(struct ptlrpc_request_pool *, int));
struct ptlrpc_request *ptlrpc_prep_req(struct obd_import *imp, __u32 version,
- int opcode, int count,
- int *lengths, char **bufs);
-struct ptlrpc_request *ptlrpc_prep_req_pool(struct obd_import *imp, __u32 version,
- int opcode, int count, int *lengths,
- char **bufs,
+ int opcode, int count, int *lengths,
+ char **bufs);
+struct ptlrpc_request *ptlrpc_prep_req_pool(struct obd_import *imp,
+ __u32 version, int opcode,
+ int count, int *lengths, char **bufs,
struct ptlrpc_request_pool *pool);
void ptlrpc_free_req(struct ptlrpc_request *request);
void ptlrpc_req_finished(struct ptlrpc_request *request);
/* ptlrpc/pack_generic.c */
int lustre_msg_swabbed(struct lustre_msg *msg);
int lustre_msg_check_version(struct lustre_msg *msg, __u32 version);
-int lustre_pack_request(struct ptlrpc_request *, int count, int *lens,
- char **bufs);
+int lustre_pack_request(struct ptlrpc_request *, __u32 magic, int count,
+ int *lens, char **bufs);
int lustre_pack_reply(struct ptlrpc_request *, int count, int *lens,
char **bufs);
-void lustre_shrink_reply(struct ptlrpc_request *req,
- int segment, unsigned int newlen, int move_data);
+void lustre_shrink_reply(struct ptlrpc_request *req, int segment,
+ unsigned int newlen, int move_data);
void lustre_free_reply_state(struct ptlrpc_reply_state *rs);
-int lustre_msg_size(int count, int *lengths);
+int lustre_msg_size(__u32 magic, int count, int *lengths);
int lustre_unpack_msg(struct lustre_msg *m, int len);
+int lustre_unpack_ptlrpc_body(struct lustre_msg *m);
void *lustre_msg_buf(struct lustre_msg *m, int n, int minlen);
int lustre_msg_buflen(struct lustre_msg *m, int n);
+void lustre_msg_set_buflen(struct lustre_msg *m, int n, int len);
+int lustre_msg_bufcount(struct lustre_msg *m);
char *lustre_msg_string (struct lustre_msg *m, int n, int max_len);
void *lustre_swab_buf(struct lustre_msg *, int n, int minlen, void *swabber);
-void *lustre_swab_reqbuf (struct ptlrpc_request *req, int n, int minlen,
- void *swabber);
-void *lustre_swab_repbuf (struct ptlrpc_request *req, int n, int minlen,
- void *swabber);
+void *lustre_swab_reqbuf(struct ptlrpc_request *req, int n, int minlen,
+ void *swabber);
+void *lustre_swab_repbuf(struct ptlrpc_request *req, int n, int minlen,
+ void *swabber);
+__u32 lustre_msg_get_flags(struct lustre_msg *msg);
+void lustre_msg_add_flags(struct lustre_msg *msg, int flags);
+void lustre_msg_set_flags(struct lustre_msg *msg, int flags);
+void lustre_msg_clear_flags(struct lustre_msg *msg, int flags);
+__u32 lustre_msg_get_op_flags(struct lustre_msg *msg);
+void lustre_msg_add_op_flags(struct lustre_msg *msg, int flags);
+void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags);
+struct lustre_handle *lustre_msg_get_handle(struct lustre_msg *msg);
+__u32 lustre_msg_get_type(struct lustre_msg *msg);
+__u32 lustre_msg_get_version(struct lustre_msg *msg);
+void lustre_msg_add_version(struct lustre_msg *msg, int version);
+__u32 lustre_msg_get_opc(struct lustre_msg *msg);
+__u64 lustre_msg_get_last_xid(struct lustre_msg *msg);
+__u64 lustre_msg_get_last_committed(struct lustre_msg *msg);
+__u64 lustre_msg_get_transno(struct lustre_msg *msg);
+__u32 lustre_msg_get_status(struct lustre_msg *msg);
+__u32 lustre_msg_get_conn_cnt(struct lustre_msg *msg);
+__u32 lustre_msg_get_magic(struct lustre_msg *msg);
+void lustre_msg_set_handle(struct lustre_msg *msg,struct lustre_handle *handle);
+void lustre_msg_set_type(struct lustre_msg *msg, __u32 type);
+void lustre_msg_set_opc(struct lustre_msg *msg, __u32 opc);
+void lustre_msg_set_last_xid(struct lustre_msg *msg, __u64 last_xid);
+void lustre_msg_set_last_committed(struct lustre_msg *msg,__u64 last_committed);
+void lustre_msg_set_transno(struct lustre_msg *msg, __u64 transno);
+void lustre_msg_set_status(struct lustre_msg *msg, __u32 status);
+void lustre_msg_set_conn_cnt(struct lustre_msg *msg, __u32 conn_cnt);
static inline void
ptlrpc_rs_addref(struct ptlrpc_reply_state *rs)
lustre_free_reply_state(rs);
}
+static inline __u32 lustre_request_magic(struct ptlrpc_request *req)
+{
+ return lustre_msg_get_magic(req->rq_reqmsg);
+}
+
+static inline int ptlrpc_req_get_repsize(struct ptlrpc_request *req)
+{
+ switch (req->rq_reqmsg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ CERROR("function not supported for lustre_msg V1!\n");
+ return -ENOTSUPP;
+ case LUSTRE_MSG_MAGIC_V2:
+ return req->rq_reqmsg->lm_repsize;
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n",
+ req->rq_reqmsg->lm_magic);
+ return -EFAULT;
+ }
+}
+
+static inline void
+ptlrpc_req_set_repsize(struct ptlrpc_request *req, int count, int *lens)
+{
+ req->rq_replen = lustre_msg_size(req->rq_reqmsg->lm_magic, count, lens);
+ if (req->rq_reqmsg->lm_magic == LUSTRE_MSG_MAGIC_V2)
+ req->rq_reqmsg->lm_repsize = req->rq_replen;
+}
+
/* ldlm/ldlm_lib.c */
int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf);
int client_obd_cleanup(struct obd_device * obddev);
return;
if (req->rq_repmsg && req->rq_reqmsg != 0)
- oti->oti_transno = req->rq_repmsg->transno;
+ oti->oti_transno = lustre_msg_get_transno(req->rq_repmsg);
oti->oti_thread_id = req->rq_svc_thread ? req->rq_svc_thread->t_id : -1;
}
int rc = 0, abort_recovery;
unsigned long flags;
struct obd_connect_data *data;
- int size = sizeof(*data);
+ int size[2] = { sizeof(struct ptlrpc_body), sizeof(*data) };
ENTRY;
OBD_RACE(OBD_FAIL_TGT_CONN_RACE);
- LASSERT_REQSWAB (req, 0);
- str = lustre_msg_string(req->rq_reqmsg, 0, sizeof(tgtuuid) - 1);
+ LASSERT_REQSWAB(req, REQ_REC_OFF);
+ str = lustre_msg_string(req->rq_reqmsg, REQ_REC_OFF, sizeof(tgtuuid)-1);
if (str == NULL) {
DEBUG_REQ(D_ERROR, req, "bad target UUID for connect");
GOTO(out, rc = -EINVAL);
Really, class_uuid2obd should take the ref. */
targref = class_incref(target);
- LASSERT_REQSWAB (req, 1);
- str = lustre_msg_string(req->rq_reqmsg, 1, sizeof(cluuid) - 1);
+ LASSERT_REQSWAB(req, REQ_REC_OFF + 1);
+ str = lustre_msg_string(req->rq_reqmsg, REQ_REC_OFF + 1,
+ sizeof(cluuid) - 1);
if (str == NULL) {
DEBUG_REQ(D_ERROR, req, "bad client UUID for connect");
GOTO(out, rc = -EINVAL);
if (abort_recovery)
target_abort_recovery(target);
- tmp = lustre_msg_buf(req->rq_reqmsg, 2, sizeof conn);
+ tmp = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 2, sizeof conn);
if (tmp == NULL)
GOTO(out, rc = -EPROTO);
memcpy(&conn, tmp, sizeof conn);
- data = lustre_swab_reqbuf(req, 3, sizeof(*data), lustre_swab_connect);
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ data = lustre_swab_reqbuf(req, REQ_REC_OFF + 3, sizeof(*data),
+ lustre_swab_connect);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc)
GOTO(out, rc);
if (!export) {
spin_unlock(&target->obd_dev_lock);
OBD_FAIL_TIMEOUT(OBD_FAIL_TGT_DELAY_CONNECT, 2 * obd_timeout);
- } else if (req->rq_reqmsg->conn_cnt == 1) {
+ } else if (lustre_msg_get_conn_cnt(req->rq_reqmsg) == 1) {
CERROR("%s: NID %s (%s) reconnected with 1 conn_cnt; "
"cookies not random?\n", target->obd_name,
libcfs_nid2str(req->rq_peer.nid), cluuid.uuid);
/* Return only the parts of obd_connect_data that we understand, so the
* client knows that we don't understand the rest. */
if (data)
- memcpy(lustre_msg_buf(req->rq_repmsg, 0, sizeof(*data)), data,
- sizeof(*data));
+ memcpy(lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*data)),
+ data, sizeof(*data));
/* If all else goes well, this is our RPC return code. */
req->rq_status = 0;
- req->rq_repmsg->handle = conn;
+ lustre_msg_set_handle(req->rq_repmsg, &conn);
/* ownership of this export ref transfers to the request AFTER we
* drop any previous reference the request had, but we don't want
req->rq_export = export;
spin_lock_irqsave(&export->exp_lock, flags);
- if (export->exp_conn_cnt >= req->rq_reqmsg->conn_cnt) {
+ if (export->exp_conn_cnt >= lustre_msg_get_conn_cnt(req->rq_reqmsg)) {
CERROR("%s: %s already connected at higher conn_cnt: %d > %d\n",
cluuid.uuid, libcfs_nid2str(req->rq_peer.nid),
- export->exp_conn_cnt, req->rq_reqmsg->conn_cnt);
+ export->exp_conn_cnt,
+ lustre_msg_get_conn_cnt(req->rq_reqmsg));
+
spin_unlock_irqrestore(&export->exp_lock, flags);
GOTO(out, rc = -EALREADY);
}
- export->exp_conn_cnt = req->rq_reqmsg->conn_cnt;
+ export->exp_conn_cnt = lustre_msg_get_conn_cnt(req->rq_reqmsg);
spin_unlock_irqrestore(&export->exp_lock, flags);
/* request from liblustre? Don't evict it for not pinging. */
if (target->obd_recovering)
target->obd_connected_clients++;
- memcpy(&conn, lustre_msg_buf(req->rq_reqmsg, 2, sizeof conn),
+ memcpy(&conn,
+ lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 2, sizeof conn),
sizeof conn);
if (export->exp_imp_reverse != NULL)
revimp->imp_remote_handle = conn;
revimp->imp_dlm_fake = 1;
revimp->imp_state = LUSTRE_IMP_FULL;
+
+ if (lustre_msg_get_op_flags(req->rq_reqmsg) & MSG_CONNECT_NEXT_VER) {
+ revimp->imp_msg_magic = LUSTRE_MSG_MAGIC_V2;
+ lustre_msg_add_op_flags(req->rq_repmsg, MSG_CONNECT_NEXT_VER);
+ }
+
class_import_put(revimp);
out:
if (export)
int rc;
ENTRY;
- rc = lustre_pack_reply(req, 0, NULL, NULL);
+ rc = lustre_pack_reply(req, 1, NULL, NULL);
if (rc)
RETURN(rc);
DEBUG_REQ(D_ERROR, req, "aborted:");
req->rq_status = -ENOTCONN;
req->rq_type = PTL_RPC_MSG_ERR;
- rc = lustre_pack_reply(req, 0, NULL, NULL);
+ rc = lustre_pack_reply(req, 1, NULL, NULL);
if (rc == 0) {
ptlrpc_reply(req);
} else {
req = list_entry(obd->obd_recovery_queue.next,
struct ptlrpc_request, rq_list);
max = obd->obd_max_recoverable_clients;
- req_transno = req->rq_reqmsg->transno;
+ req_transno = lustre_msg_get_transno(req->rq_reqmsg);
connected = obd->obd_connected_clients;
completed = max - obd->obd_recoverable_clients;
queue_len = obd->obd_requests_queued_for_recovery;
wake_up = 1;
}
spin_unlock_bh(&obd->obd_processing_task_lock);
- LASSERT(req->rq_reqmsg->transno >= next_transno);
+ LASSERT(lustre_msg_get_transno(req->rq_reqmsg) >= next_transno);
return wake_up;
}
req = list_entry(obd->obd_recovery_queue.next,
struct ptlrpc_request, rq_list);
- if (req->rq_reqmsg->transno != obd->obd_next_recovery_transno) {
+ if (lustre_msg_get_transno(req->rq_reqmsg) !=
+ obd->obd_next_recovery_transno) {
spin_unlock_bh(&obd->obd_processing_task_lock);
CDEBUG(D_HA, "Waiting for transno "LPD64" (1st is "
LPD64")\n",
obd->obd_next_recovery_transno,
- req->rq_reqmsg->transno);
+ lustre_msg_get_transno(req->rq_reqmsg));
l_wait_event(obd->obd_next_transno_waitq,
check_for_next_transno(obd), &lwi);
spin_lock_bh(&obd->obd_processing_task_lock);
{
struct list_head *tmp;
int inserted = 0;
- __u64 transno = req->rq_reqmsg->transno;
+ __u64 transno = lustre_msg_get_transno(req->rq_reqmsg);
struct ptlrpc_request *saved_req;
struct lustre_msg *reqmsg;
struct ptlrpc_request *reqiter =
list_entry(tmp, struct ptlrpc_request, rq_list);
- if (reqiter->rq_reqmsg->transno > transno) {
+ if (lustre_msg_get_transno(reqiter->rq_reqmsg) > transno) {
list_add_tail(&req->rq_list, &reqiter->rq_list);
inserted = 1;
break;
if (rc) {
/* Just like ptlrpc_error, but without the sending. */
- rc = lustre_pack_reply(req, 0, NULL, NULL);
+ rc = lustre_pack_reply(req, 1, NULL, NULL);
LASSERT(rc == 0); /* XXX handle this */
req->rq_type = PTL_RPC_MSG_ERR;
}
int target_handle_ping(struct ptlrpc_request *req)
{
- return lustre_pack_reply(req, 0, NULL, NULL);
+ return lustre_pack_reply(req, 1, NULL, NULL);
}
void target_committed_to_req(struct ptlrpc_request *req)
struct obd_device *obd = req->rq_export->exp_obd;
if (!obd->obd_no_transno && req->rq_repmsg != NULL)
- req->rq_repmsg->last_committed = obd->obd_last_committed;
+ lustre_msg_set_last_committed(req->rq_repmsg,
+ obd->obd_last_committed);
else
DEBUG_REQ(D_IOCTL, req, "not sending last_committed update");
struct obd_quotactl *oqctl;
struct client_obd *cli = &req->rq_export->exp_obd->u.cli;
- oqctl = lustre_swab_reqbuf(req, 0, sizeof(*oqctl),
+ oqctl = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*oqctl),
lustre_swab_obd_quotactl);
cli->cl_qchk_stat = oqctl->qc_stat;
struct obd_device *master_obd;
struct lustre_quota_ctxt *qctxt;
struct qunit_data *qdata, *rep;
- int rc = 0, repsize = sizeof(struct qunit_data);
+ int rc = 0;
+ int repsize[2] = { sizeof(struct ptlrpc_body),
+ sizeof(struct qunit_data) };
ENTRY;
- rc = lustre_pack_reply(req, 1, &repsize, NULL);
+ rc = lustre_pack_reply(req, 2, repsize, NULL);
if (rc) {
CERROR("packing reply failed!: rc = %d\n", rc);
RETURN(rc);
}
- rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*rep));
+ rep = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*rep));
LASSERT(rep);
- qdata = lustre_swab_reqbuf(req, 0, sizeof(*qdata), lustre_swab_qdata);
+ qdata = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*qdata),
+ lustre_swab_qdata);
if (qdata == NULL) {
CERROR("unpacking request buffer failed!");
RETURN(-EPROTO);
qctxt = &master_obd->u.obt.obt_qctxt;
LASSERT(qctxt->lqc_handler);
- rc = qctxt->lqc_handler(master_obd, qdata, req->rq_reqmsg->opc);
+ rc = qctxt->lqc_handler(master_obd, qdata,
+ lustre_msg_get_opc(req->rq_reqmsg));
if (rc && rc != -EDQUOT)
CDEBUG(rc == -EBUSY ? D_QUOTA : D_ERROR,
"dqacq failed! (rc:%d)\n", rc);
LDLM_DEBUG(lock, "client (nid %s) returned %d"
" from %s AST - normal race",
libcfs_nid2str(peer.nid),
- req->rq_repmsg->status, ast_type);
+ lustre_msg_get_status(req->rq_repmsg),
+ ast_type);
else
LDLM_ERROR(lock, "client (nid %s) returned %d "
"from %s AST", libcfs_nid2str(peer.nid),
(req->rq_repmsg != NULL) ?
- req->rq_repmsg->status : 0, ast_type);
+ lustre_msg_get_status(req->rq_repmsg) : 0,
+ ast_type);
ldlm_lock_cancel(lock);
l_unlock(&lock->l_resource->lr_namespace->ns_lock);
/* Server-side AST functions are called from ldlm_reprocess_all,
{
struct ldlm_request *body;
struct ptlrpc_request *req;
- int rc = 0, size = sizeof(*body);
- int instant_cancel = 0;
+ int size[] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+ [DLM_LOCKREQ_OFF] = sizeof(*body) };
+ int instant_cancel = 0, rc = 0;
ENTRY;
if (flag == LDLM_CB_CANCELING) {
instant_cancel = 1;
req = ptlrpc_prep_req(lock->l_export->exp_imp_reverse,
- LUSTRE_DLM_VERSION, LDLM_BL_CALLBACK,
- 1, &size, NULL);
+ LUSTRE_DLM_VERSION, LDLM_BL_CALLBACK, 2, size,
+ NULL);
if (req == NULL) {
l_unlock(&lock->l_resource->lr_namespace->ns_lock);
RETURN(-ENOMEM);
}
- body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_reqmsg, DLM_LOCKREQ_OFF, sizeof(*body));
body->lock_handle1 = lock->l_remote_handle;
body->lock_desc = *desc;
body->lock_flags |= (lock->l_flags & LDLM_AST_FLAGS);
LDLM_DEBUG(lock, "server preparing blocking AST");
- req->rq_replen = lustre_msg_size(0, NULL);
+ ptlrpc_req_set_repsize(req, 1, NULL);
if (instant_cancel)
ldlm_lock_cancel(lock);
else if (lock->l_granted_mode == lock->l_req_mode)
struct ptlrpc_request *req;
struct timeval granted_time;
long total_enqueue_wait;
- int rc = 0, size[2] = {sizeof(*body)}, buffers = 1, instant_cancel = 0;
+ int size[3] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+ [DLM_LOCKREQ_OFF] = sizeof(*body) };
+ int rc = 0, buffers = 2, instant_cancel = 0;
ENTRY;
LASSERT(lock != NULL);
mutex_down(&lock->l_resource->lr_lvb_sem);
if (lock->l_resource->lr_lvb_len) {
- buffers = 2;
- size[1] = lock->l_resource->lr_lvb_len;
+ size[DLM_REQ_REC_OFF] = lock->l_resource->lr_lvb_len;
+ buffers = 3;
}
mutex_up(&lock->l_resource->lr_lvb_sem);
req = ptlrpc_prep_req(lock->l_export->exp_imp_reverse,
- LUSTRE_DLM_VERSION, LDLM_CP_CALLBACK,
- buffers, size, NULL);
+ LUSTRE_DLM_VERSION, LDLM_CP_CALLBACK, buffers,
+ size, NULL);
if (req == NULL)
RETURN(-ENOMEM);
- body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_reqmsg, DLM_LOCKREQ_OFF, sizeof(*body));
body->lock_handle1 = lock->l_remote_handle;
body->lock_flags = flags;
ldlm_lock2desc(lock, &body->lock_desc);
- if (buffers == 2) {
+ if (buffers == 3) {
void *lvb;
mutex_down(&lock->l_resource->lr_lvb_sem);
- lvb = lustre_msg_buf(req->rq_reqmsg, 1,
+ lvb = lustre_msg_buf(req->rq_reqmsg, DLM_REQ_REC_OFF,
lock->l_resource->lr_lvb_len);
memcpy(lvb, lock->l_resource->lr_lvb_data,
lock->l_resource->lr_lvb_len);
LDLM_DEBUG(lock, "server preparing completion AST (after %ldus wait)",
total_enqueue_wait);
- req->rq_replen = lustre_msg_size(0, NULL);
+ ptlrpc_req_set_repsize(req, 1, NULL);
req->rq_send_state = LUSTRE_IMP_FULL;
req->rq_timeout = ldlm_timeout; /* timeout for initial AST reply */
struct ldlm_resource *res = lock->l_resource;
struct ldlm_request *body;
struct ptlrpc_request *req;
- int rc = 0, size = sizeof(*body);
+ int size[] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+ [DLM_LOCKREQ_OFF] = sizeof(*body) };
+ int rc = 0;
ENTRY;
LASSERT(lock != NULL);
req = ptlrpc_prep_req(lock->l_export->exp_imp_reverse,
- LUSTRE_DLM_VERSION, LDLM_GL_CALLBACK,
- 1, &size, NULL);
+ LUSTRE_DLM_VERSION, LDLM_GL_CALLBACK, 2, size,
+ NULL);
if (req == NULL)
RETURN(-ENOMEM);
- body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body));
+ body = lustre_msg_buf(req->rq_reqmsg, DLM_LOCKREQ_OFF, sizeof(*body));
body->lock_handle1 = lock->l_remote_handle;
ldlm_lock2desc(lock, &body->lock_desc);
mutex_down(&lock->l_resource->lr_lvb_sem);
- size = lock->l_resource->lr_lvb_len;
+ size[REPLY_REC_OFF] = lock->l_resource->lr_lvb_len;
mutex_up(&lock->l_resource->lr_lvb_sem);
- req->rq_replen = lustre_msg_size(1, &size);
+ ptlrpc_req_set_repsize(req, 2, size);
req->rq_send_state = LUSTRE_IMP_FULL;
req->rq_timeout = ldlm_timeout; /* timeout for initial AST reply */
rc = ldlm_handle_ast_error(lock, req, rc, "glimpse");
else
rc = res->lr_namespace->ns_lvbo->lvbo_update
- (res, req->rq_repmsg, 0, 1);
+ (res, req->rq_repmsg, REPLY_REC_OFF, 1);
ptlrpc_req_finished(req);
RETURN(rc);
}
struct obd_device *obddev = req->rq_export->exp_obd;
struct ldlm_reply *dlm_rep;
struct ldlm_request *dlm_req;
- int rc = 0, size[2] = {sizeof(*dlm_rep)};
+ int size[3] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+ [DLM_LOCKREPLY_OFF] = sizeof(*dlm_rep) };
+ int rc = 0;
__u32 flags;
ldlm_error_t err = ELDLM_OK;
struct ldlm_lock *lock = NULL;
LDLM_DEBUG_NOLOCK("server-side enqueue handler START");
- dlm_req = lustre_swab_reqbuf (req, MDS_REQ_INTENT_LOCKREQ_OFF,
- sizeof (*dlm_req),
- lustre_swab_ldlm_request);
+ dlm_req = lustre_swab_reqbuf(req, DLM_LOCKREQ_OFF, sizeof(*dlm_req),
+ lustre_swab_ldlm_request);
if (dlm_req == NULL) {
CERROR ("Can't unpack dlm_req\n");
GOTO(out, rc = -EFAULT);
* local_lock_enqueue by the policy function. */
cookie = req;
} else {
- int buffers = 1;
+ int buffers = 2;
mutex_down(&lock->l_resource->lr_lvb_sem);
if (lock->l_resource->lr_lvb_len) {
- size[1] = lock->l_resource->lr_lvb_len;
- buffers = 2;
+ size[DLM_REPLY_REC_OFF] = lock->l_resource->lr_lvb_len;
+ buffers = 3;
}
mutex_up(&lock->l_resource->lr_lvb_sem);
if (err)
GOTO(out, err);
- dlm_rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*dlm_rep));
+ dlm_rep = lustre_msg_buf(req->rq_repmsg, DLM_LOCKREPLY_OFF,
+ sizeof(*dlm_rep));
dlm_rep->lock_flags = flags;
ldlm_lock2desc(lock, &dlm_rep->lock_desc);
LDLM_ERROR(lock, "sync lock");
if (dlm_req->lock_flags & LDLM_FL_HAS_INTENT) {
struct ldlm_intent *it;
- it = lustre_msg_buf(req->rq_reqmsg, 1,
+ it = lustre_msg_buf(req->rq_reqmsg,
+ DLM_INTENT_IT_OFF,
sizeof(*it));
if (it != NULL) {
- CERROR("This is intent %s ("
- LPU64 ")\n",
+ CERROR("This is intent %s ("LPU64")\n",
ldlm_it2str(it->opc), it->opc);
}
}
out:
req->rq_status = err;
if (req->rq_reply_state == NULL) {
- err = lustre_pack_reply(req, 0, NULL, NULL);
+ err = lustre_pack_reply(req, 1, NULL, NULL);
if (rc == 0)
rc = err;
req->rq_status = rc;
if (rc == 0) {
mutex_down(&lock->l_resource->lr_lvb_sem);
- size[1] = lock->l_resource->lr_lvb_len;
- if (size[1] > 0) {
+ size[DLM_REPLY_REC_OFF] = lock->l_resource->lr_lvb_len;
+ if (size[DLM_REPLY_REC_OFF] > 0) {
void *lvb = lustre_msg_buf(req->rq_repmsg,
- 1, size[1]);
+ DLM_REPLY_REC_OFF,
+ size[DLM_REPLY_REC_OFF]);
LASSERTF(lvb != NULL, "req %p, lock %p\n",
req, lock);
memcpy(lvb, lock->l_resource->lr_lvb_data,
- size[1]);
+ size[DLM_REPLY_REC_OFF]);
}
mutex_up(&lock->l_resource->lr_lvb_sem);
} else {
struct ldlm_request *dlm_req;
struct ldlm_reply *dlm_rep;
struct ldlm_lock *lock;
- int rc, size = sizeof(*dlm_rep);
+ int rc;
+ int size[2] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+ [DLM_LOCKREPLY_OFF] = sizeof(*dlm_rep) };
ENTRY;
- dlm_req = lustre_swab_reqbuf (req, 0, sizeof (*dlm_req),
- lustre_swab_ldlm_request);
+ dlm_req = lustre_swab_reqbuf(req, DLM_LOCKREQ_OFF, sizeof(*dlm_req),
+ lustre_swab_ldlm_request);
if (dlm_req == NULL) {
CERROR ("Can't unpack dlm_req\n");
RETURN (-EFAULT);
}
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc) {
CERROR("out of memory\n");
RETURN(-ENOMEM);
}
- dlm_rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*dlm_rep));
+ dlm_rep = lustre_msg_buf(req->rq_repmsg, DLM_LOCKREPLY_OFF,
+ sizeof(*dlm_rep));
dlm_rep->lock_flags = dlm_req->lock_flags;
lock = ldlm_handle2lock(&dlm_req->lock_handle1);
int rc;
ENTRY;
- dlm_req = lustre_swab_reqbuf(req, 0, sizeof (*dlm_req),
- lustre_swab_ldlm_request);
+ dlm_req = lustre_swab_reqbuf(req, DLM_LOCKREQ_OFF, sizeof(*dlm_req),
+ lustre_swab_ldlm_request);
if (dlm_req == NULL) {
CERROR("bad request buffer for cancel\n");
RETURN(-EFAULT);
}
- rc = lustre_pack_reply(req, 0, NULL, NULL);
+ rc = lustre_pack_reply(req, 1, NULL, NULL);
if (rc) {
CERROR("out of memory\n");
RETURN(-ENOMEM);
if (lock->l_lvb_len) {
void *lvb;
- lvb = lustre_swab_reqbuf(req, 1, lock->l_lvb_len,
+ lvb = lustre_swab_reqbuf(req, DLM_REQ_REC_OFF, lock->l_lvb_len,
lock->l_lvb_swabber);
if (lvb == NULL) {
LDLM_ERROR(lock, "completion AST did not contain "
{
req->rq_status = rc;
if (req->rq_reply_state == NULL) {
- rc = lustre_pack_reply(req, 0, NULL, NULL);
+ rc = lustre_pack_reply(req, 1, NULL, NULL);
if (rc)
return rc;
}
CDEBUG(D_RPCTRACE, "operation %d from %s with bad "
"export cookie "LPX64"; this is "
"normal if this node rebooted with a lock held\n",
- req->rq_reqmsg->opc,
+ lustre_msg_get_opc(req->rq_reqmsg),
libcfs_id2str(req->rq_peer),
- req->rq_reqmsg->handle.cookie);
+ lustre_msg_get_handle(req->rq_reqmsg)->cookie);
- dlm_req = lustre_swab_reqbuf(req, 0, sizeof (*dlm_req),
+ dlm_req = lustre_swab_reqbuf(req, DLM_LOCKREQ_OFF,
+ sizeof(*dlm_req),
lustre_swab_ldlm_request);
if (dlm_req != NULL)
CDEBUG(D_RPCTRACE, "--> lock cookie: "LPX64"\n",
LASSERT(req->rq_export != NULL);
LASSERT(req->rq_export->exp_obd != NULL);
- switch(req->rq_reqmsg->opc) {
+ switch (lustre_msg_get_opc(req->rq_reqmsg)) {
case LDLM_BL_CALLBACK:
OBD_FAIL_RETURN(OBD_FAIL_LDLM_BL_CALLBACK, 0);
break;
ldlm_callback_reply(req, rc);
RETURN(0);
default:
- CERROR("unknown opcode %u\n", req->rq_reqmsg->opc);
+ CERROR("unknown opcode %u\n",
+ lustre_msg_get_opc(req->rq_reqmsg));
ldlm_callback_reply(req, -EPROTO);
RETURN(0);
}
ns = req->rq_export->exp_obd->obd_namespace;
LASSERT(ns != NULL);
- dlm_req = lustre_swab_reqbuf (req, 0, sizeof (*dlm_req),
- lustre_swab_ldlm_request);
+ dlm_req = lustre_swab_reqbuf(req, DLM_LOCKREQ_OFF, sizeof(*dlm_req),
+ lustre_swab_ldlm_request);
if (dlm_req == NULL) {
CERROR ("can't unpack dlm_req\n");
- ldlm_callback_reply (req, -EPROTO);
+ ldlm_callback_reply(req, -EPROTO);
RETURN (0);
}
* in the reply, so we might have to push the responsibility for sending
* the reply down into the AST handlers, alas. */
- switch (req->rq_reqmsg->opc) {
+ switch (lustre_msg_get_opc(req->rq_reqmsg)) {
case LDLM_BL_CALLBACK:
CDEBUG(D_INODE, "blocking ast\n");
if (!(lock->l_flags & LDLM_FL_CANCEL_ON_BLOCK))
struct ldlm_request *dlm_req;
CERROR("operation %d from %s with bad export cookie "LPU64"\n",
- req->rq_reqmsg->opc, libcfs_id2str(req->rq_peer),
- req->rq_reqmsg->handle.cookie);
+ lustre_msg_get_opc(req->rq_reqmsg),
+ libcfs_id2str(req->rq_peer),
+ lustre_msg_get_handle(req->rq_reqmsg)->cookie);
- dlm_req = lustre_swab_reqbuf(req, 0, sizeof (*dlm_req),
+ dlm_req = lustre_swab_reqbuf(req, DLM_LOCKREQ_OFF,
+ sizeof(*dlm_req),
lustre_swab_ldlm_request);
if (dlm_req != NULL)
ldlm_lock_dump_handle(D_ERROR, &dlm_req->lock_handle1);
RETURN(0);
}
- switch (req->rq_reqmsg->opc) {
+ switch (lustre_msg_get_opc(req->rq_reqmsg)) {
/* XXX FIXME move this back to mds/handler.c, bug 249 */
case LDLM_CANCEL:
ldlm_callback_reply(req, rc);
RETURN(0);
default:
- CERROR("invalid opcode %d\n", req->rq_reqmsg->opc);
+ CERROR("invalid opcode %d\n",
+ lustre_msg_get_opc(req->rq_reqmsg));
ldlm_callback_reply(req, -EINVAL);
}
struct ldlm_lock *lock;
struct ldlm_request *body;
struct ldlm_reply *reply;
- int rc, size[] = {sizeof(*body), lvb_len}, req_passed_in = 1;
+ int size[3] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+ [DLM_LOCKREQ_OFF] = sizeof(*body),
+ [DLM_REPLY_REC_OFF] = lvb_len };
int is_replay = *flags & LDLM_FL_REPLAY;
- int cleanup_phase = 0;
+ int req_passed_in = 1, cleanup_phase = 0, rc;
ENTRY;
if (exp == NULL) {
if (req == NULL) {
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_DLM_VERSION,
- LDLM_ENQUEUE, 1, size, NULL);
+ LDLM_ENQUEUE, 2, size, NULL);
if (req == NULL)
GOTO(cleanup, rc = -ENOMEM);
req_passed_in = 0;
} else {
- LASSERTF(req->rq_reqmsg->buflens[MDS_REQ_INTENT_LOCKREQ_OFF] ==
+ LASSERTF(lustre_msg_buflen(req->rq_reqmsg, DLM_LOCKREQ_OFF) ==
sizeof(*body), "buflen[%d] = %d, not %d\n",
- MDS_REQ_INTENT_LOCKREQ_OFF,
- req->rq_reqmsg->buflens[MDS_REQ_INTENT_LOCKREQ_OFF],
- (int)sizeof(*body));
+ DLM_LOCKREQ_OFF,
+ lustre_msg_buflen(req->rq_reqmsg, DLM_LOCKREQ_OFF),
+ sizeof(*body));
}
lock->l_conn_export = exp;
lock->l_blocking_ast = blocking;
/* Dump lock data into the request buffer */
- body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_INTENT_LOCKREQ_OFF,
- sizeof(*body));
+ body = lustre_msg_buf(req->rq_reqmsg, DLM_LOCKREQ_OFF, sizeof(*body));
ldlm_lock2desc(lock, &body->lock_desc);
body->lock_flags = *flags;
-
body->lock_handle1 = *lockh;
/* Continue as normal. */
if (!req_passed_in) {
- size[0] = sizeof(*reply);
- req->rq_replen = lustre_msg_size(1 + (lvb_len > 0), size);
+ size[DLM_LOCKREPLY_OFF] = sizeof(*reply);
+ ptlrpc_req_set_repsize(req, 2 + (lvb_len > 0), size);
+
}
LDLM_DEBUG(lock, "sending request");
rc = ptlrpc_queue_wait(req);
rc == ELDLM_LOCK_ABORTED ? "ABORTED" : "FAILED");
if (rc == ELDLM_LOCK_ABORTED) {
/* Before we return, swab the reply */
- reply = lustre_swab_repbuf(req, 0, sizeof(*reply),
+ reply = lustre_swab_repbuf(req, DLM_LOCKREPLY_OFF,
+ sizeof(*reply),
lustre_swab_ldlm_reply);
if (reply == NULL) {
CERROR("Can't unpack ldlm_reply\n");
}
if (lvb_len) {
void *tmplvb;
- tmplvb = lustre_swab_repbuf(req, 1, lvb_len,
+ tmplvb = lustre_swab_repbuf(req,
+ DLM_REPLY_REC_OFF,
+ lvb_len,
lvb_swabber);
if (tmplvb == NULL)
GOTO(cleanup, rc = -EPROTO);
LASSERT(ergo(LIBLUSTRE_CLIENT, type != LDLM_EXTENT ||
policy->l_extent.end == OBD_OBJECT_EOF));
- reply = lustre_swab_repbuf(req, 0, sizeof(*reply),
+ reply = lustre_swab_repbuf(req, DLM_LOCKREPLY_OFF, sizeof(*reply),
lustre_swab_ldlm_reply);
if (reply == NULL) {
CERROR("Can't unpack ldlm_reply\n");
* clobber the LVB with an older one. */
if (lvb_len && (lock->l_req_mode != lock->l_granted_mode)) {
void *tmplvb;
- tmplvb = lustre_swab_repbuf(req, 1, lvb_len, lvb_swabber);
+ tmplvb = lustre_swab_repbuf(req, DLM_REPLY_REC_OFF, lvb_len,
+ lvb_swabber);
if (tmplvb == NULL)
GOTO(cleanup, rc = -EPROTO);
memcpy(lock->l_lvb_data, tmplvb, lvb_len);
struct ldlm_lock *lock;
struct ldlm_resource *res;
struct ptlrpc_request *req;
- int rc, size = sizeof(*body);
+ int size[2] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+ [DLM_LOCKREQ_OFF] = sizeof(*body) };
+ int rc;
ENTRY;
lock = ldlm_handle2lock(lockh);
LDLM_DEBUG(lock, "client-side convert");
req = ptlrpc_prep_req(class_exp2cliimp(lock->l_conn_export),
- LUSTRE_DLM_VERSION, LDLM_CONVERT, 1, &size, NULL);
+ LUSTRE_DLM_VERSION, LDLM_CONVERT, 2, size, NULL);
if (!req)
GOTO(out, rc = -ENOMEM);
- body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_reqmsg, DLM_LOCKREQ_OFF, sizeof(*body));
body->lock_handle1 = lock->l_remote_handle;
body->lock_desc.l_req_mode = new_mode;
body->lock_flags = *flags;
- size = sizeof(*reply);
- req->rq_replen = lustre_msg_size(1, &size);
+ size[DLM_LOCKREPLY_OFF] = sizeof(*reply);
+ ptlrpc_req_set_repsize(req, 2, size);
rc = ptlrpc_queue_wait(req);
if (rc != ELDLM_OK)
GOTO(out, rc);
- reply = lustre_swab_repbuf(req, 0, sizeof (*reply),
+ reply = lustre_swab_repbuf(req, DLM_LOCKREPLY_OFF, sizeof(*reply),
lustre_swab_ldlm_reply);
if (reply == NULL) {
CERROR ("Can't unpack ldlm_reply\n");
struct ptlrpc_request *req;
struct ldlm_lock *lock;
struct ldlm_request *body;
- int rc = 0, size = sizeof(*body);
+ int size[2] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+ [DLM_LOCKREQ_OFF] = sizeof(*body) };
+ int rc = 0;
ENTRY;
/* concurrent cancels on the same handle can happen */
goto local_cancel;
}
- req = ptlrpc_prep_req(imp, LUSTRE_DLM_VERSION, LDLM_CANCEL,
- 1, &size, NULL);
+ req = ptlrpc_prep_req(imp, LUSTRE_DLM_VERSION, LDLM_CANCEL, 2,
+ size, NULL);
if (!req)
GOTO(out, rc = -ENOMEM);
req->rq_no_resend = 1;
req->rq_request_portal = LDLM_CANCEL_REQUEST_PORTAL;
req->rq_reply_portal = LDLM_CANCEL_REPLY_PORTAL;
- body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_reqmsg, DLM_LOCKREQ_OFF,
+ sizeof(*body));
body->lock_handle1 = lock->l_remote_handle;
- req->rq_replen = lustre_msg_size(0, NULL);
-
+ ptlrpc_req_set_repsize(req, 1, NULL);
rc = ptlrpc_queue_wait(req);
if (rc == ESTALE) {
lock = req->rq_async_args.pointer_arg[0];
LASSERT(lock != NULL);
- reply = lustre_swab_repbuf(req, 0, sizeof (*reply),
+ reply = lustre_swab_repbuf(req, DLM_LOCKREPLY_OFF, sizeof(*reply),
lustre_swab_ldlm_reply);
if (reply == NULL) {
CERROR("Can't unpack ldlm_reply\n");
struct ptlrpc_request *req;
struct ldlm_request *body;
struct ldlm_reply *reply;
- int buffers = 1;
- int size[2];
+ int buffers = 2;
+ int size[3] = { sizeof(struct ptlrpc_body) };
int flags;
ENTRY;
else
flags = LDLM_FL_REPLAY;
- size[0] = sizeof(*body);
- req = ptlrpc_prep_req(imp, LUSTRE_DLM_VERSION, LDLM_ENQUEUE,
- 1, size, NULL);
+ size[DLM_LOCKREQ_OFF] = sizeof(*body);
+ req = ptlrpc_prep_req(imp, LUSTRE_DLM_VERSION, LDLM_ENQUEUE, 2, size,
+ NULL);
if (!req)
RETURN(-ENOMEM);
/* We're part of recovery, so don't wait for it. */
req->rq_send_state = LUSTRE_IMP_REPLAY_LOCKS;
- body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_reqmsg, DLM_LOCKREQ_OFF, sizeof(*body));
ldlm_lock2desc(lock, &body->lock_desc);
body->lock_flags = flags;
ldlm_lock2handle(lock, &body->lock_handle1);
- size[0] = sizeof(*reply);
+ size[DLM_LOCKREPLY_OFF] = sizeof(*reply);
if (lock->l_lvb_len != 0) {
- buffers = 2;
- size[1] = lock->l_lvb_len;
+ buffers = 3;
+ size[DLM_REPLY_REC_OFF] = lock->l_lvb_len;
}
- req->rq_replen = lustre_msg_size(buffers, size);
+ ptlrpc_req_set_repsize(req, buffers, size);
LDLM_DEBUG(lock, "replaying lock:");
rc = mdc_readpage(sbi->ll_mdc_exp, &mdc_fid,
offset, page, &request);
if (!rc) {
- body = lustre_msg_buf(request->rq_repmsg, 0, sizeof (*body));
- LASSERT (body != NULL); /* checked by mdc_readpage() */
- LASSERT_REPSWABBED (request, 0); /* swabbed by mdc_readpage() */
+ body = lustre_msg_buf(request->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*body));
+ LASSERT(body != NULL); /* checked by mdc_readpage() */
+ /* swabbed by mdc_readpage() */
+ LASSERT_REPSWABBED(request, REPLY_REC_OFF);
st->st_size = body->size;
} else {
struct mds_body *body;
ENTRY;
- body = lustre_msg_buf (req->rq_repmsg, 1, sizeof (*body));
- LASSERT (body != NULL); /* reply already checked out */
- LASSERT_REPSWABBED (req, 1); /* and swabbed down */
+ body = lustre_msg_buf(req->rq_repmsg, DLM_REPLY_REC_OFF, sizeof(*body));
+ LASSERT(body != NULL); /* reply already checked out */
+ LASSERT_REPSWABBED(req, DLM_REPLY_REC_OFF); /* and swabbed down */
/* already opened? */
if (lli->lli_open_count++)
ENTRY;
/* req is swabbed so this is safe */
- body = lustre_msg_buf(request->rq_repmsg, 0, sizeof(*body));
+ body = lustre_msg_buf(request->rq_repmsg, REPLY_REC_OFF, sizeof(*body));
if (!(body->valid & OBD_MD_FLEASIZE))
RETURN(0);
* to this file. Use this EA to unlink the objects on the OST.
* It's opaque so we don't swab here; we leave it to obd_unpackmd() to
* check it is complete and sensible. */
- eadata = lustre_swab_repbuf(request, 1, body->eadatasize, NULL);
+ eadata = lustre_swab_repbuf(request, REPLY_REC_OFF+1, body->eadatasize,
+ NULL);
LASSERT(eadata != NULL);
if (eadata == NULL) {
CERROR("Can't unpack MDS EA data\n");
if (body->valid & OBD_MD_FLCOOKIE) {
oa->o_valid |= OBD_MD_FLCOOKIE;
oti.oti_logcookies =
- lustre_msg_buf(request->rq_repmsg, 2,
+ lustre_msg_buf(request->rq_repmsg, REPLY_REC_OFF + 2,
sizeof(struct llog_cookie) *
lsm->lsm_stripe_count);
if (oti.oti_logcookies == NULL) {
if (rc < 0)
GOTO(out, rc = 0);
- rc = pnode_revalidate_finish(req, 1, it, pnode);
+ rc = pnode_revalidate_finish(req, DLM_REPLY_REC_OFF, it, pnode);
if (rc != 0) {
ll_intent_release(it);
GOTO(out, rc = 0);
if (rc < 0)
GOTO(out, rc);
- rc = lookup_it_finish(req, 1, it, &icbd);
+ rc = lookup_it_finish(req, DLM_REPLY_REC_OFF, it, &icbd);
if (rc != 0) {
ll_intent_release(it);
GOTO(out, rc);
struct inode *inode = llu_inode_from_lock(lock);
struct llu_inode_info *lli;
struct ost_lvb *lvb;
- int rc, size = sizeof(*lvb), stripe = 0;
+ int size[2] = { sizeof(struct ptlrpc_body), sizeof(*lvb) };
+ int rc, stripe = 0;
ENTRY;
if (inode == NULL)
if (lli->lli_smd->lsm_stripe_count > 1)
stripe = llu_lock_to_stripe_offset(inode, lock);
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc) {
CERROR("lustre_pack_reply: %d\n", rc);
GOTO(iput, rc);
}
- lvb = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*lvb));
+ lvb = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*lvb));
lvb->lvb_size = lli->lli_smd->lsm_oinfo[stripe].loi_kms;
LDLM_DEBUG(lock, "i_size: %llu -> stripe number %u -> kms "LPU64,
/* These errors are normal races, so we don't want to fill the console
* with messages by calling ptlrpc_error() */
if (rc == -ELDLM_NO_LOCK_DATA)
- lustre_pack_reply(req, 0, NULL, NULL);
+ lustre_pack_reply(req, 1, NULL, NULL);
req->rq_status = rc;
return rc;
(long long)llu_i2stat(inode)->st_ino);
RETURN(-abs(rc));
}
- rc = mdc_req2lustre_md(req, 0, sbi->ll_osc_exp, &md);
+ rc = mdc_req2lustre_md(req, REPLY_REC_OFF, sbi->ll_osc_exp,&md);
/* XXX Too paranoid? */
if (((md.body->valid ^ valid) & OBD_MD_FLEASIZE) &&
RETURN(rc);
}
- rc = mdc_req2lustre_md(request, 0, sbi->ll_osc_exp, &md);
+ rc = mdc_req2lustre_md(request, REPLY_REC_OFF, sbi->ll_osc_exp,
+ &md);
if (rc) {
ptlrpc_req_finished(request);
RETURN(rc);
RETURN(rc);
}
- body = lustre_msg_buf ((*request)->rq_repmsg, 0, sizeof (*body));
- LASSERT (body != NULL);
- LASSERT_REPSWABBED (*request, 0);
+ body = lustre_msg_buf((*request)->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*body));
+ LASSERT(body != NULL);
+ LASSERT_REPSWABBED(*request, REPLY_REC_OFF);
if ((body->valid & OBD_MD_LINKNAME) == 0) {
CERROR ("OBD_MD_LINKNAME not set on reply\n");
GOTO(failed, rc = -EPROTO);
}
- *symname = lustre_msg_buf ((*request)->rq_repmsg, 1, symlen);
+ *symname = lustre_msg_buf((*request)->rq_repmsg, REPLY_REC_OFF + 1,
+ symlen);
if (*symname == NULL ||
strnlen(*symname, symlen) != symlen - 1) {
/* not full/NULL terminated */
GOTO(out_osc, err);
}
- err = mdc_req2lustre_md(request, 0, sbi->ll_osc_exp, &md);
+ err = mdc_req2lustre_md(request, REPLY_REC_OFF, sbi->ll_osc_exp, &md);
if (err) {
CERROR("failed to understand root inode md: rc = %d\n",err);
GOTO(out_request, err);
RETURN(-ENOENT);
rc = ll_prep_inode(ll_i2sbi(de->d_inode)->ll_osc_exp, &de->d_inode,
- request, offset,NULL);
+ request, offset, NULL);
RETURN(rc);
}
GOTO(out, rc = 0);
}
- rc = revalidate_it_finish(req, 1, it, de);
+ rc = revalidate_it_finish(req, DLM_REPLY_REC_OFF, it, de);
if (rc != 0) {
ll_intent_release(it);
GOTO(out, rc = 0);
rc = mdc_readpage(ll_i2sbi(inode)->ll_mdc_exp, &mdc_fid,
offset, page, &request);
if (!rc) {
- body = lustre_msg_buf(request->rq_repmsg, 0, sizeof (*body));
- LASSERT (body != NULL); /* checked by mdc_readpage() */
- LASSERT_REPSWABBED (request, 0); /* swabbed by mdc_readpage() */
+ body = lustre_msg_buf(request->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*body));
+ LASSERT(body != NULL); /* checked by mdc_readpage() */
+ /* swabbed by mdc_readpage() */
+ LASSERT_REPSWABBED(request, REPLY_REC_OFF);
inode->i_size = body->size;
SetPageUptodate(page);
RETURN(rc);
}
- body = lustre_msg_buf(request->rq_repmsg, 0, sizeof(*body));
- LASSERT(body != NULL); /* checked by mdc_getattr_name */
- LASSERT_REPSWABBED(request, 0);/* swabbed by mdc_getattr_name */
+ body = lustre_msg_buf(request->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*body));
+ LASSERT(body != NULL); /* checked by mdc_getattr_name */
+ /* swabbed by mdc_getattr_name */
+ LASSERT_REPSWABBED(request, REPLY_REC_OFF);
lmmsize = body->eadatasize;
if (lmmsize == 0)
GOTO(out_get, rc = -ENODATA);
- lmm = lustre_msg_buf(request->rq_repmsg, 1, lmmsize);
+ lmm = lustre_msg_buf(request->rq_repmsg, REPLY_REC_OFF + 1,
+ lmmsize);
LASSERT(lmm != NULL);
- LASSERT_REPSWABBED(request, 1);
+ LASSERT_REPSWABBED(request, REPLY_REC_OFF + 1);
/*
* This is coming from the MDS, so is probably in
GOTO(out_name, rc);
}
- body = lustre_msg_buf(request->rq_repmsg, 0, sizeof (*body));
- LASSERT(body != NULL); /* checked by mdc_getattr_name */
- LASSERT_REPSWABBED(request, 0);/* swabbed by mdc_getattr_name */
+ body = lustre_msg_buf(request->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*body));
+ LASSERT(body != NULL); /* checked by mdc_getattr_name */
+ /* swabbed by mdc_getattr_name */
+ LASSERT_REPSWABBED(request, REPLY_REC_OFF);
lmmsize = body->eadatasize;
if (lmmsize > 4096)
GOTO(out_req, rc = -EFBIG);
- lmm = lustre_msg_buf(request->rq_repmsg, 1, lmmsize);
+ lmm = lustre_msg_buf(request->rq_repmsg, REPLY_REC_OFF + 1,
+ lmmsize);
LASSERT(lmm != NULL);
- LASSERT_REPSWABBED(request, 1);
+ LASSERT_REPSWABBED(request, REPLY_REC_OFF + 1);
/*
* This is coming from the MDS, so is probably in
struct ptlrpc_request *req = NULL;
char *buf = NULL;
int rc, len = 0;
- char *bufs[2], *str;
- int lens[2], size;
+ char *bufs[3] = { NULL }, *str;
+ int lens[3] = { sizeof(struct ptlrpc_body) };
+ int size[2] = { sizeof(struct ptlrpc_body) };
rc = obd_ioctl_getdata(&buf, &len, (void *)arg);
if (rc)
RETURN(-EINVAL);
}
- lens[0] = data->ioc_inllen1;
- bufs[0] = data->ioc_inlbuf1;
+ lens[REQ_REC_OFF] = data->ioc_inllen1;
+ bufs[REQ_REC_OFF] = data->ioc_inlbuf1;
if (data->ioc_inllen2) {
- lens[1] = data->ioc_inllen2;
- bufs[1] = data->ioc_inlbuf2;
+ lens[REQ_REC_OFF + 1] = data->ioc_inllen2;
+ bufs[REQ_REC_OFF + 1] = data->ioc_inlbuf2;
} else {
- lens[1] = 0;
- bufs[1] = NULL;
+ lens[REQ_REC_OFF + 1] = 0;
+ bufs[REQ_REC_OFF + 1] = NULL;
}
- size = data->ioc_plen1;
+
req = ptlrpc_prep_req(sbi2mdc(sbi)->cl_import,
- LUSTRE_LOG_VERSION, LLOG_CATINFO,
- 2, lens, bufs);
+ LUSTRE_LOG_VERSION, LLOG_CATINFO, 3, lens,
+ bufs);
if (!req)
GOTO(out_catinfo, rc = -ENOMEM);
- req->rq_replen = lustre_msg_size(1, &size);
+
+ size[REPLY_REC_OFF] = data->ioc_plen1;
+ ptlrpc_req_set_repsize(req, 2, size);
rc = ptlrpc_queue_wait(req);
- str = lustre_msg_string(req->rq_repmsg, 0, data->ioc_plen1);
+ str = lustre_msg_string(req->rq_repmsg, REPLY_REC_OFF,
+ data->ioc_plen1);
if (!rc)
- rc = copy_to_user(data->ioc_pbuf1, str,
- data->ioc_plen1);
+ rc = copy_to_user(data->ioc_pbuf1, str,data->ioc_plen1);
ptlrpc_req_finished(req);
out_catinfo:
obd_ioctl_freedata(buf, len);
}
rc = ll_prep_inode(sbi->ll_osc_exp, &file->f_dentry->d_inode,
- (struct ptlrpc_request *)itp->d.lustre.it_data, 1,
- NULL);
+ (struct ptlrpc_request *)itp->d.lustre.it_data,
+ DLM_REPLY_REC_OFF, NULL);
out:
RETURN(rc);
}
LASSERT(och);
- body = lustre_msg_buf(req->rq_repmsg, 1, sizeof(*body));
+ body = lustre_msg_buf(req->rq_repmsg, DLM_REPLY_REC_OFF, sizeof(*body));
LASSERT(body != NULL); /* reply already checked out */
- LASSERT_REPSWABBED(req, 1); /* and swabbed in mdc_enqueue */
+ LASSERT_REPSWABBED(req, DLM_REPLY_REC_OFF); /* and swabbed in mdc_enqueue */
memcpy(&och->och_fh, &body->handle, sizeof(body->handle));
och->och_magic = OBD_CLIENT_HANDLE_MAGIC;
struct ll_inode_info *lli;
struct lov_stripe_md *lsm;
struct ost_lvb *lvb;
- int rc, size = sizeof(*lvb), stripe;
+ int rc, stripe;
+ int size[2] = { sizeof(struct ptlrpc_body), sizeof(*lvb) };
ENTRY;
if (inode == NULL)
if (stripe < 0)
GOTO(iput, rc = -ELDLM_NO_LOCK_DATA);
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc) {
CERROR("lustre_pack_reply: %d\n", rc);
GOTO(iput, rc);
}
- lvb = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*lvb));
+ lvb = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*lvb));
lvb->lvb_size = lli->lli_smd->lsm_oinfo[stripe].loi_kms;
lvb->lvb_mtime = LTIME_S(inode->i_mtime);
lvb->lvb_atime = LTIME_S(inode->i_atime);
" atime "LPU64", mtime "LPU64", ctime "LPU64,
inode->i_size, stripe, lvb->lvb_size, lvb->lvb_mtime,
lvb->lvb_atime, lvb->lvb_ctime);
- GOTO(iput, 0);
iput:
iput(inode);
/* These errors are normal races, so we don't want to fill the console
* with messages by calling ptlrpc_error() */
if (rc == -ELDLM_NO_LOCK_DATA)
- lustre_pack_reply(req, 0, NULL, NULL);
+ lustre_pack_reply(req, 1, NULL, NULL);
req->rq_status = rc;
return rc;
if (rc < 0)
GOTO(out, rc);
- rc = mdc_req2lustre_md(req, 1, exp, &md);
+ rc = mdc_req2lustre_md(req, DLM_REPLY_REC_OFF, exp, &md);
if (rc)
GOTO(out, rc);
ll_update_inode(f->f_dentry->d_inode, &md);
GOTO (out, rc);
}
- rc = revalidate_it_finish(req, 1, &oit, dentry);
+ rc = revalidate_it_finish(req, DLM_REPLY_REC_OFF, &oit, dentry);
if (rc != 0) {
ll_intent_release(&oit);
GOTO(out, rc);
rc = ll_inode_revalidate_fini(inode, rc);
RETURN(rc);
}
-
- rc = ll_prep_inode(sbi->ll_osc_exp, &inode, req, 0, NULL);
+
+ rc = ll_prep_inode(sbi->ll_osc_exp, &inode, req, REPLY_REC_OFF,
+ NULL);
if (rc)
GOTO(out, rc);
}
GOTO(out_osc, err);
}
- err = mdc_req2lustre_md(request, 0, sbi->ll_osc_exp, &md);
+ err = mdc_req2lustre_md(request, REPLY_REC_OFF, sbi->ll_osc_exp, &md);
if (err) {
CERROR("failed to understand root inode md: rc = %d\n",err);
ptlrpc_req_finished (request);
RETURN(rc);
}
- rc = mdc_req2lustre_md(request, 0, sbi->ll_osc_exp, &md);
+ rc = mdc_req2lustre_md(request, REPLY_REC_OFF, sbi->ll_osc_exp,
+ &md);
if (rc) {
ptlrpc_req_finished(request);
RETURN(rc);
RETURN(-abs(rc));
}
- body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
+ body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*body));
if (body->flags & S_APPEND)
flags |= EXT3_APPEND_FL;
if (body->flags & S_NOATIME)
flags |= EXT3_NOATIME_FL;
- ptlrpc_req_finished (req);
+ ptlrpc_req_finished(req);
RETURN(put_user(flags, (int *)arg));
}
return ERR_PTR(rc);
}
- rc = ll_prep_inode(sbi->ll_osc_exp, &inode, req, 0, sb);
+ rc = ll_prep_inode(sbi->ll_osc_exp, &inode, req, REPLY_REC_OFF, sb);
if (rc) {
ptlrpc_req_finished(req);
return ERR_PTR(rc);
CERROR("failure %d inode %lu get parent\n", rc, dir->i_ino);
return ERR_PTR(rc);
}
- body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof (*body));
LASSERT((body->valid & OBD_MD_FLGENER) && (body->valid & OBD_MD_FLID));
if (rc < 0)
GOTO(out, retval = ERR_PTR(rc));
- rc = lookup_it_finish(req, 1, it, &icbd);
+ rc = lookup_it_finish(req, DLM_REPLY_REC_OFF, it, &icbd);
if (rc != 0) {
ll_intent_release(it);
GOTO(out, retval = ERR_PTR(rc));
LASSERT(it_disposition(it, DISP_ENQ_CREATE_REF));
request = it->d.lustre.it_data;
it_clear_disposition(it, DISP_ENQ_CREATE_REF);
- rc = ll_prep_inode(sbi->ll_osc_exp, &inode, request, 1, dir->i_sb);
+ rc = ll_prep_inode(sbi->ll_osc_exp, &inode, request, DLM_REPLY_REC_OFF,
+ dir->i_sb);
if (rc)
GOTO(out, inode = ERR_PTR(rc));
if (rc)
RETURN(rc);
- mdc_store_inode_generation(request, MDS_REQ_INTENT_REC_OFF, 1);
+ mdc_store_inode_generation(request, DLM_INTENT_REC_OFF,
+ DLM_REPLY_REC_OFF);
inode = ll_create_node(dir, dentry->d_name.name, dentry->d_name.len,
NULL, 0, mode, 0, it);
if (IS_ERR(inode)) {
current->cap_effective, rdev, &request);
if (err)
break;
- ll_update_times(request, 0, dir);
+ ll_update_times(request, REPLY_REC_OFF, dir);
if (dchild) {
- err = ll_prep_inode(sbi->ll_osc_exp, &inode, request, 0,
- dchild->d_sb);
+ err = ll_prep_inode(sbi->ll_osc_exp, &inode, request,
+ REPLY_REC_OFF, dchild->d_sb);
if (err)
break;
static int ll_create_nd(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd)
{
- if (!nd || !nd->intent.d.lustre.it_disposition) {
+ if (!nd || !nd->intent.d.lustre.it_disposition)
/* No saved request? Just mknod the file */
return ll_mknod_generic(dir, &dentry->d_name, mode, 0, dentry);
- }
return ll_create_it(dir, dentry, mode, &nd->intent);
}
current->fsuid, current->fsgid, current->cap_effective,
0, &request);
if (err == 0)
- ll_update_times(request, 0, dir);
+ ll_update_times(request, REPLY_REC_OFF, dir);
ptlrpc_req_finished(request);
RETURN(err);
name->len, 0);
err = mdc_link(sbi->ll_mdc_exp, &op_data, &request);
if (err == 0)
- ll_update_times(request, 0, dir);
+ ll_update_times(request, REPLY_REC_OFF, dir);
ptlrpc_req_finished(request);
if (err)
GOTO(out, err);
- ll_update_times(request, 0, dir);
+ ll_update_times(request, REPLY_REC_OFF, dir);
if (dchild) {
- err = ll_prep_inode(sbi->ll_osc_exp, &inode, request, 0,
- dchild->d_sb);
+ err = ll_prep_inode(sbi->ll_osc_exp, &inode, request,
+ REPLY_REC_OFF, dchild->d_sb);
if (err)
GOTO(out, err);
d_instantiate(dchild, inode);
name->len, S_IFDIR);
rc = mdc_unlink(ll_i2sbi(dir)->ll_mdc_exp, &op_data, &request);
if (rc == 0)
- ll_update_times(request, 0, dir);
+ ll_update_times(request, REPLY_REC_OFF, dir);
ptlrpc_req_finished(request);
RETURN(rc);
}
ENTRY;
/* req is swabbed so this is safe */
- body = lustre_msg_buf(request->rq_repmsg, 0, sizeof(*body));
+ body = lustre_msg_buf(request->rq_repmsg, REPLY_REC_OFF, sizeof(*body));
if (!(body->valid & OBD_MD_FLEASIZE))
RETURN(0);
* to this file. Use this EA to unlink the objects on the OST.
* It's opaque so we don't swab here; we leave it to obd_unpackmd() to
* check it is complete and sensible. */
- eadata = lustre_swab_repbuf(request, 1, body->eadatasize, NULL);
+ eadata = lustre_swab_repbuf(request, REPLY_REC_OFF + 1,
+ body->eadatasize, NULL);
LASSERT(eadata != NULL);
if (eadata == NULL) {
CERROR("Can't unpack MDS EA data\n");
if (body->valid & OBD_MD_FLCOOKIE) {
oa->o_valid |= OBD_MD_FLCOOKIE;
oti.oti_logcookies =
- lustre_msg_buf(request->rq_repmsg, 2,
+ lustre_msg_buf(request->rq_repmsg, REPLY_REC_OFF + 2,
sizeof(struct llog_cookie) *
lsm->lsm_stripe_count);
if (oti.oti_logcookies == NULL) {
if (rc)
GOTO(out, rc);
- ll_update_times(request, 0, dir);
+ ll_update_times(request, REPLY_REC_OFF, dir);
rc = ll_objects_destroy(request, dir);
out:
src_name->name, src_name->len,
tgt_name->name, tgt_name->len, &request);
if (!err) {
- ll_update_times(request, 0, src);
- ll_update_times(request, 0, tgt);
+ ll_update_times(request, REPLY_REC_OFF, src);
+ ll_update_times(request, REPLY_REC_OFF, tgt);
err = ll_objects_destroy(request, src);
}
ll_unregister_cache(&ll_cache_definition);
ll_destroy_inodecache();
+
rc = kmem_cache_destroy(ll_file_data_slab);
LASSERTF(rc == 0, "couldn't destroy ll_file_data slab\n");
if (ll_async_page_slab) {
GOTO (failed, rc);
}
- body = lustre_msg_buf ((*request)->rq_repmsg, 0, sizeof (*body));
- LASSERT (body != NULL);
- LASSERT_REPSWABBED (*request, 0);
+ body = lustre_msg_buf((*request)->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*body));
+ LASSERT(body != NULL);
+ LASSERT_REPSWABBED(*request, REPLY_REC_OFF);
if ((body->valid & OBD_MD_LINKNAME) == 0) {
- CERROR ("OBD_MD_LINKNAME not set on reply\n");
- GOTO (failed, rc = -EPROTO);
+ CERROR("OBD_MD_LINKNAME not set on reply\n");
+ GOTO(failed, rc = -EPROTO);
}
- LASSERT (symlen != 0);
+ LASSERT(symlen != 0);
if (body->eadatasize != symlen) {
- CERROR ("inode %lu: symlink length %d not expected %d\n",
+ CERROR("inode %lu: symlink length %d not expected %d\n",
inode->i_ino, body->eadatasize - 1, symlen - 1);
- GOTO (failed, rc = -EPROTO);
+ GOTO(failed, rc = -EPROTO);
}
- *symname = lustre_msg_buf ((*request)->rq_repmsg, 1, symlen);
+ *symname = lustre_msg_buf((*request)->rq_repmsg, REPLY_REC_OFF + 1,
+ symlen);
if (*symname == NULL ||
strnlen (*symname, symlen) != symlen - 1) {
/* not full/NULL terminated */
- CERROR ("inode %lu: symlink not NULL terminated string"
+ CERROR("inode %lu: symlink not NULL terminated string"
"of length %d\n", inode->i_ino, symlen - 1);
- GOTO (failed, rc = -EPROTO);
+ GOTO(failed, rc = -EPROTO);
}
OBD_ALLOC(lli->lli_symlink_name, symlen);
do_getxattr:
ll_inode2fid(&fid, inode);
- rc = mdc_getxattr(sbi->ll_mdc_exp, &fid, valid, name, NULL, 0,
- size, &req);
+ rc = mdc_getxattr(sbi->ll_mdc_exp, &fid, valid, name, NULL, 0, size,
+ &req);
if (rc) {
if (rc == -EOPNOTSUPP && xattr_type == XATTR_USER_T) {
LCONSOLE_INFO("Disabling user_xattr feature because "
RETURN(rc);
}
- body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
+ body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*body));
LASSERT(body);
- LASSERT_REPSWABBED(req, 0);
+ LASSERT_REPSWABBED(req, REPLY_REC_OFF);
/* only detect the xattr size */
if (size == 0)
GOTO(out, rc = -ERANGE);
}
- if (req->rq_repmsg->bufcount < 2) {
- CERROR("reply bufcount %u\n", req->rq_repmsg->bufcount);
+ if (lustre_msg_bufcount(req->rq_repmsg) < 3) {
+ CERROR("reply bufcount %u\n",
+ lustre_msg_bufcount(req->rq_repmsg));
GOTO(out, rc = -EFAULT);
}
/* do not need swab xattr data */
- LASSERT_REPSWAB(req, 1);
- xdata = lustre_msg_buf(req->rq_repmsg, 1, body->eadatasize);
+ LASSERT_REPSWAB(req, REPLY_REC_OFF + 1);
+ xdata = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF + 1,
+ body->eadatasize);
if (!xdata) {
CERROR("can't extract: %u : %u\n", body->eadatasize,
- lustre_msg_buflen(req->rq_repmsg, 1));
+ lustre_msg_buflen(req->rq_repmsg, REPLY_REC_OFF + 1));
GOTO(out, rc = -EFAULT);
}
void mdc_pack_req_body(struct ptlrpc_request *req, int offset,
__u64 valid, struct ll_fid *fid, int ea_size);
void mdc_pack_rep_body(struct ptlrpc_request *);
-void mdc_readdir_pack(struct ptlrpc_request *req, int pos, __u64 offset,
- __u32 size, struct ll_fid *mdc_fid);
-void mdc_getattr_pack(struct ptlrpc_request *req, int valid, int offset,
+void mdc_readdir_pack(struct ptlrpc_request *req, int offset, __u64 pg_off,
+ __u32 size, struct ll_fid *mdc_fid);
+void mdc_getattr_pack(struct ptlrpc_request *req, int offset, int valid,
int flags, struct mdc_op_data *data);
void mdc_setattr_pack(struct ptlrpc_request *req, int offset,
struct mdc_op_data *data,
#endif
#endif
-void mdc_readdir_pack(struct ptlrpc_request *req, int pos, __u64 offset,
- __u32 size, struct ll_fid *mdc_fid)
+void mdc_readdir_pack(struct ptlrpc_request *req, int offset, __u64 pg_off,
+ __u32 size, struct ll_fid *fid)
{
struct mds_body *b;
- b = lustre_msg_buf(req->rq_reqmsg, pos, sizeof (*b));
+ b = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*b));
b->fsuid = current->fsuid;
b->fsgid = current->fsgid;
b->capability = current->cap_effective;
- b->fid1 = *mdc_fid;
- b->size = offset; /* !! */
+ b->fid1 = *fid;
+ b->size = pg_off; /* !! */
b->suppgid = -1;
b->nlink = size; /* !! */
}
}
void mdc_setattr_pack(struct ptlrpc_request *req, int offset,
- struct mdc_op_data *data, struct iattr *iattr,
- void *ea, int ealen, void *ea2, int ea2len)
+ struct mdc_op_data *data, struct iattr *iattr, void *ea,
+ int ealen, void *ea2, int ea2len)
{
struct mds_rec_setattr *rec = lustre_msg_buf(req->rq_reqmsg, offset,
- sizeof (*rec));
+ sizeof(*rec));
rec->sa_opcode = REINT_SETATTR;
rec->sa_fsuid = current->fsuid;
rec->sa_fsgid = current->fsgid;
int flags, struct mdc_op_data *data)
{
struct mds_body *b;
- b = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*b));
+ b = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*b));
b->fsuid = current->fsuid;
b->fsgid = current->fsgid;
{
struct mds_body *body;
- body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body));
+ body = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*body));
mdc_pack_fid(&body->fid1, oa->o_id, 0, oa->o_mode);
memcpy(&body->handle, &och->och_fh, sizeof(body->handle));
* but this is incredibly unlikely, and questionable whether the client
* could do MDS recovery under OOM anyways... */
static void mdc_realloc_openmsg(struct ptlrpc_request *req,
- struct mds_body *body, int size[5])
+ struct mds_body *body, int size[6])
{
int new_size, old_size;
struct lustre_msg *new_msg;
/* save old size */
- old_size = lustre_msg_size(5, size);
+ old_size = lustre_msg_size(lustre_request_magic(req), 6, size);
- size[4] = body->eadatasize;
- new_size = lustre_msg_size(5, size);
+ size[DLM_INTENT_REC_OFF + 2] = body->eadatasize;
+ new_size = lustre_msg_size(lustre_request_magic(req), 6, size);
OBD_ALLOC(new_msg, new_size);
if (new_msg != NULL) {
struct lustre_msg *old_msg = req->rq_reqmsg;
DEBUG_REQ(D_INFO, req, "replace reqmsg for larger EA %u\n",
body->eadatasize);
memcpy(new_msg, old_msg, old_size);
- new_msg->buflens[4] = body->eadatasize;
+ lustre_msg_set_buflen(new_msg, DLM_INTENT_REC_OFF + 2,
+ body->eadatasize);
spin_lock_irqsave(&req->rq_lock, irqflags);
req->rq_reqmsg = new_msg;
ldlm_policy_data_t policy = { .l_inodebits = { MDS_INODELOCK_LOOKUP } };
struct ldlm_request *lockreq;
struct ldlm_intent *lit;
- int size[6] = {[MDS_REQ_INTENT_LOCKREQ_OFF] = sizeof(*lockreq),
- [MDS_REQ_INTENT_IT_OFF] = sizeof(*lit) };
- struct ldlm_reply *dlm_rep;
- int repsize[4] = {sizeof(*dlm_rep),
- sizeof(struct mds_body),
- obddev->u.cli.cl_max_mds_easize};
+ struct ldlm_reply *lockrep;
+ int size[7] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+ [DLM_LOCKREQ_OFF] = sizeof(*lockreq),
+ [DLM_INTENT_IT_OFF] = sizeof(*lit) };
+ int repsize[5] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+ [DLM_LOCKREPLY_OFF] = sizeof(*lockrep),
+ [DLM_REPLY_REC_OFF] = sizeof(struct mds_body),
+ [DLM_REPLY_REC_OFF+1] = obddev->u.cli.
+ cl_max_mds_easize };
+ int flags = extra_lock_flags | LDLM_FL_HAS_INTENT;
+ int repbufcnt = 4, rc;
void *eadata;
unsigned long irqflags;
- int repbufcnt = 3, req_buffers = 2;
- int rc, flags = extra_lock_flags | LDLM_FL_HAS_INTENT;
ENTRY;
LASSERTF(lock_type == LDLM_IBITS, "lock type %d\n", lock_type);
if (it->it_op & IT_OPEN) {
it->it_create_mode |= S_IFREG;
- size[req_buffers++] = sizeof(struct mds_rec_create);
- size[req_buffers++] = data->namelen + 1;
+ size[DLM_INTENT_REC_OFF] = sizeof(struct mds_rec_create);
+ size[DLM_INTENT_REC_OFF + 1] = data->namelen + 1;
/* As an optimization, we allocate an RPC request buffer for
* at least a default-sized LOV EA even if we aren't sending
* one. We grow the whole request to the next power-of-two
* size since we get that much from a slab allocation anyways.
* This avoids an allocation below in the common case where
* we need to save a default-sized LOV EA for open replay. */
- size[req_buffers++] = max(lmmsize,
+ size[DLM_INTENT_REC_OFF + 2] = max(lmmsize,
obddev->u.cli.cl_default_mds_easize);
- rc = lustre_msg_size(req_buffers, size);
+ rc = lustre_msg_size(class_exp2cliimp(exp)->imp_msg_magic, 6,
+ size);
if (rc & (rc - 1))
- size[req_buffers - 1] = min(size[req_buffers - 1] +
- round_up(rc) - rc,
- obddev->u.cli.cl_max_mds_easize);
+ size[DLM_INTENT_REC_OFF + 2] =
+ min(size[DLM_INTENT_REC_OFF+2]+round_up(rc)-rc,
+ obddev->u.cli.cl_max_mds_easize);
if (it->it_flags & O_JOIN_FILE) {
__u64 head_size = *(__u32*)cb_data;
/* join is like an unlink of the tail */
policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
- size[req_buffers++] = sizeof(struct mds_rec_join);
+ size[DLM_INTENT_REC_OFF + 3] =
+ sizeof(struct mds_rec_join);
req = ptlrpc_prep_req(class_exp2cliimp(exp),
LUSTRE_DLM_VERSION, LDLM_ENQUEUE,
- req_buffers, size, NULL);
+ 7, size, NULL);
/* when joining file, cb_data and lmm args together
* indicate the head file size*/
- mdc_join_pack(req, req_buffers - 1, data,
+ mdc_join_pack(req, DLM_INTENT_REC_OFF + 3, data,
(head_size << 32) | tsize);
cb_data = NULL;
lmm = NULL;
- } else
+ } else {
req = ptlrpc_prep_req(class_exp2cliimp(exp),
LUSTRE_DLM_VERSION, LDLM_ENQUEUE,
- req_buffers, size, NULL);
+ 6, size, NULL);
+ }
+
if (!req)
RETURN(-ENOMEM);
spin_unlock_irqrestore (&req->rq_lock, irqflags);
/* pack the intent */
- lit = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_INTENT_IT_OFF,
- sizeof (*lit));
+ lit = lustre_msg_buf(req->rq_reqmsg, DLM_INTENT_IT_OFF,
+ sizeof(*lit));
lit->opc = (__u64)it->it_op;
/* pack the intended request */
- mdc_open_pack(req, MDS_REQ_INTENT_REC_OFF, data,
- it->it_create_mode, 0,
- it->it_flags, lmm, lmmsize);
+ mdc_open_pack(req, DLM_INTENT_REC_OFF, data, it->it_create_mode,
+ 0, it->it_flags, lmm, lmmsize);
repsize[repbufcnt++] = LUSTRE_POSIX_ACL_MAX_SIZE;
} else if (it->it_op & IT_UNLINK) {
- size[req_buffers++] = sizeof(struct mds_rec_unlink);
- size[req_buffers++] = data->namelen + 1;
+ size[DLM_INTENT_REC_OFF] = sizeof(struct mds_rec_unlink);
+ size[DLM_INTENT_REC_OFF + 1] = data->namelen + 1;
policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_DLM_VERSION,
- LDLM_ENQUEUE, req_buffers, size, NULL);
+ LDLM_ENQUEUE, 5, size, NULL);
if (!req)
RETURN(-ENOMEM);
/* pack the intent */
- lit = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_INTENT_IT_OFF,
- sizeof (*lit));
+ lit = lustre_msg_buf(req->rq_reqmsg, DLM_INTENT_IT_OFF,
+ sizeof(*lit));
lit->opc = (__u64)it->it_op;
/* pack the intended request */
- mdc_unlink_pack(req, MDS_REQ_INTENT_REC_OFF, data);
- /* get ready for the reply */
+ mdc_unlink_pack(req, DLM_INTENT_REC_OFF, data);
+
repsize[repbufcnt++] = obddev->u.cli.cl_max_mds_cookiesize;
} else if (it->it_op & (IT_GETATTR | IT_LOOKUP)) {
obd_valid valid = OBD_MD_FLGETATTR | OBD_MD_FLEASIZE |
OBD_MD_FLACL | OBD_MD_FLMODEASIZE |
OBD_MD_FLDIREA;
- size[req_buffers++] = sizeof(struct mds_body);
- size[req_buffers++] = data->namelen + 1;
+ size[DLM_INTENT_REC_OFF] = sizeof(struct mds_body);
+ size[DLM_INTENT_REC_OFF + 1] = data->namelen + 1;
if (it->it_op & IT_GETATTR)
policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_DLM_VERSION,
- LDLM_ENQUEUE, req_buffers, size, NULL);
+ LDLM_ENQUEUE, 5, size, NULL);
if (!req)
RETURN(-ENOMEM);
/* pack the intent */
- lit = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_INTENT_IT_OFF,
- sizeof (*lit));
+ lit = lustre_msg_buf(req->rq_reqmsg, DLM_INTENT_IT_OFF,
+ sizeof(*lit));
lit->opc = (__u64)it->it_op;
/* pack the intended request */
- mdc_getattr_pack(req, MDS_REQ_INTENT_REC_OFF, valid,
+ mdc_getattr_pack(req, DLM_INTENT_REC_OFF, valid,
it->it_flags, data);
- /* get ready for the reply */
+
repsize[repbufcnt++] = LUSTRE_POSIX_ACL_MAX_SIZE;
} else if (it->it_op == IT_READDIR) {
policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_DLM_VERSION,
- LDLM_ENQUEUE, 1, size, NULL);
+ LDLM_ENQUEUE, 2, size, NULL);
if (!req)
RETURN(-ENOMEM);
- /* get ready for the reply */
- repbufcnt = 1;
+ repbufcnt = 2;
} else {
LBUG();
RETURN(-EINVAL);
}
/* get ready for the reply */
- req->rq_replen = lustre_msg_size(repbufcnt, repsize);
+ ptlrpc_req_set_repsize(req, repbufcnt, repsize);
mdc_get_rpc_lock(obddev->u.cli.cl_rpc_lock, it);
rc = ldlm_cli_enqueue(exp, req, obddev->obd_namespace, res_id,
/* Similarly, if we're going to replay this request, we don't want to
* actually get a lock, just perform the intent. */
if (req->rq_transno || req->rq_replay) {
- lockreq = lustre_msg_buf(req->rq_reqmsg,
- MDS_REQ_INTENT_LOCKREQ_OFF,
+ lockreq = lustre_msg_buf(req->rq_reqmsg, DLM_LOCKREQ_OFF,
sizeof(*lockreq));
lockreq->lock_flags |= LDLM_FL_INTENT_ONLY;
}
LDLM_LOCK_PUT(lock);
}
- dlm_rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*dlm_rep));
- LASSERT(dlm_rep != NULL); /* checked by ldlm_cli_enqueue() */
- LASSERT_REPSWABBED(req, 0); /* swabbed by ldlm_cli_enqueue() */
+ lockrep = lustre_msg_buf(req->rq_repmsg, DLM_LOCKREPLY_OFF,
+ sizeof(*lockrep));
+ LASSERT(lockrep != NULL); /* checked by ldlm_cli_enqueue() */
+ LASSERT_REPSWABBED(req, DLM_LOCKREPLY_OFF); /* swabbed by ldlm_cli_enqueue() */
- it->d.lustre.it_disposition = (int) dlm_rep->lock_policy_res1;
- it->d.lustre.it_status = (int) dlm_rep->lock_policy_res2;
+ it->d.lustre.it_disposition = (int)lockrep->lock_policy_res1;
+ it->d.lustre.it_status = (int)lockrep->lock_policy_res2;
it->d.lustre.it_lock_mode = lock_mode;
it->d.lustre.it_data = req;
it->it_op,it->d.lustre.it_disposition,it->d.lustre.it_status);
/* We know what to expect, so we do any byte flipping required here */
- LASSERT(repbufcnt == 4 || repbufcnt == 1);
- if (repbufcnt == 4) {
+ LASSERT(repbufcnt == 5 || repbufcnt == 2);
+ if (repbufcnt == 5) {
struct mds_body *body;
- body = lustre_swab_repbuf(req, 1, sizeof (*body),
- lustre_swab_mds_body);
+ body = lustre_swab_repbuf(req, DLM_REPLY_REC_OFF, sizeof(*body),
+ lustre_swab_mds_body);
if (body == NULL) {
CERROR ("Can't swab mds_body\n");
RETURN (-EPROTO);
if ((body->valid & OBD_MD_FLEASIZE) != 0) {
/* The eadata is opaque; just check that it is there.
* Eventually, obd_unpackmd() will check the contents */
- eadata = lustre_swab_repbuf(req, 2, body->eadatasize,
- NULL);
+ eadata = lustre_swab_repbuf(req, DLM_REPLY_REC_OFF + 1,
+ body->eadatasize, NULL);
if (eadata == NULL) {
CERROR ("Missing/short eadata\n");
RETURN (-EPROTO);
* large enough request buffer above we need to
* reallocate it here to hold the actual LOV EA. */
if (it->it_op & IT_OPEN) {
- int pos = MDS_REQ_INTENT_REC_OFF + 2;
+ int offset = DLM_INTENT_REC_OFF + 2;
- if (req->rq_reqmsg->buflens[pos] <
+ if (lustre_msg_buflen(req->rq_reqmsg, offset) <
body->eadatasize)
mdc_realloc_openmsg(req, body, size);
- lmm = lustre_msg_buf(req->rq_reqmsg, pos,
+ lmm = lustre_msg_buf(req->rq_reqmsg, offset,
body->eadatasize);
if (lmm)
memcpy(lmm, eadata, body->eadatasize);
if (rc)
RETURN(rc);
- mds_body = lustre_msg_buf(request->rq_repmsg, 1, sizeof(*mds_body));
+ mds_body = lustre_msg_buf(request->rq_repmsg, DLM_REPLY_REC_OFF,
+ sizeof(*mds_body));
LASSERT(mds_body != NULL); /* mdc_enqueue checked */
LASSERT_REPSWABBED(request, 1); /* mdc_enqueue swabbed */
mdc_put_rpc_lock(rpc_lock, NULL);
if (rc)
CDEBUG(D_INFO, "error in handling %d\n", rc);
- else if (!lustre_swab_repbuf(request, 0, sizeof(struct mds_body),
+ else if (!lustre_swab_repbuf(request, REPLY_REC_OFF,
+ sizeof(struct mds_body),
lustre_swab_mds_body)) {
CERROR ("Can't unpack mds_body\n");
rc = -EPROTO;
struct mds_rec_setattr *rec;
struct mdc_rpc_lock *rpc_lock;
struct obd_device *obd = exp->exp_obd;
- int size[] = { sizeof(*rec), ealen, ea2len};
- int rc, bufcount = 1;
+ int size[4] = { sizeof(struct ptlrpc_body),
+ sizeof(*rec), ealen, ea2len };
+ int bufcount = 2, rc;
ENTRY;
LASSERT(iattr != NULL);
if (iattr->ia_valid & (ATTR_MTIME | ATTR_CTIME))
CDEBUG(D_INODE, "setting mtime %lu, ctime %lu\n",
LTIME_S(iattr->ia_mtime), LTIME_S(iattr->ia_ctime));
- mdc_setattr_pack(req, MDS_REQ_REC_OFF, data, iattr, ea, ealen, ea2, ea2len);
+ mdc_setattr_pack(req, REQ_REC_OFF, data, iattr, ea, ealen, ea2, ea2len);
- size[0] = sizeof(struct mds_body);
- req->rq_replen = lustre_msg_size(1, size);
+ size[REPLY_REC_OFF] = sizeof(struct mds_body);
+ ptlrpc_req_set_repsize(req, 2, size);
rc = mdc_reint(req, rpc_lock, LUSTRE_IMP_FULL);
*request = req;
{
struct obd_device *obd = exp->exp_obd;
struct ptlrpc_request *req;
- int size[] = { sizeof(struct mds_rec_create), op_data->namelen + 1, 0};
- int rc, level, bufcount = 2;
+ int level, bufcount = 3, rc;
+ int size[4] = { sizeof(struct ptlrpc_body),
+ sizeof(struct mds_rec_create),
+ op_data->namelen + 1 };
ENTRY;
if (data && datalen) {
/* mdc_create_pack fills msg->bufs[1] with name
* and msg->bufs[2] with tgt, for symlinks or lov MD data */
- mdc_create_pack(req, MDS_REQ_REC_OFF, op_data, data, datalen, mode,
- uid, gid, cap_effective, rdev);
+ mdc_create_pack(req, REQ_REC_OFF, op_data, data, datalen, mode, uid,
+ gid, cap_effective, rdev);
- size[0] = sizeof(struct mds_body);
- req->rq_replen = lustre_msg_size(1, size);
+ size[REPLY_REC_OFF] = sizeof(struct mds_body);
+ ptlrpc_req_set_repsize(req, 2, size);
level = LUSTRE_IMP_FULL;
resend:
}
if (!rc)
- mdc_store_inode_generation(req, 0, 0);
+ mdc_store_inode_generation(req, REQ_REC_OFF, REPLY_REC_OFF);
*request = req;
RETURN(rc);
{
struct obd_device *obd = class_exp2obd(exp);
struct ptlrpc_request *req = *request;
- int rc, size[] = { sizeof(struct mds_rec_unlink), data->namelen + 1, 0};
+ int size[4] = { sizeof(struct ptlrpc_body),
+ sizeof(struct mds_rec_unlink),
+ data->namelen + 1 };
+ int rc;
ENTRY;
LASSERT(req == NULL);
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
- MDS_REINT, 2, size, NULL);
+ MDS_REINT, 3, size, NULL);
if (req == NULL)
RETURN(-ENOMEM);
*request = req;
- size[0] = sizeof(struct mds_body);
- size[1] = obd->u.cli.cl_max_mds_easize;
- size[2] = obd->u.cli.cl_max_mds_cookiesize;
- req->rq_replen = lustre_msg_size(3, size);
+ size[REPLY_REC_OFF] = sizeof(struct mds_body);
+ size[REPLY_REC_OFF + 1] = obd->u.cli.cl_max_mds_easize;
+ size[REPLY_REC_OFF + 2] = obd->u.cli.cl_max_mds_cookiesize;
+ ptlrpc_req_set_repsize(req, 4, size);
- mdc_unlink_pack(req, MDS_REQ_REC_OFF, data);
+ mdc_unlink_pack(req, REQ_REC_OFF, data);
rc = mdc_reint(req, obd->u.cli.cl_rpc_lock, LUSTRE_IMP_FULL);
if (rc == -ERESTARTSYS)
{
struct obd_device *obd = exp->exp_obd;
struct ptlrpc_request *req;
- int rc, size[] = { sizeof(struct mds_rec_link), data->namelen + 1};
+ int size[3] = { sizeof(struct ptlrpc_body),
+ sizeof(struct mds_rec_link),
+ data->namelen + 1 };
+ int rc;
ENTRY;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
- MDS_REINT, 2, size, NULL);
+ MDS_REINT, 3, size, NULL);
if (req == NULL)
RETURN(-ENOMEM);
- mdc_link_pack(req, MDS_REQ_REC_OFF, data);
+ mdc_link_pack(req, REQ_REC_OFF, data);
- size[0] = sizeof(struct mds_body);
- req->rq_replen = lustre_msg_size(1, size);
+ size[REPLY_REC_OFF] = sizeof(struct mds_body);
+ ptlrpc_req_set_repsize(req, 2, size);
rc = mdc_reint(req, obd->u.cli.cl_rpc_lock, LUSTRE_IMP_FULL);
*request = req;
{
struct obd_device *obd = exp->exp_obd;
struct ptlrpc_request *req;
- int rc, size[] = { sizeof(struct mds_rec_rename), oldlen +1, newlen +1};
+ int size[4] = { sizeof(struct ptlrpc_body),
+ sizeof(struct mds_rec_rename),
+ oldlen + 1,
+ newlen + 1 };
+ int rc;
ENTRY;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
- MDS_REINT, 3, size, NULL);
+ MDS_REINT, 4, size, NULL);
if (req == NULL)
RETURN(-ENOMEM);
- mdc_rename_pack(req, MDS_REQ_REC_OFF, data, old, oldlen, new, newlen);
+ mdc_rename_pack(req, REQ_REC_OFF, data, old, oldlen, new, newlen);
- size[0] = sizeof(struct mds_body);
- size[1] = obd->u.cli.cl_max_mds_easize;
- size[2] = obd->u.cli.cl_max_mds_cookiesize;
- req->rq_replen = lustre_msg_size(3, size);
+ size[REPLY_REC_OFF] = sizeof(struct mds_body);
+ size[REPLY_REC_OFF + 1] = obd->u.cli.cl_max_mds_easize;
+ size[REPLY_REC_OFF + 2] = obd->u.cli.cl_max_mds_cookiesize;
+ ptlrpc_req_set_repsize(req, 4, size);
rc = mdc_reint(req, obd->u.cli.cl_rpc_lock, LUSTRE_IMP_FULL);
*request = req;
int level, int msg_flags)
{
struct ptlrpc_request *req;
- int rc, size[] = { [MDS_REQ_REC_OFF] = sizeof(struct mds_body) };
+ struct mds_body *body;
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
- req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_GETSTATUS,
- 1, size, NULL);
+ req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_GETSTATUS, 2, size,
+ NULL);
if (!req)
GOTO(out, rc = -ENOMEM);
req->rq_send_state = level;
- req->rq_replen = lustre_msg_size(1, size);
+ ptlrpc_req_set_repsize(req, 2, size);
- mdc_pack_req_body(req, MDS_REQ_REC_OFF, 0, NULL, 0);
- req->rq_reqmsg->flags |= msg_flags;
+ mdc_pack_req_body(req, REQ_REC_OFF, 0, NULL, 0);
+ lustre_msg_add_flags(req->rq_reqmsg, msg_flags);
rc = ptlrpc_queue_wait(req);
if (!rc) {
- struct mds_body *body;
-
- body = lustre_swab_repbuf(req, 0, sizeof(*body),
+ body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
lustre_swab_mds_body);
if (body == NULL) {
CERROR ("Can't extract mds_body\n");
CDEBUG(D_NET, "root ino="LPU64", last_committed="LPU64
", last_xid="LPU64"\n",
- rootfid->id, req->rq_repmsg->last_committed,
- req->rq_repmsg->last_xid);
+ rootfid->id,
+ lustre_msg_get_last_committed(req->rq_repmsg),
+ lustre_msg_get_last_xid(req->rq_repmsg));
}
EXIT;
unsigned int acl_size, struct ptlrpc_request *req)
{
struct mds_body *body;
- void *eadata;
- int rc;
- int size[3] = {sizeof(*body)};
- int bufcount = 1;
+ void *eadata;
+ int size[4] = { sizeof(struct ptlrpc_body), sizeof(*body) };
+ int bufcount = 2, rc;
ENTRY;
/* request message already built */
CDEBUG(D_INODE, "reserved %u bytes for ACL\n", acl_size);
}
- req->rq_replen = lustre_msg_size(bufcount, size);
+ ptlrpc_req_set_repsize(req, bufcount, size);
rc = ptlrpc_queue_wait(req);
if (rc != 0)
RETURN (rc);
- body = lustre_swab_repbuf (req, 0, sizeof (*body),
- lustre_swab_mds_body);
+ body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
+ lustre_swab_mds_body);
if (body == NULL) {
CERROR ("Can't unpack mds_body\n");
RETURN (-EPROTO);
CDEBUG(D_NET, "mode: %o\n", body->mode);
- LASSERT_REPSWAB (req, 1);
+ LASSERT_REPSWAB(req, REPLY_REC_OFF + 1);
if (body->eadatasize != 0) {
/* reply indicates presence of eadata; check it's there... */
- eadata = lustre_msg_buf (req->rq_repmsg, 1, body->eadatasize);
+ eadata = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF + 1,
+ body->eadatasize);
if (eadata == NULL) {
CERROR ("Missing/short eadata\n");
RETURN (-EPROTO);
struct ptlrpc_request **request)
{
struct ptlrpc_request *req;
- struct mds_body *body;
- int size = sizeof(*body);
+ int size[2] = { sizeof(struct ptlrpc_body), sizeof(struct mds_body) };
int acl_size = 0, rc;
ENTRY;
* to do the lookup in the first place.
*/
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
- MDS_GETATTR, 1, &size, NULL);
+ MDS_GETATTR, 2, size, NULL);
if (!req)
GOTO(out, rc = -ENOMEM);
- mdc_pack_req_body(req, MDS_REQ_REC_OFF, valid, fid, ea_size);
+ mdc_pack_req_body(req, REQ_REC_OFF, valid, fid, ea_size);
/* currently only root inode will call us with FLACL */
if (valid & OBD_MD_FLACL)
int mdc_getattr_name(struct obd_export *exp, struct ll_fid *fid,
const char *filename, int namelen, unsigned long valid,
- unsigned int ea_len, struct ptlrpc_request **request)
+ unsigned int ea_size, struct ptlrpc_request **request)
{
struct ptlrpc_request *req;
- int rc, size[] = { sizeof(struct mds_body), namelen };
+ struct mds_body *body;
+ int rc, size[3] = { sizeof(struct ptlrpc_body), sizeof(*body), namelen};
ENTRY;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
- MDS_GETATTR_NAME, 2, size, NULL);
+ MDS_GETATTR_NAME, 3, size, NULL);
if (!req)
GOTO(out, rc = -ENOMEM);
- mdc_pack_req_body(req, MDS_REQ_REC_OFF, valid, fid, ea_len);
+ mdc_pack_req_body(req, REQ_REC_OFF, valid, fid, ea_size);
- LASSERT (strnlen (filename, namelen) == namelen - 1);
- memcpy(lustre_msg_buf(req->rq_reqmsg, 1, namelen), filename, namelen);
+ LASSERT(strnlen(filename, namelen) == namelen - 1);
+ memcpy(lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 1, namelen),
+ filename, namelen);
- rc = mdc_getattr_common(exp, ea_len, 0, req);
+ rc = mdc_getattr_common(exp, ea_size, 0, req);
if (rc != 0) {
ptlrpc_req_finished (req);
req = NULL;
{
struct ptlrpc_request *req;
struct mds_body *body;
- int size[3] = {sizeof(*body)}, bufcnt = 1;
- int xattr_namelen = 0, rc;
+ int size[4] = { sizeof(struct ptlrpc_body), sizeof(*body) };
+ int rc, xattr_namelen = 0, bufcnt = 2, offset;
void *tmp;
ENTRY;
size[bufcnt++] = input_size;
}
- req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION, opcode,
- bufcnt, size, NULL);
+ req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
+ opcode, bufcnt, size, NULL);
if (!req)
GOTO(out, rc = -ENOMEM);
/* request data */
- body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof(*body));
- mdc_pack_req_body(req, MDS_REQ_REC_OFF, valid, fid, output_size);
+ mdc_pack_req_body(req, REQ_REC_OFF, valid, fid, output_size);
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
body->flags = flags;
+ offset = REQ_REC_OFF + 1;
+
if (xattr_name) {
- tmp = lustre_msg_buf(req->rq_reqmsg, 1, xattr_namelen);
+ tmp = lustre_msg_buf(req->rq_reqmsg, offset++, xattr_namelen);
memcpy(tmp, xattr_name, xattr_namelen);
}
if (input_size) {
- tmp = lustre_msg_buf(req->rq_reqmsg, bufcnt - 1, input_size);
+ tmp = lustre_msg_buf(req->rq_reqmsg, offset++, input_size);
memcpy(tmp, input, input_size);
}
/* reply buffers */
if (opcode == MDS_GETXATTR) {
- size[0] = sizeof(*body);
- bufcnt = 1;
+ bufcnt = 2;
} else {
- bufcnt = 0;
+ bufcnt = 1;
}
if (output_size)
size[bufcnt++] = output_size;
- req->rq_replen = lustre_msg_size(bufcnt, size);
+ ptlrpc_req_set_repsize(req, bufcnt, size);
/* make rpc */
if (opcode == MDS_SETXATTR)
GOTO(err_out, rc);
if (opcode == MDS_GETXATTR) {
- body = lustre_swab_repbuf(req, 0, sizeof(*body),
+ body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
lustre_swab_mds_body);
if (body == NULL) {
CERROR ("Can't unpack mds_body\n");
buf = lustre_msg_buf(req->rq_repmsg, offset, body->aclsize);
if (!buf) {
CERROR("aclsize %u, bufcount %u, bufsize %u\n",
- body->aclsize, req->rq_repmsg->bufcount,
- (req->rq_repmsg->bufcount <= offset) ? -1 :
- req->rq_repmsg->buflens[offset]);
+ body->aclsize, lustre_msg_bufcount(req->rq_repmsg),
+ (lustre_msg_bufcount(req->rq_repmsg) <= offset) ?
+ -1 : lustre_msg_buflen(req->rq_repmsg, offset));
return -EPROTO;
}
md->body = lustre_msg_buf(req->rq_repmsg, offset, sizeof (*md->body));
LASSERT (md->body != NULL);
- LASSERT_REPSWABBED (req, offset);
+ LASSERT_REPSWABBED(req, offset);
offset++;
if (md->body->valid & OBD_MD_FLEASIZE) {
lmmsize = md->body->eadatasize;
lmm = lustre_msg_buf(req->rq_repmsg, offset, lmmsize);
LASSERT (lmm != NULL);
- LASSERT_REPSWABBED (req, offset);
+ LASSERT_REPSWABBED(req, offset);
rc = obd_unpackmd(exp, &md->lsm, lmm, lmmsize);
if (rc < 0)
struct mds_body *body;
ENTRY;
- body = lustre_swab_repbuf(req, 1, sizeof(*body), lustre_swab_mds_body);
+ body = lustre_swab_repbuf(req, DLM_REPLY_REC_OFF, sizeof(*body),
+ lustre_swab_mds_body);
LASSERT (body != NULL);
if (mod == NULL) {
close_req = mod->mod_close_req;
if (close_req != NULL) {
struct mds_body *close_body;
- LASSERT(close_req->rq_reqmsg->opc == MDS_CLOSE);
- close_body = lustre_msg_buf(close_req->rq_reqmsg,
- MDS_REQ_REC_OFF,
+ LASSERT(lustre_msg_get_opc(close_req->rq_reqmsg) == MDS_CLOSE);
+ close_body = lustre_msg_buf(close_req->rq_reqmsg, REQ_REC_OFF,
sizeof(*close_body));
if (och != NULL)
LASSERT(!memcmp(&old, &close_body->handle, sizeof old));
{
struct mdc_open_data *mod;
struct mds_rec_create *rec = lustre_msg_buf(open_req->rq_reqmsg,
- MDS_REQ_INTENT_REC_OFF,
+ DLM_INTENT_REC_OFF,
sizeof(*rec));
- struct mds_body *body = lustre_msg_buf(open_req->rq_repmsg, 1,
+ struct mds_body *body = lustre_msg_buf(open_req->rq_repmsg,
+ DLM_REPLY_REC_OFF,
sizeof(*body));
- LASSERT(body != NULL);
/* incoming message in my byte order (it's been swabbed) */
LASSERT(rec != NULL);
+ LASSERT_REPSWABBED(open_req, DLM_REPLY_REC_OFF);
/* outgoing messages always in my byte order */
- LASSERT_REPSWABBED(open_req, 1);
+ LASSERT(body != NULL);
OBD_ALLOC(mod, sizeof(*mod));
if (mod == NULL) {
struct obd_client_handle *och, struct ptlrpc_request **request)
{
struct obd_device *obd = class_exp2obd(exp);
- int size[] = { sizeof(struct mds_body) };
- int rc, repsize[] = { sizeof(struct mds_body),
- obd->u.cli.cl_max_mds_easize,
- obd->u.cli.cl_max_mds_cookiesize};
+ int reqsize[2] = { sizeof(struct ptlrpc_body),
+ sizeof(struct mds_body) };
+ int rc, repsize[4] = { sizeof(struct ptlrpc_body),
+ sizeof(struct mds_body),
+ obd->u.cli.cl_max_mds_easize,
+ obd->u.cli.cl_max_mds_cookiesize };
struct ptlrpc_request *req;
struct mdc_open_data *mod;
ENTRY;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
- MDS_CLOSE, 1, size, NULL);
+ MDS_CLOSE, 2, reqsize, NULL);
if (req == NULL)
GOTO(out, rc = -ENOMEM);
CDEBUG(D_HA, "couldn't find open req; expecting close error\n");
}
- mdc_close_pack(req, MDS_REQ_REC_OFF, oa, oa->o_valid, och);
+ mdc_close_pack(req, REQ_REC_OFF, oa, oa->o_valid, och);
- req->rq_replen = lustre_msg_size(3, repsize);
+ ptlrpc_req_set_repsize(req, 4, repsize);
req->rq_commit_cb = mdc_commit_close;
LASSERT(req->rq_cb_data == NULL);
req->rq_cb_data = mod;
if (rc == 0)
rc = req->rq_status ? req->rq_status : -EIO;
} else if (rc == 0) {
- rc = req->rq_repmsg->status;
- if (req->rq_repmsg->type == PTL_RPC_MSG_ERR) {
+ rc = lustre_msg_get_status(req->rq_repmsg);
+ if (lustre_msg_get_type(req->rq_repmsg) == PTL_RPC_MSG_ERR) {
DEBUG_REQ(D_ERROR, req, "type == PTL_RPC_MSG_ERR, err "
"= %d", rc);
if (rc > 0)
CERROR("Unexpected: can't find mdc_open_data, but the "
"close succeeded. Please tell CFS.\n");
}
- if (!lustre_swab_repbuf(req, 0, sizeof(struct mds_body),
+ if (!lustre_swab_repbuf(req, REPLY_REC_OFF,
+ sizeof(struct mds_body),
lustre_swab_mds_body)) {
CERROR("Error unpacking mds_body\n");
rc = -EPROTO;
{
struct ptlrpc_request *req;
struct mds_body *body;
- int rc, size[] = { [MDS_REQ_REC_OFF] = sizeof(*body) };
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
- MDS_DONE_WRITING, 1, size, NULL);
+ MDS_DONE_WRITING, 2, size, NULL);
if (req == NULL)
RETURN(-ENOMEM);
- body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof(*body));
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
mdc_pack_fid(&body->fid1, obdo->o_id, 0, obdo->o_mode);
body->size = obdo->o_size;
body->blocks = obdo->o_blocks;
body->valid = obdo->o_valid;
// memcpy(&body->handle, &och->och_fh, sizeof(body->handle));
- req->rq_replen = lustre_msg_size(1, size);
+ ptlrpc_req_set_repsize(req, 2, size);
rc = ptlrpc_queue_wait(req);
ptlrpc_req_finished(req);
struct ptlrpc_request *req = NULL;
struct ptlrpc_bulk_desc *desc = NULL;
struct mds_body *body;
- int rc, size[] = { sizeof(*body) };
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
CDEBUG(D_INODE, "inode: "LPU64"\n", fid->id);
- req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_READPAGE,
- 1, size, NULL);
+ req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_READPAGE, 2, size,
+ NULL);
if (req == NULL)
GOTO(out, rc = -ENOMEM);
ptlrpc_prep_bulk_page(desc, page, 0, PAGE_CACHE_SIZE);
- mdc_readdir_pack(req, MDS_REQ_REC_OFF, offset, PAGE_CACHE_SIZE, fid);
+ mdc_readdir_pack(req, REQ_REC_OFF, offset, PAGE_CACHE_SIZE, fid);
- req->rq_replen = lustre_msg_size(1, size);
+ ptlrpc_req_set_repsize(req, 2, size);
rc = ptlrpc_queue_wait(req);
if (rc == 0) {
- body = lustre_swab_repbuf(req, 0, sizeof (*body),
+ body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
lustre_swab_mds_body);
if (body == NULL) {
CERROR("Can't unpack mds_body\n");
}
if (KEY_IS("read-only")) {
struct ptlrpc_request *req;
- int size[2] = {keylen, vallen};
- char *bufs[2] = {key, val};
+ int size[3] = { sizeof(struct ptlrpc_body), keylen, vallen };
+ char *bufs[3] = { NULL, key, val };
if (vallen != sizeof(int))
RETURN(-EINVAL);
~OBD_CONNECT_RDONLY;
}
- req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION,
- MDS_SET_INFO, 2, size, bufs);
+ req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_SET_INFO,
+ 3, size, bufs);
if (req == NULL)
RETURN(-ENOMEM);
- req->rq_replen = lustre_msg_size(0, NULL);
+ ptlrpc_req_set_repsize(req, 1, NULL);
if (set) {
rc = 0;
ptlrpc_set_add_req(set, req);
{
struct ptlrpc_request *req;
struct obd_statfs *msfs;
- int rc, size = sizeof(*msfs);
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*msfs) };
ENTRY;
/* We could possibly pass max_age in the request (as an absolute
* is not so great if request processing is slow, while absolute
* timestamps are not ideal because they need time synchronization. */
req = ptlrpc_prep_req(obd->u.cli.cl_import, LUSTRE_MDS_VERSION,
- MDS_STATFS, 0, NULL, NULL);
+ MDS_STATFS, 1, NULL, NULL);
if (!req)
RETURN(-ENOMEM);
- req->rq_replen = lustre_msg_size(1, &size);
+ ptlrpc_req_set_repsize(req, 2, size);
rc = ptlrpc_queue_wait(req);
if (rc)
GOTO(out, rc);
- msfs = lustre_swab_repbuf(req, 0, sizeof(*msfs),lustre_swab_obd_statfs);
+ msfs = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*msfs),
+ lustre_swab_obd_statfs);
if (msfs == NULL) {
CERROR("Can't unpack obd_statfs\n");
GOTO(out, rc = -EPROTO);
}
- memcpy(osfs, msfs, sizeof (*msfs));
+ memcpy(osfs, msfs, sizeof(*msfs));
EXIT;
out:
ptlrpc_req_finished(req);
{
struct ptlrpc_request *req;
struct mds_body *body;
- int rc, size[] = { [MDS_REQ_REC_OFF] = sizeof(struct mds_body) };
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
- MDS_PIN, 1, size, NULL);
+ MDS_PIN, 2, size, NULL);
if (req == NULL)
RETURN(-ENOMEM);
- body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body));
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
mdc_pack_fid(&body->fid1, ino, gen, type);
body->flags = flag;
- req->rq_replen = lustre_msg_size(1, size);
+ ptlrpc_req_set_repsize(req, 2, size);
mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
rc = ptlrpc_queue_wait(req);
RETURN(rc);
}
- body = lustre_swab_repbuf(req, 0, sizeof(*body), lustre_swab_mds_body);
+ body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
+ lustre_swab_mds_body);
if (body == NULL) {
ptlrpc_req_finished(req);
RETURN(rc);
{
struct ptlrpc_request *req;
struct mds_body *body;
- int rc, size[] = { [MDS_REQ_REC_OFF] = sizeof(struct mds_body) };
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
if (handle->och_magic != OBD_CLIENT_HANDLE_MAGIC)
RETURN(0);
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
- MDS_CLOSE, 1, size, NULL);
+ MDS_CLOSE, 2, size, NULL);
if (req == NULL)
RETURN(-ENOMEM);
- body = lustre_msg_buf(req->rq_reqmsg, 1, sizeof(*body));
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
memcpy(&body->handle, &handle->och_fh, sizeof(body->handle));
body->flags = flag;
- req->rq_replen = lustre_msg_size(0, NULL);
+ ptlrpc_req_set_repsize(req, 1, NULL);
mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
rc = ptlrpc_queue_wait(req);
mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
struct ptlrpc_request **request)
{
struct ptlrpc_request *req;
- int rc, size[] = { [MDS_REQ_REC_OFF] = sizeof(struct mds_body) };
+ int size[2] = { sizeof(struct ptlrpc_body), sizeof(struct mds_body) };
+ int rc;
ENTRY;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
- MDS_SYNC, 1, size, NULL);
+ MDS_SYNC, 2, size, NULL);
if (!req)
RETURN(rc = -ENOMEM);
- mdc_pack_req_body(req, MDS_REQ_REC_OFF, 0, fid, 0);
+ mdc_pack_req_body(req, REQ_REC_OFF, 0, fid, 0);
- req->rq_replen = lustre_msg_size(1, size);
+ ptlrpc_req_set_repsize(req, 2, size);
rc = ptlrpc_queue_wait(req);
if (rc || request == NULL)
/* child orphan sem protects orphan_dec_test and
* is_orphan race, mds_mfd_close drops it */
MDS_DOWN_WRITE_ORPHAN_SEM(dentry->d_inode);
- rc = mds_mfd_close(NULL, MDS_REQ_REC_OFF, obd, mfd,
+ rc = mds_mfd_close(NULL, REQ_REC_OFF, obd, mfd,
!(export->exp_flags & OBD_OPT_FAILOVER));
if (rc)
{
struct mds_obd *mds = mds_req2mds(req);
struct mds_body *body;
- int rc, size = sizeof(*body);
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_GETSTATUS_PACK)) {
- CERROR("mds: out of memory for message: size=%d\n", size);
+ CERROR("mds: out of memory for message\n");
req->rq_status = -ENOMEM; /* superfluous? */
RETURN(-ENOMEM);
}
- body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*body));
memcpy(&body->fid1, &mds->mds_rootfid, sizeof(body->fid1));
/* the last_committed and last_xid fields are filled in for all
inode->i_ino);
RETURN(0);
}
- lmm_size = msg->buflens[offset];
+ lmm_size = lustre_msg_buflen(msg, offset);
/* I don't really like this, but it is a sanity check on the client
* MD request. However, if the client doesn't know how much space
ENTRY;
LASSERT(repbody->aclsize == 0);
- LASSERT(repmsg->bufcount > repoff);
+ LASSERT(lustre_msg_bufcount(repmsg) > repoff);
buflen = lustre_msg_buflen(repmsg, repoff);
if (!buflen)
int len;
LASSERT (symname != NULL); /* caller prepped reply */
- len = req->rq_repmsg->buflens[reply_off];
+ len = lustre_msg_buflen(req->rq_repmsg, reply_off);
rc = inode->i_op->readlink(dentry, symname, len);
if (rc < 0) {
{
struct mds_obd *mds = mds_req2mds(req);
struct mds_body *body;
- int rc, size[3] = {sizeof(*body)}, bufcount = 1;
+ int rc, bufcount = 2;
+ int size[4] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
- body = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*body));
+ LASSERT(offset == REQ_REC_OFF); /* non-intent */
+
+ body = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*body));
LASSERT(body != NULL); /* checked by caller */
LASSERT_REQSWABBED(req, offset); /* swabbed by caller */
RETURN(0);
}
-static int mds_getattr_lock(int offset, struct ptlrpc_request *req,
+static int mds_getattr_lock(struct ptlrpc_request *req, int offset,
int child_part, struct lustre_handle *child_lockh)
{
struct obd_device *obd = req->rq_export->exp_obd;
LASSERT(!strcmp(obd->obd_type->typ_name, LUSTRE_MDS_NAME));
/* Swab now, before anyone looks inside the request */
-
body = lustre_swab_reqbuf(req, offset, sizeof(*body),
lustre_swab_mds_body);
if (body == NULL) {
if (rc)
GOTO(cleanup, rc);
- LASSERT (offset == MDS_REQ_REC_OFF || offset == MDS_REQ_INTENT_REC_OFF);
+ LASSERT(offset == REQ_REC_OFF || offset == DLM_INTENT_REC_OFF);
/* if requests were at offset 2, the getattr reply goes back at 1 */
- if (offset == MDS_REQ_INTENT_REC_OFF) {
- rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*rep));
- offset = 1;
+ if (offset == DLM_INTENT_REC_OFF) {
+ rep = lustre_msg_buf(req->rq_repmsg, DLM_LOCKREPLY_OFF,
+ sizeof(*rep));
+ offset = DLM_REPLY_REC_OFF;
}
push_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc);
mds_exit_ucred(&uc, mds);
if (req->rq_reply_state == NULL) {
req->rq_status = rc;
- lustre_pack_reply(req, 0, NULL, NULL);
+ lustre_pack_reply(req, 1, NULL, NULL);
}
}
return rc;
struct lvfs_run_ctxt saved;
struct dentry *de;
struct mds_body *body;
- struct lvfs_ucred uc = {NULL,};
+ struct lvfs_ucred uc = { NULL, };
int rc = 0;
ENTRY;
GOTO(out_pop, rc);
}
- req->rq_status = mds_getattr_internal(obd, de, req, body, 0);
+ req->rq_status = mds_getattr_internal(obd, de, req, body,REPLY_REC_OFF);
l_dput(de);
GOTO(out_pop, rc);
out_ucred:
if (req->rq_reply_state == NULL) {
req->rq_status = rc;
- lustre_pack_reply(req, 0, NULL, NULL);
+ lustre_pack_reply(req, 1, NULL, NULL);
}
mds_exit_ucred(&uc, mds);
return rc;
static int mds_statfs(struct ptlrpc_request *req)
{
struct obd_device *obd = req->rq_export->exp_obd;
- int rc, size = sizeof(struct obd_statfs);
+ int rc, size[2] = { sizeof(struct ptlrpc_body),
+ sizeof(struct obd_statfs) };
ENTRY;
/* This will trigger a watchdog timeout */
OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_STATFS_LCW_SLEEP,
(MDS_SERVICE_WATCHDOG_TIMEOUT / 1000) + 1);
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_STATFS_PACK)) {
CERROR("mds: statfs lustre_pack_reply failed: rc = %d\n", rc);
GOTO(out, rc);
}
/* We call this so that we can cache a bit - 1 jiffie worth */
- rc = mds_obd_statfs(obd, lustre_msg_buf(req->rq_repmsg, 0, size),
+ rc = mds_obd_statfs(obd, lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+ size[REPLY_REC_OFF]),
jiffies - HZ);
if (rc) {
CERROR("mds_obd_statfs failed: rc %d\n", rc);
struct obd_device *obd = req->rq_export->exp_obd;
struct mds_obd *mds = &obd->u.mds;
struct mds_body *body;
- int rc, size = sizeof(*body);
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
- body = lustre_swab_reqbuf(req, 0, sizeof(*body), lustre_swab_mds_body);
+ body = lustre_swab_reqbuf(req, offset, sizeof(*body),
+ lustre_swab_mds_body);
if (body == NULL)
GOTO(out, rc = -EFAULT);
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_SYNC_PACK)) {
CERROR("fsync lustre_pack_reply failed: rc = %d\n", rc);
GOTO(out, rc);
if (de->d_inode->i_fop && de->d_inode->i_fop->fsync)
rc = de->d_inode->i_fop->fsync(NULL, de, 1);
if (rc == 0) {
- body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
+ body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*body));
mds_pack_inode2fid(&body->fid1, de->d_inode);
mds_pack_inode2body(body, de->d_inode);
}
struct file *file;
struct mds_body *body, *repbody;
struct lvfs_run_ctxt saved;
- int rc, size = sizeof(*repbody);
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*repbody) };
struct lvfs_ucred uc = {NULL,};
ENTRY;
if (OBD_FAIL_CHECK(OBD_FAIL_MDS_READPAGE_PACK))
RETURN(-ENOMEM);
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc) {
CERROR("error packing readpage reply: rc %d\n", rc);
GOTO(out, rc);
if (body == NULL)
GOTO (out, rc = -EFAULT);
- rc = mds_init_ucred(&uc, req, 0);
+ rc = mds_init_ucred(&uc, req, offset);
if (rc)
GOTO(out, rc);
GOTO(out_file, rc = -EFAULT);
}
- repbody = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*repbody));
+ repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*repbody));
repbody->size = file->f_dentry->d_inode->i_size;
repbody->valid = OBD_MD_FLSIZE;
static int mds_filter_recovery_request(struct ptlrpc_request *req,
struct obd_device *obd, int *process)
{
- switch (req->rq_reqmsg->opc) {
+ switch (lustre_msg_get_opc(req->rq_reqmsg)) {
case MDS_CONNECT: /* This will never get here, but for completeness. */
case OST_CONNECT: /* This will never get here, but for completeness. */
case MDS_DISCONNECT:
int keylen, rc = 0;
ENTRY;
- key = lustre_msg_buf(req->rq_reqmsg, 0, 1);
+ key = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, 1);
if (key == NULL) {
DEBUG_REQ(D_HA, req, "no set_info key");
RETURN(-EFAULT);
}
- keylen = req->rq_reqmsg->buflens[0];
+ keylen = lustre_msg_buflen(req->rq_reqmsg, REQ_REC_OFF);
- val = lustre_msg_buf(req->rq_reqmsg, 1, sizeof(*val));
+ val = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 1, sizeof(*val));
if (val == NULL) {
DEBUG_REQ(D_HA, req, "no set_info val");
RETURN(-EFAULT);
}
- rc = lustre_pack_reply(req, 0, NULL, NULL);
+ rc = lustre_pack_reply(req, 1, NULL, NULL);
if (rc)
RETURN(rc);
- req->rq_repmsg->status = 0;
+ lustre_msg_set_status(req->rq_repmsg, 0);
if (keylen < strlen("read-only") ||
memcmp(key, "read-only", keylen) != 0)
int rc;
ENTRY;
- oqctl = lustre_swab_reqbuf(req, 0, sizeof(*oqctl),
+ oqctl = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*oqctl),
lustre_swab_obd_quotactl);
if (oqctl == NULL)
RETURN(-EPROTO);
- rc = lustre_pack_reply(req, 0, NULL, NULL);
+ rc = lustre_pack_reply(req, 1, NULL, NULL);
if (rc) {
CERROR("mds: out of memory while packing quotacheck reply\n");
RETURN(rc);
static int mds_handle_quotactl(struct ptlrpc_request *req)
{
struct obd_quotactl *oqctl, *repoqc;
- int rc, size = sizeof(*repoqc);
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*repoqc) };
ENTRY;
- oqctl = lustre_swab_reqbuf(req, 0, sizeof(*oqctl),
+ oqctl = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*oqctl),
lustre_swab_obd_quotactl);
if (oqctl == NULL)
RETURN(-EPROTO);
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc)
RETURN(rc);
- repoqc = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*repoqc));
+ repoqc = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*repoqc));
req->rq_status = obd_quotactl(req->rq_export, oqctl);
*repoqc = *oqctl;
{
int rc;
- /* TODO: enable the below check while really introducing msg version.
- * it's disabled because it will break compatibility with b1_4.
- */
- return (0);
-
- switch (msg->opc) {
+ switch (lustre_msg_get_opc(msg)) {
case MDS_CONNECT:
case MDS_DISCONNECT:
case OBD_PING:
rc = lustre_msg_check_version(msg, LUSTRE_OBD_VERSION);
if (rc)
CERROR("bad opc %u version %08x, expecting %08x\n",
- msg->opc, msg->version, LUSTRE_OBD_VERSION);
+ lustre_msg_get_opc(msg),
+ lustre_msg_get_version(msg),
+ LUSTRE_OBD_VERSION);
break;
case MDS_GETSTATUS:
case MDS_GETATTR:
rc = lustre_msg_check_version(msg, LUSTRE_MDS_VERSION);
if (rc)
CERROR("bad opc %u version %08x, expecting %08x\n",
- msg->opc, msg->version, LUSTRE_MDS_VERSION);
+ lustre_msg_get_opc(msg),
+ lustre_msg_get_version(msg),
+ LUSTRE_MDS_VERSION);
break;
case LDLM_ENQUEUE:
case LDLM_CONVERT:
rc = lustre_msg_check_version(msg, LUSTRE_DLM_VERSION);
if (rc)
CERROR("bad opc %u version %08x, expecting %08x\n",
- msg->opc, msg->version, LUSTRE_DLM_VERSION);
+ lustre_msg_get_opc(msg),
+ lustre_msg_get_version(msg),
+ LUSTRE_DLM_VERSION);
break;
case OBD_LOG_CANCEL:
case LLOG_ORIGIN_HANDLE_CREATE:
case LLOG_ORIGIN_HANDLE_NEXT_BLOCK:
- case LLOG_ORIGIN_HANDLE_PREV_BLOCK:
case LLOG_ORIGIN_HANDLE_READ_HEADER:
case LLOG_ORIGIN_HANDLE_CLOSE:
+ case LLOG_ORIGIN_HANDLE_DESTROY:
+ case LLOG_ORIGIN_HANDLE_PREV_BLOCK:
case LLOG_CATINFO:
rc = lustre_msg_check_version(msg, LUSTRE_LOG_VERSION);
if (rc)
CERROR("bad opc %u version %08x, expecting %08x\n",
- msg->opc, msg->version, LUSTRE_LOG_VERSION);
+ lustre_msg_get_opc(msg),
+ lustre_msg_get_version(msg),
+ LUSTRE_LOG_VERSION);
break;
default:
- CERROR("MDS unknown opcode %d\n", msg->opc);
+ CERROR("MDS unknown opcode %d\n", lustre_msg_get_opc(msg));
rc = -ENOTSUPP;
}
return rc;
}
/* XXX identical to OST */
- if (req->rq_reqmsg->opc != MDS_CONNECT) {
+ if (lustre_msg_get_opc(req->rq_reqmsg) != MDS_CONNECT) {
struct mds_export_data *med;
int recovering, abort_recovery;
if (req->rq_export == NULL) {
CERROR("operation %d on unconnected MDS from %s\n",
- req->rq_reqmsg->opc,
+ lustre_msg_get_opc(req->rq_reqmsg),
libcfs_id2str(req->rq_peer));
req->rq_status = -ENOTCONN;
GOTO(out, rc = -ENOTCONN);
}
}
- switch (req->rq_reqmsg->opc) {
+ switch (lustre_msg_get_opc(req->rq_reqmsg)) {
case MDS_CONNECT:
DEBUG_REQ(D_INODE, req, "connect");
OBD_FAIL_RETURN(OBD_FAIL_MDS_CONNECT_NET, 0);
case MDS_GETATTR:
DEBUG_REQ(D_INODE, req, "getattr");
OBD_FAIL_RETURN(OBD_FAIL_MDS_GETATTR_NET, 0);
- rc = mds_getattr(req, MDS_REQ_REC_OFF);
+ rc = mds_getattr(req, REQ_REC_OFF);
break;
case MDS_SETXATTR:
* acquiring any new locks in mds_getattr_lock, so we don't
* want to cancel.
*/
- rc = mds_getattr_lock(MDS_REQ_REC_OFF, req,
- MDS_INODELOCK_UPDATE, &lockh);
+ rc = mds_getattr_lock(req, REQ_REC_OFF, MDS_INODELOCK_UPDATE,
+ &lockh);
/* this non-intent call (from an ioctl) is special */
req->rq_status = rc;
if (rc == 0 && lustre_handle_is_used(&lockh))
case MDS_READPAGE:
DEBUG_REQ(D_INODE, req, "readpage");
OBD_FAIL_RETURN(OBD_FAIL_MDS_READPAGE_NET, 0);
- rc = mds_readpage(req, MDS_REQ_REC_OFF);
+ rc = mds_readpage(req, REQ_REC_OFF);
if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_MDS_SENDPAGE)) {
RETURN(0);
break;
case MDS_REINT: {
- __u32 *opcp = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF,
- sizeof (*opcp));
+ __u32 *opcp = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF,
+ sizeof(*opcp));
__u32 opc;
- int size[] = { sizeof(struct mds_body), mds->mds_max_mdsize,
- mds->mds_max_cookiesize};
+ int size[4] = { sizeof(struct ptlrpc_body),
+ sizeof(struct mds_body),
+ mds->mds_max_mdsize,
+ mds->mds_max_cookiesize };
int bufcount;
/* NB only peek inside req now; mds_reint() will swab it */
break;
}
opc = *opcp;
- if (lustre_msg_swabbed (req->rq_reqmsg))
+ if (lustre_msg_swabbed(req->rq_reqmsg))
__swab32s(&opc);
DEBUG_REQ(D_INODE, req, "reint %d (%s)", opc,
OBD_FAIL_RETURN(OBD_FAIL_MDS_REINT_NET, 0);
if (opc == REINT_UNLINK || opc == REINT_RENAME)
- bufcount = 3;
+ bufcount = 4;
else if (opc == REINT_OPEN)
- bufcount = 2;
+ bufcount = 3;
else
- bufcount = 1;
+ bufcount = 2;
rc = lustre_pack_reply(req, bufcount, size, NULL);
if (rc)
break;
- rc = mds_reint(req, MDS_REQ_REC_OFF, NULL);
+ rc = mds_reint(req, REQ_REC_OFF, NULL);
fail = OBD_FAIL_MDS_REINT_NET_REP;
break;
}
case MDS_CLOSE:
DEBUG_REQ(D_INODE, req, "close");
OBD_FAIL_RETURN(OBD_FAIL_MDS_CLOSE_NET, 0);
- rc = mds_close(req, MDS_REQ_REC_OFF);
+ rc = mds_close(req, REQ_REC_OFF);
break;
case MDS_DONE_WRITING:
DEBUG_REQ(D_INODE, req, "done_writing");
OBD_FAIL_RETURN(OBD_FAIL_MDS_DONE_WRITING_NET, 0);
- rc = mds_done_writing(req, MDS_REQ_REC_OFF);
+ rc = mds_done_writing(req, REQ_REC_OFF);
break;
case MDS_PIN:
DEBUG_REQ(D_INODE, req, "pin");
OBD_FAIL_RETURN(OBD_FAIL_MDS_PIN_NET, 0);
- rc = mds_pin(req, MDS_REQ_REC_OFF);
+ rc = mds_pin(req, REQ_REC_OFF);
break;
case MDS_SYNC:
DEBUG_REQ(D_INODE, req, "sync");
OBD_FAIL_RETURN(OBD_FAIL_MDS_SYNC_NET, 0);
- rc = mds_sync(req, MDS_REQ_REC_OFF);
+ rc = mds_sync(req, REQ_REC_OFF);
break;
case MDS_SET_INFO:
LASSERT(current->journal_info == NULL);
/* If we're DISCONNECTing, the mds_export_data is already freed */
- if (!rc && req->rq_reqmsg->opc != MDS_DISCONNECT) {
+ if (!rc && lustre_msg_get_opc(req->rq_reqmsg) != MDS_DISCONNECT) {
struct mds_export_data *med = &req->rq_export->exp_mds_data;
- req->rq_repmsg->last_xid =
- le64_to_cpu(med->med_mcd->mcd_last_xid);
+ lustre_msg_set_last_xid(req->rq_repmsg,
+ le64_to_cpu(med->med_mcd->mcd_last_xid));
target_committed_to_req(req);
}
struct obd_export *exp = req->rq_export;
struct obd_device *obd = exp->exp_obd;
struct ldlm_request *dlmreq =
- lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*dlmreq));
+ lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*dlmreq));
struct lustre_handle remote_hdl = dlmreq->lock_handle1;
struct list_head *iter;
struct lustre_handle lockh = { 0 };
struct ldlm_lock *new_lock = NULL;
int getattr_part = MDS_INODELOCK_UPDATE;
- int repsize[4] = {sizeof(*rep),
- sizeof(struct mds_body),
- mds->mds_max_mdsize};
- int repbufcnt = 3, offset = MDS_REQ_INTENT_REC_OFF;
- int rc;
+ int repsize[5] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+ [DLM_LOCKREPLY_OFF] = sizeof(struct ldlm_reply),
+ [DLM_REPLY_REC_OFF] = sizeof(struct mds_body),
+ [DLM_REPLY_REC_OFF+1] = mds->mds_max_mdsize };
+ int repbufcnt = 4, rc;
ENTRY;
LASSERT(req != NULL);
- if (req->rq_reqmsg->bufcount <= MDS_REQ_INTENT_IT_OFF) {
+ if (lustre_msg_bufcount(req->rq_reqmsg) <= DLM_INTENT_IT_OFF) {
/* No intent was provided */
- int size = sizeof(struct ldlm_reply);
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, repsize, NULL);
LASSERT(rc == 0);
RETURN(0);
}
- it = lustre_swab_reqbuf(req, MDS_REQ_INTENT_IT_OFF, sizeof(*it),
+ it = lustre_swab_reqbuf(req, DLM_INTENT_IT_OFF, sizeof(*it),
lustre_swab_ldlm_intent);
if (it == NULL) {
CERROR("Intent missing\n");
if (rc)
RETURN(req->rq_status = rc);
- rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*rep));
+ rep = lustre_msg_buf(req->rq_repmsg, DLM_LOCKREPLY_OFF, sizeof(*rep));
intent_set_disposition(rep, DISP_IT_EXECD);
switch ((long)it->opc) {
case IT_OPEN:
case IT_CREAT|IT_OPEN:
- fixup_handle_for_resent_req(req, MDS_REQ_INTENT_LOCKREQ_OFF,
- lock, NULL, &lockh);
+ fixup_handle_for_resent_req(req, DLM_LOCKREQ_OFF, lock, NULL,
+ &lockh);
/* XXX swab here to assert that an mds_open reint
* packet is following */
- rep->lock_policy_res2 = mds_reint(req, offset, &lockh);
+ rep->lock_policy_res2 = mds_reint(req, DLM_INTENT_REC_OFF,
+ &lockh);
#if 0
/* We abort the lock if the lookup was negative and
* we did not make it to the OPEN portion */
case IT_GETATTR:
getattr_part |= MDS_INODELOCK_LOOKUP;
case IT_READDIR:
- fixup_handle_for_resent_req(req, MDS_REQ_INTENT_LOCKREQ_OFF,
- lock, &new_lock, &lockh);
+ fixup_handle_for_resent_req(req, DLM_LOCKREQ_OFF, lock,
+ &new_lock, &lockh);
/* INODEBITS_INTEROP: if this lock was converted from a
* plain lock (client does not support inodebits), then
getattr_part = MDS_INODELOCK_LOOKUP |
MDS_INODELOCK_UPDATE;
- rep->lock_policy_res2 = mds_getattr_lock(offset, req,
+ rep->lock_policy_res2 = mds_getattr_lock(req,DLM_INTENT_REC_OFF,
getattr_part, &lockh);
/* FIXME: LDLM can set req->rq_status. MDS sets
policy_res{1,2} with disposition and status.
req->rq_export->exp_mds_data.med_mcd; \
if (mcd->mcd_last_xid == req->rq_xid) { \
reconstruct; \
- RETURN(req->rq_repmsg->status); \
+ RETURN(lustre_msg_get_status(req->rq_repmsg)); \
} \
DEBUG_REQ(D_HA, req, "no reply for RESENT req (have "LPD64")",\
mcd->mcd_last_xid); \
int child_mode);
void mds_shrink_reply(struct obd_device *obd, struct ptlrpc_request *req,
- struct mds_body *body);
+ struct mds_body *body, int md_off);
int mds_get_cookie_size(struct obd_device *obd, struct lov_mds_md *lmm);
/* mds/mds_lib.c */
int mds_update_unpack(struct ptlrpc_request *, int offset,
struct ptlrpc_request *req, struct lustre_handle *);
int mds_pin(struct ptlrpc_request *req, int offset);
void mds_mfd_unlink(struct mds_file_data *mfd, int decref);
-int mds_mfd_close(struct ptlrpc_request *req, int offset, struct obd_device *obd,
+int mds_mfd_close(struct ptlrpc_request *req, int offset,struct obd_device *obd,
struct mds_file_data *mfd, int unlink_orphan);
int mds_close(struct ptlrpc_request *req, int offset);
int mds_done_writing(struct ptlrpc_request *req, int offset);
struct mds_rec_join *join_rec;
ENTRY;
- join_rec = lustre_swab_reqbuf (req, 5, sizeof (*join_rec),
- lustre_swab_mds_rec_join);
+ join_rec = lustre_swab_reqbuf(req, DLM_INTENT_REC_OFF + 3,
+ sizeof(*join_rec),
+ lustre_swab_mds_rec_join);
if (join_rec == NULL)
RETURN (-EFAULT);
attr->ia_attr_flags = rec->sa_attr_flags;
LASSERT_REQSWAB (req, offset + 1);
- if (req->rq_reqmsg->bufcount > offset + 1) {
- r->ur_eadata = lustre_msg_buf (req->rq_reqmsg,
- offset + 1, 0);
+ if (lustre_msg_bufcount(req->rq_reqmsg) > offset + 1) {
+ r->ur_eadata = lustre_msg_buf(req->rq_reqmsg, offset + 1, 0);
if (r->ur_eadata == NULL)
- RETURN (-EFAULT);
- r->ur_eadatalen = req->rq_reqmsg->buflens[offset + 1];
+ RETURN(-EFAULT);
+ r->ur_eadatalen = lustre_msg_buflen(req->rq_reqmsg, offset + 1);
}
- if (req->rq_reqmsg->bufcount > offset + 2) {
+ if (lustre_msg_bufcount(req->rq_reqmsg) > offset + 2) {
r->ur_logcookies = lustre_msg_buf(req->rq_reqmsg, offset + 2,0);
if (r->ur_eadata == NULL)
RETURN (-EFAULT);
- r->ur_cookielen = req->rq_reqmsg->buflens[offset + 2];
+ r->ur_cookielen = lustre_msg_buflen(req->rq_reqmsg, offset + 2);
}
RETURN(0);
struct mds_rec_create *rec;
ENTRY;
- rec = lustre_swab_reqbuf (req, offset, sizeof (*rec),
- lustre_swab_mds_rec_create);
+ rec = lustre_swab_reqbuf(req, offset, sizeof (*rec),
+ lustre_swab_mds_rec_create);
if (rec == NULL)
RETURN (-EFAULT);
r->ur_time = rec->cr_time;
r->ur_flags = rec->cr_flags;
- LASSERT_REQSWAB (req, offset + 1);
- r->ur_name = lustre_msg_string (req->rq_reqmsg, offset + 1, 0);
+ LASSERT_REQSWAB(req, offset + 1);
+ r->ur_name = lustre_msg_string(req->rq_reqmsg, offset + 1, 0);
if (r->ur_name == NULL)
RETURN (-EFAULT);
- r->ur_namelen = req->rq_reqmsg->buflens[offset + 1];
+ r->ur_namelen = lustre_msg_buflen(req->rq_reqmsg, offset + 1);
- LASSERT_REQSWAB (req, offset + 2);
- if (req->rq_reqmsg->bufcount > offset + 2) {
+ LASSERT_REQSWAB(req, offset + 2);
+ if (lustre_msg_bufcount(req->rq_reqmsg) > offset + 2) {
/* NB for now, we only seem to pass NULL terminated symlink
* target strings here. If this ever changes, we'll have
* to stop checking for a buffer filled completely with a
r->ur_tgt = lustre_msg_string(req->rq_reqmsg, offset + 2, 0);
if (r->ur_tgt == NULL)
RETURN (-EFAULT);
- r->ur_tgtlen = req->rq_reqmsg->buflens[offset + 2];
+ r->ur_tgtlen = lustre_msg_buflen(req->rq_reqmsg, offset + 2);
}
RETURN(0);
}
struct mds_rec_link *rec;
ENTRY;
- rec = lustre_swab_reqbuf (req, offset, sizeof (*rec),
- lustre_swab_mds_rec_link);
+ rec = lustre_swab_reqbuf(req, offset, sizeof (*rec),
+ lustre_swab_mds_rec_link);
if (rec == NULL)
RETURN (-EFAULT);
r->ur_fid2 = &rec->lk_fid2;
r->ur_time = rec->lk_time;
- LASSERT_REQSWAB (req, offset + 1);
- r->ur_name = lustre_msg_string (req->rq_reqmsg, offset + 1, 0);
+ LASSERT_REQSWAB(req, offset + 1);
+ r->ur_name = lustre_msg_string(req->rq_reqmsg, offset + 1, 0);
if (r->ur_name == NULL)
RETURN (-EFAULT);
- r->ur_namelen = req->rq_reqmsg->buflens[offset + 1];
+ r->ur_namelen = lustre_msg_buflen(req->rq_reqmsg, offset + 1);
RETURN(0);
}
struct mds_rec_unlink *rec;
ENTRY;
- rec = lustre_swab_reqbuf (req, offset, sizeof (*rec),
- lustre_swab_mds_rec_unlink);
+ rec = lustre_swab_reqbuf(req, offset, sizeof (*rec),
+ lustre_swab_mds_rec_unlink);
if (rec == NULL)
RETURN(-EFAULT);
r->ur_fid2 = &rec->ul_fid2;
r->ur_time = rec->ul_time;
- LASSERT_REQSWAB (req, offset + 1);
+ LASSERT_REQSWAB(req, offset + 1);
r->ur_name = lustre_msg_string(req->rq_reqmsg, offset + 1, 0);
if (r->ur_name == NULL)
RETURN(-EFAULT);
- r->ur_namelen = req->rq_reqmsg->buflens[offset + 1];
+ r->ur_namelen = lustre_msg_buflen(req->rq_reqmsg, offset + 1);
RETURN(0);
}
struct mds_rec_rename *rec;
ENTRY;
- rec = lustre_swab_reqbuf (req, offset, sizeof (*rec),
- lustre_swab_mds_rec_rename);
+ rec = lustre_swab_reqbuf(req, offset, sizeof (*rec),
+ lustre_swab_mds_rec_rename);
if (rec == NULL)
RETURN(-EFAULT);
r->ur_name = lustre_msg_string(req->rq_reqmsg, offset + 1, 0);
if (r->ur_name == NULL)
RETURN(-EFAULT);
- r->ur_namelen = req->rq_reqmsg->buflens[offset + 1];
+ r->ur_namelen = lustre_msg_buflen(req->rq_reqmsg, offset + 1);
LASSERT_REQSWAB (req, offset + 2);
r->ur_tgt = lustre_msg_string(req->rq_reqmsg, offset + 2, 0);
if (r->ur_tgt == NULL)
RETURN(-EFAULT);
- r->ur_tgtlen = req->rq_reqmsg->buflens[offset + 2];
+ r->ur_tgtlen = lustre_msg_buflen(req->rq_reqmsg, offset + 2);
RETURN(0);
}
struct mds_rec_create *rec;
ENTRY;
- rec = lustre_swab_reqbuf (req, offset, sizeof (*rec),
- lustre_swab_mds_rec_create);
+ rec = lustre_swab_reqbuf(req, offset, sizeof(*rec),
+ lustre_swab_mds_rec_create);
if (rec == NULL)
- RETURN (-EFAULT);
+ RETURN(-EFAULT);
r->ur_uc.luc_fsuid = rec->cr_fsuid;
r->ur_uc.luc_fsgid = rec->cr_fsgid;
r->ur_time = rec->cr_time;
r->ur_flags = rec->cr_flags;
- LASSERT_REQSWAB (req, offset + 1);
- r->ur_name = lustre_msg_string (req->rq_reqmsg, offset + 1, 0);
+ LASSERT_REQSWAB(req, offset + 1);
+ r->ur_name = lustre_msg_string(req->rq_reqmsg, offset + 1, 0);
if (r->ur_name == NULL)
- RETURN (-EFAULT);
- r->ur_namelen = req->rq_reqmsg->buflens[offset + 1];
+ RETURN(-EFAULT);
+ r->ur_namelen = lustre_msg_buflen(req->rq_reqmsg, offset + 1);
- LASSERT_REQSWAB (req, offset + 2);
- if (req->rq_reqmsg->bufcount > offset + 2) {
+ LASSERT_REQSWAB(req, offset + 2);
+ if (lustre_msg_bufcount(req->rq_reqmsg) > offset + 2) {
r->ur_eadata = lustre_msg_buf(req->rq_reqmsg, offset + 2, 0);
if (r->ur_eadata == NULL)
RETURN (-EFAULT);
- r->ur_eadatalen = req->rq_reqmsg->buflens[offset + 2];
+ r->ur_eadatalen = lustre_msg_buflen(req->rq_reqmsg, offset + 2);
}
RETURN(0);
}
/* NB don't lustre_swab_reqbuf() here. We're just taking a peek
* and we want to leave it to the specific unpacker once we've
* identified the message type */
- opcodep = lustre_msg_buf (req->rq_reqmsg, offset, sizeof (*opcodep));
+ opcodep = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*opcodep));
if (opcodep == NULL)
RETURN(-EFAULT);
opcode = *opcodep;
- if (lustre_msg_swabbed (req->rq_reqmsg))
- __swab32s (&opcode);
+ if (lustre_msg_swabbed(req->rq_reqmsg))
+ __swab32s(&opcode);
if (opcode >= REINT_MAX || mds_unpackers[opcode] == NULL) {
CERROR("Unexpected opcode %d\n", opcode);
GOTO(out, rc);
}
+ EXIT;
out:
class_decref(obd);
- RETURN(rc);
+ return rc;
}
int mds_lov_synchronize(void *data)
GOTO(cleanup_dentry, error = -ENOMEM);
}
- body = lustre_msg_buf(req->rq_repmsg, 1, sizeof (*body));
+ body = lustre_msg_buf(req->rq_repmsg, DLM_REPLY_REC_OFF, sizeof(*body));
if (flags & FMODE_WRITE) {
/* FIXME: in recovery, need to pass old epoch here */
!(rec->ur_flags & FMODE_WRITE))
RETURN(0);
- body = lustre_msg_buf(req->rq_repmsg, 1, sizeof(*body));
+ body = lustre_msg_buf(req->rq_repmsg, DLM_REPLY_REC_OFF, sizeof(*body));
if (body->valid & OBD_MD_FLEASIZE)
RETURN(0);
mds_objids_from_lmm(*ids, lmm, &mds->mds_lov_desc);
rc = fsfilt_set_md(obd, inode, *handle, lmm, lmm_size, "lov");
+ if (rc)
+ CERROR("open replay failed to set md:%d\n", rc);
lmm_buf = lustre_msg_buf(req->rq_repmsg, offset, lmm_size);
LASSERT(lmm_buf);
memcpy(lmm_buf, lmm, lmm_size);
- if (rc)
- CERROR("open replay failed to set md:%d\n", rc);
+
RETURN(rc);
}
int put_child = 1;
ENTRY;
- LASSERT(offset == 2); /* only called via intent */
- rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*rep));
- body = lustre_msg_buf(req->rq_repmsg, 1, sizeof (*body));
+ LASSERT(offset == DLM_INTENT_REC_OFF); /* only called via intent */
+ rep = lustre_msg_buf(req->rq_repmsg, DLM_LOCKREPLY_OFF, sizeof(*rep));
+ body = lustre_msg_buf(req->rq_repmsg, DLM_REPLY_REC_OFF, sizeof(*body));
/* copy rc, transno and disp; steal locks */
mds_req_from_mcd(req, mcd);
mds_pack_inode2fid(&body->fid1, dchild->d_inode);
mds_pack_inode2body(body, dchild->d_inode);
if (S_ISREG(dchild->d_inode->i_mode)) {
- rc = mds_pack_md(obd, req->rq_repmsg, 2, body,
- dchild->d_inode, 1);
+ rc = mds_pack_md(obd, req->rq_repmsg, DLM_REPLY_REC_OFF + 1,
+ body, dchild->d_inode, 1);
if (rc)
LASSERT(rc == req->rq_status);
}
if (!(rec->ur_flags & MDS_OPEN_JOIN_FILE))
- lustre_shrink_reply(req, 2, body->eadatasize, 0);
+ lustre_shrink_reply(req, DLM_REPLY_REC_OFF + 1,
+ body->eadatasize, 0);
if (req->rq_export->exp_connect_flags & OBD_CONNECT_ACL &&
!(rec->ur_flags & MDS_OPEN_JOIN_FILE)) {
- int acl_off = body->eadatasize ? 3 : 2;
+ int acl_off = DLM_REPLY_REC_OFF + (body->eadatasize ? 2 : 1);
rc = mds_pack_acl(med, dchild->d_inode, req->rq_repmsg,
body, acl_off);
if (S_ISREG(dchild->d_inode->i_mode) &&
!(body->valid & OBD_MD_FLEASIZE)) {
- rc = mds_pack_md(obd, req->rq_repmsg, 2, body,
- dchild->d_inode, 0);
+ rc = mds_pack_md(obd, req->rq_repmsg, DLM_REPLY_REC_OFF + 1,
+ body, dchild->d_inode, 0);
if (rc) {
UNLOCK_INODE_MUTEX(dchild->d_inode);
RETURN(rc);
if (!(body->valid & OBD_MD_FLEASIZE) &&
!(body->valid & OBD_MD_FLMODEASIZE)) {
/* no EA: create objects */
- rc = mds_create_objects(req, 2, rec, mds, obd,
- dchild, handle, &ids);
+ rc = mds_create_objects(req, DLM_REPLY_REC_OFF + 1, rec,
+ mds, obd, dchild, handle, &ids);
if (rc) {
CERROR("mds_create_objects: rc = %d\n", rc);
UNLOCK_INODE_MUTEX(dchild->d_inode);
UNLOCK_INODE_MUTEX(dchild->d_inode);
if (!(rec->ur_flags & MDS_OPEN_JOIN_FILE))
- lustre_shrink_reply(req, 2, body->eadatasize, 0);
+ lustre_shrink_reply(req, DLM_REPLY_REC_OFF + 1,
+ body->eadatasize, 0);
if (req->rq_export->exp_connect_flags & OBD_CONNECT_ACL &&
!(rec->ur_flags & MDS_OPEN_JOIN_FILE)) {
- int acl_off = body->eadatasize ? 3 : 2;
+ int acl_off = DLM_REPLY_REC_OFF + (body->eadatasize ? 2 : 1);
rc = mds_pack_acl(&req->rq_export->exp_mds_data,
dchild->d_inode, req->rq_repmsg,
int mds_pin(struct ptlrpc_request *req, int offset)
{
struct obd_device *obd = req->rq_export->exp_obd;
- struct mds_body *request_body, *reply_body;
+ struct mds_body *reqbody, *repbody;
struct lvfs_run_ctxt saved;
- int rc, size = sizeof(*reply_body);
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*repbody) };
ENTRY;
- request_body = lustre_msg_buf(req->rq_reqmsg, offset,
- sizeof(*request_body));
+ reqbody = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*reqbody));
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc)
RETURN(rc);
- reply_body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*reply_body));
+ repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*repbody));
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- rc = mds_open_by_fid(req, &request_body->fid1, reply_body,
- request_body->flags, NULL, NULL);
+ rc = mds_open_by_fid(req, &reqbody->fid1, repbody, reqbody->flags, NULL,
+ NULL);
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
RETURN(rc);
int parent_mode = LCK_CR;
void *handle = NULL;
struct dentry_params dp;
- unsigned int qcids[MAXQUOTAS] = {current->fsuid, current->fsgid};
- unsigned int qpids[MAXQUOTAS] = {0, 0};
+ unsigned int qcids[MAXQUOTAS] = { current->fsuid, current->fsgid };
+ unsigned int qpids[MAXQUOTAS] = { 0, 0 };
ENTRY;
CLASSERT(MAXQUOTAS < 4);
- if (offset == 2) { /* intent */
- rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*rep));
- body = lustre_msg_buf(req->rq_repmsg, 1, sizeof (*body));
- } else if (offset == MDS_REQ_REC_OFF) { /* non-intent reint */
- body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body));
+ if (offset == DLM_INTENT_REC_OFF) { /* intent */
+ rep = lustre_msg_buf(req->rq_repmsg, DLM_LOCKREPLY_OFF,
+ sizeof(*rep));
+ body = lustre_msg_buf(req->rq_repmsg, DLM_REPLY_REC_OFF,
+ sizeof(*body));
+ } else if (offset == REQ_REC_OFF) { /* non-intent reint */
+ body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*body));
+ LBUG(); /* XXX: not supported yet? */
} else {
body = NULL;
LBUG();
RETURN(-EFAULT);
}
- LASSERT(offset == 2); /* If we got here, we must be called via intent */
+ /* If we got here, we must be called via intent */
+ LASSERT(offset == DLM_INTENT_REC_OFF);
med = &req->rq_export->exp_mds_data;
if (OBD_FAIL_CHECK(OBD_FAIL_MDS_OPEN_PACK)) {
if (rc)
ldlm_lock_decref(&parent_lockh, parent_mode);
else
- ptlrpc_save_lock (req, &parent_lockh, parent_mode);
+ ptlrpc_save_lock(req, &parent_lockh, parent_mode);
}
/* trigger dqacq on the owner of child and parent */
request_body = lustre_msg_buf(req->rq_reqmsg, offset,
sizeof(*request_body));
if (req && req->rq_repmsg != NULL)
- reply_body = lustre_msg_buf(req->rq_repmsg, 0,
+ reply_body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
sizeof(*reply_body));
fidlen = ll_fid2str(fidname, inode->i_ino, inode->i_generation);
}
if (req != NULL && req->rq_repmsg != NULL) {
- lmm = lustre_msg_buf(req->rq_repmsg, 1, 0);
+ lmm = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF+1,0);
stripe_count = le32_to_cpu(lmm->lmm_stripe_count);
}
if (req != NULL && req->rq_repmsg != NULL &&
(reply_body->valid & OBD_MD_FLEASIZE) &&
mds_log_op_unlink(obd, pending_child->d_inode, lmm,
- req->rq_repmsg->buflens[1],
- lustre_msg_buf(req->rq_repmsg, 2, 0),
- req->rq_repmsg->buflens[2]) > 0) {
+ lustre_msg_buflen(req->rq_repmsg, REPLY_REC_OFF+1),
+ lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF+2, 0),
+ lustre_msg_buflen(req->rq_repmsg, REPLY_REC_OFF+2))
+ > 0) {
reply_body->valid |= OBD_MD_FLCOOKIE;
}
struct mds_file_data *mfd;
struct lvfs_run_ctxt saved;
struct inode *inode;
- int rc, repsize[3] = {sizeof(struct mds_body),
- obd->u.mds.mds_max_mdsize,
- obd->u.mds.mds_max_cookiesize};
+ int rc, repsize[4] = { sizeof(struct ptlrpc_body),
+ sizeof(struct mds_body),
+ obd->u.mds.mds_max_mdsize,
+ obd->u.mds.mds_max_cookiesize };
ENTRY;
- rc = lustre_pack_reply(req, 3, repsize, NULL);
+ rc = lustre_pack_reply(req, 4, repsize, NULL);
if (rc) {
CERROR("lustre_pack_reply: rc = %d\n", rc);
req->rq_status = rc;
/* child orphan sem protects orphan_dec_test && is_orphan race */
MDS_DOWN_WRITE_ORPHAN_SEM(inode); /* mds_mfd_close drops this */
if (mds_inode_is_orphan(inode) && mds_orphan_open_count(inode) == 1) {
- body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*body));
LASSERT(body != NULL);
mds_pack_inode2fid(&body->fid1, inode);
mds_pack_inode2body(body, inode);
- mds_pack_md(obd, req->rq_repmsg, 1,body,inode,MDS_PACK_MD_LOCK);
+ mds_pack_md(obd, req->rq_repmsg, REPLY_REC_OFF + 1, body, inode,
+ MDS_PACK_MD_LOCK);
}
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
req->rq_status = mds_mfd_close(req, offset, obd, mfd, 1);
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- mds_shrink_reply(obd, req, body);
+ mds_shrink_reply(obd, req, body, REPLY_REC_OFF + 1);
if (OBD_FAIL_CHECK(OBD_FAIL_MDS_CLOSE_PACK)) {
CERROR("test case OBD_FAIL_MDS_CLOSE_PACK\n");
req->rq_status = -ENOMEM;
int mds_done_writing(struct ptlrpc_request *req, int offset)
{
struct mds_body *body;
- int rc, size = sizeof(struct mds_body);
+ int rc, size[2] = { sizeof(struct ptlrpc_body),
+ sizeof(struct mds_body) };
ENTRY;
MDS_CHECK_RESENT(req, mds_reconstruct_generic(req));
RETURN(-EFAULT);
}
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc) {
CERROR("lustre_pack_reply: rc = %d\n", rc);
req->rq_status = rc;
off = med->med_lr_off;
- transno = req->rq_reqmsg->transno;
+ transno = lustre_msg_get_transno(req->rq_reqmsg);
if (rc != 0) {
if (transno != 0) {
CERROR("%s: replay %s transno "LPU64" failed: rc %d\n",
mds->mds_last_transno = transno;
spin_unlock(&mds->mds_transno_lock);
}
- req->rq_repmsg->transno = req->rq_transno = transno;
+ req->rq_transno = transno;
+ lustre_msg_set_transno(req->rq_repmsg, transno);
mcd->mcd_last_transno = cpu_to_le64(transno);
mcd->mcd_last_xid = cpu_to_le64(req->rq_xid);
mcd->mcd_last_result = cpu_to_le32(rc);
if (oldrep->rs_xid != req->rq_xid)
continue;
- if (oldrep->rs_msg.opc != req->rq_reqmsg->opc)
+ if (lustre_msg_get_opc(oldrep->rs_msg) !=
+ lustre_msg_get_opc(req->rq_reqmsg))
CERROR ("Resent req xid "LPX64" has mismatched opc: "
"new %d old %d\n", req->rq_xid,
- req->rq_reqmsg->opc, oldrep->rs_msg.opc);
+ lustre_msg_get_opc(req->rq_reqmsg),
+ lustre_msg_get_opc(oldrep->rs_msg));
svc = oldrep->rs_service;
spin_lock (&svc->srv_lock);
CWARN("Stealing %d locks from rs %p x"LPD64".t"LPD64
" o%d NID %s\n",
oldrep->rs_nlocks, oldrep,
- oldrep->rs_xid, oldrep->rs_transno, oldrep->rs_msg.opc,
+ oldrep->rs_xid, oldrep->rs_transno,
+ lustre_msg_get_opc(oldrep->rs_msg),
libcfs_nid2str(exp->exp_connection->c_peer.nid));
for (i = 0; i < oldrep->rs_nlocks; i++)
{
DEBUG_REQ(D_HA, req, "restoring transno "LPD64"/status %d",
mcd->mcd_last_transno, mcd->mcd_last_result);
- req->rq_repmsg->transno = req->rq_transno = mcd->mcd_last_transno;
- req->rq_repmsg->status = req->rq_status = mcd->mcd_last_result;
+ req->rq_transno = mcd->mcd_last_transno;
+ lustre_msg_set_transno(req->rq_repmsg, req->rq_transno);
+ req->rq_status = mcd->mcd_last_result;
+ lustre_msg_set_status(req->rq_repmsg, req->rq_status);
mds_steal_ack_locks(req);
}
return;
}
- body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_repmsg, offset, sizeof(*body));
mds_pack_inode2fid(&body->fid1, de->d_inode);
mds_pack_inode2body(body, de->d_inode);
struct llog_cookie *logcookies = NULL;
int lmm_size = 0, need_lock = 1, cookie_size = 0;
int rc = 0, cleanup_phase = 0, err, locked = 0;
- unsigned int qcids[MAXQUOTAS] = {0, 0};
- unsigned int qpids[MAXQUOTAS] = {rec->ur_iattr.ia_uid,
- rec->ur_iattr.ia_gid};
+ unsigned int qcids[MAXQUOTAS] = { 0, 0 };
+ unsigned int qpids[MAXQUOTAS] = { rec->ur_iattr.ia_uid,
+ rec->ur_iattr.ia_gid };
ENTRY;
- LASSERT(offset == MDS_REQ_REC_OFF);
+ LASSERT(offset == REQ_REC_OFF);
+ offset = REPLY_REC_OFF;
DEBUG_REQ(D_INODE, req, "setattr "LPU64"/%u %x", rec->ur_fid1->id,
rec->ur_fid1->generation, rec->ur_iattr.ia_valid);
}
}
- body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_repmsg, offset, sizeof(*body));
mds_pack_inode2fid(&body->fid1, inode);
mds_pack_inode2body(body, inode);
LASSERT(!IS_ERR(parent));
child = ll_lookup_one_len(rec->ur_name, parent, rec->ur_namelen - 1);
LASSERT(!IS_ERR(child));
- body = lustre_msg_buf(req->rq_repmsg, offset, sizeof (*body));
+
+ body = lustre_msg_buf(req->rq_repmsg, offset, sizeof(*body));
mds_pack_inode2fid(&body->fid1, child->d_inode);
mds_pack_inode2body(body, child->d_inode);
+
l_dput(parent);
l_dput(child);
}
struct lustre_handle lockh;
int rc = 0, err, type = rec->ur_mode & S_IFMT, cleanup_phase = 0;
int created = 0;
- unsigned int qcids[MAXQUOTAS] = {current->fsuid, current->fsgid};
- unsigned int qpids[MAXQUOTAS] = {0, 0};
+ unsigned int qcids[MAXQUOTAS] = { current->fsuid, current->fsgid };
+ unsigned int qpids[MAXQUOTAS] = { 0, 0 };
struct dentry_params dp;
ENTRY;
- LASSERT(offset == MDS_REQ_REC_OFF);
+ LASSERT(offset == REQ_REC_OFF);
+ offset = REPLY_REC_OFF;
+
LASSERT(!strcmp(req->rq_export->exp_obd->obd_type->typ_name,
LUSTRE_MDS_NAME));
rc);
}
- body = lustre_msg_buf(req->rq_repmsg, offset, sizeof (*body));
+ body = lustre_msg_buf(req->rq_repmsg, offset, sizeof(*body));
mds_pack_inode2fid(&body->fid1, inode);
mds_pack_inode2body(body, inode);
}
}
void mds_shrink_reply(struct obd_device *obd, struct ptlrpc_request *req,
- struct mds_body *body)
+ struct mds_body *body, int md_off)
{
int cookie_size = 0, md_size = 0;
if (body && body->valid & OBD_MD_FLCOOKIE) {
LASSERT(body->valid & OBD_MD_FLEASIZE);
cookie_size = mds_get_cookie_size(obd, lustre_msg_buf(
- req->rq_repmsg, 1, 0));
+ req->rq_repmsg, md_off, 0));
}
CDEBUG(D_INFO, "Shrink to md_size %d cookie_size %d \n", md_size,
cookie_size);
- lustre_shrink_reply(req, 1, md_size, 1);
+ lustre_shrink_reply(req, md_off, md_size, 1);
- lustre_shrink_reply(req, md_size? 2:1, cookie_size, 0);
+ lustre_shrink_reply(req, md_off + (md_size > 0), cookie_size, 0);
}
static int mds_reint_unlink(struct mds_update_record *rec, int offset,
struct lustre_handle parent_lockh, child_lockh, child_reuse_lockh;
void *handle = NULL;
int rc = 0, cleanup_phase = 0;
- unsigned int qcids [MAXQUOTAS] = {0, 0};
- unsigned int qpids [MAXQUOTAS] = {0, 0};
+ unsigned int qcids[MAXQUOTAS] = { 0, 0 };
+ unsigned int qpids[MAXQUOTAS] = { 0, 0 };
ENTRY;
- LASSERT(offset == MDS_REQ_REC_OFF || offset == 2);
+ LASSERT(offset == REQ_REC_OFF); /* || offset == DLM_INTENT_REC_OFF); */
+ offset = REPLY_REC_OFF;
DEBUG_REQ(D_INODE, req, "parent ino "LPU64"/%u, child %s",
rec->ur_fid1->id, rec->ur_fid1->generation, rec->ur_name);
OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_UNLINK_WRITE, dparent->d_inode->i_sb);
/* ldlm_reply in buf[0] if called via intent */
- if (offset)
- offset = 1;
+ if (offset == DLM_INTENT_REC_OFF)
+ offset = DLM_REPLY_REC_OFF;
- body = lustre_msg_buf(req->rq_repmsg, offset, sizeof (*body));
+ body = lustre_msg_buf(req->rq_repmsg, offset, sizeof(*body));
LASSERT(body != NULL);
/* child orphan sem protects orphan_dec_test && is_orphan race */
OBD_MD_FLATIME | OBD_MD_FLMTIME);
} else if (mds_log_op_unlink(obd, child_inode,
lustre_msg_buf(req->rq_repmsg, offset + 1, 0),
- req->rq_repmsg->buflens[offset + 1],
+ lustre_msg_buflen(req->rq_repmsg, offset + 1),
lustre_msg_buf(req->rq_repmsg, offset + 2, 0),
- req->rq_repmsg->buflens[offset+2]) > 0){
+ lustre_msg_buflen(req->rq_repmsg, offset+2)) >
+ 0) {
body->valid |= OBD_MD_FLCOOKIE;
}
}
}
req->rq_status = rc;
- mds_shrink_reply(obd, req, body);
+ mds_shrink_reply(obd, req, body, REPLY_REC_OFF + 1);
/* trigger dqrel on the owner of child and parent */
lquota_adjust(quota_interface, obd, qcids, qpids, rc, FSFILT_OP_UNLINK);
int rc = 0, cleanup_phase = 0;
ENTRY;
- LASSERT(offset == MDS_REQ_REC_OFF);
+ LASSERT(offset == REQ_REC_OFF);
DEBUG_REQ(D_INODE, req, "original "LPU64"/%u to "LPU64"/%u %s",
rec->ur_fid1->id, rec->ur_fid1->generation,
struct lov_mds_md *lmm = NULL;
int rc = 0, lock_count = 3, cleanup_phase = 0;
void *handle = NULL;
- unsigned int qcids[MAXQUOTAS] = {0, 0};
- unsigned int qpids[4] = {0, 0, 0, 0};
+ unsigned int qcids[MAXQUOTAS] = { 0, 0 };
+ unsigned int qpids[4] = { 0, 0, 0, 0 };
ENTRY;
- LASSERT(offset == MDS_REQ_REC_OFF);
+ LASSERT(offset == REQ_REC_OFF);
+ offset = REPLY_REC_OFF;
DEBUG_REQ(D_INODE, req, "parent "LPU64"/%u %s to "LPU64"/%u %s",
rec->ur_fid1->id, rec->ur_fid1->generation, rec->ur_name,
/* if we are about to remove the target at first, pass the EA of
* that inode to client to perform and cleanup on OST */
- body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_repmsg, offset, sizeof(*body));
LASSERT(body != NULL);
/* child orphan sem protects orphan_dec_test && is_orphan race */
} else if (S_ISREG(new_inode->i_mode)) {
mds_pack_inode2fid(&body->fid1, new_inode);
mds_pack_inode2body(body, new_inode);
- mds_pack_md(obd, req->rq_repmsg, 1, body, new_inode,
- MDS_PACK_MD_LOCK);
+ mds_pack_md(obd, req->rq_repmsg, offset + 1, body,
+ new_inode, MDS_PACK_MD_LOCK);
}
}
GOTO(cleanup, rc = -EINVAL);
#endif
- lmm = lustre_msg_buf(req->rq_repmsg, 1, 0);
+ lmm = lustre_msg_buf(req->rq_repmsg, offset + 1, 0);
handle = fsfilt_start_log(obd, de_tgtdir->d_inode, FSFILT_OP_RENAME,
NULL, le32_to_cpu(lmm->lmm_stripe_count));
body->valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |
OBD_MD_FLATIME | OBD_MD_FLMTIME);
} else if (mds_log_op_unlink(obd, new_inode,
- lustre_msg_buf(req->rq_repmsg,1,0),
- req->rq_repmsg->buflens[1],
- lustre_msg_buf(req->rq_repmsg,2,0),
- req->rq_repmsg->buflens[2]) > 0) {
+ lustre_msg_buf(req->rq_repmsg,
+ offset + 1, 0),
+ lustre_msg_buflen(req->rq_repmsg,
+ offset + 1),
+ lustre_msg_buf(req->rq_repmsg,
+ offset + 2, 0),
+ lustre_msg_buflen(req->rq_repmsg,
+ offset + 2))
+ > 0) {
body->valid |= OBD_MD_FLCOOKIE;
}
}
struct mds_body *body)
{
struct inode *inode = de->d_inode;
- int size[2] = {sizeof(*body)}, bufcnt = 1;
char *xattr_name;
- int rc = -EOPNOTSUPP, rc2;
+ int size[3] = { sizeof(struct ptlrpc_body), sizeof(*body) };
+ int bufcnt = 2, rc = -EOPNOTSUPP, rc2;
if (inode == NULL)
return -ENOENT;
if (body->valid & OBD_MD_FLXATTR) {
- xattr_name = lustre_msg_string(req->rq_reqmsg, 1, 0);
+ xattr_name = lustre_msg_string(req->rq_reqmsg, REQ_REC_OFF+1,0);
if (!xattr_name) {
CERROR("can't extract xattr name\n");
return -EFAULT;
if (rc != -ENODATA && rc != -EOPNOTSUPP)
CWARN("get inode %lu EA size error: %d\n",
inode->i_ino, rc);
- bufcnt = 0;
+ bufcnt = 1;
} else {
size[bufcnt++] = min_t(int, body->eadatasize, rc);
}
if (inode == NULL)
GOTO(out, rc = -ENOENT);
- repbody = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*repbody));
+ repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*repbody));
LASSERT(repbody != NULL);
- buflen = lustre_msg_buflen(req->rq_repmsg, 1);
+ buflen = lustre_msg_buflen(req->rq_repmsg, REPLY_REC_OFF + 1);
if (buflen)
- buf = lustre_msg_buf(req->rq_repmsg, 1, buflen);
+ buf = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF + 1, buflen);
if (reqbody->valid & OBD_MD_FLXATTR) {
- xattr_name = lustre_msg_string(req->rq_reqmsg, 1, 0);
+ xattr_name = lustre_msg_string(req->rq_reqmsg, REQ_REC_OFF+1,0);
DEBUG_REQ(D_INODE, req, "getxattr %s\n", xattr_name);
if (inode->i_op && inode->i_op->getxattr) {
struct lvfs_run_ctxt saved;
struct dentry *de;
struct mds_body *body;
- struct lvfs_ucred uc = {NULL,};
+ struct lvfs_ucred uc = { NULL, };
int rc = 0;
ENTRY;
- body = lustre_swab_reqbuf(req, 0, sizeof(*body), lustre_swab_mds_body);
+ body = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*body),
+ lustre_swab_mds_body);
if (body == NULL)
RETURN(-EFAULT);
- rc = mds_init_ucred(&uc, req, 0);
+ rc = mds_init_ucred(&uc, req, REQ_REC_OFF);
if (rc)
GOTO(out_ucred, rc);
__u64 lockpart;
ENTRY;
- body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body));
LASSERT(body);
DEBUG_REQ(D_INODE, req, "setxattr "LPU64"/%u",
lockpart = MDS_INODELOCK_UPDATE;
/* various sanity check for xattr name */
- xattr_name = lustre_msg_string(req->rq_reqmsg, 1, 0);
+ xattr_name = lustre_msg_string(req->rq_reqmsg, REQ_REC_OFF + 1, 0);
if (!xattr_name) {
CERROR("can't extract xattr name\n");
GOTO(out, rc = -EPROTO);
if (body->valid & OBD_MD_FLXATTR) {
if (inode->i_op && inode->i_op->setxattr) {
- if (req->rq_reqmsg->bufcount < 3) {
+ if (lustre_msg_bufcount(req->rq_reqmsg) < 4) {
CERROR("no xattr data supplied\n");
GOTO(out_trans, rc = -EFAULT);
}
- xattrlen = lustre_msg_buflen(req->rq_reqmsg, 2);
+ xattrlen = lustre_msg_buflen(req->rq_reqmsg,
+ REQ_REC_OFF + 2);
if (xattrlen)
- xattr = lustre_msg_buf(req->rq_reqmsg, 2,
- xattrlen);
+ xattr = lustre_msg_buf(req->rq_reqmsg,
+ REQ_REC_OFF+2, xattrlen);
LOCK_INODE_MUTEX(inode);
lock_24kernel();
struct obd_device *obd = req->rq_export->exp_obd;
struct lvfs_run_ctxt saved;
struct mds_body *body;
- struct lvfs_ucred uc = {NULL,};
+ struct lvfs_ucred uc = { NULL, };
int rc;
ENTRY;
- body = lustre_swab_reqbuf(req, 0, sizeof(*body), lustre_swab_mds_body);
+ body = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*body),
+ lustre_swab_mds_body);
if (body == NULL)
RETURN(-EFAULT);
- if (req->rq_reqmsg->bufcount < 2)
+ if (lustre_msg_bufcount(req->rq_reqmsg) < 3)
RETURN(-EFAULT);
- rc = mds_init_ucred(&uc, req, 0);
+ rc = mds_init_ucred(&uc, req, REQ_REC_OFF);
if (rc)
GOTO(out_ucred, rc);
push_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc);
- rc = lustre_pack_reply(req, 0, NULL, NULL);
+ rc = lustre_pack_reply(req, 1, NULL, NULL);
if (rc)
GOTO(out_pop, rc);
{
struct ptlrpc_request *req;
struct mgs_target_info *req_mti, *rep_mti;
- int size = sizeof(*req_mti);
- int rep_size = sizeof(*mti);
+ int size[] = { sizeof(struct ptlrpc_body), sizeof(*req_mti) };
+ int rep_size[] = { sizeof(struct ptlrpc_body), sizeof(*mti) };
int rc;
ENTRY;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MGS_VERSION,
- MGS_TARGET_REG, 1, &size, NULL);
+ MGS_TARGET_REG, 2, size, NULL);
if (!req)
RETURN(-ENOMEM);
- req_mti = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*req_mti));
+ req_mti = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*req_mti));
if (!req_mti)
RETURN(-ENOMEM);
memcpy(req_mti, mti, sizeof(*req_mti));
- req->rq_replen = lustre_msg_size(1, &rep_size);
+ ptlrpc_req_set_repsize(req, 2, rep_size);
CDEBUG(D_MGC, "register %s\n", mti->mti_svname);
rc = ptlrpc_queue_wait(req);
if (!rc) {
- rep_mti = lustre_swab_repbuf(req, 0, sizeof(*rep_mti),
+ rep_mti = lustre_swab_repbuf(req, REPLY_REC_OFF,
+ sizeof(*rep_mti),
lustre_swab_mgs_target_info);
memcpy(mti, rep_mti, sizeof(*rep_mti));
CDEBUG(D_MGC, "register %s got index = %d\n",
struct obd_device *obd = req->rq_export->exp_obd;
struct lustre_handle lockh;
struct mgs_target_info *mti, *rep_mti;
- int rep_size = sizeof(*mti);
+ int rep_size[] = { sizeof(struct ptlrpc_body), sizeof(*mti) };
int rc = 0, lockrc;
ENTRY;
- mti = lustre_swab_reqbuf(req, 0, sizeof(*mti),
+ mti = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*mti),
lustre_swab_mgs_target_info);
if (!(mti->mti_flags & (LDD_F_WRITECONF | LDD_F_UPGRADE14 |
out_nolock:
CDEBUG(D_MGS, "replying with %s, index=%d, rc=%d\n", mti->mti_svname,
mti->mti_stripe_index, rc);
- lustre_pack_reply(req, 1, &rep_size, NULL);
+ lustre_pack_reply(req, 2, rep_size, NULL);
/* send back the whole mti in the reply */
- rep_mti = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*rep_mti));
+ rep_mti = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*rep_mti));
memcpy(rep_mti, mti, sizeof(*rep_mti));
RETURN(rc);
}
int mgs_handle(struct ptlrpc_request *req)
{
int fail = OBD_FAIL_MGS_ALL_REPLY_NET;
- int rc = 0;
+ int opc, rc = 0;
ENTRY;
OBD_FAIL_RETURN(OBD_FAIL_MGS_ALL_REQUEST_NET | OBD_FAIL_ONCE, 0);
LASSERT(current->journal_info == NULL);
- if (req->rq_reqmsg->opc != MGS_CONNECT) {
+ opc = lustre_msg_get_opc(req->rq_reqmsg);
+ if (opc != MGS_CONNECT) {
if (req->rq_export == NULL) {
CERROR("lustre_mgs: operation %d on unconnected MGS\n",
- req->rq_reqmsg->opc);
+ opc);
req->rq_status = -ENOTCONN;
GOTO(out, rc = -ENOTCONN);
}
}
- switch (req->rq_reqmsg->opc) {
+ switch (opc) {
case MGS_CONNECT:
DEBUG_REQ(D_MGS, req, "connect");
rc = target_handle_connect(req, mgs_handle);
- if (!rc && (req->rq_reqmsg->conn_cnt > 1))
+ if (!rc && (lustre_msg_get_conn_cnt(req->rq_reqmsg) > 1))
/* Make clients trying to reconnect after a MGS restart
happy; also requires obd_replayable */
lustre_msg_add_op_flags(req->rq_repmsg,
LASSERT(current->journal_info == NULL);
- CDEBUG(D_CONFIG | (rc?D_ERROR:0), "MGS handle cmd=%d rc=%d\n",
- req->rq_reqmsg->opc, rc);
+ CDEBUG(D_CONFIG | (rc?D_ERROR:0), "MGS handle cmd=%d rc=%d\n", opc, rc);
out:
target_send_reply(req, rc, fail);
CFS_INIT_LIST_HEAD(&imp->imp_handle.h_link);
class_handle_hash(&imp->imp_handle, import_handle_addref);
+ /* the default magic is V1, will be used in connect RPC, and
+ * then adjusted according to the flags in request/reply. */
+ imp->imp_msg_magic = LUSTRE_MSG_MAGIC_V1;
+
return imp;
}
EXPORT_SYMBOL(class_new_import);
int rc;
int size = sizeof(*idarray) * count;
loff_t off = 0;
+ ENTRY;
if (!count)
- return (0);
+ RETURN(0);
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
file = filp_open(name, O_RDWR | O_CREAT | O_LARGEFILE, 0700);
GOTO(out, rc);
}
+ EXIT;
out:
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
if (file && !IS_ERR(file))
rc = filp_close(file, 0);
- RETURN(rc);
+ return rc;
}
EXPORT_SYMBOL(llog_get_cat_list);
l_wait_event(waitq, 0, &lwi);
}
if (atomic_read(&mnt->mnt_count)) {
- CERROR("Mount is still busy, giving up.\n");
+ CERROR("Mount %p is still busy(%d refs), giving up.\n",
+ mnt, atomic_read(&mnt->mnt_count));
}
}
struct ldlm_reply *rep;
struct list_head *tmp;
ldlm_error_t err;
- int tmpflags = 0, rc, repsize[2] = {sizeof(*rep), sizeof(*reply_lvb)};
- int only_liblustre = 0;
+ int rc, tmpflags = 0, only_liblustre = 0;
+ int repsize[3] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+ [DLM_LOCKREPLY_OFF] = sizeof(*rep),
+ [DLM_REPLY_REC_OFF] = sizeof(*reply_lvb) };
ENTRY;
policy = ldlm_get_processing_policy(res);
LASSERT(policy != NULL);
LASSERT(req != NULL);
- rc = lustre_pack_reply(req, 2, repsize, NULL);
+ rc = lustre_pack_reply(req, 3, repsize, NULL);
if (rc)
RETURN(req->rq_status = rc);
- rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*rep));
+ rep = lustre_msg_buf(req->rq_repmsg, DLM_LOCKREPLY_OFF, sizeof(*rep));
LASSERT(rep != NULL);
- reply_lvb = lustre_msg_buf(req->rq_repmsg, 1, sizeof(*reply_lvb));
+ reply_lvb = lustre_msg_buf(req->rq_repmsg, DLM_REPLY_REC_OFF,
+ sizeof(*reply_lvb));
LASSERT(reply_lvb != NULL);
//fixup_handle_for_resent_req(req, lock, &lockh);
ENTRY;
if (req->rq_repmsg) {
- body = lustre_swab_repbuf(req, 0, sizeof(*body),
+ body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
lustre_swab_ost_body);
if (body == NULL && rc == 0)
rc = -EPROTO;
spin_unlock(&oscc->oscc_lock);
DEBUG_REQ(D_ERROR, req,
"unknown rc %d from async create: failing oscc", rc);
- ptlrpc_fail_import(req->rq_import, req->rq_reqmsg->conn_cnt);
+ ptlrpc_fail_import(req->rq_import,
+ lustre_msg_get_conn_cnt(req->rq_reqmsg));
} else {
if (rc == 0) {
oscc->oscc_flags &= ~OSCC_FLAG_LOW;
{
struct ptlrpc_request *request;
struct ost_body *body;
- int size = sizeof(*body);
+ int size[] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
spin_lock(&oscc->oscc_lock);
spin_unlock(&oscc->oscc_lock);
request = ptlrpc_prep_req(oscc->oscc_obd->u.cli.cl_import,
- LUSTRE_OST_VERSION, OST_CREATE, 1,
- &size, NULL);
+ LUSTRE_OST_VERSION, OST_CREATE, 2,
+ size, NULL);
if (request == NULL) {
spin_lock(&oscc->oscc_lock);
oscc->oscc_flags &= ~OSCC_FLAG_CREATING;
}
request->rq_request_portal = OST_CREATE_PORTAL; //XXX FIXME bug 249
- body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof(*body));
+ body = lustre_msg_buf(request->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
spin_lock(&oscc->oscc_lock);
body->oa.o_id = oscc->oscc_last_id + oscc->oscc_grow_count;
CDEBUG(D_HA, "preallocating through id "LPU64" (last used "LPU64")\n",
body->oa.o_id, oscc->oscc_next_id);
- request->rq_replen = lustre_msg_size(1, &size);
+ ptlrpc_req_set_repsize(request, 2, size);
request->rq_async_args.pointer_arg[0] = oscc;
request->rq_interpret_reply = osc_interpret_create;
if (rc != 0)
RETURN(rc);
- body = lustre_swab_repbuf(req, 0, sizeof(*body), lustre_swab_ost_body);
+ body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
+ lustre_swab_ost_body);
if (body) {
CDEBUG(D_INODE, "mode: %o\n", body->oa.o_mode);
memcpy(aa->aa_oa, &body->oa, sizeof(*aa->aa_oa));
struct lov_stripe_md *md,
struct ptlrpc_request_set *set)
{
- struct ptlrpc_request *request;
+ struct ptlrpc_request *req;
struct ost_body *body;
- int size = sizeof(*body);
+ int size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
struct osc_getattr_async_args *aa;
ENTRY;
- request = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
- OST_GETATTR, 1, &size, NULL);
- if (!request)
+ req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
+ OST_GETATTR, 2, size,NULL);
+ if (!req)
RETURN(-ENOMEM);
- body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
memcpy(&body->oa, oa, sizeof(*oa));
- request->rq_replen = lustre_msg_size(1, &size);
- request->rq_interpret_reply = osc_getattr_interpret;
+ ptlrpc_req_set_repsize(req, 2, size);
+ req->rq_interpret_reply = osc_getattr_interpret;
- LASSERT (sizeof (*aa) <= sizeof (request->rq_async_args));
- aa = (struct osc_getattr_async_args *)&request->rq_async_args;
+ LASSERT (sizeof (*aa) <= sizeof (req->rq_async_args));
+ aa = (struct osc_getattr_async_args *)&req->rq_async_args;
aa->aa_oa = oa;
- ptlrpc_set_add_req (set, request);
+ ptlrpc_set_add_req(set, req);
RETURN (0);
}
static int osc_getattr(struct obd_export *exp, struct obdo *oa,
struct lov_stripe_md *md)
{
- struct ptlrpc_request *request;
+ struct ptlrpc_request *req;
struct ost_body *body;
- int rc, size = sizeof(*body);
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
- request = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
- OST_GETATTR, 1, &size, NULL);
- if (!request)
+ req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
+ OST_GETATTR, 2, size, NULL);
+ if (!req)
RETURN(-ENOMEM);
- body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
memcpy(&body->oa, oa, sizeof(*oa));
- request->rq_replen = lustre_msg_size(1, &size);
+ ptlrpc_req_set_repsize(req, 2, size);
- rc = ptlrpc_queue_wait(request);
+ rc = ptlrpc_queue_wait(req);
if (rc) {
CERROR("%s failed: rc = %d\n", __FUNCTION__, rc);
GOTO(out, rc);
}
- body = lustre_swab_repbuf(request, 0, sizeof (*body),
+ body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
lustre_swab_ost_body);
if (body == NULL) {
CERROR ("can't unpack ost_body\n");
EXIT;
out:
- ptlrpc_req_finished(request);
+ ptlrpc_req_finished(req);
return rc;
}
static int osc_setattr(struct obd_export *exp, struct obdo *oa,
struct lov_stripe_md *md, struct obd_trans_info *oti)
{
- struct ptlrpc_request *request;
+ struct ptlrpc_request *req;
struct ost_body *body;
- int rc, size = sizeof(*body);
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
- request = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
- OST_SETATTR, 1, &size, NULL);
- if (!request)
+ req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
+ OST_SETATTR, 2, size, NULL);
+ if (!req)
RETURN(-ENOMEM);
- body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof(*body));
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
memcpy(&body->oa, oa, sizeof(*oa));
- request->rq_replen = lustre_msg_size(1, &size);
+ ptlrpc_req_set_repsize(req, 2, size);
- rc = ptlrpc_queue_wait(request);
+ rc = ptlrpc_queue_wait(req);
if (rc)
GOTO(out, rc);
- body = lustre_swab_repbuf(request, 0, sizeof(*body),
+ body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
lustre_swab_ost_body);
if (body == NULL)
GOTO(out, rc = -EPROTO);
EXIT;
out:
- ptlrpc_req_finished(request);
+ ptlrpc_req_finished(req);
RETURN(0);
}
struct lov_stripe_md *md,
struct obd_trans_info *oti)
{
- struct ptlrpc_request *request;
+ struct ptlrpc_request *req;
struct ost_body *body;
- int rc = 0, size = sizeof(*body);
+ int rc = 0, size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
LASSERT(oti);
- request = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
- OST_SETATTR, 1, &size, NULL);
- if (!request)
+ req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
+ OST_SETATTR, 2, size, NULL);
+ if (!req)
RETURN(-ENOMEM);
- body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof(*body));
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
if (oa->o_valid & OBD_MD_FLCOOKIE)
memcpy(obdo_logcookie(oa), oti->oti_logcookies,
sizeof(*oti->oti_logcookies));
memcpy(&body->oa, oa, sizeof(*oa));
- request->rq_replen = lustre_msg_size(1, &size);
+ ptlrpc_req_set_repsize(req, 2, size);
/* do mds to ost setattr asynchronouly */
- ptlrpcd_add_req(request);
+ ptlrpcd_add_req(req);
RETURN(rc);
}
int osc_real_create(struct obd_export *exp, struct obdo *oa,
struct lov_stripe_md **ea, struct obd_trans_info *oti)
{
- struct ptlrpc_request *request;
+ struct ptlrpc_request *req;
struct ost_body *body;
struct lov_stripe_md *lsm;
- int rc, size = sizeof(*body);
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
LASSERT(oa);
RETURN(rc);
}
- request = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
- OST_CREATE, 1, &size, NULL);
- if (!request)
+ req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
+ OST_CREATE, 2, size, NULL);
+ if (!req)
GOTO(out, rc = -ENOMEM);
- body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
memcpy(&body->oa, oa, sizeof(body->oa));
- request->rq_replen = lustre_msg_size(1, &size);
+ ptlrpc_req_set_repsize(req, 2, size);
if (oa->o_valid & OBD_MD_FLINLINE) {
LASSERT((oa->o_valid & OBD_MD_FLFLAGS) &&
oa->o_flags == OBD_FL_DELORPHAN);
- DEBUG_REQ(D_HA, request,
+ DEBUG_REQ(D_HA, req,
"delorphan from OST integration");
- /* Don't resend the delorphan request */
- request->rq_no_resend = request->rq_no_delay = 1;
+ /* Don't resend the delorphan req */
+ req->rq_no_resend = req->rq_no_delay = 1;
}
- rc = ptlrpc_queue_wait(request);
+ rc = ptlrpc_queue_wait(req);
if (rc)
GOTO(out_req, rc);
- body = lustre_swab_repbuf(request, 0, sizeof(*body),
+ body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
lustre_swab_ost_body);
if (body == NULL) {
CERROR ("can't unpack ost_body\n");
*ea = lsm;
if (oti != NULL) {
- oti->oti_transno = request->rq_repmsg->transno;
+ oti->oti_transno = lustre_msg_get_transno(req->rq_repmsg);
if (oa->o_valid & OBD_MD_FLCOOKIE) {
if (!oti->oti_logcookies)
}
}
- CDEBUG(D_HA, "transno: "LPD64"\n", request->rq_repmsg->transno);
+ CDEBUG(D_HA, "transno: "LPD64"\n",
+ lustre_msg_get_transno(req->rq_repmsg));
EXIT;
out_req:
- ptlrpc_req_finished(request);
+ ptlrpc_req_finished(req);
out:
if (rc && !*ea)
obd_free_memmd(exp, &lsm);
struct lov_stripe_md *md, obd_size start,
obd_size end, struct obd_trans_info *oti)
{
- struct ptlrpc_request *request;
+ struct ptlrpc_request *req;
struct ost_body *body;
- int rc, size = sizeof(*body);
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
if (!oa) {
RETURN(-EINVAL);
}
- request = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
- OST_PUNCH, 1, &size, NULL);
- if (!request)
+ req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
+ OST_PUNCH, 2, size, NULL);
+ if (!req)
RETURN(-ENOMEM);
- body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
memcpy(&body->oa, oa, sizeof(*oa));
/* overload the size and blocks fields in the oa with start/end */
body->oa.o_blocks = end;
body->oa.o_valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS);
- request->rq_replen = lustre_msg_size(1, &size);
+ ptlrpc_req_set_repsize(req, 2, size);
- rc = ptlrpc_queue_wait(request);
+ rc = ptlrpc_queue_wait(req);
if (rc)
GOTO(out, rc);
- body = lustre_swab_repbuf (request, 0, sizeof (*body),
- lustre_swab_ost_body);
+ body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
+ lustre_swab_ost_body);
if (body == NULL) {
CERROR ("can't unpack ost_body\n");
GOTO (out, rc = -EPROTO);
EXIT;
out:
- ptlrpc_req_finished(request);
+ ptlrpc_req_finished(req);
return rc;
}
static int osc_sync(struct obd_export *exp, struct obdo *oa,
struct lov_stripe_md *md, obd_size start, obd_size end)
{
- struct ptlrpc_request *request;
+ struct ptlrpc_request *req;
struct ost_body *body;
- int rc, size = sizeof(*body);
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
if (!oa) {
RETURN(-EINVAL);
}
- request = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
- OST_SYNC, 1, &size, NULL);
- if (!request)
+ req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
+ OST_SYNC, 2, size, NULL);
+ if (!req)
RETURN(-ENOMEM);
- body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
memcpy(&body->oa, oa, sizeof(*oa));
/* overload the size and blocks fields in the oa with start/end */
body->oa.o_blocks = end;
body->oa.o_valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS);
- request->rq_replen = lustre_msg_size(1, &size);
+ ptlrpc_req_set_repsize(req, 2, size);
- rc = ptlrpc_queue_wait(request);
+ rc = ptlrpc_queue_wait(req);
if (rc)
GOTO(out, rc);
- body = lustre_swab_repbuf(request, 0, sizeof(*body),
+ body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
lustre_swab_ost_body);
if (body == NULL) {
CERROR ("can't unpack ost_body\n");
EXIT;
out:
- ptlrpc_req_finished(request);
+ ptlrpc_req_finished(req);
return rc;
}
struct lov_stripe_md *ea, struct obd_trans_info *oti,
struct obd_export *md_export)
{
- struct ptlrpc_request *request;
+ struct ptlrpc_request *req;
struct ost_body *body;
- int rc, size = sizeof(*body);
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
if (!oa) {
RETURN(-EINVAL);
}
- request = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
- OST_DESTROY, 1, &size, NULL);
- if (!request)
+ req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
+ OST_DESTROY, 2, size, NULL);
+ if (!req)
RETURN(-ENOMEM);
- body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
if (oti != NULL && oa->o_valid & OBD_MD_FLCOOKIE) {
memcpy(obdo_logcookie(oa), oti->oti_logcookies,
}
memcpy(&body->oa, oa, sizeof(*oa));
- request->rq_replen = lustre_msg_size(1, &size);
+ ptlrpc_req_set_repsize(req, 2, size);
- rc = ptlrpc_queue_wait(request);
+ rc = ptlrpc_queue_wait(req);
if (rc == -ENOENT)
rc = 0;
if (rc)
GOTO(out, rc);
- body = lustre_swab_repbuf(request, 0, sizeof(*body),
+ body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
lustre_swab_ost_body);
if (body == NULL) {
CERROR ("Can't unpack body\n");
EXIT;
out:
- ptlrpc_req_finished(request);
+ ptlrpc_req_finished(req);
return rc;
}
}
}
-static int check_write_rcs(struct ptlrpc_request *request,
+static int check_write_rcs(struct ptlrpc_request *req,
int requested_nob, int niocount,
obd_count page_count, struct brw_page **pga)
{
int *remote_rcs, i;
/* return error if any niobuf was in error */
- remote_rcs = lustre_swab_repbuf(request, 1,
+ remote_rcs = lustre_swab_repbuf(req, REQ_REC_OFF + 1,
sizeof(*remote_rcs) * niocount, NULL);
if (remote_rcs == NULL) {
CERROR("Missing/short RC vector on BRW_WRITE reply\n");
return(-EPROTO);
}
- if (lustre_msg_swabbed(request->rq_repmsg))
+ if (lustre_msg_swabbed(req->rq_repmsg))
for (i = 0; i < niocount; i++)
__swab32s(&remote_rcs[i]);
if (remote_rcs[i] != 0) {
CERROR("rc[%d] invalid (%d) req %p\n",
- i, remote_rcs[i], request);
+ i, remote_rcs[i], req);
return(-EPROTO);
}
}
- if (request->rq_bulk->bd_nob_transferred != requested_nob) {
+ if (req->rq_bulk->bd_nob_transferred != requested_nob) {
CERROR("Unexpected # bytes transferred: %d (requested %d)\n",
- requested_nob, request->rq_bulk->bd_nob_transferred);
+ requested_nob, req->rq_bulk->bd_nob_transferred);
return(-EPROTO);
}
struct ost_body *body;
struct obd_ioobj *ioobj;
struct niobuf_remote *niobuf;
- int niocount;
- int size[3];
- int i;
- int requested_nob;
- int opc;
- int rc;
+ int size[4] = { sizeof(struct ptlrpc_body), sizeof(*body) };
+ int niocount, i, requested_nob, opc, rc;
struct ptlrpc_request_pool *pool;
ENTRY;
if (!can_merge_pages(pga[i - 1], pga[i]))
niocount++;
- size[0] = sizeof(*body);
- size[1] = sizeof(*ioobj);
- size[2] = niocount * sizeof(*niobuf);
+ size[REQ_REC_OFF + 1] = sizeof(*ioobj);
+ size[REQ_REC_OFF + 2] = niocount * sizeof(*niobuf);
OBD_FAIL_RETURN(OBD_FAIL_OSC_BRW_PREP_REQ, -ENOMEM);
- req = ptlrpc_prep_req_pool(imp, LUSTRE_OST_VERSION, opc, 3,
- size, NULL, pool);
+ req = ptlrpc_prep_req_pool(imp, LUSTRE_OST_VERSION, opc, 4, size, NULL,
+ pool);
if (req == NULL)
RETURN (-ENOMEM);
GOTO(out, rc = -ENOMEM);
/* NB request now owns desc and will free it when it gets freed */
- body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body));
- ioobj = lustre_msg_buf(req->rq_reqmsg, 1, sizeof(*ioobj));
- niobuf = lustre_msg_buf(req->rq_reqmsg, 2, niocount * sizeof(*niobuf));
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
+ ioobj = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 1, sizeof(*ioobj));
+ niobuf = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 2,
+ niocount * sizeof(*niobuf));
memcpy(&body->oa, oa, sizeof(*oa));
}
LASSERT((void *)(niobuf - niocount) ==
- lustre_msg_buf(req->rq_reqmsg, 2, niocount * sizeof(*niobuf)));
+ lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 2,
+ niocount * sizeof(*niobuf)));
osc_announce_cached(cli, &body->oa, opc == OST_WRITE ? requested_nob:0);
- /* size[0] still sizeof (*body) */
+ /* size[REQ_REC_OFF] still sizeof (*body) */
if (opc == OST_WRITE) {
if (unlikely(cli->cl_checksum)) {
body->oa.o_valid |= OBD_MD_FLCKSUM;
oa->o_cksum = body->oa.o_cksum;
}
/* 1 RC per niobuf */
- size[1] = sizeof(__u32) * niocount;
- req->rq_replen = lustre_msg_size(2, size);
+ size[REPLY_REC_OFF + 1] = sizeof(__u32) * niocount;
+ ptlrpc_req_set_repsize(req, 3, size);
} else {
if (unlikely(cli->cl_checksum))
body->oa.o_valid |= OBD_MD_FLCKSUM;
/* 1 RC for the whole I/O */
- req->rq_replen = lustre_msg_size(1, size);
+ ptlrpc_req_set_repsize(req, 2, size);
}
*niocountp = niocount;
RETURN(rc);
LASSERTF(req->rq_repmsg != NULL, "rc = %d\n", rc);
- body = lustre_swab_repbuf(req, 0, sizeof(*body), lustre_swab_ost_body);
+ body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
+ lustre_swab_ost_body);
if (body == NULL) {
CERROR ("Can't unpack body\n");
RETURN(-EPROTO);
}
/* set/clear over quota flag for a uid/gid */
- if (req->rq_reqmsg->opc == OST_WRITE &&
+ if (lustre_msg_get_opc(req->rq_reqmsg) == OST_WRITE &&
body->oa.o_valid & (OBD_MD_FLUSRQUOTA | OBD_MD_FLGRPQUOTA))
lquota_setdq(quota_interface, cli, body->oa.o_uid,
body->oa.o_gid, body->oa.o_valid,
osc_update_grant(cli, body);
memcpy(oa, &body->oa, sizeof(*oa));
- if (req->rq_reqmsg->opc == OST_WRITE) {
+ if (lustre_msg_get_opc(req->rq_reqmsg) == OST_WRITE) {
if (rc > 0) {
CERROR ("Unexpected +ve rc %d\n", rc);
RETURN(-EPROTO);
{
int requested_nob;
int niocount;
- struct ptlrpc_request *request;
+ struct ptlrpc_request *req;
int rc;
ENTRY;
restart_bulk:
rc = osc_brw_prep_request(cmd, class_exp2cliimp(exp), oa, lsm,
page_count, pga, &requested_nob, &niocount,
- &request);
+ &req);
if (rc != 0)
return (rc);
- rc = ptlrpc_queue_wait(request);
+ rc = ptlrpc_queue_wait(req);
- if (rc == -ETIMEDOUT && request->rq_resend) {
- DEBUG_REQ(D_HA, request, "BULK TIMEOUT");
- ptlrpc_req_finished(request);
+ if (rc == -ETIMEDOUT && req->rq_resend) {
+ DEBUG_REQ(D_HA, req, "BULK TIMEOUT");
+ ptlrpc_req_finished(req);
goto restart_bulk;
}
- rc = osc_brw_fini_request(request, oa, requested_nob, niocount,
+ rc = osc_brw_fini_request(req, oa, requested_nob, niocount,
page_count, pga, rc);
- ptlrpc_req_finished(request);
+ ptlrpc_req_finished(req);
RETURN (rc);
}
-static int brw_interpret(struct ptlrpc_request *request,
+static int brw_interpret(struct ptlrpc_request *req,
struct osc_brw_async_args *aa, int rc)
{
struct obdo *oa = aa->aa_oa;
struct brw_page **pga = aa->aa_ppga;
ENTRY;
- rc = osc_brw_fini_request(request, oa, requested_nob, niocount,
+ rc = osc_brw_fini_request(req, oa, requested_nob, niocount,
page_count, pga, rc);
RETURN (rc);
}
struct lov_stripe_md *lsm, obd_count page_count,
struct brw_page **pga, struct ptlrpc_request_set *set)
{
- struct ptlrpc_request *request;
+ struct ptlrpc_request *req;
int requested_nob;
int nio_count;
struct osc_brw_async_args *aa;
rc = osc_brw_prep_request(cmd, class_exp2cliimp(exp), oa, lsm,
page_count, pga, &requested_nob, &nio_count,
- &request);
+ &req);
if (rc == 0) {
- LASSERT(sizeof(*aa) <= sizeof(request->rq_async_args));
- aa = (struct osc_brw_async_args *)&request->rq_async_args;
+ LASSERT(sizeof(*aa) <= sizeof(req->rq_async_args));
+ aa = (struct osc_brw_async_args *)&req->rq_async_args;
aa->aa_oa = oa;
aa->aa_requested_nob = requested_nob;
aa->aa_nio_count = nio_count;
aa->aa_page_count = page_count;
aa->aa_ppga = pga;
- request->rq_interpret_reply = brw_interpret;
- ptlrpc_set_add_req(set, request);
+ req->rq_interpret_reply = brw_interpret;
+ ptlrpc_set_add_req(set, req);
}
RETURN (rc);
}
EXIT;
}
-static int brw_interpret_oap(struct ptlrpc_request *request,
+static int brw_interpret_oap(struct ptlrpc_request *req,
struct osc_brw_async_args *aa, int rc)
{
struct osc_async_page *oap;
struct list_head *pos, *n;
ENTRY;
- rc = osc_brw_fini_request(request, aa->aa_oa, aa->aa_requested_nob,
+ rc = osc_brw_fini_request(req, aa->aa_oa, aa->aa_requested_nob,
aa->aa_nio_count, aa->aa_page_count,
aa->aa_ppga, rc);
- CDEBUG(D_INODE, "request %p aa %p rc %d\n", request, aa, rc);
+ CDEBUG(D_INODE, "request %p aa %p rc %d\n", req, aa, rc);
cli = aa->aa_cli;
/* We need to decrement before osc_ap_completion->osc_wake_cache_waiters
* is called so we know whether to go to sync BRWs or wait for more
* RPCs to complete */
- if (request->rq_reqmsg->opc == OST_WRITE)
+ if (lustre_msg_get_opc(req->rq_reqmsg) == OST_WRITE)
cli->cl_w_in_flight--;
else
cli->cl_r_in_flight--;
static int osc_send_oap_rpc(struct client_obd *cli, struct lov_oinfo *loi,
int cmd, struct loi_oap_pages *lop)
{
- struct ptlrpc_request *request;
+ struct ptlrpc_request *req;
obd_count page_count = 0;
struct list_head *tmp, *pos;
struct osc_async_page *oap = NULL;
client_obd_list_unlock(&cli->cl_loi_list_lock);
- request = osc_build_req(cli, &rpc_list, page_count, cmd);
- if (IS_ERR(request)) {
+ req = osc_build_req(cli, &rpc_list, page_count, cmd);
+ if (IS_ERR(req)) {
/* this should happen rarely and is pretty bad, it makes the
* pending list not follow the dirty order */
client_obd_list_lock(&cli->cl_loi_list_lock);
oap->oap_count);
continue;
}
- osc_ap_completion(cli, NULL, oap, 0, PTR_ERR(request));
+ osc_ap_completion(cli, NULL, oap, 0, PTR_ERR(req));
}
loi_list_maint(cli, loi);
- RETURN(PTR_ERR(request));
+ RETURN(PTR_ERR(req));
}
- LASSERT(sizeof(*aa) <= sizeof(request->rq_async_args));
- aa = (struct osc_brw_async_args *)&request->rq_async_args;
+ LASSERT(sizeof(*aa) <= sizeof(req->rq_async_args));
+ aa = (struct osc_brw_async_args *)&req->rq_async_args;
CFS_INIT_LIST_HEAD(&aa->aa_oaps);
list_splice(&rpc_list, &aa->aa_oaps);
CFS_INIT_LIST_HEAD(&rpc_list);
oap = list_entry(pos, struct osc_async_page, oap_rpc_item);
if (oap->oap_interrupted) {
CDEBUG(D_INODE, "oap %p in req %p interrupted\n",
- oap, request);
- ptlrpc_mark_interrupted(request);
+ oap, req);
+ ptlrpc_mark_interrupted(req);
break;
}
}
CDEBUG(D_INODE, "req %p: %d pages, aa %p. now %dr/%dw in flight\n",
- request, page_count, aa, cli->cl_r_in_flight,
+ req, page_count, aa, cli->cl_r_in_flight,
cli->cl_w_in_flight);
- oap->oap_request = ptlrpc_request_addref(request);
- request->rq_interpret_reply = brw_interpret_oap;
- ptlrpcd_add_req(request);
+ oap->oap_request = ptlrpc_request_addref(req);
+ req->rq_interpret_reply = brw_interpret_oap;
+ ptlrpcd_add_req(req);
RETURN(1);
}
struct lov_stripe_md *lsm, obd_count page_count,
struct brw_page *pga)
{
- struct ptlrpc_request *request = NULL;
+ struct ptlrpc_request *req = NULL;
struct ost_body *body;
struct niobuf_remote *nioptr;
struct obd_ioobj *iooptr;
- int rc, size[3] = {sizeof(*body)}, mapped = 0;
struct obd_import *imp = class_exp2cliimp(exp);
- int swab;
+ int size[4] = { sizeof(struct ptlrpc_body), sizeof(*body)};
+ int swab, mapped = 0, rc;
ENTRY;
/* XXX does not handle 'new' brw protocol */
- size[1] = sizeof(struct obd_ioobj);
- size[2] = page_count * sizeof(*nioptr);
+ size[REQ_REC_OFF + 1] = sizeof(struct obd_ioobj);
+ size[REQ_REC_OFF + 2] = page_count * sizeof(*nioptr);
- request = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
- OST_SAN_READ, 3, size, NULL);
- if (!request)
+ req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
+ OST_SAN_READ, 4, size, NULL);
+ if (!req)
RETURN(-ENOMEM);
/* FIXME bug 249 */
/* See bug 7198 */
if (imp->imp_connect_data.ocd_connect_flags & OBD_CONNECT_REQPORTAL)
- request->rq_request_portal = OST_IO_PORTAL;
+ req->rq_request_portal = OST_IO_PORTAL;
- body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof(*body));
- iooptr = lustre_msg_buf(request->rq_reqmsg, 1, sizeof(*iooptr));
- nioptr = lustre_msg_buf(request->rq_reqmsg, 2,
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
+ iooptr = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 1,
+ sizeof(*iooptr));
+ nioptr = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 2,
sizeof(*nioptr) * page_count);
memcpy(&body->oa, oa, sizeof(body->oa));
nioptr->flags = pga[mapped].flag;
}
- size[1] = page_count * sizeof(*nioptr);
- request->rq_replen = lustre_msg_size(2, size);
+ size[REPLY_REC_OFF + 1] = page_count * sizeof(*nioptr);
+ ptlrpc_req_set_repsize(req, 3, size);
- rc = ptlrpc_queue_wait(request);
+ rc = ptlrpc_queue_wait(req);
if (rc)
GOTO(out_req, rc);
- body = lustre_swab_repbuf(request, 0, sizeof(*body),
+ body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
lustre_swab_ost_body);
if (body == NULL) {
CERROR("Can't unpack body\n");
memcpy(oa, &body->oa, sizeof(*oa));
- swab = lustre_msg_swabbed(request->rq_repmsg);
- LASSERT_REPSWAB(request, 1);
- nioptr = lustre_msg_buf(request->rq_repmsg, 1, size[1]);
+ swab = lustre_msg_swabbed(req->rq_repmsg);
+ LASSERT_REPSWAB(req, REPLY_REC_OFF + 1);
+ nioptr = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF + 1,
+ size[REPLY_REC_OFF + 1]);
if (!nioptr) {
/* nioptr missing or short */
GOTO(out_req, rc = -EPROTO);
}
out_req:
- ptlrpc_req_finished(request);
+ ptlrpc_req_finished(req);
RETURN(rc);
}
struct lov_stripe_md *lsm, obd_count page_count,
struct brw_page *pga)
{
- struct ptlrpc_request *request = NULL;
+ struct ptlrpc_request *req = NULL;
struct ost_body *body;
struct niobuf_remote *nioptr;
struct obd_ioobj *iooptr;
struct obd_import *imp = class_exp2cliimp(exp);
- int rc, size[3] = {sizeof(*body)}, mapped = 0;
- int swab;
+ int size[4] = { sizeof(struct ptlrpc_body), sizeof(*body) };
+ int swab, mapped = 0, rc;
ENTRY;
- size[1] = sizeof(struct obd_ioobj);
- size[2] = page_count * sizeof(*nioptr);
+ size[REQ_REC_OFF + 1] = sizeof(struct obd_ioobj);
+ size[REQ_REC_OFF + 2] = page_count * sizeof(*nioptr);
- request = ptlrpc_prep_req_pool(class_exp2cliimp(exp),
- LUSTRE_OST_VERSION, OST_SAN_WRITE,
- 3, size, NULL, imp->imp_rq_pool);
- if (!request)
+ req = ptlrpc_prep_req_pool(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
+ OST_SAN_WRITE, 4, size, NULL, imp->imp_rq_pool);
+ if (!req)
RETURN(-ENOMEM);
/* FIXME bug 249 */
/* See bug 7198 */
if (imp->imp_connect_data.ocd_connect_flags & OBD_CONNECT_REQPORTAL)
- request->rq_request_portal = OST_IO_PORTAL;
+ req->rq_request_portal = OST_IO_PORTAL;
- body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof (*body));
- iooptr = lustre_msg_buf(request->rq_reqmsg, 1, sizeof (*iooptr));
- nioptr = lustre_msg_buf(request->rq_reqmsg, 2,
- sizeof (*nioptr) * page_count);
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
+ iooptr = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 1,
+ sizeof(*iooptr));
+ nioptr = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 2,
+ sizeof(*nioptr) * page_count);
memcpy(&body->oa, oa, sizeof(body->oa));
nioptr->flags = pga[mapped].flag;
}
- size[1] = page_count * sizeof(*nioptr);
- request->rq_replen = lustre_msg_size(2, size);
+ size[REPLY_REC_OFF + 1] = page_count * sizeof(*nioptr);
+ ptlrpc_req_set_repsize(req, 3, size);
- rc = ptlrpc_queue_wait(request);
+ rc = ptlrpc_queue_wait(req);
if (rc)
GOTO(out_req, rc);
- swab = lustre_msg_swabbed (request->rq_repmsg);
- LASSERT_REPSWAB (request, 1);
- nioptr = lustre_msg_buf(request->rq_repmsg, 1, size[1]);
+ swab = lustre_msg_swabbed (req->rq_repmsg);
+ LASSERT_REPSWAB(req, REPLY_REC_OFF + 1);
+ nioptr = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF + 1,
+ size[REPLY_REC_OFF + 1]);
if (!nioptr) {
CERROR("absent/short niobuf array\n");
GOTO(out_req, rc = -EPROTO);
}
out_req:
- ptlrpc_req_finished(request);
+ ptlrpc_req_finished(req);
RETURN(rc);
}
no_match:
if (*flags & LDLM_FL_HAS_INTENT) {
- int size[2] = {sizeof(struct ldlm_request), sizeof(lvb)};
+ int size[3] = {
+ [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+ [DLM_LOCKREQ_OFF] = sizeof(struct ldlm_request) };
- req = ptlrpc_prep_req(class_exp2cliimp(exp),
- LUSTRE_DLM_VERSION, LDLM_ENQUEUE, 1,
- size, NULL);
+ req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_DLM_VERSION,
+ LDLM_ENQUEUE, 2, size, NULL);
if (req == NULL)
RETURN(-ENOMEM);
- size[0] = sizeof(*rep);
- req->rq_replen = lustre_msg_size(2, size);
+ size[DLM_LOCKREPLY_OFF] = sizeof(*rep);
+ size[DLM_REPLY_REC_OFF] = sizeof(lvb);
+ ptlrpc_req_set_repsize(req, 3, size);
}
/* users of osc_enqueue() can pass this flag for ldlm_lock_match() */
if (req != NULL) {
if (rc == ELDLM_LOCK_ABORTED) {
/* swabbed by ldlm_cli_enqueue() */
- LASSERT_REPSWABBED(req, 0);
- rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*rep));
+ LASSERT_REPSWABBED(req, DLM_LOCKREPLY_OFF);
+ rep = lustre_msg_buf(req->rq_repmsg, DLM_LOCKREPLY_OFF,
+ sizeof(*rep));
LASSERT(rep != NULL);
if (rep->lock_policy_res1)
rc = rep->lock_policy_res1;
cfs_time_t max_age)
{
struct obd_statfs *msfs;
- struct ptlrpc_request *request;
- int rc, size = sizeof(*osfs);
+ struct ptlrpc_request *req;
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*osfs) };
ENTRY;
/* We could possibly pass max_age in the request (as an absolute
* during mount that would help a bit). Having relative timestamps
* is not so great if request processing is slow, while absolute
* timestamps are not ideal because they need time synchronization. */
- request = ptlrpc_prep_req(obd->u.cli.cl_import, LUSTRE_OST_VERSION,
- OST_STATFS,0,NULL,NULL);
- if (!request)
+ req = ptlrpc_prep_req(obd->u.cli.cl_import, LUSTRE_OST_VERSION,
+ OST_STATFS, 1, NULL, NULL);
+ if (!req)
RETURN(-ENOMEM);
- request->rq_replen = lustre_msg_size(1, &size);
- request->rq_request_portal = OST_CREATE_PORTAL; //XXX FIXME bug 249
+ ptlrpc_req_set_repsize(req, 2, size);
+ req->rq_request_portal = OST_CREATE_PORTAL; //XXX FIXME bug 249
- rc = ptlrpc_queue_wait(request);
+ rc = ptlrpc_queue_wait(req);
if (rc)
GOTO(out, rc);
- msfs = lustre_swab_repbuf(request, 0, sizeof(*msfs),
+ msfs = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*msfs),
lustre_swab_obd_statfs);
if (msfs == NULL) {
CERROR("Can't unpack obd_statfs\n");
EXIT;
out:
- ptlrpc_req_finished(request);
+ ptlrpc_req_finished(req);
return rc;
}
} else if (keylen >= strlen("last_id") && strcmp(key, "last_id") == 0) {
struct ptlrpc_request *req;
obd_id *reply;
- char *bufs[1] = {key};
- int rc;
+ char *bufs[2] = { NULL, key };
+ int rc, size[2] = { sizeof(struct ptlrpc_body), keylen };
+
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
- OST_GET_INFO, 1, &keylen, bufs);
+ OST_GET_INFO, 2, size, bufs);
if (req == NULL)
RETURN(-ENOMEM);
- req->rq_replen = lustre_msg_size(1, vallen);
+ size[REPLY_REC_OFF] = *vallen;
+ ptlrpc_req_set_repsize(req, 2, size);
rc = ptlrpc_queue_wait(req);
if (rc)
GOTO(out, rc);
- reply = lustre_swab_repbuf(req, 0, sizeof(*reply),
+ reply = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*reply),
lustre_swab_ost_last_id);
if (reply == NULL) {
CERROR("Can't unpack OST last ID\n");
struct ptlrpc_request *req;
struct obd_device *obd = exp->exp_obd;
struct obd_import *imp = class_exp2cliimp(exp);
- int size[2] = {keylen, vallen};
- char *bufs[2] = {key, val};
+ int size[3] = { sizeof(struct ptlrpc_body), keylen, vallen };
+ char *bufs[3] = { NULL, key, val };
ENTRY;
OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_SHUTDOWN, 10);
Even if something bad goes through, we'd get a -EINVAL from OST
anyway. */
- req = ptlrpc_prep_req(imp, LUSTRE_OST_VERSION, OST_SET_INFO,
- 2, size, bufs);
+ req = ptlrpc_prep_req(imp, LUSTRE_OST_VERSION, OST_SET_INFO, 3, size,
+ bufs);
if (req == NULL)
RETURN(-ENOMEM);
- req->rq_replen = lustre_msg_size(0, NULL);
-
if (KEY_IS("mds_conn"))
req->rq_interpret_reply = osc_setinfo_mds_conn_interpret;
+
+ ptlrpc_req_set_repsize(req, 1, NULL);
ptlrpc_set_add_req(set, req);
ptlrpc_check_set(set);
case RQ_PHASE_INTERPRET:
/* being handled, so basic msg swabbed, and opc is valid
* but racing with ost_handle() */
- seq_printf(sf, "opc %d\n", req->rq_reqmsg->opc);
+ seq_printf(sf, "opc %d\n", lustre_msg_get_opc(req->rq_reqmsg));
break;
case RQ_PHASE_COMPLETE:
/* been handled by ost_handle() reply state possibly still
* volatile */
- seq_printf(sf, "opc %d\n", req->rq_reqmsg->opc);
+ seq_printf(sf, "opc %d\n", lustre_msg_get_opc(req->rq_reqmsg));
break;
default:
return;
if (req->rq_repmsg)
- req->rq_repmsg->transno = oti->oti_transno;
+ lustre_msg_set_transno(req->rq_repmsg, oti->oti_transno);
req->rq_transno = oti->oti_transno;
/* XXX 4 == entries in oti_ack_locks??? */
struct obd_trans_info *oti)
{
struct ost_body *body, *repbody;
- int rc, size = sizeof(*body);
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
- body = lustre_swab_reqbuf(req, 0, sizeof(*body), lustre_swab_ost_body);
+ body = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*body),
+ lustre_swab_ost_body);
if (body == NULL)
RETURN(-EFAULT);
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc)
RETURN(rc);
if (body->oa.o_valid & OBD_MD_FLCOOKIE)
oti->oti_logcookies = obdo_logcookie(&body->oa);
- repbody = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*repbody));
+ repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*repbody));
memcpy(&repbody->oa, &body->oa, sizeof(body->oa));
req->rq_status = obd_destroy(exp, &body->oa, NULL, oti, NULL);
RETURN(0);
static int ost_getattr(struct obd_export *exp, struct ptlrpc_request *req)
{
struct ost_body *body, *repbody;
- int rc, size = sizeof(*body);
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
- body = lustre_swab_reqbuf(req, 0, sizeof(*body), lustre_swab_ost_body);
+ body = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*body),
+ lustre_swab_ost_body);
if (body == NULL)
RETURN(-EFAULT);
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc)
RETURN(rc);
- repbody = lustre_msg_buf (req->rq_repmsg, 0, sizeof(*repbody));
+ repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*repbody));
memcpy(&repbody->oa, &body->oa, sizeof(body->oa));
req->rq_status = obd_getattr(exp, &repbody->oa, NULL);
RETURN(0);
static int ost_statfs(struct ptlrpc_request *req)
{
struct obd_statfs *osfs;
- int rc, size = sizeof(*osfs);
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*osfs) };
ENTRY;
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc)
RETURN(rc);
- osfs = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*osfs));
+ osfs = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*osfs));
req->rq_status = obd_statfs(req->rq_export->exp_obd, osfs, jiffies-HZ);
if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_OST_ENOSPC))
struct obd_trans_info *oti)
{
struct ost_body *body, *repbody;
- int rc, size = sizeof(*repbody);
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*repbody) };
ENTRY;
- body = lustre_swab_reqbuf(req, 0, sizeof(*body), lustre_swab_ost_body);
+ body = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*body),
+ lustre_swab_ost_body);
if (body == NULL)
RETURN(-EFAULT);
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc)
RETURN(rc);
- repbody = lustre_msg_buf (req->rq_repmsg, 0, sizeof(*repbody));
+ repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*repbody));
memcpy(&repbody->oa, &body->oa, sizeof(body->oa));
oti->oti_logcookies = obdo_logcookie(&repbody->oa);
req->rq_status = obd_create(exp, &repbody->oa, NULL, oti);
{
struct obdo *oa;
struct ost_body *body, *repbody;
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*repbody) };
struct lustre_handle lh = {0,};
-
- int rc, size = sizeof(*repbody);
-
ENTRY;
- /*
- * check that we do support OBD_CONNECT_TRUNCLOCK.
- */
+ /* check that we do support OBD_CONNECT_TRUNCLOCK. */
CLASSERT(OST_CONNECT_SUPPORTED & OBD_CONNECT_TRUNCLOCK);
- body = lustre_swab_reqbuf(req, 0, sizeof *body, lustre_swab_ost_body);
+ body = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*body),
+ lustre_swab_ost_body);
if (body == NULL)
RETURN(-EFAULT);
(OBD_MD_FLSIZE | OBD_MD_FLBLOCKS))
RETURN(-EINVAL);
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc)
RETURN(rc);
- repbody = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*repbody));
+ repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*repbody));
repbody->oa = *oa;
rc = ost_punch_lock_get(exp, oa, &lh);
if (rc == 0) {
static int ost_sync(struct obd_export *exp, struct ptlrpc_request *req)
{
struct ost_body *body, *repbody;
- int rc, size = sizeof(*repbody);
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*repbody) };
ENTRY;
- body = lustre_swab_reqbuf(req, 0, sizeof(*body), lustre_swab_ost_body);
+ body = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*body),
+ lustre_swab_ost_body);
if (body == NULL)
RETURN(-EFAULT);
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc)
RETURN(rc);
- repbody = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*repbody));
+ repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*repbody));
memcpy(&repbody->oa, &body->oa, sizeof(body->oa));
req->rq_status = obd_sync(exp, &repbody->oa, NULL, repbody->oa.o_size,
repbody->oa.o_blocks);
struct obd_trans_info *oti)
{
struct ost_body *body, *repbody;
- int rc, size = sizeof(*repbody);
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*repbody) };
ENTRY;
- body = lustre_swab_reqbuf(req, 0, sizeof(*body), lustre_swab_ost_body);
+ body = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*body),
+ lustre_swab_ost_body);
if (body == NULL)
RETURN(-EFAULT);
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc)
RETURN(rc);
- repbody = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*repbody));
+ repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*repbody));
memcpy(&repbody->oa, &body->oa, sizeof(body->oa));
req->rq_status = obd_setattr(exp, &repbody->oa, NULL, oti);
static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
{
struct ptlrpc_bulk_desc *desc;
- struct niobuf_remote *remote_nb;
- struct niobuf_remote *pp_rnb = NULL;
- struct niobuf_local *local_nb;
- struct obd_ioobj *ioo;
- struct ost_body *body, *repbody;
- struct l_wait_info lwi;
- struct lustre_handle lockh = {0};
- int size[1] = { sizeof(*body) };
- int comms_error = 0;
- int niocount;
- int npages;
- int nob = 0;
- int rc;
- int i, do_checksum;
+ struct niobuf_remote *remote_nb;
+ struct niobuf_remote *pp_rnb = NULL;
+ struct niobuf_local *local_nb;
+ struct obd_ioobj *ioo;
+ struct ost_body *body, *repbody;
+ struct l_wait_info lwi;
+ struct lustre_handle lockh = { 0 };
+ int size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
+ int comms_error = 0, niocount, npages, nob = 0, rc, i, do_checksum;
ENTRY;
if (OBD_FAIL_CHECK(OBD_FAIL_OST_BRW_READ_BULK))
OBD_FAIL_TIMEOUT(OBD_FAIL_OST_BRW_PAUSE_BULK | OBD_FAIL_ONCE,
(obd_timeout + 1) / 4);
- body = lustre_swab_reqbuf(req, 0, sizeof(*body), lustre_swab_ost_body);
+ body = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*body),
+ lustre_swab_ost_body);
if (body == NULL) {
CERROR("Missing/short ost_body\n");
GOTO(out, rc = -EFAULT);
}
- ioo = lustre_swab_reqbuf(req, 1, sizeof(*ioo), lustre_swab_obd_ioobj);
+ ioo = lustre_swab_reqbuf(req, REQ_REC_OFF + 1, sizeof(*ioo),
+ lustre_swab_obd_ioobj);
if (ioo == NULL) {
CERROR("Missing/short ioobj\n");
GOTO(out, rc = -EFAULT);
GOTO(out, rc = -EFAULT);
}
- remote_nb = lustre_swab_reqbuf(req, 2, niocount * sizeof(*remote_nb),
+ remote_nb = lustre_swab_reqbuf(req, REQ_REC_OFF + 2,
+ niocount * sizeof(*remote_nb),
lustre_swab_niobuf_remote);
if (remote_nb == NULL) {
CERROR("Missing/short niobuf\n");
lustre_swab_niobuf_remote (&remote_nb[i]);
}
- rc = lustre_pack_reply(req, 1, size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc)
GOTO(out, rc);
ost_nio_pages_put(req, local_nb, npages);
if (rc == 0) {
- repbody = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*repbody));
+ repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*repbody));
memcpy(&repbody->oa, &body->oa, sizeof(repbody->oa));
if (unlikely(do_checksum)) {
struct l_wait_info lwi;
struct lustre_handle lockh = {0};
__u32 *rcs;
- int size[2] = { sizeof(*body) };
- int objcount, niocount, npages;
- int comms_error = 0;
- int rc, swab, i, j, do_checksum;
+ int size[3] = { sizeof(struct ptlrpc_body), sizeof(*body) };
+ int objcount, niocount, npages, comms_error = 0;
+ int rc, swab, i, j, do_checksum;
ENTRY;
if (OBD_FAIL_CHECK(OBD_FAIL_OST_BRW_WRITE_BULK))
(obd_timeout + 1) / 4);
swab = lustre_msg_swabbed(req->rq_reqmsg);
- body = lustre_swab_reqbuf(req, 0, sizeof(*body), lustre_swab_ost_body);
+ body = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*body),
+ lustre_swab_ost_body);
if (body == NULL) {
CERROR("Missing/short ost_body\n");
GOTO(out, rc = -EFAULT);
}
- LASSERT_REQSWAB(req, 1);
- objcount = req->rq_reqmsg->buflens[1] / sizeof(*ioo);
+ LASSERT_REQSWAB(req, REQ_REC_OFF + 1);
+ objcount = lustre_msg_buflen(req->rq_reqmsg, REQ_REC_OFF + 1) /
+ sizeof(*ioo);
if (objcount == 0) {
CERROR("Missing/short ioobj\n");
GOTO(out, rc = -EFAULT);
GOTO(out, rc = -EFAULT);
}
- ioo = lustre_msg_buf (req->rq_reqmsg, 1, objcount * sizeof(*ioo));
+ ioo = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 1,
+ objcount * sizeof(*ioo));
LASSERT (ioo != NULL);
for (niocount = i = 0; i < objcount; i++) {
if (swab)
- lustre_swab_obd_ioobj (&ioo[i]);
+ lustre_swab_obd_ioobj(&ioo[i]);
if (ioo[i].ioo_bufcnt == 0) {
CERROR("ioo[%d] has zero bufcnt\n", i);
GOTO(out, rc = -EFAULT);
GOTO(out, rc = -EFAULT);
}
- remote_nb = lustre_swab_reqbuf(req, 2, niocount * sizeof(*remote_nb),
+ remote_nb = lustre_swab_reqbuf(req, REQ_REC_OFF + 2,
+ niocount * sizeof(*remote_nb),
lustre_swab_niobuf_remote);
if (remote_nb == NULL) {
CERROR("Missing/short niobuf\n");
lustre_swab_niobuf_remote (&remote_nb[i]);
}
- size[1] = niocount * sizeof(*rcs);
- rc = lustre_pack_reply(req, 2, size, NULL);
+ size[REPLY_REC_OFF + 1] = niocount * sizeof(*rcs);
+ rc = lustre_pack_reply(req, 3, size, NULL);
if (rc != 0)
GOTO(out, rc);
- rcs = lustre_msg_buf(req->rq_repmsg, 1, niocount * sizeof(*rcs));
+ rcs = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF + 1,
+ niocount * sizeof(*rcs));
/*
* Per-thread array of struct niobuf_{local,remote}'s was allocated by
}
comms_error = rc != 0;
- repbody = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*repbody));
+ repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*repbody));
memcpy(&repbody->oa, &body->oa, sizeof(repbody->oa));
if (unlikely(do_checksum && rc == 0)) {
struct niobuf_remote *remote_nb, *res_nb, *pp_rnb = NULL;
struct obd_ioobj *ioo;
struct ost_body *body, *repbody;
- int rc, i, objcount, niocount, size[2] = {sizeof(*body)}, npages;
- int swab;
+ int rc, i, objcount, niocount, npages, swab;
+ int size[3] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
/* XXX not set to use latest protocol */
swab = lustre_msg_swabbed(req->rq_reqmsg);
- body = lustre_swab_reqbuf(req, 0, sizeof(*body), lustre_swab_ost_body);
+ body = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*body),
+ lustre_swab_ost_body);
if (body == NULL) {
CERROR("Missing/short ost_body\n");
GOTO(out, rc = -EFAULT);
}
- ioo = lustre_swab_reqbuf(req, 1, sizeof(*ioo), lustre_swab_obd_ioobj);
+ ioo = lustre_swab_reqbuf(req, REQ_REC_OFF + 1, sizeof(*ioo),
+ lustre_swab_obd_ioobj);
if (ioo == NULL) {
CERROR("Missing/short ioobj\n");
GOTO(out, rc = -EFAULT);
}
- objcount = req->rq_reqmsg->buflens[1] / sizeof(*ioo);
+ objcount = lustre_msg_buflen(req->rq_reqmsg, REQ_REC_OFF + 1) /
+ sizeof(*ioo);
niocount = ioo[0].ioo_bufcnt;
for (i = 1; i < objcount; i++) {
if (swab)
niocount += ioo[i].ioo_bufcnt;
}
- remote_nb = lustre_swab_reqbuf(req, 2, niocount * sizeof(*remote_nb),
+ remote_nb = lustre_swab_reqbuf(req, REQ_REC_OFF + 2,
+ niocount * sizeof(*remote_nb),
lustre_swab_niobuf_remote);
if (remote_nb == NULL) {
CERROR("Missing/short niobuf\n");
if (npages < 0)
GOTO (out, rc = npages);
- size[1] = npages * sizeof(*pp_rnb);
- rc = lustre_pack_reply(req, 2, size, NULL);
+ size[REPLY_REC_OFF + 1] = npages * sizeof(*pp_rnb);
+ rc = lustre_pack_reply(req, 3, size, NULL);
if (rc)
GOTO(out, rc);
if (req->rq_status)
GOTO(out, rc = 0);
- repbody = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*repbody));
+ repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*repbody));
memcpy(&repbody->oa, &body->oa, sizeof(body->oa));
- res_nb = lustre_msg_buf(req->rq_repmsg, 1, size[1]);
- memcpy(res_nb, remote_nb, size[1]);
+ res_nb = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF + 1,
+ size[REPLY_REC_OFF + 1]);
+ memcpy(res_nb, remote_nb, size[REPLY_REC_OFF + 1]);
rc = 0;
out:
target_committed_to_req(req);
int keylen, vallen, rc = 0;
ENTRY;
- key = lustre_msg_buf(req->rq_reqmsg, 0, 1);
+ key = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, 1);
if (key == NULL) {
DEBUG_REQ(D_HA, req, "no set_info key");
RETURN(-EFAULT);
}
- keylen = lustre_msg_buflen(req->rq_reqmsg,0);
+ keylen = lustre_msg_buflen(req->rq_reqmsg, REQ_REC_OFF);
- rc = lustre_pack_reply(req, 0, NULL, NULL);
+ rc = lustre_pack_reply(req, 1, NULL, NULL);
if (rc)
RETURN(rc);
- vallen = lustre_msg_buflen(req->rq_reqmsg, 1);
+ vallen = lustre_msg_buflen(req->rq_reqmsg, REQ_REC_OFF + 1);
if (vallen)
- val = lustre_msg_buf(req->rq_reqmsg, 1, 0);
+ val = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 1, 0);
if (KEY_IS("evict_by_nid")) {
if (val && vallen)
rc = obd_set_info_async(exp, keylen, key, vallen, val, NULL);
out:
- req->rq_repmsg->status = 0;
+ lustre_msg_set_status(req->rq_repmsg, 0);
RETURN(rc);
}
static int ost_get_info(struct obd_export *exp, struct ptlrpc_request *req)
{
char *key;
- int keylen, rc = 0, size = sizeof(obd_id);
+ int keylen, rc = 0;
+ int size[2] = { sizeof(struct ptlrpc_body), sizeof(obd_id) };
obd_id *reply;
ENTRY;
- key = lustre_msg_buf(req->rq_reqmsg, 0, 1);
+ key = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, 1);
if (key == NULL) {
DEBUG_REQ(D_HA, req, "no get_info key");
RETURN(-EFAULT);
}
- keylen = req->rq_reqmsg->buflens[0];
+ keylen = lustre_msg_buflen(req->rq_reqmsg, REQ_REC_OFF);
if (keylen < strlen("last_id") || memcmp(key, "last_id", 7) != 0)
RETURN(-EPROTO);
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc)
RETURN(rc);
- reply = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*reply));
- rc = obd_get_info(exp, keylen, key, &size, reply);
- req->rq_repmsg->status = 0;
+ reply = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*reply));
+ rc = obd_get_info(exp, keylen, key, size, reply);
+ lustre_msg_set_status(req->rq_repmsg, 0);
RETURN(rc);
}
static int ost_handle_quotactl(struct ptlrpc_request *req)
{
struct obd_quotactl *oqctl, *repoqc;
- int rc, size = sizeof(*repoqc);
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*repoqc) };
ENTRY;
- oqctl = lustre_swab_reqbuf(req, 0, sizeof(*oqctl),
+ oqctl = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*oqctl),
lustre_swab_obd_quotactl);
if (oqctl == NULL)
GOTO(out, rc = -EPROTO);
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc)
GOTO(out, rc);
- repoqc = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*repoqc));
+ repoqc = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*repoqc));
req->rq_status = obd_quotactl(req->rq_export, oqctl);
*repoqc = *oqctl;
int rc;
ENTRY;
- oqctl = lustre_swab_reqbuf(req, 0, sizeof(*oqctl),
+ oqctl = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*oqctl),
lustre_swab_obd_quotactl);
if (oqctl == NULL)
RETURN(-EPROTO);
- rc = lustre_pack_reply(req, 0, NULL, NULL);
+ rc = lustre_pack_reply(req, 1, NULL, NULL);
if (rc) {
CERROR("ost: out of memory while packing quotacheck reply\n");
RETURN(-ENOMEM);
static int ost_filter_recovery_request(struct ptlrpc_request *req,
struct obd_device *obd, int *process)
{
- switch (req->rq_reqmsg->opc) {
+ switch (lustre_msg_get_opc(req->rq_reqmsg)) {
case OST_CONNECT: /* This will never get here, but for completeness. */
case OST_DISCONNECT:
*process = 1;
{
int rc;
- /* TODO: enable the below check while really introducing msg version.
- * it's disabled because it will break compatibility with b1_4.
- */
- return (0);
- switch(msg->opc) {
+ switch(lustre_msg_get_opc(msg)) {
case OST_CONNECT:
case OST_DISCONNECT:
case OBD_PING:
rc = lustre_msg_check_version(msg, LUSTRE_OBD_VERSION);
if (rc)
CERROR("bad opc %u version %08x, expecting %08x\n",
- msg->opc, msg->version, LUSTRE_OBD_VERSION);
+ lustre_msg_get_opc(msg),
+ lustre_msg_get_version(msg),
+ LUSTRE_OBD_VERSION);
break;
case OST_CREATE:
case OST_DESTROY:
rc = lustre_msg_check_version(msg, LUSTRE_OST_VERSION);
if (rc)
CERROR("bad opc %u version %08x, expecting %08x\n",
- msg->opc, msg->version, LUSTRE_OST_VERSION);
+ lustre_msg_get_opc(msg),
+ lustre_msg_get_version(msg),
+ LUSTRE_OST_VERSION);
break;
case LDLM_ENQUEUE:
case LDLM_CONVERT:
rc = lustre_msg_check_version(msg, LUSTRE_DLM_VERSION);
if (rc)
CERROR("bad opc %u version %08x, expecting %08x\n",
- msg->opc, msg->version, LUSTRE_DLM_VERSION);
+ lustre_msg_get_opc(msg),
+ lustre_msg_get_version(msg),
+ LUSTRE_DLM_VERSION);
break;
case LLOG_ORIGIN_CONNECT:
case OBD_LOG_CANCEL:
rc = lustre_msg_check_version(msg, LUSTRE_LOG_VERSION);
if (rc)
CERROR("bad opc %u version %08x, expecting %08x\n",
- msg->opc, msg->version, LUSTRE_LOG_VERSION);
+ lustre_msg_get_opc(msg),
+ lustre_msg_get_version(msg),
+ LUSTRE_LOG_VERSION);
+ break;
default:
- CERROR("Unexpected opcode %d\n", msg->opc);
+ CERROR("Unexpected opcode %d\n", lustre_msg_get_opc(msg));
rc = -ENOTSUPP;
}
return rc;
LASSERT(current->journal_info == NULL);
/* XXX identical to MDS */
- if (req->rq_reqmsg->opc != OST_CONNECT) {
+ if (lustre_msg_get_opc(req->rq_reqmsg) != OST_CONNECT) {
int abort_recovery, recovering;
if (req->rq_export == NULL) {
CDEBUG(D_HA,"operation %d on unconnected OST from %s\n",
- req->rq_reqmsg->opc, libcfs_id2str(req->rq_peer));
+ lustre_msg_get_opc(req->rq_reqmsg),
+ libcfs_id2str(req->rq_peer));
req->rq_status = -ENOTCONN;
GOTO(out, rc = -ENOTCONN);
}
if (rc)
RETURN(rc);
- switch (req->rq_reqmsg->opc) {
+ rc = ost_msg_check_version(req->rq_reqmsg);
+ if (rc)
+ RETURN(rc);
+
+ switch (lustre_msg_get_opc(req->rq_reqmsg)) {
case OST_CONNECT: {
CDEBUG(D_INODE, "connect\n");
OBD_FAIL_RETURN(OBD_FAIL_OST_CONNECT_NET, 0);
DEBUG_REQ(D_INODE, req, "log connect\n");
rc = llog_handle_connect(req);
req->rq_status = rc;
- rc = lustre_pack_reply(req, 0, NULL, NULL);
+ rc = lustre_pack_reply(req, 1, NULL, NULL);
if (rc)
RETURN(rc);
RETURN(ptlrpc_reply(req));
OBD_FAIL_RETURN(OBD_FAIL_OBD_LOG_CANCEL_NET, 0);
rc = llog_origin_handle_cancel(req);
req->rq_status = rc;
- rc = lustre_pack_reply(req, 0, NULL, NULL);
+ rc = lustre_pack_reply(req, 1, NULL, NULL);
if (rc)
RETURN(rc);
RETURN(ptlrpc_reply(req));
CERROR("callbacks should not happen on OST\n");
/* fall through */
default:
- CERROR("Unexpected opcode %d\n", req->rq_reqmsg->opc);
+ CERROR("Unexpected opcode %d\n",
+ lustre_msg_get_opc(req->rq_reqmsg));
req->rq_status = -ENOTSUPP;
rc = ptlrpc_error(req);
RETURN(rc);
EXIT;
/* If we're DISCONNECTing, the export_data is already freed */
- if (!rc && req->rq_reqmsg->opc != OST_DISCONNECT)
+ if (!rc && lustre_msg_get_opc(req->rq_reqmsg) != OST_DISCONNECT)
target_committed_to_req(req);
out:
RETURN(NULL);
}
- rc = lustre_pack_request(request, count, lengths, bufs);
+ rc = lustre_pack_request(request, imp->imp_msg_magic, count, lengths,
+ bufs);
if (rc) {
LASSERT(!request->rq_pool);
OBD_FREE(request, sizeof(*request));
RETURN(NULL);
}
-#if 0 /* TODO: enable this while really introducing msg version.
- * it's disabled because it will break compatibility with b1_4.
- */
- request->rq_reqmsg->version |= version;
-#endif
+ lustre_msg_add_version(request->rq_reqmsg, version);
+
if (imp->imp_server_timeout)
request->rq_timeout = obd_timeout / 2;
else
request->rq_xid = ptlrpc_next_xid();
atomic_set(&request->rq_refcount, 1);
- request->rq_reqmsg->opc = opcode;
- request->rq_reqmsg->flags = 0;
+ lustre_msg_set_opc(request->rq_reqmsg, opcode);
+ lustre_msg_set_flags(request->rq_reqmsg, 0);
RETURN(request);
}
struct ptlrpc_request *
-ptlrpc_prep_req(struct obd_import *imp, __u32 version, int opcode,
- int count, int *lengths, char **bufs)
+ptlrpc_prep_req(struct obd_import *imp, __u32 version, int opcode, int count,
+ int *lengths, char **bufs)
{
- return ptlrpc_prep_req_pool(imp, version, opcode, count, lengths,
- bufs, NULL);
+ return ptlrpc_prep_req_pool(imp, version, opcode, count, lengths, bufs,
+ NULL);
}
struct ptlrpc_request_set *ptlrpc_prep_set(void)
ENTRY;
/* serialise with network callback */
- spin_lock_irqsave (&req->rq_lock, flags);
+ spin_lock_irqsave(&req->rq_lock, flags);
if (req->rq_replied) {
DEBUG_REQ(D_NET, req, "REPLIED:");
}
EXIT;
out:
- spin_unlock_irqrestore (&req->rq_lock, flags);
+ spin_unlock_irqrestore(&req->rq_lock, flags);
DEBUG_REQ(D_NET, req, "rc = %d for", rc);
return rc;
}
int err;
ENTRY;
- err = req->rq_repmsg->status;
- if (req->rq_repmsg->type == PTL_RPC_MSG_ERR) {
+ err = lustre_msg_get_status(req->rq_repmsg);
+ if (lustre_msg_get_type(req->rq_repmsg) == PTL_RPC_MSG_ERR) {
DEBUG_REQ(D_ERROR, req, "type == PTL_RPC_MSG_ERR, err == %d",
err);
RETURN(err < 0 ? err : -EINVAL);
RETURN(-EPROTO);
}
- if (req->rq_repmsg->type != PTL_RPC_MSG_REPLY &&
- req->rq_repmsg->type != PTL_RPC_MSG_ERR) {
+ rc = lustre_unpack_ptlrpc_body(req->rq_repmsg);
+ if (rc) {
+ DEBUG_REQ(D_ERROR, req, "unpack ptlrpc body failed: %d\n", rc);
+ RETURN(-EPROTO);
+ }
+
+ if (lustre_msg_get_type(req->rq_repmsg) != PTL_RPC_MSG_REPLY &&
+ lustre_msg_get_type(req->rq_repmsg) != PTL_RPC_MSG_ERR) {
DEBUG_REQ(D_ERROR, req, "invalid packet received (type=%u)\n",
- req->rq_repmsg->type);
+ lustre_msg_get_type(req->rq_repmsg));
RETURN(-EPROTO);
}
}
/* Store transno in reqmsg for replay. */
- req->rq_reqmsg->transno = req->rq_transno = req->rq_repmsg->transno;
+ req->rq_transno = lustre_msg_get_transno(req->rq_repmsg);
+ lustre_msg_set_transno(req->rq_reqmsg, req->rq_transno);
if (req->rq_import->imp_replayable) {
spin_lock_irqsave(&imp->imp_lock, flags);
}
/* Replay-enabled imports return commit-status information. */
- if (req->rq_repmsg->last_committed)
+ if (lustre_msg_get_last_committed(req->rq_repmsg))
imp->imp_peer_committed_transno =
- req->rq_repmsg->last_committed;
+ lustre_msg_get_last_committed(req->rq_repmsg);
ptlrpc_free_committed(imp);
spin_unlock_irqrestore(&imp->imp_lock, flags);
}
DEBUG_REQ(D_HA, req, "req from PID %d waiting for recovery: "
"(%s != %s)",
- req->rq_reqmsg->status,
+ lustre_msg_get_status(req->rq_reqmsg) ,
ptlrpc_import_state_name(req->rq_send_state),
ptlrpc_import_state_name(imp->imp_state));
LASSERT(list_empty (&req->rq_list));
list_add_tail(&req->rq_list, &imp->imp_sending_list);
spin_unlock_irqrestore(&imp->imp_lock, flags);
- req->rq_reqmsg->status = cfs_curproc_pid();
+ lustre_msg_set_status(req->rq_reqmsg, cfs_curproc_pid());
CDEBUG(D_RPCTRACE, "Sending RPC pname:cluuid:pid:xid:nid:opc"
" %s:%s:%d:"LPU64":%s:%d\n", cfs_curproc_comm(),
- imp->imp_obd->obd_uuid.uuid, req->rq_reqmsg->status,
- req->rq_xid,
+ imp->imp_obd->obd_uuid.uuid,
+ lustre_msg_get_status(req->rq_reqmsg), req->rq_xid,
libcfs_nid2str(imp->imp_connection->c_peer.nid),
- req->rq_reqmsg->opc);
+ lustre_msg_get_opc(req->rq_reqmsg));
rc = ptl_send_rpc(req, 0);
if (rc) {
CDEBUG(D_RPCTRACE, "Completed RPC pname:cluuid:pid:xid:nid:"
"opc %s:%s:%d:"LPU64":%s:%d\n", cfs_curproc_comm(),
- imp->imp_obd->obd_uuid.uuid, req->rq_reqmsg->status,
- req->rq_xid,
+ imp->imp_obd->obd_uuid.uuid,
+ lustre_msg_get_status(req->rq_reqmsg), req->rq_xid,
libcfs_nid2str(imp->imp_connection->c_peer.nid),
- req->rq_reqmsg->opc);
+ lustre_msg_get_opc(req->rq_reqmsg));
set->set_remaining--;
RETURN(1);
}
- ptlrpc_fail_import(imp, req->rq_reqmsg->conn_cnt);
+ ptlrpc_fail_import(imp, lustre_msg_get_conn_cnt(req->rq_reqmsg));
RETURN(0);
}
unsigned long flags;
DEBUG_REQ(D_HA, req, "going to resend");
- req->rq_reqmsg->handle.cookie = 0;
+ lustre_msg_set_handle(req->rq_reqmsg, &(struct lustre_handle){ 0 });
req->rq_status = -EAGAIN;
spin_lock_irqsave (&req->rq_lock, flags);
atomic_inc(&imp->imp_inflight);
/* for distributed debugging */
- req->rq_reqmsg->status = cfs_curproc_pid();
+ lustre_msg_set_status(req->rq_reqmsg, cfs_curproc_pid());
LASSERT(imp->imp_obd != NULL);
CDEBUG(D_RPCTRACE, "Sending RPC pname:cluuid:pid:xid:nid:opc "
"%s:%s:%d:"LPU64":%s:%d\n", cfs_curproc_comm(),
imp->imp_obd->obd_uuid.uuid,
- req->rq_reqmsg->status, req->rq_xid,
+ lustre_msg_get_status(req->rq_reqmsg), req->rq_xid,
libcfs_nid2str(imp->imp_connection->c_peer.nid),
- req->rq_reqmsg->opc);
+ lustre_msg_get_opc(req->rq_reqmsg));
/* Mark phase here for a little debug help */
req->rq_phase = RQ_PHASE_RPC;
CDEBUG(D_RPCTRACE, "Completed RPC pname:cluuid:pid:xid:nid:opc "
"%s:%s:%d:"LPU64":%s:%d\n", cfs_curproc_comm(),
imp->imp_obd->obd_uuid.uuid,
- req->rq_reqmsg->status, req->rq_xid,
+ lustre_msg_get_status(req->rq_reqmsg), req->rq_xid,
libcfs_nid2str(imp->imp_connection->c_peer.nid),
- req->rq_reqmsg->opc);
+ lustre_msg_get_opc(req->rq_reqmsg));
spin_lock_irqsave(&imp->imp_lock, flags);
list_del_init(&req->rq_list);
GOTO(out, rc = req->rq_status);
}
- rc = after_reply (req);
+ rc = after_reply(req);
/* NB may return +ve success rc */
if (req->rq_resend) {
spin_lock_irqsave(&imp->imp_lock, flags);
GOTO(out, rc = -ETIMEDOUT);
}
-#if SWAB_PARANOIA
- /* Clear reply swab mask; this is a new reply in sender's byte order */
- req->rq_rep_swab_mask = 0;
-#endif
- LASSERT (req->rq_nob_received <= req->rq_replen);
- rc = lustre_unpack_msg(req->rq_repmsg, req->rq_nob_received);
- if (rc) {
- DEBUG_REQ(D_ERROR, req, "unpack_rep failed: %d\n", rc);
- GOTO(out, rc = -EPROTO);
- }
-
- if (req->rq_repmsg->type == PTL_RPC_MSG_ERR &&
- req->rq_repmsg->status == -ENOTCONN)
- GOTO(out, rc = req->rq_repmsg->status);
+ if (lustre_msg_get_type(req->rq_repmsg) == PTL_RPC_MSG_ERR &&
+ lustre_msg_get_status(req->rq_repmsg) == -ENOTCONN)
+ GOTO(out, rc = lustre_msg_get_status(req->rq_repmsg));
/* The transno had better not change over replay. */
- LASSERT(req->rq_reqmsg->transno == req->rq_repmsg->transno);
+ LASSERT(lustre_msg_get_transno(req->rq_reqmsg) ==
+ lustre_msg_get_transno(req->rq_repmsg));
DEBUG_REQ(D_HA, req, "got rep");
if (req->rq_replay_cb)
req->rq_replay_cb(req);
- if (req->rq_replied && req->rq_repmsg->status != aa->praa_old_status) {
+ if (req->rq_replied &&
+ lustre_msg_get_status(req->rq_repmsg) != aa->praa_old_status) {
DEBUG_REQ(D_ERROR, req, "status %d, old was %d",
- req->rq_repmsg->status, aa->praa_old_status);
+ lustre_msg_get_status(req->rq_repmsg),
+ aa->praa_old_status);
} else {
/* Put it back for re-replay. */
- req->rq_repmsg->status = aa->praa_old_status;
+ lustre_msg_set_status(req->rq_repmsg, aa->praa_old_status);
}
spin_lock_irqsave(&imp->imp_lock, flags);
aa->praa_old_state = req->rq_send_state;
req->rq_send_state = LUSTRE_IMP_REPLAY;
req->rq_phase = RQ_PHASE_NEW;
- aa->praa_old_status = req->rq_repmsg->status;
+ aa->praa_old_status = lustre_msg_get_status(req->rq_repmsg);
req->rq_status = 0;
req->rq_interpret_reply = ptlrpc_replay_interpret;
EXPORT_SYMBOL(ptlrpc_init_import);
#define UUID_STR "_UUID"
-static void deuuidify(char *uuid, const char *prefix, char **uuid_start, int *uuid_len)
+static void deuuidify(char *uuid, const char *prefix, char **uuid_start,
+ int *uuid_len)
{
*uuid_start = !prefix || strncmp(uuid, prefix, strlen(prefix))
? uuid : uuid + strlen(prefix);
int rc;
__u64 committed_before_reconnect = 0;
struct ptlrpc_request *request;
- int size[] = {sizeof(imp->imp_obd->u.cli.cl_target_uuid),
- sizeof(obd->obd_uuid),
- sizeof(imp->imp_dlm_handle),
- sizeof(imp->imp_connect_data)};
- char *tmp[] = {obd2cli_tgt(imp->imp_obd),
- obd->obd_uuid.uuid,
- (char *)&imp->imp_dlm_handle,
- (char *)&imp->imp_connect_data};
+ int size[] = { sizeof(struct ptlrpc_body),
+ sizeof(imp->imp_obd->u.cli.cl_target_uuid),
+ sizeof(obd->obd_uuid),
+ sizeof(imp->imp_dlm_handle),
+ sizeof(imp->imp_connect_data) };
+ char *tmp[] = { NULL,
+ obd2cli_tgt(imp->imp_obd),
+ obd->obd_uuid.uuid,
+ (char *)&imp->imp_dlm_handle,
+ (char *)&imp->imp_connect_data };
struct ptlrpc_connect_async_args *aa;
unsigned long flags;
GOTO(out, rc);
request = ptlrpc_prep_req(imp, LUSTRE_OBD_VERSION, imp->imp_connect_op,
- 4, size, tmp);
+ 5, size, tmp);
if (!request)
GOTO(out, rc = -ENOMEM);
#ifndef __KERNEL__
lustre_msg_add_op_flags(request->rq_reqmsg, MSG_CONNECT_LIBCLIENT);
#endif
+ lustre_msg_add_op_flags(request->rq_reqmsg, MSG_CONNECT_NEXT_VER);
request->rq_send_state = LUSTRE_IMP_CONNECTING;
/* Allow a slightly larger reply for future growth compatibility */
- size[0] = sizeof(struct obd_connect_data) + 16 * sizeof(__u64);
- request->rq_replen = lustre_msg_size(1, size);
+ size[REPLY_REC_OFF] = sizeof(struct obd_connect_data) +
+ 16 * sizeof(__u64);
+ ptlrpc_req_set_repsize(request, 2, size);
request->rq_interpret_reply = ptlrpc_connect_interpret;
CLASSERT(sizeof (*aa) <= sizeof (request->rq_async_args));
} else {
imp->imp_replayable = 0;
}
- imp->imp_remote_handle = request->rq_repmsg->handle;
+
+ if (msg_flags & MSG_CONNECT_NEXT_VER) {
+ imp->imp_msg_magic = LUSTRE_MSG_MAGIC_V2;
+ CDEBUG(D_RPCTRACE, "connect to %s with lustre_msg_v2\n",
+ obd2cli_tgt(imp->imp_obd));
+ } else {
+ CDEBUG(D_RPCTRACE, "connect to %s with lustre_msg_v1\n",
+ obd2cli_tgt(imp->imp_obd));
+ }
+
+ imp->imp_remote_handle =
+ *lustre_msg_get_handle(request->rq_repmsg);
IMPORT_SET_STATE(imp, LUSTRE_IMP_FULL);
GOTO(finish, rc = 0);
/* Determine what recovery state to move the import to. */
if (MSG_CONNECT_RECONNECT & msg_flags) {
memset(&old_hdl, 0, sizeof(old_hdl));
- if (!memcmp(&old_hdl, &request->rq_repmsg->handle,
+ if (!memcmp(&old_hdl, lustre_msg_get_handle(request->rq_repmsg),
sizeof (old_hdl))) {
CERROR("%s@%s didn't like our handle "LPX64
", failed\n", obd2cli_tgt(imp->imp_obd),
GOTO(out, rc = -ENOTCONN);
}
- if (memcmp(&imp->imp_remote_handle, &request->rq_repmsg->handle,
+ if (memcmp(&imp->imp_remote_handle,
+ lustre_msg_get_handle(request->rq_repmsg),
sizeof(imp->imp_remote_handle))) {
CERROR("%s@%s changed handle from "LPX64" to "LPX64
"; copying, but this may foreshadow disaster\n",
obd2cli_tgt(imp->imp_obd),
imp->imp_connection->c_remote_uuid.uuid,
imp->imp_remote_handle.cookie,
- request->rq_repmsg->handle.cookie);
- imp->imp_remote_handle = request->rq_repmsg->handle;
+ lustre_msg_get_handle(request->rq_repmsg)->
+ cookie);
+ imp->imp_remote_handle =
+ *lustre_msg_get_handle(request->rq_repmsg);
} else {
CDEBUG(D_HA, "reconnected to %s@%s after partition\n",
obd2cli_tgt(imp->imp_obd),
}
} else if ((MSG_CONNECT_RECOVERING & msg_flags) && !imp->imp_invalid) {
LASSERT(imp->imp_replayable);
- imp->imp_remote_handle = request->rq_repmsg->handle;
+ imp->imp_remote_handle =
+ *lustre_msg_get_handle(request->rq_repmsg);
imp->imp_last_replay_transno = 0;
IMPORT_SET_STATE(imp, LUSTRE_IMP_REPLAY);
} else {
- imp->imp_remote_handle = request->rq_repmsg->handle;
+ imp->imp_remote_handle =
+ *lustre_msg_get_handle(request->rq_repmsg);
IMPORT_SET_STATE(imp, LUSTRE_IMP_EVICTED);
}
"after reconnect. We should LBUG right here.\n");
}
- if (request->rq_repmsg->last_committed < aa->pcaa_peer_committed) {
+ if (lustre_msg_get_last_committed(request->rq_repmsg) <
+ aa->pcaa_peer_committed) {
CERROR("%s went back in time (transno "LPD64
" was previously committed, server now claims "LPD64
")! See https://bugzilla.clusterfs.com/"
"long_list.cgi?buglist=9646\n",
obd2cli_tgt(imp->imp_obd), aa->pcaa_peer_committed,
- request->rq_repmsg->last_committed);
+ lustre_msg_get_last_committed(request->rq_repmsg));
}
finish:
struct obd_connect_data *ocd;
struct obd_export *exp;
- ocd = lustre_swab_repbuf(request, 0,
+ ocd = lustre_swab_repbuf(request, REPLY_REC_OFF,
sizeof *ocd, lustre_swab_connect);
if (ocd == NULL) {
CERROR("Wrong connect data from server\n");
LASSERT(atomic_read(&imp->imp_replay_inflight) == 0);
atomic_inc(&imp->imp_replay_inflight);
- req = ptlrpc_prep_req(imp, LUSTRE_OBD_VERSION, OBD_PING,
- 0, NULL, NULL);
+ req = ptlrpc_prep_req(imp, LUSTRE_OBD_VERSION, OBD_PING, 1, NULL, NULL);
if (!req) {
atomic_dec(&imp->imp_replay_inflight);
RETURN(-ENOMEM);
}
- req->rq_replen = lustre_msg_size(0, NULL);
+ ptlrpc_req_set_repsize(req, 1, NULL);
req->rq_send_state = LUSTRE_IMP_REPLAY_WAIT;
- req->rq_reqmsg->flags |= MSG_LAST_REPLAY;
+ lustre_msg_add_flags(req->rq_reqmsg, MSG_LAST_REPLAY);
req->rq_timeout *= 3;
req->rq_interpret_reply = completed_replay_interpret;
int ptlrpc_disconnect_import(struct obd_import *imp)
{
- struct ptlrpc_request *request;
- int rq_opc;
- int rc = 0;
+ struct ptlrpc_request *req;
+ int rq_opc, rc = 0;
unsigned long flags;
ENTRY;
if (ptlrpc_import_in_recovery(imp)) {
struct l_wait_info lwi;
- lwi = LWI_TIMEOUT_INTR(cfs_timeout_cap(cfs_time_seconds(obd_timeout)),
+ cfs_duration_t timeout = cfs_time_seconds(obd_timeout);
+
+ lwi = LWI_TIMEOUT_INTR(cfs_timeout_cap(timeout),
back_to_sleep, NULL, NULL);
rc = l_wait_event(imp->imp_recovery_waitq,
!ptlrpc_import_in_recovery(imp), &lwi);
spin_unlock_irqrestore(&imp->imp_lock, flags);
- request = ptlrpc_prep_req(imp, LUSTRE_OBD_VERSION, rq_opc,
- 0, NULL, NULL);
- if (request) {
+ req = ptlrpc_prep_req(imp, LUSTRE_OBD_VERSION, rq_opc, 1, NULL, NULL);
+ if (req) {
/* We are disconnecting, do not retry a failed DISCONNECT rpc if
* it fails. We can get through the above with a down server
* if the client doesn't know the server is gone yet. */
- request->rq_no_resend = 1;
- request->rq_timeout = 5;
+ req->rq_no_resend = 1;
+ req->rq_timeout = 5;
IMPORT_SET_STATE(imp, LUSTRE_IMP_CONNECTING);
- request->rq_send_state = LUSTRE_IMP_CONNECTING;
- request->rq_replen = lustre_msg_size(0, NULL);
- rc = ptlrpc_queue_wait(request);
- ptlrpc_req_finished(request);
+ req->rq_send_state = LUSTRE_IMP_CONNECTING;
+ ptlrpc_req_set_repsize(req, 1, NULL);
+ rc = ptlrpc_queue_wait(req);
+ ptlrpc_req_finished(req);
}
spin_lock_irqsave(&imp->imp_lock, flags);
struct llogd_body *body;
struct llog_handle *handle;
struct ptlrpc_request *req = NULL;
- int size[2] = {sizeof(req_body)};
- char *tmp[2] = {(char*) &req_body};
- int bufcount = 1;
- int repsize[] = {sizeof (req_body)};
+ int size[3] = { sizeof(struct ptlrpc_body), sizeof(req_body) };
+ char *bufs[3] = { NULL, (char*)&req_body };
+ int bufcount = 2;
int rc;
ENTRY;
if (name) {
size[bufcount] = strlen(name) + 1;
- tmp[bufcount] = name;
+ bufs[bufcount] = name;
bufcount++;
}
req = ptlrpc_prep_req(imp, LUSTRE_LOG_VERSION,
- LLOG_ORIGIN_HANDLE_CREATE, bufcount, size, tmp);
+ LLOG_ORIGIN_HANDLE_CREATE, bufcount, size, bufs);
if (!req)
GOTO(err_free, rc = -ENOMEM);
- req->rq_replen = lustre_msg_size(1, repsize);
+ ptlrpc_req_set_repsize(req, 2, size);
rc = ptlrpc_queue_wait(req);
if (rc)
GOTO(err_free, rc);
- body = lustre_swab_repbuf(req, 0, sizeof(*body),
+ body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
lustre_swab_llogd_body);
if (body == NULL) {
CERROR ("Can't unpack llogd_body\n");
struct obd_import *imp = loghandle->lgh_ctxt->loc_imp;
struct ptlrpc_request *req = NULL;
struct llogd_body *body;
- int size = sizeof(*body);
- int repsize[2] = {sizeof (*body)};
+ int size[] = { sizeof(struct ptlrpc_body), sizeof(*body) };
int rc;
ENTRY;
req = ptlrpc_prep_req(imp, LUSTRE_LOG_VERSION,
- LLOG_ORIGIN_HANDLE_DESTROY, 1, &size, NULL);
+ LLOG_ORIGIN_HANDLE_DESTROY, 2, size, NULL);
if (!req)
RETURN(-ENOMEM);
- body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
body->lgd_logid = loghandle->lgh_id;
body->lgd_llh_flags = loghandle->lgh_hdr->llh_flags;
- req->rq_replen = lustre_msg_size(1, repsize);
+ ptlrpc_req_set_repsize(req, 2, size);
rc = ptlrpc_queue_wait(req);
ptlrpc_req_finished(req);
struct ptlrpc_request *req = NULL;
struct llogd_body *body;
void * ptr;
- int size = sizeof(*body);
- int repsize[2] = {sizeof (*body)};
+ int size[3] = { sizeof(struct ptlrpc_body), sizeof(*body) };
int rc;
ENTRY;
req = ptlrpc_prep_req(imp, LUSTRE_LOG_VERSION,
- LLOG_ORIGIN_HANDLE_NEXT_BLOCK, 1,&size,NULL);
+ LLOG_ORIGIN_HANDLE_NEXT_BLOCK, 2, size, NULL);
if (!req)
GOTO(out, rc = -ENOMEM);
- body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
body->lgd_logid = loghandle->lgh_id;
body->lgd_ctxt_idx = loghandle->lgh_ctxt->loc_idx - 1;
body->lgd_llh_flags = loghandle->lgh_hdr->llh_flags;
body->lgd_saved_index = *cur_idx;
body->lgd_len = len;
body->lgd_cur_offset = *cur_offset;
- repsize[1] = len;
- req->rq_replen = lustre_msg_size(2, repsize);
+ size[REPLY_REC_OFF + 1] = len;
+ ptlrpc_req_set_repsize(req, 3, size);
rc = ptlrpc_queue_wait(req);
if (rc)
GOTO(out, rc);
- body = lustre_swab_repbuf(req, 0, sizeof(*body),
+ body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
lustre_swab_llogd_body);
if (body == NULL) {
CERROR ("Can't unpack llogd_body\n");
}
/* The log records are swabbed as they are processed */
- ptr = lustre_msg_buf(req->rq_repmsg, 1, len);
+ ptr = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF + 1, len);
if (ptr == NULL) {
CERROR ("Can't unpack bitmap\n");
GOTO(out, rc =-EFAULT);
struct ptlrpc_request *req = NULL;
struct llogd_body *body;
void * ptr;
- int size = sizeof(*body);
- int repsize[2] = {sizeof (*body)};
+ int size[3] = { sizeof(struct ptlrpc_body), sizeof(*body) };
int rc;
ENTRY;
req = ptlrpc_prep_req(imp, LUSTRE_LOG_VERSION,
- LLOG_ORIGIN_HANDLE_PREV_BLOCK, 1,&size,NULL);
+ LLOG_ORIGIN_HANDLE_PREV_BLOCK, 2, size, NULL);
if (!req)
GOTO(out, rc = -ENOMEM);
- body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
body->lgd_logid = loghandle->lgh_id;
body->lgd_ctxt_idx = loghandle->lgh_ctxt->loc_idx - 1;
body->lgd_llh_flags = loghandle->lgh_hdr->llh_flags;
body->lgd_index = prev_idx;
body->lgd_len = len;
- repsize[1] = len;
- req->rq_replen = lustre_msg_size(2, repsize);
+ size[REPLY_REC_OFF + 1] = len;
+ ptlrpc_req_set_repsize(req, 3, size);
rc = ptlrpc_queue_wait(req);
if (rc)
GOTO(out, rc);
- body = lustre_swab_repbuf(req, 0, sizeof(*body),
+ body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
lustre_swab_llogd_body);
if (body == NULL) {
CERROR ("Can't unpack llogd_body\n");
GOTO(out, rc =-EFAULT);
}
- ptr = lustre_msg_buf(req->rq_repmsg, 1, len);
+ ptr = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF + 1, len);
if (ptr == NULL) {
CERROR ("Can't unpack bitmap\n");
GOTO(out, rc =-EFAULT);
struct llogd_body *body;
struct llog_log_hdr *hdr;
struct llog_rec_hdr *llh_hdr;
- int size = sizeof(*body);
- int repsize = sizeof (*hdr);
+ int size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
+ int repsize[2] = { sizeof(struct ptlrpc_body), sizeof(*hdr) };
int rc;
ENTRY;
req = ptlrpc_prep_req(imp, LUSTRE_LOG_VERSION,
- LLOG_ORIGIN_HANDLE_READ_HEADER, 1, &size, NULL);
+ LLOG_ORIGIN_HANDLE_READ_HEADER, 2, size, NULL);
if (!req)
GOTO(out, rc = -ENOMEM);
- body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
body->lgd_logid = handle->lgh_id;
body->lgd_ctxt_idx = handle->lgh_ctxt->loc_idx - 1;
body->lgd_llh_flags = handle->lgh_hdr->llh_flags;
- req->rq_replen = lustre_msg_size(1, &repsize);
+ ptlrpc_req_set_repsize(req, 2, repsize);
rc = ptlrpc_queue_wait(req);
if (rc)
GOTO(out, rc);
- hdr = lustre_swab_repbuf(req, 0, sizeof(*hdr), lustre_swab_llog_hdr);
+ hdr = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*hdr),
+ lustre_swab_llog_hdr);
if (hdr == NULL) {
CERROR ("Can't unpack llog_hdr\n");
GOTO(out, rc =-EFAULT);
struct obd_import *imp;
struct ptlrpc_request *request;
struct llogd_conn_body *req_body;
- int size = sizeof(struct llogd_conn_body);
+ int size[2] = { sizeof(struct ptlrpc_body),
+ sizeof(struct llogd_conn_body) };
int rc;
ENTRY;
imp = ctxt->loc_imp;
request = ptlrpc_prep_req(imp, LUSTRE_LOG_VERSION,
- LLOG_ORIGIN_CONNECT, 1, &size, NULL);
+ LLOG_ORIGIN_CONNECT, 2, size, NULL);
if (!request)
RETURN(-ENOMEM);
- req_body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof(*req_body));
+ req_body = lustre_msg_buf(request->rq_reqmsg, REQ_REC_OFF,
+ sizeof(*req_body));
req_body->lgdc_gen = ctxt->loc_gen;
req_body->lgdc_logid = ctxt->loc_handle->lgh_id;
req_body->lgdc_ctxt_idx = ctxt->loc_idx + 1;
- request->rq_replen = lustre_msg_size(0, NULL);
+ ptlrpc_req_set_repsize(request, 1, NULL);
rc = ptlrpc_queue_wait(request);
ptlrpc_req_finished(request);
int rc;
ENTRY;
- req_body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*req_body));
+ req_body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF,
+ sizeof(*req_body));
ctxt = llog_get_context(obd, req_body->lgdc_ctxt_idx);
rc = llog_connect(ctxt, 1, &req_body->lgdc_logid,
struct llog_logid *logid = NULL;
struct llog_ctxt *ctxt;
char * name = NULL;
- int size = sizeof (*body);
+ int size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
int rc, rc2;
ENTRY;
- body = lustre_swab_reqbuf(req, 0, sizeof(*body),
+ body = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*body),
lustre_swab_llogd_body);
if (body == NULL) {
CERROR ("Can't unpack llogd_body\n");
if (body->lgd_logid.lgl_oid > 0)
logid = &body->lgd_logid;
- if (req->rq_reqmsg->bufcount > 1) {
- name = lustre_msg_string(req->rq_reqmsg, 1, 0);
+ if (lustre_msg_bufcount(req->rq_reqmsg) > 2) {
+ name = lustre_msg_string(req->rq_reqmsg, REQ_REC_OFF + 1, 0);
if (name == NULL) {
CERROR("Can't unpack name\n");
GOTO(out, rc = -EFAULT);
if (rc)
GOTO(out_pop, rc);
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc)
GOTO(out_close, rc = -ENOMEM);
- body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*body));
body->lgd_logid = loghandle->lgh_id;
out_close:
struct lvfs_run_ctxt saved;
struct llog_logid *logid = NULL;
struct llog_ctxt *ctxt;
- int size = sizeof (*body);
+ int size[] = { sizeof(struct ptlrpc_body), sizeof(*body) };
int rc;
__u32 flags;
ENTRY;
- body = lustre_swab_reqbuf(req, 0, sizeof(*body),
+ body = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*body),
lustre_swab_llogd_body);
if (body == NULL) {
CERROR ("Can't unpack llogd_body\n");
if (rc)
GOTO(out_pop, rc);
- rc = lustre_pack_reply(req, 1, &size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc)
GOTO(out_close, rc = -ENOMEM);
- body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body));
+ body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof (*body));
body->lgd_logid = loghandle->lgh_id;
flags = body->lgd_llh_flags;
rc = llog_init_handle(loghandle, LLOG_F_IS_PLAIN, NULL);
__u32 flags;
__u8 *buf;
void * ptr;
- int size[] = {sizeof (*body),
- LLOG_CHUNK_SIZE};
+ int size[3] = { sizeof(struct ptlrpc_body),
+ sizeof(*body),
+ LLOG_CHUNK_SIZE };
int rc, rc2;
ENTRY;
- body = lustre_swab_reqbuf(req, 0, sizeof(*body),
+ body = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*body),
lustre_swab_llogd_body);
if (body == NULL) {
CERROR ("Can't unpack llogd_body\n");
GOTO(out_close, rc);
- rc = lustre_pack_reply(req, 2, size, NULL);
+ rc = lustre_pack_reply(req, 3, size, NULL);
if (rc)
GOTO(out_close, rc = -ENOMEM);
- ptr = lustre_msg_buf(req->rq_repmsg, 0, sizeof (body));
+ ptr = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof (body));
memcpy(ptr, body, sizeof(*body));
- ptr = lustre_msg_buf(req->rq_repmsg, 1, LLOG_CHUNK_SIZE);
+ ptr = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF+1, LLOG_CHUNK_SIZE);
memcpy(ptr, buf, LLOG_CHUNK_SIZE);
out_close:
__u32 flags;
__u8 *buf;
void * ptr;
- int size[] = {sizeof (*body),
- LLOG_CHUNK_SIZE};
+ int size[] = { sizeof(struct ptlrpc_body),
+ sizeof(*body),
+ LLOG_CHUNK_SIZE };
int rc, rc2;
ENTRY;
- body = lustre_swab_reqbuf(req, 0, sizeof(*body),
+ body = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*body),
lustre_swab_llogd_body);
if (body == NULL) {
CERROR ("Can't unpack llogd_body\n");
GOTO(out_close, rc);
- rc = lustre_pack_reply(req, 2, size, NULL);
+ rc = lustre_pack_reply(req, 3, size, NULL);
if (rc)
GOTO(out_close, rc = -ENOMEM);
- ptr = lustre_msg_buf(req->rq_repmsg, 0, sizeof (body));
+ ptr = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(body));
memcpy(ptr, body, sizeof(*body));
- ptr = lustre_msg_buf(req->rq_repmsg, 1, LLOG_CHUNK_SIZE);
+ ptr = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF+1, LLOG_CHUNK_SIZE);
memcpy(ptr, buf, LLOG_CHUNK_SIZE);
out_close:
struct lvfs_run_ctxt saved;
struct llog_ctxt *ctxt;
__u32 flags;
- int size[] = {sizeof (*hdr)};
+ int size[2] = { sizeof(struct ptlrpc_body), sizeof(*hdr) };
int rc, rc2;
ENTRY;
- body = lustre_swab_reqbuf(req, 0, sizeof(*body),
+ body = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*body),
lustre_swab_llogd_body);
if (body == NULL) {
CERROR ("Can't unpack llogd_body\n");
if (rc)
GOTO(out_close, rc);
- rc = lustre_pack_reply(req, 1, size, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc)
GOTO(out_close, rc = -ENOMEM);
- hdr = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*hdr));
+ hdr = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*hdr));
memcpy(hdr, loghandle->lgh_hdr, sizeof(*hdr));
out_close:
void *handle;
ENTRY;
- logcookies = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*logcookies));
- num_cookies = req->rq_reqmsg->buflens[0]/sizeof(*logcookies);
+ logcookies = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF,
+ sizeof(*logcookies));
+ num_cookies = lustre_msg_buflen(req->rq_reqmsg, REQ_REC_OFF) /
+ sizeof(*logcookies);
if (logcookies == NULL || num_cookies == 0) {
DEBUG_REQ(D_HA, req, "no cookies sent");
RETURN(-EFAULT);
char *keyword;
char *buf, *reply;
int rc, buf_len = LLOG_CHUNK_SIZE;
+ int size[2] = { sizeof(struct ptlrpc_body), buf_len };
OBD_ALLOC(buf, buf_len);
if (buf == NULL)
return -ENOMEM;
memset(buf, 0, buf_len);
- keyword = lustre_msg_string(req->rq_reqmsg, 0, 0);
+ keyword = lustre_msg_string(req->rq_reqmsg, REQ_REC_OFF, 0);
if (strcmp(keyword, "config") == 0) {
- char *client = lustre_msg_string(req->rq_reqmsg, 1, 0);
+ char *client = lustre_msg_string(req->rq_reqmsg,
+ REQ_REC_OFF + 1, 0);
rc = llog_catinfo_config(obd, buf, buf_len, client);
} else if (strcmp(keyword, "deletions") == 0) {
rc = llog_catinfo_deletions(obd, buf, buf_len);
rc = -EOPNOTSUPP;
}
- rc = lustre_pack_reply(req, 1, &buf_len, NULL);
+ rc = lustre_pack_reply(req, 2, size, NULL);
if (rc)
GOTO(out_free, rc = -ENOMEM);
- reply = lustre_msg_buf(req->rq_repmsg, 0, buf_len);
+ reply = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, buf_len);
if (strlen(buf) == 0)
sprintf(buf, "%s", "No log informations\n");
memcpy(reply, buf, buf_len);
void ptlrpc_lprocfs_rpc_sent(struct ptlrpc_request *req)
{
struct lprocfs_stats *svc_stats;
- int opc = opcode_offset(req->rq_reqmsg->opc);
+ int opc = opcode_offset(lustre_msg_get_opc(req->rq_reqmsg));
svc_stats = req->rq_import->imp_obd->obd_svc_stats;
if (svc_stats == NULL || opc <= 0)
ENTRY;
req = ptlrpc_prep_req(obd->u.cli.cl_import, LUSTRE_OBD_VERSION,
- OBD_PING, 0, NULL, NULL);
+ OBD_PING, 1, NULL, NULL);
if (req == NULL)
RETURN(-ENOMEM);
- req->rq_replen = lustre_msg_size(0, NULL);
+ ptlrpc_req_set_repsize(req, 1, NULL);
req->rq_send_state = LUSTRE_IMP_FULL;
req->rq_no_resend = 1;
LASSERT (rs != NULL);
LASSERT (req->rq_repmsg != NULL);
LASSERT (may_be_difficult || !rs->rs_difficult);
- LASSERT (req->rq_repmsg == &rs->rs_msg);
+ LASSERT (req->rq_repmsg == rs->rs_msg);
LASSERT (rs->rs_cb_id.cbid_fn == reply_out_callback);
LASSERT (rs->rs_cb_id.cbid_arg == rs);
LASSERT (req->rq_repmsg != NULL);
if (req->rq_type != PTL_RPC_MSG_ERR)
req->rq_type = PTL_RPC_MSG_REPLY;
- req->rq_repmsg->type = req->rq_type;
- req->rq_repmsg->status = req->rq_status;
- req->rq_repmsg->opc = req->rq_reqmsg->opc;
+ lustre_msg_set_type(req->rq_repmsg, req->rq_type);
+ lustre_msg_set_status(req->rq_repmsg, req->rq_status);
+ lustre_msg_set_opc(req->rq_repmsg, lustre_msg_get_opc(req->rq_reqmsg));
if (req->rq_export == NULL || req->rq_export->exp_connection == NULL)
conn = ptlrpc_get_connection(req->rq_peer, req->rq_self, NULL);
ENTRY;
if (!req->rq_repmsg) {
- rc = lustre_pack_reply(req, 0, NULL, NULL);
+ rc = lustre_pack_reply(req, 1, NULL, NULL);
if (rc)
RETURN(rc);
}
req->rq_type = PTL_RPC_MSG_ERR;
- rc = ptlrpc_send_reply (req, 0);
+ rc = ptlrpc_send_reply(req, 0);
RETURN(rc);
}
RETURN(rc);
}
- request->rq_reqmsg->handle = request->rq_import->imp_remote_handle;
- request->rq_reqmsg->type = PTL_RPC_MSG_REQUEST;
- request->rq_reqmsg->conn_cnt = request->rq_import->imp_conn_cnt;
+ lustre_msg_set_handle(request->rq_reqmsg,
+ &request->rq_import->imp_remote_handle);
+ lustre_msg_set_type(request->rq_reqmsg, PTL_RPC_MSG_REQUEST);
+ lustre_msg_set_conn_cnt(request->rq_reqmsg,
+ request->rq_import->imp_conn_cnt);
if (!noreply) {
LASSERT (request->rq_replen != 0);
/* drop request_out_callback refs, we couldn't start the send */
atomic_dec(&request->rq_import->imp_inflight);
- ptlrpc_req_finished (request);
+ ptlrpc_req_finished(request);
if (noreply)
RETURN(rc);
#include <obd_class.h>
#include <lustre_net.h>
+#if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(2,0,0,0)
+#error "lustre_msg_v1 has been deprecated since 1.6.0, please remove it"
+#elif LUSTRE_VERSION_CODE > OBD_OCD_VERSION(1,6,7,0)
+#warning "lustre_msg_v1 has been deprecated since 1.6.0, consider removing it"
+#endif
-#define HDR_SIZE(count) \
- size_round(offsetof (struct lustre_msg, buflens[(count)]))
+static inline int lustre_msg_hdr_size_v1(int count)
+{
+ return size_round(offsetof(struct lustre_msg_v1, lm_buflens[count]));
+}
+
+static inline int lustre_msg_hdr_size_v2(int count)
+{
+ return size_round(offsetof(struct lustre_msg_v2, lm_buflens[count]));
+}
int lustre_msg_swabbed(struct lustre_msg *msg)
{
- return (msg->magic == __swab32(PTLRPC_MSG_MAGIC));
+ return (msg->lm_magic == LUSTRE_MSG_MAGIC_V1_SWABBED) ||
+ (msg->lm_magic == LUSTRE_MSG_MAGIC_V2_SWABBED);
}
-int lustre_msg_check_version(struct lustre_msg *msg, __u32 version)
+static inline int
+lustre_msg_check_version_v2(struct lustre_msg_v2 *msg, __u32 version)
{
+ __u32 ver = lustre_msg_get_version(msg);
+
if (lustre_msg_swabbed(msg))
- return (__swab32(msg->version) & LUSTRE_VERSION_MASK) != version;
+ return (__swab32(ver) & LUSTRE_VERSION_MASK) != version;
+
+ return (ver & LUSTRE_VERSION_MASK) != version;
+}
+
+int lustre_msg_check_version(struct lustre_msg *msg, __u32 version)
+{
+ 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 lustre_msg_check_version_v2(msg, version);
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+ return -EINVAL;
+ }
+}
+
+static inline int lustre_msg_size_v1(int count, int *lengths)
+{
+ int size;
+ int i;
+
+ LASSERT(count >= 0);
+ size = lustre_msg_hdr_size_v1(count);
+ for (i = 0; i < count; i++)
+ size += size_round(lengths[i]);
+
+ return size;
+}
+
+static inline int lustre_msg_size_v2(int count, int *lengths)
+{
+ int size;
+ int i;
+
+ size = lustre_msg_hdr_size_v2(count);
+ for (i = 0; i < count; i++)
+ size += size_round(lengths[i]);
+
+ return size;
+}
- return (msg->version & LUSTRE_VERSION_MASK) != version;
+/* This returns the size of the buffer that is required to hold a lustre_msg
+ * with the given sub-buffer lengths. */
+int lustre_msg_size(__u32 magic, int count, int *lens)
+{
+ int size[] = { sizeof(struct ptlrpc_body) };
+
+ if (!lens) {
+ LASSERT(count == 1);
+ lens = size;
+ }
+
+ LASSERT(count > 0);
+ LASSERT(lens[MSG_PTLRPC_BODY_OFF] == sizeof(struct ptlrpc_body));
+
+ switch (magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ return lustre_msg_size_v1(count - 1, lens + 1);
+ case LUSTRE_MSG_MAGIC_V2:
+ return lustre_msg_size_v2(count, lens);
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", magic);
+ return -EINVAL;
+ }
+}
+
+static void
+lustre_init_msg_v1(void *m, int count, int *lens, char **bufs)
+{
+ struct lustre_msg_v1 *msg = (struct lustre_msg_v1 *)m;
+ char *ptr;
+ int i;
+
+ LASSERT(count >= 0);
+ msg->lm_magic = LUSTRE_MSG_MAGIC_V1;
+ msg->lm_version = PTLRPC_MSG_VERSION;
+ msg->lm_bufcount = count;
+
+ for (i = 0; i < count; i++)
+ msg->lm_buflens[i] = lens[i];
+
+ if (bufs == NULL)
+ return;
+
+ ptr = (char *)msg + lustre_msg_hdr_size_v1(count);
+ for (i = 0; i < count; i++) {
+ char *tmp = bufs[i];
+ LOGL(tmp, lens[i], ptr);
+ }
}
static void
-lustre_init_msg (struct lustre_msg *msg, int count, int *lens, char **bufs)
+lustre_init_msg_v2(struct lustre_msg_v2 *msg, int count, int *lens, char **bufs)
{
char *ptr;
- int i;
+ int i;
+
+ msg->lm_bufcount = count;
+ /* XXX: lm_secflvr uninitialized here */
+ msg->lm_magic = LUSTRE_MSG_MAGIC_V2;
- msg->magic = PTLRPC_MSG_MAGIC;
- msg->version = PTLRPC_MSG_VERSION;
- msg->bufcount = count;
for (i = 0; i < count; i++)
- msg->buflens[i] = lens[i];
+ msg->lm_buflens[i] = lens[i];
if (bufs == NULL)
return;
- ptr = (char *)msg + HDR_SIZE(count);
+ ptr = (char *)msg + lustre_msg_hdr_size_v2(count);
for (i = 0; i < count; i++) {
char *tmp = bufs[i];
LOGL(tmp, lens[i], ptr);
}
}
-int lustre_pack_request (struct ptlrpc_request *req,
- int count, int *lens, char **bufs)
+static int lustre_pack_request_v1(struct ptlrpc_request *req,
+ int count, int *lens, char **bufs)
{
int reqlen;
ENTRY;
- reqlen = lustre_msg_size (count, lens);
+ reqlen = lustre_msg_size_v1(count, lens);
+
/* See if we got it from prealloc pool */
if (req->rq_reqmsg) {
/* Cannot return error here, that would create
if (req->rq_reqmsg == NULL)
RETURN(-ENOMEM);
}
+
req->rq_reqlen = reqlen;
- lustre_init_msg (req->rq_reqmsg, count, lens, bufs);
+ lustre_init_msg_v1(req->rq_reqmsg, count, lens, bufs);
RETURN (0);
}
+static int lustre_pack_request_v2(struct ptlrpc_request *req,
+ int count, int *lens, char **bufs)
+{
+ int reqlen;
+ ENTRY;
+
+ reqlen = lustre_msg_size_v2(count, lens);
+
+ /* See if we got it from prealloc pool */
+ if (req->rq_reqmsg) {
+ /* Cannot return error here, that would create
+ infinite loop in ptlrpc_prep_req_pool */
+ /* In this case ptlrpc_prep_req_from_pool sets req->rq_reqlen
+ to maximum size that would fit into this preallocated
+ request */
+ LASSERTF(req->rq_reqlen >= reqlen, "req->rq_reqlen %d, "
+ "reqlen %d\n",req->rq_reqlen,
+ reqlen);
+ memset(req->rq_reqmsg, 0, reqlen);
+ } else {
+ OBD_ALLOC(req->rq_reqmsg, reqlen);
+ if (req->rq_reqmsg == NULL)
+ RETURN(-ENOMEM);
+ }
+
+ req->rq_reqlen = reqlen;
+
+ lustre_init_msg_v2(req->rq_reqmsg, count, lens, bufs);
+ lustre_msg_add_version(req->rq_reqmsg, PTLRPC_MSG_VERSION);
+ RETURN(0);
+}
+
+int lustre_pack_request(struct ptlrpc_request *req, __u32 magic, int count,
+ int *lens, char **bufs)
+{
+ int size[] = { sizeof(struct ptlrpc_body) };
+
+ if (!lens) {
+ LASSERT(count == 1);
+ lens = size;
+ }
+
+ LASSERT(count > 0);
+ LASSERT(lens[MSG_PTLRPC_BODY_OFF] == sizeof(struct ptlrpc_body));
+
+ switch (magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ return lustre_pack_request_v1(req, count - 1, lens + 1,
+ bufs ? bufs + 1 : NULL);
+ case LUSTRE_MSG_MAGIC_V2:
+ return lustre_pack_request_v2(req, count, lens, bufs);
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", magic);
+ return -EINVAL;
+ }
+}
+
#if RS_DEBUG
CFS_LIST_HEAD(ptlrpc_rs_debug_lru);
spinlock_t ptlrpc_rs_debug_lock;
return rs;
}
-
-int lustre_pack_reply (struct ptlrpc_request *req,
- int count, int *lens, char **bufs)
+static int lustre_pack_reply_v1(struct ptlrpc_request *req, int count,
+ int *lens, char **bufs)
{
struct ptlrpc_reply_state *rs;
int msg_len;
LASSERT (req->rq_reply_state == NULL);
- msg_len = lustre_msg_size (count, lens);
- size = offsetof (struct ptlrpc_reply_state, rs_msg) + msg_len;
- OBD_ALLOC (rs, size);
+ msg_len = lustre_msg_size_v1(count, lens);
+ size = sizeof(struct ptlrpc_reply_state) + msg_len;
+ OBD_ALLOC(rs, size);
if (unlikely(rs == NULL)) {
rs = lustre_get_emerg_rs(req->rq_rqbd->rqbd_service, size);
if (!rs)
rs->rs_size = size;
CFS_INIT_LIST_HEAD(&rs->rs_exp_list);
CFS_INIT_LIST_HEAD(&rs->rs_obd_list);
+ rs->rs_msg = (struct lustre_msg *)(rs + 1);
req->rq_replen = msg_len;
req->rq_reply_state = rs;
- req->rq_repmsg = &rs->rs_msg;
- lustre_init_msg (&rs->rs_msg, count, lens, bufs);
+ req->rq_repmsg = rs->rs_msg;
+ lustre_init_msg_v1(rs->rs_msg, count, lens, bufs);
PTLRPC_RS_DEBUG_LRU_ADD(rs);
RETURN (0);
}
-/*
- * shrink @segment to size @newlen. if @move_data is non-zero, we also move
- * data forward from @segment + 1.
- *
- * if @newlen == 0, we remove the segment completely, but we still keep the
- * totally bufcount the same to save possible data moving. this will leave a
- * unused segment with size 0 at the tail, but that's ok.
- *
- * CAUTION:
- * + if any buffers higher than @segment has been filled in, must call shrink
- * with non-zero @move_data.
- * + caller should NOT keep pointers to msg buffers which higher than @segment
- * after call shrink.
- */
-void lustre_shrink_reply(struct ptlrpc_request *req,
- int segment, unsigned int newlen, int move_data)
+static int lustre_pack_reply_v2(struct ptlrpc_request *req, int count,
+ int *lens, char **bufs)
{
- struct lustre_msg *msg = req->rq_repmsg;
- char *tail = NULL, *newpos;
- int tail_len = 0, n;
+ struct ptlrpc_reply_state *rs;
+ int msg_len;
+ int size;
+ ENTRY;
+
+ LASSERT(req->rq_reply_state == NULL);
+
+ msg_len = lustre_msg_size_v2(count, lens);
+ size = sizeof(struct ptlrpc_reply_state) + msg_len;
+ OBD_ALLOC(rs, size);
+ if (unlikely(rs == NULL)) {
+ rs = lustre_get_emerg_rs(req->rq_rqbd->rqbd_service, size);
+ if (!rs)
+ RETURN (-ENOMEM);
+ }
+ atomic_set(&rs->rs_refcount, 1); /* 1 ref for rq_reply_state */
+ rs->rs_cb_id.cbid_fn = reply_out_callback;
+ rs->rs_cb_id.cbid_arg = rs;
+ rs->rs_service = req->rq_rqbd->rqbd_service;
+ rs->rs_size = size;
+ CFS_INIT_LIST_HEAD(&rs->rs_exp_list);
+ CFS_INIT_LIST_HEAD(&rs->rs_obd_list);
+ rs->rs_msg = (struct lustre_msg *)(rs + 1);
+
+ req->rq_replen = msg_len;
+ req->rq_reply_state = rs;
+ req->rq_repmsg = rs->rs_msg;
+ lustre_init_msg_v2(rs->rs_msg, count, lens, bufs);
+ lustre_msg_add_version(rs->rs_msg, PTLRPC_MSG_VERSION);
+
+ PTLRPC_RS_DEBUG_LRU_ADD(rs);
+
+ RETURN(0);
+}
+
+int lustre_pack_reply(struct ptlrpc_request *req, int count, int *lens,
+ char **bufs)
+{
+ int size[] = { sizeof(struct ptlrpc_body) };
+
+ if (!lens) {
+ LASSERT(count == 1);
+ lens = size;
+ }
+
+ LASSERT(count > 0);
+ LASSERT(lens[MSG_PTLRPC_BODY_OFF] == sizeof(struct ptlrpc_body));
+
+ switch (req->rq_reqmsg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ return lustre_pack_reply_v1(req, count - 1, lens + 1,
+ bufs ? bufs + 1 : NULL);
+ case LUSTRE_MSG_MAGIC_V2:
+ case LUSTRE_MSG_MAGIC_V2_SWABBED:
+ return lustre_pack_reply_v2(req, count, lens, bufs);
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n",
+ req->rq_reqmsg->lm_magic);
+ return -EINVAL;
+ }
+}
+
+void *lustre_msg_buf_v1(void *msg, int n, int min_size)
+{
+ struct lustre_msg_v1 *m = (struct lustre_msg_v1 *)msg;
+ int i, offset, buflen, bufcount;
+
+ LASSERT(m != NULL);
+ LASSERT(n >= 0);
+
+ bufcount = m->lm_bufcount;
+ if (n >= bufcount) {
+ CDEBUG(D_INFO, "msg %p buffer[%d] not present (count %d)\n",
+ m, n, bufcount);
+ return NULL;
+ }
+
+ buflen = m->lm_buflens[n];
+ if (buflen < min_size) {
+ CERROR("msg %p buffer[%d] size %d too small (required %d)\n",
+ m, n, buflen, min_size);
+ LBUG();
+ return NULL;
+ }
+
+ offset = lustre_msg_hdr_size_v1(bufcount);
+ for (i = 0; i < n; i++)
+ offset += size_round(m->lm_buflens[i]);
+
+ return (char *)m + offset;
+}
+
+void *lustre_msg_buf_v2(struct lustre_msg_v2 *m, int n, int min_size)
+{
+ int i, offset, buflen, bufcount;
+
+ LASSERT(m != NULL);
+ LASSERT(n >= 0);
+
+ bufcount = m->lm_bufcount;
+ if (n >= bufcount) {
+ CDEBUG(D_INFO, "msg %p buffer[%d] not present (count %d)\n",
+ m, n, bufcount);
+ return NULL;
+ }
+
+ buflen = m->lm_buflens[n];
+ if (buflen < min_size) {
+ CERROR("msg %p buffer[%d] size %d too small (required %d)\n",
+ m, n, buflen, min_size);
+ return NULL;
+ }
+
+ offset = lustre_msg_hdr_size_v2(bufcount);
+ for (i = 0; i < n; i++)
+ offset += size_round(m->lm_buflens[i]);
+
+ return (char *)m + offset;
+}
+
+void *lustre_msg_buf(struct lustre_msg *m, int n, int min_size)
+{
+ switch (m->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ return lustre_msg_buf_v1(m, n - 1, min_size);
+ case LUSTRE_MSG_MAGIC_V2:
+ case LUSTRE_MSG_MAGIC_V2_SWABBED:
+ return lustre_msg_buf_v2(m, n, min_size);
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", m->lm_magic);
+ return NULL;
+ }
+}
+
+void lustre_shrink_reply_v1(struct ptlrpc_request *req, int segment,
+ unsigned int newlen, int move_data)
+{
+ struct lustre_msg_v1 *msg = (struct lustre_msg_v1 *)req->rq_repmsg;
+ char *tail = NULL, *newpos;
+ int tail_len = 0, n;
LASSERT(req->rq_reply_state);
LASSERT(msg);
- LASSERT(msg->bufcount > segment);
- LASSERT(msg->buflens[segment] >= newlen);
+ LASSERT(segment >= 0);
+ LASSERT(msg->lm_bufcount > segment);
+ LASSERT(msg->lm_buflens[segment] >= newlen);
- if (msg->buflens[segment] == newlen)
+ if (msg->lm_buflens[segment] == newlen)
return;
- if (move_data && msg->bufcount > segment + 1) {
- tail = lustre_msg_buf(msg, segment + 1, 0);
- for (n = segment + 1; n < msg->bufcount; n++)
- tail_len += size_round(msg->buflens[n]);
+ if (move_data && msg->lm_bufcount > segment + 1) {
+ tail = lustre_msg_buf_v1(msg, segment + 1, 0);
+ for (n = segment + 1; n < msg->lm_bufcount; n++)
+ tail_len += size_round(msg->lm_buflens[n]);
}
- msg->buflens[segment] = newlen;
+ msg->lm_buflens[segment] = newlen;
if (tail && tail_len) {
- newpos = lustre_msg_buf(msg, segment + 1, 0);
+ newpos = lustre_msg_buf_v1(msg, segment + 1, 0);
LASSERT(newpos <= tail);
if (newpos != tail)
memcpy(newpos, tail, tail_len);
}
- if (newlen == 0 && msg->bufcount > segment + 1) {
- memmove(&msg->buflens[segment], &msg->buflens[segment + 1],
- (msg->bufcount - segment - 1) * sizeof(__u32));
- msg->buflens[msg->bufcount - 1] = 0;
+ if (newlen == 0 && msg->lm_bufcount > segment + 1) {
+ memmove(&msg->lm_buflens[segment], &msg->lm_buflens[segment + 1],
+ (msg->lm_bufcount - segment - 1) * sizeof(__u32));
+ msg->lm_buflens[msg->lm_bufcount - 1] = 0;
}
- req->rq_replen = lustre_msg_size(msg->bufcount, msg->buflens);
+ req->rq_replen = lustre_msg_size_v1(msg->lm_bufcount, msg->lm_buflens);
+}
+
+void lustre_shrink_reply_v2(struct ptlrpc_request *req, int segment,
+ unsigned int newlen, int move_data)
+{
+ struct lustre_msg_v2 *msg = req->rq_repmsg;
+ char *tail = NULL, *newpos;
+ int tail_len = 0, n;
+
+ LASSERT(req->rq_reply_state);
+ LASSERT(msg);
+ LASSERT(msg->lm_bufcount > segment);
+ LASSERT(msg->lm_buflens[segment] >= newlen);
+
+ if (msg->lm_buflens[segment] == newlen)
+ return;
+
+ if (move_data && msg->lm_bufcount > segment + 1) {
+ tail = lustre_msg_buf_v2(msg, segment + 1, 0);
+ for (n = segment + 1; n < msg->lm_bufcount; n++)
+ tail_len += size_round(msg->lm_buflens[n]);
+ }
+
+ msg->lm_buflens[segment] = newlen;
+
+ if (tail && tail_len) {
+ newpos = lustre_msg_buf_v2(msg, segment + 1, 0);
+ LASSERT(newpos <= tail);
+ if (newpos != tail)
+ memcpy(newpos, tail, tail_len);
+ }
+
+ if (newlen == 0 && msg->lm_bufcount > segment + 1) {
+ memmove(&msg->lm_buflens[segment], &msg->lm_buflens[segment + 1],
+ (msg->lm_bufcount - segment - 1) * sizeof(__u32));
+ msg->lm_buflens[msg->lm_bufcount - 1] = 0;
+ }
+
+ req->rq_replen = lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens);
+}
+
+/*
+ * shrink @segment to size @newlen. if @move_data is non-zero, we also move
+ * data forward from @segment + 1.
+ *
+ * if @newlen == 0, we remove the segment completely, but we still keep the
+ * totally bufcount the same to save possible data moving. this will leave a
+ * unused segment with size 0 at the tail, but that's ok.
+ *
+ * CAUTION:
+ * + if any buffers higher than @segment has been filled in, must call shrink
+ * with non-zero @move_data.
+ * + caller should NOT keep pointers to msg buffers which higher than @segment
+ * after call shrink.
+ */
+void lustre_shrink_reply(struct ptlrpc_request *req, int segment,
+ unsigned int newlen, int move_data)
+{
+ switch (req->rq_repmsg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ lustre_shrink_reply_v1(req, segment - 1, newlen, move_data);
+ return;
+ case LUSTRE_MSG_MAGIC_V2:
+ lustre_shrink_reply_v2(req, segment, newlen, move_data);
+ return;
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n",
+ req->rq_repmsg->lm_magic);
+ }
}
-void lustre_free_reply_state (struct ptlrpc_reply_state *rs)
+void lustre_free_reply_state(struct ptlrpc_reply_state *rs)
{
PTLRPC_RS_DEBUG_LRU_DEL(rs);
}
}
-/* This returns the size of the buffer that is required to hold a lustre_msg
- * with the given sub-buffer lengths. */
-int lustre_msg_size(int count, int *lengths)
+int lustre_unpack_msg_v1(void *msg, int len)
{
- int size;
- int i;
+ struct lustre_msg_v1 *m = (struct lustre_msg_v1 *)msg;
+ int flipped, required_len, i;
+ ENTRY;
- size = HDR_SIZE (count);
- for (i = 0; i < count; i++)
- size += size_round(lengths[i]);
+ /* Now we know the sender speaks my language. */
+ required_len = lustre_msg_hdr_size_v1(0);
+ if (len < required_len) {
+ /* can't even look inside the message */
+ CERROR("message length %d too small for lustre_msg\n", len);
+ RETURN(-EINVAL);
+ }
+
+ flipped = lustre_msg_swabbed((struct lustre_msg *)m);
+
+ if (flipped) {
+ __swab32s(&m->lm_type);
+ __swab32s(&m->lm_version);
+ __swab32s(&m->lm_opc);
+ __swab64s(&m->lm_last_xid);
+ __swab64s(&m->lm_last_committed);
+ __swab64s(&m->lm_transno);
+ __swab32s(&m->lm_status);
+ __swab32s(&m->lm_flags);
+ __swab32s(&m->lm_conn_cnt);
+ __swab32s(&m->lm_bufcount);
+ }
+
+ if (m->lm_version != PTLRPC_MSG_VERSION) {
+ CERROR("wrong lustre_msg version %08x\n", m->lm_version);
+ RETURN(-EINVAL);
+ }
+
+ required_len = lustre_msg_hdr_size_v1(m->lm_bufcount);
+ if (len < required_len) {
+ /* didn't receive all the buffer lengths */
+ CERROR("message length %d too small for %d buflens\n",
+ len, m->lm_bufcount);
+ RETURN(-EINVAL);
+ }
+
+ for (i = 0; i < m->lm_bufcount; i++) {
+ if (flipped)
+ __swab32s (&m->lm_buflens[i]);
+ required_len += size_round(m->lm_buflens[i]);
+ }
+
+ if (len < required_len) {
+ CERROR("len: %d, required_len %d\n", len, required_len);
+ CERROR("bufcount: %d\n", m->lm_bufcount);
+ for (i = 0; i < m->lm_bufcount; i++)
+ CERROR("buffer %d length %d\n", i, m->lm_buflens[i]);
+ RETURN(-EINVAL);
+ }
+
+ RETURN(0);
+}
+
+static int lustre_unpack_msg_v2(struct lustre_msg_v2 *m, int len)
+{
+ int flipped, required_len, i;
+ ENTRY;
+
+ required_len = lustre_msg_hdr_size_v2(m->lm_bufcount);
+ if (len < required_len) {
+ /* didn't receive all the buffer lengths */
+ CERROR ("message length %d too small for %d buflens\n",
+ len, m->lm_bufcount);
+ RETURN(-EINVAL);
+ }
+
+ flipped = lustre_msg_swabbed(m);
+
+ if (flipped) {
+ __swab32s(&m->lm_bufcount);
+ __swab32s(&m->lm_secflvr);
+ __swab32s(&m->lm_repsize);
+ }
+
+ for (i = 0; i < m->lm_bufcount; i++) {
+ if (flipped)
+ __swab32s(&m->lm_buflens[i]);
+ required_len += size_round(m->lm_buflens[i]);
+ }
+
+ if (len < required_len) {
+ CERROR("len: %d, required_len %d\n", len, required_len);
+ CERROR("bufcount: %d\n", m->lm_bufcount);
+ for (i = 0; i < m->lm_bufcount; i++)
+ CERROR("buffer %d length %d\n", i, m->lm_buflens[i]);
+ RETURN(-EINVAL);
+ }
- return size;
+ RETURN(0);
}
int lustre_unpack_msg(struct lustre_msg *m, int len)
{
- int flipped;
- int required_len;
- int i;
+ int required_len, rc;
ENTRY;
/* We can provide a slightly better error log, if we check the
* rather than a short message.
*
*/
- required_len = MAX (offsetof (struct lustre_msg, version) +
- sizeof (m->version),
- offsetof (struct lustre_msg, magic) +
- sizeof (m->magic));
+ required_len = offsetof(struct lustre_msg, lm_magic) +
+ sizeof(m->lm_magic);
if (len < required_len) {
/* can't even look inside the message */
- CERROR ("message length %d too small for magic/version check\n",
- len);
- RETURN (-EINVAL);
+ CERROR("message length %d too small for magic/version check\n",
+ len);
+ RETURN(-EINVAL);
}
- flipped = lustre_msg_swabbed(m);
- if (flipped)
- __swab32s (&m->version);
- else if (m->magic != PTLRPC_MSG_MAGIC) {
- CERROR("wrong lustre_msg magic %#08x\n", m->magic);
- RETURN (-EINVAL);
+ switch (m->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ rc = lustre_unpack_msg_v1(m, len);
+ break;
+ case LUSTRE_MSG_MAGIC_V2:
+ case LUSTRE_MSG_MAGIC_V2_SWABBED:
+ rc = lustre_unpack_msg_v2(m, len);
+ break;
+ default:
+ CERROR("bad lustre msg magic: %#08X\n", m->lm_magic);
+ return -EINVAL;
}
- if ((m->version & ~LUSTRE_VERSION_MASK) != PTLRPC_MSG_VERSION) {
- CERROR("wrong lustre_msg version %#08x\n", m->version);
- RETURN (-EINVAL);
- }
+ RETURN(rc);
+}
- /* Now we know the sender speaks my language (but possibly flipped)...*/
- required_len = HDR_SIZE(0);
- if (len < required_len) {
- /* can't even look inside the message */
- CERROR ("message length %d too small for lustre_msg\n", len);
- RETURN (-EINVAL);
- }
+static inline int lustre_unpack_ptlrpc_body_v2(struct lustre_msg_v2 *m)
+{
+ struct ptlrpc_body *pb;
+ ENTRY;
- if (flipped) {
- __swab32s (&m->type);
- __swab32s (&m->opc);
- __swab64s (&m->last_xid);
- __swab64s (&m->last_committed);
- __swab64s (&m->transno);
- __swab32s (&m->status);
- __swab32s (&m->flags);
- __swab32s (&m->conn_cnt);
- __swab32s (&m->bufcount);
+ pb = lustre_swab_buf(m, MSG_PTLRPC_BODY_OFF, sizeof(*pb),
+ lustre_swab_ptlrpc_body);
+ if (!pb) {
+ CERROR("error unpacking ptlrpc body");
+ RETURN(-EFAULT);
}
- required_len = HDR_SIZE(m->bufcount);
+ if ((pb->pb_version & ~LUSTRE_VERSION_MASK) != PTLRPC_MSG_VERSION) {
+ CERROR("wrong lustre_msg version %08x\n", pb->pb_version);
+ RETURN(-EINVAL);
+ }
- if (len < required_len) {
- /* didn't receive all the buffer lengths */
- CERROR ("message length %d too small for %d buflens\n",
- len, m->bufcount);
- RETURN(-EINVAL);
- }
+ RETURN(0);
+}
- for (i = 0; i < m->bufcount; i++) {
- if (flipped)
- __swab32s (&m->buflens[i]);
- required_len += size_round(m->buflens[i]);
+int lustre_unpack_ptlrpc_body(struct lustre_msg *m)
+{
+ switch (m->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 lustre_unpack_ptlrpc_body_v2(m);
+ default:
+ CERROR("bad lustre msg magic: %#08X\n", m->lm_magic);
+ return -EINVAL;
}
+}
- if (len < required_len) {
- CERROR("len: %d, required_len %d\n", len, required_len);
- CERROR("bufcount: %d\n", m->bufcount);
- for (i = 0; i < m->bufcount; i++)
- CERROR("buffer %d length %d\n", i, m->buflens[i]);
- RETURN(-EINVAL);
- }
+static inline int lustre_msg_buflen_v1(void *msg, int n)
+{
+ struct lustre_msg_v1 *m = (struct lustre_msg_v1 *)msg;
- RETURN(0);
+ LASSERT(n >= 0);
+ if (n >= m->lm_bufcount)
+ return 0;
+
+ return m->lm_buflens[n];
+}
+
+static inline int lustre_msg_buflen_v2(struct lustre_msg_v2 *m, int n)
+{
+ if (n >= m->lm_bufcount)
+ return 0;
+
+ return m->lm_buflens[n];
}
/**
*/
int lustre_msg_buflen(struct lustre_msg *m, int n)
{
- if (n >= m->bufcount)
- return 0;
-
- return m->buflens[n];
+ switch (m->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ return lustre_msg_buflen_v1(m, n - 1);
+ case LUSTRE_MSG_MAGIC_V2:
+ case LUSTRE_MSG_MAGIC_V2_SWABBED:
+ return lustre_msg_buflen_v2(m, n);
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", m->lm_magic);
+ return -EINVAL;
+ }
}
EXPORT_SYMBOL(lustre_msg_buflen);
-void *lustre_msg_buf(struct lustre_msg *m, int n, int min_size)
+static inline void lustre_msg_set_buflen_v1(void *msg, int n, int len)
{
- int i;
- int offset;
- int buflen;
- int bufcount;
+ struct lustre_msg_v1 *m = (struct lustre_msg_v1 *)msg;
- LASSERT (m != NULL);
- LASSERT (n >= 0);
+ LASSERT(n >= 0);
+ if (n >= m->lm_bufcount)
+ LBUG();
- bufcount = m->bufcount;
- if (n >= bufcount) {
- CERROR("msg %p buffer[%d] not present (count %d)\n",
- m, n, bufcount);
- return NULL;
- }
+ m->lm_buflens[n] = len;
+}
- buflen = m->buflens[n];
- if (buflen < min_size) {
- CERROR("msg %p buffer[%d] size %d too small (required %d)\n",
- m, n, buflen, min_size);
- return NULL;
+static inline int
+lustre_msg_set_buflen_v2(struct lustre_msg_v2 *m, int n, int len)
+{
+ if (n >= m->lm_bufcount)
+ LBUG();
+
+ m->lm_buflens[n] = len;
+}
+
+void lustre_msg_set_buflen(struct lustre_msg *m, int n, int len)
+{
+ switch (m->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ lustre_msg_set_buflen_v1(m, n - 1, len);
+ return;
+ case LUSTRE_MSG_MAGIC_V2:
+ case LUSTRE_MSG_MAGIC_V2_SWABBED:
+ lustre_msg_set_buflen_v2(m, n, len);
+ return;
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", m->lm_magic);
}
+}
- offset = HDR_SIZE(bufcount);
- for (i = 0; i < n; i++)
- offset += size_round(m->buflens[i]);
+EXPORT_SYMBOL(lustre_msg_set_buflen);
- return (char *)m + offset;
+/* NB return the bufcount for lustre_msg_v2 format, so if message is packed
+ * in V1 format, the result is one bigger. (add struct ptlrpc_body). */
+int lustre_msg_bufcount(struct lustre_msg *m)
+{
+ switch (m->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ return ((struct lustre_msg_v1 *)m)->lm_bufcount + 1;
+ case LUSTRE_MSG_MAGIC_V2:
+ case LUSTRE_MSG_MAGIC_V2_SWABBED:
+ return m->lm_bufcount;
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", m->lm_magic);
+ return -EINVAL;
+ }
}
+EXPORT_SYMBOL(lustre_msg_bufcount);
-char *lustre_msg_string (struct lustre_msg *m, int index, int max_len)
+char *lustre_msg_string(struct lustre_msg *m, int index, int max_len)
{
/* max_len == 0 means the string should fill the buffer */
- char *str = lustre_msg_buf (m, index, 0);
- int slen;
- int blen;
+ char *str;
+ int slen, blen;
+
+ switch (m->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ str = lustre_msg_buf_v1(m, index - 1, 0);
+ blen = lustre_msg_buflen_v1(m, index - 1);
+ break;
+ case LUSTRE_MSG_MAGIC_V2:
+ case LUSTRE_MSG_MAGIC_V2_SWABBED:
+ str = lustre_msg_buf_v2(m, index, 0);
+ blen = lustre_msg_buflen_v2(m, index);
+ break;
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", m->lm_magic);
+ }
if (str == NULL) {
CERROR ("can't unpack string in msg %p buffer[%d]\n", m, index);
- return (NULL);
+ return NULL;
}
- blen = m->buflens[index];
- slen = strnlen (str, blen);
+ slen = strnlen(str, blen);
if (slen == blen) { /* not NULL terminated */
- CERROR ("can't unpack non-NULL terminated string in "
+ CERROR("can't unpack non-NULL terminated string in "
"msg %p buffer[%d] len %d\n", m, index, blen);
- return (NULL);
+ return NULL;
}
if (max_len == 0) {
if (slen != blen - 1) {
- CERROR ("can't unpack short string in msg %p "
- "buffer[%d] len %d: strlen %d\n",
- m, index, blen, slen);
- return (NULL);
+ CERROR("can't unpack short string in msg %p "
+ "buffer[%d] len %d: strlen %d\n",
+ m, index, blen, slen);
+ return NULL;
}
} else if (slen > max_len) {
- CERROR ("can't unpack oversized string in msg %p "
- "buffer[%d] len %d strlen %d: max %d expected\n",
- m, index, blen, slen, max_len);
- return (NULL);
+ CERROR("can't unpack oversized string in msg %p "
+ "buffer[%d] len %d strlen %d: max %d expected\n",
+ m, index, blen, slen, max_len);
+ return NULL;
}
- return (str);
+ return str;
}
/* Wrap up the normal fixed length cases */
{
void *ptr;
- ptr = lustre_msg_buf(msg, index, min_size);
+ switch (msg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ ptr = lustre_msg_buf_v1(msg, index - 1, min_size);
+ break;
+ case LUSTRE_MSG_MAGIC_V2:
+ case LUSTRE_MSG_MAGIC_V2_SWABBED:
+ ptr = lustre_msg_buf_v2(msg, index, min_size);
+ break;
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+ }
if (ptr == NULL)
return NULL;
return lustre_swab_buf(req->rq_repmsg, index, min_size, swabber);
}
+__u32 lustre_msg_get_flags(struct lustre_msg *msg)
+{
+ switch (msg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ return ((struct lustre_msg_v1 *)msg)->lm_flags &
+ MSG_GEN_FLAG_MASK;
+ 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 pb->pb_flags;
+ }
+ default:
+ /* flags might be printed in debug code while message
+ * uninitialized */
+ return 0;
+ }
+}
+
+void lustre_msg_add_flags(struct lustre_msg *msg, int flags)
+{
+ switch (msg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ ((struct lustre_msg_v1 *)msg)->lm_flags |=
+ MSG_GEN_FLAG_MASK & flags;
+ 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_flags |= flags;
+ return;
+ }
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+ }
+}
+
+void lustre_msg_set_flags(struct lustre_msg *msg, int flags)
+{
+ switch (msg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ ((struct lustre_msg_v1 *)msg)->lm_flags &= ~MSG_GEN_FLAG_MASK;
+ ((struct lustre_msg_v1 *)msg)->lm_flags |=
+ MSG_GEN_FLAG_MASK & flags;
+ 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_flags = flags;
+ return;
+ }
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+ }
+}
+
+void lustre_msg_clear_flags(struct lustre_msg *msg, int flags)
+{
+ switch (msg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ ((struct lustre_msg_v1 *)msg)->lm_flags &=
+ ~(MSG_GEN_FLAG_MASK & flags);
+ return;
+ 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);
+ pb->pb_flags = 0;
+ return;
+ }
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+ }
+}
+
+__u32 lustre_msg_get_op_flags(struct lustre_msg *msg)
+{
+ switch (msg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ return ((struct lustre_msg_v1 *)msg)->lm_flags >>
+ MSG_OP_FLAG_SHIFT;
+ 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 pb->pb_op_flags;
+ }
+ default:
+ return 0;
+ }
+}
+
+void lustre_msg_add_op_flags(struct lustre_msg *msg, int flags)
+{
+ switch (msg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ ((struct lustre_msg_v1 *)msg)->lm_flags |=
+ (flags & MSG_GEN_FLAG_MASK) << MSG_OP_FLAG_SHIFT;
+ 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_op_flags |= flags;
+ return;
+ }
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+ }
+}
+
+void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags)
+{
+ switch (msg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ ((struct lustre_msg_v1 *)msg)->lm_flags &= ~MSG_OP_FLAG_MASK;
+ ((struct lustre_msg_v1 *)msg)->lm_flags |=
+ ((flags & MSG_GEN_FLAG_MASK) <<MSG_OP_FLAG_SHIFT);
+ 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_op_flags |= flags;
+ return;
+ }
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+ }
+}
+
+struct lustre_handle *lustre_msg_get_handle(struct lustre_msg *msg)
+{
+ switch (msg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ return &((struct lustre_msg_v1 *)msg)->lm_handle;
+ 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 &pb->pb_handle;
+ }
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+ return NULL;
+ }
+}
+
+__u32 lustre_msg_get_type(struct lustre_msg *msg)
+{
+ switch (msg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ return ((struct lustre_msg_v1 *)msg)->lm_type;
+ 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 pb->pb_type;
+ }
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+ return 0;
+ }
+}
+
+__u32 lustre_msg_get_version(struct lustre_msg *msg)
+{
+ switch (msg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ return ((struct lustre_msg_v1 *)msg)->lm_version;
+ 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 pb->pb_version;
+ }
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+ return 0;
+ }
+}
+
+void lustre_msg_add_version(struct lustre_msg *msg, int version)
+{
+ switch (msg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ return;
+ 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);
+ pb->pb_version |= version;
+ return;
+ }
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+ }
+}
+
+__u32 lustre_msg_get_opc(struct lustre_msg *msg)
+{
+ switch (msg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ return ((struct lustre_msg_v1 *)msg)->lm_opc;
+ 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 pb->pb_opc;
+ }
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+ return 0;
+ }
+}
+
+__u64 lustre_msg_get_last_xid(struct lustre_msg *msg)
+{
+ switch (msg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ return ((struct lustre_msg_v1 *)msg)->lm_last_xid;
+ 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 pb->pb_last_xid;
+ }
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+ return 0;
+ }
+}
+
+__u64 lustre_msg_get_last_committed(struct lustre_msg *msg)
+{
+ switch (msg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ return ((struct lustre_msg_v1 *)msg)->lm_last_committed;
+ 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 pb->pb_last_committed;
+ }
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+ return 0;
+ }
+}
+
+__u64 lustre_msg_get_transno(struct lustre_msg *msg)
+{
+ switch (msg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ return ((struct lustre_msg_v1 *)msg)->lm_transno;
+ 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 pb->pb_transno;
+ }
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+ return 0;
+ }
+}
+
+__u32 lustre_msg_get_status(struct lustre_msg *msg)
+{
+ switch (msg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ return ((struct lustre_msg_v1 *)msg)->lm_status;
+ 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 pb->pb_status;
+ }
+ default:
+ /* status might be printed in debug code while message
+ * uninitialized */
+ return 0;
+ }
+}
+
+__u32 lustre_msg_get_conn_cnt(struct lustre_msg *msg)
+{
+ switch (msg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V1:
+ case LUSTRE_MSG_MAGIC_V1_SWABBED:
+ return ((struct lustre_msg_v1 *)msg)->lm_conn_cnt;
+ 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 pb->pb_conn_cnt;
+ }
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+ 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:
+ LASSERTF(0, "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);
+ }
+}
+
/* 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_committed);
+ __swab64s (&b->pb_transno);
+ __swab32s (&b->pb_flags);
+ __swab32s (&b->pb_op_flags);
+ __swab32s (&b->pb_conn_cnt);
+ __swab32s (&b->pb_paddings[0]);
+ __swab32s (&b->pb_paddings[1]);
+ __swab32s (&b->pb_paddings[2]);
+}
void lustre_swab_connect(struct obd_connect_data *ocd)
{
void lustre_assert_wire_constants(void)
{
/* Wire protocol assertions generated by 'wirecheck'
- * running on Linux vmbuild 2.6.9-build #8 Sun Dec 18 16:30:50 MST 2005 i686 i686 i386 GNU/Li
- * with gcc version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3) */
+ * running on Linux localhost.localdomain 2.6.12-1.1372_FC3 #1 Fri Jul 15 00:59:10 EDT 2005 i
+ * with gcc version 3.4.4 20050721 (Red Hat 3.4.4-2) */
/* Constants... */
- LASSERTF(PTLRPC_MSG_MAGIC == 0x0BD00BD0," found %lld\n",
- (long long)PTLRPC_MSG_MAGIC);
+ LASSERTF(LUSTRE_MSG_MAGIC_V1 == 0x0BD00BD0," found %lld\n",
+ (long long)LUSTRE_MSG_MAGIC_V1);
+ LASSERTF(LUSTRE_MSG_MAGIC_V2 == 0x0BD00BD2," found %lld\n",
+ (long long)LUSTRE_MSG_MAGIC_V2);
LASSERTF(PTLRPC_MSG_VERSION == 0x00000003," found %lld\n",
(long long)PTLRPC_MSG_VERSION);
LASSERTF(PTL_RPC_MSG_REQUEST == 4711, " found %lld\n",
LASSERTF((int)sizeof(((struct lustre_handle *)0)->cookie) == 8, " found %lld\n",
(long long)(int)sizeof(((struct lustre_handle *)0)->cookie));
- /* Checks for struct lustre_msg */
- LASSERTF((int)sizeof(struct lustre_msg) == 64, " found %lld\n",
- (long long)(int)sizeof(struct lustre_msg));
- LASSERTF((int)offsetof(struct lustre_msg, handle) == 0, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, handle));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->handle) == 8, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->handle));
- LASSERTF((int)offsetof(struct lustre_msg, magic) == 8, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, magic));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->magic) == 4, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->magic));
- LASSERTF((int)offsetof(struct lustre_msg, type) == 12, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, type));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->type) == 4, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->type));
- LASSERTF((int)offsetof(struct lustre_msg, version) == 16, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, version));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->version) == 4, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->version));
- LASSERTF((int)offsetof(struct lustre_msg, opc) == 20, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, opc));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->opc) == 4, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->opc));
- LASSERTF((int)offsetof(struct lustre_msg, last_xid) == 24, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, last_xid));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->last_xid) == 8, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->last_xid));
- LASSERTF((int)offsetof(struct lustre_msg, last_committed) == 32, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, last_committed));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->last_committed) == 8, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->last_committed));
- LASSERTF((int)offsetof(struct lustre_msg, transno) == 40, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, transno));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->transno) == 8, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->transno));
- LASSERTF((int)offsetof(struct lustre_msg, status) == 48, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, status));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->status) == 4, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->status));
- LASSERTF((int)offsetof(struct lustre_msg, flags) == 52, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, flags));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->flags) == 4, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->flags));
- LASSERTF((int)offsetof(struct lustre_msg, bufcount) == 60, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, bufcount));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->bufcount) == 4, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->bufcount));
- LASSERTF((int)offsetof(struct lustre_msg, buflens[7]) == 92, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, buflens[7]));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->buflens[7]) == 4, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->buflens[7]));
+ /* Checks for struct lustre_msg_v1 */
+ LASSERTF((int)sizeof(struct lustre_msg_v1) == 64, " found %lld\n",
+ (long long)(int)sizeof(struct lustre_msg_v1));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_handle) == 0, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_handle));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_handle) == 8, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_handle));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_magic) == 8, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_magic));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_magic) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_magic));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_type) == 12, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_type));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_type) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_type));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_version) == 16, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_version));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_version) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_version));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_opc) == 20, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_opc));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_opc) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_opc));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_last_xid) == 24, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_last_xid));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_last_xid) == 8, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_last_xid));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_last_committed) == 32, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_last_committed));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_last_committed) == 8, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_last_committed));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_transno) == 40, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_transno));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_transno) == 8, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_transno));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_status) == 48, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_status));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_status) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_status));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_flags) == 52, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_flags));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_flags) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_flags));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_conn_cnt) == 56, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_conn_cnt));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_conn_cnt) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_conn_cnt));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_bufcount) == 60, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_bufcount));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_bufcount) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_bufcount));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_buflens[7]) == 92, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_buflens[7]));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_buflens[7]) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_buflens[7]));
+
+ /* Checks for struct lustre_msg_v2 */
+ LASSERTF((int)sizeof(struct lustre_msg_v2) == 16, " found %lld\n",
+ (long long)(int)sizeof(struct lustre_msg_v2));
+ LASSERTF((int)offsetof(struct lustre_msg_v2, lm_bufcount) == 0, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v2, lm_bufcount));
+ LASSERTF((int)sizeof(((struct lustre_msg_v2 *)0)->lm_bufcount) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v2 *)0)->lm_bufcount));
+ LASSERTF((int)offsetof(struct lustre_msg_v2, lm_secflvr) == 4, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v2, lm_secflvr));
+ LASSERTF((int)sizeof(((struct lustre_msg_v2 *)0)->lm_secflvr) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v2 *)0)->lm_secflvr));
+ LASSERTF((int)offsetof(struct lustre_msg_v2, lm_magic) == 8, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v2, lm_magic));
+ LASSERTF((int)sizeof(((struct lustre_msg_v2 *)0)->lm_magic) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v2 *)0)->lm_magic));
+ LASSERTF((int)offsetof(struct lustre_msg_v2, lm_buflens[7]) == 44, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v2, lm_buflens[7]));
+ LASSERTF((int)sizeof(((struct lustre_msg_v2 *)0)->lm_buflens[7]) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v2 *)0)->lm_buflens[7]));
+ LASSERT(offsetof(struct lustre_msg_v1, lm_magic) == offsetof(struct lustre_msg_v2, lm_magic));
+
+ /* Checks for struct ptlrpc_body */
+ LASSERTF((int)sizeof(struct ptlrpc_body) == 72, " found %lld\n",
+ (long long)(int)sizeof(struct ptlrpc_body));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_handle) == 0, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_handle));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_handle) == 8, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_handle));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_type) == 8, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_type));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_type) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_type));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_version) == 12, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_version));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_version) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_version));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_opc) == 16, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_opc));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_opc) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_opc));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_status) == 20, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_status));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_status) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_status));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_last_xid) == 24, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_last_xid));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_last_xid) == 8, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_last_xid));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_last_committed) == 32, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_last_committed));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_last_committed) == 8, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_last_committed));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_transno) == 40, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_transno));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_transno) == 8, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_transno));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_flags) == 48, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_flags));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_flags) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_flags));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_op_flags) == 52, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_op_flags));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_op_flags) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_op_flags));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_conn_cnt) == 56, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_conn_cnt));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_conn_cnt) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_conn_cnt));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_paddings[3]) == 72, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_paddings[3]));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_paddings[3]) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_paddings[3]));
/* Checks for struct obdo */
LASSERTF((int)sizeof(struct obdo) == 208, " found %lld\n",
LASSERTF((int)sizeof(((struct qunit_data *)0)->qd_isblk) == 4, " found %lld\n",
(long long)(int)sizeof(((struct qunit_data *)0)->qd_isblk));
}
-
int rc = 0;
ENTRY;
- req = ptlrpc_prep_req(imp, LUSTRE_OBD_VERSION, OBD_PING, 0, NULL, NULL);
+ req = ptlrpc_prep_req(imp, LUSTRE_OBD_VERSION, OBD_PING, 1, NULL, NULL);
if (req) {
DEBUG_REQ(D_INFO, req, "pinging %s->%s",
imp->imp_obd->obd_uuid.uuid,
obd2cli_tgt(imp->imp_obd));
req->rq_no_resend = req->rq_no_delay = 1;
- req->rq_replen = lustre_msg_size(0, NULL);
+ ptlrpc_req_set_repsize(req, 1, NULL);
ptlrpcd_add_req(req);
} else {
CERROR("OOM trying to ping %s->%s\n",
}
req = ptlrpc_prep_req(imp, LUSTRE_OBD_VERSION, OBD_PING,
- 0, NULL, NULL);
+ 1, NULL, NULL);
if (!req) {
CERROR("out of memory\n");
break;
}
req->rq_no_resend = 1;
- req->rq_replen = lustre_msg_size(0, NULL);
+ ptlrpc_req_set_repsize(req, 1, NULL);
req->rq_send_state = LUSTRE_IMP_FULL;
req->rq_phase = RQ_PHASE_RPC;
req->rq_import_generation = generation;
EXPORT_SYMBOL(lustre_free_reply_state);
EXPORT_SYMBOL(lustre_msg_size);
EXPORT_SYMBOL(lustre_unpack_msg);
+EXPORT_SYMBOL(lustre_unpack_ptlrpc_body);
EXPORT_SYMBOL(lustre_msg_buf);
EXPORT_SYMBOL(lustre_msg_string);
EXPORT_SYMBOL(lustre_swab_buf);
EXPORT_SYMBOL(lustre_swab_ldlm_request);
EXPORT_SYMBOL(lustre_swab_ldlm_reply);
EXPORT_SYMBOL(lustre_swab_qdata);
+EXPORT_SYMBOL(lustre_msg_get_flags);
+EXPORT_SYMBOL(lustre_msg_add_flags);
+EXPORT_SYMBOL(lustre_msg_set_flags);
+EXPORT_SYMBOL(lustre_msg_clear_flags);
+EXPORT_SYMBOL(lustre_msg_get_op_flags);
+EXPORT_SYMBOL(lustre_msg_add_op_flags);
+EXPORT_SYMBOL(lustre_msg_set_op_flags);
+EXPORT_SYMBOL(lustre_msg_get_handle );
+EXPORT_SYMBOL(lustre_msg_get_type);
+EXPORT_SYMBOL(lustre_msg_get_version);
+EXPORT_SYMBOL(lustre_msg_add_version);
+EXPORT_SYMBOL(lustre_msg_get_opc);
+EXPORT_SYMBOL(lustre_msg_get_last_xid);
+EXPORT_SYMBOL(lustre_msg_get_last_committed);
+EXPORT_SYMBOL(lustre_msg_get_transno);
+EXPORT_SYMBOL(lustre_msg_get_status);
+EXPORT_SYMBOL(lustre_msg_get_conn_cnt);
+EXPORT_SYMBOL(lustre_msg_get_magic);
+EXPORT_SYMBOL(lustre_msg_set_handle);
+EXPORT_SYMBOL(lustre_msg_set_type);
+EXPORT_SYMBOL(lustre_msg_set_opc);
+EXPORT_SYMBOL(lustre_msg_set_last_xid);
+EXPORT_SYMBOL(lustre_msg_set_last_committed);
+EXPORT_SYMBOL(lustre_msg_set_transno);
+EXPORT_SYMBOL(lustre_msg_set_status);
+EXPORT_SYMBOL(lustre_msg_set_conn_cnt);
EXPORT_SYMBOL(lustre_swab_mgs_target_info);
/* recover.c */
static int llcd_alloc(void)
{
struct llog_canceld_ctxt *llcd;
- int llcd_size = 0;
+ int llcd_size;
- llcd_size = 4096 - lustre_msg_size(1, &llcd_size);
+ /* payload of lustre_msg V2 is bigger */
+ llcd_size = 4096 - lustre_msg_size(LUSTRE_MSG_MAGIC_V2, 1, NULL);
OBD_ALLOC(llcd,
llcd_size + offsetof(struct llog_canceld_ctxt, llcd_cookies));
if (llcd == NULL)
/* We are the only one manipulating our local list - no lock */
list_for_each_entry_safe(llcd,n, &lcd->lcd_llcd_list,llcd_list){
- char *bufs[1] = {(char *)llcd->llcd_cookies};
+ int size[2] = { sizeof(struct ptlrpc_body),
+ llcd->llcd_cookiebytes };
+ char *bufs[2] = { NULL, (char *)llcd->llcd_cookies };
list_del(&llcd->llcd_list);
if (llcd->llcd_cookiebytes == 0) {
}
request = ptlrpc_prep_req(import, LUSTRE_LOG_VERSION,
- OBD_LOG_CANCEL, 1,
- &llcd->llcd_cookiebytes,
- bufs);
+ OBD_LOG_CANCEL, 2, size,bufs);
if (request == NULL) {
rc = -ENOMEM;
CERROR("error preparing commit: rc %d\n", rc);
request->rq_request_portal = LDLM_CANCEL_REQUEST_PORTAL;
request->rq_reply_portal = LDLM_CANCEL_REPLY_PORTAL;
- request->rq_replen = lustre_msg_size(0, NULL);
+ ptlrpc_req_set_repsize(request, 1, NULL);
mutex_down(&llcd->llcd_ctxt->loc_sem);
if (llcd->llcd_ctxt->loc_imp == NULL) {
mutex_up(&llcd->llcd_ctxt->loc_sem);
imp->imp_obd->obd_name, obd2cli_tgt(imp->imp_obd),
imp->imp_connection->c_remote_uuid.uuid);
- if (ptlrpc_set_import_discon(imp, failed_req->rq_reqmsg->conn_cnt)) {
+ if (ptlrpc_set_import_discon(imp,
+ lustre_msg_get_conn_cnt(failed_req->rq_reqmsg))) {
if (!imp->imp_replayable) {
CDEBUG(D_HA, "import %s@%s for %s not replayable, "
"auto-deactivating\n",
struct ptlrpc_reply_state *rs = req->rq_reply_state;
int idx;
- LASSERT (rs != NULL);
- LASSERT (rs->rs_nlocks < RS_MAX_LOCKS);
+ LASSERT(rs != NULL);
+ LASSERT(rs->rs_nlocks < RS_MAX_LOCKS);
idx = rs->rs_nlocks++;
rs->rs_locks[idx] = *lock;
/* Clear request swab mask; this is a new request */
request->rq_req_swab_mask = 0;
#endif
- rc = lustre_unpack_msg (request->rq_reqmsg, request->rq_reqlen);
+ rc = lustre_unpack_msg(request->rq_reqmsg, request->rq_reqlen);
if (rc != 0) {
CERROR ("error unpacking request: ptl %d from %s"
" xid "LPU64"\n", svc->srv_req_portal,
goto out;
}
+ rc = lustre_unpack_ptlrpc_body(request->rq_reqmsg);
+ if (rc) {
+ CERROR ("error unpacking ptlrpc body: ptl %d from %s"
+ " xid "LPU64"\n", svc->srv_req_portal,
+ libcfs_id2str(request->rq_peer), request->rq_xid);
+ goto out;
+ }
+
rc = -EINVAL;
- if (request->rq_reqmsg->type != PTL_RPC_MSG_REQUEST) {
+ if (lustre_msg_get_type(request->rq_reqmsg) != PTL_RPC_MSG_REQUEST) {
CERROR("wrong packet type received (type=%u) from %s\n",
- request->rq_reqmsg->type,
+ lustre_msg_get_type(request->rq_reqmsg),
libcfs_id2str(request->rq_peer));
goto out;
}
CDEBUG(D_NET, "got req "LPD64"\n", request->rq_xid);
request->rq_svc_thread = thread;
- request->rq_export = class_conn2export(&request->rq_reqmsg->handle);
+ request->rq_export = class_conn2export(
+ lustre_msg_get_handle(request->rq_reqmsg));
if (request->rq_export) {
- if (request->rq_reqmsg->conn_cnt <
+ if (lustre_msg_get_conn_cnt(request->rq_reqmsg) <
request->rq_export->exp_conn_cnt) {
DEBUG_REQ(D_ERROR, request,
"DROPPING req from old connection %d < %d",
- request->rq_reqmsg->conn_cnt,
+ lustre_msg_get_conn_cnt(request->rq_reqmsg),
request->rq_export->exp_conn_cnt);
goto put_conn;
}
* REQ anyway (bug 1502) */
if (timediff / 1000000 > (long)obd_timeout) {
CERROR("Dropping timed-out opc %d request from %s"
- ": %ld seconds old\n", request->rq_reqmsg->opc,
+ ": %ld seconds old\n",
+ lustre_msg_get_opc(request->rq_reqmsg),
libcfs_id2str(request->rq_peer),
timediff / 1000000);
goto put_conn;
(char *)request->rq_export->exp_client_uuid.uuid : "0"),
(request->rq_export ?
atomic_read(&request->rq_export->exp_refcount) : -99),
- request->rq_reqmsg->status, request->rq_xid,
+ lustre_msg_get_status(request->rq_reqmsg), request->rq_xid,
libcfs_id2str(request->rq_peer),
- request->rq_reqmsg->opc);
+ lustre_msg_get_opc(request->rq_reqmsg));
rc = svc->srv_handler(request);
(char *)request->rq_export->exp_client_uuid.uuid : "0"),
(request->rq_export ?
atomic_read(&request->rq_export->exp_refcount) : -99),
- request->rq_reqmsg->status, request->rq_xid,
+ lustre_msg_get_status(request->rq_reqmsg), request->rq_xid,
libcfs_id2str(request->rq_peer),
- request->rq_reqmsg->opc);
+ lustre_msg_get_opc(request->rq_reqmsg));
put_conn:
if (request->rq_export != NULL)
if (timediff / 1000000 > (long)obd_timeout)
CERROR("request "LPU64" opc %u from %s processed in %lds "
"trans "LPU64" rc %d/%d\n",
- request->rq_xid, request->rq_reqmsg->opc,
+ request->rq_xid, lustre_msg_get_opc(request->rq_reqmsg),
libcfs_id2str(request->rq_peer),
cfs_timeval_sub(&work_end, &request->rq_arrival_time,
NULL) / 1000000,
- request->rq_repmsg ? request->rq_repmsg->transno :
- request->rq_transno, request->rq_status,
- request->rq_repmsg ? request->rq_repmsg->status : -999);
+ request->rq_repmsg ?
+ lustre_msg_get_transno(request->rq_repmsg) :
+ request->rq_transno, request->rq_status,
+ request->rq_repmsg ?
+ lustre_msg_get_status(request->rq_repmsg) :
+ -999);
else
CDEBUG(D_HA, "request "LPU64" opc %u from %s processed in "
"%ldus (%ldus total) trans "LPU64" rc %d/%d\n",
- request->rq_xid, request->rq_reqmsg->opc,
+ request->rq_xid, lustre_msg_get_opc(request->rq_reqmsg),
libcfs_id2str(request->rq_peer), timediff,
cfs_timeval_sub(&work_end, &request->rq_arrival_time,
NULL),
request->rq_transno, request->rq_status,
- request->rq_repmsg ? request->rq_repmsg->status : -999);
+ request->rq_repmsg ?
+ lustre_msg_get_status(request->rq_repmsg) :
+ -999);
if (svc->srv_stats != NULL) {
- int opc = opcode_offset(request->rq_reqmsg->opc);
+ int opc = opcode_offset(lustre_msg_get_opc(request->rq_reqmsg));
if (opc > 0) {
LASSERT(opc < LUSTRE_MAX_OPCODES);
lprocfs_counter_add(svc->srv_stats,
" o%d NID %s\n",
rs,
rs->rs_xid, rs->rs_transno,
- rs->rs_msg.opc,
+ lustre_msg_get_opc(rs->rs_msg),
libcfs_nid2str(exp->exp_connection->c_peer.nid));
}
- if ((!been_handled && rs->rs_on_net) ||
- nlocks > 0) {
+ if ((!been_handled && rs->rs_on_net) || nlocks > 0) {
spin_unlock_irqrestore(&svc->srv_lock, flags);
if (!been_handled && rs->rs_on_net) {
{
struct ptlrpc_request *req;
struct obd_quotactl *body;
- int rc, size = sizeof(*oqctl);
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*oqctl) };
ENTRY;
req = ptlrpc_prep_req(exp->exp_imp_reverse, LUSTRE_OBD_VERSION,
- OBD_QC_CALLBACK, 1, &size, NULL);
+ OBD_QC_CALLBACK, 2, size, NULL);
if (!req)
RETURN(-ENOMEM);
- body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body));
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
*body = *oqctl;
- req->rq_replen = lustre_msg_size(0, NULL);
+ ptlrpc_req_set_repsize(req, 1, NULL);
rc = ptlrpc_queue_wait(req);
ptlrpc_req_finished(req);
struct client_obd *cli = &exp->exp_obd->u.cli;
struct ptlrpc_request *req;
struct obd_quotactl *body;
- int size = sizeof(*body), opc, version;
- int rc;
+ int size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
+ int ver, opc, rc;
ENTRY;
if (!strcmp(exp->exp_obd->obd_type->typ_name, LUSTRE_MDC_NAME)) {
- version = LUSTRE_MDS_VERSION;
+ ver = LUSTRE_MDS_VERSION;
opc = MDS_QUOTACHECK;
} else if (!strcmp(exp->exp_obd->obd_type->typ_name, LUSTRE_OSC_NAME)) {
- version = LUSTRE_OST_VERSION;
+ ver = LUSTRE_OST_VERSION;
opc = OST_QUOTACHECK;
} else {
RETURN(-EINVAL);
}
- req = ptlrpc_prep_req(class_exp2cliimp(exp), version, opc, 1, &size,
- NULL);
+ req = ptlrpc_prep_req(class_exp2cliimp(exp), ver, opc, 2, size, NULL);
if (!req)
GOTO(out, rc = -ENOMEM);
- body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body));
+ body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
*body = *oqctl;
- req->rq_replen = lustre_msg_size(0, NULL);
+ ptlrpc_req_set_repsize(req, 1, NULL);
/* the next poll will find -ENODATA, that means quotacheck is
* going on */
struct qunit_data *qdata = NULL;
ENTRY;
- qdata = lustre_swab_repbuf(req, 0, sizeof(*qdata), lustre_swab_qdata);
+ qdata = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*qdata),
+ lustre_swab_qdata);
if (rc == 0 && qdata == NULL)
RETURN(-EPROTO);
qdata->qd_count == 0));
QDATA_DEBUG(qdata, "%s interpret rc(%d).\n",
- req->rq_reqmsg->opc == QUOTA_DQACQ ? "DQACQ" : "DQREL", rc);
+ lustre_msg_get_opc(req->rq_reqmsg) == QUOTA_DQACQ ?
+ "DQACQ" : "DQREL", rc);
- rc = dqacq_completion(obd, qctxt, qdata, rc, req->rq_reqmsg->opc);
+ rc = dqacq_completion(obd, qctxt, qdata, rc,
+ lustre_msg_get_opc(req->rq_reqmsg));
RETURN(rc);
}
struct ptlrpc_request *req;
struct qunit_data *reqdata;
struct dqacq_async_args *aa;
- int size = sizeof(*reqdata);
+ int size[2] = { sizeof(struct ptlrpc_body), sizeof(*reqdata) };
int rc = 0;
ENTRY;
/* build dqacq/dqrel request */
LASSERT(qctxt->lqc_import);
- req = ptlrpc_prep_req(qctxt->lqc_import, LUSTRE_MDS_VERSION, opc, 1,
- &size, NULL);
+ req = ptlrpc_prep_req(qctxt->lqc_import, LUSTRE_MDS_VERSION, opc, 2,
+ size, NULL);
if (!req) {
dqacq_completion(obd, qctxt, qdata, -ENOMEM, opc);
RETURN(-ENOMEM);
}
- reqdata = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*reqdata));
+ reqdata = lustre_msg_buf(req->rq_reqmsg, REPLY_REC_OFF,
+ sizeof(*reqdata));
*reqdata = *qdata;
- size = sizeof(*reqdata);
- req->rq_replen = lustre_msg_size(1, &size);
+ ptlrpc_req_set_repsize(req, 2, size);
CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args));
aa = (struct dqacq_async_args *)&req->rq_async_args;
{
struct ptlrpc_request *req;
struct obd_quotactl *oqc;
- int size = sizeof(*oqctl), opc, version;
- int rc;
+ int size[2] = { sizeof(struct ptlrpc_body), sizeof(*oqctl) };
+ int ver, opc, rc;
ENTRY;
if (!strcmp(exp->exp_obd->obd_type->typ_name, LUSTRE_MDC_NAME)) {
+ ver = LUSTRE_MDS_VERSION,
opc = MDS_QUOTACTL;
- version = LUSTRE_MDS_VERSION;
} else if (!strcmp(exp->exp_obd->obd_type->typ_name, LUSTRE_OSC_NAME)) {
+ ver = LUSTRE_OST_VERSION,
opc = OST_QUOTACTL;
- version = LUSTRE_OST_VERSION;
} else {
RETURN(-EINVAL);
}
- req = ptlrpc_prep_req(class_exp2cliimp(exp), version, opc, 1, &size,
- NULL);
+ req = ptlrpc_prep_req(class_exp2cliimp(exp), ver, opc, 2, size, NULL);
if (!req)
GOTO(out, rc = -ENOMEM);
- oqc = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*oqctl));
+ oqc = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*oqctl));
*oqc = *oqctl;
- req->rq_replen = lustre_msg_size(1, &size);
+ ptlrpc_req_set_repsize(req, 2, size);
rc = ptlrpc_queue_wait(req);
if (!rc) {
- oqc = lustre_swab_repbuf(req, 0, sizeof (*oqc),
+ oqc = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*oqc),
lustre_swab_obd_quotactl);
if (oqc == NULL) {
CERROR ("Can't unpack obd_quotactl\n");
STRIPES_PER_OBJ=${STRIPES_PER_OBJ:-0}
TIMEOUT=${TIMEOUT:-20}
UPCALL=${UPCALL:-DEFAULT}
-PTLDEBUG=${PTLDEBUG:-0x33f0404}
+#PTLDEBUG=${PTLDEBUG:-0x33f0404}
+PTLDEBUG=${PTLDEBUG:-0xffffffff}
SUBSYSTEM=${SUBSYSTEM:- 0xffb7e3ff}
MKFSOPT=""
$CHECKSTAT -a ${FHEAD}_tmp || error "${FHEAD}_tmp exist after join"
$CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join (2)"
- rm -rf ${FHEAD} || "delete join file error"
+ rm -rf ${FHEAD} || error "delete join file error"
cp -p ${F128k} ${F}_join_10_compare
cp -p ${F128k} ${F}_join_10
for ((i = 0; i < 10; i++)); do
#define CHECK_MEMBER(s,m) \
do { \
CHECK_MEMBER_OFFSET(s, m); \
- CHECK_MEMBER_SIZEOF(s, m); \
+ CHECK_MEMBER_SIZEOF(s, m); \
} while(0)
#define CHECK_STRUCT(s) \
CHECK_MEMBER(lustre_handle, cookie);
}
-static void
-check_lustre_msg(void)
+void
+check_lustre_msg_v1(void)
+{
+ BLANK_LINE();
+ CHECK_STRUCT(lustre_msg_v1);
+ CHECK_MEMBER(lustre_msg_v1, lm_handle);
+ CHECK_MEMBER(lustre_msg_v1, lm_magic);
+ CHECK_MEMBER(lustre_msg_v1, lm_type);
+ CHECK_MEMBER(lustre_msg_v1, lm_version);
+ CHECK_MEMBER(lustre_msg_v1, lm_opc);
+ CHECK_MEMBER(lustre_msg_v1, lm_last_xid);
+ CHECK_MEMBER(lustre_msg_v1, lm_last_committed);
+ CHECK_MEMBER(lustre_msg_v1, lm_transno);
+ CHECK_MEMBER(lustre_msg_v1, lm_status);
+ CHECK_MEMBER(lustre_msg_v1, lm_flags);
+ CHECK_MEMBER(lustre_msg_v1, lm_conn_cnt);
+ CHECK_MEMBER(lustre_msg_v1, lm_bufcount);
+ CHECK_MEMBER(lustre_msg_v1, lm_buflens[7]);
+}
+
+void
+check_lustre_msg_v2(void)
+{
+ BLANK_LINE();
+ CHECK_STRUCT(lustre_msg_v2);
+ CHECK_MEMBER(lustre_msg_v2, lm_bufcount);
+ CHECK_MEMBER(lustre_msg_v2, lm_secflvr);
+ CHECK_MEMBER(lustre_msg_v2, lm_magic);
+ CHECK_MEMBER(lustre_msg_v2, lm_buflens[7]);
+}
+
+void
+check_ptlrpc_body(void)
{
BLANK_LINE();
- CHECK_STRUCT(lustre_msg);
- CHECK_MEMBER(lustre_msg, handle);
- CHECK_MEMBER(lustre_msg, magic);
- CHECK_MEMBER(lustre_msg, type);
- CHECK_MEMBER(lustre_msg, version);
- CHECK_MEMBER(lustre_msg, opc);
- CHECK_MEMBER(lustre_msg, last_xid);
- CHECK_MEMBER(lustre_msg, last_committed);
- CHECK_MEMBER(lustre_msg, transno);
- CHECK_MEMBER(lustre_msg, status);
- CHECK_MEMBER(lustre_msg, flags);
- CHECK_MEMBER(lustre_msg, bufcount);
- CHECK_MEMBER(lustre_msg, buflens[7]);
+ CHECK_STRUCT(ptlrpc_body);
+ CHECK_MEMBER(ptlrpc_body, pb_handle);
+ CHECK_MEMBER(ptlrpc_body, pb_type);
+ CHECK_MEMBER(ptlrpc_body, pb_version);
+ CHECK_MEMBER(ptlrpc_body, pb_opc);
+ CHECK_MEMBER(ptlrpc_body, pb_status);
+ CHECK_MEMBER(ptlrpc_body, pb_last_xid);
+ CHECK_MEMBER(ptlrpc_body, pb_last_committed);
+ CHECK_MEMBER(ptlrpc_body, pb_transno);
+ CHECK_MEMBER(ptlrpc_body, pb_flags);
+ CHECK_MEMBER(ptlrpc_body, pb_op_flags);
+ CHECK_MEMBER(ptlrpc_body, pb_conn_cnt);
+ CHECK_MEMBER(ptlrpc_body, pb_paddings[3]);
}
static void
BLANK_LINE ();
COMMENT("Constants...");
- CHECK_DEFINE(PTLRPC_MSG_MAGIC);
+ CHECK_DEFINE(LUSTRE_MSG_MAGIC_V1);
+ CHECK_DEFINE(LUSTRE_MSG_MAGIC_V2);
CHECK_DEFINE(PTLRPC_MSG_VERSION);
CHECK_VALUE(PTL_RPC_MSG_REQUEST);
COMMENT("Sizes and Offsets");
BLANK_LINE();
check_lustre_handle();
- check_lustre_msg();
+ check_lustre_msg_v1();
+ check_lustre_msg_v2();
+ printf(" LASSERT(offsetof(struct lustre_msg_v1, lm_magic) == "
+ "offsetof(struct lustre_msg_v2, lm_magic));\n");
+ check_ptlrpc_body();
check_obdo();
check_lov_mds_md_v1();
check_lov_mds_md_join();
void lustre_assert_wire_constants(void)
{
/* Wire protocol assertions generated by 'wirecheck'
- * running on Linux pancake.rutmans.org 2.6.8-1.521 #1 Mon Aug 16 09:01:18 EDT 2004 i686 i686
- * with gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7) */
+ * running on Linux localhost.localdomain 2.6.12-1.1372_FC3 #1 Fri Jul 15 00:59:10 EDT 2005 i
+ * with gcc version 3.4.4 20050721 (Red Hat 3.4.4-2) */
/* Constants... */
- LASSERTF(PTLRPC_MSG_MAGIC == 0x0BD00BD0," found %lld\n",
- (long long)PTLRPC_MSG_MAGIC);
+ LASSERTF(LUSTRE_MSG_MAGIC_V1 == 0x0BD00BD0," found %lld\n",
+ (long long)LUSTRE_MSG_MAGIC_V1);
+ LASSERTF(LUSTRE_MSG_MAGIC_V2 == 0x0BD00BD2," found %lld\n",
+ (long long)LUSTRE_MSG_MAGIC_V2);
LASSERTF(PTLRPC_MSG_VERSION == 0x00000003," found %lld\n",
(long long)PTLRPC_MSG_VERSION);
LASSERTF(PTL_RPC_MSG_REQUEST == 4711, " found %lld\n",
LASSERTF((int)sizeof(((struct lustre_handle *)0)->cookie) == 8, " found %lld\n",
(long long)(int)sizeof(((struct lustre_handle *)0)->cookie));
- /* Checks for struct lustre_msg */
- LASSERTF((int)sizeof(struct lustre_msg) == 64, " found %lld\n",
- (long long)(int)sizeof(struct lustre_msg));
- LASSERTF((int)offsetof(struct lustre_msg, handle) == 0, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, handle));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->handle) == 8, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->handle));
- LASSERTF((int)offsetof(struct lustre_msg, magic) == 8, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, magic));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->magic) == 4, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->magic));
- LASSERTF((int)offsetof(struct lustre_msg, type) == 12, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, type));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->type) == 4, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->type));
- LASSERTF((int)offsetof(struct lustre_msg, version) == 16, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, version));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->version) == 4, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->version));
- LASSERTF((int)offsetof(struct lustre_msg, opc) == 20, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, opc));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->opc) == 4, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->opc));
- LASSERTF((int)offsetof(struct lustre_msg, last_xid) == 24, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, last_xid));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->last_xid) == 8, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->last_xid));
- LASSERTF((int)offsetof(struct lustre_msg, last_committed) == 32, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, last_committed));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->last_committed) == 8, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->last_committed));
- LASSERTF((int)offsetof(struct lustre_msg, transno) == 40, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, transno));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->transno) == 8, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->transno));
- LASSERTF((int)offsetof(struct lustre_msg, status) == 48, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, status));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->status) == 4, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->status));
- LASSERTF((int)offsetof(struct lustre_msg, flags) == 52, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, flags));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->flags) == 4, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->flags));
- LASSERTF((int)offsetof(struct lustre_msg, bufcount) == 60, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, bufcount));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->bufcount) == 4, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->bufcount));
- LASSERTF((int)offsetof(struct lustre_msg, buflens[7]) == 92, " found %lld\n",
- (long long)(int)offsetof(struct lustre_msg, buflens[7]));
- LASSERTF((int)sizeof(((struct lustre_msg *)0)->buflens[7]) == 4, " found %lld\n",
- (long long)(int)sizeof(((struct lustre_msg *)0)->buflens[7]));
+ /* Checks for struct lustre_msg_v1 */
+ LASSERTF((int)sizeof(struct lustre_msg_v1) == 64, " found %lld\n",
+ (long long)(int)sizeof(struct lustre_msg_v1));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_handle) == 0, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_handle));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_handle) == 8, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_handle));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_magic) == 8, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_magic));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_magic) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_magic));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_type) == 12, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_type));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_type) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_type));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_version) == 16, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_version));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_version) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_version));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_opc) == 20, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_opc));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_opc) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_opc));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_last_xid) == 24, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_last_xid));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_last_xid) == 8, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_last_xid));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_last_committed) == 32, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_last_committed));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_last_committed) == 8, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_last_committed));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_transno) == 40, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_transno));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_transno) == 8, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_transno));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_status) == 48, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_status));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_status) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_status));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_flags) == 52, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_flags));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_flags) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_flags));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_conn_cnt) == 56, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_conn_cnt));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_conn_cnt) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_conn_cnt));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_bufcount) == 60, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_bufcount));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_bufcount) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_bufcount));
+ LASSERTF((int)offsetof(struct lustre_msg_v1, lm_buflens[7]) == 92, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v1, lm_buflens[7]));
+ LASSERTF((int)sizeof(((struct lustre_msg_v1 *)0)->lm_buflens[7]) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v1 *)0)->lm_buflens[7]));
+
+ /* Checks for struct lustre_msg_v2 */
+ LASSERTF((int)sizeof(struct lustre_msg_v2) == 16, " found %lld\n",
+ (long long)(int)sizeof(struct lustre_msg_v2));
+ LASSERTF((int)offsetof(struct lustre_msg_v2, lm_bufcount) == 0, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v2, lm_bufcount));
+ LASSERTF((int)sizeof(((struct lustre_msg_v2 *)0)->lm_bufcount) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v2 *)0)->lm_bufcount));
+ LASSERTF((int)offsetof(struct lustre_msg_v2, lm_secflvr) == 4, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v2, lm_secflvr));
+ LASSERTF((int)sizeof(((struct lustre_msg_v2 *)0)->lm_secflvr) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v2 *)0)->lm_secflvr));
+ LASSERTF((int)offsetof(struct lustre_msg_v2, lm_magic) == 8, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v2, lm_magic));
+ LASSERTF((int)sizeof(((struct lustre_msg_v2 *)0)->lm_magic) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v2 *)0)->lm_magic));
+ LASSERTF((int)offsetof(struct lustre_msg_v2, lm_buflens[7]) == 44, " found %lld\n",
+ (long long)(int)offsetof(struct lustre_msg_v2, lm_buflens[7]));
+ LASSERTF((int)sizeof(((struct lustre_msg_v2 *)0)->lm_buflens[7]) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct lustre_msg_v2 *)0)->lm_buflens[7]));
+ LASSERT(offsetof(struct lustre_msg_v1, lm_magic) == offsetof(struct lustre_msg_v2, lm_magic));
+
+ /* Checks for struct ptlrpc_body */
+ LASSERTF((int)sizeof(struct ptlrpc_body) == 72, " found %lld\n",
+ (long long)(int)sizeof(struct ptlrpc_body));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_handle) == 0, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_handle));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_handle) == 8, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_handle));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_type) == 8, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_type));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_type) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_type));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_version) == 12, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_version));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_version) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_version));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_opc) == 16, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_opc));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_opc) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_opc));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_status) == 20, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_status));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_status) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_status));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_last_xid) == 24, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_last_xid));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_last_xid) == 8, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_last_xid));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_last_committed) == 32, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_last_committed));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_last_committed) == 8, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_last_committed));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_transno) == 40, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_transno));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_transno) == 8, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_transno));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_flags) == 48, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_flags));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_flags) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_flags));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_op_flags) == 52, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_op_flags));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_op_flags) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_op_flags));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_conn_cnt) == 56, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_conn_cnt));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_conn_cnt) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_conn_cnt));
+ LASSERTF((int)offsetof(struct ptlrpc_body, pb_paddings[3]) == 72, " found %lld\n",
+ (long long)(int)offsetof(struct ptlrpc_body, pb_paddings[3]));
+ LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_paddings[3]) == 4, " found %lld\n",
+ (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_paddings[3]));
/* Checks for struct obdo */
LASSERTF((int)sizeof(struct obdo) == 208, " found %lld\n",