From: Fan Yong Date: Mon, 2 Jun 2014 12:17:51 +0000 (+0800) Subject: LU-4971 ldlm: drop redundant ibits lock interoperability check X-Git-Tag: 2.6.0-RC1~4 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=a1ef13bca025e09e10ce2d6e007013d0e187e6eb;hp=63851b5816bb30687fbf3750380d6b448e9400f1 LU-4971 ldlm: drop redundant ibits lock interoperability check In very old release (older than Lustre-1.8), if the client talks with the server that does not support ibits lock, then the client needs to convert it as plain lock. Such interoperability check and convertion is out of date for a long time. Drop it. Signed-off-by: Fan Yong Change-Id: I635df2767ed3b859d93b7ff0680e30ef07d94747 Reviewed-on: http://review.whamcloud.com/11004 Tested-by: Jenkins Reviewed-by: Andreas Dilger Reviewed-by: wangdi Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index a20ec4c..0044fb7a 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -423,6 +423,7 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type, #define OBD_FAIL_TGT_LAST_REPLAY 0x710 #define OBD_FAIL_TGT_CLIENT_ADD 0x711 #define OBD_FAIL_TGT_RCVG_FLAG 0x712 +#define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713 #define OBD_FAIL_MDC_REVALIDATE_PAUSE 0x800 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801 diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 2237ae1..b19b807 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -655,51 +655,12 @@ EXPORT_SYMBOL(__ldlm_handle2lock); */ void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc) { - struct obd_export *exp = lock->l_export ?: lock->l_conn_export; - - /* INODEBITS_INTEROP: If the other side does not support - * inodebits, reply with a plain lock descriptor. */ - if ((lock->l_resource->lr_type == LDLM_IBITS) && - (exp && !(exp_connect_flags(exp) & OBD_CONNECT_IBITS))) { - /* Make sure all the right bits are set in this lock we - are going to pass to client */ - LASSERTF(lock->l_policy_data.l_inodebits.bits == - (MDS_INODELOCK_LOOKUP | MDS_INODELOCK_UPDATE | - MDS_INODELOCK_LAYOUT), - "Inappropriate inode lock bits during " - "conversion " LPU64 "\n", - lock->l_policy_data.l_inodebits.bits); - - ldlm_res2desc(lock->l_resource, &desc->l_resource); - desc->l_resource.lr_type = LDLM_PLAIN; - - /* Convert "new" lock mode to something old client can - understand */ - if ((lock->l_req_mode == LCK_CR) || - (lock->l_req_mode == LCK_CW)) - desc->l_req_mode = LCK_PR; - else - desc->l_req_mode = lock->l_req_mode; - if ((lock->l_granted_mode == LCK_CR) || - (lock->l_granted_mode == LCK_CW)) { - desc->l_granted_mode = LCK_PR; - } else { - /* We never grant PW/EX locks to clients */ - LASSERT((lock->l_granted_mode != LCK_PW) && - (lock->l_granted_mode != LCK_EX)); - desc->l_granted_mode = lock->l_granted_mode; - } - - /* We do not copy policy here, because there is no - policy for plain locks */ - } else { - ldlm_res2desc(lock->l_resource, &desc->l_resource); - desc->l_req_mode = lock->l_req_mode; - desc->l_granted_mode = lock->l_granted_mode; - ldlm_convert_policy_to_wire(lock->l_resource->lr_type, - &lock->l_policy_data, - &desc->l_policy_data); - } + ldlm_res2desc(lock->l_resource, &desc->l_resource); + desc->l_req_mode = lock->l_req_mode; + desc->l_granted_mode = lock->l_granted_mode; + ldlm_convert_policy_to_wire(lock->l_resource->lr_type, + &lock->l_policy_data, + &desc->l_policy_data); } EXPORT_SYMBOL(ldlm_lock2desc); diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index 0fa66b0..51fb844 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -898,21 +898,8 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, /* for the local lock, add the reference */ ldlm_lock_addref_internal(lock, einfo->ei_mode); ldlm_lock2handle(lock, lockh); - if (policy != NULL) { - /* INODEBITS_INTEROP: If the server does not support - * inodebits, we will request a plain lock in the - * descriptor (ldlm_lock2desc() below) but use an - * inodebits lock internally with both bits set. - */ - if (einfo->ei_type == LDLM_IBITS && - !(exp_connect_flags(exp) & - OBD_CONNECT_IBITS)) - lock->l_policy_data.l_inodebits.bits = - MDS_INODELOCK_LOOKUP | - MDS_INODELOCK_UPDATE; - else - lock->l_policy_data = *policy; - } + if (policy != NULL) + lock->l_policy_data = *policy; if (einfo->ei_type == LDLM_EXTENT) { /* extent lock without policy is a bug */ diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 1ef1862..66b0eb4 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -2878,6 +2878,11 @@ static int mdt_tgt_connect(struct tgt_session_info *tsi) ENTRY; + if (OBD_FAIL_CHECK(OBD_FAIL_TGT_DELAY_CONDITIONAL) && + cfs_fail_val == + tsi2mdt_info(tsi)->mti_mdt->mdt_seq_site.ss_node_id) + schedule_timeout_and_set_state(TASK_UNINTERRUPTIBLE, HZ * 3); + rc = tgt_connect(tsi); if (rc != 0) RETURN(rc); @@ -4901,12 +4906,14 @@ static int mdt_connect_internal(struct obd_export *exp, data->ocd_connect_flags &= MDT_CONNECT_SUPPORTED; data->ocd_ibits_known &= MDS_INODELOCK_FULL; - /* If no known bits (which should not happen, probably, - as everybody should support LOOKUP and UPDATE bits at least) - revert to compat mode with plain locks. */ - if (!data->ocd_ibits_known && - data->ocd_connect_flags & OBD_CONNECT_IBITS) - data->ocd_connect_flags &= ~OBD_CONNECT_IBITS; + if (!(data->ocd_connect_flags & OBD_CONNECT_MDS_MDS) && + !(data->ocd_connect_flags & OBD_CONNECT_IBITS)) { + CWARN("%s: client %s does not support ibits lock, either " + "very old or an invalid client: flags "LPX64"\n", + mdt_obd_name(mdt), exp->exp_client_uuid.uuid, + data->ocd_connect_flags); + return -EBADE; + } if (!mdt->mdt_opts.mo_acl) data->ocd_connect_flags &= ~OBD_CONNECT_ACL; diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index f474dd7..720ce1e 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -1048,10 +1048,17 @@ finish: spin_unlock(&imp->imp_lock); - if (!ocd->ocd_ibits_known && - ocd->ocd_connect_flags & OBD_CONNECT_IBITS) - CERROR("Inodebits aware server returned zero compatible" - " bits?\n"); + if ((imp->imp_connect_flags_orig & OBD_CONNECT_IBITS) && + !(ocd->ocd_connect_flags & OBD_CONNECT_IBITS)) { + LCONSOLE_WARN("%s: MDS %s does not support ibits " + "lock, either very old or invalid: " + "requested "LPX64", replied "LPX64"\n", + imp->imp_obd->obd_name, + imp->imp_connection->c_remote_uuid.uuid, + imp->imp_connect_flags_orig, + ocd->ocd_connect_flags); + GOTO(out, rc = -EPROTO); + } if (!warned && (ocd->ocd_connect_flags & OBD_CONNECT_VERSION) && (ocd->ocd_version > LUSTRE_VERSION_CODE + diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 13f112c..0f7c7d4 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -12717,6 +12717,26 @@ test_239() { } run_test 239 "osp_sync test" +test_240() { + [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return + + mkdir -p $DIR/$tdir + + $LFS mkdir -i 0 $DIR/$tdir/d0 || + error "failed to mkdir $DIR/$tdir/d0 on MDT0" + $LFS mkdir -i 1 $DIR/$tdir/d0/d1 || + error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1" + + umount_client $MOUNT || error "umount failed" + #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713 + do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1 + mount_client $MOUNT || error "failed to mount client" + + echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT" + stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1" +} +run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)" + cleanup_test_300() { trap 0 umask $SAVE_UMASK