1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copryright (C) 2001, 2002 Cluster File Systems, Inc.
6 * This code is issued under the GNU General Public License.
7 * See the file COPYING in this distribution
9 * Author Peter Braam <braam@clusterfs.com>
11 * This server is single threaded at present (but can easily be multi
12 * threaded). For testing and management it is treated as an
13 * obd_device, although it does not export a full OBD method table
14 * (the requests are coming in over the wire, so object target
15 * modules do not have a full method table.)
20 #define DEBUG_SUBSYSTEM S_OSC
22 #include <linux/module.h>
23 #include <linux/lustre_dlm.h>
24 #include <linux/lustre_mds.h> /* for mds_objid */
25 #include <linux/obd_ost.h>
26 #include <linux/obd_lov.h>
28 static void osc_con2cl(struct obd_conn *conn, struct ptlrpc_client **cl,
29 struct ptlrpc_connection **connection)
31 struct osc_obd *osc = &conn->oc_dev->u.osc;
32 *cl = osc->osc_client;
33 *connection = osc->osc_conn;
36 static void osc_con2dlmcl(struct obd_conn *conn, struct ptlrpc_client **cl,
37 struct ptlrpc_connection **connection)
39 struct osc_obd *osc = &conn->oc_dev->u.osc;
40 *cl = osc->osc_ldlm_client;
41 *connection = osc->osc_conn;
44 static int osc_connect(struct obd_conn *conn)
46 struct osc_obd *osc = &conn->oc_dev->u.osc;
47 struct ptlrpc_request *request;
48 struct ptlrpc_client *cl;
49 struct ptlrpc_connection *connection;
50 struct ost_body *body;
51 char *tmp = osc->osc_target_uuid;
52 int rc, size = sizeof(osc->osc_target_uuid);
55 osc_con2cl(conn, &cl, &connection);
56 request = ptlrpc_prep_req(cl, connection, OST_CONNECT, 1, &size, &tmp);
61 request->rq_replen = lustre_msg_size(1, &size);
63 rc = ptlrpc_queue_wait(request);
64 rc = ptlrpc_check_status(request, rc);
66 CERROR("%s failed: rc = %d\n", __FUNCTION__, rc);
70 body = lustre_msg_buf(request->rq_repmsg, 0);
71 CDEBUG(D_INODE, "received connid %d\n", body->connid);
73 /* This might be redundant. */
74 cl->cli_target_devno = request->rq_repmsg->target_id;
75 osc->osc_ldlm_client->cli_target_devno = cl->cli_target_devno;
76 /* XXX: Make this a handle */
77 conn->oc_id = body->connid;
80 ptlrpc_free_req(request);
84 static int osc_disconnect(struct obd_conn *conn)
86 struct ptlrpc_request *request;
87 struct ptlrpc_client *cl;
88 struct ptlrpc_connection *connection;
89 struct ost_body *body;
90 int rc, size = sizeof(*body);
93 osc_con2cl(conn, &cl, &connection);
94 request = ptlrpc_prep_req(cl, connection, OST_DISCONNECT, 1, &size,
99 body = lustre_msg_buf(request->rq_reqmsg, 0);
100 body->connid = conn->oc_id;
102 request->rq_replen = lustre_msg_size(0, NULL);
104 rc = ptlrpc_queue_wait(request);
107 ptlrpc_free_req(request);
111 static int osc_getattr(struct obd_conn *conn, struct obdo *oa)
113 struct ptlrpc_request *request;
114 struct ptlrpc_client *cl;
115 struct ptlrpc_connection *connection;
116 struct ost_body *body;
117 int rc, size = sizeof(*body);
120 osc_con2cl(conn, &cl, &connection);
121 request = ptlrpc_prep_req(cl, connection, OST_GETATTR, 1, &size, NULL);
125 body = lustre_msg_buf(request->rq_reqmsg, 0);
126 memcpy(&body->oa, oa, sizeof(*oa));
127 body->connid = conn->oc_id;
128 body->oa.o_valid = ~0;
130 request->rq_replen = lustre_msg_size(1, &size);
132 rc = ptlrpc_queue_wait(request);
133 rc = ptlrpc_check_status(request, rc);
135 CERROR("%s failed: rc = %d\n", __FUNCTION__, rc);
139 body = lustre_msg_buf(request->rq_repmsg, 0);
140 CDEBUG(D_INODE, "mode: %o\n", body->oa.o_mode);
142 memcpy(oa, &body->oa, sizeof(*oa));
146 ptlrpc_free_req(request);
150 static int osc_open(struct obd_conn *conn, struct obdo *oa)
152 struct ptlrpc_request *request;
153 struct ptlrpc_client *cl;
154 struct ptlrpc_connection *connection;
155 struct ost_body *body;
156 int rc, size = sizeof(*body);
159 osc_con2cl(conn, &cl, &connection);
160 request = ptlrpc_prep_req(cl, connection, OST_OPEN, 1, &size, NULL);
164 body = lustre_msg_buf(request->rq_reqmsg, 0);
165 memcpy(&body->oa, oa, sizeof(*oa));
166 body->connid = conn->oc_id;
167 body->oa.o_valid = (OBD_MD_FLMODE | OBD_MD_FLID);
169 request->rq_replen = lustre_msg_size(1, &size);
171 rc = ptlrpc_queue_wait(request);
172 rc = ptlrpc_check_status(request, rc);
176 body = lustre_msg_buf(request->rq_repmsg, 0);
177 CDEBUG(D_INODE, "mode: %o\n", body->oa.o_mode);
179 memcpy(oa, &body->oa, sizeof(*oa));
183 ptlrpc_free_req(request);
187 static int osc_close(struct obd_conn *conn, struct obdo *oa)
189 struct ptlrpc_request *request;
190 struct ptlrpc_client *cl;
191 struct ptlrpc_connection *connection;
192 struct ost_body *body;
193 int rc, size = sizeof(*body);
196 osc_con2cl(conn, &cl, &connection);
197 request = ptlrpc_prep_req(cl, connection, OST_CLOSE, 1, &size, NULL);
201 body = lustre_msg_buf(request->rq_reqmsg, 0);
202 memcpy(&body->oa, oa, sizeof(*oa));
203 body->connid = conn->oc_id;
205 request->rq_replen = lustre_msg_size(1, &size);
207 rc = ptlrpc_queue_wait(request);
208 rc = ptlrpc_check_status(request, rc);
212 body = lustre_msg_buf(request->rq_repmsg, 0);
213 CDEBUG(D_INODE, "mode: %o\n", body->oa.o_mode);
215 memcpy(oa, &body->oa, sizeof(*oa));
219 ptlrpc_free_req(request);
223 static int osc_setattr(struct obd_conn *conn, struct obdo *oa)
225 struct ptlrpc_request *request;
226 struct ptlrpc_client *cl;
227 struct ptlrpc_connection *connection;
228 struct ost_body *body;
229 int rc, size = sizeof(*body);
232 osc_con2cl(conn, &cl, &connection);
233 request = ptlrpc_prep_req(cl, connection, OST_SETATTR, 1, &size, NULL);
237 body = lustre_msg_buf(request->rq_reqmsg, 0);
238 memcpy(&body->oa, oa, sizeof(*oa));
239 body->connid = conn->oc_id;
241 request->rq_replen = lustre_msg_size(1, &size);
243 rc = ptlrpc_queue_wait(request);
244 rc = ptlrpc_check_status(request, rc);
248 ptlrpc_free_req(request);
252 static int osc_create(struct obd_conn *conn, struct obdo *oa)
254 struct ptlrpc_request *request;
255 struct ptlrpc_client *cl;
256 struct ptlrpc_connection *connection;
257 struct ost_body *body;
258 struct mds_objid *objid;
259 struct lov_object_id *lov_id;
260 int rc, size = sizeof(*body);
267 osc_con2cl(conn, &cl, &connection);
268 request = ptlrpc_prep_req(cl, connection, OST_CREATE, 1, &size, NULL);
272 body = lustre_msg_buf(request->rq_reqmsg, 0);
273 memcpy(&body->oa, oa, sizeof(*oa));
274 body->connid = conn->oc_id;
276 request->rq_replen = lustre_msg_size(1, &size);
278 rc = ptlrpc_queue_wait(request);
279 rc = ptlrpc_check_status(request, rc);
283 body = lustre_msg_buf(request->rq_repmsg, 0);
284 memcpy(oa, &body->oa, sizeof(*oa));
286 memset(oa->o_inline, 0, sizeof(oa->o_inline));
287 objid = (struct mds_objid *)oa->o_inline;
288 objid->mo_lov_md.lmd_object_id = oa->o_id;
289 objid->mo_lov_md.lmd_stripe_count = 1;
290 lov_id = (struct lov_object_id *)(oa->o_inline + sizeof(*objid));
291 lov_id->l_device_id = 0;
292 lov_id->l_object_id = oa->o_id;
296 ptlrpc_free_req(request);
300 static int osc_punch(struct obd_conn *conn, struct obdo *oa, obd_size count,
303 struct ptlrpc_request *request;
304 struct ptlrpc_client *cl;
305 struct ptlrpc_connection *connection;
306 struct ost_body *body;
307 int rc, size = sizeof(*body);
314 osc_con2cl(conn, &cl, &connection);
315 request = ptlrpc_prep_req(cl, connection, OST_PUNCH, 1, &size, NULL);
319 body = lustre_msg_buf(request->rq_reqmsg, 0);
320 memcpy(&body->oa, oa, sizeof(*oa));
321 body->connid = conn->oc_id;
322 body->oa.o_blocks = count;
323 body->oa.o_valid |= OBD_MD_FLBLOCKS;
325 request->rq_replen = lustre_msg_size(1, &size);
327 rc = ptlrpc_queue_wait(request);
328 rc = ptlrpc_check_status(request, rc);
332 body = lustre_msg_buf(request->rq_repmsg, 0);
333 memcpy(oa, &body->oa, sizeof(*oa));
337 ptlrpc_free_req(request);
341 static int osc_destroy(struct obd_conn *conn, struct obdo *oa)
343 struct ptlrpc_request *request;
344 struct ptlrpc_client *cl;
345 struct ptlrpc_connection *connection;
346 struct ost_body *body;
347 int rc, size = sizeof(*body);
354 osc_con2cl(conn, &cl, &connection);
355 request = ptlrpc_prep_req(cl, connection, OST_DESTROY, 1, &size, NULL);
359 body = lustre_msg_buf(request->rq_reqmsg, 0);
360 memcpy(&body->oa, oa, sizeof(*oa));
361 body->connid = conn->oc_id;
362 body->oa.o_valid = ~0;
364 request->rq_replen = lustre_msg_size(1, &size);
366 rc = ptlrpc_queue_wait(request);
367 rc = ptlrpc_check_status(request, rc);
371 body = lustre_msg_buf(request->rq_repmsg, 0);
372 memcpy(oa, &body->oa, sizeof(*oa));
376 ptlrpc_free_req(request);
380 struct osc_brw_cb_data {
382 struct ptlrpc_request *req;
383 bulk_callback_t callback;
387 static void brw_read_finish(struct ptlrpc_bulk_desc *desc, void *data)
389 struct osc_brw_cb_data *cb_data = data;
391 if (desc->b_flags & PTL_RPC_FL_INTR)
392 CERROR("got signal\n");
394 (cb_data->callback)(desc, cb_data->cb_data);
396 ptlrpc_free_bulk(desc);
397 ptlrpc_free_req(cb_data->req);
399 OBD_FREE(cb_data, sizeof(*cb_data));
402 static int osc_brw_read(struct obd_conn *conn, obd_count num_oa,
403 struct obdo **oa, obd_count *oa_bufs, struct page **buf,
404 obd_size *count, obd_off *offset, obd_flag *flags,
405 bulk_callback_t callback)
407 struct ptlrpc_client *cl;
408 struct ptlrpc_connection *connection;
409 struct ptlrpc_request *request;
410 struct ost_body *body;
411 struct list_head *tmp;
412 int pages, rc, i, j, size[3] = {sizeof(*body)};
414 struct ptlrpc_bulk_desc *desc;
417 size[1] = num_oa * sizeof(struct obd_ioobj);
419 for (i = 0; i < num_oa; i++)
421 size[2] = pages * sizeof(struct niobuf_remote);
423 osc_con2cl(conn, &cl, &connection);
424 request = ptlrpc_prep_req(cl, connection, OST_BRW, 3, size, NULL);
426 GOTO(out, rc = -ENOMEM);
428 body = lustre_msg_buf(request->rq_reqmsg, 0);
429 body->data = OBD_BRW_READ;
431 desc = ptlrpc_prep_bulk(connection);
433 GOTO(out2, rc = -ENOMEM);
434 desc->b_portal = OST_BULK_PORTAL;
436 ptr1 = lustre_msg_buf(request->rq_reqmsg, 1);
437 ptr2 = lustre_msg_buf(request->rq_reqmsg, 2);
438 for (pages = 0, i = 0; i < num_oa; i++) {
439 ost_pack_ioo(&ptr1, oa[i], oa_bufs[i]);
440 /* FIXME: this inner loop is wrong for multiple OAs */
441 for (j = 0; j < oa_bufs[i]; j++, pages++) {
442 struct ptlrpc_bulk_page *bulk;
443 bulk = ptlrpc_prep_bulk_page(desc);
445 GOTO(out3, rc = -ENOMEM);
447 spin_lock(&connection->c_lock);
448 bulk->b_xid = ++connection->c_xid_out;
449 spin_unlock(&connection->c_lock);
451 bulk->b_buf = kmap(buf[pages]);
452 bulk->b_page = buf[pages];
453 bulk->b_buflen = PAGE_SIZE;
454 ost_pack_niobuf(&ptr2, offset[pages], count[pages],
455 flags[pages], bulk->b_xid);
459 rc = ptlrpc_register_bulk(desc);
463 request->rq_replen = lustre_msg_size(1, size);
464 rc = ptlrpc_queue_wait(request);
465 rc = ptlrpc_check_status(request, rc);
467 ptlrpc_abort_bulk(desc);
471 list_for_each(tmp, &desc->b_page_list) {
472 struct ptlrpc_bulk_page *bulk;
473 bulk = list_entry(tmp, struct ptlrpc_bulk_page, b_link);
474 if (bulk->b_page != NULL)
475 kunmap(bulk->b_page);
477 ptlrpc_free_bulk(desc);
479 ptlrpc_free_req(request);
484 static void brw_write_finish(struct ptlrpc_bulk_desc *desc, void *data)
486 struct osc_brw_cb_data *cb_data = data;
490 if (desc->b_flags & PTL_RPC_FL_INTR)
491 CERROR("got signal\n");
493 for (i = 0; i < desc->b_page_count; i++)
494 kunmap(cb_data->buf[i]);
496 (cb_data->callback)(desc, cb_data->cb_data);
498 ptlrpc_free_bulk(desc);
499 ptlrpc_free_req(cb_data->req);
501 OBD_FREE(cb_data, sizeof(*cb_data));
505 static int osc_brw_write(struct obd_conn *conn, obd_count num_oa,
506 struct obdo **oa, obd_count *oa_bufs,
507 struct page **pagearray, obd_size *count,
508 obd_off *offset, obd_flag *flags,
509 bulk_callback_t callback)
511 struct ptlrpc_client *cl;
512 struct ptlrpc_connection *connection;
513 struct ptlrpc_request *request;
514 struct ptlrpc_bulk_desc *desc;
515 struct obd_ioobj ioo;
516 struct ost_body *body;
517 struct niobuf_local *local;
518 struct niobuf_remote *remote;
519 struct osc_brw_cb_data *cb_data;
521 int rc, i, j, size[3] = {sizeof(*body)};
525 size[1] = num_oa * sizeof(ioo);
527 for (i = 0; i < num_oa; i++)
529 size[2] = pages * sizeof(*remote);
531 OBD_ALLOC(local, pages * sizeof(*local));
535 osc_con2cl(conn, &cl, &connection);
536 request = ptlrpc_prep_req(cl, connection, OST_BRW, 3, size, NULL);
538 GOTO(out, rc = -ENOMEM);
539 body = lustre_msg_buf(request->rq_reqmsg, 0);
540 body->data = OBD_BRW_WRITE;
542 ptr1 = lustre_msg_buf(request->rq_reqmsg, 1);
543 ptr2 = lustre_msg_buf(request->rq_reqmsg, 2);
544 for (pages = 0, i = 0; i < num_oa; i++) {
545 ost_pack_ioo(&ptr1, oa[i], oa_bufs[i]);
546 for (j = 0; j < oa_bufs[i]; j++, pages++) {
547 local[pages].addr = kmap(pagearray[pages]);
548 local[pages].offset = offset[pages];
549 local[pages].len = count[pages];
550 ost_pack_niobuf(&ptr2, offset[pages], count[pages],
555 size[1] = pages * sizeof(struct niobuf_remote);
556 request->rq_replen = lustre_msg_size(2, size);
558 rc = ptlrpc_queue_wait(request);
559 rc = ptlrpc_check_status(request, rc);
563 ptr2 = lustre_msg_buf(request->rq_repmsg, 1);
565 GOTO(out2, rc = -EINVAL);
567 if (request->rq_repmsg->buflens[1] !=
568 pages * sizeof(struct niobuf_remote)) {
569 CERROR("buffer length wrong (%d vs. %ld)\n",
570 request->rq_repmsg->buflens[1],
571 pages * sizeof(struct niobuf_remote));
572 GOTO(out2, rc = -EINVAL);
575 desc = ptlrpc_prep_bulk(connection);
576 desc->b_portal = OSC_BULK_PORTAL;
578 desc->b_cb = brw_write_finish;
579 OBD_ALLOC(cb_data, sizeof(*cb_data));
580 cb_data->buf = pagearray;
581 cb_data->callback = callback;
582 desc->b_cb_data = cb_data;
585 for (pages = 0, i = 0; i < num_oa; i++) {
586 for (j = 0; j < oa_bufs[i]; j++, pages++) {
587 struct ptlrpc_bulk_page *page;
589 ost_unpack_niobuf(&ptr2, &remote);
591 page = ptlrpc_prep_bulk_page(desc);
593 GOTO(out3, rc = -ENOMEM);
595 page->b_buf = (void *)(unsigned long)local[pages].addr;
596 page->b_buflen = local[pages].len;
597 page->b_xid = remote->xid;
601 if (desc->b_page_count != pages)
604 rc = ptlrpc_send_bulk(desc);
610 /* If there's no callback function, sleep here until complete. */
611 wait_event_interruptible(desc->b_waitq, ptlrpc_check_bulk_sent(desc));
612 if (desc->b_flags & PTL_RPC_FL_INTR)
618 ptlrpc_free_bulk(desc);
620 ptlrpc_free_req(request);
621 for (pages = 0, i = 0; i < num_oa; i++)
622 for (j = 0; j < oa_bufs[i]; j++, pages++)
623 kunmap(pagearray[pages]);
625 OBD_FREE(local, pages * sizeof(*local));
630 static int osc_brw(int cmd, struct obd_conn *conn, obd_count num_oa,
631 struct obdo **oa, obd_count *oa_bufs, struct page **buf,
632 obd_size *count, obd_off *offset, obd_flag *flags,
638 if (cmd & OBD_BRW_WRITE)
639 return osc_brw_write(conn, num_oa, oa, oa_bufs, buf, count,
640 offset, flags, (bulk_callback_t)callback);
642 return osc_brw_read(conn, num_oa, oa, oa_bufs, buf, count,
643 offset, flags, (bulk_callback_t)callback);
646 static int osc_enqueue(struct obd_conn *oconn,
647 struct lustre_handle *parent_lock, __u64 *res_id,
648 __u32 type, void *extentp, int extent_len, __u32 mode,
649 int *flags, void *callback, void *data, int datalen,
650 struct lustre_handle *lockh)
652 struct obd_device *obddev = oconn->oc_dev;
653 struct ptlrpc_connection *conn;
654 struct ptlrpc_client *cl;
655 struct ldlm_extent *extent = extentp;
659 /* Filesystem locks are given a bit of special treatment: first we
660 * fixup the lock to start and end on page boundaries. */
661 extent->start &= PAGE_MASK;
662 extent->end = (extent->end + PAGE_SIZE - 1) & PAGE_MASK;
664 /* Next, search for already existing extent locks that will cover us */
665 osc_con2dlmcl(oconn, &cl, &conn);
666 rc = ldlm_lock_match(obddev->obd_namespace, res_id, type, extent,
667 sizeof(extent), mode, lockh);
669 /* We already have a lock, and it's referenced */
673 /* Next, search for locks that we can upgrade (if we're trying to write)
674 * or are more than we need (if we're trying to read). Because the VFS
675 * and page cache already protect us locally, lots of readers/writers
676 * can share a single PW lock. */
682 rc = ldlm_lock_match(obddev->obd_namespace, res_id, type, extent,
683 sizeof(extent), mode2, lockh);
686 struct ldlm_lock *lock = lustre_handle2object(lockh);
687 /* FIXME: This is not incredibly elegant, but it might
688 * be more elegant than adding another parameter to
689 * lock_match. I want a second opinion. */
690 ldlm_lock_addref(lock, mode);
691 ldlm_lock_decref(lock, mode2);
696 rc = ldlm_cli_convert(cl, lockh, mode, &flags);
703 rc = ldlm_cli_enqueue(cl, conn, NULL, obddev->obd_namespace,
704 parent_lock, res_id, type, extent, sizeof(extent),
705 mode, flags, callback, data, datalen, lockh);
709 static int osc_cancel(struct obd_conn *oconn, __u32 mode,
710 struct lustre_handle *lockh)
712 struct ldlm_lock *lock;
715 lock = lustre_handle2object(lockh);
716 ldlm_lock_decref(lock, mode);
721 static int osc_setup(struct obd_device *obddev, obd_count len, void *buf)
723 struct obd_ioctl_data* data = buf;
724 struct osc_obd *osc = &obddev->u.osc;
725 char server_uuid[37];
729 if (data->ioc_inllen1 < 1) {
730 CERROR("osc setup requires a TARGET UUID\n");
734 if (data->ioc_inllen1 > 37) {
735 CERROR("osc TARGET UUID must be less than 38 characters\n");
739 if (data->ioc_inllen2 < 1) {
740 CERROR("osc setup requires a SERVER UUID\n");
744 if (data->ioc_inllen2 > 37) {
745 CERROR("osc SERVER UUID must be less than 38 characters\n");
749 memcpy(osc->osc_target_uuid, data->ioc_inlbuf1, data->ioc_inllen1);
750 memcpy(server_uuid, data->ioc_inlbuf2, MIN(data->ioc_inllen2,
751 sizeof(server_uuid)));
753 osc->osc_conn = ptlrpc_uuid_to_connection(server_uuid);
757 obddev->obd_namespace =
758 ldlm_namespace_new("osc", LDLM_NAMESPACE_CLIENT);
759 if (obddev->obd_namespace == NULL)
760 GOTO(out_conn, rc = -ENOMEM);
762 OBD_ALLOC(osc->osc_client, sizeof(*osc->osc_client));
763 if (osc->osc_client == NULL)
764 GOTO(out_ns, rc = -ENOMEM);
766 OBD_ALLOC(osc->osc_ldlm_client, sizeof(*osc->osc_ldlm_client));
767 if (osc->osc_ldlm_client == NULL)
768 GOTO(out_client, rc = -ENOMEM);
770 ptlrpc_init_client(NULL, NULL, OST_REQUEST_PORTAL, OSC_REPLY_PORTAL,
772 ptlrpc_init_client(NULL, NULL, LDLM_REQUEST_PORTAL, LDLM_REPLY_PORTAL,
773 osc->osc_ldlm_client);
774 osc->osc_client->cli_name = "osc";
775 osc->osc_ldlm_client->cli_name = "ldlm";
781 OBD_FREE(osc->osc_client, sizeof(*osc->osc_client));
783 ldlm_namespace_free(obddev->obd_namespace);
785 ptlrpc_put_connection(osc->osc_conn);
789 static int osc_cleanup(struct obd_device * obddev)
791 struct osc_obd *osc = &obddev->u.osc;
793 ldlm_namespace_free(obddev->obd_namespace);
795 ptlrpc_cleanup_client(osc->osc_client);
796 OBD_FREE(osc->osc_client, sizeof(*osc->osc_client));
797 ptlrpc_cleanup_client(osc->osc_ldlm_client);
798 OBD_FREE(osc->osc_ldlm_client, sizeof(*osc->osc_ldlm_client));
799 ptlrpc_put_connection(osc->osc_conn);
806 static int osc_statfs(struct obd_conn *conn, struct statfs *sfs);
808 struct ptlrpc_request *request;
809 struct ptlrpc_client *cl;
810 struct ptlrpc_connection *connection;
811 struct obd_statfs *osfs;
812 int rc, size = sizeof(*osfs);
815 osc_con2cl(conn, &cl, &connection);
816 request = ptlrpc_prep_req(cl, connection, OST_STATFS, 0, NULL, NULL);
820 request->rq_replen = lustre_msg_size(1, &size);
822 rc = ptlrpc_queue_wait(request);
823 rc = ptlrpc_check_status(request, rc);
827 osfs = lustre_msg_buf(request->rq_repmsg, 0);
828 obd_statfs_unpack(sfs, osfs);
832 ptlrpc_free_req(request);
837 struct obd_ops osc_obd_ops = {
839 o_cleanup: osc_cleanup,
840 o_create: osc_create,
841 o_destroy: osc_destroy,
842 o_getattr: osc_getattr,
843 o_setattr: osc_setattr,
846 o_connect: osc_connect,
847 o_disconnect: osc_disconnect,
850 o_enqueue: osc_enqueue,
854 static int __init osc_init(void)
856 return obd_register_type(&osc_obd_ops, LUSTRE_OSC_NAME);
859 static void __exit osc_exit(void)
861 obd_unregister_type(LUSTRE_OSC_NAME);
864 MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
865 MODULE_DESCRIPTION("Lustre Object Storage Client (OSC) v1.0");
866 MODULE_LICENSE("GPL");
868 module_init(osc_init);
869 module_exit(osc_exit);