Whamcloud - gitweb
LU-1095 debug: no console message for long symlink
authorAndreas Dilger <adilger@whamcloud.com>
Mon, 4 Jun 2012 22:03:28 +0000 (16:03 -0600)
committerOleg Drokin <green@whamcloud.com>
Fri, 29 Jun 2012 02:42:40 +0000 (22:42 -0400)
Some minor fixups from running local sanity.sh tests:
- don't print a console message for long-but-legal symlinks,
  which could be hit during normal usage as well

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I24e3e8ea9d8db0ca9c59597f3170f2b18359500c
Reviewed-on: http://review.whamcloud.com/3130
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Yu Jian <yujian@whamcloud.com>
Reviewed-by: Li Wei <liwei@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/symlink.c
lustre/mdt/mdt_handler.c

index 6a5c2fb..9a59011 100644 (file)
@@ -56,11 +56,18 @@ static int ll_readlink_internal(struct inode *inode,
 
         *request = NULL;
 
 
         *request = NULL;
 
-        if (lli->lli_symlink_name) {
-                *symname = lli->lli_symlink_name;
-                CDEBUG(D_INODE, "using cached symlink %s\n", *symname);
-                RETURN(0);
-        }
+       if (lli->lli_symlink_name) {
+               int print_limit = min_t(int, PAGE_SIZE - 128, symlen);
+
+               *symname = lli->lli_symlink_name;
+               /* 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, "using cached symlink %s%.*s, len = %d\n",
+                      print_limit < symlen ? "..." : "", print_limit,
+                      (*symname) + symlen - print_limit, symlen);
+               RETURN(0);
+       }
 
         op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, symlen,
                                      LUSTRE_OPC_ANY, NULL);
 
         op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, symlen,
                                      LUSTRE_OPC_ANY, NULL);
index 648ac70..671ac7a 100644 (file)
@@ -579,20 +579,27 @@ static int mdt_getattr_internal(struct mdt_thread_info *info,
                         CERROR("readlink failed: %d\n", rc);
                         rc = -EFAULT;
                 } else {
                         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;
                 }
         }
 
                 }
         }