4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2013, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/ost/ost_handler.c
38 * Author: Peter J. Braam <braam@clusterfs.com>
39 * Author: Phil Schwan <phil@clusterfs.com>
42 #define DEBUG_SUBSYSTEM S_OST
44 #include <linux/module.h>
45 #include <obd_cksum.h>
47 #include <lustre_net.h>
48 #include <lustre_dlm.h>
49 #include <lustre_export.h>
50 #include <lustre_debug.h>
51 #include <lustre_fid.h>
52 #include <lustre_fld.h>
53 #include <linux/init.h>
54 #include <lprocfs_status.h>
55 #include <libcfs/list.h>
56 #include <lustre_quota.h>
57 #include <lustre_fid.h>
58 #include "ost_internal.h"
59 #include <lustre_fid.h>
61 static int oss_num_threads;
62 CFS_MODULE_PARM(oss_num_threads, "i", int, 0444,
63 "number of OSS service threads to start");
65 static int ost_num_threads;
66 CFS_MODULE_PARM(ost_num_threads, "i", int, 0444,
67 "number of OST service threads to start (deprecated)");
69 static int oss_num_create_threads;
70 CFS_MODULE_PARM(oss_num_create_threads, "i", int, 0444,
71 "number of OSS create threads to start");
73 static char *oss_cpts;
74 CFS_MODULE_PARM(oss_cpts, "s", charp, 0444,
75 "CPU partitions OSS threads should run on");
77 static char *oss_io_cpts;
78 CFS_MODULE_PARM(oss_io_cpts, "s", charp, 0444,
79 "CPU partitions OSS IO threads should run on");
82 * this page is allocated statically when module is initializing
83 * it is used to simulate data corruptions, see ost_checksum_bulk()
84 * for details. as the original pages provided by the layers below
85 * can be remain in the internal cache, we do not want to modify
88 static struct page *ost_page_to_corrupt = NULL;
91 * Do not return server-side uid/gid to remote client
93 static void ost_drop_id(struct obd_export *exp, struct obdo *oa)
95 if (exp_connect_rmtclient(exp)) {
98 oa->o_valid &= ~(OBD_MD_FLUID | OBD_MD_FLGID);
103 * Validate oa from client.
104 * If the request comes from 2.0 clients, currently only RSVD seq and IDIF
106 * a. objects in Single MDT FS seq = FID_SEQ_OST_MDT0, oi_id != 0
107 * b. Echo objects(seq = 2), old echo client still use oi_id/oi_seq to
108 * pack ost_id. Because non-zero oi_seq will make it diffcult to tell
109 * whether this is oi_fid or real ostid. So it will check
110 * OBD_CONNECT_FID, then convert the ostid to FID for old client.
111 * c. Old FID-disable osc will send IDIF.
112 * d. new FID-enable osc/osp will send normal FID.
114 * And also oi_id/f_oid should always start from 1. oi_id/f_oid = 0 will
115 * be used for LAST_ID file, and only being accessed inside OST now.
117 static int ost_validate_obdo(struct obd_export *exp, struct obdo *oa,
118 struct obd_ioobj *ioobj)
122 if (unlikely(!(exp_connect_flags(exp) & OBD_CONNECT_FID) &&
123 fid_seq_is_echo(oa->o_oi.oi.oi_seq) && oa != NULL)) {
124 /* Sigh 2.[123] client still sends echo req with oi_id = 0
125 * during create, and we will reset this to 1, since this
126 * oi_id is basically useless in the following create process,
127 * but oi_id == 0 will make it difficult to tell whether it is
128 * real FID or ost_id. */
129 oa->o_oi.oi_fid.f_oid = oa->o_oi.oi.oi_id ?: 1;
130 oa->o_oi.oi_fid.f_seq = FID_SEQ_ECHO;
131 oa->o_oi.oi_fid.f_ver = 0;
133 if (unlikely((oa == NULL) || ostid_id(&oa->o_oi) == 0))
134 GOTO(out, rc = -EPROTO);
136 /* Note: this check might be forced in 2.5 or 2.6, i.e.
137 * all of the requests are required to setup FLGROUP */
138 if (unlikely(!(oa->o_valid & OBD_MD_FLGROUP))) {
139 ostid_set_seq_mdt0(&oa->o_oi);
141 ostid_set_seq_mdt0(&ioobj->ioo_oid);
142 oa->o_valid |= OBD_MD_FLGROUP;
145 if (unlikely(!(fid_seq_is_idif(ostid_seq(&oa->o_oi)) ||
146 fid_seq_is_mdt0(ostid_seq(&oa->o_oi)) ||
147 fid_seq_is_norm(ostid_seq(&oa->o_oi)) ||
148 fid_seq_is_echo(ostid_seq(&oa->o_oi)))))
149 GOTO(out, rc = -EPROTO);
153 unsigned max_brw = ioobj_max_brw_get(ioobj);
155 if (unlikely((max_brw & (max_brw - 1)) != 0)) {
156 CERROR("%s: client %s sent bad ioobj max %u for "DOSTID
157 ": rc = -EPROTO\n", exp->exp_obd->obd_name,
158 obd_export_nid2str(exp), max_brw,
160 GOTO(out, rc = -EPROTO);
162 ioobj->ioo_oid = oa->o_oi;
167 CERROR("%s: client %s sent bad object "DOSTID": rc = %d\n",
168 exp->exp_obd->obd_name, obd_export_nid2str(exp),
169 oa ? ostid_seq(&oa->o_oi) : -1,
170 oa ? ostid_id(&oa->o_oi) : -1, rc);
174 void oti_to_request(struct obd_trans_info *oti, struct ptlrpc_request *req)
176 struct oti_req_ack_lock *ack_lock;
182 if (req->rq_repmsg) {
183 __u64 versions[PTLRPC_NUM_VERSIONS] = { 0 };
184 lustre_msg_set_transno(req->rq_repmsg, oti->oti_transno);
185 versions[0] = oti->oti_pre_version;
186 lustre_msg_set_versions(req->rq_repmsg, versions);
188 req->rq_transno = oti->oti_transno;
190 /* XXX 4 == entries in oti_ack_locks??? */
191 for (ack_lock = oti->oti_ack_locks, i = 0; i < 4; i++, ack_lock++) {
194 /* XXX not even calling target_send_reply in some cases... */
195 ptlrpc_save_lock (req, &ack_lock->lock, ack_lock->mode, 0);
199 static int ost_destroy(struct obd_export *exp, struct ptlrpc_request *req,
200 struct obd_trans_info *oti)
202 struct ost_body *body, *repbody;
203 struct lustre_capa *capa = NULL;
207 /* Get the request body */
208 body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
212 if (ostid_id(&body->oa.o_oi) == 0)
215 rc = ost_validate_obdo(exp, &body->oa, NULL);
219 /* If there's a DLM request, cancel the locks mentioned in it*/
220 if (req_capsule_field_present(&req->rq_pill, &RMF_DLM_REQ, RCL_CLIENT)) {
221 struct ldlm_request *dlm;
223 dlm = req_capsule_client_get(&req->rq_pill, &RMF_DLM_REQ);
226 ldlm_request_cancel(req, dlm, 0);
229 /* If there's a capability, get it */
230 if (body->oa.o_valid & OBD_MD_FLOSSCAPA) {
231 capa = req_capsule_client_get(&req->rq_pill, &RMF_CAPA1);
233 CERROR("Missing capability for OST DESTROY");
238 /* Prepare the reply */
239 rc = req_capsule_server_pack(&req->rq_pill);
243 /* Get the log cancellation cookie */
244 if (body->oa.o_valid & OBD_MD_FLCOOKIE)
245 oti->oti_logcookies = &body->oa.o_lcookie;
247 /* Finish the reply */
248 repbody = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
249 memcpy(&repbody->oa, &body->oa, sizeof(body->oa));
251 /* Do the destroy and set the reply status accordingly */
252 req->rq_status = obd_destroy(req->rq_svc_thread->t_env, exp,
253 &repbody->oa, NULL, oti, NULL, capa);
258 * Helper function for getting server side [start, start+count] DLM lock
259 * if asked by client.
261 static int ost_lock_get(struct obd_export *exp, struct obdo *oa,
262 __u64 start, __u64 count, struct lustre_handle *lh,
263 int mode, __u64 flags)
265 struct ldlm_res_id res_id;
266 ldlm_policy_data_t policy;
267 __u64 end = start + count;
271 LASSERT(!lustre_handle_is_used(lh));
272 /* o_id and o_gr are used for localizing resource, if client miss to set
273 * them, do not trigger ASSERTION. */
274 if (unlikely((oa->o_valid & (OBD_MD_FLID | OBD_MD_FLGROUP)) !=
275 (OBD_MD_FLID | OBD_MD_FLGROUP)))
278 if (!(oa->o_valid & OBD_MD_FLFLAGS) ||
279 !(oa->o_flags & OBD_FL_SRVLOCK))
282 ostid_build_res_name(&oa->o_oi, &res_id);
283 CDEBUG(D_INODE, "OST-side extent lock.\n");
285 policy.l_extent.start = start & CFS_PAGE_MASK;
287 /* If ->o_blocks is EOF it means "lock till the end of the
288 * file". Otherwise, it's size of a hole being punched (in bytes) */
289 if (count == OBD_OBJECT_EOF || end < start)
290 policy.l_extent.end = OBD_OBJECT_EOF;
292 policy.l_extent.end = end | ~CFS_PAGE_MASK;
294 RETURN(ldlm_cli_enqueue_local(exp->exp_obd->obd_namespace, &res_id,
295 LDLM_EXTENT, &policy, mode, &flags,
296 ldlm_blocking_ast, ldlm_completion_ast,
297 ldlm_glimpse_ast, NULL, 0, LVB_T_NONE,
301 /* Helper function: release lock, if any. */
302 static void ost_lock_put(struct obd_export *exp,
303 struct lustre_handle *lh, int mode)
306 if (lustre_handle_is_used(lh))
307 ldlm_lock_decref(lh, mode);
311 static int ost_getattr(struct obd_export *exp, struct ptlrpc_request *req)
313 struct ost_body *body, *repbody;
314 struct obd_info *oinfo;
315 struct lustre_handle lh = { 0 };
316 struct lustre_capa *capa = NULL;
320 body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
324 rc = ost_validate_obdo(exp, &body->oa, NULL);
328 if (body->oa.o_valid & OBD_MD_FLOSSCAPA) {
329 capa = req_capsule_client_get(&req->rq_pill, &RMF_CAPA1);
331 CERROR("Missing capability for OST GETATTR");
336 rc = req_capsule_server_pack(&req->rq_pill);
340 repbody = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
341 repbody->oa = body->oa;
343 rc = ost_lock_get(exp, &repbody->oa, 0, OBD_OBJECT_EOF, &lh, LCK_PR, 0);
347 OBD_ALLOC_PTR(oinfo);
349 GOTO(unlock, rc = -ENOMEM);
350 oinfo->oi_oa = &repbody->oa;
351 oinfo->oi_capa = capa;
353 req->rq_status = obd_getattr(req->rq_svc_thread->t_env, exp, oinfo);
357 ost_drop_id(exp, &repbody->oa);
360 ost_lock_put(exp, &lh, LCK_PR);
364 static int ost_statfs(struct ptlrpc_request *req)
366 struct obd_statfs *osfs;
370 rc = req_capsule_server_pack(&req->rq_pill);
374 osfs = req_capsule_server_get(&req->rq_pill, &RMF_OBD_STATFS);
376 req->rq_status = obd_statfs(req->rq_svc_thread->t_env, req->rq_export,
378 cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
380 if (req->rq_status != 0)
381 CERROR("ost: statfs failed: rc %d\n", req->rq_status);
383 if (OBD_FAIL_CHECK(OBD_FAIL_OST_STATFS_EINPROGRESS))
384 req->rq_status = -EINPROGRESS;
389 static int ost_create(struct obd_export *exp, struct ptlrpc_request *req,
390 struct obd_trans_info *oti)
392 struct ost_body *body, *repbody;
396 body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
400 rc = ost_validate_obdo(req->rq_export, &body->oa, NULL);
404 rc = req_capsule_server_pack(&req->rq_pill);
408 repbody = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
409 repbody->oa = body->oa;
410 oti->oti_logcookies = &body->oa.o_lcookie;
412 req->rq_status = obd_create(req->rq_svc_thread->t_env, exp,
413 &repbody->oa, NULL, oti);
414 //obd_log_cancel(conn, NULL, 1, oti->oti_logcookies, 0);
418 static int ost_punch(struct obd_export *exp, struct ptlrpc_request *req,
419 struct obd_trans_info *oti)
421 struct ost_body *body, *repbody;
423 struct lustre_handle lh = {0,};
427 /* check that we do support OBD_CONNECT_TRUNCLOCK. */
428 CLASSERT(OST_CONNECT_SUPPORTED & OBD_CONNECT_TRUNCLOCK);
430 body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
434 rc = ost_validate_obdo(exp, &body->oa, NULL);
438 if ((body->oa.o_valid & (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS)) !=
439 (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS))
442 rc = req_capsule_server_pack(&req->rq_pill);
446 /* standard truncate optimization: if file body is completely
447 * destroyed, don't send data back to the server. */
448 if (body->oa.o_size == 0)
449 flags |= LDLM_FL_AST_DISCARD_DATA;
451 repbody = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
452 repbody->oa = body->oa;
454 rc = ost_lock_get(exp, &repbody->oa, repbody->oa.o_size,
455 repbody->oa.o_blocks, &lh, LCK_PW, flags);
457 struct obd_info *oinfo;
458 struct lustre_capa *capa = NULL;
460 if (repbody->oa.o_valid & OBD_MD_FLFLAGS &&
461 repbody->oa.o_flags == OBD_FL_SRVLOCK)
463 * If OBD_FL_SRVLOCK is the only bit set in
464 * ->o_flags, clear OBD_MD_FLFLAGS to avoid falling
465 * through filter_setattr() to filter_iocontrol().
467 repbody->oa.o_valid &= ~OBD_MD_FLFLAGS;
469 if (repbody->oa.o_valid & OBD_MD_FLOSSCAPA) {
470 capa = req_capsule_client_get(&req->rq_pill,
473 CERROR("Missing capability for OST PUNCH");
474 GOTO(unlock, rc = -EFAULT);
478 OBD_ALLOC_PTR(oinfo);
480 GOTO(unlock, rc = -ENOMEM);
481 oinfo->oi_oa = &repbody->oa;
482 oinfo->oi_policy.l_extent.start = oinfo->oi_oa->o_size;
483 oinfo->oi_policy.l_extent.end = oinfo->oi_oa->o_blocks;
484 oinfo->oi_capa = capa;
485 oinfo->oi_flags = OBD_FL_PUNCH;
487 req->rq_status = obd_punch(req->rq_svc_thread->t_env, exp,
491 ost_lock_put(exp, &lh, LCK_PW);
494 ost_drop_id(exp, &repbody->oa);
498 static int ost_sync(struct obd_export *exp, struct ptlrpc_request *req,
499 struct obd_trans_info *oti)
501 struct ost_body *body, *repbody;
502 struct obd_info *oinfo;
503 struct lustre_capa *capa = NULL;
507 body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
511 rc = ost_validate_obdo(exp, &body->oa, NULL);
515 if (body->oa.o_valid & OBD_MD_FLOSSCAPA) {
516 capa = req_capsule_client_get(&req->rq_pill, &RMF_CAPA1);
518 CERROR("Missing capability for OST SYNC");
523 rc = req_capsule_server_pack(&req->rq_pill);
527 repbody = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
528 repbody->oa = body->oa;
530 OBD_ALLOC_PTR(oinfo);
534 oinfo->oi_oa = &repbody->oa;
535 oinfo->oi_capa = capa;
536 oinfo->oi_jobid = oti->oti_jobid;
537 req->rq_status = obd_sync(req->rq_svc_thread->t_env, exp, oinfo,
538 repbody->oa.o_size, repbody->oa.o_blocks,
542 ost_drop_id(exp, &repbody->oa);
546 static int ost_setattr(struct obd_export *exp, struct ptlrpc_request *req,
547 struct obd_trans_info *oti)
549 struct ost_body *body, *repbody;
550 struct obd_info *oinfo;
551 struct lustre_capa *capa = NULL;
555 body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
559 rc = ost_validate_obdo(req->rq_export, &body->oa, NULL);
563 rc = req_capsule_server_pack(&req->rq_pill);
567 if (body->oa.o_valid & OBD_MD_FLOSSCAPA) {
568 capa = req_capsule_client_get(&req->rq_pill, &RMF_CAPA1);
570 CERROR("Missing capability for OST SETATTR");
575 repbody = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
576 repbody->oa = body->oa;
578 OBD_ALLOC_PTR(oinfo);
581 oinfo->oi_oa = &repbody->oa;
582 oinfo->oi_capa = capa;
584 req->rq_status = obd_setattr(req->rq_svc_thread->t_env, exp, oinfo,
589 ost_drop_id(exp, &repbody->oa);
593 static __u32 ost_checksum_bulk(struct ptlrpc_bulk_desc *desc, int opc,
594 cksum_type_t cksum_type)
596 struct cfs_crypto_hash_desc *hdesc;
597 unsigned int bufsize;
599 unsigned char cfs_alg = cksum_obd2cfs(cksum_type);
602 hdesc = cfs_crypto_hash_init(cfs_alg, NULL, 0);
604 CERROR("Unable to initialize checksum hash %s\n",
605 cfs_crypto_hash_name(cfs_alg));
606 return PTR_ERR(hdesc);
608 CDEBUG(D_INFO, "Checksum for algo %s\n", cfs_crypto_hash_name(cfs_alg));
609 for (i = 0; i < desc->bd_iov_count; i++) {
611 /* corrupt the data before we compute the checksum, to
612 * simulate a client->OST data error */
613 if (i == 0 && opc == OST_WRITE &&
614 OBD_FAIL_CHECK(OBD_FAIL_OST_CHECKSUM_RECEIVE)) {
615 int off = desc->bd_iov[i].kiov_offset & ~CFS_PAGE_MASK;
616 int len = desc->bd_iov[i].kiov_len;
617 struct page *np = ost_page_to_corrupt;
618 char *ptr = kmap(desc->bd_iov[i].kiov_page) + off;
621 char *ptr2 = kmap(np) + off;
623 memcpy(ptr2, ptr, len);
624 memcpy(ptr2, "bad3", min(4, len));
626 desc->bd_iov[i].kiov_page = np;
628 CERROR("can't alloc page for corruption\n");
631 cfs_crypto_hash_update_page(hdesc, desc->bd_iov[i].kiov_page,
632 desc->bd_iov[i].kiov_offset & ~CFS_PAGE_MASK,
633 desc->bd_iov[i].kiov_len);
635 /* corrupt the data after we compute the checksum, to
636 * simulate an OST->client data error */
637 if (i == 0 && opc == OST_READ &&
638 OBD_FAIL_CHECK(OBD_FAIL_OST_CHECKSUM_SEND)) {
639 int off = desc->bd_iov[i].kiov_offset & ~CFS_PAGE_MASK;
640 int len = desc->bd_iov[i].kiov_len;
641 struct page *np = ost_page_to_corrupt;
642 char *ptr = kmap(desc->bd_iov[i].kiov_page) + off;
645 char *ptr2 = kmap(np) + off;
647 memcpy(ptr2, ptr, len);
648 memcpy(ptr2, "bad4", min(4, len));
650 desc->bd_iov[i].kiov_page = np;
652 CERROR("can't alloc page for corruption\n");
658 err = cfs_crypto_hash_final(hdesc, (unsigned char *)&cksum, &bufsize);
660 cfs_crypto_hash_final(hdesc, NULL, NULL);
665 static int ost_brw_lock_get(int mode, struct obd_export *exp,
666 struct obd_ioobj *obj, struct niobuf_remote *nb,
667 struct lustre_handle *lh)
670 int nrbufs = obj->ioo_bufcnt;
671 struct ldlm_res_id res_id;
672 ldlm_policy_data_t policy;
676 ostid_build_res_name(&obj->ioo_oid, &res_id);
677 LASSERT(mode == LCK_PR || mode == LCK_PW);
678 LASSERT(!lustre_handle_is_used(lh));
680 if (nrbufs == 0 || !(nb[0].flags & OBD_BRW_SRVLOCK))
683 for (i = 1; i < nrbufs; i ++)
684 if ((nb[0].flags & OBD_BRW_SRVLOCK) !=
685 (nb[i].flags & OBD_BRW_SRVLOCK))
688 policy.l_extent.start = nb[0].offset & CFS_PAGE_MASK;
689 policy.l_extent.end = (nb[nrbufs - 1].offset +
690 nb[nrbufs - 1].len - 1) | ~CFS_PAGE_MASK;
692 RETURN(ldlm_cli_enqueue_local(exp->exp_obd->obd_namespace, &res_id,
693 LDLM_EXTENT, &policy, mode, &flags,
694 ldlm_blocking_ast, ldlm_completion_ast,
695 ldlm_glimpse_ast, NULL, 0, LVB_T_NONE,
699 static void ost_brw_lock_put(int mode,
700 struct obd_ioobj *obj, struct niobuf_remote *niob,
701 struct lustre_handle *lh)
704 LASSERT(mode == LCK_PR || mode == LCK_PW);
705 LASSERT((obj->ioo_bufcnt > 0 && (niob[0].flags & OBD_BRW_SRVLOCK)) ==
706 lustre_handle_is_used(lh));
707 if (lustre_handle_is_used(lh))
708 ldlm_lock_decref(lh, mode);
712 /* Allocate thread local buffers if needed */
713 static struct ost_thread_local_cache *ost_tls_get(struct ptlrpc_request *r)
715 struct ost_thread_local_cache *tls =
716 (struct ost_thread_local_cache *)(r->rq_svc_thread->t_data);
718 /* In normal mode of operation an I/O request is serviced only
719 * by ll_ost_io threads each of them has own tls buffers allocated by
720 * ost_io_thread_init().
721 * During recovery, an I/O request may be queued until any of the ost
722 * service threads process it. Not necessary it should be one of
723 * ll_ost_io threads. In that case we dynamically allocating tls
724 * buffers for the request service time. */
725 if (unlikely(tls == NULL)) {
726 LASSERT(r->rq_export->exp_in_recovery);
730 r->rq_svc_thread->t_data = tls;
736 /* Free thread local buffers if they were allocated only for servicing
737 * this one request */
738 static void ost_tls_put(struct ptlrpc_request *r)
740 struct ost_thread_local_cache *tls =
741 (struct ost_thread_local_cache *)(r->rq_svc_thread->t_data);
743 if (unlikely(tls->temporary)) {
745 r->rq_svc_thread->t_data = NULL;
749 static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
751 struct ptlrpc_bulk_desc *desc = NULL;
752 struct obd_export *exp = req->rq_export;
753 struct niobuf_remote *remote_nb;
754 struct niobuf_local *local_nb;
755 struct obd_ioobj *ioo;
756 struct ost_body *body, *repbody;
757 struct lustre_capa *capa = NULL;
758 struct l_wait_info lwi;
759 struct lustre_handle lockh = { 0 };
760 int niocount, npages, nob = 0, rc, i;
762 struct ost_thread_local_cache *tls;
765 req->rq_bulk_read = 1;
767 if (OBD_FAIL_CHECK(OBD_FAIL_OST_BRW_READ_BULK))
768 GOTO(out, rc = -EIO);
770 OBD_FAIL_TIMEOUT(OBD_FAIL_OST_BRW_PAUSE_BULK, (obd_timeout + 1) / 4);
772 /* Check if there is eviction in progress, and if so, wait for it to
774 if (unlikely(cfs_atomic_read(&exp->exp_obd->obd_evict_inprogress))) {
775 lwi = LWI_INTR(NULL, NULL); // We do not care how long it takes
776 rc = l_wait_event(exp->exp_obd->obd_evict_inprogress_waitq,
777 !cfs_atomic_read(&exp->exp_obd->obd_evict_inprogress),
781 GOTO(out, rc = -ENOTCONN);
783 /* ost_body, ioobj & noibuf_remote are verified and swabbed in
784 * ost_rw_hpreq_check(). */
785 body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
787 GOTO(out, rc = -EFAULT);
790 * A req_capsule_X_get_array(pill, field, ptr_to_element_count) function
791 * would be useful here and wherever we get &RMF_OBD_IOOBJ and
792 * &RMF_NIOBUF_REMOTE.
794 ioo = req_capsule_client_get(&req->rq_pill, &RMF_OBD_IOOBJ);
796 GOTO(out, rc = -EFAULT);
798 rc = ost_validate_obdo(exp, &body->oa, ioo);
802 niocount = ioo->ioo_bufcnt;
803 remote_nb = req_capsule_client_get(&req->rq_pill, &RMF_NIOBUF_REMOTE);
804 if (remote_nb == NULL)
805 GOTO(out, rc = -EFAULT);
807 if (body->oa.o_valid & OBD_MD_FLOSSCAPA) {
808 capa = req_capsule_client_get(&req->rq_pill, &RMF_CAPA1);
810 CERROR("Missing capability for OST BRW READ");
811 GOTO(out, rc = -EFAULT);
815 rc = req_capsule_server_pack(&req->rq_pill);
819 tls = ost_tls_get(req);
821 GOTO(out_bulk, rc = -ENOMEM);
822 local_nb = tls->local;
824 rc = ost_brw_lock_get(LCK_PR, exp, ioo, remote_nb, &lockh);
829 * If getting the lock took more time than
830 * client was willing to wait, drop it. b=11330
832 if (cfs_time_current_sec() > req->rq_deadline ||
833 OBD_FAIL_CHECK(OBD_FAIL_OST_DROP_REQ)) {
835 CERROR("Dropping timed-out read from %s because locking"
836 "object "DOSTID" took %ld seconds (limit was %ld).\n",
837 libcfs_id2str(req->rq_peer), POSTID(&ioo->ioo_oid),
838 cfs_time_current_sec() - req->rq_arrival_time.tv_sec,
839 req->rq_deadline - req->rq_arrival_time.tv_sec);
840 GOTO(out_lock, rc = -ETIMEDOUT);
843 repbody = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
844 memcpy(&repbody->oa, &body->oa, sizeof(repbody->oa));
846 npages = OST_THREAD_POOL_SIZE;
847 rc = obd_preprw(req->rq_svc_thread->t_env, OBD_BRW_READ, exp,
848 &repbody->oa, 1, ioo, remote_nb, &npages, local_nb,
853 desc = ptlrpc_prep_bulk_exp(req, npages, ioobj_max_brw_get(ioo),
854 BULK_PUT_SOURCE, OST_BULK_PORTAL);
856 GOTO(out_commitrw, rc = -ENOMEM);
859 for (i = 0; i < npages; i++) {
860 int page_rc = local_nb[i].rc;
862 if (page_rc < 0) { /* error */
868 if (page_rc != 0) { /* some data! */
869 LASSERT (local_nb[i].page != NULL);
870 ptlrpc_prep_bulk_page_nopin(desc, local_nb[i].page,
871 local_nb[i].lnb_page_offset,
875 if (page_rc != local_nb[i].len) { /* short read */
876 /* All subsequent pages should be 0 */
878 LASSERT(local_nb[i].rc == 0);
883 if (body->oa.o_valid & OBD_MD_FLCKSUM) {
884 cksum_type_t cksum_type =
885 cksum_type_unpack(repbody->oa.o_valid & OBD_MD_FLFLAGS ?
886 repbody->oa.o_flags : 0);
887 repbody->oa.o_flags = cksum_type_pack(cksum_type);
888 repbody->oa.o_valid = OBD_MD_FLCKSUM | OBD_MD_FLFLAGS;
889 repbody->oa.o_cksum = ost_checksum_bulk(desc, OST_READ,cksum_type);
890 CDEBUG(D_PAGE, "checksum at read origin: %x\n",
891 repbody->oa.o_cksum);
893 repbody->oa.o_valid = 0;
895 /* We're finishing using body->oa as an input variable */
897 /* Check if client was evicted while we were doing i/o before touching
900 if (likely(!CFS_FAIL_PRECHECK(OBD_FAIL_PTLRPC_CLIENT_BULK_CB2)))
901 rc = target_bulk_io(exp, desc, &lwi);
906 /* Must commit after prep above in all cases */
907 rc = obd_commitrw(req->rq_svc_thread->t_env, OBD_BRW_READ, exp,
908 &repbody->oa, 1, ioo, remote_nb, npages, local_nb,
912 ost_drop_id(exp, &repbody->oa);
915 ost_brw_lock_put(LCK_PR, ioo, remote_nb, &lockh);
919 if (desc && !CFS_FAIL_PRECHECK(OBD_FAIL_PTLRPC_CLIENT_BULK_CB2))
920 ptlrpc_free_bulk_nopin(desc);
924 req->rq_status = nob;
925 ptlrpc_lprocfs_brw(req, nob);
926 target_committed_to_req(req);
928 } else if (!no_reply) {
929 /* Only reply if there was no comms problem with bulk */
930 target_committed_to_req(req);
934 /* reply out callback would free */
935 ptlrpc_req_drop_rs(req);
936 LCONSOLE_WARN("%s: Bulk IO read error with %s (at %s), "
937 "client will retry: rc %d\n",
938 exp->exp_obd->obd_name,
939 obd_uuid2str(&exp->exp_client_uuid),
940 obd_export_nid2str(exp), rc);
942 /* send a bulk after reply to simulate a network delay or reordering
944 if (unlikely(CFS_FAIL_PRECHECK(OBD_FAIL_PTLRPC_CLIENT_BULK_CB2))) {
946 struct l_wait_info lwi1;
948 CDEBUG(D_INFO, "reorder BULK\n");
949 cfs_waitq_init(&waitq);
951 lwi1 = LWI_TIMEOUT_INTR(cfs_time_seconds(3), NULL, NULL, NULL);
952 l_wait_event(waitq, 0, &lwi1);
953 rc = target_bulk_io(exp, desc, &lwi);
954 ptlrpc_free_bulk_nopin(desc);
960 static void ost_warn_on_cksum(struct ptlrpc_request *req,
961 struct ptlrpc_bulk_desc *desc,
962 struct niobuf_local *local_nb, int npages,
963 obd_count client_cksum, obd_count server_cksum,
966 struct obd_export *exp = req->rq_export;
967 struct ost_body *body;
971 body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
972 LASSERT (body != NULL);
974 if (req->rq_peer.nid == desc->bd_sender) {
978 router = libcfs_nid2str(desc->bd_sender);
982 CDEBUG_LIMIT(D_INFO, "client csum %x, server csum %x\n",
983 client_cksum, server_cksum);
987 LCONSOLE_ERROR_MSG(0x168, "BAD WRITE CHECKSUM: %s from %s%s%s inode "
988 DFID" object "DOSTID" extent ["LPU64"-"LPU64
989 "]: client csum %x, server csum %x\n",
990 exp->exp_obd->obd_name, libcfs_id2str(req->rq_peer),
992 body->oa.o_valid & OBD_MD_FLFID ?
993 body->oa.o_parent_seq : (__u64)0,
994 body->oa.o_valid & OBD_MD_FLFID ?
995 body->oa.o_parent_oid : 0,
996 body->oa.o_valid & OBD_MD_FLFID ?
997 body->oa.o_parent_ver : 0,
998 POSTID(&body->oa.o_oi),
999 local_nb[0].lnb_file_offset,
1000 local_nb[npages-1].lnb_file_offset +
1001 local_nb[npages-1].len - 1,
1002 client_cksum, server_cksum);
1005 static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
1007 struct ptlrpc_bulk_desc *desc = NULL;
1008 struct obd_export *exp = req->rq_export;
1009 struct niobuf_remote *remote_nb;
1010 struct niobuf_local *local_nb;
1011 struct obd_ioobj *ioo;
1012 struct ost_body *body, *repbody;
1013 struct l_wait_info lwi;
1014 struct lustre_handle lockh = {0};
1015 struct lustre_capa *capa = NULL;
1017 int objcount, niocount, npages;
1019 obd_count client_cksum = 0, server_cksum = 0;
1020 cksum_type_t cksum_type = OBD_CKSUM_CRC32;
1021 int no_reply = 0, mmap = 0;
1022 __u32 o_uid = 0, o_gid = 0;
1023 struct ost_thread_local_cache *tls;
1026 req->rq_bulk_write = 1;
1028 if (OBD_FAIL_CHECK(OBD_FAIL_OST_BRW_WRITE_BULK))
1029 GOTO(out, rc = -EIO);
1030 if (OBD_FAIL_CHECK(OBD_FAIL_OST_BRW_WRITE_BULK2))
1031 GOTO(out, rc = -EFAULT);
1033 /* pause before transaction has been started */
1034 OBD_FAIL_TIMEOUT(OBD_FAIL_OST_BRW_PAUSE_BULK, (obd_timeout + 1) / 4);
1036 /* ost_body, ioobj & noibuf_remote are verified and swabbed in
1037 * ost_rw_hpreq_check(). */
1038 body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
1040 GOTO(out, rc = -EFAULT);
1042 objcount = req_capsule_get_size(&req->rq_pill, &RMF_OBD_IOOBJ,
1043 RCL_CLIENT) / sizeof(*ioo);
1044 ioo = req_capsule_client_get(&req->rq_pill, &RMF_OBD_IOOBJ);
1046 GOTO(out, rc = -EFAULT);
1048 rc = ost_validate_obdo(exp, &body->oa, ioo);
1052 for (niocount = i = 0; i < objcount; i++)
1053 niocount += ioo[i].ioo_bufcnt;
1056 * It'd be nice to have a capsule function to indicate how many elements
1057 * there were in a buffer for an RMF that's declared to be an array.
1058 * It's easy enough to compute the number of elements here though.
1060 remote_nb = req_capsule_client_get(&req->rq_pill, &RMF_NIOBUF_REMOTE);
1061 if (remote_nb == NULL || niocount != (req_capsule_get_size(&req->rq_pill,
1062 &RMF_NIOBUF_REMOTE, RCL_CLIENT) / sizeof(*remote_nb)))
1063 GOTO(out, rc = -EFAULT);
1065 if ((remote_nb[0].flags & OBD_BRW_MEMALLOC) &&
1066 (exp->exp_connection->c_peer.nid == exp->exp_connection->c_self))
1067 memory_pressure_set();
1069 if (body->oa.o_valid & OBD_MD_FLOSSCAPA) {
1070 capa = req_capsule_client_get(&req->rq_pill, &RMF_CAPA1);
1072 CERROR("Missing capability for OST BRW WRITE");
1073 GOTO(out, rc = -EFAULT);
1077 req_capsule_set_size(&req->rq_pill, &RMF_RCS, RCL_SERVER,
1078 niocount * sizeof(*rcs));
1079 rc = req_capsule_server_pack(&req->rq_pill);
1082 CFS_FAIL_TIMEOUT(OBD_FAIL_OST_BRW_PAUSE_PACK, cfs_fail_val);
1083 rcs = req_capsule_server_get(&req->rq_pill, &RMF_RCS);
1085 tls = ost_tls_get(req);
1087 GOTO(out_bulk, rc = -ENOMEM);
1088 local_nb = tls->local;
1090 rc = ost_brw_lock_get(LCK_PW, exp, ioo, remote_nb, &lockh);
1095 * If getting the lock took more time than
1096 * client was willing to wait, drop it. b=11330
1098 if (cfs_time_current_sec() > req->rq_deadline ||
1099 OBD_FAIL_CHECK(OBD_FAIL_OST_DROP_REQ)) {
1101 CERROR("Dropping timed-out write from %s because locking "
1102 "object "DOSTID" took %ld seconds (limit was %ld).\n",
1103 libcfs_id2str(req->rq_peer), POSTID(&ioo->ioo_oid),
1104 cfs_time_current_sec() - req->rq_arrival_time.tv_sec,
1105 req->rq_deadline - req->rq_arrival_time.tv_sec);
1106 GOTO(out_lock, rc = -ETIMEDOUT);
1109 /* obd_preprw clobbers oa->valid, so save what we need */
1110 if (body->oa.o_valid & OBD_MD_FLCKSUM) {
1111 client_cksum = body->oa.o_cksum;
1112 if (body->oa.o_valid & OBD_MD_FLFLAGS)
1113 cksum_type = cksum_type_unpack(body->oa.o_flags);
1115 if (body->oa.o_valid & OBD_MD_FLFLAGS && body->oa.o_flags & OBD_FL_MMAP)
1118 /* Because we already sync grant info with client when reconnect,
1119 * grant info will be cleared for resent req, then fed_grant and
1120 * total_grant will not be modified in following preprw_write */
1121 if (lustre_msg_get_flags(req->rq_reqmsg) & (MSG_RESENT | MSG_REPLAY)) {
1122 DEBUG_REQ(D_CACHE, req, "clear resent/replay req grant info");
1123 body->oa.o_valid &= ~OBD_MD_FLGRANT;
1126 if (exp_connect_rmtclient(exp)) {
1127 o_uid = body->oa.o_uid;
1128 o_gid = body->oa.o_gid;
1131 repbody = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
1132 memcpy(&repbody->oa, &body->oa, sizeof(repbody->oa));
1134 npages = OST_THREAD_POOL_SIZE;
1135 rc = obd_preprw(req->rq_svc_thread->t_env, OBD_BRW_WRITE, exp,
1136 &repbody->oa, objcount, ioo, remote_nb, &npages,
1137 local_nb, oti, capa);
1141 desc = ptlrpc_prep_bulk_exp(req, npages, ioobj_max_brw_get(ioo),
1142 BULK_GET_SINK, OST_BULK_PORTAL);
1144 GOTO(skip_transfer, rc = -ENOMEM);
1146 /* NB Having prepped, we must commit... */
1147 for (i = 0; i < npages; i++)
1148 ptlrpc_prep_bulk_page_nopin(desc, local_nb[i].page,
1149 local_nb[i].lnb_page_offset,
1152 rc = sptlrpc_svc_prep_bulk(req, desc);
1156 rc = target_bulk_io(exp, desc, &lwi);
1160 if (client_cksum != 0 && rc == 0) {
1161 static int cksum_counter;
1162 repbody->oa.o_valid |= OBD_MD_FLCKSUM | OBD_MD_FLFLAGS;
1163 repbody->oa.o_flags &= ~OBD_FL_CKSUM_ALL;
1164 repbody->oa.o_flags |= cksum_type_pack(cksum_type);
1165 server_cksum = ost_checksum_bulk(desc, OST_WRITE, cksum_type);
1166 repbody->oa.o_cksum = server_cksum;
1168 if (unlikely(client_cksum != server_cksum)) {
1169 ost_warn_on_cksum(req, desc, local_nb, npages,
1170 client_cksum, server_cksum, mmap);
1173 } else if ((cksum_counter & (-cksum_counter)) == cksum_counter){
1174 CDEBUG(D_INFO, "Checksum %u from %s OK: %x\n",
1175 cksum_counter, libcfs_id2str(req->rq_peer),
1180 /* Must commit after prep above in all cases */
1181 rc = obd_commitrw(req->rq_svc_thread->t_env, OBD_BRW_WRITE, exp,
1182 &repbody->oa, objcount, ioo, remote_nb, npages,
1184 if (rc == -ENOTCONN)
1185 /* quota acquire process has been given up because
1186 * either the client has been evicted or the client
1187 * has timed out the request already */
1190 if (exp_connect_rmtclient(exp)) {
1191 repbody->oa.o_uid = o_uid;
1192 repbody->oa.o_gid = o_gid;
1196 * Disable sending mtime back to the client. If the client locked the
1197 * whole object, then it has already updated the mtime on its side,
1198 * otherwise it will have to glimpse anyway (see bug 21489, comment 32)
1200 repbody->oa.o_valid &= ~(OBD_MD_FLMTIME | OBD_MD_FLATIME);
1205 /* set per-requested niobuf return codes */
1206 for (i = j = 0; i < niocount; i++) {
1207 int len = remote_nb[i].len;
1212 LASSERT(j < npages);
1213 if (local_nb[j].rc < 0)
1214 rcs[i] = local_nb[j].rc;
1215 len -= local_nb[j].len;
1220 LASSERT(j == npages);
1221 ptlrpc_lprocfs_brw(req, nob);
1225 ost_brw_lock_put(LCK_PW, ioo, remote_nb, &lockh);
1230 ptlrpc_free_bulk_nopin(desc);
1233 oti_to_request(oti, req);
1234 target_committed_to_req(req);
1235 rc = ptlrpc_reply(req);
1236 } else if (!no_reply) {
1237 /* Only reply if there was no comms problem with bulk */
1238 target_committed_to_req(req);
1239 req->rq_status = rc;
1242 /* reply out callback would free */
1243 ptlrpc_req_drop_rs(req);
1244 LCONSOLE_WARN("%s: Bulk IO write error with %s (at %s), "
1245 "client will retry: rc %d\n",
1246 exp->exp_obd->obd_name,
1247 obd_uuid2str(&exp->exp_client_uuid),
1248 obd_export_nid2str(exp), rc);
1250 memory_pressure_clr();
1255 * Implementation of OST_SET_INFO.
1257 * OST_SET_INFO is like ioctl(): heavily overloaded. Specifically, it takes a
1258 * "key" and a value RPC buffers as arguments, with the value's contents
1259 * interpreted according to the key.
1261 * Value types that need swabbing have swabbing done explicitly, either here or
1262 * in functions called from here. This should be corrected: all swabbing should
1263 * be done in the capsule abstraction, as that will then allow us to move
1264 * swabbing exclusively to the client without having to modify server code
1265 * outside the capsule abstraction's implementation itself. To correct this
1266 * will require minor changes to the capsule abstraction; see the comments for
1267 * req_capsule_extend() in layout.c.
1269 static int ost_set_info(struct obd_export *exp, struct ptlrpc_request *req)
1271 struct ost_body *body = NULL, *repbody;
1272 char *key, *val = NULL;
1273 int keylen, vallen, rc = 0;
1274 int is_grant_shrink = 0;
1277 key = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY);
1279 DEBUG_REQ(D_HA, req, "no set_info key");
1282 keylen = req_capsule_get_size(&req->rq_pill, &RMF_SETINFO_KEY,
1285 vallen = req_capsule_get_size(&req->rq_pill, &RMF_SETINFO_VAL,
1288 if ((is_grant_shrink = KEY_IS(KEY_GRANT_SHRINK)))
1289 /* In this case the value is actually an RMF_OST_BODY, so we
1290 * transmutate the type of this PTLRPC */
1291 req_capsule_extend(&req->rq_pill, &RQF_OST_SET_GRANT_INFO);
1293 rc = req_capsule_server_pack(&req->rq_pill);
1298 if (is_grant_shrink) {
1299 body = req_capsule_client_get(&req->rq_pill,
1304 repbody = req_capsule_server_get(&req->rq_pill,
1306 memcpy(repbody, body, sizeof(*body));
1307 val = (char*)repbody;
1309 val = req_capsule_client_get(&req->rq_pill,
1314 if (KEY_IS(KEY_EVICT_BY_NID)) {
1316 obd_export_evict_by_nid(exp->exp_obd, val);
1318 } else if (KEY_IS(KEY_MDS_CONN) && ptlrpc_req_need_swab(req)) {
1319 if (vallen < sizeof(__u32))
1321 __swab32s((__u32 *)val);
1324 /* OBD will also check if KEY_IS(KEY_GRANT_SHRINK), and will cast val to
1325 * a struct ost_body * value */
1326 rc = obd_set_info_async(req->rq_svc_thread->t_env, exp, keylen,
1327 key, vallen, val, NULL);
1329 lustre_msg_set_status(req->rq_repmsg, 0);
1333 struct locked_region {
1335 struct lustre_handle lh;
1338 static int lock_region(struct obd_export *exp, struct obdo *oa,
1339 unsigned long long begin, unsigned long long end,
1342 struct locked_region *region = NULL;
1345 LASSERT(begin <= end);
1346 OBD_ALLOC_PTR(region);
1350 rc = ost_lock_get(exp, oa, begin, end - begin, ®ion->lh, LCK_PR, 0);
1352 OBD_FREE_PTR(region);
1356 CDEBUG(D_OTHER, "ost lock [%llu,%llu], lh=%p\n",
1357 begin, end, ®ion->lh);
1358 cfs_list_add(®ion->list, locked);
1363 static int lock_zero_regions(struct obd_export *exp, struct obdo *oa,
1364 struct ll_user_fiemap *fiemap,
1367 __u64 begin = fiemap->fm_start;
1370 struct ll_fiemap_extent *fiemap_start = fiemap->fm_extents;
1373 CDEBUG(D_OTHER, "extents count %u\n", fiemap->fm_mapped_extents);
1374 for (i = 0; i < fiemap->fm_mapped_extents; i++) {
1375 if (fiemap_start[i].fe_logical > begin) {
1376 CDEBUG(D_OTHER, "ost lock [%llu,%llu]\n",
1377 begin, fiemap_start[i].fe_logical);
1378 rc = lock_region(exp, oa, begin,
1379 fiemap_start[i].fe_logical, locked);
1384 begin = fiemap_start[i].fe_logical + fiemap_start[i].fe_length;
1387 if (begin < (fiemap->fm_start + fiemap->fm_length)) {
1388 CDEBUG(D_OTHER, "ost lock [%llu,%llu]\n",
1389 begin, fiemap->fm_start + fiemap->fm_length);
1390 rc = lock_region(exp, oa, begin,
1391 fiemap->fm_start + fiemap->fm_length, locked);
1397 static void unlock_zero_regions(struct obd_export *exp, cfs_list_t *locked)
1399 struct locked_region *entry, *temp;
1400 cfs_list_for_each_entry_safe(entry, temp, locked, list) {
1401 CDEBUG(D_OTHER, "ost unlock lh=%p\n", &entry->lh);
1402 ost_lock_put(exp, &entry->lh, LCK_PR);
1403 cfs_list_del(&entry->list);
1404 OBD_FREE_PTR(entry);
1408 static int ost_get_info(struct obd_export *exp, struct ptlrpc_request *req)
1411 int keylen, replylen, rc = 0;
1412 struct req_capsule *pill = &req->rq_pill;
1413 cfs_list_t locked = CFS_LIST_HEAD_INIT(locked);
1414 struct ll_fiemap_info_key *fm_key = NULL;
1415 struct ll_user_fiemap *fiemap;
1418 /* this common part for get_info rpc */
1419 key = req_capsule_client_get(pill, &RMF_SETINFO_KEY);
1421 DEBUG_REQ(D_HA, req, "no get_info key");
1424 keylen = req_capsule_get_size(pill, &RMF_SETINFO_KEY, RCL_CLIENT);
1426 if (KEY_IS(KEY_FIEMAP)) {
1428 rc = ost_validate_obdo(exp, &fm_key->oa, NULL);
1433 rc = obd_get_info(req->rq_svc_thread->t_env, exp, keylen, key,
1434 &replylen, NULL, NULL);
1438 req_capsule_set_size(pill, &RMF_GENERIC_DATA,
1439 RCL_SERVER, replylen);
1441 rc = req_capsule_server_pack(pill);
1445 reply = req_capsule_server_get(pill, &RMF_GENERIC_DATA);
1449 if (KEY_IS(KEY_LAST_FID)) {
1453 req_capsule_extend(pill, &RQF_OST_GET_INFO_LAST_FID);
1454 val = req_capsule_client_get(pill, &RMF_SETINFO_VAL);
1455 vallen = req_capsule_get_size(pill, &RMF_SETINFO_VAL,
1457 if (val != NULL && vallen > 0 && replylen >= vallen) {
1458 memcpy(reply, val, vallen);
1460 CERROR("%s: invalid req val %p vallen %d replylen %d\n",
1461 exp->exp_obd->obd_name, val, vallen, replylen);
1466 /* call again to fill in the reply buffer */
1467 rc = obd_get_info(req->rq_svc_thread->t_env, exp, keylen, key,
1468 &replylen, reply, NULL);
1470 /* LU-3219: Lock the sparse areas to make sure dirty flushed back
1471 * from client, then call fiemap again. */
1472 if (KEY_IS(KEY_FIEMAP) && (fm_key->oa.o_valid & OBD_MD_FLFLAGS) &&
1473 (fm_key->oa.o_flags & OBD_FL_SRVLOCK)) {
1474 fiemap = (struct ll_user_fiemap *)reply;
1477 rc = lock_zero_regions(exp, &fm_key->oa, fiemap, &locked);
1478 if (rc == 0 && !cfs_list_empty(&locked))
1479 rc = obd_get_info(req->rq_svc_thread->t_env, exp,
1480 keylen, key, &replylen, reply, NULL);
1481 unlock_zero_regions(exp, &locked);
1486 lustre_msg_set_status(req->rq_repmsg, 0);
1491 static int ost_handle_quotactl(struct ptlrpc_request *req)
1493 struct obd_quotactl *oqctl, *repoqc;
1497 oqctl = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL);
1499 GOTO(out, rc = -EPROTO);
1501 rc = req_capsule_server_pack(&req->rq_pill);
1505 repoqc = req_capsule_server_get(&req->rq_pill, &RMF_OBD_QUOTACTL);
1506 req->rq_status = obd_quotactl(req->rq_export, oqctl);
1513 static int ost_handle_quotacheck(struct ptlrpc_request *req)
1515 struct obd_quotactl *oqctl;
1519 oqctl = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL);
1523 rc = req_capsule_server_pack(&req->rq_pill);
1527 /* deprecated, not used any more */
1528 req->rq_status = -EOPNOTSUPP;
1529 RETURN(-EOPNOTSUPP);
1532 static int ost_llog_handle_connect(struct obd_export *exp,
1533 struct ptlrpc_request *req)
1535 struct llogd_conn_body *body;
1539 body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_CONN_BODY);
1540 rc = obd_llog_connect(exp, body);
1544 #define ost_init_sec_none(reply, exp) \
1546 reply->ocd_connect_flags &= ~(OBD_CONNECT_RMT_CLIENT | \
1547 OBD_CONNECT_RMT_CLIENT_FORCE | \
1548 OBD_CONNECT_OSS_CAPA); \
1549 spin_lock(&exp->exp_lock); \
1550 *exp_connect_flags_ptr(exp) = reply->ocd_connect_flags; \
1551 spin_unlock(&exp->exp_lock); \
1554 static int ost_init_sec_level(struct ptlrpc_request *req)
1556 struct obd_export *exp = req->rq_export;
1557 struct req_capsule *pill = &req->rq_pill;
1558 struct obd_device *obd = exp->exp_obd;
1559 struct filter_obd *filter = &obd->u.filter;
1560 char *client = libcfs_nid2str(req->rq_peer.nid);
1561 struct obd_connect_data *data, *reply;
1565 data = req_capsule_client_get(pill, &RMF_CONNECT_DATA);
1566 reply = req_capsule_server_get(pill, &RMF_CONNECT_DATA);
1567 if (data == NULL || reply == NULL)
1570 /* connection from MDT is always trusted */
1571 if (req->rq_auth_usr_mdt) {
1572 ost_init_sec_none(reply, exp);
1576 /* no GSS support case */
1577 if (!req->rq_auth_gss) {
1578 if (filter->fo_sec_level > LUSTRE_SEC_NONE) {
1579 CWARN("client %s -> target %s does not user GSS, "
1580 "can not run under security level %d.\n",
1581 client, obd->obd_name, filter->fo_sec_level);
1584 ost_init_sec_none(reply, exp);
1589 /* old version case */
1590 if (unlikely(!(data->ocd_connect_flags & OBD_CONNECT_RMT_CLIENT) ||
1591 !(data->ocd_connect_flags & OBD_CONNECT_OSS_CAPA))) {
1592 if (filter->fo_sec_level > LUSTRE_SEC_NONE) {
1593 CWARN("client %s -> target %s uses old version, "
1594 "can not run under security level %d.\n",
1595 client, obd->obd_name, filter->fo_sec_level);
1598 CWARN("client %s -> target %s uses old version, "
1599 "run under security level %d.\n",
1600 client, obd->obd_name, filter->fo_sec_level);
1601 ost_init_sec_none(reply, exp);
1606 remote = data->ocd_connect_flags & OBD_CONNECT_RMT_CLIENT_FORCE;
1608 if (!req->rq_auth_remote)
1609 CDEBUG(D_SEC, "client (local realm) %s -> target %s "
1610 "asked to be remote.\n", client, obd->obd_name);
1611 } else if (req->rq_auth_remote) {
1613 CDEBUG(D_SEC, "client (remote realm) %s -> target %s is set "
1614 "as remote by default.\n", client, obd->obd_name);
1618 if (!filter->fo_fl_oss_capa) {
1619 CDEBUG(D_SEC, "client %s -> target %s is set as remote,"
1620 " but OSS capabilities are not enabled: %d.\n",
1621 client, obd->obd_name, filter->fo_fl_oss_capa);
1626 switch (filter->fo_sec_level) {
1627 case LUSTRE_SEC_NONE:
1629 ost_init_sec_none(reply, exp);
1632 CDEBUG(D_SEC, "client %s -> target %s is set as remote, "
1633 "can not run under security level %d.\n",
1634 client, obd->obd_name, filter->fo_sec_level);
1637 case LUSTRE_SEC_REMOTE:
1639 ost_init_sec_none(reply, exp);
1641 case LUSTRE_SEC_ALL:
1643 reply->ocd_connect_flags &= ~(OBD_CONNECT_RMT_CLIENT |
1644 OBD_CONNECT_RMT_CLIENT_FORCE);
1645 if (!filter->fo_fl_oss_capa)
1646 reply->ocd_connect_flags &= ~OBD_CONNECT_OSS_CAPA;
1648 spin_lock(&exp->exp_lock);
1649 *exp_connect_flags_ptr(exp) = reply->ocd_connect_flags;
1650 spin_unlock(&exp->exp_lock);
1662 * this should be done in filter_connect()/filter_reconnect(), but
1663 * we can't obtain information like NID, which stored in incoming
1664 * request, thus can't decide what flavor to use. so we do it here.
1666 * This hack should be removed after the OST stack be rewritten, just
1667 * like what we are doing in mdt_obd_connect()/mdt_obd_reconnect().
1669 static int ost_connect_check_sptlrpc(struct ptlrpc_request *req)
1671 struct obd_export *exp = req->rq_export;
1672 struct filter_obd *filter = &exp->exp_obd->u.filter;
1673 struct sptlrpc_flavor flvr;
1676 if (unlikely(strcmp(exp->exp_obd->obd_type->typ_name,
1677 LUSTRE_ECHO_NAME) == 0)) {
1678 exp->exp_flvr.sf_rpc = SPTLRPC_FLVR_ANY;
1682 if (exp->exp_flvr.sf_rpc == SPTLRPC_FLVR_INVALID) {
1683 read_lock(&filter->fo_sptlrpc_lock);
1684 sptlrpc_target_choose_flavor(&filter->fo_sptlrpc_rset,
1688 read_unlock(&filter->fo_sptlrpc_lock);
1690 spin_lock(&exp->exp_lock);
1692 exp->exp_sp_peer = req->rq_sp_from;
1693 exp->exp_flvr = flvr;
1695 if (exp->exp_flvr.sf_rpc != SPTLRPC_FLVR_ANY &&
1696 exp->exp_flvr.sf_rpc != req->rq_flvr.sf_rpc) {
1697 CERROR("unauthorized rpc flavor %x from %s, "
1698 "expect %x\n", req->rq_flvr.sf_rpc,
1699 libcfs_nid2str(req->rq_peer.nid),
1700 exp->exp_flvr.sf_rpc);
1704 spin_unlock(&exp->exp_lock);
1706 if (exp->exp_sp_peer != req->rq_sp_from) {
1707 CERROR("RPC source %s doesn't match %s\n",
1708 sptlrpc_part2name(req->rq_sp_from),
1709 sptlrpc_part2name(exp->exp_sp_peer));
1712 rc = sptlrpc_target_export_check(exp, req);
1719 /* Ensure that data and metadata are synced to the disk when lock is cancelled
1721 int ost_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
1722 void *data, int flag)
1725 __u32 sync_lock_cancel = 0;
1726 __u32 len = sizeof(sync_lock_cancel);
1731 rc = lu_env_init(&env, LCT_DT_THREAD);
1732 if (unlikely(rc != 0))
1735 rc = obd_get_info(&env, lock->l_export, sizeof(KEY_SYNC_LOCK_CANCEL),
1736 KEY_SYNC_LOCK_CANCEL, &len, &sync_lock_cancel, NULL);
1737 if (rc == 0 && flag == LDLM_CB_CANCELING &&
1738 (lock->l_granted_mode & (LCK_PW|LCK_GROUP)) &&
1739 (sync_lock_cancel == ALWAYS_SYNC_ON_CANCEL ||
1740 (sync_lock_cancel == BLOCKING_SYNC_ON_CANCEL &&
1741 lock->l_flags & LDLM_FL_CBPENDING))) {
1742 struct obd_info *oinfo;
1746 OBD_ALLOC_PTR(oinfo);
1748 GOTO(out_env, rc = -ENOMEM);
1751 OBD_FREE_PTR(oinfo);
1752 GOTO(out_env, rc = -ENOMEM);
1755 ostid_res_name_to_id(&oa->o_oi, &lock->l_resource->lr_name);
1756 oa->o_valid = OBD_MD_FLID|OBD_MD_FLGROUP;
1758 oinfo->oi_capa = BYPASS_CAPA;
1760 rc = obd_sync(&env, lock->l_export, oinfo,
1761 lock->l_policy_data.l_extent.start,
1762 lock->l_policy_data.l_extent.end, NULL);
1764 CERROR("Error %d syncing data on lock cancel\n", rc);
1767 OBD_FREE_PTR(oinfo);
1770 rc = ldlm_server_blocking_ast(lock, desc, data, flag);
1776 static int ost_filter_recovery_request(struct ptlrpc_request *req,
1777 struct obd_device *obd, int *process)
1779 switch (lustre_msg_get_opc(req->rq_reqmsg)) {
1780 case OST_CONNECT: /* This will never get here, but for completeness. */
1781 case OST_DISCONNECT:
1792 case OBD_LOG_CANCEL:
1794 *process = target_queue_recovery_request(req, obd);
1798 DEBUG_REQ(D_WARNING, req, "not permitted during recovery");
1804 int ost_msg_check_version(struct lustre_msg *msg)
1808 switch(lustre_msg_get_opc(msg)) {
1810 case OST_DISCONNECT:
1813 case SEC_CTX_INIT_CONT:
1815 rc = lustre_msg_check_version(msg, LUSTRE_OBD_VERSION);
1817 CERROR("bad opc %u version %08x, expecting %08x\n",
1818 lustre_msg_get_opc(msg),
1819 lustre_msg_get_version(msg),
1820 LUSTRE_OBD_VERSION);
1823 /* Note: client always use MDS_VERSION for FID request */
1824 rc = lustre_msg_check_version(msg, LUSTRE_MDS_VERSION);
1826 CERROR("bad opc %u version %08x, expecting %08x\n",
1827 lustre_msg_get_opc(msg),
1828 lustre_msg_get_version(msg),
1829 LUSTRE_MDS_VERSION);
1842 case OST_QUOTACHECK:
1844 rc = lustre_msg_check_version(msg, LUSTRE_OST_VERSION);
1846 CERROR("bad opc %u version %08x, expecting %08x\n",
1847 lustre_msg_get_opc(msg),
1848 lustre_msg_get_version(msg),
1849 LUSTRE_OST_VERSION);
1854 case LDLM_BL_CALLBACK:
1855 case LDLM_CP_CALLBACK:
1856 rc = lustre_msg_check_version(msg, LUSTRE_DLM_VERSION);
1858 CERROR("bad opc %u version %08x, expecting %08x\n",
1859 lustre_msg_get_opc(msg),
1860 lustre_msg_get_version(msg),
1861 LUSTRE_DLM_VERSION);
1863 case LLOG_ORIGIN_CONNECT:
1864 case OBD_LOG_CANCEL:
1865 rc = lustre_msg_check_version(msg, LUSTRE_LOG_VERSION);
1867 CERROR("bad opc %u version %08x, expecting %08x\n",
1868 lustre_msg_get_opc(msg),
1869 lustre_msg_get_version(msg),
1870 LUSTRE_LOG_VERSION);
1872 case OST_QUOTA_ADJUST_QUNIT:
1874 CERROR("Quota adjust is deprecated as of 2.4.0\n");
1877 CERROR("Unexpected opcode %d\n", lustre_msg_get_opc(msg));
1883 struct ost_prolong_data {
1884 struct ptlrpc_request *opd_req;
1885 struct obd_export *opd_exp;
1886 struct obdo *opd_oa;
1887 struct ldlm_res_id opd_resid;
1888 struct ldlm_extent opd_extent;
1889 ldlm_mode_t opd_mode;
1890 unsigned int opd_locks;
1894 /* prolong locks for the current service time of the corresponding
1895 * portal (= OST_IO_PORTAL)
1897 static inline int prolong_timeout(struct ptlrpc_request *req)
1899 struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt;
1902 return obd_timeout / 2;
1904 return max(at_est2timeout(at_get(&svcpt->scp_at_estimate)),
1908 static void ost_prolong_lock_one(struct ost_prolong_data *opd,
1909 struct ldlm_lock *lock)
1911 LASSERT(lock->l_export == opd->opd_exp);
1913 if (lock->l_flags & LDLM_FL_DESTROYED) /* lock already cancelled */
1916 /* XXX: never try to grab resource lock here because we're inside
1917 * exp_bl_list_lock; in ldlm_lockd.c to handle waiting list we take
1918 * res lock and then exp_bl_list_lock. */
1920 if (!(lock->l_flags & LDLM_FL_AST_SENT))
1921 /* ignore locks not being cancelled */
1925 "refreshed for req x"LPU64" ext("LPU64"->"LPU64") to %ds.\n",
1926 opd->opd_req->rq_xid, opd->opd_extent.start,
1927 opd->opd_extent.end, opd->opd_timeout);
1929 /* OK. this is a possible lock the user holds doing I/O
1930 * let's refresh eviction timer for it */
1931 ldlm_refresh_waiting_lock(lock, opd->opd_timeout);
1935 static void ost_prolong_locks(struct ost_prolong_data *data)
1937 struct obd_export *exp = data->opd_exp;
1938 struct obdo *oa = data->opd_oa;
1939 struct ldlm_lock *lock;
1942 if (oa->o_valid & OBD_MD_FLHANDLE) {
1943 /* mostly a request should be covered by only one lock, try
1945 lock = ldlm_handle2lock(&oa->o_handle);
1947 /* Fast path to check if the lock covers the whole IO
1948 * region exclusively. */
1949 if (lock->l_granted_mode == LCK_PW &&
1950 ldlm_extent_contain(&lock->l_policy_data.l_extent,
1951 &data->opd_extent)) {
1953 ost_prolong_lock_one(data, lock);
1954 LDLM_LOCK_PUT(lock);
1957 LDLM_LOCK_PUT(lock);
1962 spin_lock_bh(&exp->exp_bl_list_lock);
1963 cfs_list_for_each_entry(lock, &exp->exp_bl_list, l_exp_list) {
1964 LASSERT(lock->l_flags & LDLM_FL_AST_SENT);
1965 LASSERT(lock->l_resource->lr_type == LDLM_EXTENT);
1967 if (!ldlm_res_eq(&data->opd_resid, &lock->l_resource->lr_name))
1970 if (!ldlm_extent_overlap(&lock->l_policy_data.l_extent,
1974 ost_prolong_lock_one(data, lock);
1976 spin_unlock_bh(&exp->exp_bl_list_lock);
1982 * Returns 1 if the given PTLRPC matches the given LDLM locks, or 0 if it does
1985 static int ost_rw_hpreq_lock_match(struct ptlrpc_request *req,
1986 struct ldlm_lock *lock)
1988 struct niobuf_remote *nb;
1989 struct obd_ioobj *ioo;
1991 struct ldlm_extent ext;
1994 opc = lustre_msg_get_opc(req->rq_reqmsg);
1995 LASSERT(opc == OST_READ || opc == OST_WRITE);
1997 ioo = req_capsule_client_get(&req->rq_pill, &RMF_OBD_IOOBJ);
1998 LASSERT(ioo != NULL);
2000 nb = req_capsule_client_get(&req->rq_pill, &RMF_NIOBUF_REMOTE);
2001 LASSERT(nb != NULL);
2003 ext.start = nb->offset;
2004 nb += ioo->ioo_bufcnt - 1;
2005 ext.end = nb->offset + nb->len - 1;
2007 LASSERT(lock->l_resource != NULL);
2008 if (!ostid_res_name_eq(&ioo->ioo_oid, &lock->l_resource->lr_name))
2012 if (opc == OST_READ)
2014 if (!(lock->l_granted_mode & mode))
2017 RETURN(ldlm_extent_overlap(&lock->l_policy_data.l_extent, &ext));
2021 * High-priority queue request check for whether the given PTLRPC request (\a
2022 * req) is blocking an LDLM lock cancel.
2024 * Returns 1 if the given given PTLRPC request (\a req) is blocking an LDLM lock
2025 * cancel, 0 if it is not, and -EFAULT if the request is malformed.
2027 * Only OST_READs, OST_WRITEs and OST_PUNCHes go on the h-p RPC queue. This
2028 * function looks only at OST_READs and OST_WRITEs.
2030 static int ost_rw_hpreq_check(struct ptlrpc_request *req)
2032 struct obd_device *obd = req->rq_export->exp_obd;
2033 struct ost_body *body;
2034 struct obd_ioobj *ioo;
2035 struct niobuf_remote *nb;
2036 struct ost_prolong_data opd = { 0 };
2041 * Use LASSERT to do sanity check because malformed RPCs should have
2042 * been filtered out in ost_hpreq_handler().
2044 opc = lustre_msg_get_opc(req->rq_reqmsg);
2045 LASSERT(opc == OST_READ || opc == OST_WRITE);
2047 body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
2048 LASSERT(body != NULL);
2050 ioo = req_capsule_client_get(&req->rq_pill, &RMF_OBD_IOOBJ);
2051 LASSERT(ioo != NULL);
2053 nb = req_capsule_client_get(&req->rq_pill, &RMF_NIOBUF_REMOTE);
2054 LASSERT(nb != NULL);
2055 LASSERT(!(nb->flags & OBD_BRW_SRVLOCK));
2057 ostid_build_res_name(&ioo->ioo_oid, &opd.opd_resid);
2061 if (opc == OST_READ)
2063 opd.opd_mode = mode;
2064 opd.opd_exp = req->rq_export;
2065 opd.opd_oa = &body->oa;
2066 opd.opd_extent.start = nb->offset;
2067 nb += ioo->ioo_bufcnt - 1;
2068 opd.opd_extent.end = nb->offset + nb->len - 1;
2069 opd.opd_timeout = prolong_timeout(req);
2071 DEBUG_REQ(D_RPCTRACE, req,
2072 "%s %s: refresh rw locks: " LPU64"/"LPU64" ("LPU64"->"LPU64")\n",
2073 obd->obd_name, cfs_current()->comm,
2074 opd.opd_resid.name[0], opd.opd_resid.name[1],
2075 opd.opd_extent.start, opd.opd_extent.end);
2077 ost_prolong_locks(&opd);
2079 CDEBUG(D_DLMTRACE, "%s: refreshed %u locks timeout for req %p.\n",
2080 obd->obd_name, opd.opd_locks, req);
2082 RETURN(opd.opd_locks > 0);
2085 static void ost_rw_hpreq_fini(struct ptlrpc_request *req)
2087 (void)ost_rw_hpreq_check(req);
2091 * Like ost_rw_hpreq_lock_match(), but for OST_PUNCH RPCs.
2093 static int ost_punch_hpreq_lock_match(struct ptlrpc_request *req,
2094 struct ldlm_lock *lock)
2096 struct ost_body *body;
2099 body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
2100 LASSERT(body != NULL);
2102 if (body->oa.o_valid & OBD_MD_FLHANDLE &&
2103 body->oa.o_handle.cookie == lock->l_handle.h_cookie)
2110 * Like ost_rw_hpreq_check(), but for OST_PUNCH RPCs.
2112 static int ost_punch_hpreq_check(struct ptlrpc_request *req)
2114 struct obd_device *obd = req->rq_export->exp_obd;
2115 struct ost_body *body;
2117 struct ost_prolong_data opd = { 0 };
2121 body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
2122 LASSERT(body != NULL);
2125 LASSERT(!(oa->o_valid & OBD_MD_FLFLAGS) ||
2126 !(oa->o_flags & OBD_FL_SRVLOCK));
2129 end = start + oa->o_blocks;
2132 opd.opd_mode = LCK_PW;
2133 opd.opd_exp = req->rq_export;
2135 opd.opd_extent.start = start;
2136 opd.opd_extent.end = end;
2137 if (oa->o_blocks == OBD_OBJECT_EOF)
2138 opd.opd_extent.end = OBD_OBJECT_EOF;
2139 opd.opd_timeout = prolong_timeout(req);
2141 ostid_build_res_name(&oa->o_oi, &opd.opd_resid);
2144 "%s: refresh locks: "LPU64"/"LPU64" ("LPU64"->"LPU64")\n",
2146 opd.opd_resid.name[0], opd.opd_resid.name[1],
2147 opd.opd_extent.start, opd.opd_extent.end);
2149 ost_prolong_locks(&opd);
2151 CDEBUG(D_DLMTRACE, "%s: refreshed %u locks timeout for req %p.\n",
2152 obd->obd_name, opd.opd_locks, req);
2154 RETURN(opd.opd_locks > 0);
2157 static void ost_punch_hpreq_fini(struct ptlrpc_request *req)
2159 (void)ost_punch_hpreq_check(req);
2162 struct ptlrpc_hpreq_ops ost_hpreq_rw = {
2163 .hpreq_lock_match = ost_rw_hpreq_lock_match,
2164 .hpreq_check = ost_rw_hpreq_check,
2165 .hpreq_fini = ost_rw_hpreq_fini
2168 struct ptlrpc_hpreq_ops ost_hpreq_punch = {
2169 .hpreq_lock_match = ost_punch_hpreq_lock_match,
2170 .hpreq_check = ost_punch_hpreq_check,
2171 .hpreq_fini = ost_punch_hpreq_fini
2174 /** Assign high priority operations to the request if needed. */
2175 static int ost_io_hpreq_handler(struct ptlrpc_request *req)
2178 if (req->rq_export) {
2179 int opc = lustre_msg_get_opc(req->rq_reqmsg);
2180 struct ost_body *body;
2182 if (opc == OST_READ || opc == OST_WRITE) {
2183 struct niobuf_remote *nb;
2184 struct obd_ioobj *ioo;
2185 int objcount, niocount;
2189 /* RPCs on the H-P queue can be inspected before
2190 * ost_handler() initializes their pills, so we
2191 * initialize that here. Capsule initialization is
2192 * idempotent, as is setting the pill's format (provided
2193 * it doesn't change).
2195 req_capsule_init(&req->rq_pill, req, RCL_SERVER);
2196 if (opc == OST_READ)
2197 req_capsule_set(&req->rq_pill,
2200 req_capsule_set(&req->rq_pill,
2201 &RQF_OST_BRW_WRITE);
2203 body = req_capsule_client_get(&req->rq_pill,
2206 CERROR("Missing/short ost_body\n");
2210 objcount = req_capsule_get_size(&req->rq_pill,
2214 if (objcount == 0) {
2215 CERROR("Missing/short ioobj\n");
2219 CERROR("too many ioobjs (%d)\n", objcount);
2223 ioo = req_capsule_client_get(&req->rq_pill,
2226 CERROR("Missing/short ioobj\n");
2230 rc = ost_validate_obdo(req->rq_export, &body->oa, ioo);
2232 CERROR("invalid object ids\n");
2236 for (niocount = i = 0; i < objcount; i++) {
2237 if (ioo[i].ioo_bufcnt == 0) {
2238 CERROR("ioo[%d] has zero bufcnt\n", i);
2241 niocount += ioo[i].ioo_bufcnt;
2243 if (niocount > PTLRPC_MAX_BRW_PAGES) {
2244 DEBUG_REQ(D_RPCTRACE, req,
2245 "bulk has too many pages (%d)",
2250 nb = req_capsule_client_get(&req->rq_pill,
2251 &RMF_NIOBUF_REMOTE);
2253 CERROR("Missing/short niobuf\n");
2257 if (niocount == 0 || !(nb[0].flags & OBD_BRW_SRVLOCK))
2258 req->rq_ops = &ost_hpreq_rw;
2259 } else if (opc == OST_PUNCH) {
2260 req_capsule_init(&req->rq_pill, req, RCL_SERVER);
2261 req_capsule_set(&req->rq_pill, &RQF_OST_PUNCH);
2263 body = req_capsule_client_get(&req->rq_pill,
2266 CERROR("Missing/short ost_body\n");
2270 if (!(body->oa.o_valid & OBD_MD_FLFLAGS) ||
2271 !(body->oa.o_flags & OBD_FL_SRVLOCK))
2272 req->rq_ops = &ost_hpreq_punch;
2278 /* TODO: handle requests in a similar way as MDT: see mdt_handle_common() */
2279 int ost_handle(struct ptlrpc_request *req)
2281 struct obd_trans_info trans_info = { 0, };
2282 struct obd_trans_info *oti = &trans_info;
2283 int should_process, fail = OBD_FAIL_OST_ALL_REPLY_NET, rc = 0;
2284 struct obd_device *obd = NULL;
2285 __u32 opc = lustre_msg_get_opc(req->rq_reqmsg);
2288 /* OST module is kept between remounts, but the last reference
2289 * to specific module (say, osd or ofd) kills all related keys
2290 * from the environment. so we have to refill it until the root
2291 * cause is fixed properly */
2292 lu_env_refill(req->rq_svc_thread->t_env);
2294 LASSERT(current->journal_info == NULL);
2296 /* primordial rpcs don't affect server recovery */
2299 case SEC_CTX_INIT_CONT:
2304 req_capsule_init(&req->rq_pill, req, RCL_SERVER);
2306 if (opc != OST_CONNECT) {
2307 if (!class_connected_export(req->rq_export)) {
2308 CDEBUG(D_HA,"operation %d on unconnected OST from %s\n",
2309 opc, libcfs_id2str(req->rq_peer));
2310 req->rq_status = -ENOTCONN;
2311 GOTO(out, rc = -ENOTCONN);
2314 obd = req->rq_export->exp_obd;
2316 /* Check for aborted recovery. */
2317 if (obd->obd_recovering) {
2318 rc = ost_filter_recovery_request(req, obd,
2320 if (rc || !should_process)
2322 else if (should_process < 0) {
2323 req->rq_status = should_process;
2324 rc = ptlrpc_error(req);
2332 rc = ost_msg_check_version(req->rq_reqmsg);
2336 if (req && req->rq_reqmsg && req->rq_export &&
2337 (exp_connect_flags(req->rq_export) & OBD_CONNECT_JOBSTATS))
2338 oti->oti_jobid = lustre_msg_get_jobid(req->rq_reqmsg);
2342 CDEBUG(D_INODE, "connect\n");
2343 req_capsule_set(&req->rq_pill, &RQF_OST_CONNECT);
2344 if (OBD_FAIL_CHECK(OBD_FAIL_OST_CONNECT_NET))
2346 rc = target_handle_connect(req);
2347 if (OBD_FAIL_CHECK(OBD_FAIL_OST_CONNECT_NET2))
2350 rc = ost_init_sec_level(req);
2352 rc = ost_connect_check_sptlrpc(req);
2356 case OST_DISCONNECT:
2357 CDEBUG(D_INODE, "disconnect\n");
2358 req_capsule_set(&req->rq_pill, &RQF_OST_DISCONNECT);
2359 if (OBD_FAIL_CHECK(OBD_FAIL_OST_DISCONNECT_NET))
2361 rc = target_handle_disconnect(req);
2364 CDEBUG(D_INODE, "create\n");
2365 req_capsule_set(&req->rq_pill, &RQF_OST_CREATE);
2366 if (OBD_FAIL_CHECK(OBD_FAIL_OST_CREATE_NET))
2368 if (OBD_FAIL_CHECK(OBD_FAIL_OST_EROFS))
2369 GOTO(out, rc = -EROFS);
2370 rc = ost_create(req->rq_export, req, oti);
2373 CDEBUG(D_INODE, "destroy\n");
2374 req_capsule_set(&req->rq_pill, &RQF_OST_DESTROY);
2375 if (OBD_FAIL_CHECK(OBD_FAIL_OST_DESTROY_NET))
2377 if (OBD_FAIL_CHECK(OBD_FAIL_OST_EROFS))
2378 GOTO(out, rc = -EROFS);
2379 rc = ost_destroy(req->rq_export, req, oti);
2382 CDEBUG(D_INODE, "getattr\n");
2383 req_capsule_set(&req->rq_pill, &RQF_OST_GETATTR);
2384 if (OBD_FAIL_CHECK(OBD_FAIL_OST_GETATTR_NET))
2386 rc = ost_getattr(req->rq_export, req);
2389 CDEBUG(D_INODE, "setattr\n");
2390 req_capsule_set(&req->rq_pill, &RQF_OST_SETATTR);
2391 if (OBD_FAIL_CHECK(OBD_FAIL_OST_SETATTR_NET))
2393 rc = ost_setattr(req->rq_export, req, oti);
2396 req_capsule_set(&req->rq_pill, &RQF_OST_BRW_WRITE);
2397 CDEBUG(D_INODE, "write\n");
2398 /* req->rq_request_portal would be nice, if it was set */
2399 if (ptlrpc_req2svc(req)->srv_req_portal != OST_IO_PORTAL) {
2400 CERROR("%s: deny write request from %s to portal %u\n",
2401 req->rq_export->exp_obd->obd_name,
2402 obd_export_nid2str(req->rq_export),
2403 ptlrpc_req2svc(req)->srv_req_portal);
2404 GOTO(out, rc = -EPROTO);
2406 if (OBD_FAIL_CHECK(OBD_FAIL_OST_BRW_NET))
2408 if (OBD_FAIL_CHECK(OBD_FAIL_OST_ENOSPC))
2409 GOTO(out, rc = -ENOSPC);
2410 if (OBD_FAIL_TIMEOUT(OBD_FAIL_OST_EROFS, 1))
2411 GOTO(out, rc = -EROFS);
2412 rc = ost_brw_write(req, oti);
2413 LASSERT(current->journal_info == NULL);
2414 /* ost_brw_write sends its own replies */
2417 req_capsule_set(&req->rq_pill, &RQF_OST_BRW_READ);
2418 CDEBUG(D_INODE, "read\n");
2419 /* req->rq_request_portal would be nice, if it was set */
2420 if (ptlrpc_req2svc(req)->srv_req_portal != OST_IO_PORTAL) {
2421 CERROR("%s: deny read request from %s to portal %u\n",
2422 req->rq_export->exp_obd->obd_name,
2423 obd_export_nid2str(req->rq_export),
2424 ptlrpc_req2svc(req)->srv_req_portal);
2425 GOTO(out, rc = -EPROTO);
2427 if (OBD_FAIL_CHECK(OBD_FAIL_OST_BRW_NET))
2429 rc = ost_brw_read(req, oti);
2430 LASSERT(current->journal_info == NULL);
2431 /* ost_brw_read sends its own replies */
2434 CDEBUG(D_INODE, "punch\n");
2435 req_capsule_set(&req->rq_pill, &RQF_OST_PUNCH);
2436 if (OBD_FAIL_CHECK(OBD_FAIL_OST_PUNCH_NET))
2438 if (OBD_FAIL_CHECK(OBD_FAIL_OST_EROFS))
2439 GOTO(out, rc = -EROFS);
2440 rc = ost_punch(req->rq_export, req, oti);
2443 CDEBUG(D_INODE, "statfs\n");
2444 req_capsule_set(&req->rq_pill, &RQF_OST_STATFS);
2445 if (OBD_FAIL_CHECK(OBD_FAIL_OST_STATFS_NET))
2447 rc = ost_statfs(req);
2450 CDEBUG(D_INODE, "sync\n");
2451 req_capsule_set(&req->rq_pill, &RQF_OST_SYNC);
2452 if (OBD_FAIL_CHECK(OBD_FAIL_OST_SYNC_NET))
2454 rc = ost_sync(req->rq_export, req, oti);
2457 DEBUG_REQ(D_INODE, req, "set_info");
2458 req_capsule_set(&req->rq_pill, &RQF_OBD_SET_INFO);
2459 rc = ost_set_info(req->rq_export, req);
2462 DEBUG_REQ(D_INODE, req, "get_info");
2463 req_capsule_set(&req->rq_pill, &RQF_OST_GET_INFO_GENERIC);
2464 rc = ost_get_info(req->rq_export, req);
2467 CDEBUG(D_INODE, "seq\n");
2468 rc = seq_handle(req);
2470 case OST_QUOTACHECK:
2471 CDEBUG(D_INODE, "quotacheck\n");
2472 req_capsule_set(&req->rq_pill, &RQF_OST_QUOTACHECK);
2473 if (OBD_FAIL_CHECK(OBD_FAIL_OST_QUOTACHECK_NET))
2475 rc = ost_handle_quotacheck(req);
2478 CDEBUG(D_INODE, "quotactl\n");
2479 req_capsule_set(&req->rq_pill, &RQF_OST_QUOTACTL);
2480 if (OBD_FAIL_CHECK(OBD_FAIL_OST_QUOTACTL_NET))
2482 rc = ost_handle_quotactl(req);
2485 DEBUG_REQ(D_INODE, req, "ping");
2486 req_capsule_set(&req->rq_pill, &RQF_OBD_PING);
2487 rc = target_handle_ping(req);
2489 /* FIXME - just reply status */
2490 case LLOG_ORIGIN_CONNECT:
2491 DEBUG_REQ(D_INODE, req, "log connect");
2492 req_capsule_set(&req->rq_pill, &RQF_LLOG_ORIGIN_CONNECT);
2493 rc = ost_llog_handle_connect(req->rq_export, req);
2494 req->rq_status = rc;
2495 rc = req_capsule_server_pack(&req->rq_pill);
2498 RETURN(ptlrpc_reply(req));
2500 CDEBUG(D_INODE, "enqueue\n");
2501 req_capsule_set(&req->rq_pill, &RQF_LDLM_ENQUEUE);
2502 if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_ENQUEUE_NET))
2504 rc = ldlm_handle_enqueue(req, ldlm_server_completion_ast,
2506 ldlm_server_glimpse_ast);
2507 fail = OBD_FAIL_OST_LDLM_REPLY_NET;
2510 CDEBUG(D_INODE, "convert\n");
2511 req_capsule_set(&req->rq_pill, &RQF_LDLM_CONVERT);
2512 if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CONVERT_NET))
2514 rc = ldlm_handle_convert(req);
2517 CDEBUG(D_INODE, "cancel\n");
2518 req_capsule_set(&req->rq_pill, &RQF_LDLM_CANCEL);
2519 if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CANCEL_NET))
2521 rc = ldlm_handle_cancel(req);
2523 case LDLM_BL_CALLBACK:
2524 case LDLM_CP_CALLBACK:
2525 CDEBUG(D_INODE, "callback\n");
2526 CERROR("callbacks should not happen on OST\n");
2529 CERROR("Unexpected opcode %d\n", opc);
2530 req->rq_status = -ENOTSUPP;
2531 rc = ptlrpc_error(req);
2535 LASSERT(current->journal_info == NULL);
2538 /* If we're DISCONNECTing, the export_data is already freed */
2539 if (!rc && opc != OST_DISCONNECT)
2540 target_committed_to_req(req);
2544 oti_to_request(oti, req);
2546 target_send_reply(req, rc, fail);
2549 EXPORT_SYMBOL(ost_handle);
2552 * free per-thread pool created by ost_io_thread_init().
2554 static void ost_io_thread_done(struct ptlrpc_thread *thread)
2556 struct ost_thread_local_cache *tls; /* TLS stands for Thread-Local
2561 LASSERT(thread != NULL);
2564 * be prepared to handle partially-initialized pools (because this is
2565 * called from ost_io_thread_init() for cleanup.
2567 tls = thread->t_data;
2570 thread->t_data = NULL;
2576 * initialize per-thread page pool (bug 5137).
2578 static int ost_io_thread_init(struct ptlrpc_thread *thread)
2580 struct ost_thread_local_cache *tls;
2584 LASSERT(thread != NULL);
2585 LASSERT(thread->t_data == NULL);
2590 thread->t_data = tls;
2594 #define OST_WATCHDOG_TIMEOUT (obd_timeout * 1000)
2596 static struct cfs_cpt_table *ost_io_cptable;
2598 /* Sigh - really, this is an OSS, the _server_, not the _target_ */
2599 static int ost_setup(struct obd_device *obd, struct lustre_cfg* lcfg)
2601 static struct ptlrpc_service_conf svc_conf;
2602 struct ost_obd *ost = &obd->u.ost;
2603 struct lprocfs_static_vars lvars;
2608 rc = cfs_cleanup_group_info();
2612 lprocfs_ost_init_vars(&lvars);
2613 lprocfs_obd_setup(obd, lvars.obd_vars);
2615 mutex_init(&ost->ost_health_mutex);
2617 svc_conf = (typeof(svc_conf)) {
2618 .psc_name = LUSTRE_OSS_NAME,
2619 .psc_watchdog_factor = OSS_SERVICE_WATCHDOG_FACTOR,
2621 .bc_nbufs = OST_NBUFS,
2622 .bc_buf_size = OST_BUFSIZE,
2623 .bc_req_max_size = OST_MAXREQSIZE,
2624 .bc_rep_max_size = OST_MAXREPSIZE,
2625 .bc_req_portal = OST_REQUEST_PORTAL,
2626 .bc_rep_portal = OSC_REPLY_PORTAL,
2629 .tc_thr_name = "ll_ost",
2630 .tc_thr_factor = OSS_THR_FACTOR,
2631 .tc_nthrs_init = OSS_NTHRS_INIT,
2632 .tc_nthrs_base = OSS_NTHRS_BASE,
2633 .tc_nthrs_max = OSS_NTHRS_MAX,
2634 .tc_nthrs_user = oss_num_threads,
2635 .tc_cpu_affinity = 1,
2636 .tc_ctx_tags = LCT_DT_THREAD,
2639 .cc_pattern = oss_cpts,
2642 .so_req_handler = ost_handle,
2643 .so_req_printer = target_print_req,
2644 .so_hpreq_handler = ptlrpc_hpreq_handler,
2647 ost->ost_service = ptlrpc_register_service(&svc_conf,
2648 obd->obd_proc_entry);
2649 if (IS_ERR(ost->ost_service)) {
2650 rc = PTR_ERR(ost->ost_service);
2651 CERROR("failed to start service: %d\n", rc);
2652 GOTO(out_lprocfs, rc);
2655 memset(&svc_conf, 0, sizeof(svc_conf));
2656 svc_conf = (typeof(svc_conf)) {
2657 .psc_name = "ost_create",
2658 .psc_watchdog_factor = OSS_SERVICE_WATCHDOG_FACTOR,
2660 .bc_nbufs = OST_NBUFS,
2661 .bc_buf_size = OST_BUFSIZE,
2662 .bc_req_max_size = OST_MAXREQSIZE,
2663 .bc_rep_max_size = OST_MAXREPSIZE,
2664 .bc_req_portal = OST_CREATE_PORTAL,
2665 .bc_rep_portal = OSC_REPLY_PORTAL,
2668 .tc_thr_name = "ll_ost_create",
2669 .tc_thr_factor = OSS_CR_THR_FACTOR,
2670 .tc_nthrs_init = OSS_CR_NTHRS_INIT,
2671 .tc_nthrs_base = OSS_CR_NTHRS_BASE,
2672 .tc_nthrs_max = OSS_CR_NTHRS_MAX,
2673 .tc_nthrs_user = oss_num_create_threads,
2674 .tc_cpu_affinity = 1,
2675 .tc_ctx_tags = LCT_DT_THREAD,
2678 .cc_pattern = oss_cpts,
2681 .so_req_handler = ost_handle,
2682 .so_req_printer = target_print_req,
2685 ost->ost_create_service = ptlrpc_register_service(&svc_conf,
2686 obd->obd_proc_entry);
2687 if (IS_ERR(ost->ost_create_service)) {
2688 rc = PTR_ERR(ost->ost_create_service);
2689 CERROR("failed to start OST create service: %d\n", rc);
2690 GOTO(out_service, rc);
2693 mask = cfs_cpt_table->ctb_nodemask;
2694 /* event CPT feature is disabled in libcfs level by set partition
2695 * number to 1, we still want to set node affinity for io service */
2696 if (cfs_cpt_number(cfs_cpt_table) == 1 && nodes_weight(*mask) > 1) {
2700 ost_io_cptable = cfs_cpt_table_alloc(nodes_weight(*mask));
2701 for_each_node_mask(i, *mask) {
2702 if (ost_io_cptable == NULL) {
2703 CWARN("OSS failed to create CPT table\n");
2707 rc = cfs_cpt_set_node(ost_io_cptable, cpt++, i);
2709 CWARN("OSS Failed to set node %d for"
2710 "IO CPT table\n", i);
2711 cfs_cpt_table_free(ost_io_cptable);
2712 ost_io_cptable = NULL;
2718 memset(&svc_conf, 0, sizeof(svc_conf));
2719 svc_conf = (typeof(svc_conf)) {
2720 .psc_name = "ost_io",
2721 .psc_watchdog_factor = OSS_SERVICE_WATCHDOG_FACTOR,
2723 .bc_nbufs = OST_NBUFS,
2724 .bc_buf_size = OST_IO_BUFSIZE,
2725 .bc_req_max_size = OST_IO_MAXREQSIZE,
2726 .bc_rep_max_size = OST_IO_MAXREPSIZE,
2727 .bc_req_portal = OST_IO_PORTAL,
2728 .bc_rep_portal = OSC_REPLY_PORTAL,
2731 .tc_thr_name = "ll_ost_io",
2732 .tc_thr_factor = OSS_THR_FACTOR,
2733 .tc_nthrs_init = OSS_NTHRS_INIT,
2734 .tc_nthrs_base = OSS_NTHRS_BASE,
2735 .tc_nthrs_max = OSS_NTHRS_MAX,
2736 .tc_nthrs_user = oss_num_threads,
2737 .tc_cpu_affinity = 1,
2738 .tc_ctx_tags = LCT_DT_THREAD,
2741 .cc_cptable = ost_io_cptable,
2742 .cc_pattern = ost_io_cptable == NULL ?
2746 .so_thr_init = ost_io_thread_init,
2747 .so_thr_done = ost_io_thread_done,
2748 .so_req_handler = ost_handle,
2749 .so_hpreq_handler = ost_io_hpreq_handler,
2750 .so_req_printer = target_print_req,
2753 ost->ost_io_service = ptlrpc_register_service(&svc_conf,
2754 obd->obd_proc_entry);
2755 if (IS_ERR(ost->ost_io_service)) {
2756 rc = PTR_ERR(ost->ost_io_service);
2757 CERROR("failed to start OST I/O service: %d\n", rc);
2758 ost->ost_io_service = NULL;
2759 GOTO(out_create, rc);
2762 memset(&svc_conf, 0, sizeof(svc_conf));
2763 svc_conf = (typeof(svc_conf)) {
2764 .psc_name = "ost_seq",
2765 .psc_watchdog_factor = OSS_SERVICE_WATCHDOG_FACTOR,
2767 .bc_nbufs = OST_NBUFS,
2768 .bc_buf_size = OST_BUFSIZE,
2769 .bc_req_max_size = OST_MAXREQSIZE,
2770 .bc_rep_max_size = OST_MAXREPSIZE,
2771 .bc_req_portal = SEQ_DATA_PORTAL,
2772 .bc_rep_portal = OSC_REPLY_PORTAL,
2775 .tc_thr_name = "ll_ost_seq",
2776 .tc_thr_factor = OSS_CR_THR_FACTOR,
2777 .tc_nthrs_init = OSS_CR_NTHRS_INIT,
2778 .tc_nthrs_base = OSS_CR_NTHRS_BASE,
2779 .tc_nthrs_max = OSS_CR_NTHRS_MAX,
2780 .tc_nthrs_user = oss_num_create_threads,
2781 .tc_cpu_affinity = 1,
2782 .tc_ctx_tags = LCT_DT_THREAD,
2786 .cc_pattern = oss_cpts,
2789 .so_req_handler = ost_handle,
2790 .so_req_printer = target_print_req,
2791 .so_hpreq_handler = NULL,
2794 ost->ost_seq_service = ptlrpc_register_service(&svc_conf,
2795 obd->obd_proc_entry);
2796 if (IS_ERR(ost->ost_seq_service)) {
2797 rc = PTR_ERR(ost->ost_seq_service);
2798 CERROR("failed to start OST seq service: %d\n", rc);
2799 ost->ost_seq_service = NULL;
2803 ping_evictor_start();
2807 ptlrpc_unregister_service(ost->ost_io_service);
2808 ost->ost_io_service = NULL;
2810 ptlrpc_unregister_service(ost->ost_create_service);
2811 ost->ost_create_service = NULL;
2813 ptlrpc_unregister_service(ost->ost_service);
2814 ost->ost_service = NULL;
2816 lprocfs_obd_cleanup(obd);
2820 static int ost_cleanup(struct obd_device *obd)
2822 struct ost_obd *ost = &obd->u.ost;
2826 ping_evictor_stop();
2828 /* there is no recovery for OST OBD, all recovery is controlled by
2830 LASSERT(obd->obd_recovering == 0);
2831 mutex_lock(&ost->ost_health_mutex);
2832 ptlrpc_unregister_service(ost->ost_service);
2833 ptlrpc_unregister_service(ost->ost_create_service);
2834 ptlrpc_unregister_service(ost->ost_io_service);
2835 ptlrpc_unregister_service(ost->ost_seq_service);
2836 ost->ost_service = NULL;
2837 ost->ost_create_service = NULL;
2838 ost->ost_io_service = NULL;
2839 ost->ost_seq_service = NULL;
2841 mutex_unlock(&ost->ost_health_mutex);
2843 lprocfs_obd_cleanup(obd);
2845 if (ost_io_cptable != NULL) {
2846 cfs_cpt_table_free(ost_io_cptable);
2847 ost_io_cptable = NULL;
2853 static int ost_health_check(const struct lu_env *env, struct obd_device *obd)
2855 struct ost_obd *ost = &obd->u.ost;
2858 mutex_lock(&ost->ost_health_mutex);
2859 rc |= ptlrpc_service_health_check(ost->ost_service);
2860 rc |= ptlrpc_service_health_check(ost->ost_create_service);
2861 rc |= ptlrpc_service_health_check(ost->ost_io_service);
2862 mutex_unlock(&ost->ost_health_mutex);
2865 * health_check to return 0 on healthy
2866 * and 1 on unhealthy.
2874 struct ost_thread_local_cache *ost_tls(struct ptlrpc_request *r)
2876 return (struct ost_thread_local_cache *)(r->rq_svc_thread->t_data);
2879 /* use obd ops to offer management infrastructure */
2880 static struct obd_ops ost_obd_ops = {
2881 .o_owner = THIS_MODULE,
2882 .o_setup = ost_setup,
2883 .o_cleanup = ost_cleanup,
2884 .o_health_check = ost_health_check,
2888 static int __init ost_init(void)
2890 struct lprocfs_static_vars lvars;
2894 ost_page_to_corrupt = alloc_page(GFP_IOFS);
2896 lprocfs_ost_init_vars(&lvars);
2897 rc = class_register_type(&ost_obd_ops, NULL, lvars.module_vars,
2898 LUSTRE_OSS_NAME, NULL);
2900 if (ost_num_threads != 0 && oss_num_threads == 0) {
2901 LCONSOLE_INFO("ost_num_threads module parameter is deprecated, "
2902 "use oss_num_threads instead or unset both for "
2903 "dynamic thread startup\n");
2904 oss_num_threads = ost_num_threads;
2910 static void /*__exit*/ ost_exit(void)
2912 if (ost_page_to_corrupt)
2913 page_cache_release(ost_page_to_corrupt);
2915 class_unregister_type(LUSTRE_OSS_NAME);
2918 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
2919 MODULE_DESCRIPTION("Lustre Object Storage Target (OST) v0.01");
2920 MODULE_LICENSE("GPL");
2922 module_init(ost_init);
2923 module_exit(ost_exit);