- all requests are now ptlrpc requests.
- better packing/unpacking once more
- new directory with Portals RPC infrastructure.
- wait and restart hooks event handlers
#define OST_DISCONNECT 8
#define OST_GETATTR 1
#define OST_SETATTR 2
-#define OST_BRW 3
+#define OST_PREPW 3
#define OST_CREATE 4
#define OST_DESTROY 5
#define OST_TYPE_REP 2
#define OST_TYPE_ERR 3
-struct ost_req_hdr {
+struct ptlreq_hdr {
__u32 opc;
__u64 seqno;
__u32 status;
__u32 type;
};
-struct ost_rep_hdr {
+struct ptlrep_hdr {
__u32 opc;
__u64 seqno;
__u32 status;
#define OST_REQ_HAS_OA1 0x1
-struct ost_req_packed {
+struct ost_req {
__u32 connid;
__u32 cmd;
- struct obdo oa;
+ struct obdo oa;
__u32 buflen1;
__u32 buflen2;
- __u32 bufoffset1;
- __u32 bufoffset2;
};
-struct ost_rep_packed {
+struct ost_rep {
__u32 result;
__u32 connid;
- struct obdo oa;
+ struct obdo oa;
__u32 buflen1;
__u32 buflen2;
- __u32 bufoffset1;
- __u32 bufoffset2;
};
-struct obd_buf {
- __u64 addr; // address
- __u64 handle; // DMA handle
- __u64 matchbits; // portals match bits
- __u32 offset; // first bit after addr that is relevant
- __u32 size; // size from addr + offset that needs moving
+struct obd_ioobj {
+ obd_id ioo_id;
+ obd_gr ioo_gr;
+ __u32 ioo_type;
+ __u32 ioo_bufcnt;
};
-struct obd_bufref {
- obd_id obj_id;
- obd_gr obj_gr;
- __u64 offset;
- __u32 size;
- __u32 flags;
-};
-
-/* reply structure for OST's */
-
-
-
-
/*
* MDS REQ RECORDS
#define REINT_CREATE 1
#define REINT_MAX 1
-struct mds_req_hdr {
- __u32 opc;
- __u64 seqno;
- __u32 status;
- __u32 type;
-};
-
struct ll_fid {
__u64 id;
__u32 generation;
struct niobuf {
__u64 addr;
+ __u64 offset;
+ __u32 len;
+ __u32 flags;
};
-struct mds_rep_hdr {
- __u32 opc;
- __u64 seqno;
- __u32 status;
- __u32 type;
-};
-
-struct mds_req_packed {
+struct mds_req {
struct ll_fid fid1;
struct ll_fid fid2;
- int namelen;
- int tgtlen;
+ __u32 namelen;
+ __u32 tgtlen;
__u32 opcode;
__u32 valid;
__u32 mode;
__u64 objid;
};
-struct mds_rep_packed {
- struct ll_fid fid1;
- struct ll_fid fid2;
- int namelen;
- int tgtlen;
+struct mds_rep {
+ struct ll_fid fid1;
+ struct ll_fid fid2;
+ __u32 namelen;
+ __u32 tgtlen;
__u32 valid;
__u32 mode;
__u32 uid;
#define OBD_IOC_DEC_FS_USE_COUNT _IO ('f', 32 )
+/* GENERAL THINGS */
+union ptl_rep {
+ struct mds_rep *mds;
+ struct ost_rep *ost;
+};
+
+union ptl_req {
+ struct mds_req *mds;
+ struct ost_req *ost;
+};
+
#endif
*
*/
-#ifndef _LUSTRE_LIB_H
-#define _LUSTRE_LIB_H
+#ifndef _CFS_LIB_H
+#define _CFS_LIB_H
#include <asm/types.h>
return (ll_i2info(inode)->lli_flags & OBD_FL_INLINEDATA);
}
-static void inline ll_from_inode(struct obdo *oa, struct inode *inode)
-{
- struct ll_inode_info *oinfo = ll_i2info(inode);
-
- CDEBUG(D_INFO, "src inode %ld, dst obdo %ld valid 0x%08x\n",
- inode->i_ino, (long)oa->o_id, oa->o_valid);
- obdo_from_inode(oa, inode);
- if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
- CDEBUG(D_INODE, "copying device %x from inode to obdo\n",
- inode->i_rdev);
- *((obd_rdev *)oa->o_inline) = kdev_t_to_nr(inode->i_rdev);
- oa->o_obdflags |= OBD_FL_INLINEDATA;
- oa->o_valid |= OBD_MD_FLINLINE;
- } else if (ll_has_inline(inode)) {
- CDEBUG(D_INODE, "copying inline data from inode to obdo\n");
- memcpy(oa->o_inline, oinfo->lli_inline, OBD_INLINESZ);
- oa->o_obdflags |= OBD_FL_INLINEDATA;
- oa->o_valid |= OBD_MD_FLINLINE;
- }
-} /* ll_from_inode */
#ifndef _LUSTRE_MDS_H
#define _LUSTRE_MDS_H
-#include <linux/obd_support.h>
+#include <linux/obd_support.h>
+#include <linux/lustre_idl.h>
+#include <linux/lustre_net.h>
struct mds_run_ctxt {
struct vfsmount *pwdmnt;
struct mds_obd {
char *mds_fstype;
struct task_struct *mds_thread;
+ __u32 mds_remote_nid;
wait_queue_head_t mds_waitq;
wait_queue_head_t mds_done_waitq;
struct timer_list *mds_timer;
};
-struct mds_request {
- struct list_head rq_list;
- struct mds_obd *rq_obd;
- int rq_status;
-
- char *rq_reqbuf;
- int rq_reqlen;
- struct mds_req_hdr *rq_reqhdr;
- struct mds_req *rq_req;
-
- char *rq_repbuf;
- int rq_replen;
- struct mds_rep_hdr *rq_rephdr;
- struct mds_rep *rq_rep;
-
- void * rq_reply_handle;
- wait_queue_head_t rq_wait_for_rep;
-};
-
-
-/* more or less identical to the packed structure, except for the pointers */
-struct mds_req {
- struct ll_fid fid1;
- struct ll_fid fid2;
- int namelen;
- int tgtlen;
- __u32 opcode;
- __u32 valid;
- __u32 mode;
- __u32 uid;
- __u32 gid;
- __u64 size;
- __u32 mtime;
- __u32 ctime;
- __u32 atime;
- __u32 flags;
- __u32 major;
- __u32 minor;
- __u32 ino;
- __u32 nlink;
- __u32 generation;
- __u64 objid;
-};
-
-/* more or less identical to the packed structure, except for the pointers */
-struct mds_rep {
- struct ll_fid fid1;
- struct ll_fid fid2;
- int namelen;
- int tgtlen;
- __u32 valid;
- __u32 mode;
- __u32 uid;
- __u32 gid;
- __u64 size;
- __u32 mtime;
- __u32 ctime;
- __u32 atime;
- __u32 flags;
- __u32 major;
- __u32 minor;
- __u32 ino;
- __u32 nlink;
- __u32 generation;
- __u64 objid;
-};
-
struct mds_update_record {
__u32 ur_reclen;
__u32 ur_opcode;
/* mds/mds_pack.c */
void *mds_req_tgt(struct mds_req *req);
-int mds_pack_req(char *name, int namelen, char *tgt, int tgtlen, struct mds_req_hdr **hdr, struct mds_req **req, int *len, char **buf);
-int mds_unpack_req(char *buf, int len, struct mds_req_hdr **hdr, struct mds_req **req);
-int mds_pack_rep(char *name, int namelen, char *tgt, int tgtlen, struct mds_rep_hdr **hdr, struct mds_rep **rep, int *len, char **buf);
-int mds_unpack_rep(char *buf, int len, struct mds_rep_hdr **hdr, struct mds_rep **rep);
+int mds_pack_req(char *name, int namelen, char *tgt, int tgtlen, struct ptlreq_hdr **hdr, struct mds_req **req, int *len, char **buf);
+int mds_unpack_req(char *buf, int len, struct ptlreq_hdr **hdr, struct mds_req **req);
+int mds_pack_rep(char *name, int namelen, char *tgt, int tgtlen, struct ptlrep_hdr **hdr, struct mds_rep **rep, int *len, char **buf);
+int mds_unpack_rep(char *buf, int len, struct ptlrep_hdr **hdr, struct mds_rep **rep);
/* mds/mds_reint.c */
-int mds_reint_rec(struct mds_update_record *r, struct mds_request *req);
+int mds_reint_rec(struct mds_update_record *r, struct ptlrpc_request *req);
/* lib/mds_updates.c */
int mds_update_unpack(char *buf, int len, struct mds_update_record *r);
struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid, struct vfsmount **mnt);
/* llight/request.c */
-int mdc_getattr(ino_t ino, int type, int valid,
- struct mds_rep **mds_reply, struct mds_rep_hdr **hdr);
-int mdc_setattr(struct inode *inode, struct iattr *iattr,
- struct mds_rep **mds_reply, struct mds_rep_hdr **hdr);
-int mdc_readpage(ino_t ino, int type, __u64 offset, char *addr,
- struct mds_rep **rep, struct mds_rep_hdr **hdr);
-int mdc_create(struct inode *dir, const char *name,
+int mdc_getattr(struct lustre_peer *peer, ino_t ino, int type, int valid,
+ struct mds_rep **mds_reply, struct ptlrep_hdr **hdr);
+int mdc_setattr(struct lustre_peer *peer, struct inode *inode,
+ struct iattr *iattr, struct mds_rep **mds_reply,
+ struct ptlrep_hdr **hdr);
+int mdc_readpage(struct lustre_peer *peer, ino_t ino, int type, __u64 offset,
+ char *addr, struct mds_rep **rep, struct ptlrep_hdr **hdr);
+int mdc_create(struct lustre_peer *peer, struct inode *dir, const char *name,
int namelen, int mode, __u64 id, __u32 uid,
__u32 gid, __u64 time,
- struct mds_rep **rep, struct mds_rep_hdr **hdr);
+ struct mds_rep **rep, struct ptlrep_hdr **hdr);
/* ioctls for trying requests */
#define IOC_REQUEST_TYPE 'f'
obd_size count, obd_off offset);
int (*o_iterate)(struct obd_conn *conn, int (*)(obd_id, obd_gr, void *),
obd_id *startid, obd_gr group, void *data);
+#if 0
int (*o_dmaread)(struct obd_conn *conn, int count, struct obd_buf **dest,
struct obd_bufref **source);
int (*o_pre_dmawrite)(struct obd_conn *conn, int count, struct obd_buf **dstbufs,
struct obd_bufref **dest);
int (*o_dmawrite)(struct obd_conn *conn, int count, struct obd_buf **dstbufs,
struct obd_buf **dest);
+#endif
};
struct obd_request {
wait_queue_head_t rq_wait_for_rep;
};
-struct ost_req {
- __u32 connid;
- __u32 cmd;
- struct obdo oa;
- __u32 buflen1;
- __u32 buflen2;
- char * buf1;
- char * buf2;
-};
-
-struct ost_rep {
- __u32 result;
- __u32 connid;
- struct obdo oa;
- __u32 buflen1;
- __u32 buflen2;
- char * buf1;
- char * buf2;
-};
-
-
/* ost/ost_pack.c */
int ost_pack_req(char *buf1, int buflen1, char *buf2, int buflen2, struct ost_req_hdr **hdr, struct ost_req **req, int *len, char **buf);
int ost_unpack_req(char *buf, int len, struct ost_req_hdr **hdr, struct ost_req **req);
struct obd_device *osc_tgt;
};
-struct ost_request {
- struct list_head rq_list;
- struct ost_obd *rq_obd;
- int rq_status;
-
- char *rq_reqbuf;
- int rq_reqlen;
- struct ost_req_hdr *rq_reqhdr;
- struct ost_req *rq_req;
-
- char *rq_repbuf;
- int rq_replen;
- struct ost_rep_hdr *rq_rephdr;
- struct ost_rep *rq_rep;
-
- void *rq_reply_handle;
- wait_queue_head_t rq_wait_for_rep;
-};
-
-struct ost_req {
- __u32 connid;
- __u32 cmd;
- struct obdo oa;
- __u32 buflen1;
- __u32 buflen2;
- char *buf1;
- char *buf2;
-};
-
-struct ost_rep {
- __u32 result;
- __u32 connid;
- struct obdo oa;
- __u32 buflen1;
- __u32 buflen2;
- char * buf1;
- char * buf2;
-};
+/* ost/ost_pack.c */
+int ost_pack_req(char *buf1, int buflen1, char *buf2, int buflen2, struct ptlreq_hdr **hdr, struct ost_req **req, int *len, char **buf);
+int ost_unpack_req(char *buf, int len, struct ptlreq_hdr **hdr, struct ost_req **req);
+int ost_pack_rep(void *buf1, __u32 buflen1, void *buf2, __u32 buflen2, struct ptlrep_hdr **hdr, struct ost_rep **rep, int *len, char **buf);
+int ost_unpack_rep(char *buf, int len, struct ptlrep_hdr **hdr, struct ost_rep **rep);
+void ost_pack_niobuf(void **tmp, void *addr, __u64 offset, __u32 len,
+ __u32 flags);
+void ost_unpack_niobuf(void **tmp, struct niobuf **nbp);
+void ost_pack_ioo(void **tmp, struct obdo *oa, int bufcnt);
+void *ost_req_buf2(struct ost_req *req);
+void *ost_req_buf1(struct ost_req *req);
+void *ost_rep_buf2(struct ost_rep *rep);
+void *ost_rep_buf1(struct ost_rep *rep);
-/* ost/ost_pack.c */
-int ost_pack_req(char *buf1, int buflen1, char *buf2, int buflen2, struct ost_req_hdr **hdr, struct ost_req **req, int *len, char **buf);
-int ost_unpack_req(char *buf, int len, struct ost_req_hdr **hdr, struct ost_req **req);
-int ost_pack_rep(void *buf1, __u32 buflen1, void *buf2, __u32 buflen2, struct ost_rep_hdr **hdr, struct ost_rep **rep, int *len, char **buf);
-int ost_unpack_rep(char *buf, int len, struct ost_rep_hdr **hdr, struct ost_rep **rep);
#endif
int mds_pack_req(char *name, int namelen, char *tgt, int tgtlen,
- struct mds_req_hdr **hdr, struct mds_req **req,
+ struct ptlreq_hdr **hdr, struct mds_req **req,
int *len, char **buf)
{
char *ptr;
- struct mds_req_packed *preq;
*len = sizeof(**hdr) + size_round(namelen) + size_round(tgtlen) +
- sizeof(*preq);
+ sizeof(**req);
*buf = kmalloc(*len, GFP_KERNEL);
if (!*buf) {
}
memset(*buf, 0, *len);
- *hdr = (struct mds_req_hdr *)(*buf);
+ *hdr = (struct ptlreq_hdr *)(*buf);
*req = (struct mds_req *)(*buf + sizeof(**hdr));
-
- preq = (struct mds_req_packed *)(*buf + sizeof(**hdr));
- ptr = *buf + sizeof(**hdr) + sizeof(*preq);
+ ptr = *buf + sizeof(**hdr) + sizeof(**req);
(*hdr)->type = MDS_TYPE_REQ;
int mds_unpack_req(char *buf, int len,
- struct mds_req_hdr **hdr, struct mds_req **req)
+ struct ptlreq_hdr **hdr, struct mds_req **req)
{
- struct mds_req_packed *preq;
char *name, *tgt;
if (len < sizeof(**hdr) + sizeof(**req)) {
return -EINVAL;
}
- *hdr = (struct mds_req_hdr *) (buf);
- preq = (struct mds_req_packed *) (buf + sizeof(**hdr));
-
+ *hdr = (struct ptlreq_hdr *) (buf);
*req = (struct mds_req *) (buf + sizeof(**hdr));
+
(*req)->namelen = NTOH__u32((*req)->namelen);
(*req)->tgtlen = NTOH__u32((*req)->tgtlen);
- if (len < sizeof(**hdr) + sizeof(**req) + (*req)->namelen +
- (*req)->tgtlen ) {
+ if (len < sizeof(**hdr) + sizeof(**req) +
+ size_round((*req)->namelen) + size_round((*req)->tgtlen) ) {
EXIT;
return -EINVAL;
}
if ((*req)->namelen) {
- name = buf + sizeof(**hdr) + sizeof(*preq);
+ name = buf + sizeof(**hdr) + sizeof(**req);
} else {
name = NULL;
}
if ((*req)->tgtlen) {
- tgt = buf + sizeof(**hdr) + sizeof(*preq) +
+ tgt = buf + sizeof(**hdr) + sizeof(**req) +
size_round((*req)->namelen);
} else {
tgt = NULL;
{
if (!req->tgtlen)
return NULL;
- return (void *)((char *)req + sizeof(*req) + size_round(req->namelen));
+ return (void *)((char *)req + sizeof(*req) +
+ size_round(req->namelen));
+}
+
+void *mds_req_name(struct mds_req *req)
+{
+ if (!req->namelen)
+ return NULL;
+ return (void *)((char *)req + sizeof(*req));
}
int mds_pack_rep(char *name, int namelen, char *tgt, int tgtlen,
- struct mds_rep_hdr **hdr, struct mds_rep **rep,
+ struct ptlrep_hdr **hdr, struct mds_rep **rep,
int *len, char **buf)
{
char *ptr;
- struct mds_rep_packed *prep;
*len = sizeof(**hdr) + size_round(namelen) + size_round(tgtlen) +
- sizeof(*prep);
+ sizeof(**rep);
*buf = kmalloc(*len, GFP_KERNEL);
if (!*buf) {
}
memset(*buf, 0, *len);
- *hdr = (struct mds_rep_hdr *)(*buf);
+ *hdr = (struct ptlrep_hdr *)(*buf);
*rep = (struct mds_rep *)(*buf + sizeof(**hdr));
- prep = (struct mds_rep_packed *)(*buf + sizeof(**hdr));
- ptr = *buf + sizeof(**hdr) + sizeof(*prep);
+ ptr = *buf + sizeof(**hdr) + sizeof(**rep);
(*hdr)->type = MDS_TYPE_REP;
return 0;
}
-
int mds_unpack_rep(char *buf, int len,
- struct mds_rep_hdr **hdr, struct mds_rep **rep)
+ struct ptlrep_hdr **hdr, struct mds_rep **rep)
{
- struct mds_rep_packed *prep;
if (len < sizeof(**hdr)) {
EXIT;
return -EINVAL;
}
- *hdr = (struct mds_rep_hdr *) (buf);
+ *hdr = (struct ptlrep_hdr *) (buf);
if (len < sizeof(**hdr) + sizeof(**rep)) {
EXIT;
return -EINVAL;
}
- prep = (struct mds_rep_packed *) (buf + sizeof(**hdr));
-
*rep = (struct mds_rep *) (buf + sizeof(**hdr));
(*rep)->namelen = NTOH__u32((*rep)->namelen);
(*rep)->tgtlen = NTOH__u32((*rep)->namelen);
- if (len < sizeof(**hdr) + sizeof(**rep) + (*rep)->namelen +
- (*rep)->tgtlen ) {
+ if (len < sizeof(**hdr) + sizeof(**rep)
+ + size_round((*rep)->namelen) + size_round((*rep)->tgtlen) ) {
EXIT;
return -EINVAL;
}
return 0;
}
-void *mds_rep_tgt(struct mds_rep *rep)
+void *mds_rep_name(struct mds_rep *rep)
{
- if (!rep->tgtlen)
+ if (!rep->namelen)
return NULL;
- return (void *)((char *)rep + sizeof(*rep) + size_round(rep->namelen));
+ return (void *)((char *)rep + sizeof(*rep));
}
-#if 0
-int mds_pack_rep(char *name, int namelen, char *tgt, int tgtlen,
- struct mds_rep_hdr **hdr, struct mds_rep **rep,
- int *len, char **buf)
+void *mds_rep_tgt(struct mds_rep *rep)
{
- char *ptr;
-
- *len = sizeof(**hdr) + size_round(namelen) + size_round(tgtlen) +
- sizeof(**rep);
-
- *buf = kmalloc(*len, GFP_KERNEL);
- if (!*buf) {
- EXIT;
- return -ENOMEM;
- }
-
- memset(*buf, 0, *len);
- *hdr = (struct mds_rep_hdr *)(*buf);
- *rep = (struct mds_rep *)(*buf + sizeof(**hdr));
- ptr = *buf + sizeof(**hdr) + sizeof(**rep);
-
- (*rep)->namelen = NTOH__u32(namelen);
- if (name) {
- LOGL(name, namelen, ptr);
- }
-
- (*rep)->tgtlen = NTOH__u32(tgtlen);
- if (tgt) {
- LOGL(tgt, tgtlen, ptr);
- }
- return 0;
+ if (!rep->tgtlen)
+ return NULL;
+ return (void *)((char *)rep + sizeof(*rep) + size_round(rep->namelen));
}
-
-int mds_unpack_rep(char *buf, int len,
- struct mds_rep_hdr **hdr, struct mds_rep **rep)
-{
- if (len < sizeof(**hdr) + sizeof(**rep)) {
- EXIT;
- return -EINVAL;
- }
-
- *hdr = (struct mds_rep_hdr *) (buf);
- *rep = (struct mds_rep *) (buf + sizeof(**hdr));
- (*rep)->namelen = NTOH__u32((*rep)->namelen);
- (*rep)->tgtlen = NTOH__u32((*rep)->namelen);
-
- if (len < sizeof(**hdr) + sizeof(**rep) + (*rep)->namelen +
- (*rep)->tgtlen ) {
- EXIT;
- return -EINVAL;
- }
-
- if ((*rep)->namelen) {
- (*rep)->name = buf + sizeof(**hdr) + sizeof(**rep);
- } else {
- (*rep)->name = NULL;
- }
-
- if ((*rep)->tgtlen) {
- (*rep)->tgt = buf + sizeof(**hdr) + sizeof(**rep) +
- size_round((*rep)->namelen);
- } else {
- (*rep)->tgt = NULL;
- }
-
- EXIT;
- return 0;
-}
-#endif
int ost_pack_req(char *buf1, int buflen1, char *buf2, int buflen2,
- struct ost_req_hdr **hdr, struct ost_req **req,
+ struct ptlreq_hdr **hdr, struct ost_req **req,
int *len, char **buf)
{
char *ptr;
- struct ost_req_packed *preq;
*len = sizeof(**hdr) + size_round(buflen1) + size_round(buflen2) +
- sizeof(*preq);
+ sizeof(**req);
*buf = kmalloc(*len, GFP_KERNEL);
if (!*buf) {
}
memset(*buf, 0, *len);
- *hdr = (struct ost_req_hdr *)(*buf);
-
- preq = (struct ost_req_packed *)(*buf + sizeof(**hdr));
- ptr = *buf + sizeof(**hdr) + sizeof(*preq);
+ *hdr = (struct ptlreq_hdr *)(*buf);
*req = (struct ost_req *)(*buf + sizeof(**hdr));
+ ptr = *buf + sizeof(**hdr) + sizeof(**req);
+
(*hdr)->type = OST_TYPE_REQ;
(*req)->buflen1 = NTOH__u32(buflen1);
if (buf1) {
- preq->bufoffset1 = (__u32)(ptr - (char *)preq);
LOGL(buf1, buflen1, ptr);
}
(*req)->buflen2 = NTOH__u32(buflen2);
if (buf2) {
- preq->bufoffset2 = (__u32)(ptr - (char *)preq);
LOGL(buf2, buflen2, ptr);
}
return 0;
}
int ost_unpack_req(char *buf, int len,
- struct ost_req_hdr **hdr, struct ost_req **req)
+ struct ptlreq_hdr **hdr, struct ost_req **req)
{
- struct ost_req_packed *reqp;
- __u32 off1, off2;
- if (len < sizeof(**hdr) + sizeof(*reqp)) {
+ if (len < sizeof(**hdr) + sizeof(**req)) {
EXIT;
return -EINVAL;
}
- *hdr = (struct ost_req_hdr *) (buf);
- reqp = (struct ost_req_packed *) (buf + sizeof(**hdr));
+ *hdr = (struct ptlreq_hdr *) (buf);
*req = (struct ost_req *) (buf + sizeof(**hdr));
- (*req)->buflen1 = NTOH__u32(reqp->buflen1);
- (*req)->buflen2 = NTOH__u32(reqp->buflen2);
- off1 = NTOH__u32(reqp->bufoffset1);
- off2 = NTOH__u32(reqp->bufoffset2);
+ (*req)->buflen1 = NTOH__u32((*req)->buflen1);
+ (*req)->buflen2 = NTOH__u32((*req)->buflen2);
- if (len < sizeof(**hdr) + sizeof(*reqp) + size_round(reqp->buflen1) +
- size_round(reqp->buflen2) ) {
+ if (len < sizeof(**hdr) + sizeof(**req) +
+ size_round((*req)->buflen1) + size_round((*req)->buflen2) ) {
EXIT;
return -EINVAL;
}
- if ((*req)->buflen1) {
- (*req)->buf1 = (buf + sizeof(**hdr) + off1);
- } else {
- (*req)->buf1 = 0;
- }
- if ((*req)->buflen2) {
- (*req)->buf2 = (buf + sizeof(**hdr) + off2);
- } else {
- (*req)->buf2 = 0;
- }
-
EXIT;
return 0;
}
+
+void *ost_req_buf1(struct ost_req *req)
+{
+ if (!req->buflen1)
+ return NULL;
+ return (void *)((char *)req + sizeof(*req));
+}
+
+void *ost_req_buf2(struct ost_req *req)
+{
+ if (!req->buflen2)
+ return NULL;
+ return (void *)((char *)req + sizeof(*req) +
+ size_round(req->buflen1));
+}
+
int ost_pack_rep(void *buf1, __u32 buflen1, void *buf2, __u32 buflen2,
- struct ost_rep_hdr **hdr, struct ost_rep **rep,
+ struct ptlrep_hdr **hdr, struct ost_rep **rep,
int *len, char **buf)
{
char *ptr;
}
memset(*buf, 0, *len);
- *hdr = (struct ost_rep_hdr *)(*buf);
+ *hdr = (struct ptlrep_hdr *)(*buf);
*rep = (struct ost_rep *)(*buf + sizeof(**hdr));
ptr = *buf + sizeof(**hdr) + sizeof(**rep);
int ost_unpack_rep(char *buf, int len,
- struct ost_rep_hdr **hdr, struct ost_rep **rep)
+ struct ptlrep_hdr **hdr, struct ost_rep **rep)
{
- struct ost_rep_packed *prep;
- __u32 off1, off2;
-
if (len < sizeof(**hdr) + sizeof(**rep)) {
EXIT;
return -EINVAL;
}
- *hdr = (struct ost_rep_hdr *) (buf);
+ *hdr = (struct ptlrep_hdr *) (buf);
*rep = (struct ost_rep *) (buf + sizeof(**hdr));
- prep = (struct ost_rep_packed *) (buf + sizeof(**hdr));
- (*rep)->buflen1 = NTOH__u32(prep->buflen1);
- (*rep)->buflen2 = NTOH__u32(prep->buflen2);
- off1 = prep->bufoffset1;
- off2 = prep->bufoffset2;
-
- if (len < sizeof(**hdr) + sizeof(*prep) + size_round((*rep)->buflen1) +
- size_round((*rep)->buflen2) ) {
+
+ (*rep)->buflen1 = NTOH__u32((*rep)->buflen1);
+ (*rep)->buflen2 = NTOH__u32((*rep)->buflen2);
+
+ if (len < sizeof(**hdr) + sizeof(**rep) +
+ size_round((*rep)->buflen1) + size_round((*rep)->buflen2) ) {
EXIT;
return -EINVAL;
}
- if ((*rep)->buflen1) {
- (*rep)->buf1 = (buf + sizeof(**hdr) + off1);
- } else {
- (*rep)->buf1 = 0;
- }
- if ((*rep)->buflen2) {
- (*rep)->buf2 = (buf + sizeof(**hdr) + off2);
- } else {
- (*rep)->buf2 = 0;
- }
-
EXIT;
return 0;
}
+void *ost_rep_buf1(struct ost_rep *rep)
+{
+ if (!rep->buflen1)
+ return NULL;
+ return (void *)((char *)rep + sizeof(*rep));
+}
+
+void *ost_rep_buf2(struct ost_rep *rep)
+{
+ if (!rep->buflen2)
+ return NULL;
+ return (void *)((char *)rep + sizeof(*rep) +
+ size_round(rep->buflen1));
+}
+
+void ost_pack_ioo(void **tmp, struct obdo *oa, int bufcnt)
+{
+ struct obd_ioobj *ioo = *tmp;
+ char *c = *tmp;
+
+ ioo->ioo_id = NTOH__u64(oa->o_id);
+ ioo->ioo_gr = NTOH__u64(oa->o_gr);
+ ioo->ioo_type = NTOH__u64(oa->o_mode);
+ ioo->ioo_bufcnt = NTOH__u32(bufcnt);
+ *tmp = c + sizeof(*ioo);
+}
+
+void ost_unpack_ioo(void **tmp, struct obd_ioobj **ioop)
+{
+ char *c = *tmp;
+ struct obd_ioobj *ioo = *tmp;
+ *ioop = *tmp;
+
+ ioo->ioo_id = NTOH__u64(ioo->ioo_id);
+ ioo->ioo_gr = NTOH__u64(ioo->ioo_gr);
+ ioo->ioo_type = NTOH__u64(ioo->ioo_type);
+ ioo->ioo_bufcnt = NTOH__u32(ioo->ioo_bufcnt);
+ *tmp = c + sizeof(*ioo);
+}
+
+void ost_pack_niobuf(void **tmp, void *addr, __u64 offset, __u32 len,
+ __u32 flags)
+{
+ struct niobuf *ioo = *tmp;
+ char *c = *tmp;
+
+ ioo->addr = NTOH__u64((__u64)(unsigned long)addr);
+ ioo->offset = NTOH__u64(offset);
+ ioo->len = NTOH__u32(len);
+ ioo->flags = NTOH__u32(flags);
+ *tmp = c + sizeof(*ioo);
+}
+
+void ost_unpack_niobuf(void **tmp, struct niobuf **nbp)
+{
+ char *c = *tmp;
+ struct niobuf *nb = *tmp;
+
+ *nbp = *tmp;
+
+ nb->addr = NTOH__u64((__u64)(unsigned long)nb->addr);
+ nb->offset = NTOH__u64(nb->offset);
+ nb->len = NTOH__u32(nb->len);
+ nb->flags = NTOH__u32(nb->flags);
+
+ *tmp = c + sizeof(*nb);
+}
static struct dentry *ll_lookup(struct inode * dir, struct dentry *dentry)
{
struct mds_rep *rep;
- struct mds_rep_hdr *hdr = NULL;
+ struct ptlrep_hdr *hdr = NULL;
struct inode * inode = NULL;
int err;
int type;
{
struct inode *inode;
struct mds_rep *rep;
- struct mds_rep_hdr *hdr;
+ struct ptlrep_hdr *hdr;
int err;
ENTRY;
#include <linux/lustre_mds.h>
#include <linux/lustre_light.h>
+
+static void inline ll_oa_from_inode(struct obdo *oa, struct inode *inode)
+{
+ struct ll_inode_info *oinfo = ll_i2info(inode);
+
+ if ( oa->o_valid & OBD_MD_FLID )
+ oa->o_id = oinfo->lli_objid;
+ if ( oa->o_valid & OBD_MD_FLATIME )
+ oa->o_atime = inode->i_atime;
+ if ( oa->o_valid & OBD_MD_FLMTIME )
+ oa->o_mtime = inode->i_mtime;
+ if ( oa->o_valid & OBD_MD_FLCTIME )
+ oa->o_ctime = inode->i_ctime;
+ if ( oa->o_valid & OBD_MD_FLSIZE )
+ oa->o_size = inode->i_size;
+ if ( oa->o_valid & OBD_MD_FLBLOCKS ) /* allocation of space */
+ oa->o_blocks = inode->i_blocks;
+ if ( oa->o_valid & OBD_MD_FLBLKSZ )
+ oa->o_blksize = inode->i_blksize;
+ if ( oa->o_valid & OBD_MD_FLMODE )
+ oa->o_mode = inode->i_mode;
+ if ( oa->o_valid & OBD_MD_FLUID )
+ oa->o_uid = inode->i_uid;
+ if ( oa->o_valid & OBD_MD_FLGID )
+ oa->o_gid = inode->i_gid;
+ if ( oa->o_valid & OBD_MD_FLFLAGS )
+ oa->o_flags = inode->i_flags;
+ if ( oa->o_valid & OBD_MD_FLNLINK )
+ oa->o_nlink = inode->i_nlink;
+ if ( oa->o_valid & OBD_MD_FLGENER )
+ oa->o_generation = inode->i_generation;
+
+ CDEBUG(D_INFO, "src inode %ld, dst obdo %ld valid 0x%08x\n",
+ inode->i_ino, (long)oa->o_id, oa->o_valid);
+ obdo_from_inode(oa, inode);
+
+ /* this will transfer metadata for the logical object to
+ the oa: that metadata could contain the constituent objects
+ */
+ if (ll_has_inline(inode)) {
+ CDEBUG(D_INODE, "copying inline data from inode to obdo\n");
+ memcpy(oa->o_inline, oinfo->lli_inline, OBD_INLINESZ);
+ oa->o_obdflags |= OBD_FL_INLINEDATA;
+ oa->o_valid |= OBD_MD_FLINLINE;
+ }
+} /* ll_oa_from_inode */
+
/*
* Add a page to the dirty page list.
*/
return -ENOMEM;
}
oa->o_valid = OBD_MD_FLNOTOBD;
- ll_from_inode(oa, inode);
+ ll_oa_from_inode(oa, inode);
err = obd_brw(rw, IID(inode), num_obdo, &oa, &bufs_per_obdo,
&page, &count, &offset, &flags);
return -ENOMEM;
}
oa->o_valid = OBD_MD_FLNOTOBD;
- ll_from_inode(oa, inode);
+ ll_oa_from_inode(oa, inode);
CDEBUG(D_INODE, "commit_page writing (at %d) to %d, count %Ld\n",
from, to, count);
char *buf;
__u64 offset;
int rc = 0;
- struct mds_rep_hdr *hdr;
+ struct ptlrep_hdr *hdr;
ENTRY;
printk(__FUNCTION__ ": obdo_alloc failed - using stack!\n");
obdo.o_valid = OBD_MD_FLNOTOBD;
- ll_from_inode(&obdo, inode);
+ ll_oa_from_inode(&obdo, inode);
err = obd_punch(IID(inode), &obdo, 0, obdo.o_size);
} else {
oa->o_valid = OBD_MD_FLNOTOBD;
- ll_from_inode(oa, inode);
+ ll_oa_from_inode(oa, inode);
CDEBUG(D_INFO, "calling punch for %ld (%Lu bytes at 0)\n",
(long)oa->o_id, oa->o_size);
int devno;
int err;
struct mds_rep *rep;
- struct mds_rep_hdr *hdr = NULL;
+ struct ptlrep_hdr *hdr = NULL;
ENTRY;
MOD_INC_USE_COUNT;
int ll_setattr(struct dentry *de, struct iattr *attr)
{
struct inode *inode = de->d_inode;
- struct mds_rep_hdr *hdr = NULL;
+ struct ptlrep_hdr *hdr = NULL;
int err;
ENTRY;
#include <linux/lustre_idl.h>
#include <linux/lustre_mds.h>
-extern int mdc_reint(struct mds_request *request);
-extern struct mds_request *mds_prep_req(int opcode, int namelen, char *name, int tgtlen, char *tgt);
+extern int mdc_reint(struct lustre_peer *peer, struct ptlrpc_request *request);
+extern struct ptlrpc_request *mds_prep_req(int opcode, int namelen, char *name, int tgtlen, char *tgt);
-int mdc_setattr(struct inode *inode, struct iattr *iattr,
- struct mds_rep **rep, struct mds_rep_hdr **hdr)
+int mdc_setattr(struct lustre_peer *peer,
+ struct inode *inode, struct iattr *iattr,
+ struct mds_rep **rep, struct ptlrep_hdr **hdr)
{
int rc;
- struct mds_request *request;
+ struct ptlrpc_request *request;
struct mds_rec_setattr *rec;
request = mds_prep_req(MDS_REINT, 0, NULL, sizeof(*rec), NULL);
return -ENOMEM;
}
- rec = mds_req_tgt(request->rq_req);
+ rec = mds_req_tgt(request->rq_req.mds);
mds_setattr_pack(rec, inode, iattr);
- request->rq_req->opcode = HTON__u32(REINT_SETATTR);
+ request->rq_req.mds->opcode = HTON__u32(REINT_SETATTR);
- rc = mdc_reint(request);
+ rc = mdc_reint(peer, request);
if (rep) {
- *rep = request->rq_rep;
+ *rep = request->rq_rep.mds;
}
if (hdr) {
*hdr = request->rq_rephdr;
return rc;
}
-int mdc_create(struct inode *dir, const char *name, int namelen,
+int mdc_create(struct lustre_peer *peer,
+ struct inode *dir, const char *name, int namelen,
int mode, __u64 id, __u32 uid, __u32 gid, __u64 time,
- struct mds_rep **rep, struct mds_rep_hdr **hdr)
+ struct mds_rep **rep, struct ptlrep_hdr **hdr)
{
int rc;
- struct mds_request *request;
+ struct ptlrpc_request *request;
struct mds_rec_create *rec;
request = mds_prep_req(MDS_REINT, 0, NULL,
return -ENOMEM;
}
- rec = mds_req_tgt(request->rq_req);
+ rec = mds_req_tgt(request->rq_req.mds);
mds_create_pack(rec, dir, name, namelen, mode, id, uid, gid, time);
- rc = mdc_reint(request);
+ rc = mdc_reint(peer, request);
if (rep) {
- *rep = request->rq_rep;
+ *rep = request->rq_rep.mds;
}
if (hdr) {
*hdr = request->rq_rephdr;
#define REQUEST_MINOR 244
-extern int mds_queue_req(struct mds_request *);
+extern int mds_queue_req(struct ptlrpc_request *);
-struct mds_request *mds_prep_req(int opcode, int namelen, char *name, int tgtlen, char *tgt)
+struct ptlrpc_request *mds_prep_req(int opcode, int namelen, char *name, int tgtlen, char *tgt)
{
- struct mds_request *request;
+ struct ptlrpc_request *request;
int rc;
ENTRY;
- request = (struct mds_request *)kmalloc(sizeof(*request), GFP_KERNEL);
+ request = (struct ptlrpc_request *)kmalloc(sizeof(*request), GFP_KERNEL);
if (!request) {
printk("mds_prep_req: request allocation out of memory\n");
return NULL;
}
rc = mds_pack_req(name, namelen, tgt, tgtlen,
- &request->rq_reqhdr, &request->rq_req,
+ &request->rq_reqhdr, &(request->rq_req.mds),
&request->rq_reqlen, &request->rq_reqbuf);
if (rc) {
printk("llight request: cannot pack request %d\n", rc);
return NULL;
}
printk("--> mds_prep_req: len %d, req %p, tgtlen %d\n",
- request->rq_reqlen, request->rq_req,
- request->rq_req->tgtlen);
+ request->rq_reqlen, request->rq_req.mds,
+ request->rq_req.mds->tgtlen);
request->rq_reqhdr->opc = opcode;
EXIT;
-static int mds_queue_wait(struct mds_request *req)
+static int mds_queue_wait(struct ptlrpc_request *req, struct lustre_peer *peer)
{
int rc;
/* XXX fix the race here (wait_for_event?)*/
/* hand the packet over to the server */
- rc = mds_queue_req(req);
+ rc = ptl_send_rpc(req, peer);
if (rc) {
printk("mdc_queue_wait: error %d, opcode %d\n", rc,
req->rq_reqhdr->opc);
printk("-- done\n");
mds_unpack_rep(req->rq_repbuf, req->rq_replen, &req->rq_rephdr,
- &req->rq_rep);
+ &req->rq_rep.mds);
if ( req->rq_rephdr->status == 0 )
printk("-->mdc_queue_wait: buf %p len %d status %d\n",
req->rq_repbuf, req->rq_replen,
return req->rq_rephdr->status;
}
-void mds_free_req(struct mds_request *request)
+void mds_free_req(struct ptlrpc_request *request)
{
kfree(request);
}
-int mdc_getattr(ino_t ino, int type, int valid,
- struct mds_rep **rep, struct mds_rep_hdr **hdr)
+int mdc_getattr(struct lustre_peer *peer, ino_t ino, int type, int valid,
+ struct mds_rep **rep, struct ptlrep_hdr **hdr)
{
- struct mds_request *request;
+ struct ptlrpc_request *request;
int rc;
request = mds_prep_req(MDS_GETATTR, 0, NULL, 0, NULL);
return -ENOMEM;
}
- ll_ino2fid(&request->rq_req->fid1, ino, 0, type);
+ ll_ino2fid(&request->rq_req.mds->fid1, ino, 0, type);
- request->rq_req->valid = valid;
+ request->rq_req.mds->valid = valid;
+ request->rq_replen =
+ sizeof(struct ptlrep_hdr) + sizeof(struct mds_rep);
- rc = mds_queue_wait(request);
+ rc = mds_queue_wait(request, peer);
if (rc) {
printk("llight request: error in handling %d\n", rc);
goto out;
}
- printk("mds_getattr: mode: %o\n", request->rq_rep->mode);
+ printk("mds_getattr: mode: %o\n", request->rq_rep.mds->mode);
if (rep) {
- *rep = request->rq_rep;
+ *rep = request->rq_rep.mds;
}
if (hdr) {
*hdr = request->rq_rephdr;
return rc;
}
-int mdc_readpage(ino_t ino, int type, __u64 offset, char *addr,
- struct mds_rep **rep, struct mds_rep_hdr **hdr)
+int mdc_readpage(struct lustre_peer *peer, ino_t ino, int type, __u64 offset,
+ char *addr, struct mds_rep **rep, struct ptlrep_hdr **hdr)
{
- struct mds_request *request;
+ struct ptlrpc_request *request;
struct niobuf niobuf;
int rc;
return -ENOMEM;
}
- request->rq_req->fid1.id = ino;
- request->rq_req->fid1.f_type = type;
- request->rq_req->size = offset;
- request->rq_req->tgtlen = sizeof(niobuf);
+ request->rq_req.mds->fid1.id = ino;
+ request->rq_req.mds->fid1.f_type = type;
+ request->rq_req.mds->size = offset;
+ request->rq_req.mds->tgtlen = sizeof(niobuf);
- rc = mds_queue_wait(request);
+ rc = mds_queue_wait(request, peer);
if (rc) {
printk("mdc request: error in handling %d\n", rc);
goto out;
}
- printk("mdc_readpage: mode: %o\n", request->rq_rep->mode);
+ printk("mdc_readpage: mode: %o\n", request->rq_rep.mds->mode);
if (rep) {
- *rep = request->rq_rep;
+ *rep = request->rq_rep.mds;
}
if (hdr) {
*hdr = request->rq_rephdr;
return rc;
}
-int mdc_reint(struct mds_request *request)
+int mdc_reint(struct lustre_peer *peer, struct ptlrpc_request *request)
{
int rc;
- rc = mds_queue_wait(request);
+ rc = mds_queue_wait(request, peer);
if (rc) {
printk("mdc request: error in handling %d\n", rc);
}
unsigned int cmd, unsigned long arg)
{
int err;
+ struct lustre_peer peer;
ENTRY;
return -EINVAL;
}
+ //rc = ptl_peer("mds", peer);
switch (cmd) {
case IOC_REQUEST_GETATTR: {
- struct mds_rep_hdr *hdr = NULL;
+ struct ptlrep_hdr *hdr = NULL;
printk("-- getting attr for ino 2\n");
- err = mdc_getattr(2, S_IFDIR, ~0, NULL, &hdr);
+ err = mdc_getattr(&peer, 2, S_IFDIR, ~0, NULL, &hdr);
if (hdr)
kfree(hdr);
printk("-- done err %d\n", err);
}
case IOC_REQUEST_READPAGE: {
- struct mds_rep_hdr *hdr = NULL;
+ struct ptlrep_hdr *hdr = NULL;
char *buf;
buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (!buf) {
break;
}
printk("-- readpage 0 for ino 2\n");
- err = mdc_readpage(2, S_IFDIR, 0, buf, NULL, &hdr);
+ err = mdc_readpage(&peer, 2, S_IFDIR, 0, buf, NULL, &hdr);
printk("-- done err %d\n", err);
if (!err) {
printk("-- status: %d\n", hdr->status);
case IOC_REQUEST_SETATTR: {
struct inode inode;
- struct mds_rep_hdr *hdr;
+ struct ptlrep_hdr *hdr;
struct iattr iattr;
inode.i_ino = 2;
iattr.ia_atime = 0;
iattr.ia_valid = ATTR_MODE | ATTR_ATIME;
- err = mdc_setattr(&inode, &iattr, NULL, &hdr);
+ err = mdc_setattr(&peer, &inode, &iattr, NULL, &hdr);
printk("-- done err %d\n", err);
if (!err) {
printk("-- status: %d\n", hdr->status);
case IOC_REQUEST_CREATE: {
struct inode inode;
- struct mds_rep_hdr *hdr;
+ struct ptlrep_hdr *hdr;
struct iattr iattr;
inode.i_ino = 2;
iattr.ia_atime = 0;
iattr.ia_valid = ATTR_MODE | ATTR_ATIME;
- err = mdc_create(&inode, "foofile", strlen("foofile"),
+ err = mdc_create(&peer, &inode, "foofile", strlen("foofile"),
0100707, 47114711,
11, 47, 0, NULL, &hdr);
printk("-- done err %d\n", err);
};
-static int __init mds_request_init(void)
+static int __init ptlrpc_request_init(void)
{
misc_register(&request_dev);
return 0 ;
}
-static void __exit mds_request_exit(void)
+static void __exit ptlrpc_request_exit(void)
{
misc_deregister(&request_dev);
}
EXPORT_SYMBOL(mdc_readpage);
EXPORT_SYMBOL(mdc_setattr);
-module_init(mds_request_init);
-module_exit(mds_request_exit);
+module_init(ptlrpc_request_init);
+module_exit(ptlrpc_request_exit);
*
* Lustre Metadata Server (mds) request handler
*
- * Copyright (C) 2001 Cluster File Systems, Inc.
+ * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
*
* This code is issued under the GNU General Public License.
* See the file COPYING in this distribution
#include <linux/lustre_lib.h>
#include <linux/lustre_idl.h>
#include <linux/lustre_mds.h>
+#include <linux/lustre_net.h>
#include <linux/obd_class.h>
// XXX for testing
static struct mds_obd *MDS;
// XXX make this networked!
-static int mds_queue_req(struct mds_request *req)
+static int mds_queue_req(struct ptlrpc_request *req)
{
- struct mds_request *srv_req;
+ struct ptlrpc_request *srv_req;
if (!MDS) {
EXIT;
}
/* XXX do this over the net */
-int mds_sendpage(struct mds_request *req, struct file *file,
+int mds_sendpage(struct ptlrpc_request *req, struct file *file,
__u64 offset, struct niobuf *dst)
{
int rc;
}
/* XXX replace with networking code */
-int mds_reply(struct mds_request *req)
+int mds_reply(struct ptlrpc_request *req)
{
- struct mds_request *clnt_req = req->rq_reply_handle;
+ struct ptlrpc_request *clnt_req = req->rq_reply_handle;
ENTRY;
-
- /* free the request buffer */
- kfree(req->rq_reqbuf);
- req->rq_reqbuf = NULL;
/* move the reply to the client */
clnt_req->rq_replen = req->rq_replen;
req->rq_repbuf = NULL;
req->rq_replen = 0;
+ /* free the request buffer */
+ kfree(req->rq_reqbuf);
+ req->rq_reqbuf = NULL;
+
/* wake up the client */
wake_up_interruptible(&clnt_req->rq_wait_for_rep);
EXIT;
return 0;
}
-int mds_error(struct mds_request *req)
+int mds_error(struct ptlrpc_request *req)
{
- struct mds_rep_hdr *hdr;
+ struct ptlrep_hdr *hdr;
ENTRY;
+
hdr = kmalloc(sizeof(*hdr), GFP_KERNEL);
if (!hdr) {
EXIT;
memcpy(id, &inode->u.ext2_i.i_data, sizeof(*id));
}
-int mds_getattr(struct mds_request *req)
+int mds_getattr(struct ptlrpc_request *req)
{
- struct dentry *de = mds_fid2dentry(req->rq_obd, &req->rq_req->fid1,
+ struct dentry *de = mds_fid2dentry(req->rq_obd, &req->rq_req.mds->fid1,
NULL);
struct inode *inode;
struct mds_rep *rep;
int rc;
- rc = mds_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep,
+ rc = mds_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep.mds,
&req->rq_replen, &req->rq_repbuf);
if (rc) {
EXIT;
printk("mds: out of memory\n");
req->rq_status = -ENOMEM;
- return -ENOMEM;
+ return 0;
}
req->rq_rephdr->seqno = req->rq_reqhdr->seqno;
- rep = req->rq_rep;
+ rep = req->rq_rep.mds;
if (!de) {
EXIT;
return 0;
}
-int mds_readpage(struct mds_request *req)
+int mds_readpage(struct ptlrpc_request *req)
{
struct vfsmount *mnt;
- struct dentry *de = mds_fid2dentry(req->rq_obd, &req->rq_req->fid1,
+ struct dentry *de = mds_fid2dentry(req->rq_obd, &req->rq_req.mds->fid1,
&mnt);
struct file *file;
struct niobuf *niobuf;
int rc;
printk("mds_readpage: ino %ld\n", de->d_inode->i_ino);
- rc = mds_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep,
+ rc = mds_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep.mds,
&req->rq_replen, &req->rq_repbuf);
if (rc) {
EXIT;
printk("mds: out of memory\n");
req->rq_status = -ENOMEM;
- return -ENOMEM;
+ return 0;
}
req->rq_rephdr->seqno = req->rq_reqhdr->seqno;
- rep = req->rq_rep;
+ rep = req->rq_rep.mds;
if (IS_ERR(de)) {
EXIT;
return 0;
}
- niobuf = mds_req_tgt(req->rq_req);
+ niobuf = mds_req_tgt(req->rq_req.mds);
/* to make this asynchronous make sure that the handling function
doesn't send a reply when this function completes. Instead a
callback function would send the reply */
- rc = mds_sendpage(req, file, req->rq_req->size, niobuf);
+ rc = mds_sendpage(req, file, req->rq_req.mds->size, niobuf);
filp_close(file, 0);
req->rq_rephdr->status = rc;
return 0;
}
-int mds_reint(struct mds_request *req)
+int mds_reint(struct ptlrpc_request *req)
{
int rc;
- char *buf = mds_req_tgt(req->rq_req);
- int len = req->rq_req->tgtlen;
+ char *buf = mds_req_tgt(req->rq_req.mds);
+ int len = req->rq_req.mds->tgtlen;
struct mds_update_record rec;
rc = mds_update_unpack(buf, len, &rec);
if (rc) {
printk(__FUNCTION__ ": invalid record\n");
- return -EINVAL;
+ req->rq_status = -EINVAL;
+ return 0;
}
-
+ /* rc will be used to interrupt a for loop over multiple records */
rc = mds_reint_rec(&rec, req);
return 0;
}
//int mds_handle(struct mds_conn *conn, int len, char *buf)
-int mds_handle(struct mds_request *req)
+int mds_handle(struct ptlrpc_request *req)
{
int rc;
- struct mds_req_hdr *hdr;
+ struct ptlreq_hdr *hdr;
ENTRY;
- hdr = (struct mds_req_hdr *)req->rq_reqbuf;
+ hdr = (struct ptlreq_hdr *)req->rq_reqbuf;
if (NTOH__u32(hdr->type) != MDS_TYPE_REQ) {
printk("lustre_mds: wrong packet type sent %d\n",
}
rc = mds_unpack_req(req->rq_reqbuf, req->rq_reqlen,
- &req->rq_reqhdr, &req->rq_req);
+ &req->rq_reqhdr, &req->rq_req.mds);
if (rc) {
printk("lustre_mds: Invalid request\n");
EXIT;
out:
if (rc) {
- printk("mds: processing error %d\n", rc);
+ printk(__FUNCTION__ ": no header\n");
+ return 0;
+ }
+
+ if( req->rq_status) {
mds_error(req);
} else {
CDEBUG(D_INODE, "sending reply\n");
/* And now, wait forever for commit wakeup events. */
while (1) {
- struct mds_request *request;
+ struct ptlrpc_request *request;
int rc;
if (mds->mds_flags & MDS_UNMOUNT)
CDEBUG(D_INODE, "woke because of timer\n");
} else {
request = list_entry(mds->mds_reqs.next,
- struct mds_request, rq_list);
+ struct ptlrpc_request, rq_list);
list_del(&request->rq_list);
rc = mds_handle(request);
}
{
struct obd_ioctl_data* data = buf;
struct mds_obd *mds = &obddev->u.mds;
- struct vfsmount *mnt;
- int err;
ENTRY;
-
- mnt = do_kern_mount(data->ioc_inlbuf2, 0,
- data->ioc_inlbuf1, NULL);
- err = PTR_ERR(mnt);
- if (IS_ERR(mnt)) {
- EXIT;
- return err;
- }
- mds->mds_sb = mnt->mnt_root->d_inode->i_sb;
- if (!obddev->u.mds.mds_sb) {
- EXIT;
- return -ENODEV;
- }
+ /* If the ioctl data contains two inline buffers, this is a request to
+ * mount a local filesystem for metadata storage. If the ioctl data
+ * contains one buffer, however, it is the UUID of the remote node that
+ * we will contact for metadata. */
+ if (data->ioc_inllen2 == 0) {
+ __u32 nid;
+
+ nid = kportal_uuid_to_nid(data->ioc_inlbuf1);
+ if (nid == 0) {
+ printk("Lustre: uuid_to_nid failed; use ptlctl to "
+ "associate this uuid with a NID\n");
+ EXIT;
+ return -EINVAL;
+ }
+ printk("Lustre MDS: remote nid is %u\n", nid);
+ mds->mds_remote_nid = nid;
+ } else {
+ struct vfsmount *mnt;
+ int err;
+
+ mnt = do_kern_mount(data->ioc_inlbuf2, 0,
+ data->ioc_inlbuf1, NULL);
+ err = PTR_ERR(mnt);
+ if (IS_ERR(mnt)) {
+ EXIT;
+ return err;
+ }
+
+ mds->mds_sb = mnt->mnt_root->d_inode->i_sb;
+ if (!obddev->u.mds.mds_sb) {
+ EXIT;
+ return -ENODEV;
+ }
+
+ mds->mds_vfsmnt = mnt;
+ obddev->u.mds.mds_fstype = strdup(data->ioc_inlbuf2);
+
+ mds->mds_ctxt.pwdmnt = mnt;
+ mds->mds_ctxt.pwd = mnt->mnt_root;
+ mds->mds_ctxt.fs = KERNEL_DS;
+ mds->mds_remote_nid = 0;
+ }
INIT_LIST_HEAD(&mds->mds_reqs);
mds->mds_thread = NULL;
mds->mds_flags = 0;
mds->mds_interval = 3 * HZ;
- mds->mds_vfsmnt = mnt;
- obddev->u.mds.mds_fstype = strdup(data->ioc_inlbuf2);
-
- mds->mds_ctxt.pwdmnt = mnt;
- mds->mds_ctxt.pwd = mnt->mnt_root;
- mds->mds_ctxt.fs = KERNEL_DS;
MDS = mds;
spin_lock_init(&obddev->u.mds.mds_lock);
#include <linux/lustre_mds.h>
#include <linux/obd_class.h>
-extern struct mds_request *mds_prep_req(int size, int opcode, int namelen, char *name, int tgtlen, char *tgt);
+extern struct ptlrpc_request *mds_prep_req(int size, int opcode, int namelen, char *name, int tgtlen, char *tgt);
-static int mds_reint_setattr(struct mds_update_record *rec, struct mds_request *req)
+static int mds_reint_setattr(struct mds_update_record *rec, struct ptlrpc_request *req)
{
struct vfsmount *mnt;
struct dentry *de;
static int mds_reint_create(struct mds_update_record *rec,
- struct mds_request *req)
+ struct ptlrpc_request *req)
{
struct vfsmount *mnt;
int type = rec->ur_mode & S_IFMT;
struct dentry *de;
- struct mds_rep *rep = req->rq_rep;
+ struct mds_rep *rep = req->rq_rep.mds;
struct dentry *dchild;
int rc;
return 0;
}
-typedef int (*mds_reinter)(struct mds_update_record *, struct mds_request*);
+typedef int (*mds_reinter)(struct mds_update_record *, struct ptlrpc_request*);
static mds_reinter reinters[REINT_MAX+1] = {
[REINT_SETATTR] mds_reint_setattr,
[REINT_CREATE] mds_reint_create
};
-int mds_reint_rec(struct mds_update_record *rec, struct mds_request *req)
+int mds_reint_rec(struct mds_update_record *rec, struct ptlrpc_request *req)
{
int rc;
if (rec->ur_opcode < 0 || rec->ur_opcode > REINT_MAX) {
printk(__FUNCTION__ "opcode %d not valid\n",
rec->ur_opcode);
- return -EINVAL;
+ rc = req->rq_status = -EINVAL;
+ return rc;
}
- rc = mds_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep,
+ rc = mds_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep.mds,
&req->rq_replen, &req->rq_repbuf);
if (rc) {
EXIT;
printk("mds: out of memory\n");
- req->rq_status = -ENOMEM;
- return -ENOMEM;
+ rc = req->rq_status = -ENOMEM;
+ return rc;
}
req->rq_rephdr->seqno = req->rq_reqhdr->seqno;
rc = reinters[rec->ur_opcode](rec, req);
+ req->rq_status = rc;
+
return rc;
}
#include <linux/lustre_lib.h>
#include <linux/lustre_idl.h>
-extern int ost_queue_req(struct obd_device *, struct ost_request *);
+extern int ost_queue_req(struct obd_device *, struct ptlrpc_request *);
-struct ost_request *osc_prep_req(int size, int opcode)
+struct ptlrpc_request *ost_prep_req(int opcode, int buflen1, char *buf1,
+ int buflen2, char *buf2)
{
- struct ost_request *request;
+ struct ptlrpc_request *request;
int rc;
ENTRY;
- request = (struct ost_request *)kmalloc(sizeof(*request), GFP_KERNEL);
+ request = (struct ptlrpc_request *)kmalloc(sizeof(*request), GFP_KERNEL);
if (!request) {
printk("osc_prep_req: request allocation out of memory\n");
return NULL;
}
- rc = ost_pack_req(NULL, 0, NULL, 0,
- &request->rq_reqhdr, &request->rq_req,
+ rc = ost_pack_req(buf1, buflen1, buf2, buflen2,
+ &request->rq_reqhdr, &request->rq_req.ost,
&request->rq_reqlen, &request->rq_reqbuf);
if (rc) {
printk("llight request: cannot pack request %d\n", rc);
return request;
}
-extern int osc_queue_wait(struct obd_conn *conn, struct ost_request *req)
+extern int osc_queue_wait(struct obd_conn *conn, struct ptlrpc_request *req)
{
struct obd_device *client = conn->oc_dev;
struct obd_device *target = client->u.osc.osc_tgt;
ENTRY;
/* set the connection id */
- req->rq_req->connid = conn->oc_id;
+ req->rq_req.ost->connid = conn->oc_id;
CDEBUG(D_INODE, "tgt at %p, conn id %d, opcode %d request at: %p\n",
&conn->oc_dev->u.osc.osc_tgt->u.ost,
interruptible_sleep_on(&req->rq_wait_for_rep);
ost_unpack_rep(req->rq_repbuf, req->rq_replen, &req->rq_rephdr,
- &req->rq_rep);
+ &req->rq_rep.ost);
printk("-->osc_queue_wait: buf %p len %d status %d\n",
req->rq_repbuf, req->rq_replen, req->rq_rephdr->status);
return req->rq_rephdr->status;
}
-void osc_free_req(struct ost_request *request)
+void osc_free_req(struct ptlrpc_request *request)
{
if (request->rq_repbuf)
kfree(request->rq_repbuf);
int osc_connect(struct obd_conn *conn)
{
- struct ost_request *request;
+ struct ptlrpc_request *request;
int rc;
ENTRY;
- request = osc_prep_req(sizeof(*request), OST_CONNECT);
+ request = ost_prep_req(OST_CONNECT, 0, NULL, 0, NULL);
if (!request) {
printk("osc_connect: cannot pack req!\n");
return -ENOMEM;
goto out;
}
- CDEBUG(D_INODE, "received connid %d\n", request->rq_rep->connid);
+ CDEBUG(D_INODE, "received connid %d\n", request->rq_rep.ost->connid);
- conn->oc_id = request->rq_rep->connid;
+ conn->oc_id = request->rq_rep.ost->connid;
out:
osc_free_req(request);
EXIT;
int osc_disconnect(struct obd_conn *conn)
{
- struct ost_request *request;
+ struct ptlrpc_request *request;
int rc;
ENTRY;
- request = osc_prep_req(sizeof(*request), OST_DISCONNECT);
+ request = ost_prep_req(OST_DISCONNECT, 0, NULL, 0, NULL);
if (!request) {
printk("osc_connect: cannot pack req!\n");
return -ENOMEM;
int osc_getattr(struct obd_conn *conn, struct obdo *oa)
{
- struct ost_request *request;
+ struct ptlrpc_request *request;
int rc;
- request = osc_prep_req(sizeof(*request), OST_GETATTR);
+ request = ost_prep_req(OST_GETATTR, 0, NULL, 0, NULL);
if (!request) {
printk("osc_connect: cannot pack req!\n");
return -ENOMEM;
}
- memcpy(&request->rq_req->oa, oa, sizeof(*oa));
- request->rq_req->oa.o_valid = ~0;
+ memcpy(&request->rq_req.ost->oa, oa, sizeof(*oa));
+ request->rq_req.ost->oa.o_valid = ~0;
rc = osc_queue_wait(conn, request);
if (rc) {
goto out;
}
- CDEBUG(D_INODE, "mode: %o\n", request->rq_rep->oa.o_mode);
+ CDEBUG(D_INODE, "mode: %o\n", request->rq_rep.ost->oa.o_mode);
if (oa) {
- memcpy(oa, &request->rq_rep->oa, sizeof(*oa));
+ memcpy(oa, &request->rq_rep.ost->oa, sizeof(*oa));
}
out:
int osc_create(struct obd_conn *conn, struct obdo *oa)
{
- struct ost_request *request;
+ struct ptlrpc_request *request;
int rc;
if (!oa) {
printk(__FUNCTION__ ": oa NULL\n");
}
- request = osc_prep_req(sizeof(*request), OST_CREATE);
+ request = ost_prep_req(OST_CREATE, 0, NULL, 0, NULL);
if (!request) {
printk("osc_connect: cannot pack req!\n");
return -ENOMEM;
}
- memcpy(&request->rq_req->oa, oa, sizeof(*oa));
- request->rq_req->oa.o_valid = ~0;
+ memcpy(&request->rq_req.ost->oa, oa, sizeof(*oa));
+ request->rq_req.ost->oa.o_valid = ~0;
rc = osc_queue_wait(conn, request);
if (rc) {
EXIT;
goto out;
}
- memcpy(oa, &request->rq_rep->oa, sizeof(*oa));
+ memcpy(oa, &request->rq_rep.ost->oa, sizeof(*oa));
out:
osc_free_req(request);
return 0;
}
+void osc_sendpage(struct niobuf *dst, struct niobuf *src)
+{
+ memcpy((char *)(unsigned long)dst->addr,
+ (char *)(unsigned long)src->addr,
+ src->len);
+ return;
+}
+
+
+int osc_brw(int rw, struct obd_conn *conn, obd_count num_oa,
+ struct obdo **oa, obd_count *oa_bufs, struct page **buf,
+ obd_size *count, obd_off *offset, obd_flag *flags)
+{
+ struct ptlrpc_request *request;
+ int rc;
+ struct obd_ioobj ioo;
+ struct niobuf src;
+ int size1, size2 = 0;
+ void *ptr1, *ptr2;
+ int i, j, n;
+
+ size1 = num_oa * sizeof(ioo);
+ for (i = 0; i < num_oa; i++) {
+ size2 += oa_bufs[i] * sizeof(src);
+ }
+
+ request = ost_prep_req(OST_PREPW, size1, NULL, size2, NULL);
+ if (!request) {
+ printk("osc_connect: cannot pack req!\n");
+ return -ENOMEM;
+ }
+
+ n = 0;
+ ptr1 = ost_req_buf1(request->rq_req.ost);
+ ptr2 = ost_req_buf2(request->rq_req.ost);
+ for (i=0; i < num_oa; i++) {
+ ost_pack_ioo(&ptr1, oa[i], oa_bufs[i]);
+ for (j = 0 ; j < oa_bufs[i] ; j++) {
+ ost_pack_niobuf(&ptr2, kmap(buf[n]), offset[n],
+ count[n], flags[n]);
+ n++;
+ }
+ }
+
+ rc = osc_queue_wait(conn, request);
+ if (rc) {
+ EXIT;
+ goto out;
+ }
+
+ ptr2 = ost_rep_buf2(request->rq_rep.ost);
+ if (request->rq_rep.ost->buflen2 != n * sizeof(struct niobuf)) {
+ printk(__FUNCTION__ ": buffer length wrong\n");
+ goto out;
+ }
+
+ for (i=0; i < num_oa; i++) {
+ for (j = 0 ; j < oa_bufs[i] ; j++) {
+ struct niobuf *dst;
+ src.addr = (__u64)(unsigned long)buf[n];
+ src.len = count[n];
+ ost_unpack_niobuf(&ptr2, &dst);
+ osc_sendpage(dst, &src);
+ n++;
+ }
+ }
+ //ost_complete_brw(rep);
+
+ out:
+ if (request->rq_rephdr)
+ kfree(request->rq_rephdr);
+ n = 0;
+ for (i=0; i < num_oa; i++) {
+ for (j = 0 ; j < oa_bufs[i] ; j++) {
+ kunmap(buf[n]);
+ n++;
+ }
+ }
+
+ osc_free_req(request);
+ return 0;
+
+
+
+}
+
static int osc_cleanup(struct obd_device * obddev)
{
#include <linux/obd_class.h>
// for testing
-static int ost_queue_req(struct obd_device *obddev, struct ost_request *req)
+static int ost_queue_req(struct obd_device *obddev, struct ptlrpc_request *req)
{
- struct ost_request *srv_req;
+ struct ptlrpc_request *srv_req;
struct ost_obd *ost = &obddev->u.ost;
if (!ost) {
/* move the request buffer */
srv_req->rq_reqbuf = req->rq_reqbuf;
srv_req->rq_reqlen = req->rq_reqlen;
- srv_req->rq_obd = ost;
+ srv_req->rq_ost = ost;
/* remember where it came from */
srv_req->rq_reply_handle = req;
/* XXX replace with networking code */
-int ost_reply(struct obd_device *obddev, struct ost_request *req)
+int ost_reply(struct obd_device *obddev, struct ptlrpc_request *req)
{
- struct ost_request *clnt_req = req->rq_reply_handle;
+ struct ptlrpc_request *clnt_req = req->rq_reply_handle;
ENTRY;
printk("ost_reply: req %p clnt_req at %p\n", req, clnt_req);
return 0;
}
-int ost_error(struct obd_device *obddev, struct ost_request *req)
+int ost_error(struct obd_device *obddev, struct ptlrpc_request *req)
{
- struct ost_rep_hdr *hdr;
+ struct ptlrep_hdr *hdr;
ENTRY;
hdr = kmalloc(sizeof(*hdr), GFP_KERNEL);
return ost_reply(obddev, req);
}
-static int ost_destroy(struct ost_obd *ost, struct ost_request *req)
+static int ost_destroy(struct ost_obd *ost, struct ptlrpc_request *req)
{
struct obd_conn conn;
int rc;
ENTRY;
- conn.oc_id = req->rq_req->connid;
+ conn.oc_id = req->rq_req.ost->connid;
conn.oc_dev = ost->ost_tgt;
- rc = ost_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep,
+ rc = ost_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep.ost,
&req->rq_replen, &req->rq_repbuf);
if (rc) {
printk("ost_destroy: cannot pack reply\n");
return rc;
}
- req->rq_rep->result =ost->ost_tgt->obd_type->typ_ops->o_destroy
- (&conn, &req->rq_req->oa);
+ req->rq_rep.ost->result =ost->ost_tgt->obd_type->typ_ops->o_destroy
+ (&conn, &req->rq_req.ost->oa);
EXIT;
return 0;
}
-static int ost_getattr(struct ost_obd *ost, struct ost_request *req)
+static int ost_getattr(struct ost_obd *ost, struct ptlrpc_request *req)
{
struct obd_conn conn;
int rc;
ENTRY;
printk("ost getattr entered\n");
- conn.oc_id = req->rq_req->connid;
+ conn.oc_id = req->rq_req.ost->connid;
conn.oc_dev = ost->ost_tgt;
- rc = ost_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep,
+ rc = ost_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep.ost,
&req->rq_replen, &req->rq_repbuf);
if (rc) {
printk("ost_getattr: cannot pack reply\n");
return rc;
}
- req->rq_rep->oa.o_id = req->rq_req->oa.o_id;
- req->rq_rep->oa.o_valid = req->rq_req->oa.o_valid;
+ req->rq_rep.ost->oa.o_id = req->rq_req.ost->oa.o_id;
+ req->rq_rep.ost->oa.o_valid = req->rq_req.ost->oa.o_valid;
- req->rq_rep->result =ost->ost_tgt->obd_type->typ_ops->o_getattr
- (&conn, &req->rq_rep->oa);
+ req->rq_rep.ost->result =ost->ost_tgt->obd_type->typ_ops->o_getattr
+ (&conn, &req->rq_rep.ost->oa);
EXIT;
return 0;
}
-static int ost_create(struct ost_obd *ost, struct ost_request *req)
+static int ost_create(struct ost_obd *ost, struct ptlrpc_request *req)
{
struct obd_conn conn;
int rc;
ENTRY;
- conn.oc_id = req->rq_req->connid;
+ conn.oc_id = req->rq_req.ost->connid;
conn.oc_dev = ost->ost_tgt;
- rc = ost_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep,
+ rc = ost_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep.ost,
&req->rq_replen, &req->rq_repbuf);
if (rc) {
printk("ost_create: cannot pack reply\n");
return rc;
}
- memcpy(&req->rq_rep->oa, &req->rq_req->oa, sizeof(req->rq_req->oa));
+ memcpy(&req->rq_rep.ost->oa, &req->rq_req.ost->oa, sizeof(req->rq_req.ost->oa));
- req->rq_rep->result =ost->ost_tgt->obd_type->typ_ops->o_create
- (&conn, &req->rq_rep->oa);
+ req->rq_rep.ost->result =ost->ost_tgt->obd_type->typ_ops->o_create
+ (&conn, &req->rq_rep.ost->oa);
EXIT;
return 0;
}
-static int ost_setattr(struct ost_obd *ost, struct ost_request *req)
+static int ost_setattr(struct ost_obd *ost, struct ptlrpc_request *req)
{
struct obd_conn conn;
int rc;
ENTRY;
- conn.oc_id = req->rq_req->connid;
+ conn.oc_id = req->rq_req.ost->connid;
conn.oc_dev = ost->ost_tgt;
- rc = ost_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep,
+ rc = ost_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep.ost,
&req->rq_replen, &req->rq_repbuf);
if (rc) {
printk("ost_setattr: cannot pack reply\n");
return rc;
}
- memcpy(&req->rq_rep->oa, &req->rq_req->oa, sizeof(req->rq_req->oa));
+ memcpy(&req->rq_rep.ost->oa, &req->rq_req.ost->oa, sizeof(req->rq_req.ost->oa));
- req->rq_rep->result =ost->ost_tgt->obd_type->typ_ops->o_setattr
- (&conn, &req->rq_rep->oa);
+ req->rq_rep.ost->result =ost->ost_tgt->obd_type->typ_ops->o_setattr
+ (&conn, &req->rq_rep.ost->oa);
EXIT;
return 0;
}
-static int ost_connect(struct ost_obd *ost, struct ost_request *req)
+static int ost_connect(struct ost_obd *ost, struct ptlrpc_request *req)
{
struct obd_conn conn;
int rc;
conn.oc_dev = ost->ost_tgt;
- rc = ost_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep,
+ rc = ost_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep.ost,
&req->rq_replen, &req->rq_repbuf);
if (rc) {
printk("ost_setattr: cannot pack reply\n");
return rc;
}
- req->rq_rep->result =ost->ost_tgt->obd_type->typ_ops->o_connect(&conn);
+ req->rq_rep.ost->result =ost->ost_tgt->obd_type->typ_ops->o_connect(&conn);
printk("ost_connect: rep buffer %p, id %d\n", req->rq_repbuf,
conn.oc_id);
- req->rq_rep->connid = conn.oc_id;
+ req->rq_rep.ost->connid = conn.oc_id;
EXIT;
return 0;
}
-static int ost_disconnect(struct ost_obd *ost, struct ost_request *req)
+static int ost_disconnect(struct ost_obd *ost, struct ptlrpc_request *req)
{
struct obd_conn conn;
int rc;
ENTRY;
conn.oc_dev = ost->ost_tgt;
- conn.oc_id = req->rq_req->connid;
+ conn.oc_id = req->rq_req.ost->connid;
- rc = ost_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep,
+ rc = ost_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep.ost,
&req->rq_replen, &req->rq_repbuf);
if (rc) {
printk("ost_setattr: cannot pack reply\n");
return rc;
}
- req->rq_rep->result =ost->ost_tgt->obd_type->typ_ops->o_disconnect(&conn);
+ req->rq_rep.ost->result =ost->ost_tgt->obd_type->typ_ops->o_disconnect(&conn);
EXIT;
return 0;
}
-static int ost_get_info(struct ost_obd *ost, struct ost_request *req)
+static int ost_get_info(struct ost_obd *ost, struct ptlrpc_request *req)
{
struct obd_conn conn;
int rc;
int vallen;
void *val;
+ char *ptr;
ENTRY;
- conn.oc_id = req->rq_req->connid;
+ conn.oc_id = req->rq_req.ost->connid;
conn.oc_dev = ost->ost_tgt;
- req->rq_rep->result =ost->ost_tgt->obd_type->typ_ops->o_get_info
- (&conn, req->rq_req->buflen1, req->rq_req->buf1, &vallen, &val);
-
+ ptr = ost_req_buf1(req->rq_req.ost);
+ req->rq_rep.ost->result =ost->ost_tgt->obd_type->typ_ops->o_get_info
+ (&conn, req->rq_req.ost->buflen1, ptr, &vallen, &val);
- rc = ost_pack_rep(val, vallen, NULL, 0, &req->rq_rephdr, &req->rq_rep,
+ rc = ost_pack_rep(val, vallen, NULL, 0, &req->rq_rephdr, &req->rq_rep.ost,
&req->rq_replen, &req->rq_repbuf);
if (rc) {
printk("ost_setattr: cannot pack reply\n");
}
+static struct page * ext2_get_page(struct inode *dir, unsigned long n)
+{
+ struct address_space *mapping = dir->i_mapping;
+ struct page *page = read_cache_page(mapping, n,
+ (filler_t*)mapping->a_ops->readpage, NULL);
+ if (!IS_ERR(page)) {
+ wait_on_page(page);
+ kmap(page);
+ if (!Page_Uptodate(page))
+ goto fail;
+ if (!PageChecked(page))
+ ext2_check_page(page);
+ if (PageError(page))
+ goto fail;
+ }
+ return page;
+
+fail:
+ ext2_put_page(page);
+ return ERR_PTR(-EIO);
+}
+
+#if 0
+
+static inline void ext2_put_page(struct page *page)
+{
+ kunmap(page);
+ page_cache_release(page);
+}
+
+/* Releases the page */
+void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de,
+ struct page *page, struct inode *inode)
+{
+ unsigned from = (char *) de - (char *) page_address(page);
+ unsigned to = from + le16_to_cpu(de->rec_len);
+ int err;
+
+ lock_page(page);
+ err = page->mapping->a_ops->prepare_write(NULL, page, from, to);
+ if (err)
+ BUG();
+ de->inode = cpu_to_le32(inode->i_ino);
+ ext2_set_de_type (de, inode);
+ dir->i_mtime = dir->i_ctime = CURRENT_TIME;
+ err = ext2_commit_chunk(page, from, to);
+ UnlockPage(page);
+ ext2_put_page(page);
+}
-//int ost_handle(struct ost_conn *conn, int len, char *buf)
-int ost_handle(struct obd_device *obddev, struct ost_request *req)
+static int ext2_commit_chunk(struct page *page, unsigned from, unsigned to)
+{
+ struct inode *dir = page->mapping->host;
+ int err = 0;
+ dir->i_version = ++event;
+ SetPageUptodate(page);
+ set_page_clean(page);
+
+ //page->mapping->a_ops->commit_write(NULL, page, from, to);
+ //if (IS_SYNC(dir))
+ // err = waitfor_one_page(page);
+ return err;
+}
+
+#endif
+
+int ost_prepw(struct ost_obd *obddev, struct ptlrpc_request *req)
+{
+#if 0
+ struct obd_conn conn;
+ int rc;
+ int i, j, n;
+ int objcount;
+ void *tmp;
+ struct niobuf **nb;
+ struct obd_ioo **ioo;
+
+ ENTRY;
+
+ tmp1 = ost_req_buf1(req);
+ tmp2 = ost_req_buf2(req);
+ objcount = req->buflen1 / sizeof(**ioo);
+
+ n = 0;
+ for (i=0 ; i<objcount ; i++) {
+ obd_unpack_ioo
+
+ conn.oc_id = req->rq_req.ost->connid;
+ conn.oc_dev = ost->ost_tgt;
+
+ rc = ost_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep,
+ &req->rq_replen, &req->rq_repbuf);
+ if (rc) {
+ printk("ost_create: cannot pack reply\n");
+ return rc;
+ }
+
+ memcpy(&req->rq_rep.ost->oa, &req->rq_req.ost->oa, sizeof(req->rq_req.ost->oa));
+
+ req->rq_rep.ost->result =ost->ost_tgt->obd_type->typ_ops->o_create
+ (&conn, &req->rq_rep.ost->oa);
+
+ EXIT;
+ return 0;
+#endif
+ return -ENOTSUPP;
+
+}
+
+
+int ost_handle(struct obd_device *obddev, struct ptlrpc_request *req)
{
int rc;
struct ost_obd *ost = &obddev->u.ost;
- struct ost_req_hdr *hdr;
+ struct ptlreq_hdr *hdr;
ENTRY;
printk("ost_handle: req at %p\n", req);
- hdr = (struct ost_req_hdr *)req->rq_reqbuf;
+ hdr = (struct ptlreq_hdr *)req->rq_reqbuf;
if (NTOH__u32(hdr->type) != OST_TYPE_REQ) {
printk("lustre_ost: wrong packet type sent %d\n",
NTOH__u32(hdr->type));
}
rc = ost_unpack_req(req->rq_reqbuf, req->rq_reqlen,
- &req->rq_reqhdr, &req->rq_req);
+ &req->rq_reqhdr, &req->rq_req.ost);
if (rc) {
printk("lustre_ost: Invalid request\n");
EXIT;
CDEBUG(D_INODE, "setattr\n");
rc = ost_setattr(ost, req);
break;
-
+ case OST_PREPW:
+ CDEBUG(D_INODE, "prepw\n");
+ rc = ost_prepw(ost, req);
+ break;
default:
+ req->rq_status = -ENOTSUPP;
return ost_error(obddev, req);
}
out:
- req->rq_rephdr->status = rc;
+ req->rq_status = rc;
if (rc) {
printk("ost: processing error %d\n", rc);
ost_error(obddev, req);
/* And now, wait forever for commit wakeup events. */
while (1) {
- struct ost_request *request;
+ struct ptlrpc_request *request;
int rc;
if (ost->ost_flags & OST_EXIT)
} else {
printk("---> %d\n", __LINE__);
request = list_entry(ost->ost_reqs.next,
- struct ost_request, rq_list);
+ struct ptlrpc_request, rq_list);
printk("---> %d\n", __LINE__);
list_del(&request->rq_list);
rc = ost_handle(obddev, request);
R=/r
insmod /lib/modules/2.4.17/kernel/drivers/block/loop.o
+insmod $R/usr/src/portals/linux/oslib/portals.o
+insmod $R/usr/src/portals/linux/socknal/ksocknal.o
+insmod $R/usr/src/obd/rpc/ptlrpc.o
insmod $R/usr/src/obd/class/obdclass.o
insmod $R/usr/src/obd/ext2obd/obdext2.o
insmod $R/usr/src/obd/ost/ost.o