From a0ae1aa349b899a6de1d7d38760a0f7ae09d87f8 Mon Sep 17 00:00:00 2001 From: pschwan Date: Thu, 26 Sep 2002 16:37:17 +0000 Subject: [PATCH] b=613941 Previously, if a filesystem user called readlink() without enough buffer space, Lustre would allocate a reply packet that's too small and we'd drop the packet and go into recovery. Now Lustre sends the maximum size to the server, which will truncate its own readlink and reply appropriately. --- lustre/mdc/mdc_request.c | 5 ++++- lustre/mds/handler.c | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index da291bc..7e41574 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -125,7 +125,6 @@ int mdc_getattr(struct lustre_handle *conn, body = lustre_msg_buf(req->rq_reqmsg, 0); ll_ino2fid(&body->fid1, ino, 0, type); body->valid = valid; - mds_pack_req_body(req); if (S_ISREG(type)) { struct client_obd *mdc = &class_conn2obd(conn)->u.cli; @@ -134,8 +133,12 @@ int mdc_getattr(struct lustre_handle *conn, } else if (valid & OBD_MD_LINKNAME) { bufcount = 2; size[1] = ea_size; + body->size = ea_size; + CDEBUG(D_INODE, "allocating %d bytes for symlink in packet\n", + ea_size); } req->rq_replen = lustre_msg_size(bufcount, size); + mds_pack_req_body(req); rc = ptlrpc_queue_wait(req); rc = ptlrpc_check_status(req, rc); diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index c64b045..052b6ea 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -606,7 +606,9 @@ static int mds_getattr(int offset, struct ptlrpc_request *req) size[1] = mds->mds_max_mdsize; } else if (body->valid & OBD_MD_LINKNAME) { bufcount = 2; - size[1] = inode->i_size + 1; + size[1] = MIN(inode->i_size + 1, body->size); + CDEBUG(D_INODE, "symlink size: %d, reply space: %d\n", + inode->i_size + 1, body->size); } if (OBD_FAIL_CHECK(OBD_FAIL_MDS_GETATTR_PACK)) { -- 1.8.3.1