Whamcloud - gitweb
LU-4629 utils: fix rsources leak
[fs/lustre-release.git] / lustre / utils / obdiolib.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
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.
9  *
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).
15  *
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
19  *
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
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  */
30 /*
31  * This file is part of Lustre, http://www.lustre.org/
32  * Lustre is a trademark of Sun Microsystems, Inc.
33  */
34
35 #ifndef _OBDIOLIB_H_
36 #define _OBDIOLIB_H_
37
38 #include <unistd.h>
39
40 #include <sys/types.h>
41 #include <sys/stat.h>
42
43 #include <lustre_lib.h>
44 #include <lustre/lustre_idl.h>
45 #include <obd_class.h>
46
47 struct obdio_conn {
48         int                    oc_fd;
49         __u32                  oc_device;
50         struct obd_ioctl_data  oc_data;
51         char                   oc_buffer[8192];
52 };
53
54 struct obdio_barrier {
55         __u64                  ob_id;
56         __u64                  ob_oid;
57         __u64                  ob_npeers;
58         __u64                  ob_ordinal;
59         __u64                  ob_count;
60 };
61
62 extern struct obdio_conn *obdio_connect(int device);
63 extern void obdio_disconnect(struct obdio_conn *conn, int flags);
64 extern int obdio_open(struct obdio_conn *conn, __u64 oid,
65                       struct lustre_handle *fh);
66 extern int obdio_close(struct obdio_conn *conn, __u64 oid,
67                        struct lustre_handle *fh);
68 extern int obdio_pread(struct obdio_conn *conn, __u64 oid,
69                        void *buffer, __u32 count, __u64 offset);
70 extern int obdio_pwrite(struct obdio_conn *conn, __u64 oid,
71                         void *buffer, __u32 count, __u64 offset);
72 extern int obdio_enqueue(struct obdio_conn *conn, __u64 oid,
73                          int mode, __u64 offset, __u32 count,
74                          struct lustre_handle *lh);
75 extern int obdio_cancel(struct obdio_conn *conn, struct lustre_handle *lh);
76 extern void *obdio_alloc_aligned_buffer(void **spacep, int size);
77 extern struct obdio_barrier *obdio_new_barrier(__u64 oid, __u64 id,
78                                                int npeers);
79 extern int obdio_setup_barrier(struct obdio_conn *conn,struct obdio_barrier *b);
80 extern int obdio_barrier(struct obdio_conn *conn, struct obdio_barrier *b);
81
82 #endif