1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (c) 2003 Cluster File Systems, Inc.
6 * This file is part of the Lustre file system, http://www.lustre.org
7 * Lustre is a trademark of Cluster File Systems, Inc.
9 * You may have signed or agreed to another license before downloading
10 * this software. If so, you are bound by the terms and conditions
11 * of that agreement, and the following does not apply to you. See the
12 * LICENSE file included with this distribution for more information.
14 * If you did not agree to a different license, then this copy of Lustre
15 * is open source software; you can redistribute it and/or modify it
16 * under the terms of version 2 of the GNU General Public License as
17 * published by the Free Software Foundation.
19 * In either case, Lustre is distributed in the hope that it will be
20 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
21 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * license text for more details.
26 # define EXPORT_SYMTAB
28 #define DEBUG_SUBSYSTEM S_LDLM
31 # include <linux/module.h>
33 # include <liblustre.h>
35 #include <linux/obd.h>
36 #include <linux/obd_class.h>
37 #include <linux/lustre_dlm.h>
38 #include <linux/lustre_ver.h>
39 #include <linux/lustre_net.h>
41 /* @priority: if non-zero, move the selected to the list head
42 * @create: if zero, only search in existed connections
44 static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid,
45 int priority, int create)
47 struct ptlrpc_connection *ptlrpc_conn;
48 struct obd_import_conn *imp_conn = NULL, *item;
52 if (!create && !priority) {
53 CDEBUG(D_HA, "Nothing to do\n");
57 ptlrpc_conn = ptlrpc_uuid_to_connection(uuid);
59 CDEBUG(D_HA, "can't find connection %s\n", uuid->uuid);
64 OBD_ALLOC(imp_conn, sizeof(*imp_conn));
66 GOTO(out_put, rc = -ENOMEM);
70 spin_lock(&imp->imp_lock);
71 list_for_each_entry(item, &imp->imp_conn_list, oic_item) {
72 if (obd_uuid_equals(uuid, &item->oic_uuid)) {
74 list_del(&item->oic_item);
75 list_add(&item->oic_item, &imp->imp_conn_list);
77 CDEBUG(D_HA, "imp %p@%s: found existing conn %s%s\n",
78 imp, imp->imp_obd->obd_name, uuid->uuid,
79 (priority ? ", moved to head" : ""));
80 spin_unlock(&imp->imp_lock);
81 GOTO(out_free, rc = 0);
86 imp_conn->oic_conn = ptlrpc_conn;
87 imp_conn->oic_uuid = *uuid;
89 list_add(&imp_conn->oic_item, &imp->imp_conn_list);
91 list_add_tail(&imp_conn->oic_item, &imp->imp_conn_list);
92 CDEBUG(D_HA, "imp %p@%s: add connection %s at %s\n",
93 imp, imp->imp_obd->obd_name, uuid->uuid,
94 (priority ? "head" : "tail"));
96 spin_unlock(&imp->imp_lock);
97 GOTO(out_free, rc = -ENOENT);
101 spin_unlock(&imp->imp_lock);
105 OBD_FREE(imp_conn, sizeof(*imp_conn));
107 ptlrpc_put_connection(ptlrpc_conn);
111 int import_set_conn_priority(struct obd_import *imp, struct obd_uuid *uuid)
113 return import_set_conn(imp, uuid, 1, 0);
116 int client_import_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
119 return import_set_conn(imp, uuid, priority, 1);
122 int client_import_del_conn(struct obd_import *imp, struct obd_uuid *uuid)
124 struct obd_import_conn *imp_conn;
125 struct obd_import_conn *cur_conn;
126 struct obd_export *dlmexp;
130 spin_lock(&imp->imp_lock);
131 if (list_empty(&imp->imp_conn_list)) {
132 LASSERT(!imp->imp_connection);
136 list_for_each_entry(imp_conn, &imp->imp_conn_list, oic_item) {
137 if (!obd_uuid_equals(uuid, &imp_conn->oic_uuid))
139 LASSERT(imp_conn->oic_conn);
141 cur_conn = list_entry(imp->imp_conn_list.next,
142 struct obd_import_conn,
145 /* is current conn? */
146 if (imp_conn == cur_conn) {
147 LASSERT(imp_conn->oic_conn == imp->imp_connection);
149 if (imp->imp_state != LUSTRE_IMP_CLOSED &&
150 imp->imp_state != LUSTRE_IMP_DISCON) {
151 CERROR("can't remove current connection\n");
152 GOTO(out, rc = -EBUSY);
155 ptlrpc_put_connection(imp->imp_connection);
156 imp->imp_connection = NULL;
158 dlmexp = class_conn2export(&imp->imp_dlm_handle);
159 if (dlmexp && dlmexp->exp_connection) {
160 LASSERT(dlmexp->exp_connection ==
162 ptlrpc_put_connection(dlmexp->exp_connection);
163 dlmexp->exp_connection = NULL;
167 list_del(&imp_conn->oic_item);
168 ptlrpc_put_connection(imp_conn->oic_conn);
169 OBD_FREE(imp_conn, sizeof(*imp_conn));
170 CDEBUG(D_HA, "imp %p@%s: remove connection %s\n",
171 imp, imp->imp_obd->obd_name, uuid->uuid);
176 spin_unlock(&imp->imp_lock);
178 CERROR("connection %s not found\n", uuid->uuid);
182 /* configure an RPC client OBD device
187 * 3 - inactive-on-startup
189 int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf)
191 struct lustre_cfg* lcfg = buf;
192 struct client_obd *cli = &obddev->u.cli;
193 struct obd_import *imp;
194 struct obd_uuid server_uuid;
195 int rq_portal, rp_portal, connect_op;
196 char *name = obddev->obd_type->typ_name;
200 /* In a more perfect world, we would hang a ptlrpc_client off of
201 * obd_type and just use the values from there. */
202 if (!strcmp(name, LUSTRE_OSC_NAME)) {
203 rq_portal = OST_IO_PORTAL;
204 rp_portal = OSC_REPLY_PORTAL;
205 connect_op = OST_CONNECT;
206 } else if (!strcmp(name, LUSTRE_MDC_NAME)) {
207 rq_portal = MDS_REQUEST_PORTAL;
208 rp_portal = MDC_REPLY_PORTAL;
209 connect_op = MDS_CONNECT;
210 } else if (!strcmp(name, LUSTRE_MGC_NAME)) {
211 rq_portal = MGS_REQUEST_PORTAL;
212 rp_portal = MGC_REPLY_PORTAL;
213 connect_op = MGS_CONNECT;
215 CERROR("unknown client OBD type \"%s\", can't setup\n",
220 if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) {
221 CERROR("requires a TARGET UUID\n");
225 if (LUSTRE_CFG_BUFLEN(lcfg, 1) > 37) {
226 CERROR("client UUID must be less than 38 characters\n");
230 if (LUSTRE_CFG_BUFLEN(lcfg, 2) < 1) {
231 CERROR("setup requires a SERVER UUID\n");
235 if (LUSTRE_CFG_BUFLEN(lcfg, 2) > 37) {
236 CERROR("target UUID must be less than 38 characters\n");
240 sema_init(&cli->cl_sem, 1);
241 sema_init(&cli->cl_mgc_sem, 1);
242 cli->cl_conn_count = 0;
243 memcpy(server_uuid.uuid, lustre_cfg_buf(lcfg, 2),
244 min_t(unsigned int, LUSTRE_CFG_BUFLEN(lcfg, 2),
245 sizeof(server_uuid)));
248 cli->cl_avail_grant = 0;
249 /* FIXME: should limit this for the sum of all cl_dirty_max */
250 cli->cl_dirty_max = OSC_MAX_DIRTY_DEFAULT * 1024 * 1024;
251 if (cli->cl_dirty_max >> PAGE_SHIFT > num_physpages / 8)
252 cli->cl_dirty_max = num_physpages << (PAGE_SHIFT - 3);
253 INIT_LIST_HEAD(&cli->cl_cache_waiters);
254 INIT_LIST_HEAD(&cli->cl_loi_ready_list);
255 INIT_LIST_HEAD(&cli->cl_loi_write_list);
256 INIT_LIST_HEAD(&cli->cl_loi_read_list);
257 spin_lock_init(&cli->cl_loi_list_lock);
258 cli->cl_r_in_flight = 0;
259 cli->cl_w_in_flight = 0;
260 spin_lock_init(&cli->cl_read_rpc_hist.oh_lock);
261 spin_lock_init(&cli->cl_write_rpc_hist.oh_lock);
262 spin_lock_init(&cli->cl_read_page_hist.oh_lock);
263 spin_lock_init(&cli->cl_write_page_hist.oh_lock);
264 spin_lock_init(&cli->cl_read_offset_hist.oh_lock);
265 spin_lock_init(&cli->cl_write_offset_hist.oh_lock);
266 if (num_physpages >> (20 - PAGE_SHIFT) <= 128) { /* <= 128 MB */
267 cli->cl_max_pages_per_rpc = PTLRPC_MAX_BRW_PAGES / 4;
268 cli->cl_max_rpcs_in_flight = OSC_MAX_RIF_DEFAULT / 4;
269 } else if (num_physpages >> (20 - PAGE_SHIFT) <= 256) { /* <= 256 MB */
270 cli->cl_max_pages_per_rpc = PTLRPC_MAX_BRW_PAGES / 2;
271 cli->cl_max_rpcs_in_flight = OSC_MAX_RIF_DEFAULT / 2;
273 cli->cl_max_pages_per_rpc = PTLRPC_MAX_BRW_PAGES;
274 cli->cl_max_rpcs_in_flight = OSC_MAX_RIF_DEFAULT;
279 CERROR("ldlm_get_ref failed: %d\n", rc);
283 ptlrpc_init_client(rq_portal, rp_portal, name,
284 &obddev->obd_ldlm_client);
286 imp = class_new_import();
288 GOTO(err_ldlm, rc = -ENOENT);
289 imp->imp_client = &obddev->obd_ldlm_client;
290 imp->imp_obd = obddev;
291 imp->imp_connect_op = connect_op;
292 imp->imp_generation = 0;
293 imp->imp_initial_recov = 1;
294 imp->imp_initial_recov_bk = 0;
295 INIT_LIST_HEAD(&imp->imp_pinger_chain);
296 memcpy(imp->imp_target_uuid.uuid, lustre_cfg_buf(lcfg, 1),
297 LUSTRE_CFG_BUFLEN(lcfg, 1));
298 class_import_put(imp);
300 rc = client_import_add_conn(imp, &server_uuid, 1);
302 CERROR("can't add initial connection\n");
303 GOTO(err_import, rc);
306 cli->cl_import = imp;
307 /* cli->cl_max_mds_{easize,cookiesize} updated by mdc_init_ea_size() */
308 cli->cl_max_mds_easize = sizeof(struct lov_mds_md);
309 cli->cl_max_mds_cookiesize = sizeof(struct llog_cookie);
310 cli->cl_sandev = to_kdev_t(0);
312 if (LUSTRE_CFG_BUFLEN(lcfg, 3) > 0) {
313 if (!strcmp(lustre_cfg_string(lcfg, 3), "inactive")) {
314 CDEBUG(D_HA, "marking %s %s->%s as inactive\n",
315 name, obddev->obd_name,
316 imp->imp_target_uuid.uuid);
317 imp->imp_invalid = 1;
321 cli->cl_qchk_stat = CL_NOT_QUOTACHECKED;
326 class_destroy_import(imp);
334 int client_obd_cleanup(struct obd_device *obddev)
336 struct client_obd *cli = &obddev->u.cli;
340 class_destroy_import(cli->cl_import);
341 cli->cl_import = NULL;
343 ldlm_put_ref(obddev->obd_force);
348 /* ->o_connect() method for client side (OSC and MDC and MGC) */
349 int client_connect_import(struct lustre_handle *dlm_handle,
350 struct obd_device *obd, struct obd_uuid *cluuid,
351 struct obd_connect_data *data)
353 struct client_obd *cli = &obd->u.cli;
354 struct obd_import *imp = cli->cl_import;
355 struct obd_export *exp;
356 struct obd_connect_data *ocd;
361 rc = class_connect(dlm_handle, obd, cluuid);
365 cli->cl_conn_count++;
366 if (cli->cl_conn_count > 1)
368 exp = class_conn2export(dlm_handle);
370 if (obd->obd_namespace != NULL)
371 CERROR("already have namespace!\n");
372 obd->obd_namespace = ldlm_namespace_new(obd->obd_name,
373 LDLM_NAMESPACE_CLIENT);
374 if (obd->obd_namespace == NULL)
375 GOTO(out_disco, rc = -ENOMEM);
377 imp->imp_dlm_handle = *dlm_handle;
378 rc = ptlrpc_init_import(imp);
382 ocd = &imp->imp_connect_data;
385 imp->imp_connect_flags_orig = data->ocd_connect_flags;
388 rc = ptlrpc_connect_import(imp, NULL);
390 LASSERT (imp->imp_state == LUSTRE_IMP_DISCON);
393 LASSERT(exp->exp_connection);
396 LASSERT((ocd->ocd_connect_flags & data->ocd_connect_flags) ==
397 ocd->ocd_connect_flags);
398 data->ocd_connect_flags = ocd->ocd_connect_flags;
401 ptlrpc_pinger_add_import(imp);
406 ldlm_namespace_free(obd->obd_namespace, 0);
407 obd->obd_namespace = NULL;
409 cli->cl_conn_count--;
410 class_disconnect(exp);
412 class_export_put(exp);
419 int client_disconnect_export(struct obd_export *exp)
421 struct obd_device *obd = class_exp2obd(exp);
422 struct client_obd *cli;
423 struct obd_import *imp;
428 CERROR("invalid export for disconnect: exp %p cookie "LPX64"\n",
429 exp, exp ? exp->exp_handle.h_cookie : -1);
434 imp = cli->cl_import;
437 if (!cli->cl_conn_count) {
438 CERROR("disconnecting disconnected device (%s)\n",
440 GOTO(out_sem, rc = -EINVAL);
443 cli->cl_conn_count--;
444 if (cli->cl_conn_count)
445 GOTO(out_no_disconnect, rc = 0);
447 /* Some non-replayable imports (MDS's OSCs) are pinged, so just
448 * delete it regardless. (It's safe to delete an import that was
450 (void)ptlrpc_pinger_del_import(imp);
452 if (obd->obd_namespace != NULL) {
453 /* obd_no_recov == local only */
454 ldlm_cli_cancel_unused(obd->obd_namespace, NULL,
455 obd->obd_no_recov, NULL);
456 ldlm_namespace_free(obd->obd_namespace, obd->obd_no_recov);
457 obd->obd_namespace = NULL;
460 /* Yeah, obd_no_recov also (mainly) means "forced shutdown". */
461 if (obd->obd_no_recov)
462 ptlrpc_invalidate_import(imp);
464 rc = ptlrpc_disconnect_import(imp);
468 err = class_disconnect(exp);
476 /* --------------------------------------------------------------------------
477 * from old lib/target.c
478 * -------------------------------------------------------------------------- */
480 int target_handle_reconnect(struct lustre_handle *conn, struct obd_export *exp,
481 struct obd_uuid *cluuid)
483 if (exp->exp_connection) {
484 struct lustre_handle *hdl;
485 hdl = &exp->exp_imp_reverse->imp_remote_handle;
486 /* Might be a re-connect after a partition. */
487 if (!memcmp(&conn->cookie, &hdl->cookie, sizeof conn->cookie)) {
488 CWARN("%s reconnecting\n", cluuid->uuid);
489 conn->cookie = exp->exp_handle.h_cookie;
490 /* target_handle_connect() treats EALREADY and
491 * -EALREADY differently. EALREADY means we are
492 * doing a valid reconnect from the same client. */
495 CERROR("%s reconnecting from %s, "
496 "handle mismatch (ours "LPX64", theirs "
497 LPX64")\n", cluuid->uuid,
498 exp->exp_connection->c_remote_uuid.uuid,
499 hdl->cookie, conn->cookie);
500 memset(conn, 0, sizeof *conn);
501 /* target_handle_connect() treats EALREADY and
502 * -EALREADY differently. -EALREADY is an error
503 * (same UUID, different handle). */
508 conn->cookie = exp->exp_handle.h_cookie;
509 CDEBUG(D_HA, "connect export for UUID '%s' at %p, cookie "LPX64"\n",
510 cluuid->uuid, exp, conn->cookie);
514 int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler)
516 struct obd_device *target;
517 struct obd_export *export = NULL;
518 struct obd_import *revimp;
519 struct lustre_handle conn;
520 struct obd_uuid tgtuuid;
521 struct obd_uuid cluuid;
522 struct obd_uuid remote_uuid;
525 int rc = 0, abort_recovery;
527 struct obd_connect_data *data;
528 int size = sizeof(*data);
531 OBD_RACE(OBD_FAIL_TGT_CONN_RACE);
533 LASSERT_REQSWAB (req, 0);
534 str = lustre_msg_string(req->rq_reqmsg, 0, sizeof(tgtuuid) - 1);
536 DEBUG_REQ(D_ERROR, req, "bad target UUID for connect");
537 GOTO(out, rc = -EINVAL);
540 obd_str2uuid (&tgtuuid, str);
541 target = class_uuid2obd(&tgtuuid);
543 /* old (pre 1.6) lustre_process_log tries to connect to mdsname
544 (eg. mdsA) instead of uuid. */
546 snprintf((char *)tgtuuid.uuid, sizeof(tgtuuid), "%s_UUID", str);
547 target = class_uuid2obd(&tgtuuid);
550 target = class_name2obd(str);
553 if (!target || target->obd_stopping || !target->obd_set_up) {
554 DEBUG_REQ(D_ERROR, req, "UUID '%s' is not available "
555 " for connect (%s)", str,
556 !target ? "no target" :
557 (target->obd_stopping ? "stopping" : "not set up"));
558 GOTO(out, rc = -ENODEV);
561 LASSERT_REQSWAB (req, 1);
562 str = lustre_msg_string(req->rq_reqmsg, 1, sizeof(cluuid) - 1);
564 DEBUG_REQ(D_ERROR, req, "bad client UUID for connect");
565 GOTO(out, rc = -EINVAL);
568 obd_str2uuid (&cluuid, str);
570 /* XXX extract a nettype and format accordingly */
571 switch (sizeof(lnet_nid_t)) {
572 /* NB the casts only avoid compiler warnings */
574 snprintf(remote_uuid.uuid, sizeof remote_uuid,
575 "NET_"LPX64"_UUID", (__u64)req->rq_peer.nid);
578 snprintf(remote_uuid.uuid, sizeof remote_uuid,
579 "NET_%x_UUID", (__u32)req->rq_peer.nid);
585 spin_lock_bh(&target->obd_processing_task_lock);
586 abort_recovery = target->obd_abort_recovery;
587 spin_unlock_bh(&target->obd_processing_task_lock);
589 target_abort_recovery(target);
591 tmp = lustre_msg_buf(req->rq_reqmsg, 2, sizeof conn);
593 GOTO(out, rc = -EPROTO);
595 memcpy(&conn, tmp, sizeof conn);
597 data = lustre_swab_reqbuf(req, 3, sizeof(*data), lustre_swab_connect);
598 rc = lustre_pack_reply(req, 1, &size, NULL);
602 if (lustre_msg_get_op_flags(req->rq_reqmsg) & MSG_CONNECT_LIBCLIENT) {
604 DEBUG_REQ(D_WARNING, req, "Refusing old (unversioned) "
605 "libclient connection attempt\n");
606 GOTO(out, rc = -EPROTO);
607 } else if (data->ocd_version < LUSTRE_VERSION_CODE -
608 LUSTRE_VERSION_ALLOWED_OFFSET) {
609 DEBUG_REQ(D_WARNING, req, "Refusing old (%d.%d.%d.%d) "
610 "libclient connection attempt\n",
611 OBD_OCD_VERSION_MAJOR(data->ocd_version),
612 OBD_OCD_VERSION_MINOR(data->ocd_version),
613 OBD_OCD_VERSION_PATCH(data->ocd_version),
614 OBD_OCD_VERSION_FIX(data->ocd_version));
615 data = lustre_msg_buf(req->rq_repmsg, 0,
616 offsetof(typeof(*data),
618 sizeof(data->ocd_version));
620 data->ocd_connect_flags = OBD_CONNECT_VERSION;
621 data->ocd_version = LUSTRE_VERSION_CODE;
623 GOTO(out, rc = -EPROTO);
627 /* lctl gets a backstage, all-access pass. */
628 if (obd_uuid_equals(&cluuid, &target->obd_uuid))
629 goto dont_check_exports;
631 spin_lock(&target->obd_dev_lock);
632 list_for_each(p, &target->obd_exports) {
633 export = list_entry(p, struct obd_export, exp_obd_chain);
634 if (obd_uuid_equals(&cluuid, &export->exp_client_uuid)) {
635 spin_unlock(&target->obd_dev_lock);
636 LASSERT(export->exp_obd == target);
638 rc = target_handle_reconnect(&conn, export, &cluuid);
643 /* If we found an export, we already unlocked. */
645 spin_unlock(&target->obd_dev_lock);
646 } else if (req->rq_reqmsg->conn_cnt == 1) {
647 CERROR("%s: NID %s (%s) reconnected with 1 conn_cnt; "
648 "cookies not random?\n", target->obd_name,
649 libcfs_nid2str(req->rq_peer.nid), cluuid.uuid);
650 GOTO(out, rc = -EALREADY);
653 /* We indicate the reconnection in a flag, not an error code. */
654 if (rc == EALREADY) {
655 lustre_msg_add_op_flags(req->rq_repmsg, MSG_CONNECT_RECONNECT);
659 /* Tell the client if we're in recovery. */
660 /* If this is the first client, start the recovery timer */
661 if (target->obd_recovering) {
662 lustre_msg_add_op_flags(req->rq_repmsg, MSG_CONNECT_RECOVERING);
663 target_start_recovery_timer(target, handler);
666 /* Tell the client if we support replayable requests */
667 if (target->obd_replayable)
668 lustre_msg_add_op_flags(req->rq_repmsg, MSG_CONNECT_REPLAYABLE);
670 if (export == NULL) {
671 if (target->obd_recovering) {
672 CERROR("%s: denying connection for new client %s (%s): "
673 "%d clients in recovery for %lds\n",
675 libcfs_nid2str(req->rq_peer.nid), cluuid.uuid,
676 target->obd_recoverable_clients,
677 (target->obd_recovery_timer.expires-jiffies)/HZ);
681 rc = obd_connect(&conn, target, &cluuid, data);
684 rc = obd_reconnect(export, target, &cluuid, data);
687 /* we want to handle EALREADY but *not* -EALREADY from
688 * target_handle_reconnect() */
689 if (rc && rc != EALREADY)
692 /* Return only the parts of obd_connect_data that we understand, so the
693 * client knows that we don't understand the rest. */
695 memcpy(lustre_msg_buf(req->rq_repmsg, 0, sizeof(*data)), data,
698 /* If all else goes well, this is our RPC return code. */
701 req->rq_repmsg->handle = conn;
703 /* ownership of this export ref transfers to the request AFTER we
704 * drop any previous reference the request had, but we don't want
705 * that to go to zero before we get our new export reference. */
706 export = class_conn2export(&conn);
707 LASSERT(export != NULL);
709 /* If the client and the server are the same node, we will already
710 * have an export that really points to the client's DLM export,
711 * because we have a shared handles table.
713 * XXX this will go away when shaver stops sending the "connect" handle
714 * in the real "remote handle" field of the request --phik 24 Apr 2003
716 if (req->rq_export != NULL)
717 class_export_put(req->rq_export);
719 req->rq_export = export;
721 spin_lock_irqsave(&export->exp_lock, flags);
722 if (export->exp_conn_cnt >= req->rq_reqmsg->conn_cnt) {
723 CERROR("%s: %s already connected at higher conn_cnt: %d > %d\n",
724 cluuid.uuid, libcfs_nid2str(req->rq_peer.nid),
725 export->exp_conn_cnt, req->rq_reqmsg->conn_cnt);
726 spin_unlock_irqrestore(&export->exp_lock, flags);
727 GOTO(out, rc = -EALREADY);
729 export->exp_conn_cnt = req->rq_reqmsg->conn_cnt;
730 spin_unlock_irqrestore(&export->exp_lock, flags);
732 /* request from liblustre? Don't evict it for not pinging. */
733 if (lustre_msg_get_op_flags(req->rq_reqmsg) & MSG_CONNECT_LIBCLIENT) {
734 export->exp_libclient = 1;
735 spin_lock(&target->obd_dev_lock);
736 list_del_init(&export->exp_obd_chain_timed);
737 spin_unlock(&target->obd_dev_lock);
740 if (export->exp_connection != NULL)
741 ptlrpc_put_connection(export->exp_connection);
742 export->exp_connection = ptlrpc_get_connection(req->rq_peer,
746 if (lustre_msg_get_op_flags(req->rq_repmsg) & MSG_CONNECT_RECONNECT)
749 if (target->obd_recovering)
750 target->obd_connected_clients++;
752 memcpy(&conn, lustre_msg_buf(req->rq_reqmsg, 2, sizeof conn),
755 if (export->exp_imp_reverse != NULL)
756 class_destroy_import(export->exp_imp_reverse);
757 revimp = export->exp_imp_reverse = class_new_import();
758 revimp->imp_connection = ptlrpc_connection_addref(export->exp_connection);
759 revimp->imp_client = &export->exp_obd->obd_ldlm_client;
760 revimp->imp_remote_handle = conn;
761 revimp->imp_obd = target;
762 revimp->imp_dlm_fake = 1;
763 revimp->imp_state = LUSTRE_IMP_FULL;
764 class_import_put(revimp);
771 int target_handle_disconnect(struct ptlrpc_request *req)
776 rc = lustre_pack_reply(req, 0, NULL, NULL);
780 /* keep the rq_export around so we can send the reply */
781 req->rq_status = obd_disconnect(class_export_get(req->rq_export));
785 void target_destroy_export(struct obd_export *exp)
787 /* exports created from last_rcvd data, and "fake"
788 exports created by lctl don't have an import */
789 if (exp->exp_imp_reverse != NULL)
790 class_destroy_import(exp->exp_imp_reverse);
792 /* We cancel locks at disconnect time, but this will catch any locks
793 * granted in a race with recovery-induced disconnect. */
794 if (exp->exp_obd->obd_namespace != NULL)
795 ldlm_cancel_locks_for_export(exp);
803 static void target_release_saved_req(struct ptlrpc_request *req)
805 if (req->rq_reply_state != NULL) {
806 ptlrpc_rs_decref(req->rq_reply_state);
807 /* req->rq_reply_state = NULL; */
810 class_export_put(req->rq_export);
811 OBD_FREE(req->rq_reqmsg, req->rq_reqlen);
812 OBD_FREE(req, sizeof *req);
815 static void target_finish_recovery(struct obd_device *obd)
817 struct list_head *tmp, *n;
819 CWARN("%s: sending delayed replies to recovered clients\n",
822 ldlm_reprocess_all_ns(obd->obd_namespace);
824 /* when recovery finished, cleanup orphans on mds and ost */
825 if (OBT(obd) && OBP(obd, postrecov)) {
826 int rc = OBP(obd, postrecov)(obd);
827 CWARN("%s: recovery %s: rc %d\n", obd->obd_name,
828 rc < 0 ? "failed" : "complete", rc);
831 list_for_each_safe(tmp, n, &obd->obd_delayed_reply_queue) {
832 struct ptlrpc_request *req;
833 req = list_entry(tmp, struct ptlrpc_request, rq_list);
834 list_del(&req->rq_list);
835 DEBUG_REQ(D_WARNING, req, "delayed:");
837 target_release_saved_req(req);
839 obd->obd_recovery_end = CURRENT_SECONDS;
842 static void abort_recovery_queue(struct obd_device *obd)
844 struct ptlrpc_request *req;
845 struct list_head *tmp, *n;
848 list_for_each_safe(tmp, n, &obd->obd_recovery_queue) {
849 req = list_entry(tmp, struct ptlrpc_request, rq_list);
850 list_del(&req->rq_list);
851 DEBUG_REQ(D_ERROR, req, "aborted:");
852 req->rq_status = -ENOTCONN;
853 req->rq_type = PTL_RPC_MSG_ERR;
854 rc = lustre_pack_reply(req, 0, NULL, NULL);
858 DEBUG_REQ(D_ERROR, req,
859 "packing failed for abort-reply; skipping");
861 target_release_saved_req(req);
865 /* Called from a cleanup function if the device is being cleaned up
866 forcefully. The exports should all have been disconnected already,
867 the only thing left to do is
868 - clear the recovery flags
870 - free queued requests and replies, but don't send replies
871 Because the obd_stopping flag is set, no new requests should be received.
874 void target_cleanup_recovery(struct obd_device *obd)
876 struct list_head *tmp, *n;
877 struct ptlrpc_request *req;
880 LASSERT(obd->obd_stopping);
882 spin_lock_bh(&obd->obd_processing_task_lock);
883 if (!obd->obd_recovering) {
884 spin_unlock_bh(&obd->obd_processing_task_lock);
888 obd->obd_recovering = obd->obd_abort_recovery = 0;
889 target_cancel_recovery_timer(obd);
890 spin_unlock_bh(&obd->obd_processing_task_lock);
892 list_for_each_safe(tmp, n, &obd->obd_delayed_reply_queue) {
893 req = list_entry(tmp, struct ptlrpc_request, rq_list);
894 list_del(&req->rq_list);
895 target_release_saved_req(req);
898 list_for_each_safe(tmp, n, &obd->obd_recovery_queue) {
899 req = list_entry(tmp, struct ptlrpc_request, rq_list);
900 list_del(&req->rq_list);
901 target_release_saved_req(req);
906 void target_abort_recovery(void *data)
908 struct obd_device *obd = data;
910 spin_lock_bh(&obd->obd_processing_task_lock);
911 if (!obd->obd_recovering) {
912 spin_unlock_bh(&obd->obd_processing_task_lock);
916 obd->obd_recovering = obd->obd_abort_recovery = 0;
917 obd->obd_recoverable_clients = 0;
918 target_cancel_recovery_timer(obd);
919 spin_unlock_bh(&obd->obd_processing_task_lock);
921 CERROR("%s: recovery period over; disconnecting unfinished clients.\n",
923 class_disconnect_stale_exports(obd);
924 abort_recovery_queue(obd);
926 target_finish_recovery(obd);
928 ptlrpc_run_recovery_over_upcall(obd);
931 static void target_recovery_expired(unsigned long castmeharder)
933 struct obd_device *obd = (struct obd_device *)castmeharder;
934 CERROR("%s: recovery timed out, aborting\n", obd->obd_name);
935 spin_lock_bh(&obd->obd_processing_task_lock);
936 if (obd->obd_recovering)
937 obd->obd_abort_recovery = 1;
938 wake_up(&obd->obd_next_transno_waitq);
939 spin_unlock_bh(&obd->obd_processing_task_lock);
943 /* obd_processing_task_lock should be held */
944 void target_cancel_recovery_timer(struct obd_device *obd)
946 CDEBUG(D_HA, "%s: cancel recovery timer\n", obd->obd_name);
947 del_timer(&obd->obd_recovery_timer);
950 static void reset_recovery_timer(struct obd_device *obd)
952 spin_lock_bh(&obd->obd_processing_task_lock);
953 if (!obd->obd_recovering) {
954 spin_unlock_bh(&obd->obd_processing_task_lock);
957 mod_timer(&obd->obd_recovery_timer, jiffies + OBD_RECOVERY_TIMEOUT);
958 spin_unlock_bh(&obd->obd_processing_task_lock);
959 CDEBUG(D_HA, "%s: timer will expire in %u seconds\n", obd->obd_name,
960 (int)(OBD_RECOVERY_TIMEOUT / HZ));
961 /* Only used for lprocfs_status */
962 obd->obd_recovery_end = CURRENT_SECONDS + OBD_RECOVERY_TIMEOUT/HZ;
966 /* Only start it the first time called */
967 void target_start_recovery_timer(struct obd_device *obd, svc_handler_t handler)
969 spin_lock_bh(&obd->obd_processing_task_lock);
970 if (obd->obd_recovery_handler) {
971 spin_unlock_bh(&obd->obd_processing_task_lock);
974 CWARN("%s: starting recovery timer (%us)\n", obd->obd_name,
975 (int)(OBD_RECOVERY_TIMEOUT / HZ));
976 obd->obd_recovery_handler = handler;
977 obd->obd_recovery_timer.function = target_recovery_expired;
978 obd->obd_recovery_timer.data = (unsigned long)obd;
979 spin_unlock_bh(&obd->obd_processing_task_lock);
981 reset_recovery_timer(obd);
984 static int check_for_next_transno(struct obd_device *obd)
986 struct ptlrpc_request *req;
987 int wake_up = 0, connected, completed, queue_len, max;
988 __u64 next_transno, req_transno;
990 spin_lock_bh(&obd->obd_processing_task_lock);
991 req = list_entry(obd->obd_recovery_queue.next,
992 struct ptlrpc_request, rq_list);
993 max = obd->obd_max_recoverable_clients;
994 req_transno = req->rq_reqmsg->transno;
995 connected = obd->obd_connected_clients;
996 completed = max - obd->obd_recoverable_clients;
997 queue_len = obd->obd_requests_queued_for_recovery;
998 next_transno = obd->obd_next_recovery_transno;
1000 CDEBUG(D_HA,"max: %d, connected: %d, completed: %d, queue_len: %d, "
1001 "req_transno: "LPU64", next_transno: "LPU64"\n",
1002 max, connected, completed, queue_len, req_transno, next_transno);
1003 if (obd->obd_abort_recovery) {
1004 CDEBUG(D_HA, "waking for aborted recovery\n");
1006 } else if (!obd->obd_recovering) {
1007 CDEBUG(D_HA, "waking for completed recovery (?)\n");
1009 } else if (req_transno == next_transno) {
1010 CDEBUG(D_HA, "waking for next ("LPD64")\n", next_transno);
1012 } else if (queue_len + completed == max) {
1014 "waking for skipped transno (skip: "LPD64
1015 ", ql: %d, comp: %d, conn: %d, next: "LPD64")\n",
1016 next_transno, queue_len, completed, max, req_transno);
1017 obd->obd_next_recovery_transno = req_transno;
1020 spin_unlock_bh(&obd->obd_processing_task_lock);
1021 LASSERT(req->rq_reqmsg->transno >= next_transno);
1025 static void process_recovery_queue(struct obd_device *obd)
1027 struct ptlrpc_request *req;
1028 int abort_recovery = 0;
1029 struct l_wait_info lwi = { 0 };
1033 spin_lock_bh(&obd->obd_processing_task_lock);
1034 LASSERT(obd->obd_processing_task == current->pid);
1035 req = list_entry(obd->obd_recovery_queue.next,
1036 struct ptlrpc_request, rq_list);
1038 if (req->rq_reqmsg->transno != obd->obd_next_recovery_transno) {
1039 spin_unlock_bh(&obd->obd_processing_task_lock);
1040 CDEBUG(D_HA, "Waiting for transno "LPD64" (1st is "
1042 obd->obd_next_recovery_transno,
1043 req->rq_reqmsg->transno);
1044 l_wait_event(obd->obd_next_transno_waitq,
1045 check_for_next_transno(obd), &lwi);
1046 spin_lock_bh(&obd->obd_processing_task_lock);
1047 abort_recovery = obd->obd_abort_recovery;
1048 spin_unlock_bh(&obd->obd_processing_task_lock);
1049 if (abort_recovery) {
1050 target_abort_recovery(obd);
1055 list_del_init(&req->rq_list);
1056 obd->obd_requests_queued_for_recovery--;
1057 spin_unlock_bh(&obd->obd_processing_task_lock);
1059 DEBUG_REQ(D_HA, req, "processing: ");
1060 (void)obd->obd_recovery_handler(req);
1061 obd->obd_replayed_requests++;
1062 reset_recovery_timer(obd);
1063 /* bug 1580: decide how to properly sync() in recovery */
1064 //mds_fsync_super(obd->u.obt.obt_sb);
1065 class_export_put(req->rq_export);
1066 if (req->rq_reply_state != NULL) {
1067 ptlrpc_rs_decref(req->rq_reply_state);
1068 /* req->rq_reply_state = NULL; */
1070 OBD_FREE(req->rq_reqmsg, req->rq_reqlen);
1071 OBD_FREE(req, sizeof *req);
1072 spin_lock_bh(&obd->obd_processing_task_lock);
1073 obd->obd_next_recovery_transno++;
1074 if (list_empty(&obd->obd_recovery_queue)) {
1075 obd->obd_processing_task = 0;
1076 spin_unlock_bh(&obd->obd_processing_task_lock);
1079 spin_unlock_bh(&obd->obd_processing_task_lock);
1084 int target_queue_recovery_request(struct ptlrpc_request *req,
1085 struct obd_device *obd)
1087 struct list_head *tmp;
1089 __u64 transno = req->rq_reqmsg->transno;
1090 struct ptlrpc_request *saved_req;
1091 struct lustre_msg *reqmsg;
1093 /* CAVEAT EMPTOR: The incoming request message has been swabbed
1094 * (i.e. buflens etc are in my own byte order), but type-dependent
1095 * buffers (eg mds_body, ost_body etc) have NOT been swabbed. */
1098 INIT_LIST_HEAD(&req->rq_list);
1099 DEBUG_REQ(D_HA, req, "not queueing");
1103 /* XXX If I were a real man, these LBUGs would be sane cleanups. */
1104 /* XXX just like the request-dup code in queue_final_reply */
1105 OBD_ALLOC(saved_req, sizeof *saved_req);
1108 OBD_ALLOC(reqmsg, req->rq_reqlen);
1112 spin_lock_bh(&obd->obd_processing_task_lock);
1114 /* If we're processing the queue, we want don't want to queue this
1117 * Also, if this request has a transno less than the one we're waiting
1118 * for, we should process it now. It could (and currently always will)
1119 * be an open request for a descriptor that was opened some time ago.
1121 * Also, a resent, replayed request that has already been
1122 * handled will pass through here and be processed immediately.
1124 if (obd->obd_processing_task == current->pid ||
1125 transno < obd->obd_next_recovery_transno) {
1126 /* Processing the queue right now, don't re-add. */
1127 LASSERT(list_empty(&req->rq_list));
1128 spin_unlock_bh(&obd->obd_processing_task_lock);
1129 OBD_FREE(reqmsg, req->rq_reqlen);
1130 OBD_FREE(saved_req, sizeof *saved_req);
1134 /* A resent, replayed request that is still on the queue; just drop it.
1135 The queued request will handle this. */
1136 if ((lustre_msg_get_flags(req->rq_reqmsg) & (MSG_RESENT|MSG_REPLAY)) ==
1137 (MSG_RESENT | MSG_REPLAY)) {
1138 DEBUG_REQ(D_ERROR, req, "dropping resent queued req");
1139 spin_unlock_bh(&obd->obd_processing_task_lock);
1140 OBD_FREE(reqmsg, req->rq_reqlen);
1141 OBD_FREE(saved_req, sizeof *saved_req);
1145 memcpy(saved_req, req, sizeof *req);
1146 memcpy(reqmsg, req->rq_reqmsg, req->rq_reqlen);
1148 req->rq_reqmsg = reqmsg;
1149 class_export_get(req->rq_export);
1150 INIT_LIST_HEAD(&req->rq_list);
1153 list_for_each(tmp, &obd->obd_recovery_queue) {
1154 struct ptlrpc_request *reqiter =
1155 list_entry(tmp, struct ptlrpc_request, rq_list);
1157 if (reqiter->rq_reqmsg->transno > transno) {
1158 list_add_tail(&req->rq_list, &reqiter->rq_list);
1165 list_add_tail(&req->rq_list, &obd->obd_recovery_queue);
1168 obd->obd_requests_queued_for_recovery++;
1170 if (obd->obd_processing_task != 0) {
1171 /* Someone else is processing this queue, we'll leave it to
1174 wake_up(&obd->obd_next_transno_waitq);
1175 spin_unlock_bh(&obd->obd_processing_task_lock);
1179 /* Nobody is processing, and we know there's (at least) one to process
1180 * now, so we'll do the honours.
1182 obd->obd_processing_task = current->pid;
1183 spin_unlock_bh(&obd->obd_processing_task_lock);
1185 process_recovery_queue(obd);
1189 struct obd_device * target_req2obd(struct ptlrpc_request *req)
1191 return req->rq_export->exp_obd;
1194 int target_queue_final_reply(struct ptlrpc_request *req, int rc)
1196 struct obd_device *obd = target_req2obd(req);
1197 struct ptlrpc_request *saved_req;
1198 struct lustre_msg *reqmsg;
1199 int recovery_done = 0;
1201 LASSERT ((rc == 0) == (req->rq_reply_state != NULL));
1204 /* Just like ptlrpc_error, but without the sending. */
1205 rc = lustre_pack_reply(req, 0, NULL, NULL);
1206 LASSERT(rc == 0); /* XXX handle this */
1207 req->rq_type = PTL_RPC_MSG_ERR;
1210 LASSERT (!req->rq_reply_state->rs_difficult);
1211 LASSERT(list_empty(&req->rq_list));
1212 /* XXX a bit like the request-dup code in queue_recovery_request */
1213 OBD_ALLOC(saved_req, sizeof *saved_req);
1216 OBD_ALLOC(reqmsg, req->rq_reqlen);
1220 memcpy(reqmsg, req->rq_reqmsg, req->rq_reqlen);
1222 /* Don't race cleanup */
1223 spin_lock_bh(&obd->obd_processing_task_lock);
1224 if (obd->obd_stopping) {
1225 spin_unlock_bh(&obd->obd_processing_task_lock);
1226 OBD_FREE(reqmsg, req->rq_reqlen);
1227 OBD_FREE(saved_req, sizeof *req);
1228 req->rq_status = -ENOTCONN;
1229 /* rv is ignored anyhow */
1232 ptlrpc_rs_addref(req->rq_reply_state); /* +1 ref for saved reply */
1234 req->rq_reqmsg = reqmsg;
1235 class_export_get(req->rq_export);
1236 list_add(&req->rq_list, &obd->obd_delayed_reply_queue);
1238 /* only count the first "replay over" request from each
1240 if (req->rq_export->exp_replay_needed) {
1241 --obd->obd_recoverable_clients;
1242 req->rq_export->exp_replay_needed = 0;
1244 recovery_done = (obd->obd_recoverable_clients == 0);
1245 spin_unlock_bh(&obd->obd_processing_task_lock);
1247 OBD_RACE(OBD_FAIL_LDLM_RECOV_CLIENTS);
1248 if (recovery_done) {
1249 spin_lock_bh(&obd->obd_processing_task_lock);
1250 obd->obd_recovering = obd->obd_abort_recovery = 0;
1251 target_cancel_recovery_timer(obd);
1252 spin_unlock_bh(&obd->obd_processing_task_lock);
1254 target_finish_recovery(obd);
1255 ptlrpc_run_recovery_over_upcall(obd);
1257 CWARN("%s: %d recoverable clients remain\n",
1258 obd->obd_name, obd->obd_recoverable_clients);
1259 wake_up(&obd->obd_next_transno_waitq);
1266 target_send_reply_msg (struct ptlrpc_request *req, int rc, int fail_id)
1268 if (OBD_FAIL_CHECK(fail_id | OBD_FAIL_ONCE)) {
1269 obd_fail_loc |= OBD_FAIL_ONCE | OBD_FAILED;
1270 DEBUG_REQ(D_ERROR, req, "dropping reply");
1275 DEBUG_REQ(D_ERROR, req, "processing error (%d)", rc);
1276 req->rq_status = rc;
1277 return (ptlrpc_error(req));
1279 DEBUG_REQ(D_NET, req, "sending reply");
1282 return (ptlrpc_send_reply(req, 1));
1286 target_send_reply(struct ptlrpc_request *req, int rc, int fail_id)
1289 unsigned long flags;
1290 struct ptlrpc_reply_state *rs;
1291 struct obd_device *obd;
1292 struct obd_export *exp;
1293 struct ptlrpc_service *svc;
1295 svc = req->rq_rqbd->rqbd_service;
1296 rs = req->rq_reply_state;
1297 if (rs == NULL || !rs->rs_difficult) {
1299 target_send_reply_msg (req, rc, fail_id);
1303 /* must be an export if locks saved */
1304 LASSERT (req->rq_export != NULL);
1305 /* req/reply consistent */
1306 LASSERT (rs->rs_service == svc);
1309 LASSERT (!rs->rs_scheduled);
1310 LASSERT (!rs->rs_scheduled_ever);
1311 LASSERT (!rs->rs_handled);
1312 LASSERT (!rs->rs_on_net);
1313 LASSERT (rs->rs_export == NULL);
1314 LASSERT (list_empty(&rs->rs_obd_list));
1315 LASSERT (list_empty(&rs->rs_exp_list));
1317 exp = class_export_get (req->rq_export);
1320 /* disable reply scheduling onto srv_reply_queue while I'm setting up */
1321 rs->rs_scheduled = 1;
1323 rs->rs_xid = req->rq_xid;
1324 rs->rs_transno = req->rq_transno;
1325 rs->rs_export = exp;
1327 spin_lock_irqsave (&obd->obd_uncommitted_replies_lock, flags);
1329 if (rs->rs_transno > obd->obd_last_committed) {
1330 /* not committed already */
1331 list_add_tail (&rs->rs_obd_list,
1332 &obd->obd_uncommitted_replies);
1335 spin_unlock (&obd->obd_uncommitted_replies_lock);
1336 spin_lock (&exp->exp_lock);
1338 list_add_tail (&rs->rs_exp_list, &exp->exp_outstanding_replies);
1340 spin_unlock_irqrestore (&exp->exp_lock, flags);
1342 netrc = target_send_reply_msg (req, rc, fail_id);
1344 spin_lock_irqsave (&svc->srv_lock, flags);
1346 svc->srv_n_difficult_replies++;
1349 /* error sending: reply is off the net. Also we need +1
1350 * reply ref until ptlrpc_server_handle_reply() is done
1351 * with the reply state (if the send was successful, there
1352 * would have been +1 ref for the net, which
1353 * reply_out_callback leaves alone) */
1355 ptlrpc_rs_addref(rs);
1356 atomic_inc (&svc->srv_outstanding_replies);
1359 if (!rs->rs_on_net || /* some notifier */
1360 list_empty(&rs->rs_exp_list) || /* completed already */
1361 list_empty(&rs->rs_obd_list)) {
1362 list_add_tail (&rs->rs_list, &svc->srv_reply_queue);
1363 wake_up (&svc->srv_waitq);
1365 list_add (&rs->rs_list, &svc->srv_active_replies);
1366 rs->rs_scheduled = 0; /* allow notifier to schedule */
1369 spin_unlock_irqrestore (&svc->srv_lock, flags);
1372 int target_handle_ping(struct ptlrpc_request *req)
1374 return lustre_pack_reply(req, 0, NULL, NULL);
1377 void target_committed_to_req(struct ptlrpc_request *req)
1379 struct obd_device *obd = req->rq_export->exp_obd;
1381 if (!obd->obd_no_transno && req->rq_repmsg != NULL)
1382 req->rq_repmsg->last_committed = obd->obd_last_committed;
1384 DEBUG_REQ(D_IOCTL, req, "not sending last_committed update");
1386 CDEBUG(D_INFO, "last_committed "LPU64", xid "LPU64"\n",
1387 obd->obd_last_committed, req->rq_xid);
1390 EXPORT_SYMBOL(target_committed_to_req);
1392 #ifdef HAVE_QUOTA_SUPPORT
1393 int target_handle_qc_callback(struct ptlrpc_request *req)
1395 struct obd_quotactl *oqctl;
1396 struct client_obd *cli = &req->rq_export->exp_obd->u.cli;
1398 oqctl = lustre_swab_reqbuf(req, 0, sizeof(*oqctl),
1399 lustre_swab_obd_quotactl);
1401 cli->cl_qchk_stat = oqctl->qc_stat;
1406 int target_handle_dqacq_callback(struct ptlrpc_request *req)
1409 struct obd_device *obd = req->rq_export->exp_obd;
1410 struct obd_device *master_obd;
1411 struct lustre_quota_ctxt *qctxt;
1412 struct qunit_data *qdata, *rep;
1413 int rc = 0, repsize = sizeof(struct qunit_data);
1416 rc = lustre_pack_reply(req, 1, &repsize, NULL);
1418 CERROR("packing reply failed!: rc = %d\n", rc);
1421 rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*rep));
1424 qdata = lustre_swab_reqbuf(req, 0, sizeof(*qdata), lustre_swab_qdata);
1425 if (qdata == NULL) {
1426 CERROR("unpacking request buffer failed!");
1430 /* we use the observer */
1431 LASSERT(obd->obd_observer && obd->obd_observer->obd_observer);
1432 master_obd = obd->obd_observer->obd_observer;
1433 qctxt = &master_obd->u.obt.obt_qctxt;
1435 LASSERT(qctxt->lqc_handler);
1436 rc = qctxt->lqc_handler(master_obd, qdata, req->rq_reqmsg->opc);
1437 if (rc && rc != -EDQUOT)
1438 CDEBUG(rc == -EBUSY ? D_QUOTA : D_ERROR,
1439 "dqacq failed! (rc:%d)\n", rc);
1441 /* the qd_count might be changed in lqc_handler */
1442 memcpy(rep, qdata, sizeof(*rep));
1443 req->rq_status = rc;
1444 rc = ptlrpc_reply(req);
1449 #endif /* !__KERNEL__ */
1451 #endif /* HAVE_QUOTA_SUPPORT */
1453 ldlm_mode_t lck_compat_array[] = {
1454 [LCK_EX] LCK_COMPAT_EX,
1455 [LCK_PW] LCK_COMPAT_PW,
1456 [LCK_PR] LCK_COMPAT_PR,
1457 [LCK_CW] LCK_COMPAT_CW,
1458 [LCK_CR] LCK_COMPAT_CR,
1459 [LCK_NL] LCK_COMPAT_NL,
1460 [LCK_GROUP] LCK_COMPAT_GROUP