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>
33 # include <linux/list.h>
38 * this file contains all data structures used in Lustre interfaces:
39 * - obdo and obd_request records
40 * - mds_request records
45 #define PTL_RPC_MSG_REQUEST 4711
46 #define PTL_RPC_MSG_ERR 4712
64 #define N_LOCAL_TEMP_PAGE 0x00000001
67 * OST requests: OBDO & OBD request records
76 #define OST_GET_INFO 6
78 #define OST_DISCONNECT 8
85 typedef uint64_t obd_id;
86 typedef uint64_t obd_gr;
87 typedef uint64_t obd_time;
88 typedef uint64_t obd_size;
89 typedef uint64_t obd_off;
90 typedef uint64_t obd_blocks;
91 typedef uint32_t obd_blksize;
92 typedef uint32_t obd_mode;
93 typedef uint32_t obd_uid;
94 typedef uint32_t obd_gid;
95 typedef uint32_t obd_rdev;
96 typedef uint32_t obd_flag;
97 typedef uint32_t obd_count;
99 #define OBD_FL_INLINEDATA (0x00000001)
100 #define OBD_FL_OBDMDEXISTS (0x00000002)
102 #define OBD_INLINESZ 60
103 #define OBD_OBDMDSZ 60
104 /* Note: 64-bit types are 64-bit aligned in structure */
113 obd_blksize o_blksize;
120 obd_count o_generation;
121 obd_flag o_valid; /* hot fields in this obdo */
122 char o_inline[OBD_INLINESZ];
123 char o_obdmd[OBD_OBDMDSZ];
124 struct list_head o_list;
125 struct obd_ops *o_op;
128 #define OBD_MD_FLALL 0xffffffff
129 #define OBD_MD_FLID (0x00000001)
130 #define OBD_MD_FLATIME (0x00000002)
131 #define OBD_MD_FLMTIME (0x00000004)
132 #define OBD_MD_FLCTIME (0x00000008)
133 #define OBD_MD_FLSIZE (0x00000010)
134 #define OBD_MD_FLBLOCKS (0x00000020)
135 #define OBD_MD_FLBLKSZ (0x00000040)
136 #define OBD_MD_FLMODE (0x00000080)
137 #define OBD_MD_FLTYPE (0x00000100)
138 #define OBD_MD_FLUID (0x00000200)
139 #define OBD_MD_FLGID (0x00000400)
140 #define OBD_MD_FLFLAGS (0x00000800)
141 #define OBD_MD_FLOBDFLG (0x00001000)
142 #define OBD_MD_FLNLINK (0x00002000)
143 #define OBD_MD_FLGENER (0x00004000)
144 #define OBD_MD_FLINLINE (0x00008000)
145 #define OBD_MD_FLOBDMD (0x00010000)
146 #define OBD_MD_FLOBJID (0x00020000)
147 #define OBD_MD_LINKNAME (0x00040000)
148 #define OBD_MD_FLNOTOBD (~(OBD_MD_FLOBDMD | OBD_MD_FLOBDFLG | OBD_MD_FLBLOCKS |\
158 struct niobuf_remote {
165 struct niobuf_local {
172 void *target_private;
173 struct dentry *dentry;
176 /* request structure for OST's */
178 #define OST_REQ_HAS_OA1 0x1
191 #define MDS_GETATTR 1
195 #define MDS_READPAGE 6
196 #define MDS_CONNECT 7
199 #define REINT_SETATTR 1
200 #define REINT_CREATE 2
202 #define REINT_UNLINK 4
203 #define REINT_RENAME 5
204 #define REINT_RECREATE 6
234 /* MDS update records */
235 struct mds_update_record_hdr {
239 struct mds_rec_setattr {
241 struct ll_fid sa_fid;
253 struct mds_rec_create {
255 struct ll_fid cr_fid;
263 struct mds_rec_link {
265 struct ll_fid lk_fid1;
266 struct ll_fid lk_fid2;
269 struct mds_rec_unlink {
271 struct ll_fid ul_fid1;
272 struct ll_fid ul_fid2;
275 struct mds_rec_rename {
277 struct ll_fid rn_fid1;
278 struct ll_fid rn_fid2;
287 #define LDLM_ENQUEUE 1
288 #define LDLM_CONVERT 2
289 #define LDLM_CANCEL 3
290 #define LDLM_CALLBACK 4
292 #define RES_NAME_SIZE 3
293 #define RES_VERSION_SIZE 4
315 struct ldlm_resource_desc {
317 __u64 lr_name[RES_NAME_SIZE];
318 __u64 lr_version[RES_VERSION_SIZE];
321 struct ldlm_lock_desc {
322 struct ldlm_resource_desc l_resource;
323 ldlm_mode_t l_req_mode;
324 ldlm_mode_t l_granted_mode;
325 struct ldlm_extent l_extent;
326 __u32 l_version[RES_VERSION_SIZE];
329 struct ldlm_request {
331 struct ldlm_lock_desc lock_desc;
332 struct ldlm_handle lock_handle1;
333 struct ldlm_handle lock_handle2;
338 struct ldlm_handle lock_handle;
339 struct ldlm_extent lock_extent;
347 #define OBD_IOCTL_VERSION 0x00010001
349 struct obd_ioctl_data {
351 uint32_t ioc_version;
354 struct obdo ioc_obdo1;
355 struct obdo ioc_obdo2;
360 /* buffers the kernel will treat as user pointers */
366 /* two inline buffers */
367 uint32_t ioc_inllen1;
369 uint32_t ioc_inllen2;
375 struct obd_ioctl_hdr {
377 uint32_t ioc_version;
380 static inline int obd_ioctl_packlen(struct obd_ioctl_data *data)
382 int len = sizeof(struct obd_ioctl_data);
383 len += size_round(data->ioc_inllen1);
384 len += size_round(data->ioc_inllen2);
388 static inline int obd_ioctl_is_invalid(struct obd_ioctl_data *data)
390 if (data->ioc_len > (1<<30)) {
391 printk("OBD ioctl: ioc_len larger than 1<<30\n");
394 if (data->ioc_inllen1 > (1<<30)) {
395 printk("OBD ioctl: ioc_inllen1 larger than 1<<30\n");
398 if (data->ioc_inllen2 > (1<<30)) {
399 printk("OBD ioctl: ioc_inllen2 larger than 1<<30\n");
402 if (data->ioc_inlbuf1 && !data->ioc_inllen1) {
403 printk("OBD ioctl: inlbuf1 pointer but 0 length\n");
406 if (data->ioc_inlbuf2 && !data->ioc_inllen2) {
407 printk("OBD ioctl: inlbuf2 pointer but 0 length\n");
410 if (data->ioc_pbuf1 && !data->ioc_plen1) {
411 printk("OBD ioctl: pbuf1 pointer but 0 length\n");
414 if (data->ioc_pbuf2 && !data->ioc_plen2) {
415 printk("OBD ioctl: pbuf2 pointer but 0 length\n");
419 if (data->ioc_inllen1 && !data->ioc_inlbuf1) {
420 printk("OBD ioctl: inllen1 set but NULL pointer\n");
423 if (data->ioc_inllen2 && !data->ioc_inlbuf2) {
424 printk("OBD ioctl: inllen2 set but NULL pointer\n");
427 if (data->ioc_plen1 && !data->ioc_pbuf1) {
428 printk("OBD ioctl: plen1 set but NULL pointer\n");
431 if (data->ioc_plen2 && !data->ioc_pbuf2) {
432 printk("OBD ioctl: plen2 set but NULL pointer\n");
436 if (obd_ioctl_packlen(data) != data->ioc_len ) {
437 printk("OBD ioctl: packlen exceeds ioc_len\n");
440 if (data->ioc_inllen1 &&
441 data->ioc_bulk[data->ioc_inllen1 - 1] != '\0') {
442 printk("OBD ioctl: inlbuf1 not 0 terminated\n");
445 if (data->ioc_inllen2 &&
446 data->ioc_bulk[size_round(data->ioc_inllen1) + data->ioc_inllen2 - 1] != '\0') {
447 printk("OBD ioctl: inlbuf2 not 0 terminated\n");
454 static inline int obd_ioctl_pack(struct obd_ioctl_data *data, char **pbuf,
458 struct obd_ioctl_data *overlay;
459 data->ioc_len = obd_ioctl_packlen(data);
460 data->ioc_version = OBD_IOCTL_VERSION;
462 if (*pbuf && obd_ioctl_packlen(data) > max)
465 *pbuf = malloc(data->ioc_len);
469 overlay = (struct obd_ioctl_data *)*pbuf;
470 memcpy(*pbuf, data, sizeof(*data));
472 ptr = overlay->ioc_bulk;
473 if (data->ioc_inlbuf1)
474 LOGL(data->ioc_inlbuf1, data->ioc_inllen1, ptr);
475 if (data->ioc_inlbuf2)
476 LOGL(data->ioc_inlbuf2, data->ioc_inllen2, ptr);
477 if (obd_ioctl_is_invalid(overlay))
485 /* buffer MUST be at least the size of obd_ioctl_hdr */
486 static inline int obd_ioctl_getdata(char *buf, char *end, void *arg)
488 struct obd_ioctl_hdr *hdr;
489 struct obd_ioctl_data *data;
493 hdr = (struct obd_ioctl_hdr *)buf;
494 data = (struct obd_ioctl_data *)buf;
496 err = copy_from_user(buf, (void *)arg, sizeof(*hdr));
502 if (hdr->ioc_version != OBD_IOCTL_VERSION) {
503 printk("OBD: version mismatch kernel vs application\n");
507 if (hdr->ioc_len + buf >= end) {
508 printk("OBD: user buffer exceeds kernel buffer\n");
513 if (hdr->ioc_len < sizeof(struct obd_ioctl_data)) {
514 printk("OBD: user buffer too small for ioctl\n");
518 err = copy_from_user(buf, (void *)arg, hdr->ioc_len);
524 if (obd_ioctl_is_invalid(data)) {
525 printk("OBD: ioctl not correctly formatted\n");
529 if (data->ioc_inllen1) {
530 data->ioc_inlbuf1 = &data->ioc_bulk[0];
533 if (data->ioc_inllen2) {
534 data->ioc_inlbuf2 = &data->ioc_bulk[0] + size_round(data->ioc_inllen1);
543 #define OBD_IOC_CREATE _IOR ('f', 101, long)
544 #define OBD_IOC_SETUP _IOW ('f', 102, long)
545 #define OBD_IOC_CLEANUP _IO ('f', 103 )
546 #define OBD_IOC_DESTROY _IOW ('f', 104, long)
547 #define OBD_IOC_PREALLOCATE _IOWR('f', 105, long)
548 #define OBD_IOC_DEC_USE_COUNT _IO ('f', 106 )
549 #define OBD_IOC_SETATTR _IOW ('f', 107, long)
550 #define OBD_IOC_GETATTR _IOR ('f', 108, long)
551 #define OBD_IOC_READ _IOWR('f', 109, long)
552 #define OBD_IOC_WRITE _IOWR('f', 110, long)
553 #define OBD_IOC_CONNECT _IOR ('f', 111, long)
554 #define OBD_IOC_DISCONNECT _IOW ('f', 112, long)
555 #define OBD_IOC_STATFS _IOWR('f', 113, long)
556 #define OBD_IOC_SYNC _IOR ('f', 114, long)
557 #define OBD_IOC_READ2 _IOWR('f', 115, long)
558 #define OBD_IOC_FORMAT _IOWR('f', 116, long)
559 #define OBD_IOC_PARTITION _IOWR('f', 117, long)
560 #define OBD_IOC_ATTACH _IOWR('f', 118, long)
561 #define OBD_IOC_DETACH _IOWR('f', 119, long)
562 #define OBD_IOC_COPY _IOWR('f', 120, long)
563 #define OBD_IOC_MIGR _IOWR('f', 121, long)
564 #define OBD_IOC_PUNCH _IOWR('f', 122, long)
565 #define OBD_IOC_DEVICE _IOWR('f', 123, long)
566 #define OBD_IOC_MODULE_DEBUG _IOWR('f', 124, long)
567 #define OBD_IOC_BRW_READ _IOWR('f', 125, long)
568 #define OBD_IOC_BRW_WRITE _IOWR('f', 126, long)
569 #define OBD_IOC_NAME2DEV _IOWR('f', 127, long)
570 #define OBD_IOC_NEWDEV _IOWR('f', 128, long)
572 #define OBD_IOC_RECOVD_NEWCONN _IOWR('f', 131, long)
574 #define OBD_IOC_DEC_FS_USE_COUNT _IO ('f', 132 )