From af2f748719202c7257228d9d44b1c61d81bf02d8 Mon Sep 17 00:00:00 2001 From: shaver Date: Tue, 15 Oct 2002 20:54:30 +0000 Subject: [PATCH] - make_bad_inode as part of epoch-check mismatch handling - cleanup and comment-for-phil in ll_lock - partial fix for the crash in recovery that I introduced with my patch yesterday - better diagnostics in lustre_msg_buf - finished, not free_req, in reconnection --- lustre/include/linux/lustre_lite.h | 4 +++- lustre/llite/namei.c | 20 +++++++++++--------- lustre/mdc/mdc_request.c | 4 ++-- lustre/ptlrpc/niobuf.c | 11 +++++++++-- lustre/ptlrpc/pack_generic.c | 7 ++++--- lustre/ptlrpc/recover.c | 2 +- 6 files changed, 30 insertions(+), 18 deletions(-) diff --git a/lustre/include/linux/lustre_lite.h b/lustre/include/linux/lustre_lite.h index 24afe9e..4174dab 100644 --- a/lustre/include/linux/lustre_lite.h +++ b/lustre/include/linux/lustre_lite.h @@ -80,8 +80,10 @@ struct ll_sb_info { #define CHECK_MOUNT_EPOCH(i) \ do { \ - if (ll_i2info(i)->lli_mount_epoch != ll_i2sbi(i)->ll_mount_epoch) \ + if (ll_i2info(i)->lli_mount_epoch != ll_i2sbi(i)->ll_mount_epoch) { \ + make_bad_inode(i); \ RETURN(-EIO); \ + } \ } while(0) static inline struct ll_sb_info *ll_s2sbi(struct super_block *sb) diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index b8cf40c..cd02e57 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -108,20 +108,20 @@ int ll_lock(struct inode *dir, struct dentry *dentry, int tgtlen = 0; int err, lock_mode; - if ((it->it_op & (IT_CREAT | IT_MKDIR | IT_SETATTR | IT_MKNOD))) + /* CREAT needs to be tested before open (both could be set) */ + if ((it->it_op & (IT_CREAT | IT_MKDIR | IT_SETATTR | IT_MKNOD))) { lock_mode = LCK_PW; - else if (it->it_op & (IT_READDIR | IT_GETATTR | IT_OPEN | IT_UNLINK | - IT_RMDIR | IT_RENAME | IT_RENAME2 | IT_READLINK| - IT_LINK | IT_LINK2)) + } else if (it->it_op & (IT_READDIR | IT_GETATTR | IT_OPEN | IT_UNLINK | + IT_RMDIR | IT_RENAME | IT_RENAME2 | IT_READLINK| + IT_LINK | IT_LINK2 | IT_LOOKUP)) { + /* XXXphil PW for LINK2/RENAME2? */ lock_mode = LCK_PR; - else if (it->it_op & IT_SYMLINK) { + } else if (it->it_op & IT_SYMLINK) { lock_mode = LCK_PW; tgt = it->it_data; tgtlen = strlen(tgt); it->it_data = NULL; - } else if (it->it_op & IT_LOOKUP) - lock_mode = LCK_PR; - else { + } else { LBUG(); RETURN(-EINVAL); } @@ -156,8 +156,10 @@ static struct dentry *ll_lookup2(struct inode *dir, struct dentry *dentry, ENTRY; /* CHECK_MOUNT_EPOCH(dir); */ - if (ll_i2info(dir)->lli_mount_epoch != ll_i2sbi(dir)->ll_mount_epoch) + if (ll_i2info(dir)->lli_mount_epoch != ll_i2sbi(dir)->ll_mount_epoch) { + make_bad_inode(dir); RETURN(ERR_PTR(-EIO)); + } if (it == NULL) { it = &lookup_it; diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 59a3b4f..5bfba9e 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -285,7 +285,7 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type, /* pack the intended request */ mds_link_pack(req, 2, old_de->d_inode, dir, - de->d_name.name, de->d_name.len); + de->d_name.name, de->d_name.len); req->rq_replen = lustre_msg_size(3, repsize); } else if (it->it_op == IT_UNLINK || it->it_op == IT_RMDIR) { size[2] = sizeof(struct mds_rec_unlink); @@ -420,7 +420,7 @@ int mdc_open(struct lustre_handle *conn, obd_id ino, int type, int flags, /* If open is replayed, we need to fix up the fh. */ req->rq_replay_cb = mdc_replay_open; - memcpy(&req->rq_replay_cb_handle, fh, sizeof(req->rq_replay_cb_handle)); + memcpy(&req->rq_replay_cb_handle, fh, sizeof(fh)); EXIT; out: diff --git a/lustre/ptlrpc/niobuf.c b/lustre/ptlrpc/niobuf.c index ddd674c..82c2547 100644 --- a/lustre/ptlrpc/niobuf.c +++ b/lustre/ptlrpc/niobuf.c @@ -339,10 +339,14 @@ int ptl_send_rpc(struct ptlrpc_request *request) /* request->rq_repmsg is set only when the reply comes in, in * client_packet_callback() */ - if (request->rq_reply_md.start) + if (request->rq_reply_md.start) { OBD_FREE(request->rq_reply_md.start, request->rq_replen); - + /* If we're resending, rq_repmsg needs to be NULLed out + * again so that ptlrpc_check_reply doesn't trip early. + */ + request->rq_repmsg = NULL; + } OBD_ALLOC(repbuf, request->rq_replen); if (!repbuf) { LBUG(); @@ -380,6 +384,9 @@ int ptl_send_rpc(struct ptlrpc_request *request) request->rq_import->imp_client->cli_reply_portal); } + /* Clear any flags that may be present from previous sends, + * except for REPLAY. */ + request->rq_flags &= PTL_RPC_FL_REPLAY; rc = ptl_send_buf(request, request->rq_connection, request->rq_import->imp_client->cli_request_portal); RETURN(rc); diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index 3804bbc..dc537ec 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -116,14 +116,15 @@ void *lustre_msg_buf(struct lustre_msg *m, int n) } if (n < 0 || n >= m->bufcount) { - CERROR("referencing bad sub buffer (want %d, count is %d)!\n", - n, m->bufcount); + CERROR("referencing bad sub buffer in %p (want %d, count %d)!\n", + m, n, m->bufcount); LBUG(); return NULL; } if (m->buflens[n] == 0) { - CERROR("zero-length buffer requested for buffer %d\n", n); + CERROR("zero-length buffer requested for buffer %d in %p\n", n, + m); return NULL; } diff --git a/lustre/ptlrpc/recover.c b/lustre/ptlrpc/recover.c index 70d549b..2260a5f 100644 --- a/lustre/ptlrpc/recover.c +++ b/lustre/ptlrpc/recover.c @@ -78,7 +78,7 @@ static int ptlrpc_reconnect(struct ptlrpc_connection *conn) cli->cl_target_uuid, conn->c_remote_uuid, imp->imp_handle.addr, imp->imp_handle.cookie, old_hdl.addr, old_hdl.cookie); - ptlrpc_free_req(request); + ptlrpc_req_finished(request); } conn->c_level = LUSTRE_CONN_RECOVD; -- 1.8.3.1