Whamcloud - gitweb
b=613941
authorpschwan <pschwan>
Thu, 26 Sep 2002 16:37:17 +0000 (16:37 +0000)
committerpschwan <pschwan>
Thu, 26 Sep 2002 16:37:17 +0000 (16:37 +0000)
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
lustre/mds/handler.c

index da291bc..7e41574 100644 (file)
@@ -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);
index c64b045..052b6ea 100644 (file)
@@ -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)) {