Whamcloud - gitweb
LU-1095 debug: no console message for long symlink
[fs/lustre-release.git] / lustre / mdt / mdt_handler.c
index e58ac8b..671ac7a 100644 (file)
@@ -336,20 +336,20 @@ static int mdt_getstatus(struct mdt_thread_info *info)
 
 static int mdt_statfs(struct mdt_thread_info *info)
 {
-        struct ptlrpc_request *req = mdt_info_req(info);
-        struct md_device      *next  = info->mti_mdt->mdt_child;
-        struct ptlrpc_service *svc;
-        struct obd_statfs     *osfs;
-        int                    rc;
+       struct ptlrpc_request           *req = mdt_info_req(info);
+       struct md_device                *next = info->mti_mdt->mdt_child;
+       struct ptlrpc_service_part      *svcpt;
+       struct obd_statfs               *osfs;
+       int                             rc;
 
-        ENTRY;
+       ENTRY;
 
-        svc = info->mti_pill->rc_req->rq_rqbd->rqbd_service;
+       svcpt = info->mti_pill->rc_req->rq_rqbd->rqbd_svcpt;
 
-        /* This will trigger a watchdog timeout */
-        OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_STATFS_LCW_SLEEP,
-                         (MDT_SERVICE_WATCHDOG_FACTOR *
-                          at_get(&svc->srv_at_estimate)) + 1);
+       /* This will trigger a watchdog timeout */
+       OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_STATFS_LCW_SLEEP,
+                        (MDT_SERVICE_WATCHDOG_FACTOR *
+                         at_get(&svcpt->scp_at_estimate)) + 1);
 
         rc = mdt_check_ucred(info);
         if (rc)
@@ -579,20 +579,27 @@ static int mdt_getattr_internal(struct mdt_thread_info *info,
                         CERROR("readlink failed: %d\n", rc);
                         rc = -EFAULT;
                 } else {
-                        if (OBD_FAIL_CHECK(OBD_FAIL_MDS_READLINK_EPROTO))
-                                 rc -= 2;
-                        repbody->valid |= OBD_MD_LINKNAME;
-                        /* we need to report back size with NULL-terminator
-                         * because client expects that */
-                        repbody->eadatasize = rc + 1;
-                        if (repbody->eadatasize != reqbody->eadatasize)
-                                CERROR("Read shorter link %d than expected "
-                                       "%d\n", rc, reqbody->eadatasize - 1);
-                        /* NULL terminate */
-                        ((char*)ma->ma_lmm)[rc] = 0;
-                        CDEBUG(D_INODE, "symlink dest %s, len = %d\n",
-                               (char*)ma->ma_lmm, rc);
-                        rc = 0;
+                       int print_limit = min_t(int, CFS_PAGE_SIZE - 128, rc);
+
+                       if (OBD_FAIL_CHECK(OBD_FAIL_MDS_READLINK_EPROTO))
+                               rc -= 2;
+                       repbody->valid |= OBD_MD_LINKNAME;
+                       /* we need to report back size with NULL-terminator
+                        * because client expects that */
+                       repbody->eadatasize = rc + 1;
+                       if (repbody->eadatasize != reqbody->eadatasize)
+                               CERROR("Read shorter symlink %d, expected %d\n",
+                                      rc, reqbody->eadatasize - 1);
+                       /* NULL terminate */
+                       ((char *)ma->ma_lmm)[rc] = 0;
+
+                       /* If the total CDEBUG() size is larger than a page, it
+                        * will print a warning to the console, avoid this by
+                        * printing just the last part of the symlink. */
+                       CDEBUG(D_INODE, "symlink dest %s%.*s, len = %d\n",
+                              print_limit < rc ? "..." : "", print_limit,
+                              (char *)ma->ma_lmm + rc - print_limit, rc);
+                       rc = 0;
                 }
         }
 
@@ -5312,12 +5319,21 @@ static int mdt_init_export(struct obd_export *exp)
                 RETURN(0);
 
         rc = lut_client_alloc(exp);
-        if (rc == 0)
-                rc = ldlm_init_export(exp);
         if (rc)
-                CERROR("%s: Error %d while initializing export\n",
-                       exp->exp_obd->obd_name, rc);
+               GOTO(err, rc);
+
+       rc = ldlm_init_export(exp);
+       if (rc)
+               GOTO(err_free, rc);
+
         RETURN(rc);
+
+err_free:
+       lut_client_free(exp);
+err:
+       CERROR("%s: Error %d while initializing export\n",
+              exp->exp_obd->obd_name, rc);
+       return rc;
 }
 
 static int mdt_destroy_export(struct obd_export *exp)