1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
38 # define EXPORT_SYMTAB
40 #define DEBUG_SUBSYSTEM S_LDLM
43 # include <libcfs/libcfs.h>
45 # include <liblustre.h>
48 #include <lustre_mds.h>
49 #include <lustre_dlm.h>
50 #include <lustre_net.h>
51 #include "ldlm_internal.h"
53 /* @priority: if non-zero, move the selected to the list head
54 * @create: if zero, only search in existed connections
56 static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid,
57 int priority, int create)
59 struct ptlrpc_connection *ptlrpc_conn;
60 struct obd_import_conn *imp_conn = NULL, *item;
64 if (!create && !priority) {
65 CDEBUG(D_HA, "Nothing to do\n");
69 ptlrpc_conn = ptlrpc_uuid_to_connection(uuid);
71 CDEBUG(D_HA, "can't find connection %s\n", uuid->uuid);
76 OBD_ALLOC(imp_conn, sizeof(*imp_conn));
78 GOTO(out_put, rc = -ENOMEM);
82 spin_lock(&imp->imp_lock);
83 list_for_each_entry(item, &imp->imp_conn_list, oic_item) {
84 if (obd_uuid_equals(uuid, &item->oic_uuid)) {
86 list_del(&item->oic_item);
87 list_add(&item->oic_item, &imp->imp_conn_list);
88 item->oic_last_attempt = 0;
90 CDEBUG(D_HA, "imp %p@%s: found existing conn %s%s\n",
91 imp, imp->imp_obd->obd_name, uuid->uuid,
92 (priority ? ", moved to head" : ""));
93 spin_unlock(&imp->imp_lock);
94 GOTO(out_free, rc = 0);
99 imp_conn->oic_conn = ptlrpc_conn;
100 imp_conn->oic_uuid = *uuid;
101 item->oic_last_attempt = 0;
103 list_add(&imp_conn->oic_item, &imp->imp_conn_list);
105 list_add_tail(&imp_conn->oic_item, &imp->imp_conn_list);
106 CDEBUG(D_HA, "imp %p@%s: add connection %s at %s\n",
107 imp, imp->imp_obd->obd_name, uuid->uuid,
108 (priority ? "head" : "tail"));
110 spin_unlock(&imp->imp_lock);
111 GOTO(out_free, rc = -ENOENT);
115 spin_unlock(&imp->imp_lock);
119 OBD_FREE(imp_conn, sizeof(*imp_conn));
121 ptlrpc_connection_put(ptlrpc_conn);
125 int import_set_conn_priority(struct obd_import *imp, struct obd_uuid *uuid)
127 return import_set_conn(imp, uuid, 1, 0);
130 int client_import_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
133 return import_set_conn(imp, uuid, priority, 1);
136 int client_import_del_conn(struct obd_import *imp, struct obd_uuid *uuid)
138 struct obd_import_conn *imp_conn;
139 struct obd_export *dlmexp;
143 spin_lock(&imp->imp_lock);
144 if (list_empty(&imp->imp_conn_list)) {
145 LASSERT(!imp->imp_connection);
149 list_for_each_entry(imp_conn, &imp->imp_conn_list, oic_item) {
150 if (!obd_uuid_equals(uuid, &imp_conn->oic_uuid))
152 LASSERT(imp_conn->oic_conn);
154 /* is current conn? */
155 if (imp_conn == imp->imp_conn_current) {
156 LASSERT(imp_conn->oic_conn == imp->imp_connection);
158 if (imp->imp_state != LUSTRE_IMP_CLOSED &&
159 imp->imp_state != LUSTRE_IMP_DISCON) {
160 CERROR("can't remove current connection\n");
161 GOTO(out, rc = -EBUSY);
164 ptlrpc_connection_put(imp->imp_connection);
165 imp->imp_connection = NULL;
167 dlmexp = class_conn2export(&imp->imp_dlm_handle);
168 if (dlmexp && dlmexp->exp_connection) {
169 LASSERT(dlmexp->exp_connection ==
171 ptlrpc_connection_put(dlmexp->exp_connection);
172 dlmexp->exp_connection = NULL;
176 list_del(&imp_conn->oic_item);
177 ptlrpc_connection_put(imp_conn->oic_conn);
178 OBD_FREE(imp_conn, sizeof(*imp_conn));
179 CDEBUG(D_HA, "imp %p@%s: remove connection %s\n",
180 imp, imp->imp_obd->obd_name, uuid->uuid);
185 spin_unlock(&imp->imp_lock);
187 CERROR("connection %s not found\n", uuid->uuid);
191 /* configure an RPC client OBD device
196 * 3 - inactive-on-startup
198 int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf)
200 struct lustre_cfg* lcfg = buf;
201 struct client_obd *cli = &obddev->u.cli;
202 struct obd_import *imp;
203 struct obd_uuid server_uuid;
204 int rq_portal, rp_portal, connect_op;
205 char *name = obddev->obd_type->typ_name;
209 /* In a more perfect world, we would hang a ptlrpc_client off of
210 * obd_type and just use the values from there. */
211 if (!strcmp(name, LUSTRE_OSC_NAME)) {
213 /* Can be removed in Lustre 1.8, for compatibility only */
214 rq_portal = OST_IO_PORTAL;
216 rq_portal = OST_REQUEST_PORTAL;
218 rp_portal = OSC_REPLY_PORTAL;
219 connect_op = OST_CONNECT;
220 } else if (!strcmp(name, LUSTRE_MDC_NAME)) {
221 rq_portal = MDS_REQUEST_PORTAL;
222 rp_portal = MDC_REPLY_PORTAL;
223 connect_op = MDS_CONNECT;
224 } else if (!strcmp(name, LUSTRE_MGC_NAME)) {
225 rq_portal = MGS_REQUEST_PORTAL;
226 rp_portal = MGC_REPLY_PORTAL;
227 connect_op = MGS_CONNECT;
229 CERROR("unknown client OBD type \"%s\", can't setup\n",
234 if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) {
235 CERROR("requires a TARGET UUID\n");
239 if (LUSTRE_CFG_BUFLEN(lcfg, 1) > 37) {
240 CERROR("client UUID must be less than 38 characters\n");
244 if (LUSTRE_CFG_BUFLEN(lcfg, 2) < 1) {
245 CERROR("setup requires a SERVER UUID\n");
249 if (LUSTRE_CFG_BUFLEN(lcfg, 2) > 37) {
250 CERROR("target UUID must be less than 38 characters\n");
254 init_rwsem(&cli->cl_sem);
255 sema_init(&cli->cl_mgc_sem, 1);
256 cli->cl_conn_count = 0;
257 memcpy(server_uuid.uuid, lustre_cfg_buf(lcfg, 2),
258 min_t(unsigned int, LUSTRE_CFG_BUFLEN(lcfg, 2),
259 sizeof(server_uuid)));
262 cli->cl_avail_grant = 0;
263 /* FIXME: should limit this for the sum of all cl_dirty_max */
264 cli->cl_dirty_max = OSC_MAX_DIRTY_DEFAULT * 1024 * 1024;
265 if (cli->cl_dirty_max >> CFS_PAGE_SHIFT > num_physpages / 8)
266 cli->cl_dirty_max = num_physpages << (CFS_PAGE_SHIFT - 3);
267 CFS_INIT_LIST_HEAD(&cli->cl_cache_waiters);
268 CFS_INIT_LIST_HEAD(&cli->cl_loi_ready_list);
269 CFS_INIT_LIST_HEAD(&cli->cl_loi_hp_ready_list);
270 CFS_INIT_LIST_HEAD(&cli->cl_loi_write_list);
271 CFS_INIT_LIST_HEAD(&cli->cl_loi_read_list);
272 client_obd_list_lock_init(&cli->cl_loi_list_lock);
273 cli->cl_r_in_flight = 0;
274 cli->cl_w_in_flight = 0;
275 spin_lock_init(&cli->cl_read_rpc_hist.oh_lock);
276 spin_lock_init(&cli->cl_write_rpc_hist.oh_lock);
277 spin_lock_init(&cli->cl_read_page_hist.oh_lock);
278 spin_lock_init(&cli->cl_write_page_hist.oh_lock);
279 spin_lock_init(&cli->cl_read_offset_hist.oh_lock);
280 spin_lock_init(&cli->cl_write_offset_hist.oh_lock);
281 cfs_waitq_init(&cli->cl_destroy_waitq);
282 atomic_set(&cli->cl_destroy_in_flight, 0);
283 #ifdef ENABLE_CHECKSUM
284 /* Turn on checksumming by default. */
285 cli->cl_checksum = 1;
287 * The supported checksum types will be worked out at connect time
288 * Set cl_chksum* to CRC32 for now to avoid returning screwed info
291 cli->cl_cksum_type = cli->cl_supp_cksum_types = OBD_CKSUM_CRC32;
293 atomic_set(&cli->cl_resends, OSC_DEFAULT_RESENDS);
295 /* This value may be changed at connect time in
296 ptlrpc_connect_interpret. */
297 cli->cl_max_pages_per_rpc = min((int)PTLRPC_MAX_BRW_PAGES,
298 (int)(1024 * 1024 >> CFS_PAGE_SHIFT));
300 if (!strcmp(name, LUSTRE_MDC_NAME)) {
301 cli->cl_max_rpcs_in_flight = MDC_MAX_RIF_DEFAULT;
302 } else if (num_physpages >> (20 - CFS_PAGE_SHIFT) <= 128 /* MB */) {
303 cli->cl_max_rpcs_in_flight = 2;
304 } else if (num_physpages >> (20 - CFS_PAGE_SHIFT) <= 256 /* MB */) {
305 cli->cl_max_rpcs_in_flight = 3;
306 } else if (num_physpages >> (20 - CFS_PAGE_SHIFT) <= 512 /* MB */) {
307 cli->cl_max_rpcs_in_flight = 4;
309 cli->cl_max_rpcs_in_flight = OSC_MAX_RIF_DEFAULT;
313 CERROR("ldlm_get_ref failed: %d\n", rc);
317 ptlrpc_init_client(rq_portal, rp_portal, name,
318 &obddev->obd_ldlm_client);
320 imp = class_new_import(obddev);
322 GOTO(err_ldlm, rc = -ENOENT);
323 imp->imp_client = &obddev->obd_ldlm_client;
324 imp->imp_connect_op = connect_op;
325 imp->imp_initial_recov = 1;
326 imp->imp_initial_recov_bk = 0;
327 CFS_INIT_LIST_HEAD(&imp->imp_pinger_chain);
328 memcpy(cli->cl_target_uuid.uuid, lustre_cfg_buf(lcfg, 1),
329 LUSTRE_CFG_BUFLEN(lcfg, 1));
330 class_import_put(imp);
332 rc = client_import_add_conn(imp, &server_uuid, 1);
334 CERROR("can't add initial connection\n");
335 GOTO(err_import, rc);
338 cli->cl_import = imp;
339 /* cli->cl_max_mds_{easize,cookiesize} updated by mdc_init_ea_size() */
340 cli->cl_max_mds_easize = sizeof(struct lov_mds_md_v3);
341 cli->cl_max_mds_cookiesize = sizeof(struct llog_cookie);
343 if (LUSTRE_CFG_BUFLEN(lcfg, 3) > 0) {
344 if (!strcmp(lustre_cfg_string(lcfg, 3), "inactive")) {
345 CDEBUG(D_HA, "marking %s %s->%s as inactive\n",
346 name, obddev->obd_name,
347 cli->cl_target_uuid.uuid);
348 spin_lock(&imp->imp_lock);
349 imp->imp_invalid = 1;
350 spin_unlock(&imp->imp_lock);
354 cli->cl_qchk_stat = CL_NOT_QUOTACHECKED;
359 class_destroy_import(imp);
367 int client_obd_cleanup(struct obd_device *obddev)
374 /* ->o_connect() method for client side (OSC and MDC and MGC) */
375 int client_connect_import(struct lustre_handle *dlm_handle,
376 struct obd_device *obd, struct obd_uuid *cluuid,
377 struct obd_connect_data *data, void *localdata)
379 struct client_obd *cli = &obd->u.cli;
380 struct obd_import *imp = cli->cl_import;
381 struct obd_export *exp;
382 struct obd_connect_data *ocd;
383 struct ldlm_namespace *to_be_freed = NULL;
387 down_write(&cli->cl_sem);
388 rc = class_connect(dlm_handle, obd, cluuid);
392 cli->cl_conn_count++;
393 if (cli->cl_conn_count > 1)
395 exp = class_conn2export(dlm_handle);
397 if (obd->obd_namespace != NULL)
398 CERROR("already have namespace!\n");
399 obd->obd_namespace = ldlm_namespace_new(obd, obd->obd_name,
400 LDLM_NAMESPACE_CLIENT,
401 LDLM_NAMESPACE_GREEDY);
402 if (obd->obd_namespace == NULL)
403 GOTO(out_disco, rc = -ENOMEM);
405 imp->imp_dlm_handle = *dlm_handle;
406 rc = ptlrpc_init_import(imp);
410 ocd = &imp->imp_connect_data;
413 imp->imp_connect_flags_orig = data->ocd_connect_flags;
416 rc = ptlrpc_connect_import(imp, NULL);
418 LASSERT (imp->imp_state == LUSTRE_IMP_DISCON);
421 LASSERT(exp->exp_connection);
424 LASSERT((ocd->ocd_connect_flags & data->ocd_connect_flags) ==
425 ocd->ocd_connect_flags);
426 data->ocd_connect_flags = ocd->ocd_connect_flags;
429 ptlrpc_pinger_add_import(imp);
434 ldlm_namespace_free_prior(obd->obd_namespace, imp, 0);
435 to_be_freed = obd->obd_namespace;
436 obd->obd_namespace = NULL;
438 cli->cl_conn_count--;
439 class_disconnect(exp);
441 class_export_put(exp);
444 up_write(&cli->cl_sem);
446 ldlm_namespace_free_post(to_be_freed);
450 int client_disconnect_export(struct obd_export *exp)
452 struct obd_device *obd = class_exp2obd(exp);
453 struct client_obd *cli;
454 struct obd_import *imp;
455 struct ldlm_namespace *to_be_freed = NULL;
460 CERROR("invalid export for disconnect: exp %p cookie "LPX64"\n",
461 exp, exp ? exp->exp_handle.h_cookie : -1);
466 imp = cli->cl_import;
468 down_write(&cli->cl_sem);
469 if (!cli->cl_conn_count) {
470 CERROR("disconnecting disconnected device (%s)\n",
472 GOTO(out_sem, rc = -EINVAL);
475 cli->cl_conn_count--;
476 if (cli->cl_conn_count)
477 GOTO(out_no_disconnect, rc = 0);
479 /* Mark import deactivated now, so we don't try to reconnect if any
480 * of the cleanup RPCs fails (e.g. ldlm cancel, etc). We don't
481 * fully deactivate the import, or that would drop all requests. */
482 spin_lock(&imp->imp_lock);
483 imp->imp_deactive = 1;
484 spin_unlock(&imp->imp_lock);
486 /* Some non-replayable imports (MDS's OSCs) are pinged, so just
487 * delete it regardless. (It's safe to delete an import that was
489 (void)ptlrpc_pinger_del_import(imp);
491 if (obd->obd_namespace != NULL) {
492 /* obd_force == local only */
493 ldlm_cli_cancel_unused(obd->obd_namespace, NULL,
494 obd->obd_force ? LDLM_FL_LOCAL_ONLY:0,
496 ldlm_namespace_free_prior(obd->obd_namespace, imp,
498 to_be_freed = obd->obd_namespace;
501 rc = ptlrpc_disconnect_import(imp, 0);
503 ptlrpc_invalidate_import(imp);
504 /* set obd_namespace to NULL only after invalidate, because we can have
505 * some connect requests in flight, and his need store a connect flags
506 * in obd_namespace. bug 14260 */
507 obd->obd_namespace = NULL;
509 if (imp->imp_rq_pool) {
510 ptlrpc_free_rq_pool(imp->imp_rq_pool);
511 imp->imp_rq_pool = NULL;
513 class_destroy_import(imp);
514 cli->cl_import = NULL;
518 err = class_disconnect(exp);
522 up_write(&cli->cl_sem);
524 ldlm_namespace_free_post(to_be_freed);
528 /* --------------------------------------------------------------------------
529 * from old lib/target.c
530 * -------------------------------------------------------------------------- */
532 int target_handle_reconnect(struct lustre_handle *conn, struct obd_export *exp,
533 struct obd_uuid *cluuid)
536 if (exp->exp_connection && exp->exp_imp_reverse) {
537 struct lustre_handle *hdl;
538 hdl = &exp->exp_imp_reverse->imp_remote_handle;
539 /* Might be a re-connect after a partition. */
540 if (!memcmp(&conn->cookie, &hdl->cookie, sizeof conn->cookie)) {
541 CWARN("%s: %s reconnecting\n", exp->exp_obd->obd_name,
543 conn->cookie = exp->exp_handle.h_cookie;
544 /* target_handle_connect() treats EALREADY and
545 * -EALREADY differently. EALREADY means we are
546 * doing a valid reconnect from the same client. */
549 CERROR("%s reconnecting from %s, "
550 "handle mismatch (ours "LPX64", theirs "
551 LPX64")\n", cluuid->uuid,
552 exp->exp_connection->c_remote_uuid.uuid,
553 hdl->cookie, conn->cookie);
554 memset(conn, 0, sizeof *conn);
555 /* target_handle_connect() treats EALREADY and
556 * -EALREADY differently. -EALREADY is an error
557 * (same UUID, different handle). */
562 conn->cookie = exp->exp_handle.h_cookie;
563 CDEBUG(D_HA, "connect export for UUID '%s' at %p, cookie "LPX64"\n",
564 cluuid->uuid, exp, conn->cookie);
568 void target_client_add_cb(struct obd_device *obd, __u64 transno, void *cb_data,
571 struct obd_export *exp = cb_data;
573 CDEBUG(D_RPCTRACE, "%s: committing for initial connect of %s\n",
574 obd->obd_name, exp->exp_client_uuid.uuid);
576 spin_lock(&exp->exp_lock);
577 exp->exp_need_sync = 0;
578 spin_unlock(&exp->exp_lock);
580 EXPORT_SYMBOL(target_client_add_cb);
583 target_start_and_reset_recovery_timer(struct obd_device *obd,
584 svc_handler_t handler,
585 struct ptlrpc_request *req,
587 void target_stop_recovery(void *, int);
588 int target_recovery_check_and_stop(struct obd_device *obd)
590 int abort_recovery = 0;
592 spin_lock_bh(&obd->obd_processing_task_lock);
593 abort_recovery = obd->obd_abort_recovery;
594 spin_unlock_bh(&obd->obd_processing_task_lock);
595 if (abort_recovery) {
596 target_stop_recovery(obd, 0);
601 EXPORT_SYMBOL(target_recovery_check_and_stop);
603 int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler)
605 struct obd_device *target, *targref = NULL;
606 struct obd_export *export = NULL;
607 struct obd_import *revimp;
608 struct lustre_handle conn;
609 struct obd_uuid tgtuuid;
610 struct obd_uuid cluuid;
611 struct obd_uuid remote_uuid;
614 struct obd_connect_data *data;
615 __u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(*data) };
616 lnet_nid_t *client_nid = NULL;
619 OBD_RACE(OBD_FAIL_TGT_CONN_RACE);
621 lustre_set_req_swabbed(req, REQ_REC_OFF);
622 str = lustre_msg_string(req->rq_reqmsg, REQ_REC_OFF, sizeof(tgtuuid)-1);
624 DEBUG_REQ(D_ERROR, req, "bad target UUID for connect");
625 GOTO(out, rc = -EINVAL);
628 obd_str2uuid (&tgtuuid, str);
629 target = class_uuid2obd(&tgtuuid);
631 /* old (pre 1.6) lustre_process_log tries to connect to mdsname
632 (eg. mdsA) instead of uuid. */
634 snprintf((char *)tgtuuid.uuid, sizeof(tgtuuid), "%s_UUID", str);
635 target = class_uuid2obd(&tgtuuid);
638 target = class_name2obd(str);
641 if (!target || target->obd_stopping || !target->obd_set_up) {
642 LCONSOLE_ERROR_MSG(0x137, "UUID '%s' is not available "
643 " for connect (%s)\n", str,
644 !target ? "no target" :
645 (target->obd_stopping ? "stopping" :
647 GOTO(out, rc = -ENODEV);
650 if (target->obd_no_conn) {
651 LCONSOLE_WARN("%s: temporarily refusing client connection "
652 "from %s\n", target->obd_name,
653 libcfs_nid2str(req->rq_peer.nid));
654 GOTO(out, rc = -EAGAIN);
657 /* Make sure the target isn't cleaned up while we're here. Yes,
658 there's still a race between the above check and our incref here.
659 Really, class_uuid2obd should take the ref. */
660 targref = class_incref(target);
662 lustre_set_req_swabbed(req, REQ_REC_OFF + 1);
663 str = lustre_msg_string(req->rq_reqmsg, REQ_REC_OFF + 1,
666 DEBUG_REQ(D_ERROR, req, "bad client UUID for connect");
667 GOTO(out, rc = -EINVAL);
670 obd_str2uuid (&cluuid, str);
672 /* XXX extract a nettype and format accordingly */
673 switch (sizeof(lnet_nid_t)) {
674 /* NB the casts only avoid compiler warnings */
676 snprintf(remote_uuid.uuid, sizeof remote_uuid,
677 "NET_"LPX64"_UUID", (__u64)req->rq_peer.nid);
680 snprintf(remote_uuid.uuid, sizeof remote_uuid,
681 "NET_%x_UUID", (__u32)req->rq_peer.nid);
687 target_recovery_check_and_stop(target);
689 tmp = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 2, sizeof conn);
691 GOTO(out, rc = -EPROTO);
693 memcpy(&conn, tmp, sizeof conn);
695 data = lustre_swab_reqbuf(req, REQ_REC_OFF + 3, sizeof(*data),
696 lustre_swab_connect);
697 rc = lustre_pack_reply(req, 2, size, NULL);
701 if (lustre_msg_get_op_flags(req->rq_reqmsg) & MSG_CONNECT_LIBCLIENT) {
703 DEBUG_REQ(D_WARNING, req, "Refusing old (unversioned) "
704 "libclient connection attempt");
705 GOTO(out, rc = -EPROTO);
706 } else if (data->ocd_version < LUSTRE_VERSION_CODE -
707 LUSTRE_VERSION_ALLOWED_OFFSET ||
708 data->ocd_version > LUSTRE_VERSION_CODE +
709 LUSTRE_VERSION_ALLOWED_OFFSET) {
710 DEBUG_REQ(D_WARNING, req, "Refusing %s (%d.%d.%d.%d) "
711 "libclient connection attempt",
712 data->ocd_version < LUSTRE_VERSION_CODE ?
714 OBD_OCD_VERSION_MAJOR(data->ocd_version),
715 OBD_OCD_VERSION_MINOR(data->ocd_version),
716 OBD_OCD_VERSION_PATCH(data->ocd_version),
717 OBD_OCD_VERSION_FIX(data->ocd_version));
718 data = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
719 offsetof(typeof(*data),
721 sizeof(data->ocd_version));
723 data->ocd_connect_flags = OBD_CONNECT_VERSION;
724 data->ocd_version = LUSTRE_VERSION_CODE;
726 GOTO(out, rc = -EPROTO);
730 /* lctl gets a backstage, all-access pass. */
731 if (obd_uuid_equals(&cluuid, &target->obd_uuid))
732 goto dont_check_exports;
734 spin_lock(&target->obd_dev_lock);
735 export = lustre_hash_lookup(target->obd_uuid_hash, &cluuid);
737 if (export != NULL && export->exp_connecting) { /* bug 9635, et. al. */
738 CWARN("%s: exp %p already connecting\n",
739 export->exp_obd->obd_name, export);
740 class_export_put(export);
743 } else if (export != NULL && export->exp_connection != NULL &&
744 req->rq_peer.nid != export->exp_connection->c_peer.nid) {
745 /* make darn sure this is coming from the same peer
746 * if the UUIDs matched */
747 if (data && data->ocd_connect_flags & OBD_CONNECT_MDS) {
748 /* the MDS UUID can be reused, don't need to wait
749 * for the export to be evicted */
750 CWARN("%s: received MDS connection from a new NID %s,"
751 " removing former export from NID %s\n",
753 libcfs_nid2str(req->rq_peer.nid),
754 libcfs_nid2str(export->exp_connection->c_peer.nid));
755 class_fail_export(export);
757 CWARN("%s: cookie %s seen on new NID %s when "
758 "existing NID %s is already connected\n",
759 target->obd_name, cluuid.uuid,
760 libcfs_nid2str(req->rq_peer.nid),
761 libcfs_nid2str(export->exp_connection->c_peer.nid));
764 class_export_put(export);
766 } else if (export != NULL && export->exp_failed) { /* bug 11327 */
767 CDEBUG(D_HA, "%s: exp %p evict in progress - new cookie needed "
768 "for connect\n", export->exp_obd->obd_name, export);
769 class_export_put(export);
772 } else if (export != NULL && export->exp_delayed &&
773 !(data && data->ocd_connect_flags & OBD_CONNECT_VBR)) {
774 spin_unlock(&target->obd_dev_lock);
775 class_fail_export(export);
776 class_export_put(export);
778 GOTO(out, rc = -ENODEV);
779 } else if (export != NULL) {
780 spin_lock(&export->exp_lock);
781 export->exp_connecting = 1;
782 spin_unlock(&export->exp_lock);
783 class_export_put(export);
784 spin_unlock(&target->obd_dev_lock);
785 LASSERT(export->exp_obd == target);
787 rc = target_handle_reconnect(&conn, export, &cluuid);
790 /* If we found an export, we already unlocked. */
792 spin_unlock(&target->obd_dev_lock);
793 OBD_FAIL_TIMEOUT(OBD_FAIL_TGT_DELAY_CONNECT, 2 * obd_timeout);
794 } else if (req->rq_export == NULL &&
795 atomic_read(&export->exp_rpc_count) > 0) {
796 CWARN("%s: refuse connection from %s/%s to 0x%p; still busy "
797 "with %d references\n", target->obd_name, cluuid.uuid,
798 libcfs_nid2str(req->rq_peer.nid),
799 export, atomic_read(&export->exp_refcount));
800 GOTO(out, rc = -EBUSY);
801 } else if (req->rq_export != NULL &&
802 atomic_read(&export->exp_rpc_count) > 1) {
803 CWARN("%s: refuse reconnection from %s@%s to 0x%p; still busy "
804 "with %d active RPCs\n", target->obd_name, cluuid.uuid,
805 libcfs_nid2str(req->rq_peer.nid),
806 export, atomic_read(&export->exp_rpc_count));
807 GOTO(out, rc = -EBUSY);
808 } else if (lustre_msg_get_conn_cnt(req->rq_reqmsg) == 1) {
809 CERROR("%s: NID %s (%s) reconnected with 1 conn_cnt; "
810 "cookies not random?\n", target->obd_name,
811 libcfs_nid2str(req->rq_peer.nid), cluuid.uuid);
812 GOTO(out, rc = -EALREADY);
813 } else if (export->exp_delayed && target->obd_recovering) {
814 /* VBR: don't allow delayed connection during recovery */
815 CWARN("%s: NID %s (%s) export was already marked as delayed "
816 "and will wait for end of recovery\n", target->obd_name,
817 libcfs_nid2str(req->rq_peer.nid), cluuid.uuid);
818 GOTO(out, rc = -EBUSY);
820 OBD_FAIL_TIMEOUT(OBD_FAIL_TGT_DELAY_RECONNECT, 2 * obd_timeout);
826 /* Tell the client if we're in recovery. */
827 if (target->obd_recovering) {
828 lustre_msg_add_op_flags(req->rq_repmsg, MSG_CONNECT_RECOVERING);
829 /* If this is the first time a client connects,
830 reset the recovery timer */
832 target_start_and_reset_recovery_timer(target, handler,
836 /* We want to handle EALREADY but *not* -EALREADY from
837 * target_handle_reconnect(), return reconnection state in a flag */
838 if (rc == EALREADY) {
839 lustre_msg_add_op_flags(req->rq_repmsg, MSG_CONNECT_RECONNECT);
845 /* Tell the client if we support replayable requests */
846 if (target->obd_replayable)
847 lustre_msg_add_op_flags(req->rq_repmsg, MSG_CONNECT_REPLAYABLE);
848 client_nid = &req->rq_peer.nid;
850 /* VBR: for delayed connections we start recovery */
851 if (export && export->exp_delayed && !export->exp_in_recovery) {
852 LASSERT(!target->obd_recovering);
853 LASSERT(data && data->ocd_connect_flags & OBD_CONNECT_VBR);
854 lustre_msg_add_op_flags(req->rq_repmsg, MSG_CONNECT_DELAYED |
855 MSG_CONNECT_RECOVERING);
856 spin_lock_bh(&target->obd_processing_task_lock);
857 target->obd_version_recov = 1;
858 spin_unlock_bh(&target->obd_processing_task_lock);
859 target_start_and_reset_recovery_timer(target, handler, req, 1);
862 if (export == NULL) {
863 if (target->obd_recovering) {
864 CERROR("%s: denying connection for new client %s (%s): "
865 "%d clients in recovery for %lds\n",
867 libcfs_nid2str(req->rq_peer.nid), cluuid.uuid,
868 target->obd_recoverable_clients,
869 cfs_duration_sec(cfs_time_sub(cfs_timer_deadline(&target->obd_recovery_timer),
870 cfs_time_current())));
874 rc = obd_connect(&conn, target, &cluuid, data,
878 rc = obd_reconnect(export, target, &cluuid, data, client_nid);
884 /* Return only the parts of obd_connect_data that we understand, so the
885 * client knows that we don't understand the rest. */
887 memcpy(lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
889 data, sizeof(*data));
891 /* If all else goes well, this is our RPC return code. */
894 lustre_msg_set_handle(req->rq_repmsg, &conn);
896 /* ownership of this export ref transfers to the request AFTER we
897 * drop any previous reference the request had, but we don't want
898 * that to go to zero before we get our new export reference. */
899 export = class_conn2export(&conn);
901 DEBUG_REQ(D_ERROR, req, "Missing export!");
902 GOTO(out, rc = -ENODEV);
905 /* If the client and the server are the same node, we will already
906 * have an export that really points to the client's DLM export,
907 * because we have a shared handles table.
909 * XXX this will go away when shaver stops sending the "connect" handle
910 * in the real "remote handle" field of the request --phik 24 Apr 2003
912 if (req->rq_export != NULL)
913 class_export_put(req->rq_export);
915 req->rq_export = export;
917 spin_lock(&export->exp_lock);
918 if (export->exp_conn_cnt >= lustre_msg_get_conn_cnt(req->rq_reqmsg)) {
919 CERROR("%s: %s already connected at higher conn_cnt: %d > %d\n",
920 cluuid.uuid, libcfs_nid2str(req->rq_peer.nid),
921 export->exp_conn_cnt,
922 lustre_msg_get_conn_cnt(req->rq_reqmsg));
924 spin_unlock(&export->exp_lock);
925 GOTO(out, rc = -EALREADY);
927 export->exp_conn_cnt = lustre_msg_get_conn_cnt(req->rq_reqmsg);
929 /* request from liblustre? Don't evict it for not pinging. */
930 if (lustre_msg_get_op_flags(req->rq_reqmsg) & MSG_CONNECT_LIBCLIENT) {
931 export->exp_libclient = 1;
932 spin_unlock(&export->exp_lock);
934 spin_lock(&target->obd_dev_lock);
935 list_del_init(&export->exp_obd_chain_timed);
936 spin_unlock(&target->obd_dev_lock);
938 spin_unlock(&export->exp_lock);
941 if (export->exp_connection != NULL)
942 ptlrpc_connection_put(export->exp_connection);
943 export->exp_connection = ptlrpc_connection_get(req->rq_peer,
947 if (hlist_unhashed(&export->exp_nid_hash)) {
948 lustre_hash_add_unique(export->exp_obd->obd_nid_hash,
949 &export->exp_connection->c_peer.nid,
950 &export->exp_nid_hash);
953 if (lustre_msg_get_op_flags(req->rq_repmsg) & MSG_CONNECT_RECONNECT) {
954 revimp = class_import_get(export->exp_imp_reverse);
955 GOTO(set_flags, rc = 0);
958 if (target->obd_recovering && !export->exp_in_recovery) {
959 spin_lock(&export->exp_lock);
960 export->exp_in_recovery = 1;
961 spin_unlock(&export->exp_lock);
962 target->obd_connected_clients++;
965 lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 2, sizeof conn),
968 if (export->exp_imp_reverse != NULL)
969 class_destroy_import(export->exp_imp_reverse);
970 revimp = export->exp_imp_reverse = class_new_import(target);
971 revimp->imp_connection = ptlrpc_connection_addref(export->exp_connection);
972 revimp->imp_client = &export->exp_obd->obd_ldlm_client;
973 revimp->imp_remote_handle = conn;
974 revimp->imp_dlm_fake = 1;
975 revimp->imp_state = LUSTRE_IMP_FULL;
978 if (req->rq_reqmsg->lm_magic == LUSTRE_MSG_MAGIC_V1 &&
979 lustre_msg_get_op_flags(req->rq_reqmsg) & MSG_CONNECT_NEXT_VER) {
980 revimp->imp_msg_magic = LUSTRE_MSG_MAGIC_V2;
981 lustre_msg_add_op_flags(req->rq_repmsg, MSG_CONNECT_NEXT_VER);
983 /* unknown versions will be caught in
984 * ptlrpc_handle_server_req_in->lustre_unpack_msg() */
985 revimp->imp_msg_magic = req->rq_reqmsg->lm_magic;
988 if (revimp->imp_msg_magic != LUSTRE_MSG_MAGIC_V1) {
989 if (export->exp_connect_flags & OBD_CONNECT_AT)
990 revimp->imp_msghdr_flags |= MSGHDR_AT_SUPPORT;
992 revimp->imp_msghdr_flags &= ~MSGHDR_AT_SUPPORT;
995 class_import_put(revimp);
998 spin_lock(&export->exp_lock);
999 export->exp_connecting = 0;
1000 spin_unlock(&export->exp_lock);
1003 class_decref(targref);
1005 req->rq_status = rc;
1009 int target_handle_disconnect(struct ptlrpc_request *req)
1014 rc = lustre_pack_reply(req, 1, NULL, NULL);
1018 /* keep the rq_export around so we can send the reply */
1019 req->rq_status = obd_disconnect(class_export_get(req->rq_export));
1023 void target_destroy_export(struct obd_export *exp)
1025 /* exports created from last_rcvd data, and "fake"
1026 exports created by lctl don't have an import */
1027 if (exp->exp_imp_reverse != NULL)
1028 class_destroy_import(exp->exp_imp_reverse);
1030 /* We cancel locks at disconnect time, but this will catch any locks
1031 * granted in a race with recovery-induced disconnect. */
1032 if (exp->exp_obd->obd_namespace != NULL)
1033 ldlm_cancel_locks_for_export(exp);
1037 * Recovery functions
1040 static int target_exp_enqueue_req_replay(struct ptlrpc_request *req)
1042 __u64 transno = lustre_msg_get_transno(req->rq_reqmsg);
1043 struct obd_export *exp = req->rq_export;
1044 struct ptlrpc_request *reqiter;
1049 spin_lock(&exp->exp_lock);
1050 list_for_each_entry(reqiter, &exp->exp_req_replay_queue,
1052 if (lustre_msg_get_transno(reqiter->rq_reqmsg) == transno) {
1059 /* we expect it with RESENT and REPLAY flags */
1060 if ((lustre_msg_get_flags(req->rq_reqmsg) &
1061 (MSG_RESENT | MSG_REPLAY)) != (MSG_RESENT | MSG_REPLAY))
1062 CERROR("invalid flags %x of resent replay\n",
1063 lustre_msg_get_flags(req->rq_reqmsg));
1065 list_add_tail(&req->rq_replay_list, &exp->exp_req_replay_queue);
1068 spin_unlock(&exp->exp_lock);
1072 static void target_exp_dequeue_req_replay(struct ptlrpc_request *req)
1074 LASSERT(!list_empty(&req->rq_replay_list));
1075 LASSERT(req->rq_export);
1077 spin_lock(&req->rq_export->exp_lock);
1078 list_del_init(&req->rq_replay_list);
1079 spin_unlock(&req->rq_export->exp_lock);
1082 static void target_release_saved_req(struct ptlrpc_request *req)
1084 ptlrpc_req_drop_rs(req);
1085 class_export_put(req->rq_export);
1086 OBD_FREE(req->rq_reqmsg, req->rq_reqlen);
1087 OBD_FREE(req, sizeof *req);
1090 static void target_send_delayed_replies(struct obd_device *obd)
1092 struct ptlrpc_request *req, *tmp;
1094 LCONSOLE_INFO("%s: sending delayed replies to recovered clients\n",
1097 list_for_each_entry_safe(req, tmp, &obd->obd_delayed_reply_queue,
1099 list_del_init(&req->rq_list);
1100 DEBUG_REQ(D_HA, req, "delayed:");
1102 target_release_saved_req(req);
1104 obd->obd_recovery_end = cfs_time_current_sec();
1107 static void target_finish_recovery(struct obd_device *obd)
1109 ldlm_reprocess_all_ns(obd->obd_namespace);
1110 spin_lock_bh(&obd->obd_processing_task_lock);
1111 if (list_empty(&obd->obd_recovery_queue)) {
1112 obd->obd_processing_task = 0;
1114 spin_unlock_bh(&obd->obd_processing_task_lock);
1115 CERROR("%s: Recovery queue isn't empty\n", obd->obd_name);
1118 spin_unlock_bh(&obd->obd_processing_task_lock);
1120 /* when recovery finished, cleanup orphans on mds and ost */
1121 if (OBT(obd) && OBP(obd, postrecov)) {
1122 int rc = OBP(obd, postrecov)(obd);
1123 LCONSOLE_WARN("%s: recovery %s: rc %d\n", obd->obd_name,
1124 rc < 0 ? "failed" : "complete", rc);
1126 target_send_delayed_replies(obd);
1129 static void abort_recovery_queue(struct obd_device *obd)
1131 struct ptlrpc_request *req, *n;
1132 struct list_head abort_list;
1135 CFS_INIT_LIST_HEAD(&abort_list);
1136 spin_lock_bh(&obd->obd_processing_task_lock);
1137 list_splice_init(&obd->obd_recovery_queue, &abort_list);
1138 spin_unlock_bh(&obd->obd_processing_task_lock);
1139 /* process abort list unlocked */
1140 list_for_each_entry_safe(req, n, &abort_list, rq_list) {
1141 target_exp_dequeue_req_replay(req);
1142 list_del_init(&req->rq_list);
1143 DEBUG_REQ(D_ERROR, req, "aborted:");
1144 req->rq_status = -ENOTCONN;
1145 req->rq_type = PTL_RPC_MSG_ERR;
1146 rc = lustre_pack_reply(req, 1, NULL, NULL);
1150 DEBUG_REQ(D_ERROR, req,
1151 "packing failed for abort-reply; skipping");
1152 target_release_saved_req(req);
1156 /* Called from a cleanup function if the device is being cleaned up
1157 forcefully. The exports should all have been disconnected already,
1158 the only thing left to do is
1159 - clear the recovery flags
1161 - free queued requests and replies, but don't send replies
1162 Because the obd_stopping flag is set, no new requests should be received.
1165 void target_cleanup_recovery(struct obd_device *obd)
1167 struct list_head *tmp, *n;
1168 struct ptlrpc_request *req;
1169 struct list_head clean_list;
1172 LASSERT(obd->obd_stopping);
1174 spin_lock_bh(&obd->obd_processing_task_lock);
1175 if (!obd->obd_recovering) {
1176 spin_unlock_bh(&obd->obd_processing_task_lock);
1180 obd->obd_recovering = obd->obd_abort_recovery = 0;
1181 target_cancel_recovery_timer(obd);
1182 spin_unlock_bh(&obd->obd_processing_task_lock);
1184 list_for_each_safe(tmp, n, &obd->obd_delayed_reply_queue) {
1185 req = list_entry(tmp, struct ptlrpc_request, rq_list);
1186 list_del(&req->rq_list);
1187 target_release_saved_req(req);
1190 CFS_INIT_LIST_HEAD(&clean_list);
1191 spin_lock_bh(&obd->obd_processing_task_lock);
1192 list_splice_init(&obd->obd_recovery_queue, &clean_list);
1193 spin_unlock_bh(&obd->obd_processing_task_lock);
1194 list_for_each_safe(tmp, n, &clean_list) {
1195 req = list_entry(tmp, struct ptlrpc_request, rq_list);
1196 target_exp_dequeue_req_replay(req);
1197 list_del_init(&req->rq_list);
1198 target_release_saved_req(req);
1203 void target_stop_recovery(void *data, int abort)
1205 struct obd_device *obd = data;
1206 enum obd_option flags;
1209 spin_lock_bh(&obd->obd_processing_task_lock);
1210 if (!obd->obd_recovering) {
1211 spin_unlock_bh(&obd->obd_processing_task_lock);
1215 flags = exp_flags_from_obd(obd) | OBD_OPT_ABORT_RECOV;
1216 obd->obd_recovering = 0;
1217 obd->obd_abort_recovery = 0;
1218 obd->obd_processing_task = 0;
1220 LASSERT(obd->obd_recoverable_clients == 0);
1222 target_cancel_recovery_timer(obd);
1223 spin_unlock_bh(&obd->obd_processing_task_lock);
1226 LCONSOLE_WARN("%s: recovery is aborted by administrative "
1227 "request; %d clients are not recovered "
1228 "(%d clients did)\n", obd->obd_name,
1229 obd->obd_recoverable_clients,
1230 obd->obd_connected_clients);
1231 class_disconnect_stale_exports(obd, flags);
1233 abort_recovery_queue(obd);
1234 target_finish_recovery(obd);
1235 CDEBUG(D_HA, "%s: recovery complete\n", obd_uuid2str(&obd->obd_uuid));
1239 void target_abort_recovery(void *data)
1241 target_stop_recovery(data, 1);
1244 static void reset_recovery_timer(struct obd_device *, int, int);
1245 static void target_recovery_expired(unsigned long castmeharder)
1247 struct obd_device *obd = (struct obd_device *)castmeharder;
1248 int version_recov = obd->obd_version_recov;
1249 LCONSOLE_WARN("%s: recovery period over; %d clients never reconnected "
1250 "after %lds (%d clients did)\n",
1251 obd->obd_name, obd->obd_recoverable_clients,
1252 cfs_time_current_sec()- obd->obd_recovery_start,
1253 obd->obd_connected_clients);
1255 /** check is fs version-capable */
1256 if (target_fs_version_capable(obd)) {
1257 class_handle_stale_exports(obd);
1259 CWARN("Versions are not supported by ldiskfs, VBR is OFF\n");
1260 class_disconnect_stale_exports(obd, exp_flags_from_obd(obd));
1262 spin_lock_bh(&obd->obd_processing_task_lock);
1263 /* VBR: no clients are remained to replay, stop recovery */
1264 if (obd->obd_recovering && obd->obd_recoverable_clients == 0)
1265 obd->obd_abort_recovery = 1;
1266 /* always check versions now */
1267 obd->obd_version_recov = 1;
1268 cfs_waitq_signal(&obd->obd_next_transno_waitq);
1269 spin_unlock_bh(&obd->obd_processing_task_lock);
1270 /* reset timer if recovery will proceed with versions now */
1271 reset_recovery_timer(obd, OBD_RECOVERY_FACTOR * obd_timeout,
1275 /* obd_processing_task_lock should be held */
1276 void target_cancel_recovery_timer(struct obd_device *obd)
1278 CDEBUG(D_HA, "%s: cancel recovery timer\n", obd->obd_name);
1279 cfs_timer_disarm(&obd->obd_recovery_timer);
1282 /* extend = 1 means require at least "duration" seconds left in the timer,
1283 extend = 0 means set the total duration (start_recovery_timer) */
1284 static void reset_recovery_timer(struct obd_device *obd, int duration,
1287 cfs_time_t now = cfs_time_current_sec();
1288 cfs_duration_t left;
1290 spin_lock_bh(&obd->obd_processing_task_lock);
1291 if (!obd->obd_recovering) {
1292 spin_unlock_bh(&obd->obd_processing_task_lock);
1296 left = cfs_time_sub(obd->obd_recovery_end, now);
1298 if (extend && (duration > left))
1299 obd->obd_recovery_timeout += duration - left;
1300 else if (!extend && (duration > obd->obd_recovery_timeout))
1301 /* Track the client's largest expected replay time */
1302 obd->obd_recovery_timeout = duration;
1305 * If total recovery time already exceed the
1306 * obd_recovery_max_time, then CRAY XT3 will
1307 * abort the recovery
1309 if(obd->obd_recovery_timeout > obd->obd_recovery_max_time)
1310 obd->obd_recovery_timeout = obd->obd_recovery_max_time;
1312 obd->obd_recovery_end = obd->obd_recovery_start +
1313 obd->obd_recovery_timeout;
1314 if (cfs_time_before(now, obd->obd_recovery_end)) {
1315 left = cfs_time_sub(obd->obd_recovery_end, now);
1316 cfs_timer_arm(&obd->obd_recovery_timer, cfs_time_shift(left));
1318 spin_unlock_bh(&obd->obd_processing_task_lock);
1319 CDEBUG(D_HA, "%s: recovery timer will expire in %u seconds\n",
1320 obd->obd_name, (unsigned)left);
1323 static void check_and_start_recovery_timer(struct obd_device *obd,
1324 svc_handler_t handler)
1326 spin_lock_bh(&obd->obd_processing_task_lock);
1327 if (obd->obd_recovery_handler) {
1328 spin_unlock_bh(&obd->obd_processing_task_lock);
1331 CWARN("%s: starting recovery timer\n", obd->obd_name);
1332 obd->obd_recovery_start = cfs_time_current_sec();
1334 obd->obd_recovery_timeout = OBD_RECOVERY_FACTOR * obd_timeout;
1335 obd->obd_recovery_handler = handler;
1336 cfs_timer_init(&obd->obd_recovery_timer, target_recovery_expired, obd);
1337 spin_unlock_bh(&obd->obd_processing_task_lock);
1339 reset_recovery_timer(obd, obd->obd_recovery_timeout, 0);
1342 /* Reset the timer with each new client connection */
1344 * This timer is actually reconnect_timer, which is for making sure
1345 * the total recovery window is at least as big as my reconnect
1346 * attempt timing. So the initial recovery time_out will be set to
1347 * OBD_RECOVERY_FACTOR * obd_timeout. If the timeout coming
1348 * from client is bigger than this, then the recovery time_out will
1349 * be extend to make sure the client could be reconnected, in the
1350 * process, the timeout from the new client should be ignored.
1354 target_start_and_reset_recovery_timer(struct obd_device *obd,
1355 svc_handler_t handler,
1356 struct ptlrpc_request *req,
1359 int service_time = lustre_msg_get_service_time(req->rq_reqmsg);
1361 if (!new_client && service_time)
1362 /* Teach server about old server's estimates, as first guess
1363 at how long new requests will take. */
1364 at_add(&req->rq_rqbd->rqbd_service->srv_at_estimate,
1367 check_and_start_recovery_timer(obd, handler);
1369 /* convert the service time to rpc timeout,
1370 * reuse service_time to limit stack usage */
1371 service_time = at_est2timeout(service_time);
1373 /* We expect other clients to timeout within service_time, then try
1374 * to reconnect, then try the failover server. The max delay between
1375 * connect attempts is SWITCH_MAX + SWITCH_INC + INITIAL */
1376 service_time += 2 * (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC +
1377 INITIAL_CONNECT_TIMEOUT);
1378 if (service_time > obd->obd_recovery_timeout && !new_client)
1379 reset_recovery_timer(obd, service_time, 0);
1382 static int check_for_next_transno(struct obd_device *obd)
1384 struct ptlrpc_request *req;
1385 int wake_up = 0, connected, completed, queue_len, max;
1386 __u64 next_transno, req_transno;
1388 spin_lock_bh(&obd->obd_processing_task_lock);
1389 req = list_entry(obd->obd_recovery_queue.next,
1390 struct ptlrpc_request, rq_list);
1391 max = obd->obd_max_recoverable_clients;
1392 req_transno = lustre_msg_get_transno(req->rq_reqmsg);
1393 connected = obd->obd_connected_clients;
1394 completed = max - obd->obd_recoverable_clients -
1395 obd->obd_delayed_clients;
1396 queue_len = obd->obd_requests_queued_for_recovery;
1397 next_transno = obd->obd_next_recovery_transno;
1399 CDEBUG(D_HA,"max: %d, connected: %d, delayed %d, completed: %d, "
1400 "queue_len: %d, req_transno: "LPU64", next_transno: "LPU64"\n",
1401 max, connected, obd->obd_delayed_clients, completed, queue_len,
1402 req_transno, next_transno);
1403 if (obd->obd_abort_recovery) {
1404 CDEBUG(D_HA, "waking for aborted recovery\n");
1406 } else if (!obd->obd_recovering) {
1407 CDEBUG(D_HA, "waking for completed recovery (?)\n");
1409 } else if (req_transno == next_transno) {
1410 CDEBUG(D_HA, "waking for next ("LPD64")\n", next_transno);
1412 } else if (queue_len == obd->obd_recoverable_clients) {
1414 "waking for skipped transno (skip: "LPD64
1415 ", ql: %d, comp: %d, conn: %d, next: "LPD64")\n",
1416 next_transno, queue_len, completed, max, req_transno);
1417 obd->obd_next_recovery_transno = req_transno;
1420 spin_unlock_bh(&obd->obd_processing_task_lock);
1421 LASSERT(lustre_msg_get_transno(req->rq_reqmsg) >= next_transno);
1425 static void process_recovery_queue(struct obd_device *obd)
1427 struct ptlrpc_request *req;
1428 struct l_wait_info lwi = { 0 };
1432 spin_lock_bh(&obd->obd_processing_task_lock);
1433 LASSERT(obd->obd_processing_task == cfs_curproc_pid());
1434 req = list_entry(obd->obd_recovery_queue.next,
1435 struct ptlrpc_request, rq_list);
1437 if (lustre_msg_get_transno(req->rq_reqmsg) !=
1438 obd->obd_next_recovery_transno) {
1439 spin_unlock_bh(&obd->obd_processing_task_lock);
1440 CDEBUG(D_HA, "Waiting for transno "LPD64" (1st is "
1441 LPD64", x"LPU64")\n",
1442 obd->obd_next_recovery_transno,
1443 lustre_msg_get_transno(req->rq_reqmsg),
1445 l_wait_event(obd->obd_next_transno_waitq,
1446 check_for_next_transno(obd), &lwi);
1447 if (target_recovery_check_and_stop(obd))
1451 target_exp_dequeue_req_replay(req);
1452 list_del_init(&req->rq_list);
1453 obd->obd_requests_queued_for_recovery--;
1454 spin_unlock_bh(&obd->obd_processing_task_lock);
1456 DEBUG_REQ(D_HA, req, "processing: ");
1457 (void)obd->obd_recovery_handler(req);
1458 obd->obd_replayed_requests++;
1459 /* Extend the recovery timer enough to complete the next
1461 reset_recovery_timer(obd, AT_OFF ? obd_timeout :
1462 at_get(&req->rq_rqbd->rqbd_service->srv_at_estimate), 1);
1463 /* bug 1580: decide how to properly sync() in recovery */
1464 //mds_fsync_super(obd->u.obt.obt_sb);
1465 class_export_put(req->rq_export);
1466 ptlrpc_req_drop_rs(req);
1467 OBD_FREE(req->rq_reqmsg, req->rq_reqlen);
1468 OBD_FREE(req, sizeof *req);
1469 OBD_RACE(OBD_FAIL_TGT_REPLAY_DELAY);
1470 spin_lock_bh(&obd->obd_processing_task_lock);
1471 obd->obd_next_recovery_transno++;
1472 if (list_empty(&obd->obd_recovery_queue)) {
1473 obd->obd_processing_task = 0;
1474 spin_unlock_bh(&obd->obd_processing_task_lock);
1477 spin_unlock_bh(&obd->obd_processing_task_lock);
1482 int target_queue_recovery_request(struct ptlrpc_request *req,
1483 struct obd_device *obd)
1485 struct list_head *tmp;
1487 __u64 transno = lustre_msg_get_transno(req->rq_reqmsg);
1488 struct ptlrpc_request *saved_req;
1489 struct lustre_msg *reqmsg;
1492 /* CAVEAT EMPTOR: The incoming request message has been swabbed
1493 * (i.e. buflens etc are in my own byte order), but type-dependent
1494 * buffers (eg mds_body, ost_body etc) have NOT been swabbed. */
1497 CFS_INIT_LIST_HEAD(&req->rq_list);
1498 DEBUG_REQ(D_HA, req, "not queueing");
1502 /* XXX If I were a real man, these LBUGs would be sane cleanups. */
1503 /* XXX just like the request-dup code in queue_final_reply */
1504 OBD_ALLOC(saved_req, sizeof *saved_req);
1507 OBD_ALLOC(reqmsg, req->rq_reqlen);
1511 spin_lock_bh(&obd->obd_processing_task_lock);
1513 /* If we're processing the queue, we want don't want to queue this
1516 * Also, if this request has a transno less than the one we're waiting
1517 * for, we should process it now. It could (and currently always will)
1518 * be an open request for a descriptor that was opened some time ago.
1520 * Also, a resent, replayed request that has already been
1521 * handled will pass through here and be processed immediately.
1523 if (obd->obd_processing_task == cfs_curproc_pid() ||
1524 transno < obd->obd_next_recovery_transno) {
1525 /* Processing the queue right now, don't re-add. */
1526 LASSERT(list_empty(&req->rq_list));
1527 spin_unlock_bh(&obd->obd_processing_task_lock);
1528 GOTO(err_free, rc = 1);
1531 if (unlikely(OBD_FAIL_CHECK(OBD_FAIL_TGT_REPLAY_DROP))) {
1532 spin_unlock_bh(&obd->obd_processing_task_lock);
1533 GOTO(err_free, rc = 0);
1536 memcpy(saved_req, req, sizeof *req);
1537 memcpy(reqmsg, req->rq_reqmsg, req->rq_reqlen);
1539 req->rq_reqmsg = reqmsg;
1540 class_export_get(req->rq_export);
1541 CFS_INIT_LIST_HEAD(&req->rq_list);
1542 CFS_INIT_LIST_HEAD(&req->rq_replay_list);
1544 if (target_exp_enqueue_req_replay(req)) {
1545 spin_unlock_bh(&obd->obd_processing_task_lock);
1546 DEBUG_REQ(D_ERROR, req, "dropping resent queued req");
1547 GOTO(err_exp, rc = 0);
1551 list_for_each(tmp, &obd->obd_recovery_queue) {
1552 struct ptlrpc_request *reqiter =
1553 list_entry(tmp, struct ptlrpc_request, rq_list);
1555 if (lustre_msg_get_transno(reqiter->rq_reqmsg) > transno) {
1556 list_add_tail(&req->rq_list, &reqiter->rq_list);
1561 if (unlikely(lustre_msg_get_transno(reqiter->rq_reqmsg) ==
1563 spin_unlock_bh(&obd->obd_processing_task_lock);
1564 DEBUG_REQ(D_ERROR, req, "dropping replay: transno "
1565 "has been claimed by another client");
1566 target_exp_dequeue_req_replay(req);
1567 GOTO(err_exp, rc = 0);
1572 list_add_tail(&req->rq_list, &obd->obd_recovery_queue);
1575 obd->obd_requests_queued_for_recovery++;
1577 if (obd->obd_processing_task != 0) {
1578 /* Someone else is processing this queue, we'll leave it to
1581 cfs_waitq_signal(&obd->obd_next_transno_waitq);
1582 spin_unlock_bh(&obd->obd_processing_task_lock);
1586 /* Nobody is processing, and we know there's (at least) one to process
1587 * now, so we'll do the honours.
1589 obd->obd_processing_task = cfs_curproc_pid();
1590 spin_unlock_bh(&obd->obd_processing_task_lock);
1592 process_recovery_queue(obd);
1596 class_export_put(req->rq_export);
1598 OBD_FREE(reqmsg, req->rq_reqlen);
1599 OBD_FREE(saved_req, sizeof(*saved_req));
1603 struct obd_device * target_req2obd(struct ptlrpc_request *req)
1605 return req->rq_export->exp_obd;
1608 int target_queue_last_replay_reply(struct ptlrpc_request *req, int rc)
1610 struct obd_device *obd = target_req2obd(req);
1611 struct ptlrpc_request *saved_req;
1612 struct lustre_msg *reqmsg;
1613 struct obd_export *exp = req->rq_export;
1614 int recovery_done = 0, delayed_done = 0;
1616 LASSERT ((rc == 0) == req->rq_packed_final);
1618 if (!req->rq_packed_final) {
1619 /* Just like ptlrpc_error, but without the sending. */
1620 rc = lustre_pack_reply(req, 1, NULL, NULL);
1623 req->rq_type = PTL_RPC_MSG_ERR;
1626 LASSERT(!req->rq_reply_state->rs_difficult);
1627 LASSERT(list_empty(&req->rq_list));
1628 /* XXX a bit like the request-dup code in queue_recovery_request */
1629 OBD_ALLOC(saved_req, sizeof *saved_req);
1632 OBD_ALLOC(reqmsg, req->rq_reqlen);
1634 OBD_FREE(saved_req, sizeof *req);
1638 memcpy(reqmsg, req->rq_reqmsg, req->rq_reqlen);
1640 /* Don't race cleanup */
1641 spin_lock_bh(&obd->obd_processing_task_lock);
1642 if (obd->obd_stopping) {
1643 spin_unlock_bh(&obd->obd_processing_task_lock);
1647 if (!exp->exp_vbr_failed) {
1648 ptlrpc_rs_addref(req->rq_reply_state); /* +1 ref for saved reply */
1650 req->rq_reqmsg = reqmsg;
1651 CFS_INIT_LIST_HEAD(&req->rq_list);
1652 CFS_INIT_LIST_HEAD(&req->rq_replay_list);
1653 class_export_get(exp);
1654 list_add(&req->rq_list, &obd->obd_delayed_reply_queue);
1657 /* only count the first "replay over" request from each
1659 if (exp->exp_replay_needed) {
1660 spin_lock(&exp->exp_lock);
1661 exp->exp_replay_needed = 0;
1662 spin_unlock(&exp->exp_lock);
1664 if (!exp->exp_delayed) {
1665 --obd->obd_recoverable_clients;
1667 spin_lock(&exp->exp_lock);
1668 exp->exp_delayed = 0;
1669 spin_unlock(&exp->exp_lock);
1671 if (obd->obd_delayed_clients == 0) {
1672 spin_unlock_bh(&obd->obd_processing_task_lock);
1675 --obd->obd_delayed_clients;
1678 recovery_done = (obd->obd_recoverable_clients == 0);
1679 spin_unlock_bh(&obd->obd_processing_task_lock);
1682 /* start pinging export */
1683 spin_lock(&obd->obd_dev_lock);
1684 list_add_tail(&exp->exp_obd_chain_timed,
1685 &obd->obd_exports_timed);
1686 list_move_tail(&exp->exp_obd_chain, &obd->obd_exports);
1687 spin_unlock(&obd->obd_dev_lock);
1688 target_send_delayed_replies(obd);
1691 OBD_RACE(OBD_FAIL_LDLM_RECOV_CLIENTS);
1692 if (recovery_done) {
1693 spin_lock_bh(&obd->obd_processing_task_lock);
1694 obd->obd_recovering = 0;
1695 obd->obd_version_recov = 0;
1696 obd->obd_abort_recovery = 0;
1697 target_cancel_recovery_timer(obd);
1698 spin_unlock_bh(&obd->obd_processing_task_lock);
1700 OBD_RACE(OBD_FAIL_TGT_REPLAY_DELAY);
1703 target_finish_recovery(obd);
1704 CDEBUG(D_HA, "%s: recovery complete\n",
1705 obd_uuid2str(&obd->obd_uuid));
1707 CWARN("%s: %d recoverable clients remain\n",
1708 obd->obd_name, obd->obd_recoverable_clients);
1709 cfs_waitq_signal(&obd->obd_next_transno_waitq);
1712 /* VBR: disconnect export with failed recovery */
1713 if (exp->exp_vbr_failed) {
1714 CWARN("%s: disconnect export %s\n", obd->obd_name,
1715 exp->exp_client_uuid.uuid);
1716 class_fail_export(exp);
1717 OBD_FREE(reqmsg, req->rq_reqlen);
1718 OBD_FREE(saved_req, sizeof *req);
1720 ptlrpc_send_reply(req, 0);
1726 OBD_FREE(reqmsg, req->rq_reqlen);
1727 OBD_FREE(saved_req, sizeof *req);
1728 req->rq_status = -ENOTCONN;
1729 /* rv is ignored anyhow */
1733 int target_handle_reply(struct ptlrpc_request *req, int rc, int fail)
1735 struct obd_device *obd = NULL;
1738 obd = target_req2obd(req);
1740 /* handle replay reply for version recovery */
1741 if (obd && obd->obd_version_recov &&
1742 (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY)) {
1743 LASSERT(req->rq_repmsg);
1744 lustre_msg_add_flags(req->rq_repmsg, MSG_VERSION_REPLAY);
1747 /* handle last replay */
1748 if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_LAST_REPLAY) {
1750 lustre_msg_get_flags(req->rq_reqmsg) & MSG_DELAY_REPLAY) {
1751 DEBUG_REQ(D_HA, req,
1752 "delayed LAST_REPLAY, queuing reply");
1753 rc = target_queue_last_replay_reply(req, rc);
1754 LASSERT(req->rq_export->exp_delayed == 0);
1758 if (obd && obd->obd_recovering) { /* normal recovery */
1759 DEBUG_REQ(D_HA, req, "LAST_REPLAY, queuing reply");
1760 rc = target_queue_last_replay_reply(req, rc);
1764 /* Lost a race with recovery; let the error path DTRT. */
1765 rc = req->rq_status = -ENOTCONN;
1767 target_send_reply(req, rc, fail);
1771 static inline struct ldlm_pool *ldlm_exp2pl(struct obd_export *exp)
1773 LASSERT(exp != NULL);
1774 return &exp->exp_obd->obd_namespace->ns_pool;
1777 int target_pack_pool_reply(struct ptlrpc_request *req)
1779 struct obd_device *obd;
1783 * Check that we still have all structures alive as this may
1784 * be some late rpc in shutdown time.
1786 if (unlikely(!req->rq_export || !req->rq_export->exp_obd ||
1787 !exp_connect_lru_resize(req->rq_export))) {
1788 lustre_msg_set_slv(req->rq_repmsg, 0);
1789 lustre_msg_set_limit(req->rq_repmsg, 0);
1794 * OBD is alive here as export is alive, which we checked above.
1796 obd = req->rq_export->exp_obd;
1798 read_lock(&obd->obd_pool_lock);
1799 lustre_msg_set_slv(req->rq_repmsg, obd->obd_pool_slv);
1800 lustre_msg_set_limit(req->rq_repmsg, obd->obd_pool_limit);
1801 read_unlock(&obd->obd_pool_lock);
1807 target_send_reply_msg (struct ptlrpc_request *req, int rc, int fail_id)
1809 if (OBD_FAIL_CHECK(fail_id | OBD_FAIL_ONCE)) {
1810 obd_fail_loc |= OBD_FAIL_ONCE | OBD_FAILED;
1811 DEBUG_REQ(D_ERROR, req, "dropping reply");
1816 DEBUG_REQ(D_ERROR, req, "processing error (%d)", rc);
1817 req->rq_status = rc;
1818 return (ptlrpc_send_error(req, 1));
1820 DEBUG_REQ(D_NET, req, "sending reply");
1823 return (ptlrpc_send_reply(req, PTLRPC_REPLY_MAYBE_DIFFICULT));
1827 target_send_reply(struct ptlrpc_request *req, int rc, int fail_id)
1830 struct ptlrpc_reply_state *rs;
1831 struct obd_device *obd;
1832 struct obd_export *exp;
1833 struct ptlrpc_service *svc;
1835 svc = req->rq_rqbd->rqbd_service;
1836 rs = req->rq_reply_state;
1837 if (rs == NULL || !rs->rs_difficult) {
1839 target_send_reply_msg (req, rc, fail_id);
1843 /* must be an export if locks saved */
1844 LASSERT (req->rq_export != NULL);
1845 /* req/reply consistent */
1846 LASSERT (rs->rs_service == svc);
1849 LASSERT (!rs->rs_scheduled);
1850 LASSERT (!rs->rs_scheduled_ever);
1851 LASSERT (!rs->rs_handled);
1852 LASSERT (!rs->rs_on_net);
1853 LASSERT (rs->rs_export == NULL);
1854 LASSERT (list_empty(&rs->rs_obd_list));
1855 LASSERT (list_empty(&rs->rs_exp_list));
1857 exp = class_export_get(req->rq_export);
1860 /* disable reply scheduling onto srv_reply_queue while I'm setting up */
1861 rs->rs_scheduled = 1;
1863 rs->rs_xid = req->rq_xid;
1864 rs->rs_transno = req->rq_transno;
1865 rs->rs_export = exp;
1867 spin_lock(&exp->exp_uncommitted_replies_lock);
1869 /* VBR: use exp_last_committed */
1870 if (rs->rs_transno > exp->exp_last_committed) {
1871 /* not committed already */
1872 list_add_tail (&rs->rs_obd_list,
1873 &exp->exp_uncommitted_replies);
1876 spin_unlock (&exp->exp_uncommitted_replies_lock);
1877 spin_lock (&exp->exp_lock);
1879 list_add_tail (&rs->rs_exp_list, &exp->exp_outstanding_replies);
1881 spin_unlock(&exp->exp_lock);
1883 netrc = target_send_reply_msg (req, rc, fail_id);
1885 spin_lock(&svc->srv_lock);
1887 svc->srv_n_difficult_replies++;
1890 /* error sending: reply is off the net. Also we need +1
1891 * reply ref until ptlrpc_server_handle_reply() is done
1892 * with the reply state (if the send was successful, there
1893 * would have been +1 ref for the net, which
1894 * reply_out_callback leaves alone) */
1896 ptlrpc_rs_addref(rs);
1897 atomic_inc (&svc->srv_outstanding_replies);
1900 if (!rs->rs_on_net || /* some notifier */
1901 list_empty(&rs->rs_exp_list) || /* completed already */
1902 list_empty(&rs->rs_obd_list)) {
1903 list_add_tail (&rs->rs_list, &svc->srv_reply_queue);
1904 cfs_waitq_signal (&svc->srv_waitq);
1906 list_add (&rs->rs_list, &svc->srv_active_replies);
1907 rs->rs_scheduled = 0; /* allow notifier to schedule */
1910 spin_unlock(&svc->srv_lock);
1913 int target_handle_ping(struct ptlrpc_request *req)
1915 if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_LAST_REPLAY &&
1916 req->rq_export->exp_in_recovery) {
1917 spin_lock(&req->rq_export->exp_lock);
1918 req->rq_export->exp_in_recovery = 0;
1919 spin_unlock(&req->rq_export->exp_lock);
1921 obd_ping(req->rq_export);
1922 return lustre_pack_reply(req, 1, NULL, NULL);
1925 void target_committed_to_req(struct ptlrpc_request *req)
1927 struct obd_export *exp = req->rq_export;
1928 if (!exp->exp_obd->obd_no_transno && req->rq_repmsg != NULL) {
1929 lustre_msg_set_last_committed(req->rq_repmsg,
1930 exp->exp_last_committed);
1932 DEBUG_REQ(D_IOCTL, req, "not sending last_committed update (%d/"
1933 "%d)", exp->exp_obd->obd_no_transno,
1934 req->rq_repmsg == NULL);
1936 CDEBUG(D_INFO, "last_committed x"LPU64", this req x"LPU64"\n",
1937 exp->exp_obd->obd_last_committed, req->rq_xid);
1940 EXPORT_SYMBOL(target_committed_to_req);
1942 int target_handle_qc_callback(struct ptlrpc_request *req)
1944 struct obd_quotactl *oqctl;
1945 struct client_obd *cli = &req->rq_export->exp_obd->u.cli;
1947 oqctl = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*oqctl),
1948 lustre_swab_obd_quotactl);
1949 if (oqctl == NULL) {
1950 CERROR("Can't unpack obd_quatactl\n");
1954 cli->cl_qchk_stat = oqctl->qc_stat;
1959 #ifdef HAVE_QUOTA_SUPPORT
1960 int target_handle_dqacq_callback(struct ptlrpc_request *req)
1963 struct obd_device *obd = req->rq_export->exp_obd;
1964 struct obd_device *master_obd;
1965 struct lustre_quota_ctxt *qctxt;
1966 struct qunit_data *qdata = NULL;
1968 int repsize[2] = { sizeof(struct ptlrpc_body), 0 };
1971 if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_MDS_DROP_QUOTA_REQ))
1974 repsize[1] = quota_get_qunit_data_size(req->rq_export->
1977 rc = lustre_pack_reply(req, 2, repsize, NULL);
1981 LASSERT(req->rq_export);
1983 /* there are three forms of qunit(historic causes), so we need to
1984 * adjust qunits from slaves to the same form here */
1985 OBD_ALLOC(qdata, sizeof(struct qunit_data));
1988 rc = quota_get_qdata(req, qdata, QUOTA_REQUEST, QUOTA_EXPORT);
1990 CDEBUG(D_ERROR, "Can't unpack qunit_data(rc: %d)\n", rc);
1994 /* we use the observer */
1995 if (!obd->obd_observer || !obd->obd_observer->obd_observer) {
1996 CERROR("Can't find the observer, it is recovering\n");
1997 req->rq_status = -EAGAIN;
1998 GOTO(send_reply, rc = -EAGAIN);
2001 master_obd = obd->obd_observer->obd_observer;
2002 qctxt = &master_obd->u.obt.obt_qctxt;
2004 if (!qctxt->lqc_setup) {
2005 /* quota_type has not been processed yet, return EAGAIN
2006 * until we know whether or not quotas are supposed to
2008 CDEBUG(D_QUOTA, "quota_type not processed yet, return "
2010 req->rq_status = -EAGAIN;
2011 rc = ptlrpc_reply(req);
2015 LASSERT(qctxt->lqc_handler);
2016 rc = qctxt->lqc_handler(master_obd, qdata,
2017 lustre_msg_get_opc(req->rq_reqmsg));
2018 if (rc && rc != -EDQUOT)
2019 CDEBUG(rc == -EBUSY ? D_QUOTA : D_ERROR,
2020 "dqacq failed! (rc:%d)\n", rc);
2021 req->rq_status = rc;
2023 /* there are three forms of qunit(historic causes), so we need to
2024 * adjust the same form to different forms slaves needed */
2025 rc = quota_copy_qdata(req, qdata, QUOTA_REPLY, QUOTA_EXPORT);
2027 CDEBUG(D_ERROR, "Can't pack qunit_data(rc: %d)\n", rc);
2031 /* Block the quota req. b=14840 */
2032 OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_BLOCK_QUOTA_REQ, obd_timeout);
2034 rc = ptlrpc_reply(req);
2036 OBD_FREE(qdata, sizeof(struct qunit_data));
2040 #endif /* !__KERNEL__ */
2042 #endif /* HAVE_QUOTA_SUPPORT */
2044 ldlm_mode_t lck_compat_array[] = {
2045 [LCK_EX] LCK_COMPAT_EX,
2046 [LCK_PW] LCK_COMPAT_PW,
2047 [LCK_PR] LCK_COMPAT_PR,
2048 [LCK_CW] LCK_COMPAT_CW,
2049 [LCK_CR] LCK_COMPAT_CR,
2050 [LCK_NL] LCK_COMPAT_NL,
2051 [LCK_GROUP] LCK_COMPAT_GROUP