1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
5 * Author: Peter J. Braam <braam@clusterfs.com>
6 * Author: Phil Schwan <phil@clusterfs.com>
8 * This file is part of Lustre, http://www.lustre.org.
10 * Lustre is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
14 * Lustre is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with Lustre; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * Storage Target Handling functions
24 * Lustre Object Server Module (OST)
26 * This server is single threaded at present (but can easily be multi
27 * threaded). For testing and management it is treated as an
28 * obd_device, although it does not export a full OBD method table
29 * (the requests are coming in over the wire, so object target
30 * modules do not have a full method table.)
34 #define DEBUG_SUBSYSTEM S_OST
36 #include <linux/module.h>
37 #include <linux/obd_ost.h>
38 #include <linux/lustre_net.h>
39 #include <linux/lustre_dlm.h>
42 int target_handle_connect(struct ptlrpc_request *req)
44 struct obd_device *target;
45 struct obd_export *export;
51 uuid = lustre_msg_buf(req->rq_reqmsg, 0);
52 if (req->rq_reqmsg->buflens[0] > 37) {
54 req->rq_status = -EINVAL;
58 i = obd_class_uuid2dev(uuid);
60 req->rq_status = -ENODEV;
66 req->rq_status = -ENODEV;
70 conn.addr = req->rq_reqmsg->addr;
71 conn.cookie = req->rq_reqmsg->cookie;
73 rc = lustre_pack_msg(0, NULL, NULL, &req->rq_replen, &req->rq_repmsg);
77 req->rq_status = obd_connect(&conn, target);
78 req->rq_repmsg->addr = conn.addr;
79 req->rq_repmsg->cookie = conn.cookie;
81 export = gen_client(&conn);
85 req->rq_export = export;
86 export->export_connection = req->rq_connection;
91 int target_handle_disconnect(struct ptlrpc_request *req)
93 struct obd_conn *conn = (struct obd_conn *)req->rq_reqmsg;
97 rc = lustre_pack_msg(0, NULL, NULL, &req->rq_replen, &req->rq_repmsg);
101 req->rq_status = obd_disconnect(conn);