From 9e470375f65e8608d5dab194f7cb549daab98201 Mon Sep 17 00:00:00 2001 From: shadow Date: Fri, 31 Jul 2009 10:23:31 +0000 Subject: [PATCH] correctly handling request reference in error cases Branch HEAD b=20122 i=adilger i=panda --- lustre/ChangeLog | 5 +++++ lustre/include/obd_support.h | 2 +- lustre/llite/symlink.c | 12 ++++-------- lustre/mdt/mdt_handler.c | 2 ++ lustre/tests/sanity.sh | 11 +++++++++++ 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/lustre/ChangeLog b/lustre/ChangeLog index bf325c6..9b8bd80 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -13,6 +13,11 @@ tbd Sun Microsystems, Inc. removed cwd "./" (refer to Bugzilla 14399). * File join has been disabled in this release, refer to Bugzilla 16929. +Severity : normal +Bugzilla : 20122 +Description: don't panic if EPROTO was hit when reading symlink +Details : correctly handling request reference in error cases. + Severity : enhancement Bugzilla : 19856 Description: Add LustreNetLink, a kernel-userspace communcation path. diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index e482567..47dc072 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -206,6 +206,7 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type, #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141 #define OBD_FAIL_MDS_REINT_DELAY 0x142 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x143 +#define OBD_FAIL_MDS_READLINK_EPROTO 0x144 /* CMD */ #define OBD_FAIL_MDS_IS_SUBDIR_NET 0x180 @@ -314,7 +315,6 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type, #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c #define OBD_FAIL_PTLRPC_IMP_DEACTIVE 0x50d - #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f #define OBD_FAIL_PTLRPC_LONG_BULK_UNLINK 0x510 diff --git a/lustre/llite/symlink.c b/lustre/llite/symlink.c index ff1c99a..7db4a19 100644 --- a/lustre/llite/symlink.c +++ b/lustre/llite/symlink.c @@ -99,15 +99,11 @@ static int ll_readlink_internal(struct inode *inode, /* do not return an error if we cannot cache the symlink locally */ if (lli->lli_symlink_name) { memcpy(lli->lli_symlink_name, *symname, symlen); - ptlrpc_req_finished (*request); - *request = NULL; *symname = lli->lli_symlink_name; } - RETURN(0); - failed: - ptlrpc_req_finished (*request); +failed: RETURN (rc); } @@ -127,8 +123,8 @@ static int ll_readlink(struct dentry *dentry, char *buffer, int buflen) GOTO(out, rc); rc = vfs_readlink(dentry, buffer, buflen, symname); - ptlrpc_req_finished(request); out: + ptlrpc_req_finished(request); ll_inode_size_unlock(inode, 0); RETURN(rc); } @@ -187,10 +183,10 @@ static LL_FOLLOW_LINK_RETURN_TYPE ll_follow_link(struct dentry *dentry, we delay request releasing until ll_put_link then. */ RETURN(request); #else - if (request != NULL) { + if (lli->lli_symlink_name == NULL) { /* falling back to recursive follow link if the request * needs to be cleaned up still. */ - rc = vfs_follow_link(nd, symname); + rc = vfs_follow_link(nd, symname); GOTO(out, rc); } nd_set_link(nd, symname); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 2bb3866..6602382 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -523,6 +523,8 @@ 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; repbody->eadatasize = rc; /* NULL terminate */ diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index f838a5f..1752ca8 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -482,6 +482,17 @@ test_17h() { #bug 17378 } run_test 17h "create objects: lov_free_memmd() doesn't lbug" +test_17i() { #bug 20018 + mkdir -p $DIR/$tdir + local foo=$DIR/$tdir/$tfile + ln -s $foo $foo || error "create symlink failed" +#define OBD_FAIL_MDS_READLINK_EPROTO 0x143 + do_facet mds lctl set_param fail_loc=0x80000144 + ls -l $foo && error "error not detected" + return 0 +} +run_test 17i "don't panic on short symlink" + test_18() { touch $DIR/f ls $DIR || error -- 1.8.3.1