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 imp_conn->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)) {
212 rq_portal = OST_REQUEST_PORTAL;
213 rp_portal = OSC_REPLY_PORTAL;
214 connect_op = OST_CONNECT;
215 } else if (!strcmp(name, LUSTRE_MDC_NAME)) {
216 rq_portal = MDS_REQUEST_PORTAL;
217 rp_portal = MDC_REPLY_PORTAL;
218 connect_op = MDS_CONNECT;
219 } else if (!strcmp(name, LUSTRE_MGC_NAME)) {
220 rq_portal = MGS_REQUEST_PORTAL;
221 rp_portal = MGC_REPLY_PORTAL;
222 connect_op = MGS_CONNECT;
224 CERROR("unknown client OBD type \"%s\", can't setup\n",
229 if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) {
230 CERROR("requires a TARGET UUID\n");
234 if (LUSTRE_CFG_BUFLEN(lcfg, 1) > 37) {
235 CERROR("client UUID must be less than 38 characters\n");
239 if (LUSTRE_CFG_BUFLEN(lcfg, 2) < 1) {
240 CERROR("setup requires a SERVER UUID\n");
244 if (LUSTRE_CFG_BUFLEN(lcfg, 2) > 37) {
245 CERROR("target UUID must be less than 38 characters\n");
249 init_rwsem(&cli->cl_sem);
250 sema_init(&cli->cl_mgc_sem, 1);
251 cli->cl_conn_count = 0;
252 memcpy(server_uuid.uuid, lustre_cfg_buf(lcfg, 2),
253 min_t(unsigned int, LUSTRE_CFG_BUFLEN(lcfg, 2),
254 sizeof(server_uuid)));
257 cli->cl_avail_grant = 0;
258 /* FIXME: should limit this for the sum of all cl_dirty_max */
259 cli->cl_dirty_max = OSC_MAX_DIRTY_DEFAULT * 1024 * 1024;
260 if (cli->cl_dirty_max >> CFS_PAGE_SHIFT > num_physpages / 8)
261 cli->cl_dirty_max = num_physpages << (CFS_PAGE_SHIFT - 3);
262 CFS_INIT_LIST_HEAD(&cli->cl_cache_waiters);
263 CFS_INIT_LIST_HEAD(&cli->cl_loi_ready_list);
264 CFS_INIT_LIST_HEAD(&cli->cl_loi_hp_ready_list);
265 CFS_INIT_LIST_HEAD(&cli->cl_loi_write_list);
266 CFS_INIT_LIST_HEAD(&cli->cl_loi_read_list);
267 client_obd_list_lock_init(&cli->cl_loi_list_lock);
268 cli->cl_r_in_flight = 0;
269 cli->cl_w_in_flight = 0;
270 spin_lock_init(&cli->cl_read_rpc_hist.oh_lock);
271 spin_lock_init(&cli->cl_write_rpc_hist.oh_lock);
272 spin_lock_init(&cli->cl_read_page_hist.oh_lock);
273 spin_lock_init(&cli->cl_write_page_hist.oh_lock);
274 spin_lock_init(&cli->cl_read_offset_hist.oh_lock);
275 spin_lock_init(&cli->cl_write_offset_hist.oh_lock);
276 cfs_waitq_init(&cli->cl_destroy_waitq);
277 atomic_set(&cli->cl_destroy_in_flight, 0);
278 #ifdef ENABLE_CHECKSUM
279 /* Turn on checksumming by default. */
280 cli->cl_checksum = 1;
282 * The supported checksum types will be worked out at connect time
283 * Set cl_chksum* to CRC32 for now to avoid returning screwed info
286 cli->cl_cksum_type = cli->cl_supp_cksum_types = OBD_CKSUM_CRC32;
288 atomic_set(&cli->cl_resends, OSC_DEFAULT_RESENDS);
290 /* This value may be changed at connect time in
291 ptlrpc_connect_interpret. */
292 cli->cl_max_pages_per_rpc = min((int)PTLRPC_MAX_BRW_PAGES,
293 (int)(1024 * 1024 >> CFS_PAGE_SHIFT));
295 if (!strcmp(name, LUSTRE_MDC_NAME)) {
296 cli->cl_max_rpcs_in_flight = MDC_MAX_RIF_DEFAULT;
297 } else if (num_physpages >> (20 - CFS_PAGE_SHIFT) <= 128 /* MB */) {
298 cli->cl_max_rpcs_in_flight = 2;
299 } else if (num_physpages >> (20 - CFS_PAGE_SHIFT) <= 256 /* MB */) {
300 cli->cl_max_rpcs_in_flight = 3;
301 } else if (num_physpages >> (20 - CFS_PAGE_SHIFT) <= 512 /* MB */) {
302 cli->cl_max_rpcs_in_flight = 4;
304 cli->cl_max_rpcs_in_flight = OSC_MAX_RIF_DEFAULT;
308 CERROR("ldlm_get_ref failed: %d\n", rc);
312 ptlrpc_init_client(rq_portal, rp_portal, name,
313 &obddev->obd_ldlm_client);
315 imp = class_new_import(obddev);
317 GOTO(err_ldlm, rc = -ENOENT);
318 imp->imp_client = &obddev->obd_ldlm_client;
319 imp->imp_connect_op = connect_op;
320 imp->imp_initial_recov = 1;
321 imp->imp_initial_recov_bk = 0;
322 CFS_INIT_LIST_HEAD(&imp->imp_pinger_chain);
323 memcpy(cli->cl_target_uuid.uuid, lustre_cfg_buf(lcfg, 1),
324 LUSTRE_CFG_BUFLEN(lcfg, 1));
325 class_import_put(imp);
327 rc = client_import_add_conn(imp, &server_uuid, 1);
329 CERROR("can't add initial connection\n");
330 GOTO(err_import, rc);
333 cli->cl_import = imp;
334 /* cli->cl_max_mds_{easize,cookiesize} updated by mdc_init_ea_size() */
335 cli->cl_max_mds_easize = sizeof(struct lov_mds_md_v3);
336 cli->cl_max_mds_cookiesize = sizeof(struct llog_cookie);
338 if (LUSTRE_CFG_BUFLEN(lcfg, 3) > 0) {
339 if (!strcmp(lustre_cfg_string(lcfg, 3), "inactive")) {
340 CDEBUG(D_HA, "marking %s %s->%s as inactive\n",
341 name, obddev->obd_name,
342 cli->cl_target_uuid.uuid);
343 spin_lock(&imp->imp_lock);
344 imp->imp_invalid = 1;
345 spin_unlock(&imp->imp_lock);
349 cli->cl_qchk_stat = CL_NOT_QUOTACHECKED;
354 class_destroy_import(imp);
362 int client_obd_cleanup(struct obd_device *obddev)
369 /* ->o_connect() method for client side (OSC and MDC and MGC) */
370 int client_connect_import(struct lustre_handle *dlm_handle,
371 struct obd_device *obd, struct obd_uuid *cluuid,
372 struct obd_connect_data *data, void *localdata)
374 struct client_obd *cli = &obd->u.cli;
375 struct obd_import *imp = cli->cl_import;
376 struct obd_export **exp = localdata;
377 struct obd_connect_data *ocd;
378 struct ldlm_namespace *to_be_freed = NULL;
382 down_write(&cli->cl_sem);
383 if (cli->cl_conn_count > 0)
384 GOTO(out_sem, rc = -EALREADY);
386 rc = class_connect(dlm_handle, obd, cluuid);
390 cli->cl_conn_count++;
391 *exp = class_conn2export(dlm_handle);
393 if (obd->obd_namespace != NULL)
394 CERROR("already have namespace!\n");
395 obd->obd_namespace = ldlm_namespace_new(obd, obd->obd_name,
396 LDLM_NAMESPACE_CLIENT,
397 LDLM_NAMESPACE_GREEDY);
398 if (obd->obd_namespace == NULL)
399 GOTO(out_disco, rc = -ENOMEM);
401 imp->imp_dlm_handle = *dlm_handle;
402 rc = ptlrpc_init_import(imp);
406 ocd = &imp->imp_connect_data;
409 imp->imp_connect_flags_orig = data->ocd_connect_flags;
412 rc = ptlrpc_connect_import(imp, NULL);
414 LASSERT (imp->imp_state == LUSTRE_IMP_DISCON);
417 LASSERT((*exp)->exp_connection);
420 LASSERT((ocd->ocd_connect_flags & data->ocd_connect_flags) ==
421 ocd->ocd_connect_flags);
422 data->ocd_connect_flags = ocd->ocd_connect_flags;
425 ptlrpc_pinger_add_import(imp);
430 ldlm_namespace_free_prior(obd->obd_namespace, imp, 0);
431 to_be_freed = obd->obd_namespace;
432 obd->obd_namespace = NULL;
434 cli->cl_conn_count--;
435 class_disconnect(*exp);
439 up_write(&cli->cl_sem);
441 ldlm_namespace_free_post(to_be_freed);
445 int client_disconnect_export(struct obd_export *exp)
447 struct obd_device *obd = class_exp2obd(exp);
448 struct client_obd *cli;
449 struct obd_import *imp;
450 struct ldlm_namespace *to_be_freed = NULL;
455 CERROR("invalid export for disconnect: exp %p cookie "LPX64"\n",
456 exp, exp ? exp->exp_handle.h_cookie : -1);
461 imp = cli->cl_import;
463 down_write(&cli->cl_sem);
464 if (!cli->cl_conn_count) {
465 CERROR("disconnecting disconnected device (%s)\n",
467 GOTO(out_sem, rc = -EINVAL);
470 cli->cl_conn_count--;
471 if (cli->cl_conn_count)
472 GOTO(out_no_disconnect, rc = 0);
474 /* Mark import deactivated now, so we don't try to reconnect if any
475 * of the cleanup RPCs fails (e.g. ldlm cancel, etc). We don't
476 * fully deactivate the import, or that would drop all requests. */
477 spin_lock(&imp->imp_lock);
478 imp->imp_deactive = 1;
479 spin_unlock(&imp->imp_lock);
481 /* Some non-replayable imports (MDS's OSCs) are pinged, so just
482 * delete it regardless. (It's safe to delete an import that was
484 (void)ptlrpc_pinger_del_import(imp);
486 if (obd->obd_namespace != NULL) {
487 /* obd_force == local only */
488 ldlm_cli_cancel_unused(obd->obd_namespace, NULL,
489 obd->obd_force ? LDLM_FL_LOCAL_ONLY:0,
491 ldlm_namespace_free_prior(obd->obd_namespace, imp,
493 to_be_freed = obd->obd_namespace;
496 rc = ptlrpc_disconnect_import(imp, 0);
498 ptlrpc_invalidate_import(imp);
499 /* set obd_namespace to NULL only after invalidate, because we can have
500 * some connect requests in flight, and his need store a connect flags
501 * in obd_namespace. bug 14260 */
502 obd->obd_namespace = NULL;
504 if (imp->imp_rq_pool) {
505 ptlrpc_free_rq_pool(imp->imp_rq_pool);
506 imp->imp_rq_pool = NULL;
508 class_destroy_import(imp);
509 cli->cl_import = NULL;
513 err = class_disconnect(exp);
517 up_write(&cli->cl_sem);
519 ldlm_namespace_free_post(to_be_freed);
523 /* --------------------------------------------------------------------------
524 * from old lib/target.c
525 * -------------------------------------------------------------------------- */
527 static int target_handle_reconnect(struct lustre_handle *conn,
528 struct obd_export *exp,
529 struct obd_uuid *cluuid)
532 if (exp->exp_connection && exp->exp_imp_reverse) {
533 struct lustre_handle *hdl;
534 hdl = &exp->exp_imp_reverse->imp_remote_handle;
535 /* Might be a re-connect after a partition. */
536 if (!memcmp(&conn->cookie, &hdl->cookie, sizeof conn->cookie)) {
537 CWARN("%s: %s reconnecting\n", exp->exp_obd->obd_name,
539 conn->cookie = exp->exp_handle.h_cookie;
540 /* target_handle_connect() treats EALREADY and
541 * -EALREADY differently. EALREADY means we are
542 * doing a valid reconnect from the same client. */
545 CERROR("%s reconnecting from %s, "
546 "handle mismatch (ours "LPX64", theirs "
547 LPX64")\n", cluuid->uuid,
548 exp->exp_connection->c_remote_uuid.uuid,
549 hdl->cookie, conn->cookie);
550 memset(conn, 0, sizeof *conn);
551 /* target_handle_connect() treats EALREADY and
552 * -EALREADY differently. -EALREADY is an error
553 * (same UUID, different handle). */
558 conn->cookie = exp->exp_handle.h_cookie;
559 CDEBUG(D_HA, "connect export for UUID '%s' at %p, cookie "LPX64"\n",
560 cluuid->uuid, exp, conn->cookie);
564 void target_client_add_cb(struct obd_device *obd, __u64 transno, void *cb_data,
567 struct obd_export *exp = cb_data;
569 CDEBUG(D_RPCTRACE, "%s: committing for initial connect of %s\n",
570 obd->obd_name, exp->exp_client_uuid.uuid);
572 spin_lock(&exp->exp_lock);
573 exp->exp_need_sync = 0;
574 spin_unlock(&exp->exp_lock);
576 EXPORT_SYMBOL(target_client_add_cb);
579 target_start_and_reset_recovery_timer(struct obd_device *obd,
580 svc_handler_t handler,
581 struct ptlrpc_request *req,
583 void target_stop_recovery(void *, int);
584 static void reset_recovery_timer(struct obd_device *obd, int duration,
586 int target_recovery_check_and_stop(struct obd_device *obd)
588 int abort_recovery = 0;
590 spin_lock_bh(&obd->obd_processing_task_lock);
591 abort_recovery = obd->obd_abort_recovery;
592 obd->obd_abort_recovery = 0;
593 spin_unlock_bh(&obd->obd_processing_task_lock);
596 /** check is fs version-capable */
597 if (target_fs_version_capable(obd)) {
598 class_handle_stale_exports(obd);
600 CWARN("Versions are not supported by ldiskfs, VBR is OFF\n");
601 class_disconnect_stale_exports(obd, exp_flags_from_obd(obd));
603 /* VBR: no clients are remained to replay, stop recovery */
604 spin_lock_bh(&obd->obd_processing_task_lock);
605 if (obd->obd_recovering && obd->obd_recoverable_clients == 0) {
606 spin_unlock_bh(&obd->obd_processing_task_lock);
607 target_stop_recovery(obd, 0);
610 /* always check versions now */
611 obd->obd_version_recov = 1;
612 spin_unlock_bh(&obd->obd_processing_task_lock);
613 /* reset timer, recovery will proceed with versions now */
614 reset_recovery_timer(obd, OBD_RECOVERY_FACTOR * obd_timeout, 1);
617 EXPORT_SYMBOL(target_recovery_check_and_stop);
619 int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler)
621 struct obd_device *target, *targref = NULL;
622 struct obd_export *export = NULL;
623 struct obd_import *revimp;
624 struct lustre_handle conn;
625 struct obd_uuid tgtuuid;
626 struct obd_uuid cluuid;
627 struct obd_uuid remote_uuid;
630 struct obd_connect_data *data;
631 __u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(*data) };
632 lnet_nid_t *client_nid = NULL;
636 OBD_RACE(OBD_FAIL_TGT_CONN_RACE);
638 lustre_set_req_swabbed(req, REQ_REC_OFF);
639 str = lustre_msg_string(req->rq_reqmsg, REQ_REC_OFF, sizeof(tgtuuid)-1);
641 DEBUG_REQ(D_ERROR, req, "bad target UUID for connect");
642 GOTO(out, rc = -EINVAL);
645 obd_str2uuid (&tgtuuid, str);
646 target = class_uuid2obd(&tgtuuid);
648 /* old (pre 1.6) lustre_process_log tries to connect to mdsname
649 (eg. mdsA) instead of uuid. */
651 snprintf((char *)tgtuuid.uuid, sizeof(tgtuuid), "%s_UUID", str);
652 target = class_uuid2obd(&tgtuuid);
655 target = class_name2obd(str);
658 if (!target || target->obd_stopping || !target->obd_set_up) {
659 LCONSOLE_ERROR_MSG(0x137, "UUID '%s' is not available "
660 " for connect (%s)\n", str,
661 !target ? "no target" :
662 (target->obd_stopping ? "stopping" :
664 GOTO(out, rc = -ENODEV);
667 if (target->obd_no_conn) {
668 LCONSOLE_WARN("%s: temporarily refusing client connection "
669 "from %s\n", target->obd_name,
670 libcfs_nid2str(req->rq_peer.nid));
671 GOTO(out, rc = -EAGAIN);
674 /* Make sure the target isn't cleaned up while we're here. Yes,
675 there's still a race between the above check and our incref here.
676 Really, class_uuid2obd should take the ref. */
677 targref = class_incref(target);
679 lustre_set_req_swabbed(req, REQ_REC_OFF + 1);
680 str = lustre_msg_string(req->rq_reqmsg, REQ_REC_OFF + 1,
683 DEBUG_REQ(D_ERROR, req, "bad client UUID for connect");
684 GOTO(out, rc = -EINVAL);
687 obd_str2uuid (&cluuid, str);
689 /* XXX extract a nettype and format accordingly */
690 switch (sizeof(lnet_nid_t)) {
691 /* NB the casts only avoid compiler warnings */
693 snprintf(remote_uuid.uuid, sizeof remote_uuid,
694 "NET_"LPX64"_UUID", (__u64)req->rq_peer.nid);
697 snprintf(remote_uuid.uuid, sizeof remote_uuid,
698 "NET_%x_UUID", (__u32)req->rq_peer.nid);
704 target_recovery_check_and_stop(target);
706 tmp = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 2, sizeof conn);
708 GOTO(out, rc = -EPROTO);
710 memcpy(&conn, tmp, sizeof conn);
712 data = lustre_swab_reqbuf(req, REQ_REC_OFF + 3, sizeof(*data),
713 lustre_swab_connect);
714 rc = lustre_pack_reply(req, 2, size, NULL);
718 if (lustre_msg_get_op_flags(req->rq_reqmsg) & MSG_CONNECT_LIBCLIENT) {
720 DEBUG_REQ(D_WARNING, req, "Refusing old (unversioned) "
721 "libclient connection attempt");
722 GOTO(out, rc = -EPROTO);
723 } else if (data->ocd_version < LUSTRE_VERSION_CODE -
724 LUSTRE_VERSION_ALLOWED_OFFSET ||
725 data->ocd_version > LUSTRE_VERSION_CODE +
726 LUSTRE_VERSION_ALLOWED_OFFSET) {
727 DEBUG_REQ(D_WARNING, req, "Refusing %s (%d.%d.%d.%d) "
728 "libclient connection attempt",
729 data->ocd_version < LUSTRE_VERSION_CODE ?
731 OBD_OCD_VERSION_MAJOR(data->ocd_version),
732 OBD_OCD_VERSION_MINOR(data->ocd_version),
733 OBD_OCD_VERSION_PATCH(data->ocd_version),
734 OBD_OCD_VERSION_FIX(data->ocd_version));
735 data = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
736 offsetof(typeof(*data),
738 sizeof(data->ocd_version));
740 data->ocd_connect_flags = OBD_CONNECT_VERSION;
741 data->ocd_version = LUSTRE_VERSION_CODE;
743 GOTO(out, rc = -EPROTO);
747 if ((lustre_msg_get_op_flags(req->rq_reqmsg) & MSG_CONNECT_INITIAL) &&
748 (data->ocd_connect_flags & OBD_CONNECT_MDS))
751 /* lctl gets a backstage, all-access pass. */
752 if (obd_uuid_equals(&cluuid, &target->obd_uuid))
753 goto dont_check_exports;
755 export = lustre_hash_lookup(target->obd_uuid_hash, &cluuid);
759 /* we've found an export in the hash */
760 if (export->exp_connecting) {
761 /* bug 9635, et. al. */
762 CWARN("%s: exp %p already connecting\n",
763 export->exp_obd->obd_name, export);
764 class_export_put(export);
767 } else if (mds_conn && export->exp_connection) {
768 if (req->rq_peer.nid != export->exp_connection->c_peer.nid)
769 /* mds reconnected after failover */
770 CWARN("%s: received MDS connection from NID %s,"
771 " removing former export from NID %s\n",
772 target->obd_name, libcfs_nid2str(req->rq_peer.nid),
773 libcfs_nid2str(export->exp_connection->c_peer.nid));
775 /* new mds connection from the same nid */
776 CWARN("%s: received new MDS connection from NID %s,"
777 " removing former export from same NID\n",
778 target->obd_name, libcfs_nid2str(req->rq_peer.nid));
779 class_fail_export(export);
780 class_export_put(export);
783 } else if (export->exp_connection &&
784 req->rq_peer.nid != export->exp_connection->c_peer.nid) {
785 CWARN("%s: cookie %s seen on new NID %s when "
786 "existing NID %s is already connected\n",
787 target->obd_name, cluuid.uuid,
788 libcfs_nid2str(req->rq_peer.nid),
789 libcfs_nid2str(export->exp_connection->c_peer.nid));
791 class_export_put(export);
793 } else if (export->exp_failed) { /* bug 11327 */
794 CDEBUG(D_HA, "%s: exp %p evict in progress - new cookie needed "
795 "for connect\n", export->exp_obd->obd_name, export);
796 class_export_put(export);
799 } else if (export->exp_delayed &&
800 !(data && data->ocd_connect_flags & OBD_CONNECT_VBR)) {
801 class_fail_export(export);
802 class_export_put(export);
804 GOTO(out, rc = -ENODEV);
806 spin_lock(&export->exp_lock);
807 export->exp_connecting = 1;
808 spin_unlock(&export->exp_lock);
809 class_export_put(export);
810 LASSERT(export->exp_obd == target);
812 rc = target_handle_reconnect(&conn, export, &cluuid);
815 /* If we found an export, we already unlocked. */
818 OBD_FAIL_TIMEOUT(OBD_FAIL_TGT_DELAY_CONNECT, 2 * obd_timeout);
819 } else if (req->rq_export == NULL &&
820 atomic_read(&export->exp_rpc_count) > 0) {
821 CWARN("%s: refuse connection from %s/%s to 0x%p; still busy "
822 "with %d references\n", target->obd_name, cluuid.uuid,
823 libcfs_nid2str(req->rq_peer.nid),
824 export, atomic_read(&export->exp_refcount));
825 GOTO(out, rc = -EBUSY);
826 } else if (req->rq_export != NULL &&
827 atomic_read(&export->exp_rpc_count) > 1) {
828 /* the current connect rpc has increased exp_rpc_count */
829 CWARN("%s: refuse reconnection from %s@%s to 0x%p; still busy "
830 "with %d active RPCs\n", target->obd_name, cluuid.uuid,
831 libcfs_nid2str(req->rq_peer.nid),
832 export, atomic_read(&export->exp_rpc_count) - 1);
833 GOTO(out, rc = -EBUSY);
834 } else if (lustre_msg_get_conn_cnt(req->rq_reqmsg) == 1) {
835 CERROR("%s: NID %s (%s) reconnected with 1 conn_cnt; "
836 "cookies not random?\n", target->obd_name,
837 libcfs_nid2str(req->rq_peer.nid), cluuid.uuid);
838 GOTO(out, rc = -EALREADY);
839 } else if (export->exp_delayed && target->obd_recovering) {
840 /* VBR: don't allow delayed connection during recovery */
841 CWARN("%s: NID %s (%s) export was already marked as delayed "
842 "and will wait for end of recovery\n", target->obd_name,
843 libcfs_nid2str(req->rq_peer.nid), cluuid.uuid);
844 GOTO(out, rc = -EBUSY);
846 OBD_FAIL_TIMEOUT(OBD_FAIL_TGT_DELAY_RECONNECT, 2 * obd_timeout);
852 /* Tell the client if we're in recovery. */
853 if (target->obd_recovering) {
854 lustre_msg_add_op_flags(req->rq_repmsg, MSG_CONNECT_RECOVERING);
855 /* If this is the first time a client connects,
856 reset the recovery timer */
858 target_start_and_reset_recovery_timer(target, handler,
862 /* We want to handle EALREADY but *not* -EALREADY from
863 * target_handle_reconnect(), return reconnection state in a flag */
864 if (rc == EALREADY) {
865 lustre_msg_add_op_flags(req->rq_repmsg, MSG_CONNECT_RECONNECT);
871 /* Tell the client if we support replayable requests */
872 if (target->obd_replayable)
873 lustre_msg_add_op_flags(req->rq_repmsg, MSG_CONNECT_REPLAYABLE);
874 client_nid = &req->rq_peer.nid;
876 /* VBR: for delayed connections we start recovery */
877 if (export && export->exp_delayed && !export->exp_in_recovery) {
878 LASSERT(!target->obd_recovering);
879 LASSERT(data && data->ocd_connect_flags & OBD_CONNECT_VBR);
880 lustre_msg_add_op_flags(req->rq_repmsg, MSG_CONNECT_DELAYED |
881 MSG_CONNECT_RECOVERING);
882 spin_lock_bh(&target->obd_processing_task_lock);
883 target->obd_version_recov = 1;
884 spin_unlock_bh(&target->obd_processing_task_lock);
885 target_start_and_reset_recovery_timer(target, handler, req, 1);
888 if (export == NULL) {
889 if (target->obd_recovering) {
890 CERROR("%s: denying connection for new client %s (%s): "
891 "%d clients in recovery for %lds\n",
893 libcfs_nid2str(req->rq_peer.nid), cluuid.uuid,
894 target->obd_recoverable_clients,
895 cfs_duration_sec(cfs_time_sub(cfs_timer_deadline(&target->obd_recovery_timer),
896 cfs_time_current())));
900 rc = obd_connect(&conn, target, &cluuid, data,
904 rc = obd_reconnect(export, target, &cluuid, data, client_nid);
910 /* Return only the parts of obd_connect_data that we understand, so the
911 * client knows that we don't understand the rest. */
913 memcpy(lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
915 data, sizeof(*data));
917 /* If all else goes well, this is our RPC return code. */
920 lustre_msg_set_handle(req->rq_repmsg, &conn);
922 /* ownership of this export ref transfers to the request AFTER we
923 * drop any previous reference the request had, but we don't want
924 * that to go to zero before we get our new export reference. */
925 export = class_conn2export(&conn);
927 DEBUG_REQ(D_ERROR, req, "Missing export!");
928 GOTO(out, rc = -ENODEV);
931 /* If the client and the server are the same node, we will already
932 * have an export that really points to the client's DLM export,
933 * because we have a shared handles table.
935 * XXX this will go away when shaver stops sending the "connect" handle
936 * in the real "remote handle" field of the request --phik 24 Apr 2003
938 if (req->rq_export != NULL)
939 class_export_put(req->rq_export);
941 req->rq_export = export;
943 spin_lock(&export->exp_lock);
944 if (export->exp_conn_cnt >= lustre_msg_get_conn_cnt(req->rq_reqmsg)) {
945 CERROR("%s: %s already connected at higher conn_cnt: %d > %d\n",
946 cluuid.uuid, libcfs_nid2str(req->rq_peer.nid),
947 export->exp_conn_cnt,
948 lustre_msg_get_conn_cnt(req->rq_reqmsg));
950 spin_unlock(&export->exp_lock);
951 GOTO(out, rc = -EALREADY);
953 export->exp_conn_cnt = lustre_msg_get_conn_cnt(req->rq_reqmsg);
955 /* request from liblustre? Don't evict it for not pinging. */
956 if (lustre_msg_get_op_flags(req->rq_reqmsg) & MSG_CONNECT_LIBCLIENT) {
957 export->exp_libclient = 1;
958 spin_unlock(&export->exp_lock);
960 spin_lock(&target->obd_dev_lock);
961 list_del_init(&export->exp_obd_chain_timed);
962 spin_unlock(&target->obd_dev_lock);
964 spin_unlock(&export->exp_lock);
967 if (export->exp_connection != NULL)
968 ptlrpc_connection_put(export->exp_connection);
969 export->exp_connection = ptlrpc_connection_get(req->rq_peer,
973 if (hlist_unhashed(&export->exp_nid_hash)) {
974 lustre_hash_add_unique(export->exp_obd->obd_nid_hash,
975 &export->exp_connection->c_peer.nid,
976 &export->exp_nid_hash);
979 if (lustre_msg_get_op_flags(req->rq_repmsg) & MSG_CONNECT_RECONNECT) {
980 revimp = class_import_get(export->exp_imp_reverse);
981 GOTO(set_flags, rc = 0);
984 if (target->obd_recovering && !export->exp_in_recovery) {
985 spin_lock(&export->exp_lock);
986 export->exp_in_recovery = 1;
987 spin_unlock(&export->exp_lock);
988 target->obd_connected_clients++;
991 lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 2, sizeof conn),
994 if (export->exp_imp_reverse != NULL)
995 class_destroy_import(export->exp_imp_reverse);
996 revimp = export->exp_imp_reverse = class_new_import(target);
997 revimp->imp_connection = ptlrpc_connection_addref(export->exp_connection);
998 revimp->imp_client = &export->exp_obd->obd_ldlm_client;
999 revimp->imp_remote_handle = conn;
1000 revimp->imp_dlm_fake = 1;
1001 revimp->imp_state = LUSTRE_IMP_FULL;
1004 if (req->rq_reqmsg->lm_magic == LUSTRE_MSG_MAGIC_V1 &&
1005 lustre_msg_get_op_flags(req->rq_reqmsg) & MSG_CONNECT_NEXT_VER) {
1006 revimp->imp_msg_magic = LUSTRE_MSG_MAGIC_V2;
1007 lustre_msg_add_op_flags(req->rq_repmsg, MSG_CONNECT_NEXT_VER);
1009 /* unknown versions will be caught in
1010 * ptlrpc_handle_server_req_in->lustre_unpack_msg() */
1011 revimp->imp_msg_magic = req->rq_reqmsg->lm_magic;
1014 if (revimp->imp_msg_magic != LUSTRE_MSG_MAGIC_V1) {
1015 if (export->exp_connect_flags & OBD_CONNECT_AT)
1016 revimp->imp_msghdr_flags |= MSGHDR_AT_SUPPORT;
1018 revimp->imp_msghdr_flags &= ~MSGHDR_AT_SUPPORT;
1021 class_import_put(revimp);
1024 spin_lock(&export->exp_lock);
1025 export->exp_connecting = 0;
1026 spin_unlock(&export->exp_lock);
1029 class_decref(targref);
1031 req->rq_status = rc;
1035 int target_handle_disconnect(struct ptlrpc_request *req)
1040 rc = lustre_pack_reply(req, 1, NULL, NULL);
1044 /* keep the rq_export around so we can send the reply */
1045 req->rq_status = obd_disconnect(class_export_get(req->rq_export));
1049 void target_destroy_export(struct obd_export *exp)
1051 /* exports created from last_rcvd data, and "fake"
1052 exports created by lctl don't have an import */
1053 if (exp->exp_imp_reverse != NULL)
1054 class_destroy_import(exp->exp_imp_reverse);
1056 /* We cancel locks at disconnect time, but this will catch any locks
1057 * granted in a race with recovery-induced disconnect. */
1058 if (exp->exp_obd->obd_namespace != NULL)
1059 ldlm_cancel_locks_for_export(exp);
1063 * Recovery functions
1066 static int target_exp_enqueue_req_replay(struct ptlrpc_request *req)
1068 __u64 transno = lustre_msg_get_transno(req->rq_reqmsg);
1069 struct obd_export *exp = req->rq_export;
1070 struct ptlrpc_request *reqiter;
1075 spin_lock(&exp->exp_lock);
1076 list_for_each_entry(reqiter, &exp->exp_req_replay_queue,
1078 if (lustre_msg_get_transno(reqiter->rq_reqmsg) == transno) {
1085 /* we expect it with RESENT and REPLAY flags */
1086 if ((lustre_msg_get_flags(req->rq_reqmsg) &
1087 (MSG_RESENT | MSG_REPLAY)) != (MSG_RESENT | MSG_REPLAY))
1088 CERROR("invalid flags %x of resent replay\n",
1089 lustre_msg_get_flags(req->rq_reqmsg));
1091 list_add_tail(&req->rq_replay_list, &exp->exp_req_replay_queue);
1094 spin_unlock(&exp->exp_lock);
1098 static void target_exp_dequeue_req_replay(struct ptlrpc_request *req)
1100 LASSERT(!list_empty(&req->rq_replay_list));
1101 LASSERT(req->rq_export);
1103 spin_lock(&req->rq_export->exp_lock);
1104 list_del_init(&req->rq_replay_list);
1105 spin_unlock(&req->rq_export->exp_lock);
1108 static void target_release_saved_req(struct ptlrpc_request *req)
1110 ptlrpc_req_drop_rs(req);
1111 class_export_put(req->rq_export);
1112 OBD_FREE(req->rq_reqmsg, req->rq_reqlen);
1113 OBD_FREE(req, sizeof *req);
1116 static void target_send_delayed_replies(struct obd_device *obd)
1118 int max_clients = obd->obd_max_recoverable_clients;
1119 struct ptlrpc_request *req, *tmp;
1120 time_t elapsed_time = max_t(time_t, 1, cfs_time_current_sec() -
1121 obd->obd_recovery_start);
1123 LCONSOLE_INFO("%s: Recovery period over after %d:%.02d, of %d clients "
1124 "%d recovered and %d %s evicted.\n", obd->obd_name,
1125 (int)elapsed_time/60, (int)elapsed_time%60, max_clients,
1126 max_clients - obd->obd_recoverable_clients,
1127 obd->obd_stale_clients,
1128 obd->obd_stale_clients == 1 ? "was" : "were");
1130 LCONSOLE_INFO("%s: sending delayed replies to recovered clients\n",
1133 list_for_each_entry_safe(req, tmp, &obd->obd_delayed_reply_queue,
1135 list_del_init(&req->rq_list);
1136 DEBUG_REQ(D_HA, req, "delayed:");
1138 target_release_saved_req(req);
1140 obd->obd_recovery_end = cfs_time_current_sec();
1143 static void target_finish_recovery(struct obd_device *obd)
1145 ldlm_reprocess_all_ns(obd->obd_namespace);
1146 spin_lock_bh(&obd->obd_processing_task_lock);
1147 if (list_empty(&obd->obd_recovery_queue)) {
1148 obd->obd_recovery_thread = NULL;
1149 obd->obd_processing_task = 0;
1151 spin_unlock_bh(&obd->obd_processing_task_lock);
1152 CERROR("%s: Recovery queue isn't empty\n", obd->obd_name);
1155 spin_unlock_bh(&obd->obd_processing_task_lock);
1157 /* when recovery finished, cleanup orphans on mds and ost */
1158 if (OBT(obd) && OBP(obd, postrecov)) {
1159 int rc = OBP(obd, postrecov)(obd);
1161 LCONSOLE_WARN("%s: Post recovery failed, rc %d\n",
1164 target_send_delayed_replies(obd);
1167 static void abort_recovery_queue(struct obd_device *obd)
1169 struct ptlrpc_request *req, *n;
1170 struct list_head abort_list;
1173 CFS_INIT_LIST_HEAD(&abort_list);
1174 spin_lock_bh(&obd->obd_processing_task_lock);
1175 list_splice_init(&obd->obd_recovery_queue, &abort_list);
1176 spin_unlock_bh(&obd->obd_processing_task_lock);
1177 /* process abort list unlocked */
1178 list_for_each_entry_safe(req, n, &abort_list, rq_list) {
1179 target_exp_dequeue_req_replay(req);
1180 list_del_init(&req->rq_list);
1181 DEBUG_REQ(D_ERROR, req, "aborted:");
1182 req->rq_status = -ENOTCONN;
1183 req->rq_type = PTL_RPC_MSG_ERR;
1184 rc = lustre_pack_reply(req, 1, NULL, NULL);
1188 DEBUG_REQ(D_ERROR, req,
1189 "packing failed for abort-reply; skipping");
1190 target_release_saved_req(req);
1194 /* Called from a cleanup function if the device is being cleaned up
1195 forcefully. The exports should all have been disconnected already,
1196 the only thing left to do is
1197 - clear the recovery flags
1199 - free queued requests and replies, but don't send replies
1200 Because the obd_stopping flag is set, no new requests should be received.
1203 void target_cleanup_recovery(struct obd_device *obd)
1205 struct list_head *tmp, *n;
1206 struct ptlrpc_request *req;
1207 struct list_head clean_list;
1210 LASSERT(obd->obd_stopping);
1212 spin_lock_bh(&obd->obd_processing_task_lock);
1213 if (!obd->obd_recovering) {
1214 spin_unlock_bh(&obd->obd_processing_task_lock);
1218 obd->obd_recovering = obd->obd_abort_recovery = 0;
1219 target_cancel_recovery_timer(obd);
1220 spin_unlock_bh(&obd->obd_processing_task_lock);
1222 list_for_each_safe(tmp, n, &obd->obd_delayed_reply_queue) {
1223 req = list_entry(tmp, struct ptlrpc_request, rq_list);
1224 list_del(&req->rq_list);
1225 target_release_saved_req(req);
1228 CFS_INIT_LIST_HEAD(&clean_list);
1229 spin_lock_bh(&obd->obd_processing_task_lock);
1230 list_splice_init(&obd->obd_recovery_queue, &clean_list);
1231 spin_unlock_bh(&obd->obd_processing_task_lock);
1232 list_for_each_safe(tmp, n, &clean_list) {
1233 req = list_entry(tmp, struct ptlrpc_request, rq_list);
1234 target_exp_dequeue_req_replay(req);
1235 list_del_init(&req->rq_list);
1236 target_release_saved_req(req);
1241 void target_stop_recovery(void *data, int abort)
1243 struct obd_device *obd = data;
1244 enum obd_option flags;
1247 spin_lock_bh(&obd->obd_processing_task_lock);
1248 if (!obd->obd_recovering) {
1249 spin_unlock_bh(&obd->obd_processing_task_lock);
1253 flags = exp_flags_from_obd(obd) | OBD_OPT_ABORT_RECOV;
1254 obd->obd_recovering = 0;
1255 obd->obd_abort_recovery = 0;
1256 obd->obd_processing_task = 0;
1258 LASSERT(obd->obd_recoverable_clients == 0);
1260 target_cancel_recovery_timer(obd);
1261 spin_unlock_bh(&obd->obd_processing_task_lock);
1264 LCONSOLE_WARN("%s: recovery is aborted by administrative "
1265 "request; %d clients are not recovered "
1266 "(%d clients did)\n", obd->obd_name,
1267 obd->obd_recoverable_clients,
1268 obd->obd_connected_clients);
1269 class_disconnect_stale_exports(obd, flags);
1271 abort_recovery_queue(obd);
1272 target_finish_recovery(obd);
1273 CDEBUG(D_HA, "%s: recovery complete\n", obd_uuid2str(&obd->obd_uuid));
1277 void target_abort_recovery(void *data)
1279 target_stop_recovery(data, 1);
1282 static void reset_recovery_timer(struct obd_device *, int, int);
1283 static void target_recovery_expired(unsigned long castmeharder)
1285 struct obd_device *obd = (struct obd_device *)castmeharder;
1286 CDEBUG(D_HA, "%s: recovery period over; %d clients never reconnected "
1287 "after %lds (%d clients did)\n", obd->obd_name,
1288 obd->obd_recoverable_clients,
1289 cfs_time_current_sec() - obd->obd_recovery_start,
1290 obd->obd_connected_clients);
1292 spin_lock_bh(&obd->obd_processing_task_lock);
1293 obd->obd_abort_recovery = 1;
1294 cfs_waitq_signal(&obd->obd_next_transno_waitq);
1295 spin_unlock_bh(&obd->obd_processing_task_lock);
1298 /* obd_processing_task_lock should be held */
1299 void target_cancel_recovery_timer(struct obd_device *obd)
1301 CDEBUG(D_HA, "%s: cancel recovery timer\n", obd->obd_name);
1302 cfs_timer_disarm(&obd->obd_recovery_timer);
1305 /* extend = 1 means require at least "duration" seconds left in the timer,
1306 extend = 0 means set the total duration (start_recovery_timer) */
1307 static void reset_recovery_timer(struct obd_device *obd, int duration,
1310 cfs_time_t now = cfs_time_current_sec();
1311 cfs_duration_t left;
1313 spin_lock_bh(&obd->obd_processing_task_lock);
1314 if (!obd->obd_recovering) {
1315 spin_unlock_bh(&obd->obd_processing_task_lock);
1319 left = cfs_time_sub(obd->obd_recovery_end, now);
1321 if (extend && (duration > left))
1322 obd->obd_recovery_timeout += duration - left;
1323 else if (!extend && (duration > obd->obd_recovery_timeout))
1324 /* Track the client's largest expected replay time */
1325 obd->obd_recovery_timeout = duration;
1328 * If total recovery time already exceed the
1329 * obd_recovery_max_time, then CRAY XT3 will
1330 * abort the recovery
1332 if(obd->obd_recovery_timeout > obd->obd_recovery_max_time)
1333 obd->obd_recovery_timeout = obd->obd_recovery_max_time;
1335 obd->obd_recovery_end = obd->obd_recovery_start +
1336 obd->obd_recovery_timeout;
1337 if (cfs_time_before(now, obd->obd_recovery_end)) {
1338 left = cfs_time_sub(obd->obd_recovery_end, now);
1339 cfs_timer_arm(&obd->obd_recovery_timer, cfs_time_shift(left));
1341 spin_unlock_bh(&obd->obd_processing_task_lock);
1342 CDEBUG(D_HA, "%s: recovery timer will expire in %u seconds\n",
1343 obd->obd_name, (unsigned)left);
1346 static void check_and_start_recovery_timer(struct obd_device *obd,
1347 svc_handler_t handler)
1349 spin_lock_bh(&obd->obd_processing_task_lock);
1350 if (obd->obd_recovery_handler) {
1351 spin_unlock_bh(&obd->obd_processing_task_lock);
1354 CDEBUG(D_HA, "%s: starting recovery timer\n", obd->obd_name);
1355 obd->obd_recovery_start = cfs_time_current_sec();
1357 obd->obd_recovery_timeout = OBD_RECOVERY_FACTOR * obd_timeout;
1358 obd->obd_recovery_handler = handler;
1359 cfs_timer_init(&obd->obd_recovery_timer, target_recovery_expired, obd);
1360 spin_unlock_bh(&obd->obd_processing_task_lock);
1362 reset_recovery_timer(obd, obd->obd_recovery_timeout, 0);
1365 /* Reset the timer with each new client connection */
1367 * This timer is actually reconnect_timer, which is for making sure
1368 * the total recovery window is at least as big as my reconnect
1369 * attempt timing. So the initial recovery time_out will be set to
1370 * OBD_RECOVERY_FACTOR * obd_timeout. If the timeout coming
1371 * from client is bigger than this, then the recovery time_out will
1372 * be extend to make sure the client could be reconnected, in the
1373 * process, the timeout from the new client should be ignored.
1377 target_start_and_reset_recovery_timer(struct obd_device *obd,
1378 svc_handler_t handler,
1379 struct ptlrpc_request *req,
1382 int service_time = lustre_msg_get_service_time(req->rq_reqmsg);
1384 if (!new_client && service_time)
1385 /* Teach server about old server's estimates, as first guess
1386 at how long new requests will take. */
1387 at_add(&req->rq_rqbd->rqbd_service->srv_at_estimate,
1390 check_and_start_recovery_timer(obd, handler);
1392 /* convert the service time to rpc timeout,
1393 * reuse service_time to limit stack usage */
1394 service_time = at_est2timeout(service_time);
1396 /* We expect other clients to timeout within service_time, then try
1397 * to reconnect, then try the failover server. The max delay between
1398 * connect attempts is SWITCH_MAX + SWITCH_INC + INITIAL */
1399 service_time += 2 * (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC +
1400 INITIAL_CONNECT_TIMEOUT);
1401 if (service_time > obd->obd_recovery_timeout && !new_client)
1402 reset_recovery_timer(obd, service_time, 0);
1405 static int check_for_next_transno(struct obd_device *obd)
1407 struct ptlrpc_request *req;
1408 int wake_up = 0, connected, completed, queue_len, max;
1409 __u64 next_transno, req_transno;
1411 spin_lock_bh(&obd->obd_processing_task_lock);
1412 req = list_entry(obd->obd_recovery_queue.next,
1413 struct ptlrpc_request, rq_list);
1414 max = obd->obd_max_recoverable_clients;
1415 req_transno = lustre_msg_get_transno(req->rq_reqmsg);
1416 connected = obd->obd_connected_clients;
1417 completed = max - obd->obd_recoverable_clients -
1418 obd->obd_delayed_clients;
1419 queue_len = obd->obd_requests_queued_for_recovery;
1420 next_transno = obd->obd_next_recovery_transno;
1422 CDEBUG(D_HA,"max: %d, connected: %d, delayed %d, completed: %d, "
1423 "queue_len: %d, req_transno: "LPU64", next_transno: "LPU64"\n",
1424 max, connected, obd->obd_delayed_clients, completed, queue_len,
1425 req_transno, next_transno);
1426 if (obd->obd_abort_recovery) {
1427 CDEBUG(D_HA, "waking for aborted recovery\n");
1429 } else if (!obd->obd_recovering) {
1430 CDEBUG(D_HA, "waking for completed recovery (?)\n");
1432 } else if (req_transno == next_transno) {
1433 CDEBUG(D_HA, "waking for next ("LPD64")\n", next_transno);
1435 } else if (queue_len == obd->obd_recoverable_clients) {
1437 "waking for skipped transno (skip: "LPD64
1438 ", ql: %d, comp: %d, conn: %d, next: "LPD64")\n",
1439 next_transno, queue_len, completed, max, req_transno);
1440 obd->obd_next_recovery_transno = req_transno;
1443 spin_unlock_bh(&obd->obd_processing_task_lock);
1444 LASSERT(lustre_msg_get_transno(req->rq_reqmsg) >= next_transno);
1448 static void process_recovery_queue(struct obd_device *obd)
1450 struct ptlrpc_request *req;
1451 struct l_wait_info lwi = { 0 };
1455 spin_lock_bh(&obd->obd_processing_task_lock);
1456 LASSERT(obd->obd_processing_task == cfs_curproc_pid());
1457 req = list_entry(obd->obd_recovery_queue.next,
1458 struct ptlrpc_request, rq_list);
1460 if (lustre_msg_get_transno(req->rq_reqmsg) !=
1461 obd->obd_next_recovery_transno) {
1462 spin_unlock_bh(&obd->obd_processing_task_lock);
1463 CDEBUG(D_HA, "Waiting for transno "LPD64" (1st is "
1464 LPD64", x"LPU64")\n",
1465 obd->obd_next_recovery_transno,
1466 lustre_msg_get_transno(req->rq_reqmsg),
1468 l_wait_event(obd->obd_next_transno_waitq,
1469 check_for_next_transno(obd), &lwi);
1470 if (target_recovery_check_and_stop(obd))
1474 list_del_init(&req->rq_list);
1475 LASSERT(obd->obd_recovery_thread);
1476 /* replace request initial thread with current one, bug #18221 */
1477 req->rq_svc_thread = obd->obd_recovery_thread;
1478 obd->obd_requests_queued_for_recovery--;
1479 spin_unlock_bh(&obd->obd_processing_task_lock);
1481 DEBUG_REQ(D_HA, req, "processing: ");
1482 (void)obd->obd_recovery_handler(req);
1483 obd->obd_replayed_requests++;
1484 /* Extend the recovery timer enough to complete the next
1486 reset_recovery_timer(obd, AT_OFF ? obd_timeout :
1487 at_get(&req->rq_rqbd->rqbd_service->srv_at_estimate), 1);
1488 /* bug 1580: decide how to properly sync() in recovery */
1489 //mds_fsync_super(obd->u.obt.obt_sb);
1490 spin_lock_bh(&obd->obd_processing_task_lock);
1491 obd->obd_next_recovery_transno++;
1492 spin_unlock_bh(&obd->obd_processing_task_lock);
1493 target_exp_dequeue_req_replay(req);
1494 class_export_put(req->rq_export);
1495 ptlrpc_req_drop_rs(req);
1496 OBD_FREE(req->rq_reqmsg, req->rq_reqlen);
1497 OBD_FREE(req, sizeof *req);
1498 OBD_RACE(OBD_FAIL_TGT_REPLAY_DELAY);
1499 spin_lock_bh(&obd->obd_processing_task_lock);
1500 if (list_empty(&obd->obd_recovery_queue)) {
1501 obd->obd_processing_task = 0;
1502 obd->obd_recovery_thread = NULL;
1503 spin_unlock_bh(&obd->obd_processing_task_lock);
1506 spin_unlock_bh(&obd->obd_processing_task_lock);
1511 int target_queue_recovery_request(struct ptlrpc_request *req,
1512 struct obd_device *obd)
1514 struct list_head *tmp;
1516 __u64 transno = lustre_msg_get_transno(req->rq_reqmsg);
1517 struct ptlrpc_request *saved_req;
1518 struct lustre_msg *reqmsg;
1521 /* CAVEAT EMPTOR: The incoming request message has been swabbed
1522 * (i.e. buflens etc are in my own byte order), but type-dependent
1523 * buffers (eg mds_body, ost_body etc) have NOT been swabbed. */
1526 CFS_INIT_LIST_HEAD(&req->rq_list);
1527 DEBUG_REQ(D_HA, req, "not queueing");
1531 /* XXX If I were a real man, these LBUGs would be sane cleanups. */
1532 /* XXX just like the request-dup code in queue_final_reply */
1533 OBD_ALLOC(saved_req, sizeof *saved_req);
1536 OBD_ALLOC(reqmsg, req->rq_reqlen);
1540 spin_lock_bh(&obd->obd_processing_task_lock);
1542 /* If we're processing the queue, we want don't want to queue this
1545 * Also, if this request has a transno less than the one we're waiting
1546 * for, we should process it now. It could (and currently always will)
1547 * be an open request for a descriptor that was opened some time ago.
1549 * Also, a resent, replayed request that has already been
1550 * handled will pass through here and be processed immediately.
1552 if (obd->obd_processing_task == cfs_curproc_pid() ||
1553 transno < obd->obd_next_recovery_transno) {
1554 /* Processing the queue right now, don't re-add. */
1555 LASSERT(list_empty(&req->rq_list));
1556 spin_unlock_bh(&obd->obd_processing_task_lock);
1557 GOTO(err_free, rc = 1);
1560 if (unlikely(OBD_FAIL_CHECK(OBD_FAIL_TGT_REPLAY_DROP))) {
1561 spin_unlock_bh(&obd->obd_processing_task_lock);
1562 GOTO(err_free, rc = 0);
1565 memcpy(saved_req, req, sizeof *req);
1566 memcpy(reqmsg, req->rq_reqmsg, req->rq_reqlen);
1568 req->rq_reqmsg = reqmsg;
1569 class_export_get(req->rq_export);
1570 CFS_INIT_LIST_HEAD(&req->rq_list);
1571 CFS_INIT_LIST_HEAD(&req->rq_replay_list);
1573 if (target_exp_enqueue_req_replay(req)) {
1574 spin_unlock_bh(&obd->obd_processing_task_lock);
1575 DEBUG_REQ(D_ERROR, req, "dropping resent queued req");
1576 GOTO(err_exp, rc = 0);
1580 list_for_each(tmp, &obd->obd_recovery_queue) {
1581 struct ptlrpc_request *reqiter =
1582 list_entry(tmp, struct ptlrpc_request, rq_list);
1584 if (lustre_msg_get_transno(reqiter->rq_reqmsg) > transno) {
1585 list_add_tail(&req->rq_list, &reqiter->rq_list);
1590 if (unlikely(lustre_msg_get_transno(reqiter->rq_reqmsg) ==
1592 spin_unlock_bh(&obd->obd_processing_task_lock);
1593 DEBUG_REQ(D_ERROR, req, "dropping replay: transno "
1594 "has been claimed by another client");
1595 target_exp_dequeue_req_replay(req);
1596 GOTO(err_exp, rc = 0);
1601 list_add_tail(&req->rq_list, &obd->obd_recovery_queue);
1604 obd->obd_requests_queued_for_recovery++;
1606 if (obd->obd_processing_task != 0) {
1607 /* Someone else is processing this queue, we'll leave it to
1610 cfs_waitq_signal(&obd->obd_next_transno_waitq);
1611 spin_unlock_bh(&obd->obd_processing_task_lock);
1615 /* Nobody is processing, and we know there's (at least) one to process
1616 * now, so we'll do the honours.
1618 obd->obd_processing_task = cfs_curproc_pid();
1619 /* save thread that handle recovery queue */
1620 obd->obd_recovery_thread = req->rq_svc_thread;
1621 spin_unlock_bh(&obd->obd_processing_task_lock);
1623 process_recovery_queue(obd);
1627 class_export_put(req->rq_export);
1629 OBD_FREE(reqmsg, req->rq_reqlen);
1630 OBD_FREE(saved_req, sizeof(*saved_req));
1634 struct obd_device * target_req2obd(struct ptlrpc_request *req)
1636 return req->rq_export->exp_obd;
1639 int target_queue_last_replay_reply(struct ptlrpc_request *req, int rc)
1641 struct obd_device *obd = target_req2obd(req);
1642 struct ptlrpc_request *saved_req;
1643 struct lustre_msg *reqmsg;
1644 struct obd_export *exp = req->rq_export;
1645 int recovery_done = 0, delayed_done = 0;
1647 LASSERT ((rc == 0) == req->rq_packed_final);
1649 if (!req->rq_packed_final) {
1650 /* Just like ptlrpc_error, but without the sending. */
1651 rc = lustre_pack_reply(req, 1, NULL, NULL);
1654 req->rq_type = PTL_RPC_MSG_ERR;
1657 LASSERT(!req->rq_reply_state->rs_difficult);
1658 LASSERT(list_empty(&req->rq_list));
1659 /* XXX a bit like the request-dup code in queue_recovery_request */
1660 OBD_ALLOC(saved_req, sizeof *saved_req);
1663 OBD_ALLOC(reqmsg, req->rq_reqlen);
1665 OBD_FREE(saved_req, sizeof *req);
1669 memcpy(reqmsg, req->rq_reqmsg, req->rq_reqlen);
1671 /* Don't race cleanup */
1672 spin_lock_bh(&obd->obd_processing_task_lock);
1673 if (obd->obd_stopping) {
1674 spin_unlock_bh(&obd->obd_processing_task_lock);
1678 if (!exp->exp_vbr_failed) {
1679 ptlrpc_rs_addref(req->rq_reply_state); /* +1 ref for saved reply */
1681 req->rq_reqmsg = reqmsg;
1682 CFS_INIT_LIST_HEAD(&req->rq_list);
1683 CFS_INIT_LIST_HEAD(&req->rq_replay_list);
1684 class_export_get(exp);
1685 list_add(&req->rq_list, &obd->obd_delayed_reply_queue);
1688 /* only count the first "replay over" request from each
1690 if (exp->exp_replay_needed) {
1691 spin_lock(&exp->exp_lock);
1692 exp->exp_replay_needed = 0;
1693 spin_unlock(&exp->exp_lock);
1695 if (!exp->exp_delayed) {
1696 --obd->obd_recoverable_clients;
1698 spin_lock(&exp->exp_lock);
1699 exp->exp_delayed = 0;
1700 spin_unlock(&exp->exp_lock);
1702 if (obd->obd_delayed_clients == 0) {
1703 spin_unlock_bh(&obd->obd_processing_task_lock);
1706 --obd->obd_delayed_clients;
1709 recovery_done = (obd->obd_recoverable_clients == 0);
1710 spin_unlock_bh(&obd->obd_processing_task_lock);
1713 /* start pinging export */
1714 spin_lock(&obd->obd_dev_lock);
1715 list_add_tail(&exp->exp_obd_chain_timed,
1716 &obd->obd_exports_timed);
1717 list_move_tail(&exp->exp_obd_chain, &obd->obd_exports);
1718 spin_unlock(&obd->obd_dev_lock);
1719 target_send_delayed_replies(obd);
1722 OBD_RACE(OBD_FAIL_LDLM_RECOV_CLIENTS);
1723 if (recovery_done) {
1724 spin_lock_bh(&obd->obd_processing_task_lock);
1725 obd->obd_recovering = 0;
1726 obd->obd_version_recov = 0;
1727 obd->obd_abort_recovery = 0;
1728 target_cancel_recovery_timer(obd);
1729 spin_unlock_bh(&obd->obd_processing_task_lock);
1731 OBD_RACE(OBD_FAIL_TGT_REPLAY_DELAY);
1734 target_finish_recovery(obd);
1735 CDEBUG(D_HA, "%s: recovery complete\n",
1736 obd_uuid2str(&obd->obd_uuid));
1738 CWARN("%s: %d recoverable clients remain\n",
1739 obd->obd_name, obd->obd_recoverable_clients);
1740 cfs_waitq_signal(&obd->obd_next_transno_waitq);
1743 /* VBR: disconnect export with failed recovery */
1744 if (exp->exp_vbr_failed) {
1745 CWARN("%s: disconnect export %s\n", obd->obd_name,
1746 exp->exp_client_uuid.uuid);
1747 class_fail_export(exp);
1748 OBD_FREE(reqmsg, req->rq_reqlen);
1749 OBD_FREE(saved_req, sizeof *req);
1751 ptlrpc_send_reply(req, 0);
1757 OBD_FREE(reqmsg, req->rq_reqlen);
1758 OBD_FREE(saved_req, sizeof *req);
1759 req->rq_status = -ENOTCONN;
1760 /* rv is ignored anyhow */
1764 int target_handle_reply(struct ptlrpc_request *req, int rc, int fail)
1766 struct obd_device *obd = NULL;
1769 obd = target_req2obd(req);
1771 /* handle replay reply for version recovery */
1772 if (obd && obd->obd_version_recov &&
1773 (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY)) {
1774 LASSERT(req->rq_repmsg);
1775 lustre_msg_add_flags(req->rq_repmsg, MSG_VERSION_REPLAY);
1778 /* handle last replay */
1779 if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_LAST_REPLAY) {
1781 lustre_msg_get_flags(req->rq_reqmsg) & MSG_DELAY_REPLAY) {
1782 DEBUG_REQ(D_HA, req,
1783 "delayed LAST_REPLAY, queuing reply");
1784 rc = target_queue_last_replay_reply(req, rc);
1785 LASSERT(req->rq_export->exp_delayed == 0);
1789 if (obd && obd->obd_recovering) { /* normal recovery */
1790 DEBUG_REQ(D_HA, req, "LAST_REPLAY, queuing reply");
1791 rc = target_queue_last_replay_reply(req, rc);
1795 /* Lost a race with recovery; let the error path DTRT. */
1796 rc = req->rq_status = -ENOTCONN;
1798 target_send_reply(req, rc, fail);
1802 static inline struct ldlm_pool *ldlm_exp2pl(struct obd_export *exp)
1804 LASSERT(exp != NULL);
1805 return &exp->exp_obd->obd_namespace->ns_pool;
1808 int target_pack_pool_reply(struct ptlrpc_request *req)
1810 struct obd_device *obd;
1814 * Check that we still have all structures alive as this may
1815 * be some late rpc in shutdown time.
1817 if (unlikely(!req->rq_export || !req->rq_export->exp_obd ||
1818 !exp_connect_lru_resize(req->rq_export))) {
1819 lustre_msg_set_slv(req->rq_repmsg, 0);
1820 lustre_msg_set_limit(req->rq_repmsg, 0);
1825 * OBD is alive here as export is alive, which we checked above.
1827 obd = req->rq_export->exp_obd;
1829 read_lock(&obd->obd_pool_lock);
1830 lustre_msg_set_slv(req->rq_repmsg, obd->obd_pool_slv);
1831 lustre_msg_set_limit(req->rq_repmsg, obd->obd_pool_limit);
1832 read_unlock(&obd->obd_pool_lock);
1838 target_send_reply_msg (struct ptlrpc_request *req, int rc, int fail_id)
1840 if (OBD_FAIL_CHECK(fail_id | OBD_FAIL_ONCE)) {
1841 obd_fail_loc |= OBD_FAIL_ONCE | OBD_FAILED;
1842 DEBUG_REQ(D_ERROR, req, "dropping reply");
1847 DEBUG_REQ(D_ERROR, req, "processing error (%d)", rc);
1848 req->rq_status = rc;
1849 return (ptlrpc_send_error(req, 1));
1851 DEBUG_REQ(D_NET, req, "sending reply");
1854 return (ptlrpc_send_reply(req, PTLRPC_REPLY_MAYBE_DIFFICULT));
1858 target_send_reply(struct ptlrpc_request *req, int rc, int fail_id)
1861 struct ptlrpc_reply_state *rs;
1862 struct obd_device *obd;
1863 struct obd_export *exp;
1864 struct ptlrpc_service *svc;
1866 svc = req->rq_rqbd->rqbd_service;
1867 rs = req->rq_reply_state;
1868 if (rs == NULL || !rs->rs_difficult) {
1870 target_send_reply_msg (req, rc, fail_id);
1874 /* must be an export if locks saved */
1875 LASSERT (req->rq_export != NULL);
1876 /* req/reply consistent */
1877 LASSERT (rs->rs_service == svc);
1880 LASSERT (!rs->rs_scheduled);
1881 LASSERT (!rs->rs_scheduled_ever);
1882 LASSERT (!rs->rs_handled);
1883 LASSERT (!rs->rs_on_net);
1884 LASSERT (rs->rs_export == NULL);
1885 LASSERT (list_empty(&rs->rs_obd_list));
1886 LASSERT (list_empty(&rs->rs_exp_list));
1888 exp = class_export_get(req->rq_export);
1891 /* disable reply scheduling onto srv_reply_queue while I'm setting up */
1892 rs->rs_scheduled = 1;
1894 rs->rs_xid = req->rq_xid;
1895 rs->rs_transno = req->rq_transno;
1896 rs->rs_export = exp;
1898 spin_lock(&exp->exp_uncommitted_replies_lock);
1900 /* VBR: use exp_last_committed */
1901 if (rs->rs_transno > exp->exp_last_committed) {
1902 /* not committed already */
1903 list_add_tail (&rs->rs_obd_list,
1904 &exp->exp_uncommitted_replies);
1907 spin_unlock (&exp->exp_uncommitted_replies_lock);
1908 spin_lock (&exp->exp_lock);
1910 list_add_tail (&rs->rs_exp_list, &exp->exp_outstanding_replies);
1912 spin_unlock(&exp->exp_lock);
1914 netrc = target_send_reply_msg (req, rc, fail_id);
1916 spin_lock(&svc->srv_lock);
1918 svc->srv_n_difficult_replies++;
1921 /* error sending: reply is off the net. Also we need +1
1922 * reply ref until ptlrpc_server_handle_reply() is done
1923 * with the reply state (if the send was successful, there
1924 * would have been +1 ref for the net, which
1925 * reply_out_callback leaves alone) */
1927 ptlrpc_rs_addref(rs);
1928 atomic_inc (&svc->srv_outstanding_replies);
1931 if (!rs->rs_on_net || /* some notifier */
1932 list_empty(&rs->rs_exp_list) || /* completed already */
1933 list_empty(&rs->rs_obd_list)) {
1934 list_add_tail (&rs->rs_list, &svc->srv_reply_queue);
1935 cfs_waitq_signal (&svc->srv_waitq);
1937 list_add (&rs->rs_list, &svc->srv_active_replies);
1938 rs->rs_scheduled = 0; /* allow notifier to schedule */
1941 spin_unlock(&svc->srv_lock);
1944 int target_handle_ping(struct ptlrpc_request *req)
1946 if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_LAST_REPLAY &&
1947 req->rq_export->exp_in_recovery) {
1948 spin_lock(&req->rq_export->exp_lock);
1949 req->rq_export->exp_in_recovery = 0;
1950 spin_unlock(&req->rq_export->exp_lock);
1952 obd_ping(req->rq_export);
1953 return lustre_pack_reply(req, 1, NULL, NULL);
1956 void target_committed_to_req(struct ptlrpc_request *req)
1958 struct obd_export *exp = req->rq_export;
1959 if (!exp->exp_obd->obd_no_transno && req->rq_repmsg != NULL) {
1960 lustre_msg_set_last_committed(req->rq_repmsg,
1961 exp->exp_last_committed);
1963 DEBUG_REQ(D_IOCTL, req, "not sending last_committed update (%d/"
1964 "%d)", exp->exp_obd->obd_no_transno,
1965 req->rq_repmsg == NULL);
1967 CDEBUG(D_INFO, "last_committed x"LPU64", this req x"LPU64"\n",
1968 exp->exp_obd->obd_last_committed, req->rq_xid);
1971 EXPORT_SYMBOL(target_committed_to_req);
1973 int target_handle_qc_callback(struct ptlrpc_request *req)
1975 struct obd_quotactl *oqctl;
1976 struct client_obd *cli = &req->rq_export->exp_obd->u.cli;
1978 oqctl = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*oqctl),
1979 lustre_swab_obd_quotactl);
1980 if (oqctl == NULL) {
1981 CERROR("Can't unpack obd_quatactl\n");
1985 cli->cl_qchk_stat = oqctl->qc_stat;
1990 #ifdef HAVE_QUOTA_SUPPORT
1991 int target_handle_dqacq_callback(struct ptlrpc_request *req)
1994 struct obd_device *obd = req->rq_export->exp_obd;
1995 struct obd_device *master_obd;
1996 struct lustre_quota_ctxt *qctxt;
1997 struct qunit_data *qdata = NULL;
1999 int repsize[2] = { sizeof(struct ptlrpc_body), 0 };
2002 if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_MDS_DROP_QUOTA_REQ))
2005 repsize[1] = quota_get_qunit_data_size(req->rq_export->
2008 rc = lustre_pack_reply(req, 2, repsize, NULL);
2012 LASSERT(req->rq_export);
2014 /* there are three forms of qunit(historic causes), so we need to
2015 * adjust qunits from slaves to the same form here */
2016 OBD_ALLOC(qdata, sizeof(struct qunit_data));
2019 rc = quota_get_qdata(req, qdata, QUOTA_REQUEST, QUOTA_EXPORT);
2021 CDEBUG(D_ERROR, "Can't unpack qunit_data(rc: %d)\n", rc);
2025 /* we use the observer */
2026 if (!obd->obd_observer || !obd->obd_observer->obd_observer) {
2027 CERROR("Can't find the observer, it is recovering\n");
2028 req->rq_status = -EAGAIN;
2029 GOTO(send_reply, rc = -EAGAIN);
2032 master_obd = obd->obd_observer->obd_observer;
2033 qctxt = &master_obd->u.obt.obt_qctxt;
2035 if (!qctxt->lqc_setup) {
2036 /* quota_type has not been processed yet, return EAGAIN
2037 * until we know whether or not quotas are supposed to
2039 CDEBUG(D_QUOTA, "quota_type not processed yet, return "
2041 req->rq_status = -EAGAIN;
2042 rc = ptlrpc_reply(req);
2046 LASSERT(qctxt->lqc_handler);
2047 rc = qctxt->lqc_handler(master_obd, qdata,
2048 lustre_msg_get_opc(req->rq_reqmsg));
2049 if (rc && rc != -EDQUOT)
2050 CDEBUG(rc == -EBUSY ? D_QUOTA : D_ERROR,
2051 "dqacq failed! (rc:%d)\n", rc);
2052 req->rq_status = rc;
2054 /* there are three forms of qunit(historic causes), so we need to
2055 * adjust the same form to different forms slaves needed */
2056 rc = quota_copy_qdata(req, qdata, QUOTA_REPLY, QUOTA_EXPORT);
2058 CDEBUG(D_ERROR, "Can't pack qunit_data(rc: %d)\n", rc);
2062 /* Block the quota req. b=14840 */
2063 OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_BLOCK_QUOTA_REQ, obd_timeout);
2065 rc = ptlrpc_reply(req);
2067 OBD_FREE(qdata, sizeof(struct qunit_data));
2071 #endif /* !__KERNEL__ */
2073 #endif /* HAVE_QUOTA_SUPPORT */
2075 ldlm_mode_t lck_compat_array[] = {
2076 [LCK_EX] LCK_COMPAT_EX,
2077 [LCK_PW] LCK_COMPAT_PW,
2078 [LCK_PR] LCK_COMPAT_PR,
2079 [LCK_CW] LCK_COMPAT_CW,
2080 [LCK_CR] LCK_COMPAT_CR,
2081 [LCK_NL] LCK_COMPAT_NL,
2082 [LCK_GROUP] LCK_COMPAT_GROUP