struct list_head ll_list; /* list of supers */
struct obd_conn ll_conn;
struct super_block *ll_super;
- // struct obd_device *ll_obd;
- //struct obd_ops *ll_ops;
- ino_t ll_rootino; /* number of root inode */
- int ll_minor; /* minor of /dev/obdX */
+ ino_t ll_rootino; /* number of root inode */
+ int ll_minor; /* minor of /dev/obdX */
struct list_head ll_inodes; /* list of dirty inodes */
- unsigned long ll_cache_count;
+ unsigned long ll_cache_count;
struct semaphore ll_list_mutex;
- struct lustre_peer ll_peer;
- struct lustre_peer *ll_peer_ptr;
+ struct ptlrpc_client ll_mds_client;
+ struct ptlrpc_client ll_ost_client;
};
+static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
+{
+ return (struct ll_sb_info *) (inode->i_sb->u.generic_sbp);
+}
+
static inline struct ll_inode_info *ll_i2info(struct inode *inode)
{
return (struct ll_inode_info *)&(inode->u.generic_ip);
}
+static inline struct obd_conn *ll_i2obdconn(struct inode *inode)
+{
+ return &(ll_i2sbi(inode))->ll_conn;
+}
void ll_sysctl_init(void);
void ll_sysctl_clean(void);
-static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
-{
- return (struct ll_sb_info *) &(inode->i_sb->u.generic_sbp);
-}
static inline struct list_head *ll_slist(struct inode *inode)
/* 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 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);
+int mds_pack_req(char *name, int namelen, char *tgt, int tgtlen, struct ptlreq_hdr **hdr, union ptl_req *req, int *len, char **buf);
+int mds_unpack_req(char *buf, int len, struct ptlreq_hdr **hdr, union ptl_req *);
+int mds_pack_rep(char *name, int namelen, char *tgt, int tgtlen, struct ptlrep_hdr **hdr, union ptl_rep *rep, int *len, char **buf);
+int mds_unpack_rep(char *buf, int len, struct ptlrep_hdr **hdr, union ptl_rep *rep);
/* mds/mds_reint.c */
int mds_reint_rec(struct mds_update_record *r, struct ptlrpc_request *req);
struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid, struct vfsmount **mnt);
/* llight/request.c */
-int mdc_getattr(struct lustre_peer *peer, ino_t ino, int type, int valid,
+int mdc_getattr(struct ptlrpc_client *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,
+int mdc_setattr(struct ptlrpc_client *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,
+int mdc_readpage(struct ptlrpc_client *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,
+int mdc_create(struct ptlrpc_client *peer,
struct inode *dir, const char *name, int namelen,
const char *tgt, int tgtlen,
int mode, __u64 id, __u32 uid, __u32 gid, __u64 time,
struct mds_rep **rep, struct ptlrep_hdr **hdr);
-int mdc_unlink(struct lustre_peer *peer,
+int mdc_unlink(struct ptlrpc_client *peer,
struct inode *dir, const char *name, int namelen,
struct mds_rep **rep, struct ptlrep_hdr **hdr);
-int mdc_link(struct lustre_peer *peer, struct dentry *src,
+int mdc_link(struct ptlrpc_client *peer, struct dentry *src,
struct inode *dir, const char *name, int namelen,
struct mds_rep **rep, struct ptlrep_hdr **hdr);
-int mdc_rename(struct lustre_peer *peer, struct inode *src,
+int mdc_rename(struct ptlrpc_client *peer, struct inode *src,
struct inode *tgt, const char *old, int oldlen,
const char *new, int newlen,
struct mds_rep **rep, struct ptlrep_hdr **hdr);
+int mdc_create_client(char *uuid, struct ptlrpc_client *cl);
/* ioctls for trying requests */
#define IOC_REQUEST_TYPE 'f'
ptl_md_t srv_md[RPC_RING_LENGTH];
ptl_handle_md_t srv_md_h[RPC_RING_LENGTH];
wait_queue_head_t *srv_wait_queue;
+ int (*srv_req_unpack)(char *buf, int len, struct ptlreq_hdr **,
+ union ptl_req *);
+ int (*srv_rep_pack)(char *buf1, int len1, char *buf2, int len2,
+ struct ptlrep_hdr **, union ptl_rep*,
+ int *replen, char **repbuf);
};
+
struct ptlrpc_request {
struct list_head rq_list;
struct mds_obd *rq_obd;
struct lustre_peer rq_peer;
};
+struct ptlrpc_client {
+ struct lustre_peer cli_server;
+ __u32 cli_request_portal;
+ __u32 cli_reply_portal;
+ __u32 cli_xid;
+ int (*cli_rep_unpack)(char *buf, int len, struct ptlrep_hdr **,
+ union ptl_rep *);
+ int (*cli_req_pack)(char *buf1, int len1, char *buf2, int len2,
+ struct ptlreq_hdr **, union ptl_req*,
+ int *reqlen, char **reqbuf);
+ int (*cli_enqueue)(struct ptlrpc_request *req);
+};
+
+
+
/* rpc/rpc.c */
int ptl_send_buf(struct ptlrpc_request *request, struct lustre_peer *peer,
int portal, int is_request);
int ptl_received_rpc(struct ptlrpc_service *service);
int rpc_register_service(struct ptlrpc_service *service, char *uuid);
int rpc_unregister_service(struct ptlrpc_service *service);
+int ptlrpc_queue_wait(struct ptlrpc_request *req,
+ struct ptlrpc_client *cl);
+struct ptlrpc_request *ptlrpc_prep_req(struct ptlrpc_client *cl,
+ int opcode, int namelen, char *name,
+ int tgtlen, char *tgt);
+void ptlrpc_free_req(struct ptlrpc_request *request);
+
/* FIXME */
#if 1
#include <linux/lustre_mds.h>
int mds_pack_req(char *name, int namelen, char *tgt, int tgtlen,
- struct ptlreq_hdr **hdr, struct mds_req **req,
+ struct ptlreq_hdr **hdr, union ptl_req *r,
int *len, char **buf)
{
+ struct mds_req *req;
char *ptr;
*len = sizeof(**hdr) + size_round(namelen) + size_round(tgtlen) +
- sizeof(**req);
+ sizeof(*req);
OBD_ALLOC(*buf, *len);
if (!*buf) {
memset(*buf, 0, *len);
*hdr = (struct ptlreq_hdr *)(*buf);
- *req = (struct mds_req *)(*buf + sizeof(**hdr));
- ptr = *buf + sizeof(**hdr) + sizeof(**req);
+ req = (struct mds_req *)(*buf + sizeof(**hdr));
+ r->mds = req;
+
+ ptr = *buf + sizeof(**hdr) + sizeof(*req);
(*hdr)->type = MDS_TYPE_REQ;
- (*req)->namelen = NTOH__u32(namelen);
+ req->namelen = NTOH__u32(namelen);
if (name) {
LOGL(name, namelen, ptr);
}
- (*req)->tgtlen = NTOH__u32(tgtlen);
+ req->tgtlen = NTOH__u32(tgtlen);
if (tgt) {
LOGL(tgt, tgtlen, ptr);
}
int mds_unpack_req(char *buf, int len,
- struct ptlreq_hdr **hdr, struct mds_req **req)
+ struct ptlreq_hdr **hdr, union ptl_req *r)
{
+ struct mds_req *req;
char *name, *tgt;
- if (len < sizeof(**hdr) + sizeof(**req)) {
+ if (len < sizeof(**hdr) + sizeof(*req)) {
EXIT;
return -EINVAL;
}
*hdr = (struct ptlreq_hdr *) (buf);
- *req = (struct mds_req *) (buf + sizeof(**hdr));
+ req = (struct mds_req *) (buf + sizeof(**hdr));
+ r->mds = req;
- (*req)->namelen = NTOH__u32((*req)->namelen);
- (*req)->tgtlen = NTOH__u32((*req)->tgtlen);
+ req->namelen = NTOH__u32(req->namelen);
+ req->tgtlen = NTOH__u32(req->tgtlen);
- if (len < sizeof(**hdr) + sizeof(**req) +
- size_round((*req)->namelen) + size_round((*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(**req);
+ if (req->namelen) {
+ name = buf + sizeof(**hdr) + sizeof(*req);
} else {
name = NULL;
}
- if ((*req)->tgtlen) {
- tgt = buf + sizeof(**hdr) + sizeof(**req) +
- size_round((*req)->namelen);
+ if (req->tgtlen) {
+ tgt = buf + sizeof(**hdr) + sizeof(*req) +
+ size_round(req->namelen);
} else {
tgt = NULL;
}
}
int mds_pack_rep(char *name, int namelen, char *tgt, int tgtlen,
- struct ptlrep_hdr **hdr, struct mds_rep **rep,
+ struct ptlrep_hdr **hdr, union ptl_rep *r,
int *len, char **buf)
{
+ struct mds_rep *rep;
char *ptr;
*len = sizeof(**hdr) + size_round(namelen) + size_round(tgtlen) +
- sizeof(**rep);
+ sizeof(*rep);
OBD_ALLOC(*buf, *len);
if (!*buf) {
memset(*buf, 0, *len);
*hdr = (struct ptlrep_hdr *)(*buf);
- *rep = (struct mds_rep *)(*buf + sizeof(**hdr));
+ rep = (struct mds_rep *)(*buf + sizeof(**hdr));
+ r->mds = rep;
- ptr = *buf + sizeof(**hdr) + sizeof(**rep);
+ ptr = *buf + sizeof(**hdr) + sizeof(*rep);
(*hdr)->type = MDS_TYPE_REP;
- (*rep)->namelen = NTOH__u32(namelen);
+ rep->namelen = NTOH__u32(namelen);
if (name) {
LOGL(name, namelen, ptr);
}
- (*rep)->tgtlen = NTOH__u32(tgtlen);
+ rep->tgtlen = NTOH__u32(tgtlen);
if (tgt) {
LOGL(tgt, tgtlen, ptr);
}
}
int mds_unpack_rep(char *buf, int len,
- struct ptlrep_hdr **hdr, struct mds_rep **rep)
+ struct ptlrep_hdr **hdr, union ptl_rep *r)
{
-
+ struct mds_rep *rep;
if (len < sizeof(**hdr)) {
EXIT;
return -EINVAL;
}
*hdr = (struct ptlrep_hdr *) (buf);
- if (len < sizeof(**hdr) + sizeof(**rep)) {
+ if (len < sizeof(**hdr) + sizeof(*rep)) {
EXIT;
return -EINVAL;
}
- *rep = (struct mds_rep *) (buf + sizeof(**hdr));
- (*rep)->namelen = NTOH__u32((*rep)->namelen);
- (*rep)->tgtlen = NTOH__u32((*rep)->namelen);
+ rep = (struct mds_rep *) (buf + sizeof(**hdr));
+ r->mds = rep;
+ rep->namelen = NTOH__u32(rep->namelen);
+ rep->tgtlen = NTOH__u32(rep->namelen);
- if (len < sizeof(**hdr) + sizeof(**rep)
- + size_round((*rep)->namelen) + size_round((*rep)->tgtlen) ) {
+ if (len < sizeof(**hdr) + sizeof(*rep)
+ + size_round(rep->namelen) + size_round(rep->tgtlen) ) {
EXIT;
return -EINVAL;
}
offset = page->index << PAGE_SHIFT;
buf = kmap(page);
- rc = mdc_readpage(sbi->ll_peer_ptr, inode->i_ino, S_IFDIR, offset, buf,
- NULL, &hdr);
+ rc = mdc_readpage(&sbi->ll_mds_client, inode->i_ino, S_IFDIR, offset,
+ buf, NULL, &hdr);
kunmap(page);
if ( rc ) {
EXIT;
if ((dir->i_size >> PAGE_CACHE_SHIFT) == page->index) {
limit = dir->i_size & ~PAGE_CACHE_MASK;
- if (limit & (chunk_size - 1))
+ if (limit & (chunk_size - 1)) {
+ CERROR("limit %d dir size %lld index %ld\n",
+ limit, dir->i_size, page->index);
goto Ebadsize;
+ }
for (offs = limit; offs<PAGE_CACHE_SIZE; offs += chunk_size) {
ext2_dirent *p = (ext2_dirent*)(kaddr + offs);
p->rec_len = cpu_to_le16(chunk_size);
Ebadsize:
CERROR("ext2_check_page"
- "size of directory #%lu is not a multiple of chunk size",
+ "size of directory #%lu is not a multiple of chunk size\n",
dir->i_ino
);
goto fail;
if (!ino)
goto negative;
- err = mdc_getattr(sbi->ll_peer_ptr, ino, type,
+ err = mdc_getattr(&sbi->ll_mds_client, ino, type,
OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, &rep, &hdr);
if ( err ) {
CERROR("obdo_fromid failed\n");
ENTRY;
- err = mdc_create(sbi->ll_peer_ptr, dir, name, namelen, tgt, tgtlen,
+ err = mdc_create(&sbi->ll_mds_client, dir, name, namelen, tgt, tgtlen,
mode, id,
current->uid, current->gid, time, &rep, &hdr);
if (err) {
ENTRY;
- err = mdc_unlink(sbi->ll_peer_ptr, dir, name, len, &rep, &hdr);
+ err = mdc_unlink(&sbi->ll_mds_client, dir, name, len, &rep, &hdr);
if (err) {
EXIT;
ENTRY;
- err = mdc_link(sbi->ll_peer_ptr, src, dir, name, len, &rep, &hdr);
+ err = mdc_link(&sbi->ll_mds_client, src, dir, name, len, &rep, &hdr);
if (err) {
EXIT;
ENTRY;
- err = mdc_rename(sbi->ll_peer_ptr, src, tgt,
+ err = mdc_rename(&sbi->ll_mds_client, src, tgt,
old->d_name.name, old->d_name.len,
new->d_name.name, new->d_name.len,
&rep, &hdr);
memset(&oa, 0, sizeof(oa));
oa.o_valid = OBD_MD_FLMODE;
oa.o_mode = S_IFREG | 0600;
- err = obd_create(IID(dir), &oa);
+ err = obd_create(ll_i2obdconn(dir), &oa);
if (err) {
EXIT;
return err;
if (!oa) {
return -ENOMEM;
}
- err = obd_brw(rw, IID(inode), num_obdo, &oa, &bufs_per_obdo,
+ err = obd_brw(rw, ll_i2obdconn(inode), num_obdo, &oa, &bufs_per_obdo,
&page, &count, &offset, &flags);
obdo_free(oa);
CDEBUG(D_INODE, "commit_page writing (at %d) to %d, count %Ld\n",
from, to, count);
- err = obd_brw(OBD_BRW_WRITE, IID(inode), num_obdo, &oa, &bufs_per_obdo,
+ err = obd_brw(OBD_BRW_WRITE, ll_i2obdconn(inode), num_obdo, &oa, &bufs_per_obdo,
&page, &count, &offset, &flags);
if ( !err ) {
SetPageUptodate(page);
CDEBUG(D_INFO, "calling punch for %ld (%Lu bytes at 0)\n",
(long)oa->o_id, oa->o_size);
- err = obd_punch(IID(inode), oa, oa->o_size, 0);
+ err = obd_punch(ll_i2obdconn(inode), oa, oa->o_size, 0);
obdo_free(oa);
if (err) {
void *data, int silent)
{
struct inode *root = 0;
- struct ll_sb_info *sbi = (struct ll_sb_info *)(&sb->u.generic_sbp);
+ struct ll_sb_info *sbi;
char *device = NULL;
char *version = NULL;
int connected = 0;
ENTRY;
MOD_INC_USE_COUNT;
+ OBD_ALLOC(sbi, sizeof(*sbi));
+ if (!sbi) {
+ EXIT;
+ return NULL;
+ }
memset(sbi, 0, sizeof(*sbi));
+ sb->u.generic_sbp = (struct ll_sb_info *) sbi;
ll_options(data, &device, &version);
}
connected = 1;
- err = kportal_uuid_to_peer("mds", &sbi->ll_peer);
- if (err == 0)
- sbi->ll_peer_ptr = &sbi->ll_peer;
-
+ err = mdc_create_client("mds", &sbi->ll_mds_client);
+ if (err) {
+ CERROR("cannot find MDS\n");
+ sb = NULL;
+ goto ERR;
+ }
sbi->ll_super = sb;
sbi->ll_rootino = 2;
sb->s_op = &ll_super_operations;
/* make root inode */
- err = mdc_getattr(sbi->ll_peer_ptr, sbi->ll_rootino, S_IFDIR,
+ err = mdc_getattr(&sbi->ll_mds_client, sbi->ll_rootino, S_IFDIR,
OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS,
&rep, &hdr);
if (err) {
ENTRY;
obd_disconnect(ID(sb));
-
+ OBD_FREE(sb->u.generic_sbp, sizeof(struct ll_sb_info));
MOD_DEC_USE_COUNT;
EXIT;
} /* ll_put_super */
/* change incore inode */
ll_attr2inode(inode, attr, do_trunc);
- err = mdc_setattr(sbi->ll_peer_ptr, inode, attr, NULL, &hdr);
+ err = mdc_setattr(&sbi->ll_mds_client, inode, attr, NULL, &hdr);
if ( err )
CERROR("ll_setattr fails (%d)\n", err);
#include <linux/lustre_idl.h>
#include <linux/lustre_mds.h>
-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);
+extern int mdc_reint(struct ptlrpc_client *peer, struct ptlrpc_request *request);
-int mdc_setattr(struct lustre_peer *peer,
+int mdc_setattr(struct ptlrpc_client *peer,
struct inode *inode, struct iattr *iattr,
struct mds_rep **rep, struct ptlrep_hdr **hdr)
{
struct ptlrpc_request *request;
struct mds_rec_setattr *rec;
- request = mds_prep_req(MDS_REINT, 0, NULL, sizeof(*rec), NULL);
+ request = ptlrpc_prep_req(peer, MDS_REINT, 0, NULL, sizeof(*rec), NULL);
if (!request) {
CERROR("mdc request: cannot pack\n");
return -ENOMEM;
return 0;
}
-int mdc_create(struct lustre_peer *peer,
+int mdc_create(struct ptlrpc_client *peer,
struct inode *dir, const char *name, int namelen,
const char *tgt, int tgtlen,
int mode, __u64 id, __u32 uid, __u32 gid, __u64 time,
struct ptlrpc_request *request;
struct mds_rec_create *rec;
- request = mds_prep_req(MDS_REINT, 0, NULL,
+ request = ptlrpc_prep_req(peer, MDS_REINT, 0, NULL,
sizeof(*rec) + size_round0(namelen) +
size_round0(tgtlen), NULL);
if (!request) {
return rc;
}
-int mdc_unlink(struct lustre_peer *peer,
+int mdc_unlink(struct ptlrpc_client *peer,
struct inode *dir, const char *name, int namelen,
struct mds_rep **rep, struct ptlrep_hdr **hdr)
{
struct ptlrpc_request *request;
struct mds_rec_unlink *rec;
- request = mds_prep_req(MDS_REINT, 0, NULL,
+ request = ptlrpc_prep_req(peer, MDS_REINT, 0, NULL,
sizeof(*rec) + size_round0(namelen), NULL);
if (!request) {
CERROR("mdc_unlink: cannot pack\n");
return rc;
}
-int mdc_link(struct lustre_peer *peer, struct dentry *src,
+int mdc_link(struct ptlrpc_client *peer, struct dentry *src,
struct inode *dir, const char *name, int namelen,
struct mds_rep **rep, struct ptlrep_hdr **hdr)
{
struct ptlrpc_request *request;
struct mds_rec_link *rec;
- request = mds_prep_req(MDS_REINT, 0, NULL,
+ request = ptlrpc_prep_req(peer, MDS_REINT, 0, NULL,
sizeof(*rec) + size_round0(namelen), NULL);
if (!request) {
CERROR("mdc_link: cannot pack\n");
return rc;
}
-int mdc_rename(struct lustre_peer *peer, struct inode *src,
+int mdc_rename(struct ptlrpc_client *peer, struct inode *src,
struct inode *tgt, const char *old, int oldlen,
const char *new, int newlen,
struct mds_rep **rep, struct ptlrep_hdr **hdr)
struct ptlrpc_request *request;
struct mds_rec_rename *rec;
- request = mds_prep_req(MDS_REINT, 0, NULL,
+ request = ptlrpc_prep_req(peer, MDS_REINT, 0, NULL,
sizeof(*rec) + size_round0(oldlen)
+ size_round0(newlen), NULL);
if (!request) {
extern int mds_queue_req(struct ptlrpc_request *);
-/* FIXME: this belongs in some sort of service struct */
-static int mdc_xid = 0;
-struct ptlrpc_request *mds_prep_req(int opcode, int namelen, char *name,
- int tgtlen, char *tgt)
-{
- struct ptlrpc_request *request;
- int rc;
- ENTRY;
-
- OBD_ALLOC(request, sizeof(*request));
- if (!request) {
- CERROR("request allocation out of memory\n");
- return NULL;
- }
-
- memset(request, 0, sizeof(*request));
- request->rq_xid = mdc_xid++;
-
- rc = mds_pack_req(name, namelen, tgt, tgtlen,
- &request->rq_reqhdr, &(request->rq_req.mds),
- &request->rq_reqlen, &request->rq_reqbuf);
- if (rc) {
- CERROR("llight request: cannot pack request %d\n", rc);
- return NULL;
- }
- CDEBUG(0, "--> len %d, req %p, tgtlen %d\n",
- request->rq_reqlen, request->rq_req.mds,
- request->rq_req.mds->tgtlen);
- request->rq_reqhdr->opc = opcode;
-
- EXIT;
- return request;
-}
-
-static int mds_queue_wait(struct ptlrpc_request *req, struct lustre_peer *peer)
-{
- int rc;
- DECLARE_WAITQUEUE(wait, current);
-
- init_waitqueue_head(&req->rq_wait_for_rep);
-
- /* XXX fix the race here (wait_for_event?)*/
- if (peer == NULL) {
- /* Local delivery */
- ENTRY;
- rc = mds_queue_req(req);
- } else {
- /* Remote delivery via portals. */
- req->rq_req_portal = MDS_REQUEST_PORTAL;
- req->rq_reply_portal = MDS_REPLY_PORTAL;
- rc = ptl_send_rpc(req, peer);
- }
- if (rc) {
- CERROR("error %d, opcode %d\n", rc,
- req->rq_reqhdr->opc);
- return -rc;
- }
-
- CDEBUG(0, "-- sleeping\n");
- add_wait_queue(&req->rq_wait_for_rep, &wait);
- while (req->rq_repbuf == NULL) {
- set_current_state(TASK_INTERRUPTIBLE);
-
- /* if this process really wants to die, let it go */
- if (sigismember(&(current->pending.signal), SIGKILL) ||
- sigismember(&(current->pending.signal), SIGINT))
- break;
-
- schedule();
- }
- remove_wait_queue(&req->rq_wait_for_rep, &wait);
- set_current_state(TASK_RUNNING);
- CDEBUG(0, "-- done\n");
-
- if (req->rq_repbuf == NULL) {
- /* We broke out because of a signal */
- EXIT;
- return -EINTR;
- }
-
- rc = mds_unpack_rep(req->rq_repbuf, req->rq_replen, &req->rq_rephdr,
- &req->rq_rep.mds);
- if (rc) {
- CERROR("mds_unpack_rep failed: %d\n", rc);
- return rc;
- }
-
- if ( req->rq_rephdr->status == 0 )
- CDEBUG(0, "--> buf %p len %d status %d\n",
- req->rq_repbuf, req->rq_replen,
- req->rq_rephdr->status);
-
- EXIT;
- return 0;
-}
-
-void mdc_free_req(struct ptlrpc_request *request)
-{
- OBD_FREE(request, sizeof(*request));
-}
-
-int mdc_getattr(struct lustre_peer *peer, ino_t ino, int type, int valid,
+int mdc_getattr(struct ptlrpc_client *peer, ino_t ino, int type, int valid,
struct mds_rep **rep, struct ptlrep_hdr **hdr)
{
struct ptlrpc_request *request;
int rc;
- request = mds_prep_req(MDS_GETATTR, 0, NULL, 0, NULL);
+ request = ptlrpc_prep_req(peer, MDS_GETATTR, 0, NULL, 0, NULL);
if (!request) {
CERROR("llight request: cannot pack\n");
return -ENOMEM;
request->rq_replen =
sizeof(struct ptlrep_hdr) + sizeof(struct mds_rep);
- rc = mds_queue_wait(request, peer);
+ rc = ptlrpc_queue_wait(request, peer);
if (rc) {
CERROR("llight request: error in handling %d\n", rc);
goto out;
}
out:
- mdc_free_req(request);
+ ptlrpc_free_req(request);
return rc;
}
-int mdc_readpage(struct lustre_peer *peer, ino_t ino, int type, __u64 offset,
+int mdc_readpage(struct ptlrpc_client *peer, ino_t ino, int type, __u64 offset,
char *addr, struct mds_rep **rep, struct ptlrep_hdr **hdr)
{
struct ptlrpc_request *request;
CDEBUG(D_INODE, "inode: %ld\n", ino);
- request = mds_prep_req(MDS_READPAGE, 0, NULL,
+ request = ptlrpc_prep_req(peer, MDS_READPAGE, 0, NULL,
sizeof(struct niobuf), (char *)&niobuf);
if (!request) {
CERROR("mdc request: cannot pack\n");
request->rq_replen =
sizeof(struct ptlrep_hdr) + sizeof(struct mds_rep);
- rc = mds_queue_wait(request, peer);
+ rc = ptlrpc_queue_wait(request, peer);
if (rc) {
CERROR("mdc request: error in handling %d\n", rc);
goto out;
}
out:
- mdc_free_req(request);
+ ptlrpc_free_req(request);
return rc;
}
-int mdc_reint(struct lustre_peer *peer, struct ptlrpc_request *request)
+int mdc_reint(struct ptlrpc_client *peer, struct ptlrpc_request *request)
{
int rc;
- rc = mds_queue_wait(request, peer);
+ rc = ptlrpc_queue_wait(request, peer);
if (rc) {
CERROR("mdc request: error in handling %d\n", rc);
}
return rc;
}
+int mdc_create_client(char *uuid, struct ptlrpc_client *cl)
+{
+ int err;
+
+ memset(cl, 0, sizeof(*cl));
+ cl->cli_xid = 0;
+ cl->cli_rep_unpack = mds_unpack_rep;
+ cl->cli_req_pack = mds_pack_req;
+ err = kportal_uuid_to_peer("mds", &cl->cli_server);
+ if (err == 0) {
+ cl->cli_request_portal = MDS_REQUEST_PORTAL;
+ cl->cli_reply_portal = MDS_REPLY_PORTAL;
+
+ } else {
+ cl->cli_enqueue = mds_queue_req;
+ }
+ return 0;
+}
static int request_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
int err;
- struct lustre_peer peer, *peer_ptr = NULL;
+ struct ptlrpc_client peer;
ENTRY;
return -EINVAL;
}
- err = kportal_uuid_to_peer("mds", &peer);
- if (err == 0)
- peer_ptr = &peer;
+ err = mdc_create_client("mds", &peer);
+ if (err) {
+ CERROR("cannot create client");
+ return -EINVAL;
+ }
switch (cmd) {
case IOC_REQUEST_GETATTR: {
struct ptlrep_hdr *hdr = NULL;
CERROR("-- getting attr for ino 2\n");
- err = mdc_getattr(peer_ptr, 2, S_IFDIR, ~0, NULL, &hdr);
+ err = mdc_getattr(&peer, 2, S_IFDIR, ~0, NULL, &hdr);
if (hdr) {
/* FIXME: there must be a better way to get the size */
OBD_FREE(hdr, sizeof(struct ptlrep_hdr) +
break;
}
CERROR("-- readpage 0 for ino 2\n");
- err = mdc_readpage(peer_ptr, 2, S_IFDIR, 0, buf, NULL, &hdr);
+ err = mdc_readpage(&peer, 2, S_IFDIR, 0, buf, NULL, &hdr);
CERROR("-- done err %d\n", err);
if (!err) {
CERROR("-- status: %d\n", hdr->status);
iattr.ia_atime = 0;
iattr.ia_valid = ATTR_MODE | ATTR_ATIME;
- err = mdc_setattr(peer_ptr, &inode, &iattr, NULL, &hdr);
+ err = mdc_setattr(&peer, &inode, &iattr, NULL, &hdr);
CERROR("-- done err %d\n", err);
if (!err) {
CERROR("-- status: %d\n", hdr->status);
iattr.ia_atime = 0;
iattr.ia_valid = ATTR_MODE | ATTR_ATIME;
- err = mdc_create(peer_ptr, &inode,
+ err = mdc_create(&peer, &inode,
"foofile", strlen("foofile"),
NULL, 0, 0100707, 47114711,
11, 47, 0, NULL, &hdr);
MODULE_DESCRIPTION("Lustre MDS Request Tester v1.0");
MODULE_LICENSE("GPL");
+EXPORT_SYMBOL(mdc_create_client);
EXPORT_SYMBOL(mdc_create);
EXPORT_SYMBOL(mdc_unlink);
EXPORT_SYMBOL(mdc_rename);
struct mds_rep *rep;
int rc;
- rc = mds_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep.mds,
+ rc = mds_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep,
&req->rq_replen, &req->rq_repbuf);
if (rc) {
EXIT;
struct mds_rep *rep;
int rc;
- rc = mds_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep.mds,
+ rc = mds_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep,
&req->rq_replen, &req->rq_repbuf);
if (rc) {
EXIT;
}
rc = mds_unpack_req(req->rq_reqbuf, req->rq_reqlen,
- &req->rq_reqhdr, &req->rq_req.mds);
+ &req->rq_reqhdr, &req->rq_req);
if (rc) {
CERROR("lustre_mds: Invalid request\n");
EXIT;
/* And now, wait forever for commit wakeup events. */
while (1) {
+ int signal;
int rc;
- if (mds->mds_flags & MDS_UNMOUNT)
- break;
wake_up(&mds->mds_done_waitq);
- interruptible_sleep_on(&mds->mds_waitq);
CDEBUG(D_INODE, "mds_wakes pick up req here and continue\n");
if (mds->mds_service != NULL) {
CDEBUG(D_IOCTL, "-- sleeping\n");
+ signal = 0;
add_wait_queue(&mds->mds_waitq, &wait);
while (1) {
+ set_current_state(TASK_INTERRUPTIBLE);
rc = PtlEQGet(mds->mds_service->srv_eq_h, &ev);
if (rc == PTL_OK || rc == PTL_EQ_DROPPED)
break;
+ if (mds->mds_flags & MDS_UNMOUNT)
+ break;
- set_current_state(TASK_INTERRUPTIBLE);
/* if this process really wants to die,
* let it go */
if (sigismember(&(current->pending.signal),
SIGKILL) ||
sigismember(&(current->pending.signal),
- SIGINT))
+ SIGINT)) {
+ signal = 1;
break;
+ }
schedule();
}
set_current_state(TASK_RUNNING);
CDEBUG(D_IOCTL, "-- done\n");
- if (rc == PTL_EQ_EMPTY) {
+ if (signal == 1) {
/* We broke out because of a signal */
EXIT;
- return -EINTR;
+ break;
+ }
+ if (mds->mds_flags & MDS_UNMOUNT) {
+ break;
}
service = (struct ptlrpc_service *)ev.mem_desc.user_ptr;
return rc;
}
- rc = mds_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep.mds,
+ rc = mds_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep,
&req->rq_replen, &req->rq_repbuf);
if (rc) {
EXIT;
/* FIXME: Serious refactoring needed */
int ost_main(void *arg)
{
+ int signal;
struct obd_device *obddev = (struct obd_device *) arg;
struct ost_obd *ost = &obddev->u.ost;
DECLARE_WAITQUEUE(wait, current);
while (1) {
int rc;
- if (ost->ost_flags & OST_EXIT)
- break;
-
if (ost->ost_service != NULL) {
ptl_event_t ev;
struct ptlrpc_request request;
struct ptlrpc_service *service;
CDEBUG(D_IOCTL, "-- sleeping\n");
+ signal = 0;
add_wait_queue(&ost->ost_waitq, &wait);
while (1) {
+ set_current_state(TASK_INTERRUPTIBLE);
rc = PtlEQGet(ost->ost_service->srv_eq_h, &ev);
if (rc == PTL_OK || rc == PTL_EQ_DROPPED)
break;
+ if (ost->ost_flags & OST_EXIT)
+ break;
- set_current_state(TASK_INTERRUPTIBLE);
/* if this process really wants to die,
* let it go */
if (sigismember(&(current->pending.signal),
SIGKILL) ||
sigismember(&(current->pending.signal),
- SIGINT))
+ SIGINT)) {
+ signal = 1;
break;
+ }
schedule();
}
set_current_state(TASK_RUNNING);
CDEBUG(D_IOCTL, "-- done\n");
- if (rc == PTL_EQ_EMPTY) {
+ if (signal == 1) {
/* We broke out because of a signal */
EXIT;
- return -EINTR;
+ break;
+ }
+ if (ost->ost_flags & OST_EXIT) {
+ EXIT;
+ break;
}
service = (struct ptlrpc_service *)ev.mem_desc.user_ptr;
if (list_empty(&ost->ost_reqs)) {
CDEBUG(D_INODE, "woke because of signal\n");
- spin_unlock(&ost->ost_req_lock);
+ spin_unlock(&ost->ost_lock);
} else {
request = list_entry(ost->ost_reqs.next,
struct ptlrpc_request,
rq_list);
list_del(&request->rq_list);
- spin_unlock(&ost->ost_req_lock);
+ spin_unlock(&ost->ost_lock);
rc = ost_handle(obddev, request);
}
}
#include <linux/obd_support.h>
#include <linux/lustre_net.h>
-static ptl_handle_eq_t req_eq, bulk_source_eq, bulk_sink_eq;
+static ptl_handle_eq_t sent_pkt_eq, rcvd_rep_eq,
+ bulk_source_eq, bulk_sink_eq;
+
+struct ptlrpc_request *ptlrpc_prep_req(struct ptlrpc_client *cl,
+ int opcode, int namelen, char *name,
+ int tgtlen, char *tgt)
+{
+ struct ptlrpc_request *request;
+ int rc;
+ ENTRY;
+
+ OBD_ALLOC(request, sizeof(*request));
+ if (!request) {
+ CERROR("request allocation out of memory\n");
+ return NULL;
+ }
+
+ memset(request, 0, sizeof(*request));
+ request->rq_xid = cl->cli_xid++;
+
+ rc = cl->cli_req_pack(name, namelen, tgt, tgtlen,
+ &request->rq_reqhdr, &request->rq_req,
+ &request->rq_reqlen, &request->rq_reqbuf);
+ if (rc) {
+ CERROR("cannot pack request %d\n", rc);
+ return NULL;
+ }
+ request->rq_reqhdr->opc = opcode;
+
+ EXIT;
+ return request;
+}
+
+void ptlrpc_free_req(struct ptlrpc_request *request)
+{
+ OBD_FREE(request, sizeof(*request));
+}
+
+int ptlrpc_queue_wait(struct ptlrpc_request *req,
+ struct ptlrpc_client *cl)
+{
+ int rc;
+ DECLARE_WAITQUEUE(wait, current);
+
+ init_waitqueue_head(&req->rq_wait_for_rep);
+
+ if (cl->cli_enqueue) {
+ /* Local delivery */
+ ENTRY;
+ rc = cl->cli_enqueue(req);
+ } else {
+ /* Remote delivery via portals. */
+ req->rq_req_portal = cl->cli_request_portal;
+ req->rq_reply_portal = cl->cli_reply_portal;
+ rc = ptl_send_rpc(req, &cl->cli_server);
+ }
+ if (rc) {
+ CERROR("error %d, opcode %d\n", rc,
+ req->rq_reqhdr->opc);
+ return -rc;
+ }
+
+ CDEBUG(0, "-- sleeping\n");
+ add_wait_queue(&req->rq_wait_for_rep, &wait);
+ while (req->rq_repbuf == NULL) {
+ set_current_state(TASK_INTERRUPTIBLE);
+
+ /* if this process really wants to die, let it go */
+ if (sigismember(&(current->pending.signal), SIGKILL) ||
+ sigismember(&(current->pending.signal), SIGINT))
+ break;
+
+ schedule();
+ }
+ remove_wait_queue(&req->rq_wait_for_rep, &wait);
+ set_current_state(TASK_RUNNING);
+ CDEBUG(0, "-- done\n");
+
+ if (req->rq_repbuf == NULL) {
+ /* We broke out because of a signal */
+ EXIT;
+ return -EINTR;
+ }
+
+ rc = cl->cli_rep_unpack(req->rq_repbuf, req->rq_replen, &req->rq_rephdr, &req->rq_rep);
+ if (rc) {
+ CERROR("unpack_rep failed: %d\n", rc);
+ return rc;
+ }
+
+ if ( req->rq_rephdr->status == 0 )
+ CDEBUG(0, "--> buf %p len %d status %d\n",
+ req->rq_repbuf, req->rq_replen,
+ req->rq_rephdr->status);
+
+ EXIT;
+ return 0;
+}
/*
- * 1. Free the request buffer after it has gone out on the wire
- * 2. Wake up the thread waiting for the reply once it comes in.
+ * Free the packet when it has gone out
*/
-static int client_packet_callback(ptl_event_t *ev, void *data)
+static int sent_packet_callback(ptl_event_t *ev, void *data)
{
- struct ptlrpc_request *rpc = ev->mem_desc.user_ptr;
-
ENTRY;
- // XXX make sure we understand all events, including ACK's
if (ev->type == PTL_EVENT_SENT) {
OBD_FREE(ev->mem_desc.start, ev->mem_desc.length);
- } else if (ev->type == PTL_EVENT_PUT) {
+ } else {
+ // XXX make sure we understand all events, including ACK's
+ CERROR("Unknown event %d\n", ev->type);
+ BUG();
+ }
+
+ EXIT;
+ return 1;
+}
+
+/*
+ * Wake up the thread waiting for the reply once it comes in.
+ */
+static int rcvd_reply_callback(ptl_event_t *ev, void *data)
+{
+ struct ptlrpc_request *rpc = ev->mem_desc.user_ptr;
+ ENTRY;
+
+ if (ev->type == PTL_EVENT_PUT) {
rpc->rq_repbuf = ev->mem_desc.start + ev->offset;
wake_up_interruptible(&rpc->rq_wait_for_rep);
+ } else {
+ // XXX make sure we understand all events, including ACK's
+ CERROR("Unknown event %d\n", ev->type);
+ BUG();
}
EXIT;
wake_up_interruptible(&rpc->rq_wait_for_bulk);
} else {
CERROR("Unexpected event type!\n");
+ BUG();
}
EXIT;
wake_up_interruptible(&rpc->rq_wait_for_bulk);
} else {
CERROR("Unexpected event type!\n");
+ BUG();
}
EXIT;
} else if (is_request) {
request->rq_req_md.start = request->rq_reqbuf;
request->rq_req_md.length = request->rq_reqlen;
- request->rq_req_md.eventq = req_eq;
+ request->rq_req_md.eventq = sent_pkt_eq;
} else {
request->rq_req_md.start = request->rq_repbuf;
request->rq_req_md.length = request->rq_replen;
- request->rq_req_md.eventq = req_eq;
+ request->rq_req_md.eventq = sent_pkt_eq;
}
request->rq_req_md.threshold = 1;
request->rq_req_md.options = PTL_MD_OP_PUT;
rc = PtlMDBind(peer->peer_ni, request->rq_req_md, &md_h);
if (rc != 0) {
+ BUG();
CERROR("PtlMDBind failed: %d\n", rc);
return rc;
}
request->rq_xid, 0, 0);
}
if (rc != PTL_OK) {
+ BUG();
CERROR("PtlPut(%d, %d, %d) failed: %d\n", remote_id.nid,
portal, request->rq_xid, rc);
/* FIXME: tear down md */
local_id.gid = PTL_ID_ANY;
local_id.rid = PTL_ID_ANY;
+ CERROR("sending req %d\n", request->rq_xid);
rc = PtlMEAttach(peer->peer_ni, request->rq_reply_portal, local_id,
request->rq_xid, 0, PTL_UNLINK, &me_h);
if (rc != PTL_OK) {
CERROR("PtlMEAttach failed: %d\n", rc);
+ BUG();
EXIT;
goto cleanup;
}
request->rq_reply_md.threshold = 1;
request->rq_reply_md.options = PTL_MD_OP_PUT;
request->rq_reply_md.user_ptr = request;
- request->rq_reply_md.eventq = req_eq;
+ request->rq_reply_md.eventq = rcvd_rep_eq;
rc = PtlMDAttach(me_h, request->rq_reply_md, PTL_UNLINK,
&request->rq_reply_md_h);
if (rc != PTL_OK) {
CERROR("PtlMDAttach failed: %d\n", rc);
+ BUG();
EXIT;
goto cleanup2;
}
&bulk_me_h);
if (rc != PTL_OK) {
CERROR("PtlMEAttach failed: %d\n", rc);
+ BUG();
EXIT;
goto cleanup3;
}
&request->rq_bulk_md_h);
if (rc != PTL_OK) {
CERROR("PtlMDAttach failed: %d\n", rc);
+ BUG();
EXIT;
goto cleanup4;
}
CDEBUG(D_INFO, "Attach MD in ring, rc %d\n", rc);
if (rc != PTL_OK) {
- /* cleanup */
+ /* XXX cleanup */
+ BUG();
CERROR("PtlMDAttach failed: %d\n", rc);
return rc;
}
}
ni = *nip;
- rc = PtlEQAlloc(ni, 128, client_packet_callback, NULL, &req_eq);
+ rc = PtlEQAlloc(ni, 128, sent_packet_callback, NULL, &sent_pkt_eq);
+ if (rc != PTL_OK)
+ CERROR("PtlEQAlloc failed: %d\n", rc);
+
+ rc = PtlEQAlloc(ni, 128, rcvd_reply_callback, NULL, &rcvd_rep_eq);
if (rc != PTL_OK)
CERROR("PtlEQAlloc failed: %d\n", rc);
static void __exit ptlrpc_exit(void)
{
- PtlEQFree(req_eq);
+ PtlEQFree(sent_pkt_eq);
+ PtlEQFree(rcvd_rep_eq);
PtlEQFree(bulk_source_eq);
PtlEQFree(bulk_sink_eq);
EOF
mkdir /mnt/obd
-mount -t lustre_light -o device=3 none /mnt/obd
+# mount -t lustre_light -o device=3 none /mnt/obd
"obd/class", "obd/rpc", "obd/ext2obd", "obd/ost",
"obd/osc", "obd/mds", "obd/mdc", "obd/llight", NULL};
char *path = "..";
+ char *kernel = "linux";
int i;
- if (argc == 2)
+ if (argc >= 2)
path = argv[1];
- if (argc > 2) {
- printf("%s [path]\n", argv[0]);
+ if (argc == 3)
+ kernel = argv[2];
+ if (argc > 3) {
+ printf("%s [path] [kernel]\n", argv[0]);
return 0;
}
+ printf("symbol-file\nsymbol-file %s\nb panic\nb stop\n", kernel);
+
for (i = 0; modules[i] != NULL; i++) {
struct module_info info;
int rc;