From 6d460a058a13a6db9cf44cda1fd8f97cefdec42a Mon Sep 17 00:00:00 2001 From: shaver Date: Wed, 30 Oct 2002 20:38:28 +0000 Subject: [PATCH] - Bug 296: remove LDLM_MDSINTENT to fix mismatches with LDLM_PLAIN locks. We now use LDLM_FL_HAS_INTENT in flags, instead. - Remove some over-verbose debugging in lookup2_finish. - Automatically reactivate OSC when recovery reconnects successfully. --- lustre/include/linux/lustre_dlm.h | 4 ++-- lustre/ldlm/ldlm_lock.c | 25 +++++++++++++++++-------- lustre/ldlm/ldlm_lockd.c | 5 +++-- lustre/llite/dcache.c | 8 ++++---- lustre/llite/dir.c | 4 ++-- lustre/llite/namei.c | 8 +++----- lustre/llite/recover.c | 36 ++++++++++++++++++++++++------------ lustre/mdc/mdc_request.c | 5 +++-- 8 files changed, 58 insertions(+), 37 deletions(-) diff --git a/lustre/include/linux/lustre_dlm.h b/lustre/include/linux/lustre_dlm.h index 5dcd21f..3558013 100644 --- a/lustre/include/linux/lustre_dlm.h +++ b/lustre/include/linux/lustre_dlm.h @@ -43,6 +43,7 @@ typedef enum { #define LDLM_FL_INTENT_ONLY (1 << 10) /* don't grant lock, just do intent */ #define LDLM_FL_LOCAL_ONLY (1 << 11) /* see ldlm_cli_cancel_unused */ #define LDLM_FL_NO_CALLBACK (1 << 12) /* see ldlm_cli_cancel_unused */ +#define LDLM_FL_HAS_INTENT (1 << 13) /* lock request has intent */ #define LDLM_CB_BLOCKING 1 #define LDLM_CB_CANCELING 2 @@ -166,10 +167,9 @@ typedef int (*ldlm_res_policy)(struct ldlm_lock *lock, void *req_cookie, #define LDLM_PLAIN 10 #define LDLM_EXTENT 11 -#define LDLM_MDSINTENT 12 #define LDLM_MIN_TYPE 10 -#define LDLM_MAX_TYPE 12 +#define LDLM_MAX_TYPE 11 extern ldlm_res_compat ldlm_res_compat_table []; extern ldlm_res_policy ldlm_res_policy_table []; diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 269f394..40dc2ff 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -45,7 +45,6 @@ char *ldlm_lockname[] = { char *ldlm_typename[] = { [LDLM_PLAIN] "PLN", [LDLM_EXTENT] "EXT", - [LDLM_MDSINTENT] "INT" }; char *ldlm_it2str(int it) @@ -98,24 +97,34 @@ static int ldlm_plain_compat(struct ldlm_lock *a, struct ldlm_lock *b); ldlm_res_compat ldlm_res_compat_table[] = { [LDLM_PLAIN] ldlm_plain_compat, [LDLM_EXTENT] ldlm_extent_compat, - [LDLM_MDSINTENT] ldlm_plain_compat }; +static ldlm_res_policy ldlm_intent_policy_func; + +static int ldlm_plain_policy(struct ldlm_lock *lock, void *req_cookie, + ldlm_mode_t mode, int flags, void *data) +{ + if ((flags & LDLM_FL_HAS_INTENT) && ldlm_intent_policy_func) { + return ldlm_intent_policy_func(lock, req_cookie, mode, flags, + data); + } + + return ELDLM_OK; +} + ldlm_res_policy ldlm_res_policy_table[] = { - [LDLM_PLAIN] NULL, + [LDLM_PLAIN] ldlm_plain_policy, [LDLM_EXTENT] ldlm_extent_policy, - [LDLM_MDSINTENT] NULL }; -void ldlm_register_intent(int (*arg) (struct ldlm_lock * lock, void *req_cookie, - ldlm_mode_t mode, int flags, void *data)) +void ldlm_register_intent(ldlm_res_policy arg) { - ldlm_res_policy_table[LDLM_MDSINTENT] = arg; + ldlm_intent_policy_func = arg; } void ldlm_unregister_intent(void) { - ldlm_res_policy_table[LDLM_MDSINTENT] = NULL; + ldlm_intent_policy_func = NULL; } /* diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index cc4ebe5..494b82b 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -213,7 +213,9 @@ int ldlm_handle_enqueue(struct ptlrpc_request *req) LDLM_DEBUG_NOLOCK("server-side enqueue handler START"); dlm_req = lustre_msg_buf(req->rq_reqmsg, 0); - if (dlm_req->lock_desc.l_resource.lr_type == LDLM_MDSINTENT) { + flags = dlm_req->lock_flags; + if (dlm_req->lock_desc.l_resource.lr_type == LDLM_PLAIN && + (flags & LDLM_FL_HAS_INTENT)) { /* In this case, the reply buffer is allocated deep in * local_lock_enqueue by the policy function. */ cookie = req; @@ -245,7 +247,6 @@ int ldlm_handle_enqueue(struct ptlrpc_request *req) sizeof(lock->l_remote_handle)); LDLM_DEBUG(lock, "server-side enqueue handler, new lock created"); - flags = dlm_req->lock_flags; err = ldlm_lock_enqueue(lock, cookie, cookielen, &flags, ldlm_server_completion_ast, ldlm_server_blocking_ast); diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c index fbbc305..0befbcc 100644 --- a/lustre/llite/dcache.c +++ b/lustre/llite/dcache.c @@ -123,14 +123,14 @@ int ll_revalidate2(struct dentry *de, int flags, struct lookup_intent *it) CDEBUG(D_INFO, "trying to match res "LPU64"\n", res_id[0]); - if (ldlm_lock_match(obddev->obd_namespace, res_id, LDLM_MDSINTENT, - NULL, 0, LCK_PR, &lockh)) { + if (ldlm_lock_match(obddev->obd_namespace, res_id, LDLM_PLAIN, NULL, 0, + LCK_PR, &lockh)) { ldlm_lock_decref(&lockh, LCK_PR); GOTO(out, rc = 1); } - if (ldlm_lock_match(obddev->obd_namespace, res_id, LDLM_MDSINTENT, - NULL, 0, LCK_PW, &lockh)) { + if (ldlm_lock_match(obddev->obd_namespace, res_id, LDLM_PLAIN, NULL, 0, + LCK_PW, &lockh)) { ldlm_lock_decref(&lockh, LCK_PW); GOTO(out, rc = 1); } diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 32a4e32..4384208 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -81,8 +81,8 @@ static int ll_dir_readpage(struct file *file, struct page *page) GOTO(readpage_out, rc); } - rc = mdc_enqueue(&sbi->ll_mdc_conn, LDLM_MDSINTENT, &it, LCK_PR, - inode, NULL, &lockh, NULL, 0, inode, sizeof(*inode)); + rc = mdc_enqueue(&sbi->ll_mdc_conn, LDLM_PLAIN, &it, LCK_PR, inode, + NULL, &lockh, NULL, 0, inode, sizeof(*inode)); request = (struct ptlrpc_request *)it.it_data; if (request) ptlrpc_req_finished(request); diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index c09924d..9e5eaa6 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -197,9 +197,8 @@ int ll_intent_lock(struct inode *parent, struct dentry **de, it->it_data = NULL; } - rc = mdc_enqueue(&sbi->ll_mdc_conn, LDLM_MDSINTENT, it, lock_mode, - parent, dentry, &lockh, tgt, tgtlen, parent, - sizeof(*parent)); + rc = mdc_enqueue(&sbi->ll_mdc_conn, LDLM_PLAIN, it, lock_mode, parent, + dentry, &lockh, tgt, tgtlen, parent, sizeof(*parent)); if (rc < 0) RETURN(rc); memcpy(it->it_lock_handle, &lockh, sizeof(lockh)); @@ -426,8 +425,7 @@ lookup2_finish(int flag, struct ptlrpc_request *request, struct dentry **de, dentry->d_op = &ll_d_ops; if (ll_d2d(dentry) == NULL) { ll_set_dd(dentry); - } else - CERROR("NOT allocating fsdata - already set\n"); + } if (dentry == saved) d_add(dentry, inode); diff --git a/lustre/llite/recover.c b/lustre/llite/recover.c index d512ce2..b688fb9 100644 --- a/lustre/llite/recover.c +++ b/lustre/llite/recover.c @@ -69,33 +69,26 @@ static void abort_inflight_for_import(struct obd_import *imp) } } -static void prepare_osc(struct obd_import *imp) +static void set_osc_active(struct obd_import *imp, int active) { - int rc; - struct ldlm_namespace *ns = imp->imp_obd->obd_namespace; struct obd_device *notify_obd = imp->imp_obd->u.cli.cl_containing_lov; - CDEBUG(D_HA, "invalidating all locks for OST imp %p (to %s):\n", - imp, imp->imp_connection->c_remote_uuid); - ldlm_namespace_dump(ns); - ldlm_namespace_cleanup(ns, 1 /* no network ops */); - - abort_inflight_for_import(imp); - if (notify_obd == NULL) return; /* How gross is _this_? */ if (!list_empty(¬ify_obd->obd_exports)) { + int rc; struct lustre_handle fakeconn; struct obd_ioctl_data ioc_data; struct obd_export *exp = list_entry(notify_obd->obd_exports.next, struct obd_export, exp_obd_chain); + fakeconn.addr = (__u64)(unsigned long)exp; fakeconn.cookie = exp->exp_cookie; ioc_data.ioc_inlbuf1 = imp->imp_obd->obd_uuid; - ioc_data.ioc_offset = 0; /* inactive */ + ioc_data.ioc_offset = active; rc = obd_iocontrol(IOC_LOV_SET_OSC_ACTIVE, &fakeconn, sizeof ioc_data, &ioc_data, NULL); if (rc) @@ -109,6 +102,20 @@ static void prepare_osc(struct obd_import *imp) } } +static void prepare_osc(struct obd_import *imp) +{ + struct ldlm_namespace *ns = imp->imp_obd->obd_namespace; + + CDEBUG(D_HA, "invalidating all locks for OST imp %p (to %s):\n", + imp, imp->imp_connection->c_remote_uuid); + ldlm_namespace_dump(ns); + ldlm_namespace_cleanup(ns, 1 /* no network ops */); + + abort_inflight_for_import(imp); + + set_osc_active(imp, 0 /* inactive */); +} + static void prepare_mdc(struct obd_import *imp) { struct ldlm_namespace *ns = imp->imp_obd->obd_namespace; @@ -134,7 +141,12 @@ static int ll_prepare_recovery(struct ptlrpc_connection *conn) static void reconnect_osc(struct obd_import *imp) { - (void)ptlrpc_reconnect_import(imp, OST_CONNECT); + int rc = ptlrpc_reconnect_import(imp, OST_CONNECT); + if (rc == 0) + set_osc_active(imp, 1 /* active */); + else + CDEBUG(D_HA, "reconnection failed, not reactivating OSC %s\n", + imp->imp_obd->obd_uuid); } static int reconnect_mdc(struct obd_import *imp) diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index acf6839..7c63d23 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -284,7 +284,8 @@ static void fixup_req_for_recreate(struct ptlrpc_request *fixreq, if (fixreq->rq_reqmsg->opc == LDLM_ENQUEUE) { lockreq = lustre_msg_buf(fixreq->rq_reqmsg, 0); - if (lockreq->lock_desc.l_resource.lr_type != LDLM_MDSINTENT) { + if (lockreq->lock_desc.l_resource.lr_type != LDLM_PLAIN && + !(lockreq->lock_flags & LDLM_FL_HAS_INTENT)) { DEBUG_REQ(D_HA, fixreq, "non-intent lock, skipping"); return; } @@ -408,7 +409,7 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type, struct obd_device *obddev = class_conn2obd(conn); __u64 res_id[RES_NAME_SIZE] = {dir->i_ino, (__u64)dir->i_generation}; int size[6] = {sizeof(struct ldlm_request), sizeof(struct ldlm_intent)}; - int rc, flags = 0; + int rc, flags = LDLM_FL_HAS_INTENT; int repsize[3] = {sizeof(struct ldlm_reply), sizeof(struct mds_body), obddev->u.cli.cl_max_mds_easize}; -- 1.8.3.1