From 4c819fc310c1f6fe135fc7b1f35dac40e23ae076 Mon Sep 17 00:00:00 2001 From: braam Date: Wed, 27 Feb 2002 17:49:34 +0000 Subject: [PATCH] - add open and close to MDC interface (not used yet) - very defensive logging to track our lost packet --- lustre/include/linux/lustre_idl.h | 6 ++-- lustre/include/linux/lustre_mds.h | 3 +- lustre/mdc/mdc_request.c | 72 +++++++++++++++++++++++++++++++++++++++ lustre/mds/handler.c | 52 +++++++++++++++++++++++++--- lustre/mds/mds_reint.c | 2 +- lustre/patches/patch-2.4.17 | 5 ++- 6 files changed, 129 insertions(+), 11 deletions(-) diff --git a/lustre/include/linux/lustre_idl.h b/lustre/include/linux/lustre_idl.h index 7da184b..c8d8969 100644 --- a/lustre/include/linux/lustre_idl.h +++ b/lustre/include/linux/lustre_idl.h @@ -178,8 +178,10 @@ struct obd_ioobj { #define MDS_TYPE_ERR 3 #define MDS_GETATTR 1 -#define MDS_REINT 2 -#define MDS_READPAGE 3 +#define MDS_OPEN 2 +#define MDS_CLOSE 3 +#define MDS_REINT 4 +#define MDS_READPAGE 5 #define REINT_SETATTR 0 #define REINT_CREATE 1 diff --git a/lustre/include/linux/lustre_mds.h b/lustre/include/linux/lustre_mds.h index 8186e0b..60e32b8 100644 --- a/lustre/include/linux/lustre_mds.h +++ b/lustre/include/linux/lustre_mds.h @@ -44,7 +44,8 @@ struct mds_run_ctxt { mm_segment_t fs; }; -#define MDS_UNMOUNT 1 +#define MDS_STOPPING 1 +#define MDS_RUNNING 2 #define LUSTRE_MDS_NAME "mds" struct mds_obd { diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 149e8d1..8d322ad 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -92,6 +92,78 @@ int mdc_getattr(struct ptlrpc_client *peer, ino_t ino, int type, int valid, return rc; } +int mdc_open(struct ptlrpc_client *peer, ino_t ino, int type, int flags, + __u64 *fh, struct mds_rep **rep, struct ptlrep_hdr **hdr) +{ + struct ptlrpc_request *request; + int rc; + + request = ptlrpc_prep_req(peer, MDS_OPEN, 0, NULL, 0, NULL); + if (!request) { + CERROR("llight request: cannot pack\n"); + return -ENOMEM; + } + + ll_ino2fid(&request->rq_req.mds->fid1, ino, 0, type); + request->rq_req.mds->flags = flags; + request->rq_replen = + sizeof(struct ptlrep_hdr) + sizeof(struct mds_rep); + + rc = ptlrpc_queue_wait(request, peer); + if (rc) { + CERROR("llight request: error in handling %d\n", rc); + goto out; + } + + if (rep) { + *rep = request->rq_rep.mds; + } + if (hdr) { + *hdr = request->rq_rephdr; + } + *fh = request->rq_rep.mds->objid; + + out: + ptlrpc_free_req(request); + return rc; +} + + +int mdc_close(struct ptlrpc_client *peer, ino_t ino, int type, __u64 fh, + struct mds_rep **rep, struct ptlrep_hdr **hdr) +{ + struct ptlrpc_request *request; + int rc; + + request = ptlrpc_prep_req(peer, MDS_CLOSE, 0, NULL, 0, NULL); + if (!request) { + CERROR("llight request: cannot pack\n"); + return -ENOMEM; + } + + ll_ino2fid(&request->rq_req.mds->fid1, ino, 0, type); + request->rq_req.mds->objid = fh; + request->rq_replen = + sizeof(struct ptlrep_hdr) + sizeof(struct mds_rep); + + rc = ptlrpc_queue_wait(request, peer); + if (rc) { + CERROR("llight request: error in handling %d\n", rc); + goto out; + } + + if (rep) { + *rep = request->rq_rep.mds; + } + if (hdr) { + *hdr = request->rq_rephdr; + } + + out: + ptlrpc_free_req(request); + return rc; +} + int mdc_readpage(struct ptlrpc_client *peer, ino_t ino, int type, __u64 offset, char *addr, struct mds_rep **rep, struct ptlrep_hdr **hdr) { diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index c41c901..e57472d 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -286,6 +286,48 @@ int mds_getattr(struct ptlrpc_request *req) return 0; } +int mds_open(struct ptlrpc_request *req) +{ + struct dentry *de; + struct inode *inode; + struct mds_rep *rep; + struct file *file; + struct vfsmount *mnt; + __u32 flags; + int rc; + + rc = mds_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep, + &req->rq_replen, &req->rq_repbuf); + if (rc) { + EXIT; + CERROR("mds: out of memory\n"); + req->rq_status = -ENOMEM; + return 0; + } + + req->rq_rephdr->seqno = req->rq_reqhdr->seqno; + rep = req->rq_rep.mds; + + de = mds_fid2dentry(req->rq_obd, &req->rq_req.mds->fid1, &mnt); + if (IS_ERR(de)) { + EXIT; + req->rq_rephdr->status = -ENOENT; + return 0; + } + flags = req->rq_req.mds->flags; + file = dentry_open(de, mnt, flags); + if (!file || IS_ERR(file)) { + req->rq_rephdr->status = -EINVAL; + return 0; + } + + rep->objid = (__u64) (unsigned long)file; + mds_get_objid(inode, &rep->objid); + dput(de); + return 0; +} + + int mds_readpage(struct ptlrpc_request *req) { struct vfsmount *mnt; @@ -449,6 +491,7 @@ int mds_main(void *arg) /* Record that the thread is running */ mds->mds_thread = current; + mds->mds_flags = MDS_RUNNING; wake_up(&mds->mds_done_waitq); /* And now, wait forever for commit wakeup events. */ @@ -465,7 +508,6 @@ int mds_main(void *arg) struct ptlrpc_request request; struct ptlrpc_service *service; - CDEBUG(D_IOCTL, "-- sleeping\n"); signal = 0; add_wait_queue(&mds->mds_waitq, &wait); @@ -474,7 +516,8 @@ int mds_main(void *arg) rc = PtlEQGet(mds->mds_service->srv_eq_h, &ev); if (rc == PTL_OK || rc == PTL_EQ_DROPPED) break; - if (mds->mds_flags & MDS_UNMOUNT) + CERROR("EQGet rc %d\n", rc); + if (mds->mds_flags & MDS_STOPPING) break; @@ -499,7 +542,7 @@ int mds_main(void *arg) EXIT; break; } - if (mds->mds_flags & MDS_UNMOUNT) { + if (mds->mds_flags & MDS_STOPPING) { break; } @@ -513,6 +556,7 @@ int mds_main(void *arg) request.rq_reqlen = ev.mem_desc.length; request.rq_obd = MDS; request.rq_xid = ev.match_bits; + CERROR("got req %d\n", request.rq_xid); request.rq_peer.peer_nid = ev.initiator.nid; /* FIXME: this NI should be the incoming NI. @@ -577,7 +621,7 @@ int mds_main(void *arg) static void mds_stop_srv_thread(struct mds_obd *mds) { - mds->mds_flags |= MDS_UNMOUNT; + mds->mds_flags |= MDS_STOPPING; while (mds->mds_thread) { wake_up(&mds->mds_waitq); diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index 4cc4187..56121db 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -118,7 +118,7 @@ static int mds_reint_create(struct mds_update_record *rec, CERROR("child exists (dir %ld, name %s\n", de->d_inode->i_ino, rec->ur_name); dput(de); - req->rq_rephdr->status = -ESTALE; + req->rq_rephdr->status = -EEXIST; EXIT; return 0; } diff --git a/lustre/patches/patch-2.4.17 b/lustre/patches/patch-2.4.17 index 70728d0..2a72130 100644 --- a/lustre/patches/patch-2.4.17 +++ b/lustre/patches/patch-2.4.17 @@ -1,13 +1,12 @@ --- linux-2.4.17/kernel/ksyms.c.lustre Fri Feb 22 15:26:38 2002 +++ linux-2.4.17/kernel/ksyms.c Fri Feb 22 15:27:44 2002 -@@ -282,6 +282,12 @@ +@@ -282,6 +282,11 @@ EXPORT_SYMBOL(lock_may_write); EXPORT_SYMBOL(dcache_readdir); +/* lustre */ +EXPORT_SYMBOL(pagecache_lock); +EXPORT_SYMBOL(do_kern_mount); -+EXPORT_SYMBOL(module_list); + + /* for stackable file systems (lofs, wrapfs, cryptfs, etc.) */ @@ -15,7 +14,7 @@ EXPORT_SYMBOL(dentry_open); --- linux-2.4.17/include/linux/fs.h.lustre Fri Feb 22 15:27:53 2002 +++ linux-2.4.17/include/linux/fs.h Fri Feb 22 15:28:52 2002 -@@ -983,7 +983,7 @@ +@@ -983,7 +984,7 @@ extern struct vfsmount *kern_mount(struct file_system_type *); extern int may_umount(struct vfsmount *); extern long do_mount(char *, char *, char *, unsigned long, void *); -- 1.8.3.1