Whamcloud - gitweb
Land b_smallfix onto HEAD (20040512_1806)
[fs/lustre-release.git] / lustre / include / lustre / lustre_user.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  * Lustre public user-space interface definitions.
22  */
23
24 #ifndef _LUSTRE_USER_H
25 #define _LUSTRE_USER_H
26 #include <asm/types.h>
27 #ifdef __KERNEL__
28 #include <linux/string.h>
29 #else
30 #include <string.h>
31 #endif
32
33 #define LL_IOC_GETFLAGS                 _IOR ('f', 151, long)
34 #define LL_IOC_SETFLAGS                 _IOW ('f', 152, long)
35 #define LL_IOC_CLRFLAGS                 _IOW ('f', 153, long)
36 #define LL_IOC_LOV_SETSTRIPE            _IOW ('f', 154, long)
37 #define LL_IOC_LOV_GETSTRIPE            _IOW ('f', 155, long)
38 #define LL_IOC_LOV_SETEA                _IOW ('f', 156, long)
39 #define LL_IOC_RECREATE_OBJ             _IOW ('f', 157, long)
40 #define LL_IOC_GROUP_LOCK               _IOW ('f', 158, long)
41 #define LL_IOC_GROUP_UNLOCK             _IOW ('f', 159, long)
42
43 #define IOC_MDC_TYPE            'i'
44 #define IOC_MDC_GETSTRIPE       _IOWR(IOC_MDC_TYPE, 21, struct lov_mds_md *)
45
46 #define O_LOV_DELAY_CREATE 0100000000  /* hopefully this does not conflict */
47
48 #define LL_FILE_IGNORE_LOCK             0x00000001
49 #define LL_FILE_GROUP_LOCKED            0x00000002
50
51 #define LOV_USER_MAGIC_V1 0x0BD10BD0
52 #define LOV_USER_MAGIC    LOV_USER_MAGIC_V1
53
54 #define LOV_PATTERN_RAID0 0x001
55 #define LOV_PATTERN_RAID1 0x002
56 #define LOV_PATTERN_FIRST 0x100
57
58 #define lov_user_ost_data lov_user_ost_data_v1
59 struct lov_user_ost_data_v1 {     /* per-stripe data structure */
60         __u64 l_object_id;        /* OST object ID */
61         __u64 l_object_gr;        /* OST object group (creating MDS number) */
62         __u32 l_ost_gen;          /* generation of this OST index */
63         __u32 l_ost_idx;          /* OST index in LOV */
64 } __attribute__((packed));
65
66 #define lov_user_md lov_user_md_v1
67 struct lov_user_md_v1 {           /* LOV EA user data (host-endian) */
68         __u32 lmm_magic;          /* magic number = LOV_USER_MAGIC_V1 */
69         __u32 lmm_pattern;        /* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */
70         __u64 lmm_object_id;      /* LOV object ID */
71         __u64 lmm_object_gr;      /* LOV object group */
72         __u32 lmm_stripe_size;    /* size of stripe in bytes */
73         __u16 lmm_stripe_count;   /* num stripes in use for this object */
74         __u16 lmm_stripe_offset;  /* starting stripe offset in lmm_objects */
75         struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */
76 } __attribute__((packed));
77
78 struct ll_recreate_obj {
79         __u64 lrc_id;
80         __u32 lrc_ost_idx;
81 };
82
83 struct obd_uuid {
84         __u8 uuid[40];
85 };
86
87 static inline int obd_uuid_equals(struct obd_uuid *u1, struct obd_uuid *u2)
88 {
89         return strcmp(u1->uuid, u2->uuid) == 0;
90 }
91
92 static inline void obd_str2uuid(struct obd_uuid *uuid, char *tmp)
93 {
94         strncpy(uuid->uuid, tmp, sizeof(*uuid));
95         uuid->uuid[sizeof(*uuid) - 1] = '\0';
96 }
97
98 #endif /* _LUSTRE_USER_H */