From 99aec0dc17de5f980588c08d8befd0f3119db0ea Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Mon, 4 Jun 2012 16:03:28 -0600 Subject: [PATCH] LU-1095 debug: no console message for long symlink 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 Change-Id: I24e3e8ea9d8db0ca9c59597f3170f2b18359500c Reviewed-on: http://review.whamcloud.com/3130 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Yu Jian Reviewed-by: Li Wei Reviewed-by: Oleg Drokin --- lustre/llite/symlink.c | 17 ++++++++++++----- lustre/mdt/mdt_handler.c | 35 +++++++++++++++++++++-------------- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/lustre/llite/symlink.c b/lustre/llite/symlink.c index 6a5c2fb..9a59011 100644 --- a/lustre/llite/symlink.c +++ b/lustre/llite/symlink.c @@ -56,11 +56,18 @@ static int ll_readlink_internal(struct inode *inode, *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); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 648ac70..671ac7a 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -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; } } -- 1.8.3.1