Whamcloud - gitweb
merge b_devel into HEAD (20030703)
[fs/lustre-release.git] / lustre / include / linux / lustre_idl.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  * (Un)packing of OST requests
22  *
23  * We assume all nodes are either little-endian or big-endian, and we
24  * always send messages in the sender's native format.  The receiver
25  * detects the message format by checking the 'magic' field of the message
26  * (see lustre_msg_swabbed() below).
27  *
28  * Each wire type has corresponding 'lustre_swab_xxxtypexxx()' routines,
29  * implemented either here, inline (trivial implementations) or in
30  * ptlrpc/pack_generic.c.  These 'swabbers' convert the type from "other"
31  * endian, in-place in the message buffer.
32  * 
33  * A swabber takes a single pointer argument.  The caller must already have
34  * verified that the length of the message buffer >= sizeof (type).  
35  *
36  * For variable length types, a second 'lustre_swab_v_xxxtypexxx()' routine
37  * may be defined that swabs just the variable part, after the caller has
38  * verified that the message buffer is large enough.
39  */
40
41 #ifndef _LUSTRE_IDL_H_
42 #define _LUSTRE_IDL_H_
43
44 #ifdef __KERNEL__
45 # include <linux/ioctl.h>
46 # include <asm/types.h>
47 # include <linux/types.h>
48 # include <linux/list.h>
49 # include <linux/string.h> /* for strncpy, below */
50 # include <asm/byteorder.h>
51 #else
52 #ifdef __CYGWIN__
53 # include <sys/types.h>
54 #else
55 # include <asm/types.h>
56 # include <stdint.h>
57 #endif
58 # include <portals/list.h>
59 #endif
60 /*
61  * this file contains all data structures used in Lustre interfaces:
62  * - obdo and obd_request records
63  * - mds_request records
64  * - ldlm data
65  * - ioctl's
66  */
67
68 /*
69  *  GENERAL STUFF
70  */
71 struct obd_uuid {
72         __u8 uuid[37];
73 };
74
75 static inline int obd_uuid_equals(struct obd_uuid *u1, struct obd_uuid *u2)
76 {
77         return strcmp(u1->uuid, u2->uuid) == 0;
78 }
79
80 static inline void obd_str2uuid(struct obd_uuid *uuid, char *tmp)
81 {
82         strncpy(uuid->uuid, tmp, sizeof(*uuid));
83         uuid->uuid[sizeof(*uuid) - 1] = '\0';
84 }
85
86 extern struct obd_uuid lctl_fake_uuid;
87
88 /* FOO_REQUEST_PORTAL is for incoming requests on the FOO
89  * FOO_REPLY_PORTAL   is for incoming replies on the FOO
90  * FOO_BULK_PORTAL    is for incoming bulk on the FOO
91  */
92
93 #define CONNMGR_REQUEST_PORTAL  1
94 #define CONNMGR_REPLY_PORTAL    2
95 //#define OSC_REQUEST_PORTAL      3
96 #define OSC_REPLY_PORTAL        4
97 //#define OSC_BULK_PORTAL         5
98 #define OST_REQUEST_PORTAL      6
99 //#define OST_REPLY_PORTAL        7
100 #define OST_BULK_PORTAL         8
101 //#define MDC_REQUEST_PORTAL      9
102 #define MDC_REPLY_PORTAL        10
103 //#define MDC_BULK_PORTAL         11
104 #define MDS_REQUEST_PORTAL      12
105 //#define MDS_REPLY_PORTAL        13
106 #define MDS_BULK_PORTAL         14
107 #define LDLM_CB_REQUEST_PORTAL     15
108 #define LDLM_CB_REPLY_PORTAL       16
109 #define LDLM_CANCEL_REQUEST_PORTAL     17
110 #define LDLM_CANCEL_REPLY_PORTAL       18
111 #define PTLBD_REQUEST_PORTAL           19
112 #define PTLBD_REPLY_PORTAL             20
113 #define PTLBD_BULK_PORTAL              21
114 #define MDS_SETATTR_PORTAL      22
115 #define MDS_READPAGE_PORTAL     23
116
117 #define SVC_KILLED               1
118 #define SVC_EVENT                2
119 #define SVC_SIGNAL               4
120 #define SVC_RUNNING              8
121 #define SVC_STOPPING            16
122 #define SVC_STOPPED             32
123
124 #define LUSTRE_CONN_NEW          1
125 #define LUSTRE_CONN_CON          2
126 #define LUSTRE_CONN_NOTCONN      3
127 #define LUSTRE_CONN_RECOVER      4
128 #define LUSTRE_CONN_FULL         5
129
130 /* packet types */
131 #define PTL_RPC_MSG_REQUEST 4711
132 #define PTL_RPC_MSG_ERR     4712
133 #define PTL_RPC_MSG_REPLY   4713
134
135 #define PTLRPC_MSG_MAGIC    0x0BD00BD0
136 #define PTLRPC_MSG_VERSION  0x00040002
137
138 struct lustre_handle {
139         __u64 cookie;
140 };
141 #define DEAD_HANDLE_MAGIC 0xdeadbeefcafebabe
142
143 /* we depend on this structure to be 8-byte aligned */
144 /* this type is only endian-adjusted in lustre_unpack_msg() */
145 struct lustre_msg {
146         struct lustre_handle handle;
147         __u32 magic;
148         __u32 type;
149         __u32 version;
150         __u32 opc;
151         __u64 last_xid;
152         __u64 last_committed;
153         __u64 transno;
154         __u32 status;
155         __u32 flags;
156         __u32 bufcount;
157         __u32 buflens[0];
158 };
159
160 static inline int lustre_msg_swabbed (struct lustre_msg *msg)
161 {
162         return (msg->magic == __swab32 (PTLRPC_MSG_MAGIC));
163 }
164
165 /* Flags that are operation-specific go in the top 16 bits. */
166 #define MSG_OP_FLAG_MASK   0xffff0000
167 #define MSG_OP_FLAG_SHIFT  16
168
169 /* Flags that apply to all requests are in the bottom 16 bits */
170 #define MSG_GEN_FLAG_MASK      0x0000ffff
171 #define MSG_LAST_REPLAY        1
172 #define MSG_RESENT             2
173
174 static inline int lustre_msg_get_flags(struct lustre_msg *msg)
175 {
176         return (msg->flags & MSG_GEN_FLAG_MASK);
177 }
178
179 static inline void lustre_msg_add_flags(struct lustre_msg *msg, int flags)
180 {
181         msg->flags |= MSG_GEN_FLAG_MASK & flags;
182 }
183
184 static inline void lustre_msg_set_flags(struct lustre_msg *msg, int flags)
185 {
186         msg->flags &= ~MSG_GEN_FLAG_MASK;
187         lustre_msg_add_flags(msg, flags);
188 }
189
190 static inline int lustre_msg_get_op_flags(struct lustre_msg *msg)
191 {
192         return (msg->flags >> MSG_OP_FLAG_SHIFT);
193 }
194
195 static inline void lustre_msg_add_op_flags(struct lustre_msg *msg, int flags)
196 {
197         msg->flags |= ((flags & MSG_GEN_FLAG_MASK) << MSG_OP_FLAG_SHIFT);
198 }
199
200 static inline void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags)
201 {
202         msg->flags &= ~MSG_OP_FLAG_MASK;
203         lustre_msg_add_op_flags(msg, flags);
204 }
205
206 /*
207  * Flags for all connect opcodes (MDS_CONNECT, OST_CONNECT)
208  */
209
210 #define MSG_CONNECT_RECOVERING 0x1
211 #define MSG_CONNECT_RECONNECT  0x2
212 #define MSG_CONNECT_REPLAYABLE  0x4
213
214 /*
215  *   OST requests: OBDO & OBD request records
216  */
217
218 /* opcodes */
219 typedef enum {
220         OST_REPLY      =  0,       /* reply ? */
221         OST_GETATTR    =  1,
222         OST_SETATTR    =  2,
223         OST_READ       =  3,
224         OST_WRITE      =  4,
225         OST_CREATE     =  5,
226         OST_DESTROY    =  6,
227         OST_GET_INFO   =  7,
228         OST_CONNECT    =  8,
229         OST_DISCONNECT =  9,
230         OST_PUNCH      = 10,
231         OST_OPEN       = 11,
232         OST_CLOSE      = 12,
233         OST_STATFS     = 13,
234         OST_SAN_READ   = 14,
235         OST_SAN_WRITE  = 15,
236         OST_SYNCFS     = 16,
237         OST_LAST_OPC
238 } ost_cmd_t;
239 #define OST_FIRST_OPC  OST_REPLY
240 /* When adding OST RPC opcodes, please update 
241  * LAST/FIRST macros used in ptlrpc/ptlrpc_internals.h */
242
243
244 typedef uint64_t        obd_id;
245 typedef uint64_t        obd_gr;
246 typedef uint64_t        obd_time;
247 typedef uint64_t        obd_size;
248 typedef uint64_t        obd_off;
249 typedef uint64_t        obd_blocks;
250 typedef uint32_t        obd_blksize;
251 typedef uint32_t        obd_mode;
252 typedef uint32_t        obd_uid;
253 typedef uint32_t        obd_gid;
254 typedef uint64_t        obd_rdev;
255 typedef uint32_t        obd_flag;
256 typedef uint32_t        obd_count;
257
258 #define OBD_FL_INLINEDATA       (0x00000001)
259 #define OBD_FL_OBDMDEXISTS      (0x00000002)
260
261 #define OBD_INLINESZ    60
262 #define FD_OSTDATA_SIZE sizeof(struct obd_client_handle)
263
264 /* Note: 64-bit types are 64-bit aligned in structure */
265 struct obdo {
266         obd_id                  o_id;
267         obd_gr                  o_gr;
268         obd_time                o_atime;
269         obd_time                o_mtime;
270         obd_time                o_ctime;
271         obd_size                o_size;
272         obd_blocks              o_blocks; /* brw: clients sent cached bytes */
273         obd_rdev                o_rdev; /* brw: clients/servers sent grant */
274         obd_blksize             o_blksize;      /* optimal IO blocksize */
275         obd_mode                o_mode;
276         obd_uid                 o_uid;
277         obd_gid                 o_gid;
278         obd_flag                o_flags;
279         obd_count               o_nlink; /* brw: checksum */
280         obd_count               o_generation;
281         obd_flag                o_valid;        /* hot fields in this obdo */
282         obd_flag                o_obdflags;
283         __u32                   o_easize;
284         char                    o_inline[OBD_INLINESZ];
285 };
286
287 extern void lustre_swab_obdo (struct obdo *o);
288
289 struct lov_object_id { /* per-child structure */
290         __u64 l_object_id;
291 };
292
293 #define LOV_MAGIC  0x0BD00BD0
294
295 struct lov_mds_md {
296         __u32 lmm_magic;
297         __u64 lmm_object_id;       /* lov object id */
298         __u32 lmm_stripe_size;     /* size of the stripe */
299         __u32 lmm_stripe_offset;   /* starting stripe offset in lmm_objects */
300         __u16 lmm_stripe_count;    /* number of stipes in use for this object */
301         __u16 lmm_ost_count;       /* how many OST idx are in this LOV md */
302         struct lov_object_id lmm_objects[0];
303 };
304
305 #define OBD_MD_FLALL    (0xffffffff)
306 #define OBD_MD_FLID     (0x00000001)    /* object ID */
307 #define OBD_MD_FLATIME  (0x00000002)    /* access time */
308 #define OBD_MD_FLMTIME  (0x00000004)    /* data modification time */
309 #define OBD_MD_FLCTIME  (0x00000008)    /* change time */
310 #define OBD_MD_FLSIZE   (0x00000010)    /* size */
311 #define OBD_MD_FLBLOCKS (0x00000020)    /* allocated blocks count */
312 #define OBD_MD_FLBLKSZ  (0x00000040)    /* block size */
313 #define OBD_MD_FLMODE   (0x00000080)    /* access bits (mode & ~S_IFMT) */
314 #define OBD_MD_FLTYPE   (0x00000100)    /* object type (mode & S_IFMT) */
315 #define OBD_MD_FLUID    (0x00000200)    /* user ID */
316 #define OBD_MD_FLGID    (0x00000400)    /* group ID */
317 #define OBD_MD_FLFLAGS  (0x00000800)    /* flags word */
318 #define OBD_MD_FLOBDFLG (0x00001000)
319 #define OBD_MD_FLNLINK  (0x00002000)    /* link count */
320 #define OBD_MD_FLGENER  (0x00004000)    /* generation number */
321 #define OBD_MD_FLINLINE (0x00008000)    /* inline data */
322 #define OBD_MD_FLRDEV   (0x00010000)    /* device number */
323 #define OBD_MD_FLEASIZE (0x00020000)    /* extended attribute data */
324 #define OBD_MD_LINKNAME (0x00040000)    /* symbolic link target */
325 #define OBD_MD_FLHANDLE (0x00080000)    /* file handle */
326 #define OBD_MD_FLCKSUM  (0x00100000)    /* bulk data checksum */
327 #define OBD_MD_FLNOTOBD (~(OBD_MD_FLOBDFLG | OBD_MD_FLBLOCKS | OBD_MD_LINKNAME|\
328                            OBD_MD_FLEASIZE | OBD_MD_FLHANDLE | OBD_MD_FLCKSUM))
329
330 struct obd_statfs {
331         __u64           os_type;
332         __u64           os_blocks;
333         __u64           os_bfree;
334         __u64           os_bavail;
335         __u64           os_files;
336         __u64           os_ffree;
337         __u8            os_fsid[40];
338         __u32           os_bsize;
339         __u32           os_namelen;
340         __u64           os_maxbytes;
341         __u32           os_spare[10];
342 };
343
344 extern void lustre_swab_obd_statfs (struct obd_statfs *os);
345
346 /* ost_body.data values for OST_BRW */
347
348 #define OBD_BRW_READ       0x01
349 #define OBD_BRW_WRITE      0x02
350 #define OBD_BRW_RWMASK     (OBD_BRW_READ | OBD_BRW_WRITE)
351 #define OBD_BRW_CREATE     0x04
352 #define OBD_BRW_SYNC       0x08
353 #define OBD_BRW_CHECK      0x10
354 #define OBD_BRW_FROM_GRANT 0x20
355
356 #define OBD_OBJECT_EOF 0xffffffffffffffffULL
357
358 struct obd_ioobj {
359         obd_id               ioo_id;
360         obd_gr               ioo_gr;
361         __u32                ioo_type;
362         __u32                ioo_bufcnt;
363 } __attribute__((packed));
364
365 extern void lustre_swab_obd_ioobj (struct obd_ioobj *ioo);
366
367 /* multiple of 8 bytes => can array */
368 struct niobuf_remote {
369         __u64 offset;
370         __u32 len;
371         __u32 flags;
372 } __attribute__((packed));
373
374 extern void lustre_swab_niobuf_remote (struct niobuf_remote *nbr);
375
376 /* request structure for OST's */
377
378 #define OST_REQ_HAS_OA1  0x1
379
380 struct ost_body {
381         struct  obdo oa;
382 };
383
384 extern void lustre_swab_ost_body (struct ost_body *b);
385
386 /*
387  *   MDS REQ RECORDS
388  */
389
390 /* opcodes */
391 typedef enum {
392         MDS_GETATTR      = 33,
393         MDS_GETATTR_NAME = 34,
394         MDS_CLOSE        = 35,
395         MDS_REINT        = 36,
396         MDS_READPAGE     = 37,
397         MDS_CONNECT      = 38,
398         MDS_DISCONNECT   = 39,
399         MDS_GETSTATUS    = 40,
400         MDS_STATFS       = 41,
401         MDS_GETLOVINFO   = 42,
402         MDS_LAST_OPC
403 } mds_cmd_t;
404 #define MDS_FIRST_OPC    MDS_GETATTR
405 /* When adding MDS RPC opcodes, please update 
406  * LAST/FIRST macros used in ptlrpc/ptlrpc_internals.h */
407
408 /*
409  * Do not exceed 63 
410  */
411
412 #define REINT_SETATTR  1
413 #define REINT_CREATE   2
414 #define REINT_LINK     3
415 #define REINT_UNLINK   4
416 #define REINT_RENAME   5
417 #define REINT_OPEN     6
418 #define REINT_MAX      6
419
420 #define IT_INTENT_EXEC   1
421 #define IT_OPEN_LOOKUP  (1 << 1)
422 #define IT_OPEN_NEG     (1 << 2)
423 #define IT_OPEN_POS     (1 << 3)
424 #define IT_OPEN_CREATE  (1 << 4)
425 #define IT_OPEN_OPEN    (1 << 5)
426
427 struct ll_fid {
428         __u64 id;
429         __u32 generation;
430         __u32 f_type;
431 };
432
433 extern void lustre_swab_ll_fid (struct ll_fid *fid);
434
435 #define MDS_STATUS_CONN 1
436 #define MDS_STATUS_LOV 2
437
438 struct mds_status_req {
439         __u32  flags;
440         __u32  repbuf;
441 };
442
443 extern void lustre_swab_mds_status_req (struct mds_status_req *r);
444
445 struct mds_fileh_body {
446         struct ll_fid f_fid;
447         struct lustre_handle f_handle;
448 };
449
450 extern void lustre_swab_mds_fileh_body (struct mds_fileh_body *f);
451
452 struct mds_body {
453         struct ll_fid  fid1;
454         struct ll_fid  fid2;
455         struct lustre_handle handle;
456         __u64          size;   /* Offset, in the case of MDS_READPAGE */
457         __u64          blocks; /* XID, in the case of MDS_READPAGE */
458         __u32          ino;   /* make this a __u64 */
459         __u32          valid;
460         __u32          fsuid;
461         __u32          fsgid;
462         __u32          capability;
463         __u32          mode;
464         __u32          uid;
465         __u32          gid;
466         __u32          mtime;
467         __u32          ctime;
468         __u32          atime;
469         __u32          flags;
470         __u32          rdev;
471         __u32          nlink; /* #bytes to read in the case of MDS_READPAGE */
472         __u32          generation;
473         __u32          suppgid;
474         __u32          eadatasize;
475 };
476
477 extern void lustre_swab_mds_body (struct mds_body *b);
478
479 /* This is probably redundant with OBD_MD_FLEASIZE, but we need an audit */
480 #define MDS_OPEN_HAS_EA 1 /* this open has an EA, for a delayed create*/
481
482 /* MDS update records */
483
484 //struct mds_update_record_hdr {
485 //        __u32 ur_opcode;
486 //};
487
488 struct mds_rec_setattr {
489         __u32           sa_opcode;
490         __u32           sa_fsuid;
491         __u32           sa_fsgid;
492         __u32           sa_cap;
493         __u32           sa_reserved;
494         __u32           sa_valid;
495         struct ll_fid   sa_fid;
496         __u32           sa_mode;
497         __u32           sa_uid;
498         __u32           sa_gid;
499         __u32           sa_attr_flags;
500         __u64           sa_size;
501         __u64           sa_atime;
502         __u64           sa_mtime;
503         __u64           sa_ctime;
504         __u32           sa_suppgid;
505 };
506
507 extern void lustre_swab_mds_rec_setattr (struct mds_rec_setattr *sa);
508
509 struct mds_rec_create {
510         __u32           cr_opcode;
511         __u32           cr_fsuid;
512         __u32           cr_fsgid;
513         __u32           cr_cap;
514         __u32           cr_flags; /* for use with open */
515         __u32           cr_mode;
516         struct ll_fid   cr_fid;
517         struct ll_fid   cr_replayfid;
518         __u32           cr_uid;
519         __u32           cr_gid;
520         __u64           cr_time;
521         __u64           cr_rdev;
522         __u32           cr_suppgid;
523 };
524
525 extern void lustre_swab_mds_rec_create (struct mds_rec_create *cr);
526
527 struct mds_rec_link {
528         __u32           lk_opcode;
529         __u32           lk_fsuid;
530         __u32           lk_fsgid;
531         __u32           lk_cap;
532         __u32           lk_suppgid1;
533         __u32           lk_suppgid2;
534         struct ll_fid   lk_fid1;
535         struct ll_fid   lk_fid2;
536 };
537
538 extern void lustre_swab_mds_rec_link (struct mds_rec_link *lk);
539
540 struct mds_rec_unlink {
541         __u32           ul_opcode;
542         __u32           ul_fsuid;
543         __u32           ul_fsgid;
544         __u32           ul_cap;
545         __u32           ul_reserved;
546         __u32           ul_mode;
547         __u32           ul_suppgid;
548         struct ll_fid   ul_fid1;
549         struct ll_fid   ul_fid2;
550 };
551
552 extern void lustre_swab_mds_rec_unlink (struct mds_rec_unlink *ul);
553
554 struct mds_rec_rename {
555         __u32           rn_opcode;
556         __u32           rn_fsuid;
557         __u32           rn_fsgid;
558         __u32           rn_cap;
559         __u32           rn_suppgid1;
560         __u32           rn_suppgid2;
561         struct ll_fid   rn_fid1;
562         struct ll_fid   rn_fid2;
563 };
564
565 extern void lustre_swab_mds_rec_rename (struct mds_rec_rename *rn);
566
567 /*
568  *  LOV data structures
569  */
570
571 #define LOV_RAID0   0
572 #define LOV_RAIDRR  1
573
574 #define LOV_MAX_UUID_BUFFER_SIZE  8192
575 /* The size of the buffer the lov/mdc reserves for the 
576  * array of UUIDs returned by the MDS.  With the current
577  * protocol, this will limit the max number of OSTs per LOV */
578
579 struct lov_desc {
580         __u32 ld_tgt_count;                /* how many OBD's */
581         __u32 ld_active_tgt_count;         /* how many active */
582         __u32 ld_default_stripe_count;     /* how many objects are used */
583         __u64 ld_default_stripe_size;      /* in bytes */
584         __u64 ld_default_stripe_offset;    /* in bytes */
585         __u32 ld_pattern;                  /* RAID 0,1 etc */
586         struct obd_uuid ld_uuid;
587 };
588
589 extern void lustre_swab_lov_desc (struct lov_desc *ld);
590
591 /*
592  *   LDLM requests:
593  */
594 /* opcodes -- MUST be distinct from OST/MDS opcodes */
595 typedef enum {
596         LDLM_ENQUEUE     = 101,
597         LDLM_CONVERT     = 102,
598         LDLM_CANCEL      = 103,
599         LDLM_BL_CALLBACK = 104,
600         LDLM_CP_CALLBACK = 105,
601         LDLM_LAST_OPC
602 } ldlm_cmd_t;
603 #define LDLM_FIRST_OPC LDLM_ENQUEUE
604 /* When adding LDLM RPC opcodes, please update 
605  * LAST/FIRST macros used in ptlrpc/ptlrpc_internals.h */
606
607 #define RES_NAME_SIZE 3
608 #define RES_VERSION_SIZE 4
609
610 struct ldlm_res_id {
611         __u64 name[RES_NAME_SIZE];
612 };
613
614 extern void lustre_swab_ldlm_res_id (struct ldlm_res_id *id);
615
616 /* lock types */
617 typedef enum {
618         LCK_EX = 1,
619         LCK_PW,
620         LCK_PR,
621         LCK_CW,
622         LCK_CR,
623         LCK_NL
624 } ldlm_mode_t;
625
626 struct ldlm_extent {
627         __u64 start;
628         __u64 end;
629 };
630
631 extern void lustre_swab_ldlm_extent (struct ldlm_extent *e);
632
633 struct ldlm_intent {
634         __u64 opc;
635 };
636
637 extern void lustre_swab_ldlm_intent (struct ldlm_intent *i);
638
639 /* Note this unaligned structure; as long as it's only used in ldlm_request
640  * below, we're probably fine. */
641 struct ldlm_resource_desc {
642         __u32 lr_type;
643         struct ldlm_res_id lr_name;
644         __u32 lr_version[RES_VERSION_SIZE];
645 };
646
647 extern void lustre_swab_ldlm_resource_desc (struct ldlm_resource_desc *r);
648
649 struct ldlm_lock_desc {
650         struct ldlm_resource_desc l_resource;
651         ldlm_mode_t l_req_mode;
652         ldlm_mode_t l_granted_mode;
653         struct ldlm_extent l_extent;
654         __u32 l_version[RES_VERSION_SIZE];
655 };
656
657 extern void lustre_swab_ldlm_lock_desc (struct ldlm_lock_desc *l);
658
659 struct ldlm_request {
660         __u32 lock_flags;
661         struct ldlm_lock_desc lock_desc;
662         struct lustre_handle lock_handle1;
663         struct lustre_handle lock_handle2;
664 };
665
666 extern void lustre_swab_ldlm_request (struct ldlm_request *rq);
667
668 struct ldlm_reply {
669         __u32 lock_flags;
670         __u32 lock_mode;
671         struct ldlm_res_id lock_resource_name;
672         struct lustre_handle lock_handle;
673         struct ldlm_extent lock_extent;   /* XXX make this policy 1 &2 */
674         __u64  lock_policy_res1;
675         __u64  lock_policy_res2;
676 };
677
678 extern void lustre_swab_ldlm_reply (struct ldlm_reply *r);
679
680 /*
681  * ptlbd, portal block device requests
682  */
683 typedef enum {
684         PTLBD_QUERY = 200,
685         PTLBD_READ = 201,
686         PTLBD_WRITE = 202,
687         PTLBD_FLUSH = 203,
688         PTLBD_CONNECT = 204,
689         PTLBD_DISCONNECT = 205,
690         PTLBD_LAST_OPC
691 } ptlbd_cmd_t;
692 #define PTLBD_FIRST_OPC PTLBD_QUERY
693 /* When adding PTLBD RPC opcodes, please update 
694  * LAST/FIRST macros used in ptlrpc/ptlrpc_internals.h */
695
696 struct ptlbd_op {
697         __u16 op_cmd;
698         __u16 op_lun;
699         __u16 op_niob_cnt;
700         __u16 op__padding;
701         __u32 op_block_cnt;
702 };
703
704 extern void lustre_swab_ptlbd_op (struct ptlbd_op *op);
705
706 struct ptlbd_niob {
707         __u64 n_xid;
708         __u64 n_block_nr;
709         __u32 n_offset;
710         __u32 n_length;
711 };
712
713 extern void lustre_swab_ptlbd_niob (struct ptlbd_niob *n);
714
715 struct ptlbd_rsp {
716         __u16 r_status;
717         __u16 r_error_cnt;
718 };
719
720 extern void lustre_swab_ptlbd_rsp (struct ptlbd_rsp *r);
721
722 /*
723  * Opcodes for multiple servers.
724  */
725
726 #define OBD_PING 400
727
728 #endif