From 46c24ecd782c797d87565a8ecda6f00666fe7607 Mon Sep 17 00:00:00 2001 From: adilger Date: Wed, 31 Mar 2004 01:02:01 +0000 Subject: [PATCH] Don't copy lvb into possibly NULL reply on ldlm_handle_enqueue() error client won't use it anyways. Regression test for same. Fix secondary bug hit during regression tests in mds_mfd_close() cleanup. b=2983 --- lustre/ChangeLog | 7 ++++++- lustre/include/linux/obd_support.h | 2 ++ lustre/ldlm/ldlm_lockd.c | 7 ++++++- lustre/llite/file.c | 7 +++---- lustre/mdc/mdc_reint.c | 1 - lustre/mds/mds_open.c | 29 ++++++++++++++++------------- lustre/tests/recovery-small.sh | 32 +++++++++++++++++++++++++++++++- 7 files changed, 64 insertions(+), 21 deletions(-) diff --git a/lustre/ChangeLog b/lustre/ChangeLog index 5a2918b..8c489e1 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -1,3 +1,8 @@ +tbd Cluster File Systems, Inc. + * version 1.2.x + * Bug fixes + - don't copy lvb into (possibly NULL) reply on error (2983) + 2004-03-22 Cluster File Systems, Inc. * version 1.2.1 * bug fixes @@ -21,7 +26,7 @@ - don't oops on a deleted current working directory (2399) - handle hard links to targets without a parent properly (2517) - don't dereference NULL lock when racing during eviction (2867) - - don't grow lock extents when there are lots of conflicting locks (2919) + - don't grow lock extents when lots of conflicting locks (2919) 2004-03-04 Cluster File Systems, Inc. * version 1.2.0 diff --git a/lustre/include/linux/obd_support.h b/lustre/include/linux/obd_support.h index c39cb6f..2daa927 100644 --- a/lustre/include/linux/obd_support.h +++ b/lustre/include/linux/obd_support.h @@ -113,6 +113,8 @@ extern wait_queue_head_t obd_race_waitq; #define OBD_FAIL_LDLM_BL_CALLBACK 0x305 #define OBD_FAIL_LDLM_CP_CALLBACK 0x306 #define OBD_FAIL_LDLM_GL_CALLBACK 0x307 +#define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308 +#define OBD_FAIL_LDLM_ENQUEUE_INTENT_ERR 0x309 #define OBD_FAIL_OSC 0x400 #define OBD_FAIL_OSC_BRW_READ_BULK 0x401 diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index c88139f..b456ff6 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -617,6 +617,9 @@ int ldlm_handle_enqueue(struct ptlrpc_request *req, buffers = 2; } + if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR)) + GOTO(out, rc = -ENOMEM); + rc = lustre_pack_reply(req, buffers, size, NULL); if (rc) GOTO(out, rc); @@ -656,6 +659,7 @@ int ldlm_handle_enqueue(struct ptlrpc_request *req, err = lustre_pack_reply(req, 0, NULL, NULL); if (rc == 0) rc = err; + req->rq_status = rc; } /* The LOCK_CHANGED code in ldlm_lock_enqueue depends on this @@ -664,9 +668,10 @@ int ldlm_handle_enqueue(struct ptlrpc_request *req, LDLM_DEBUG(lock, "server-side enqueue handler, sending reply" "(err=%d, rc=%d)", err, rc); - if (lock->l_resource->lr_lvb_len > 0) { + if (lock->l_resource->lr_lvb_len > 0 && rc == 0) { void *lvb = lustre_msg_buf(req->rq_repmsg, 1, lock->l_resource->lr_lvb_len); + LASSERT(lvb != NULL); memcpy(lvb, lock->l_resource->lr_lvb_data, lock->l_resource->lr_lvb_len); } diff --git a/lustre/llite/file.c b/lustre/llite/file.c index b40f122..bc3f7f7 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -951,7 +951,7 @@ static int ll_lov_setea(struct inode *inode, struct file *file, { int flags = MDS_OPEN_HAS_OBJS | FMODE_WRITE; struct lov_user_md *lump; - int lum_size = sizeof(struct lov_user_md) + + int lum_size = sizeof(struct lov_user_md) + sizeof(struct lov_user_ost_data); int rc; ENTRY; @@ -963,8 +963,7 @@ static int ll_lov_setea(struct inode *inode, struct file *file, if (lump == NULL) { RETURN(-ENOMEM); } - rc = copy_from_user(lump, (struct lov_user_md *)arg, - lum_size); + rc = copy_from_user(lump, (struct lov_user_md *)arg, lum_size); if (rc) { OBD_FREE(lump, lum_size); RETURN(-EFAULT); @@ -1041,7 +1040,7 @@ int ll_file_ioctl(struct inode *inode, struct file *file, unsigned int cmd, case LL_IOC_LOV_SETSTRIPE: RETURN(ll_lov_setstripe(inode, file, arg)); case LL_IOC_LOV_SETEA: - RETURN( ll_lov_setea(inode, file, arg) ); + RETURN(ll_lov_setea(inode, file, arg)); case LL_IOC_LOV_GETSTRIPE: RETURN(ll_lov_getstripe(inode, arg)); case LL_IOC_RECREATE_OBJ: diff --git a/lustre/mdc/mdc_reint.c b/lustre/mdc/mdc_reint.c index d092270..a845347 100644 --- a/lustre/mdc/mdc_reint.c +++ b/lustre/mdc/mdc_reint.c @@ -41,7 +41,6 @@ static int mdc_reint(struct ptlrpc_request *request, struct mdc_rpc_lock *rpc_lock, int level) { int rc; - request->rq_send_state = level; diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c index 8b8bae0..c16b374 100644 --- a/lustre/mds/mds_open.c +++ b/lustre/mds/mds_open.c @@ -360,7 +360,6 @@ static int mds_create_objects(struct ptlrpc_request *req, int offset, RETURN(0); } - if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_MDS_ALLOC_OBDO)) GOTO(out_ids, rc = -ENOMEM); @@ -380,9 +379,9 @@ static int mds_create_objects(struct ptlrpc_request *req, int offset, OBD_MD_FLCTIME); if (!(rec->ur_flags & MDS_OPEN_HAS_OBJS)) { - /* check if things like lstripe/lfs stripe are sending us the ea */ + /* check if things like lfs setstripe are sending us the ea */ if (rec->ur_flags & MDS_OPEN_HAS_EA) { - rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE, + rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE, mds->mds_osc_exp, 0, &lsm, rec->ur_eadata); if (rc) @@ -952,9 +951,10 @@ int mds_open(struct mds_update_record *rec, int offset, if ((rec->ur_flags & MDS_OPEN_DIRECTORY) && !S_ISDIR(dchild->d_inode->i_mode)) GOTO(cleanup, rc = -ENOTDIR); - - if (S_ISDIR(dchild->d_inode->i_mode)) { - if (rec->ur_flags & MDS_OPEN_CREAT || rec->ur_flags & FMODE_WRITE) { + + if (S_ISDIR(dchild->d_inode->i_mode)) { + if (rec->ur_flags & MDS_OPEN_CREAT || + rec->ur_flags & FMODE_WRITE) { /*we are tryying to create or write a exist dir*/ GOTO(cleanup, rc = -EISDIR); } @@ -1021,7 +1021,6 @@ int mds_mfd_close(struct ptlrpc_request *req, struct obd_device *obd, void *handle = NULL; struct mds_body *request_body = NULL, *reply_body = NULL; struct dentry_params dp; - struct lov_mds_md *lmm; ENTRY; if (req != NULL) { @@ -1045,6 +1044,7 @@ int mds_mfd_close(struct ptlrpc_request *req, struct obd_device *obd, } if (last_orphan && unlink_orphan) { + int stripe_count = 0; LASSERT(rc == 0); /* mds_put_write_access must have succeeded */ CDEBUG(D_HA, "destroying orphan object %s\n", fidname); @@ -1062,18 +1062,21 @@ int mds_mfd_close(struct ptlrpc_request *req, struct obd_device *obd, LASSERT(pending_child->d_inode != NULL); cleanup_phase = 2; /* dput(pending_child) when finished */ - lmm = lustre_msg_buf(req->rq_repmsg, 1, 0); - handle = fsfilt_start_log(obd, pending_dir, - FSFILT_OP_UNLINK, NULL, - le32_to_cpu(lmm->lmm_stripe_count)); + if (req != NULL) { + struct lov_mds_md *lmm = lustre_msg_buf(req->rq_repmsg, + 1, 0); + stripe_count = le32_to_cpu(lmm->lmm_stripe_count); + } + + handle = fsfilt_start_log(obd, pending_dir, FSFILT_OP_UNLINK, + NULL, stripe_count); if (IS_ERR(handle)) { rc = PTR_ERR(handle); handle = NULL; GOTO(cleanup, rc); } - if (req != NULL && - (reply_body->valid & OBD_MD_FLEASIZE) && + if (req != NULL && (reply_body->valid & OBD_MD_FLEASIZE) && mds_log_op_unlink(obd, pending_child->d_inode, lustre_msg_buf(req->rq_repmsg, 1, 0), req->rq_repmsg->buflens[1], diff --git a/lustre/tests/recovery-small.sh b/lustre/tests/recovery-small.sh index 4b2c37f..57ab438 100755 --- a/lustre/tests/recovery-small.sh +++ b/lustre/tests/recovery-small.sh @@ -2,6 +2,9 @@ set -e +# 17 = bug 2732 2986 +ALWAYS_EXCEPT="17 19b" + LUSTRE=${LUSTRE:-`dirname $0`/..} UPCALL=${UPCALL:-$PWD/recovery-small-upcall.sh} . $LUSTRE/tests/test-framework.sh @@ -220,8 +223,35 @@ test_19b() { drop_ldlm_cancel multiop $f Ow || echo "client evicted, as expected" do_facet client munlink $f || return 4 - } run_test 19b "test expired_lock_main on ost (2867)" +test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup + mkdir -p $DIR/$tdir + multiop $DIR/$tdir/${tfile} O_wc & + MULTI_PID=$! + usleep 500 + cancel_lru_locks OSC +#define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308 + do_facet ost sysctl -w lustre.fail_loc=0x80000308 + set -vx + kill -USR1 $MULTI_PID + wait $MULTI_PID + rc=$? + [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true + set +vx +} +run_test 20a "ldlm_handle_enqueue error (should return error)" + +test_20b() { # bug 2986 - ldlm_handle_enqueue error during open + mkdir $DIR/$tdir + touch $DIR/$tdir/${tfile} + cancel_lru_locks OSC +#define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308 + do_facet ost sysctl -w lustre.fail_loc=0x80000308 + dd if=/etc/hosts of=$DIR/$tdir/$tfile && \ + error "didn't fail open enqueue" || true +} +run_test 20b "ldlm_handle_enqueue error (should return error)" + $CLEANUP -- 1.8.3.1