X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fmdc%2Fmdc_reint.c;h=348fc21f73903ccbbb9a79620d6dd1768629c0f2;hb=280993ae28bf703ddf15db50f2432a794f4e283d;hp=58eb55a9e8f9cb4832f773fb772dee5f1d1c4ba9;hpb=06fb20cfda6b2fe1c3b3e909d1448548505d033a;p=fs%2Flustre-release.git diff --git a/lustre/mdc/mdc_reint.c b/lustre/mdc/mdc_reint.c index 58eb55a..348fc21 100644 --- a/lustre/mdc/mdc_reint.c +++ b/lustre/mdc/mdc_reint.c @@ -30,168 +30,169 @@ #include #include +#include -static int mdc_reint(struct ptlrpc_client *cl, struct ptlrpc_request *request) +static int mdc_reint(struct ptlrpc_request *request, int level) { int rc; + request->rq_level = level; - rc = ptlrpc_queue_wait(cl, request); + rc = ptlrpc_queue_wait(request); rc = ptlrpc_check_status(request, rc); - if (rc) - CERROR("error in handling %d\n", rc); + if (rc) { + CERROR("error in handling %d\n", rc); + } else { + /* For future resend/replays. */ + u32 *opcodeptr = lustre_msg_buf(request->rq_reqmsg, 0); + *opcodeptr |= REINT_REPLAYING; + } return rc; } -int mdc_setattr(struct ptlrpc_client *cl, struct lustre_peer *peer, +int mdc_setattr(struct lustre_handle *conn, struct inode *inode, struct iattr *iattr, struct ptlrpc_request **request) { - struct mds_rec_setattr *rec; struct ptlrpc_request *req; + struct mds_rec_setattr *rec; int rc, size = sizeof(*rec); ENTRY; - req = ptlrpc_prep_req(cl, peer, MDS_REINT, 1, &size, NULL); + req = ptlrpc_prep_req(class_conn2cliimp(conn), MDS_REINT, 1, &size, + NULL); if (!req) RETURN(-ENOMEM); - rec = lustre_msg_buf(req->rq_reqmsg, 0); - mds_setattr_pack(rec, inode, iattr); + mds_setattr_pack(req, 0, inode, iattr, NULL, 0); size = sizeof(struct mds_body); req->rq_replen = lustre_msg_size(1, &size); - rc = mdc_reint(cl, req); + rc = mdc_reint(req, LUSTRE_CONN_FULL); *request = req; + if (rc == -ERESTARTSYS ) + rc = 0; RETURN(rc); } -int mdc_create(struct ptlrpc_client *cl, struct lustre_peer *peer, +int mdc_create(struct lustre_handle *conn, 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) + const char *tgt, int tgtlen, int mode, __u32 uid, + __u32 gid, __u64 time, __u64 rdev, struct lov_stripe_md *lsm, + struct ptlrpc_request **request) { - struct mds_rec_create *rec; struct ptlrpc_request *req; - int rc, size[3] = {sizeof(*rec), namelen + 1, tgtlen + 1}; - char *tmp; + int rc, size[3] = {sizeof(struct mds_rec_create), namelen + 1, 0}; + int level, bufcount = 2; ENTRY; - req = ptlrpc_prep_req(cl, peer, MDS_REINT, 3, size, NULL); + if (S_ISLNK(mode)) { + size[2] = tgtlen + 1; + bufcount = 3; + } + + req = ptlrpc_prep_req(class_conn2cliimp(conn), MDS_REINT, bufcount, + size, NULL); if (!req) RETURN(-ENOMEM); - rec = lustre_msg_buf(req->rq_reqmsg, 0); - mds_create_pack(rec, dir, mode, id, uid, gid, time); - - tmp = lustre_msg_buf(req->rq_reqmsg, 1); - LOGL0(name, namelen, tmp); - - if (tgt) { - tmp = lustre_msg_buf(req->rq_reqmsg, 2); - LOGL0(tgt, tgtlen, tmp); - } + /* mds_create_pack fills msg->bufs[1] with name + * and msg->bufs[2] with tgt, for symlinks */ + mds_create_pack(req, 0, dir, mode, rdev, uid, gid, time, + name, namelen, tgt, tgtlen); size[0] = sizeof(struct mds_body); req->rq_replen = lustre_msg_size(1, size); - rc = mdc_reint(cl, req); - *request = req; + level = LUSTRE_CONN_FULL; + resend: + rc = mdc_reint(req, level); + /* Resend if we were told to. */ + if (rc == -ERESTARTSYS) { + level = LUSTRE_CONN_RECOVD; + req->rq_flags = 0; + goto resend; + } + *request = req; RETURN(rc); } -int mdc_unlink(struct ptlrpc_client *cl, struct lustre_peer *peer, - struct inode *dir, struct inode *child, const char *name, - int namelen, struct ptlrpc_request **request) +int mdc_unlink(struct lustre_handle *conn, struct inode *dir, + struct inode *child, __u32 mode, const char *name, int namelen, + struct ptlrpc_request **request) { - struct mds_rec_unlink *rec; struct ptlrpc_request *req; - int rc, size[2] = {sizeof(*rec), namelen + 1}; - char *tmp; + int rc, size[2] = {sizeof(struct mds_rec_unlink), namelen + 1}; ENTRY; - req = ptlrpc_prep_req(cl, peer, MDS_REINT, 2, size, NULL); + req = ptlrpc_prep_req(class_conn2cliimp(conn), MDS_REINT, 2, size, NULL); if (!req) RETURN(-ENOMEM); - rec = lustre_msg_buf(req->rq_reqmsg, 0); - mds_unlink_pack(rec, dir, child); - - tmp = lustre_msg_buf(req->rq_reqmsg, 1); - LOGL0(name, namelen, tmp); + mds_unlink_pack(req, 0, dir, child, mode, name, namelen); size[0] = sizeof(struct mds_body); req->rq_replen = lustre_msg_size(1, size); - rc = mdc_reint(cl, req); + rc = mdc_reint(req, LUSTRE_CONN_FULL); *request = req; + if (rc == -ERESTARTSYS) + rc = 0; RETURN(rc); } -int mdc_link(struct ptlrpc_client *cl, struct lustre_peer *peer, +int mdc_link(struct lustre_handle *conn, struct dentry *src, struct inode *dir, const char *name, int namelen, struct ptlrpc_request **request) { - struct mds_rec_link *rec; struct ptlrpc_request *req; - int rc, size[2] = {sizeof(*rec), namelen + 1}; - char *tmp; + int rc, size[2] = {sizeof(struct mds_rec_link), namelen + 1}; ENTRY; - req = ptlrpc_prep_req(cl, peer, MDS_REINT, 2, size, NULL); + req = ptlrpc_prep_req(class_conn2cliimp(conn), MDS_REINT, 2, size, NULL); if (!req) RETURN(-ENOMEM); - rec = lustre_msg_buf(req->rq_reqmsg, 0); - mds_link_pack(rec, src->d_inode, dir); - - tmp = lustre_msg_buf(req->rq_reqmsg, 1); - LOGL0(name, namelen, tmp); + mds_link_pack(req, 0, src->d_inode, dir, name, namelen); size[0] = sizeof(struct mds_body); req->rq_replen = lustre_msg_size(1, size); - rc = mdc_reint(cl, req); + rc = mdc_reint(req, LUSTRE_CONN_FULL); *request = req; + if (rc == -ERESTARTSYS ) + rc = 0; RETURN(rc); } -int mdc_rename(struct ptlrpc_client *cl, struct lustre_peer *peer, +int mdc_rename(struct lustre_handle *conn, struct inode *src, struct inode *tgt, const char *old, int oldlen, const char *new, int newlen, struct ptlrpc_request **request) { - struct mds_rec_rename *rec; struct ptlrpc_request *req; - int rc, size[3] = {sizeof(*rec), oldlen + 1, newlen + 1}; - char *tmp; + int rc, size[3] = {sizeof(struct mds_rec_rename), oldlen + 1, + newlen + 1}; ENTRY; - req = ptlrpc_prep_req(cl, peer, MDS_REINT, 3, size, NULL); + req = ptlrpc_prep_req(class_conn2cliimp(conn), MDS_REINT, 3, size, NULL); if (!req) RETURN(-ENOMEM); - rec = lustre_msg_buf(req->rq_reqmsg, 0); - mds_rename_pack(rec, src, tgt); - - tmp = lustre_msg_buf(req->rq_reqmsg, 1); - LOGL0(old, oldlen, tmp); - - if (tgt) { - tmp = lustre_msg_buf(req->rq_reqmsg, 2); - LOGL0(new, newlen, tmp); - } + mds_rename_pack(req, 0, src, tgt, old, oldlen, new, newlen); size[0] = sizeof(struct mds_body); req->rq_replen = lustre_msg_size(1, size); - rc = mdc_reint(cl, req); + rc = mdc_reint(req, LUSTRE_CONN_FULL); *request = req; + if (rc == -ERESTARTSYS ) + rc = 0; RETURN(rc); }