1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
6 * This file is part of Lustre, http://www.lustre.org.
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.
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.
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.
21 * (Un)packing of OST requests
24 #ifndef __LUSTRE_IDL_H__
25 #define __LUSTRE_IDL_H__
28 # include <linux/ioctl.h>
29 # include <asm/types.h>
30 # include <linux/types.h>
31 # include <linux/list.h>
34 # include <linux/list.h>
39 * this file contains all data structures used in Lustre interfaces:
40 * - obdo and obd_request records
41 * - mds_request records
46 #define PTL_RPC_MSG_REQUEST 4711
47 #define PTL_RPC_MSG_ERR 4712
49 struct lustre_handle {
55 __u64 conn; /* pointer to ptlrpc_connection */
56 __u64 token; /* security token */
69 #define N_LOCAL_TEMP_PAGE 0x00000001
72 * OST requests: OBDO & OBD request records
81 #define OST_GET_INFO 6
83 #define OST_DISCONNECT 8
90 typedef uint64_t obd_id;
91 typedef uint64_t obd_gr;
92 typedef uint64_t obd_time;
93 typedef uint64_t obd_size;
94 typedef uint64_t obd_off;
95 typedef uint64_t obd_blocks;
96 typedef uint32_t obd_blksize;
97 typedef uint32_t obd_mode;
98 typedef uint32_t obd_uid;
99 typedef uint32_t obd_gid;
100 typedef uint32_t obd_rdev;
101 typedef uint32_t obd_flag;
102 typedef uint32_t obd_count;
104 #define OBD_FL_INLINEDATA (0x00000001)
105 #define OBD_FL_OBDMDEXISTS (0x00000002)
106 #define OBD_FL_CREATEONOPEN (0x00000004)
108 #define OBD_INLINESZ 60
109 #define OBD_OBDMDSZ 60
110 /* Note: 64-bit types are 64-bit aligned in structure */
119 obd_blksize o_blksize;
126 obd_count o_generation;
127 obd_flag o_valid; /* hot fields in this obdo */
128 char o_inline[OBD_INLINESZ];
129 char o_obdmd[OBD_OBDMDSZ];
130 struct list_head o_list;
131 struct obd_ops *o_op;
134 #define OBD_MD_FLALL 0xffffffff
135 #define OBD_MD_FLID (0x00000001)
136 #define OBD_MD_FLATIME (0x00000002)
137 #define OBD_MD_FLMTIME (0x00000004)
138 #define OBD_MD_FLCTIME (0x00000008)
139 #define OBD_MD_FLSIZE (0x00000010)
140 #define OBD_MD_FLBLOCKS (0x00000020)
141 #define OBD_MD_FLBLKSZ (0x00000040)
142 #define OBD_MD_FLMODE (0x00000080)
143 #define OBD_MD_FLTYPE (0x00000100)
144 #define OBD_MD_FLUID (0x00000200)
145 #define OBD_MD_FLGID (0x00000400)
146 #define OBD_MD_FLFLAGS (0x00000800)
147 #define OBD_MD_FLOBDFLG (0x00001000)
148 #define OBD_MD_FLNLINK (0x00002000)
149 #define OBD_MD_FLGENER (0x00004000)
150 #define OBD_MD_FLINLINE (0x00008000)
151 #define OBD_MD_FLOBDMD (0x00010000)
152 #define OBD_MD_FLOBJID (0x00020000)
153 #define OBD_MD_LINKNAME (0x00040000)
154 #define OBD_MD_FLNOTOBD (~(OBD_MD_FLOBDMD | OBD_MD_FLOBDFLG | OBD_MD_FLBLOCKS |\
177 struct niobuf_remote {
184 struct niobuf_local {
191 void *target_private;
192 struct dentry *dentry;
195 /* request structure for OST's */
197 #define OST_REQ_HAS_OA1 0x1
210 #define MDS_GETATTR 1
214 #define MDS_READPAGE 6
215 #define MDS_CONNECT 7
216 #define MDS_DISCONNECT 8
217 #define MDS_GETSTATUS 9
218 #define MDS_STATFS 10
220 #define REINT_SETATTR 1
221 #define REINT_CREATE 2
223 #define REINT_UNLINK 4
224 #define REINT_RENAME 5
225 #define REINT_RECREATE 6
255 /* MDS update records */
256 struct mds_update_record_hdr {
260 struct mds_rec_setattr {
262 struct ll_fid sa_fid;
274 struct mds_rec_create {
276 struct ll_fid cr_fid;
284 struct mds_rec_link {
286 struct ll_fid lk_fid1;
287 struct ll_fid lk_fid2;
290 struct mds_rec_unlink {
292 struct ll_fid ul_fid1;
293 struct ll_fid ul_fid2;
296 struct mds_rec_rename {
298 struct ll_fid rn_fid1;
299 struct ll_fid rn_fid2;
308 #define LDLM_ENQUEUE 1
309 #define LDLM_CONVERT 2
310 #define LDLM_CANCEL 3
311 #define LDLM_CALLBACK 4
313 #define RES_NAME_SIZE 3
314 #define RES_VERSION_SIZE 4
335 struct ldlm_resource_desc {
337 __u64 lr_name[RES_NAME_SIZE];
338 __u64 lr_version[RES_VERSION_SIZE];
341 struct ldlm_lock_desc {
342 struct ldlm_resource_desc l_resource;
343 ldlm_mode_t l_req_mode;
344 ldlm_mode_t l_granted_mode;
345 struct ldlm_extent l_extent;
346 __u32 l_version[RES_VERSION_SIZE];
349 struct ldlm_request {
351 struct ldlm_lock_desc lock_desc;
352 struct lustre_handle lock_handle1;
353 struct lustre_handle lock_handle2;
358 __u64 lock_resource_name[3];
359 struct lustre_handle lock_handle;
360 struct ldlm_extent lock_extent; /* XXX make this policy 1 &2 */
361 __u64 lock_policy_res1;
362 __u64 lock_policy_res2;
368 #define OBD_IOCTL_VERSION 0x00010001
370 struct obd_ioctl_data {
372 uint32_t ioc_version;
375 struct obdo ioc_obdo1;
376 struct obdo ioc_obdo2;
381 /* buffers the kernel will treat as user pointers */
387 /* two inline buffers */
388 uint32_t ioc_inllen1;
390 uint32_t ioc_inllen2;
396 struct obd_ioctl_hdr {
398 uint32_t ioc_version;
401 static inline int obd_ioctl_packlen(struct obd_ioctl_data *data)
403 int len = sizeof(struct obd_ioctl_data);
404 len += size_round(data->ioc_inllen1);
405 len += size_round(data->ioc_inllen2);
409 static inline int obd_ioctl_is_invalid(struct obd_ioctl_data *data)
411 if (data->ioc_len > (1<<30)) {
412 printk("OBD ioctl: ioc_len larger than 1<<30\n");
415 if (data->ioc_inllen1 > (1<<30)) {
416 printk("OBD ioctl: ioc_inllen1 larger than 1<<30\n");
419 if (data->ioc_inllen2 > (1<<30)) {
420 printk("OBD ioctl: ioc_inllen2 larger than 1<<30\n");
423 if (data->ioc_inlbuf1 && !data->ioc_inllen1) {
424 printk("OBD ioctl: inlbuf1 pointer but 0 length\n");
427 if (data->ioc_inlbuf2 && !data->ioc_inllen2) {
428 printk("OBD ioctl: inlbuf2 pointer but 0 length\n");
431 if (data->ioc_pbuf1 && !data->ioc_plen1) {
432 printk("OBD ioctl: pbuf1 pointer but 0 length\n");
435 if (data->ioc_pbuf2 && !data->ioc_plen2) {
436 printk("OBD ioctl: pbuf2 pointer but 0 length\n");
440 if (data->ioc_inllen1 && !data->ioc_inlbuf1) {
441 printk("OBD ioctl: inllen1 set but NULL pointer\n");
444 if (data->ioc_inllen2 && !data->ioc_inlbuf2) {
445 printk("OBD ioctl: inllen2 set but NULL pointer\n");
448 if (data->ioc_plen1 && !data->ioc_pbuf1) {
449 printk("OBD ioctl: plen1 set but NULL pointer\n");
452 if (data->ioc_plen2 && !data->ioc_pbuf2) {
453 printk("OBD ioctl: plen2 set but NULL pointer\n");
457 if (obd_ioctl_packlen(data) != data->ioc_len ) {
458 printk("OBD ioctl: packlen exceeds ioc_len\n");
461 if (data->ioc_inllen1 &&
462 data->ioc_bulk[data->ioc_inllen1 - 1] != '\0') {
463 printk("OBD ioctl: inlbuf1 not 0 terminated\n");
466 if (data->ioc_inllen2 &&
467 data->ioc_bulk[size_round(data->ioc_inllen1) + data->ioc_inllen2 - 1] != '\0') {
468 printk("OBD ioctl: inlbuf2 not 0 terminated\n");
475 static inline int obd_ioctl_pack(struct obd_ioctl_data *data, char **pbuf,
479 struct obd_ioctl_data *overlay;
480 data->ioc_len = obd_ioctl_packlen(data);
481 data->ioc_version = OBD_IOCTL_VERSION;
483 if (*pbuf && obd_ioctl_packlen(data) > max)
486 *pbuf = malloc(data->ioc_len);
490 overlay = (struct obd_ioctl_data *)*pbuf;
491 memcpy(*pbuf, data, sizeof(*data));
493 ptr = overlay->ioc_bulk;
494 if (data->ioc_inlbuf1)
495 LOGL(data->ioc_inlbuf1, data->ioc_inllen1, ptr);
496 if (data->ioc_inlbuf2)
497 LOGL(data->ioc_inlbuf2, data->ioc_inllen2, ptr);
498 if (obd_ioctl_is_invalid(overlay))
506 /* buffer MUST be at least the size of obd_ioctl_hdr */
507 static inline int obd_ioctl_getdata(char *buf, char *end, void *arg)
509 struct obd_ioctl_hdr *hdr;
510 struct obd_ioctl_data *data;
514 hdr = (struct obd_ioctl_hdr *)buf;
515 data = (struct obd_ioctl_data *)buf;
517 err = copy_from_user(buf, (void *)arg, sizeof(*hdr));
523 if (hdr->ioc_version != OBD_IOCTL_VERSION) {
524 printk("OBD: version mismatch kernel vs application\n");
528 if (hdr->ioc_len + buf >= end) {
529 printk("OBD: user buffer exceeds kernel buffer\n");
534 if (hdr->ioc_len < sizeof(struct obd_ioctl_data)) {
535 printk("OBD: user buffer too small for ioctl\n");
539 err = copy_from_user(buf, (void *)arg, hdr->ioc_len);
545 if (obd_ioctl_is_invalid(data)) {
546 printk("OBD: ioctl not correctly formatted\n");
550 if (data->ioc_inllen1) {
551 data->ioc_inlbuf1 = &data->ioc_bulk[0];
554 if (data->ioc_inllen2) {
555 data->ioc_inlbuf2 = &data->ioc_bulk[0] + size_round(data->ioc_inllen1);
564 #define OBD_IOC_CREATE _IOR ('f', 101, long)
565 #define OBD_IOC_SETUP _IOW ('f', 102, long)
566 #define OBD_IOC_CLEANUP _IO ('f', 103 )
567 #define OBD_IOC_DESTROY _IOW ('f', 104, long)
568 #define OBD_IOC_PREALLOCATE _IOWR('f', 105, long)
569 #define OBD_IOC_DEC_USE_COUNT _IO ('f', 106 )
570 #define OBD_IOC_SETATTR _IOW ('f', 107, long)
571 #define OBD_IOC_GETATTR _IOR ('f', 108, long)
572 #define OBD_IOC_READ _IOWR('f', 109, long)
573 #define OBD_IOC_WRITE _IOWR('f', 110, long)
574 #define OBD_IOC_CONNECT _IOR ('f', 111, long)
575 #define OBD_IOC_DISCONNECT _IOW ('f', 112, long)
576 #define OBD_IOC_STATFS _IOWR('f', 113, long)
577 #define OBD_IOC_SYNC _IOR ('f', 114, long)
578 #define OBD_IOC_READ2 _IOWR('f', 115, long)
579 #define OBD_IOC_FORMAT _IOWR('f', 116, long)
580 #define OBD_IOC_PARTITION _IOWR('f', 117, long)
581 #define OBD_IOC_ATTACH _IOWR('f', 118, long)
582 #define OBD_IOC_DETACH _IOWR('f', 119, long)
583 #define OBD_IOC_COPY _IOWR('f', 120, long)
584 #define OBD_IOC_MIGR _IOWR('f', 121, long)
585 #define OBD_IOC_PUNCH _IOWR('f', 122, long)
586 #define OBD_IOC_DEVICE _IOWR('f', 123, long)
587 #define OBD_IOC_MODULE_DEBUG _IOWR('f', 124, long)
588 #define OBD_IOC_BRW_READ _IOWR('f', 125, long)
589 #define OBD_IOC_BRW_WRITE _IOWR('f', 126, long)
590 #define OBD_IOC_NAME2DEV _IOWR('f', 127, long)
591 #define OBD_IOC_NEWDEV _IOWR('f', 128, long)
593 #define OBD_IOC_RECOVD_NEWCONN _IOWR('f', 131, long)
595 #define OBD_IOC_DEC_FS_USE_COUNT _IO ('f', 132 )