lustre_idl.h 122 KB
Newer Older
1
/*
kalpak's avatar
   
kalpak committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 * GPL HEADER START
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 only,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License version 2 for more details (a copy is included
 * in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU General Public License
kalpak's avatar
   
kalpak committed
17
 * version 2 along with this program; If not, see
18
 * http://www.gnu.org/licenses/gpl-2.0.html
kalpak's avatar
   
kalpak committed
19
20
21
22
 *
 * GPL HEADER END
 */
/*
23
 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
kalpak's avatar
   
kalpak committed
24
 * Use is subject to license terms.
25
 *
26
 * Copyright (c) 2011, 2017, Intel Corporation.
27
 */
kalpak's avatar
   
kalpak committed
28
29
30
31
/*
 * This file is part of Lustre, http://www.lustre.org/
 * Lustre is a trademark of Sun Microsystems, Inc.
 *
nathan's avatar
nathan committed
32
 * Lustre wire protocol definitions.
33
34
35
 */

/** \defgroup lustreidl lustreidl
nathan's avatar
nathan committed
36
 *
37
 * Lustre wire protocol definitions.
tappro's avatar
tappro committed
38
 *
nathan's avatar
nathan committed
39
40
41
42
 * ALL structs passing over the wire should be declared here.  Structs
 * that are used in interfaces with userspace should go in lustre_user.h.
 *
 * All structs being declared here should be built from simple fixed-size
43
 * types defined in linux/types.h or be built from other types or
nathan's avatar
nathan committed
44
45
46
47
48
 * structs also declared in this file.  Similarly, all flags and magic
 * values in those structs should also be declared here.  This ensures
 * that the Lustre wire protocol is not influenced by external dependencies.
 *
 * The only other acceptable items in this file are VERY SIMPLE accessor
49
 * functions to avoid callers grubbing inside the structures. Nothing that
nathan's avatar
nathan committed
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 * depends on external functions or definitions should be in here.
 *
 * Structs must be properly aligned to put 64-bit values on an 8-byte
 * boundary.  Any structs being added here must also be added to
 * utils/wirecheck.c and "make newwiretest" run to regenerate the
 * utils/wiretest.c sources.  This allows us to verify that wire structs
 * have the proper alignment/size on all architectures.
 *
 * DO NOT CHANGE any of the structs, flags, values declared here and used
 * in released Lustre versions.  Some structs may have padding fields that
 * can be used.  Some structs might allow addition at the end (verify this
 * in the code to ensure that new/old clients that see this larger struct
 * do not fail, otherwise you need to implement protocol compatibility).
 *
64
 * @{
nathan's avatar
nathan committed
65
66
67
68
69
 */

#ifndef _LUSTRE_IDL_H_
#define _LUSTRE_IDL_H_

70
#include <asm/byteorder.h>
71
#include <linux/errno.h>
72
#include <linux/fiemap.h>
73
#include <linux/types.h>
74
#include <linux/lnet/lnet-types.h>
75
76
#include <linux/lustre/lustre_user.h>
#include <linux/lustre/lustre_ver.h>
77

78
79
80
81
#if defined(__cplusplus)
extern "C" {
#endif

nathan's avatar
nathan committed
82
83
84
85
86
87
88
89
90
91
/*
 *  GENERAL STUFF
 */
/* FOO_REQUEST_PORTAL is for incoming requests on the FOO
 * FOO_REPLY_PORTAL   is for incoming replies on the FOO
 * FOO_BULK_PORTAL    is for incoming bulk on the FOO
 */

#define CONNMGR_REQUEST_PORTAL          1
#define CONNMGR_REPLY_PORTAL            2
92
/* #define OSC_REQUEST_PORTAL		 3*/
nathan's avatar
nathan committed
93
#define OSC_REPLY_PORTAL                4
94
/*#define OSC_BULK_PORTAL		 5*/
nathan's avatar
nathan committed
95
96
97
#define OST_IO_PORTAL                   6
#define OST_CREATE_PORTAL               7
#define OST_BULK_PORTAL                 8
98
/*#define MDC_REQUEST_PORTAL		 9*/
nathan's avatar
nathan committed
99
#define MDC_REPLY_PORTAL               10
100
/*#define MDC_BULK_PORTAL		11*/
nathan's avatar
nathan committed
101
#define MDS_REQUEST_PORTAL             12
102
#define MDS_IO_PORTAL			13
nathan's avatar
nathan committed
103
104
105
106
107
#define MDS_BULK_PORTAL                14
#define LDLM_CB_REQUEST_PORTAL         15
#define LDLM_CB_REPLY_PORTAL           16
#define LDLM_CANCEL_REQUEST_PORTAL     17
#define LDLM_CANCEL_REPLY_PORTAL       18
108
109
110
/*#define PTLBD_REQUEST_PORTAL		19*/
/*#define PTLBD_REPLY_PORTAL		20*/
/*#define PTLBD_BULK_PORTAL		21*/
nathan's avatar
nathan committed
111
112
#define MDS_SETATTR_PORTAL             22
#define MDS_READPAGE_PORTAL            23
113
#define OUT_PORTAL			24
nathan's avatar
nathan committed
114
115
116
117
#define MGC_REPLY_PORTAL               25
#define MGS_REQUEST_PORTAL             26
#define MGS_REPLY_PORTAL               27
#define OST_REQUEST_PORTAL             28
tappro's avatar
tappro committed
118
119
120
121
#define FLD_REQUEST_PORTAL             29
#define SEQ_METADATA_PORTAL            30
#define SEQ_DATA_PORTAL                31
#define SEQ_CONTROLLER_PORTAL          32
122
#define MGS_BULK_PORTAL                33
123
124
/* #define DVS_PORTAL			63 */
/* reserved for Cray DVS - spitzcor@cray.com, roe@cray.com, n8851@cray.com */
nathan's avatar
nathan committed
125

pravins's avatar
b=15957    
pravins committed
126
127
128
/**
 * Describes a range of sequence, lsr_start is included but lsr_end is
 * not in the range.
129
 * Same structure is used in fld module where lsr_index field holds mdt id
pravins's avatar
b=15957    
pravins committed
130
131
132
 * of the home mdt.
 */
struct lu_seq_range {
133
134
135
136
	__u64 lsr_start;
	__u64 lsr_end;
	__u32 lsr_index;
	__u32 lsr_flags;
tappro's avatar
tappro committed
137
138
};

139
140
141
142
143
144
struct lu_seq_range_array {
	__u32 lsra_count;
	__u32 lsra_padding;
	struct lu_seq_range lsra_lsr[0];
};

145
146
147
148
149
150
#define LU_SEQ_RANGE_MDT	0x0
#define LU_SEQ_RANGE_OST	0x1
#define LU_SEQ_RANGE_ANY	0x3

#define LU_SEQ_RANGE_MASK	0x3

151
152
153
/** \defgroup lu_fid lu_fid
 * @{ */

154
155
extern void lustre_lma_swab(struct lustre_mdt_attrs *lma);
extern void lustre_lma_init(struct lustre_mdt_attrs *lma,
Fan Yong's avatar
Fan Yong committed
156
157
			    const struct lu_fid *fid,
			    __u32 compat, __u32 incompat);
158
159
160
161
162
extern void lustre_loa_swab(struct lustre_ost_attrs *loa,
			    bool to_cpu);
extern void lustre_loa_init(struct lustre_ost_attrs *loa,
			    const struct lu_fid *fid,
			    __u32 compat, __u32 incompat);
nathan's avatar
b=19669    
nathan committed
163

164
165
/* copytool can use any nonnegative integer to represent archive-Ids during
 * register with MDT thru kuc.
166
 * archive num = 0 => all
167
 * archive num from 1 to MAX_U32
168
 */
169
170
171
#define LL_HSM_ORIGIN_MAX_ARCHIVE	(sizeof(__u32) * 8)
/* the max count of archive ids that one agent can support */
#define LL_HSM_MAX_ARCHIVES_PER_AGENT	1024
172

nathan's avatar
b=19669    
nathan committed
173
/**
174
 * HSM on-disk attributes stored in a separate xattr.
nathan's avatar
b=19669    
nathan committed
175
 */
176
177
178
179
180
181
182
183
184
185
struct hsm_attrs {
	/** Bitfield for supported data in this structure. For future use. */
	__u32	hsm_compat;

	/** HSM flags, see hsm_flags enum below */
	__u32	hsm_flags;
	/** backend archive id associated with the file */
	__u64	hsm_arch_id;
	/** version associated with the last archiving, if any */
	__u64	hsm_arch_ver;
nathan's avatar
b=19669    
nathan committed
186
};
187
extern void lustre_hsm_swab(struct hsm_attrs *attrs);
nathan's avatar
b=19669    
nathan committed
188

189
/**
tappro's avatar
tappro committed
190
191
 * fid constants
 */
192
enum {
193
194
	/** LASTID file has zero OID */
	LUSTRE_FID_LASTID_OID = 0UL,
195
        /** initial fid id value */
tappro's avatar
tappro committed
196
197
198
        LUSTRE_FID_INIT_OID  = 1UL
};

199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/**
 * Different FID Format
 * http://arch.lustre.org/index.php?title=Interoperability_fids_zfs#NEW.0
 *
 * FID:
 * File IDentifier generated by client from range allocated by the seq service.
 * First 0x400 sequences [2^33, 2^33 + 0x400] are reserved for system use. Note
 * that on ldiskfs MDTs that IGIF FIDs can use inode numbers starting at 12,
 * but this is in the IGIF SEQ rangeand does not conflict with assigned FIDs.
 *
 * IGIF:
 * Inode and Generation In FID, a surrogate FID used to globally identify an
 * existing object on OLD formatted MDT file system. This would only be used on
 * MDT0 in a DNE filesystem, because there are not expected to be any OLD
 * formatted DNE filesystems. Belongs to a sequence in [12, 2^32 - 1] range,
 * where sequence number is inode number, and inode generation is used as OID.
 * NOTE: This assumes no more than 2^32-1 inodes exist in the MDT filesystem,
 * which is the maximum possible for an ldiskfs backend. NOTE: This assumes
 * that the reserved ext3/ext4/ldiskfs inode numbers [0-11] are never visible
 * to clients, which has always been true.
 *
 * IDIF:
 * Object ID in FID, a surrogate FID used to globally identify an existing
 * object on OLD formatted OST file system. Belongs to a sequence in
 * [2^32, 2^33 - 1]. Sequence number is calculated as:
 *	1 << 32 | (ost_index << 16) | ((objid >> 32) & 0xffff)
 * that is, SEQ consists of 16-bit OST index, and higher 16 bits of object ID.
 * The generation of unique SEQ values per OST allows the IDIF FIDs to be
 * identified in the FLD correctly. The OID field is calculated as:
 *	objid & 0xffffffff
 * that is, it consists of lower 32 bits of object ID. NOTE This assumes that
 * no more than 2^48-1 objects have ever been created on an OST, and that no
 * more than 65535 OSTs are in use. Both are very reasonable assumptions (can
 * uniquely map all objects on an OST that created 1M objects per second for 9
 * years, or combinations thereof).
 *
 * OST_MDT0:
 * Surrogate FID used to identify an existing object on OLD formatted OST
 * filesystem. Belongs to the reserved sequence 0, and is used internally prior
 * to the introduction of FID-on-OST, at which point IDIF will be used to
 * identify objects as residing on a specific OST.
 *
 * LLOG:
 * For Lustre Log objects the object sequence 1 is used. This is compatible with
 * both OLD and NEW.1 namespaces, as this SEQ number is in the ext3/ldiskfs
 * reserved inode range and does not conflict with IGIF sequence numbers.
 *
 * ECHO:
 * For testing OST IO performance the object sequence 2 is used. This is
 * compatible with both OLD and NEW.1 namespaces, as this SEQ number is in the
 * ext3/ldiskfs reserved inode range and does not conflict with IGIF sequence
 * numbers.
 *
 * OST_MDT1 .. OST_MAX:
 * For testing with multiple MDTs the object sequence 3 through 9 is used,
 * allowing direct mapping of MDTs 1 through 7 respectively, for a total of 8
 * MDTs including OST_MDT0. This matches the legacy CMD project "group"
 * mappings. However, this SEQ range is only for testing prior to any production
 * DNE release, as the objects in this range conflict across all OSTs, as the
 * OST index is not part of the FID.
 *
 *
 * For compatibility with existing OLD OST network protocol structures, the FID
 * must map onto the o_id and o_gr in a manner that ensures existing objects are
 * identified consistently for IO, as well as onto the lock namespace to ensure
 * both IDIFs map onto the same objects for IO as well as resources in the DLM.
 *
 * DLM OLD OBIF/IDIF:
 * resource[] = {o_id, o_seq, 0, 0};  // o_seq == 0 for production releases
 *
 * DLM NEW.1 FID (this is the same for both the MDT and OST):
 * resource[] = {SEQ, OID, VER, HASH};
 *
 * Note that for mapping IDIF values to DLM resource names the o_id may be
 * larger than the 2^33 reserved sequence numbers for IDIF, so it is possible
 * for the o_id numbers to overlap FID SEQ numbers in the resource. However, in
 * all production releases the OLD o_seq field is always zero, and all valid FID
 * OID values are non-zero, so the lock resources will not collide.
 *
 * For objects within the IDIF range, group extraction (non-CMD) will be:
 * o_id = (fid->f_seq & 0x7fff) << 16 | fid->f_oid;
 * o_seq = 0;  // formerly group number
 */

283
/**
Rahul Deshmukh's avatar
Rahul Deshmukh committed
284
285
286
 * Note that reserved SEQ numbers below 12 will conflict with ldiskfs
 * inodes in the IGIF namespace, so these reserved SEQ numbers can be
 * used for other purposes and not risk collisions with existing inodes.
287
288
 */
enum fid_seq {
289
	FID_SEQ_OST_MDT0	= 0,
290
	FID_SEQ_LLOG		= 1, /* unnamed llogs */
291
	FID_SEQ_ECHO		= 2,
292
293
	FID_SEQ_UNUSED_START	= 3,
	FID_SEQ_UNUSED_END	= 9,
294
	FID_SEQ_LLOG_NAME	= 10, /* named llogs */
295
296
297
298
299
300
301
	FID_SEQ_RSVD		= 11,
	FID_SEQ_IGIF		= 12,
	FID_SEQ_IGIF_MAX	= 0x0ffffffffULL,
	FID_SEQ_IDIF		= 0x100000000ULL,
	FID_SEQ_IDIF_MAX	= 0x1ffffffffULL,
	/* Normal FID sequence starts from this value, i.e. 1<<33 */
	FID_SEQ_START		= 0x200000000ULL,
302
	/* sequence for local pre-defined FIDs listed in local_oid */
303
304
	FID_SEQ_LOCAL_FILE	= 0x200000001ULL,
	FID_SEQ_DOT_LUSTRE	= 0x200000002ULL,
305
306
	/* sequence is used for local named objects FIDs generated
	 * by local_object_storage library */
307
308
309
310
311
312
313
314
315
	FID_SEQ_LOCAL_NAME	= 0x200000003ULL,
	/* Because current FLD will only cache the fid sequence, instead
	 * of oid on the client side, if the FID needs to be exposed to
	 * clients sides, it needs to make sure all of fids under one
	 * sequence will be located in one MDT. */
	FID_SEQ_SPECIAL		= 0x200000004ULL,
	FID_SEQ_QUOTA		= 0x200000005ULL,
	FID_SEQ_QUOTA_GLB	= 0x200000006ULL,
	FID_SEQ_ROOT		= 0x200000007ULL,  /* Located on MDT0 */
316
	FID_SEQ_LAYOUT_RBTREE	= 0x200000008ULL,
317
318
319
320
321
	/* sequence is used for update logs of cross-MDT operation */
	FID_SEQ_UPDATE_LOG	= 0x200000009ULL,
	/* Sequence is used for the directory under which update logs
	 * are created. */
	FID_SEQ_UPDATE_LOG_DIR	= 0x20000000aULL,
322
323
	FID_SEQ_NORMAL		= 0x200000400ULL,
	FID_SEQ_LOV_DEFAULT	= 0xffffffffffffffffULL
324
325
326
327
328
329
330
331
332
};

#define OBIF_OID_MAX_BITS           32
#define OBIF_MAX_OID                (1ULL << OBIF_OID_MAX_BITS)
#define OBIF_OID_MASK               ((1ULL << OBIF_OID_MAX_BITS) - 1)
#define IDIF_OID_MAX_BITS           48
#define IDIF_MAX_OID                (1ULL << IDIF_OID_MAX_BITS)
#define IDIF_OID_MASK               ((1ULL << IDIF_OID_MAX_BITS) - 1)

333
334
335
336
337
338
339
340
/** OID for FID_SEQ_SPECIAL */
enum special_oid {
        /* Big Filesystem Lock to serialize rename operations */
        FID_OID_SPECIAL_BFL     = 1UL,
};

/** OID for FID_SEQ_DOT_LUSTRE */
enum dot_lustre_oid {
341
342
343
	FID_OID_DOT_LUSTRE	= 1UL,
	FID_OID_DOT_LUSTRE_OBF	= 2UL,
	FID_OID_DOT_LUSTRE_LPF	= 3UL,
344
};
345

346
347
348
349
350
351
/** OID for FID_SEQ_ROOT */
enum root_oid {
	FID_OID_ROOT		= 1UL,
	FID_OID_ECHO_ROOT	= 2UL,
};

352
353
354
355
356
357
358
359
360
361
362
363
364
struct lu_orphan_rec {
	/* The MDT-object's FID referenced by the orphan OST-object */
	struct lu_fid	lor_fid;
	__u32		lor_uid;
	__u32		lor_gid;
};

struct lu_orphan_ent {
	/* The orphan OST-object's FID */
	struct lu_fid		loe_key;
	struct lu_orphan_rec	loe_rec;
};

365
366
367
368
369
370
371
372
373
374
375
376
struct lu_orphan_rec_v2 {
	struct lu_orphan_rec	lor_rec;
	struct ost_layout	lor_layout;
	__u32			lor_padding;
};

struct lu_orphan_ent_v2 {
	/* The orphan OST-object's FID */
	struct lu_fid		loe_key;
	struct lu_orphan_rec_v2	loe_rec;
};

377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
struct lu_orphan_rec_v3 {
	struct lu_orphan_rec	lor_rec;
	struct ost_layout	lor_layout;
	/* The OST-object declared layout version in PFID EA.*/
	__u32			lor_layout_version;
	/* The OST-object declared layout range (of version) in PFID EA.*/
	__u32			lor_range;
	__u32			lor_padding_1;
	__u64			lor_padding_2;
};

struct lu_orphan_ent_v3 {
	/* The orphan OST-object's FID */
	struct lu_fid		loe_key;
	struct lu_orphan_rec_v3	loe_rec;
};

394
395
396
397
/** @} lu_fid */

/** \defgroup lu_dir lu_dir
 * @{ */
pravins's avatar
b=15134    
pravins committed
398
399
400
401
402
403
404
405

/**
 * Enumeration of possible directory entry attributes.
 *
 * Attributes follow directory entry header in the order they appear in this
 * enumeration.
 */
enum lu_dirent_attrs {
406
407
408
409
	LUDA_FID		= 0x0001,
	LUDA_TYPE		= 0x0002,
	LUDA_64BITHASH		= 0x0004,

410
	/* The following attrs are used for MDT internal only,
411
412
	 * not visible to client */

413
414
	/* Something in the record is unknown, to be verified in further. */
	LUDA_UNKNOWN		= 0x0400,
415
416
	/* Ignore this record, go to next directly. */
	LUDA_IGNORE		= 0x0800,
417
418
419
420
421
422
423
424
	/* The system is upgraded, has beed or to be repaired (dryrun). */
	LUDA_UPGRADE		= 0x1000,
	/* The dirent has been repaired, or to be repaired (dryrun). */
	LUDA_REPAIR		= 0x2000,
	/* Only check but not repair the dirent inconsistency */
	LUDA_VERIFY_DRYRUN	= 0x4000,
	/* Verify the dirent consistency */
	LUDA_VERIFY		= 0x8000,
pravins's avatar
b=15134    
pravins committed
425
426
};

427
#define LU_DIRENT_ATTRS_MASK	0xff00
428

429
/**
tappro's avatar
tappro committed
430
431
432
 * Layout of readdir pages, as transmitted on wire.
 */
struct lu_dirent {
pravins's avatar
b=15134    
pravins committed
433
        /** valid if LUDA_FID is set. */
tappro's avatar
tappro committed
434
        struct lu_fid lde_fid;
pravins's avatar
b=15134    
pravins committed
435
        /** a unique entry identifier: a hash or an offset. */
pravins's avatar
b=14340    
pravins committed
436
        __u64         lde_hash;
pravins's avatar
b=15134    
pravins committed
437
        /** total record length, including all attributes. */
tappro's avatar
tappro committed
438
        __u16         lde_reclen;
pravins's avatar
b=15134    
pravins committed
439
        /** name length */
tappro's avatar
tappro committed
440
        __u16         lde_namelen;
pravins's avatar
b=15134    
pravins committed
441
442
443
444
445
446
447
448
        /** optional variable size attributes following this entry.
         *  taken from enum lu_dirent_attrs.
         */
        __u32         lde_attrs;
        /** name is followed by the attributes indicated in ->ldp_attrs, in
         *  their natural order. After the last attribute, padding bytes are
         *  added to make ->lde_reclen a multiple of 8.
         */
tappro's avatar
tappro committed
449
450
451
        char          lde_name[0];
};

pravins's avatar
b=15134    
pravins committed
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
/*
 * Definitions of optional directory entry attributes formats.
 *
 * Individual attributes do not have their length encoded in a generic way. It
 * is assumed that consumer of an attribute knows its format. This means that
 * it is impossible to skip over an unknown attribute, except by skipping over all
 * remaining attributes (by using ->lde_reclen), which is not too
 * constraining, because new server versions will append new attributes at
 * the end of an entry.
 */

/**
 * Fid directory attribute: a fid of an object referenced by the entry. This
 * will be almost always requested by the client and supplied by the server.
 *
 * Aligned to 8 bytes.
 */
/* To have compatibility with 1.8, lets have fid in lu_dirent struct. */

/**
 * File type.
 *
 * Aligned to 2 bytes.
 */
struct luda_type {
        __u16 lt_type;
};

tappro's avatar
tappro committed
480
struct lu_dirpage {
pravins's avatar
b=14340    
pravins committed
481
482
        __u64            ldp_hash_start;
        __u64            ldp_hash_end;
yury's avatar
b=13934    
yury committed
483
        __u32            ldp_flags;
tappro's avatar
tappro committed
484
485
486
487
488
        __u32            ldp_pad0;
        struct lu_dirent ldp_entries[0];
};

enum lu_dirpage_flags {
489
490
491
492
493
494
495
496
        /**
         * dirpage contains no entry.
         */
        LDF_EMPTY   = 1 << 0,
        /**
         * last entry's lde_hash equals ldp_hash_end.
         */
        LDF_COLLIDE = 1 << 1
tappro's avatar
tappro committed
497
498
499
500
};

static inline struct lu_dirent *lu_dirent_start(struct lu_dirpage *dp)
{
501
502
503
504
	if (__le32_to_cpu(dp->ldp_flags) & LDF_EMPTY)
		return NULL;
	else
		return dp->ldp_entries;
tappro's avatar
tappro committed
505
506
507
508
}

static inline struct lu_dirent *lu_dirent_next(struct lu_dirent *ent)
{
509
	struct lu_dirent *next;
tappro's avatar
tappro committed
510

511
512
513
514
	if (__le16_to_cpu(ent->lde_reclen) != 0)
		next = ((void *)ent) + __le16_to_cpu(ent->lde_reclen);
	else
		next = NULL;
tappro's avatar
tappro committed
515

516
	return next;
tappro's avatar
tappro committed
517
518
}

519
static inline __kernel_size_t lu_dirent_calc_size(size_t namelen, __u16 attr)
pravins's avatar
b=15134    
pravins committed
520
{
521
	__kernel_size_t size;
pravins's avatar
b=15134    
pravins committed
522

523
	if (attr & LUDA_TYPE) {
524
		const __kernel_size_t align = sizeof(struct luda_type) - 1;
pravins's avatar
b=15134    
pravins committed
525

526
527
528
529
530
531
532
533
		size = (sizeof(struct lu_dirent) + namelen + 1 + align) &
		       ~align;
		size += sizeof(struct luda_type);
	} else {
		size = sizeof(struct lu_dirent) + namelen + 1;
	}

	return (size + 7) & ~7;
pravins's avatar
b=15134    
pravins committed
534
535
}

536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
static inline __u16 lu_dirent_type_get(struct lu_dirent *ent)
{
	__u16 type = 0;
	struct luda_type *lt;
	int len = 0;

	if (__le32_to_cpu(ent->lde_attrs) & LUDA_TYPE) {
		const unsigned int align = sizeof(struct luda_type) - 1;

		len = __le16_to_cpu(ent->lde_namelen);
		len = (len + align) & ~align;
		lt = (void *)ent->lde_name + len;
		type = __le16_to_cpu(lt->lt_type);
	}

	return type;
}

554
#define MDS_DIR_END_OFF 0xfffffffffffffffeULL
tappro's avatar
tappro committed
555

556
557
558
559
/**
 * MDS_READPAGE page size
 *
 * This is the directory page size packed in MDS_READPAGE RPC.
560
 * It's different than PAGE_SIZE because the client needs to
561
562
 * access the struct lu_dirpage header packed at the beginning of
 * the "page" and without this there isn't any way to know find the
563
 * lu_dirpage header is if client and server PAGE_SIZE differ.
564
565
566
567
568
 */
#define LU_PAGE_SHIFT 12
#define LU_PAGE_SIZE  (1UL << LU_PAGE_SHIFT)
#define LU_PAGE_MASK  (~(LU_PAGE_SIZE - 1))

569
#define LU_PAGE_COUNT (1 << (PAGE_SHIFT - LU_PAGE_SHIFT))
570

571
572
/** @} lu_dir */

nathan's avatar
nathan committed
573
574
575
576
577
struct lustre_handle {
        __u64 cookie;
};
#define DEAD_HANDLE_MAGIC 0xdeadbeefcafebabeULL

578
static inline bool lustre_handle_is_used(const struct lustre_handle *lh)
nathan's avatar
nathan committed
579
{
580
	return lh->cookie != 0;
nathan's avatar
nathan committed
581
582
}

583
584
static inline bool lustre_handle_equal(const struct lustre_handle *lh1,
				       const struct lustre_handle *lh2)
nathan's avatar
nathan committed
585
{
586
	return lh1->cookie == lh2->cookie;
nathan's avatar
nathan committed
587
588
589
}

static inline void lustre_handle_copy(struct lustre_handle *tgt,
590
				      const struct lustre_handle *src)
nathan's avatar
nathan committed
591
{
592
	tgt->cookie = src->cookie;
nathan's avatar
nathan committed
593
594
}

595
/* lustre_msg struct magic.  DON'T use swabbed values of MAGIC as magic! */
596
597
598
599
600
enum lustre_msg_magic {
	LUSTRE_MSG_MAGIC_V2		= 0x0BD00BD3,
	LUSTRE_MSG_MAGIC_V2_SWABBED	= 0xD30BD00B,
	LUSTRE_MSG_MAGIC		= LUSTRE_MSG_MAGIC_V2
};
ericm's avatar
ericm committed
601

602
/* flags for lm_flags */
603
604
enum lustre_msghdr {
	MSGHDR_AT_SUPPORT	= 0x1,	/* adaptive timeouts, lm_cksum valid
605
					 * in early reply messages */
606
	MSGHDR_CKSUM_INCOMPAT18	= 0x2,	/* compat for 1.8, needs to be set well
607
					 * beyond 2.8.0 for compatibility */
608
609
};

nathan's avatar
nathan committed
610
611
612
613
#define lustre_msg lustre_msg_v2
/* we depend on this structure to be 8-byte aligned */
/* this type is only endian-adjusted in lustre_unpack_msg() */
struct lustre_msg_v2 {
614
615
616
617
618
	__u32 lm_bufcount;	/* number of buffers in lm_buflens[] */
	__u32 lm_secflvr;	/* 0 = no crypto, or sptlrpc security flavour */
	__u32 lm_magic;		/* RPC version magic = LUSTRE_MSG_MAGIC_V2 */
	__u32 lm_repsize;	/* size of preallocated reply buffer */
	__u32 lm_cksum;		/* CRC32 of ptlrpc_body early reply messages */
619
	__u32 lm_flags;		/* enum lustre_msghdr MSGHDR_* flags */
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
	__u32 lm_padding_2;	/* unused */
	__u32 lm_padding_3;	/* unused */
	__u32 lm_buflens[0];	/* length of additional buffers in bytes,
				 * padded to a multiple of 8 bytes. */
	/*
	 * message buffers are packed after padded lm_buflens[] array,
	 * padded to a multiple of 8 bytes each to align contents.
	 */
};

/* ptlrpc_body packet pb_types */
#define PTL_RPC_MSG_REQUEST	4711	/* normal RPC request message */
#define PTL_RPC_MSG_ERR		4712	/* error reply if request unprocessed */
#define PTL_RPC_MSG_REPLY	4713	/* normal RPC reply message */

/* ptlrpc_body pb_version ((target_version << 16) | rpc_version) */
636
637
638
639
640
641
642
643
644
645
enum lustre_msg_version {
	PTLRPC_MSG_VERSION	= 0x00000003,
	LUSTRE_VERSION_MASK	= 0xffff0000,
	LUSTRE_OBD_VERSION	= 0x00010000,
	LUSTRE_MDS_VERSION	= 0x00020000,
	LUSTRE_OST_VERSION	= 0x00030000,
	LUSTRE_DLM_VERSION	= 0x00040000,
	LUSTRE_LOG_VERSION	= 0x00050000,
	LUSTRE_MGS_VERSION	= 0x00060000,
};
646

647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
/* pb_flags that apply to all request messages */
/* #define MSG_LAST_REPLAY	0x0001 obsolete 2.0 => {REQ,LOCK}_REPLAY_DONE */
#define MSG_RESENT		0x0002 /* was previously sent, no reply seen */
#define MSG_REPLAY		0x0004 /* was processed, got reply, recovery */
/* #define MSG_AT_SUPPORT	0x0008 obsolete since 1.5, AT always enabled */
/* #define MSG_DELAY_REPLAY	0x0010 obsolete since 2.0 */
/* #define MSG_VERSION_REPLAY	0x0020 obsolete since 1.8.2, VBR always on */
#define MSG_REQ_REPLAY_DONE	0x0040 /* request replay over, locks next */
#define MSG_LOCK_REPLAY_DONE	0x0080 /* lock replay over, client done */

/* pb_op_flags for connect opcodes: MDS_CONNECT, OST_CONNECT, MGS_CONNECT */
#define MSG_CONNECT_RECOVERING	0x00000001 /* target is in recovery */
#define MSG_CONNECT_RECONNECT	0x00000002 /* tgt already has client import */
#define MSG_CONNECT_REPLAYABLE	0x00000004 /* target supports RPC replay */
/* #define MSG_CONNECT_PEER	0x00000008 obsolete since 1.2, removed in 1.5 */
#define MSG_CONNECT_LIBCLIENT	0x00000010 /* obsolete since 2.3, removed 2.6 */
#define MSG_CONNECT_INITIAL	0x00000020 /* first client connection attempt */
/* #define MSG_CONNECT_ASYNC	0x00000040 obsolete since 1.5 */
665
#define MSG_CONNECT_NEXT_VER	0x00000080 /* use next version of lustre_msg */
666
#define MSG_CONNECT_TRANSNO	0x00000100 /* client sent transno in replay */
667
668

/* number of previous object versions in pb_pre_versions[] */
huanghua's avatar
huanghua committed
669
#define PTLRPC_NUM_VERSIONS     4
670
/* without gss, ptlrpc_body is put at the first buffer. */
Niu Yawei's avatar
Niu Yawei committed
671
672
struct ptlrpc_body_v3 {
	struct lustre_handle pb_handle;
673
674
675
676
677
678
	__u32 pb_type;		/* request/reply/err type: PTL_RPC_MSG_* */
	__u32 pb_version;	/* LUSTRE_*_VERSION | PTLRPC_MSG_VERSION */
	__u32 pb_opc;		/* RPC opcodes: MDS_*, OST_*, LDLM_, ... */
	__u32 pb_status;	/* negative Linux x86 error number */
	__u64 pb_last_xid;	/* highest replied XID w/o lower unreplied XID*/
	__u16 pb_tag;		/* multiple modifying RPCs virtual slot index */
679
680
	__u16 pb_padding0;
	__u32 pb_padding1;
681
682
683
684
685
686
687
688
689
690
	__u64 pb_last_committed;/* rep: highest pb_transno committed to disk */
	__u64 pb_transno;	/* server-assigned transno for modifying RPCs */
	__u32 pb_flags;		/* req: MSG_* flags */
	__u32 pb_op_flags;	/* req: MSG_CONNECT_* flags */
	__u32 pb_conn_cnt;	/* connect instance of this client on server */
	__u32 pb_timeout;	/* req: max wait time; rep: service estimate */
	__u32 pb_service_time;	/* rep: server arrival to reply in seconds */
	__u32 pb_limit;		/* rep: dynamic DLM LRU lock count limit */
	__u64 pb_slv;		/* rep: dynamic DLM LRU server lock volume */
	/* VBR: rep: previous pb_version(s) of objects modified by this RPC */
Niu Yawei's avatar
Niu Yawei committed
691
	__u64 pb_pre_versions[PTLRPC_NUM_VERSIONS];
692
	__u64 pb_mbits;	/**< match bits for bulk request */
693
	/* padding for future needs - fix lustre_swab_ptlrpc_body() also */
694
695
696
	__u64 pb_padding64_0;
	__u64 pb_padding64_1;
	__u64 pb_padding64_2;
697
	char  pb_jobid[LUSTRE_JOBID_SIZE]; /* req: ASCII jobid from env + NUL */
Niu Yawei's avatar
Niu Yawei committed
698
699
700
701
};
#define ptlrpc_body     ptlrpc_body_v3

struct ptlrpc_body_v2 {
nathan's avatar
nathan committed
702
703
704
705
706
        struct lustre_handle pb_handle;
        __u32 pb_type;
        __u32 pb_version;
        __u32 pb_opc;
        __u32 pb_status;
707
708
709
710
	__u64 pb_last_xid; /* highest replied XID without lower unreplied XID */
	__u16 pb_tag;      /* virtual slot idx for multiple modifying RPCs */
	__u16 pb_padding0;
	__u32 pb_padding1;
nathan's avatar
nathan committed
711
712
713
714
715
        __u64 pb_last_committed;
        __u64 pb_transno;
        __u32 pb_flags;
        __u32 pb_op_flags;
        __u32 pb_conn_cnt;
ericm's avatar
ericm committed
716
        __u32 pb_timeout;  /* for req, the deadline, for rep, the service est */
717
718
        __u32 pb_service_time; /* for rep, actual service time, also used for
                                  net_latency of req */
yury's avatar
b=2262    
yury committed
719
720
        __u32 pb_limit;
        __u64 pb_slv;
huanghua's avatar
huanghua committed
721
722
        /* VBR: pre-versions */
        __u64 pb_pre_versions[PTLRPC_NUM_VERSIONS];
723
	__u64 pb_mbits;	/**< unused in V2 */
huanghua's avatar
huanghua committed
724
        /* padding for future needs */
725
726
727
	__u64 pb_padding64_0;
	__u64 pb_padding64_1;
	__u64 pb_padding64_2;
nathan's avatar
nathan committed
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
};

/* message body offset for lustre_msg_v2 */
/* ptlrpc body offset in all request/reply messages */
#define MSG_PTLRPC_BODY_OFF             0

/* normal request/reply message record offset */
#define REQ_REC_OFF                     1
#define REPLY_REC_OFF                   1

/* ldlm request message body offset */
#define DLM_LOCKREQ_OFF                 1 /* lockreq offset */
#define DLM_REQ_REC_OFF                 2 /* normal dlm request record offset */

/* ldlm intent lock message body offset */
#define DLM_INTENT_IT_OFF               2 /* intent lock it offset */
#define DLM_INTENT_REC_OFF              3 /* intent lock record offset */

/* ldlm reply message body offset */
#define DLM_LOCKREPLY_OFF               1 /* lockrep offset */
#define DLM_REPLY_REC_OFF               2 /* reply record offset */

pravins's avatar
b=15534    
pravins committed
750
751
752
/** only use in req->rq_{req,rep}_swab_mask */
#define MSG_PTLRPC_HEADER_OFF           31

nathan's avatar
nathan committed
753
/* Connect flags */
adilger's avatar
adilger committed
754
755
#define OBD_CONNECT_RDONLY                0x1ULL /*client has read-only access*/
#define OBD_CONNECT_INDEX                 0x2ULL /*connect specific LOV idx */
nathan's avatar
b=18798    
nathan committed
756
#define OBD_CONNECT_MDS                   0x4ULL /*connect from MDT to OST */
adilger's avatar
adilger committed
757
758
#define OBD_CONNECT_GRANT                 0x8ULL /*OSC gets grant at connect */
#define OBD_CONNECT_SRVLOCK              0x10ULL /*server takes locks for cli */
nathan's avatar
b=18798    
nathan committed
759
#define OBD_CONNECT_VERSION              0x20ULL /*Lustre versions in ocd */
adilger's avatar
adilger committed
760
#define OBD_CONNECT_REQPORTAL            0x40ULL /*Separate non-IO req portal */
nathan's avatar
b=18798    
nathan committed
761
#define OBD_CONNECT_ACL                  0x80ULL /*access control lists */
adilger's avatar
adilger committed
762
#define OBD_CONNECT_XATTR               0x100ULL /*client use extended attr */
763
#define OBD_CONNECT_LARGE_ACL		0x200ULL /* more than 32 ACL entries */
nathan's avatar
b=18798    
nathan committed
764
#define OBD_CONNECT_TRUNCLOCK           0x400ULL /*locks on server for punch */
adilger's avatar
adilger committed
765
#define OBD_CONNECT_TRANSNO             0x800ULL /*replay sends init transno */
766
#define OBD_CONNECT_IBITS	       0x1000ULL /* not checked in 2.11+ */
767
#define OBD_CONNECT_BARRIER	       0x2000ULL /* write barrier */
adilger's avatar
adilger committed
768
769
#define OBD_CONNECT_ATTRFID            0x4000ULL /*Server can GetAttr By Fid*/
#define OBD_CONNECT_NODEVOH            0x8000ULL /*No open hndl on specl nodes*/
770
771
772
773
774
775
776
777
778
779
#define OBD_CONNECT_RMT_CLIENT        0x10000ULL /* Remote client, never used
						  * in production. Removed in
						  * 2.9. Keep this flag to
						  * avoid reusing.
						  */
#define OBD_CONNECT_RMT_CLIENT_FORCE  0x20000ULL /* Remote client by force,
						  * never used in production.
						  * Removed in 2.9. Keep this
						  * flag to avoid reusing.
						  */
nathan's avatar
b=18798    
nathan committed
780
#define OBD_CONNECT_BRW_SIZE          0x40000ULL /*Max bytes per rpc */
781
#define OBD_CONNECT_QUOTA64           0x80000ULL /*Not used since 2.4 */
nathan's avatar
b=18798    
nathan committed
782
783
784
785
#define OBD_CONNECT_MDS_CAPA         0x100000ULL /*MDS capability */
#define OBD_CONNECT_OSS_CAPA         0x200000ULL /*OSS capability */
#define OBD_CONNECT_CANCELSET        0x400000ULL /*Early batched cancels. */
#define OBD_CONNECT_SOM              0x800000ULL /*Size on MDS */
adilger's avatar
adilger committed
786
#define OBD_CONNECT_AT              0x1000000ULL /*client uses AT */
nathan's avatar
b=18798    
nathan committed
787
788
#define OBD_CONNECT_LRU_RESIZE      0x2000000ULL /*LRU resize feature. */
#define OBD_CONNECT_MDS_MDS         0x4000000ULL /*MDS-MDS connection */
789
#define OBD_CONNECT_REAL            0x8000000ULL /* obsolete since 2.8 */
790
#define OBD_CONNECT_CHANGE_QS      0x10000000ULL /*Not used since 2.4 */
adilger's avatar
adilger committed
791
#define OBD_CONNECT_CKSUM          0x20000000ULL /*support several cksum algos*/
nathan's avatar
b=18798    
nathan committed
792
793
794
#define OBD_CONNECT_FID            0x40000000ULL /*FID is supported by server */
#define OBD_CONNECT_VBR            0x80000000ULL /*version based recovery */
#define OBD_CONNECT_LOV_V3        0x100000000ULL /*client supports LOV v3 EA */
wangdi's avatar
wangdi committed
795
#define OBD_CONNECT_GRANT_SHRINK  0x200000000ULL /* support grant shrink */
nathan's avatar
b=18798    
nathan committed
796
#define OBD_CONNECT_SKIP_ORPHAN   0x400000000ULL /* don't reuse orphan objids */
797
798
#define OBD_CONNECT_MAX_EASIZE    0x800000000ULL /* preserved for large EA */
#define OBD_CONNECT_FULL20       0x1000000000ULL /* it is 2.0 client */
799
#define OBD_CONNECT_LAYOUTLOCK   0x2000000000ULL /* client uses layout lock */
800
801
#define OBD_CONNECT_64BITHASH    0x4000000000ULL /* client supports 64-bits
                                                  * directory hash */
802
#define OBD_CONNECT_MAXBYTES     0x8000000000ULL /* max stripe size */
803
#define OBD_CONNECT_IMP_RECOV   0x10000000000ULL /* imp recovery support */
804
#define OBD_CONNECT_JOBSTATS    0x20000000000ULL /* jobid in ptlrpc_body */
805
806
#define OBD_CONNECT_UMASK       0x40000000000ULL /* create uses client umask */
#define OBD_CONNECT_EINPROGRESS 0x80000000000ULL /* client handles -EINPROGRESS
807
                                                  * RPC error properly */
808
809
#define OBD_CONNECT_GRANT_PARAM 0x100000000000ULL/* extra grant params used for
                                                  * finer space reservation */
810
811
#define OBD_CONNECT_FLOCK_OWNER 0x200000000000ULL /* for the fixed 1.8
						   * policy and 2.x server */
812
#define OBD_CONNECT_LVB_TYPE	0x400000000000ULL /* variable type of LVB */
813
#define OBD_CONNECT_NANOSEC_TIME 0x800000000000ULL /* nanosecond timestamps */
814
#define OBD_CONNECT_LIGHTWEIGHT 0x1000000000000ULL/* lightweight connection */
815
#define OBD_CONNECT_SHORTIO     0x2000000000000ULL/* short io */
816
#define OBD_CONNECT_PINGLESS	0x4000000000000ULL/* pings not required */
817
#define OBD_CONNECT_FLOCK_DEAD	0x8000000000000ULL/* improved flock deadlock detection */
818
#define OBD_CONNECT_DISP_STRIPE 0x10000000000000ULL/* create stripe disposition*/
819
820
#define OBD_CONNECT_OPEN_BY_FID	0x20000000000000ULL /* open by fid won't pack
						       name in request */
821
#define OBD_CONNECT_LFSCK      0x40000000000000ULL/* support online LFSCK */
822
#define OBD_CONNECT_UNLINK_CLOSE 0x100000000000000ULL/* close file in unlink */
823
824
#define OBD_CONNECT_MULTIMODRPCS 0x200000000000000ULL /* support multiple modify
							 RPCs in parallel */
825
#define OBD_CONNECT_DIR_STRIPE	 0x400000000000000ULL /* striped DNE dir */
826
#define OBD_CONNECT_SUBTREE	0x800000000000000ULL /* fileset mount */
827
/* was OBD_CONNECT_LOCKAHEAD_OLD 0x1000000000000000ULL old lockahead 2.12-2.13*/
828

829
830
/** bulk matchbits is sent within ptlrpc_body */
#define OBD_CONNECT_BULK_MBITS	 0x2000000000000000ULL
831
#define OBD_CONNECT_OBDOPACK	 0x4000000000000000ULL /* compact OUT obdo */
832
#define OBD_CONNECT_FLAGS2	 0x8000000000000000ULL /* second flags word */
833
/* ocd_connect_flags2 flags */
834
835
836
#define OBD_CONNECT2_FILE_SECCTX	 0x1ULL /* set file security context at create */
#define OBD_CONNECT2_LOCKAHEAD		 0x2ULL /* ladvise lockahead v2 */
#define OBD_CONNECT2_DIR_MIGRATE	 0x4ULL /* migrate striped dir */
837
#define OBD_CONNECT2_SUM_STATFS		0x8ULL /* MDT return aggregated stats */
838
#define OBD_CONNECT2_OVERSTRIPING	0x10ULL /* OST overstriping support */
839
#define OBD_CONNECT2_FLR		0x20ULL /* FLR support */
840
#define OBD_CONNECT2_WBC_INTENTS	0x40ULL /* create/unlink/... intents for wbc, also operations under client-held parent locks */
841
#define OBD_CONNECT2_LOCK_CONVERT	0x80ULL /* IBITS lock convert support */
842
#define OBD_CONNECT2_ARCHIVE_ID_ARRAY	0x100ULL /* store HSM archive_id in array */
843
#define OBD_CONNECT2_INC_XID		0x200ULL /* Increasing xid */
844
#define OBD_CONNECT2_SELINUX_POLICY	0x400ULL /* has client SELinux policy */
845
#define OBD_CONNECT2_LSOM		0x800ULL /* LSOM support */
846
#define OBD_CONNECT2_PCC		0x1000ULL /* Persistent Client Cache */
847
#define OBD_CONNECT2_CRUSH		0x2000ULL /* crush hash striped directory */
848
#define OBD_CONNECT2_ASYNC_DISCARD	0x4000ULL /* support async DoM data discard */
849
#define OBD_CONNECT2_ENCRYPT		0x8000ULL /* client-to-disk encrypt */
850
#define OBD_CONNECT2_FIDMAP	       0x10000ULL /* FID map */
851
#define OBD_CONNECT2_GETATTR_PFID      0x20000ULL /* pack parent FID in getattr */
852
853
854
855
/* XXX README XXX:
 * Please DO NOT add flag values here before first ensuring that this same
 * flag value is not in use on some other branch.  Please clear any such
 * changes with senior engineers before starting to use a new flag.  Then,
856
 * submit a small patch against EVERY branch that ONLY adds the new flag,
857
858
859
860
 * updates obd_connect_names[], adds the flag to check_obd_connect_data(),
 * and updates wiretests accordingly, so it can be approved and landed easily
 * to reserve the flag for future use.
 */
861
862
863
864

#define OCD_HAS_FLAG(ocd, flg)  \
        (!!((ocd)->ocd_connect_flags & OBD_CONNECT_##flg))

nathan's avatar
nathan committed
865

yury's avatar
b=14433    
yury committed
866
867
868
869
870
871
#ifdef HAVE_LRU_RESIZE_SUPPORT
#define LRU_RESIZE_CONNECT_FLAG OBD_CONNECT_LRU_RESIZE
#else
#define LRU_RESIZE_CONNECT_FLAG 0
#endif

tappro's avatar
tappro committed
872
#define MDT_CONNECT_SUPPORTED  (OBD_CONNECT_RDONLY | OBD_CONNECT_VERSION | \
873
874
875
876
877
878
879
				OBD_CONNECT_ACL | OBD_CONNECT_XATTR | \
				OBD_CONNECT_IBITS | OBD_CONNECT_NODEVOH | \
				OBD_CONNECT_ATTRFID | OBD_CONNECT_CANCELSET | \
				OBD_CONNECT_AT | OBD_CONNECT_BRW_SIZE | \
				OBD_CONNECT_MDS_MDS | OBD_CONNECT_FID | \
				LRU_RESIZE_CONNECT_FLAG | OBD_CONNECT_VBR | \
				OBD_CONNECT_LOV_V3 | OBD_CONNECT_FULL20 | \
880
881
				OBD_CONNECT_64BITHASH | OBD_CONNECT_JOBSTATS | \
				OBD_CONNECT_EINPROGRESS | \
882
				OBD_CONNECT_LIGHTWEIGHT | OBD_CONNECT_UMASK | \
883
				OBD_CONNECT_LVB_TYPE | OBD_CONNECT_LAYOUTLOCK |\
884
				OBD_CONNECT_PINGLESS | OBD_CONNECT_MAX_EASIZE |\
885
				OBD_CONNECT_FLOCK_DEAD | \
886
				OBD_CONNECT_DISP_STRIPE | OBD_CONNECT_LFSCK | \
887
				OBD_CONNECT_OPEN_BY_FID | \
888
889
890
				OBD_CONNECT_DIR_STRIPE | OBD_CONNECT_GRANT | \
				OBD_CONNECT_TRUNCLOCK | OBD_CONNECT_SRVLOCK | \
				OBD_CONNECT_BULK_MBITS | OBD_CONNECT_CKSUM | \
891
				OBD_CONNECT_MULTIMODRPCS | \
892
				OBD_CONNECT_SUBTREE | OBD_CONNECT_LARGE_ACL | \
893
				OBD_CONNECT_GRANT_PARAM | \
894
				OBD_CONNECT_SHORTIO | OBD_CONNECT_FLAGS2)
895

896
#define MDT_CONNECT_SUPPORTED2 (OBD_CONNECT2_FILE_SECCTX | \
897
				OBD_CONNECT2_DIR_MIGRATE | \
898
				OBD_CONNECT2_SUM_STATFS | \
899
				OBD_CONNECT2_OVERSTRIPING | \
900
901
				OBD_CONNECT2_FLR |\
				OBD_CONNECT2_LOCK_CONVERT | \
902
				OBD_CONNECT2_ARCHIVE_ID_ARRAY | \
903
				OBD_CONNECT2_INC_XID | \
904
				OBD_CONNECT2_SELINUX_POLICY | \
905
				OBD_CONNECT2_LSOM | \
906
				OBD_CONNECT2_ASYNC_DISCARD | \
907
				OBD_CONNECT2_PCC | \
908
				OBD_CONNECT2_CRUSH | \
909
910
				OBD_CONNECT2_ENCRYPT | \
				OBD_CONNECT2_GETATTR_PFID)
911

nathan's avatar
nathan committed
912
#define OST_CONNECT_SUPPORTED  (OBD_CONNECT_SRVLOCK | OBD_CONNECT_GRANT | \
913
914
915
916
917
918
919
920
921
				OBD_CONNECT_REQPORTAL | OBD_CONNECT_VERSION | \
				OBD_CONNECT_TRUNCLOCK | OBD_CONNECT_INDEX | \
				OBD_CONNECT_BRW_SIZE | OBD_CONNECT_CANCELSET | \
				OBD_CONNECT_AT | LRU_RESIZE_CONNECT_FLAG | \
				OBD_CONNECT_CKSUM | OBD_CONNECT_VBR | \
				OBD_CONNECT_MDS | OBD_CONNECT_SKIP_ORPHAN | \
				OBD_CONNECT_GRANT_SHRINK | OBD_CONNECT_FULL20 |\
				OBD_CONNECT_64BITHASH | OBD_CONNECT_MAXBYTES | \
				OBD_CONNECT_MAX_EASIZE | \
922
				OBD_CONNECT_EINPROGRESS | \
923
				OBD_CONNECT_JOBSTATS | \
924
				OBD_CONNECT_LIGHTWEIGHT | OBD_CONNECT_LVB_TYPE|\
925
				OBD_CONNECT_LAYOUTLOCK | OBD_CONNECT_FID | \
926
				OBD_CONNECT_PINGLESS | OBD_CONNECT_LFSCK | \
927
				OBD_CONNECT_BULK_MBITS | \
928
929
				OBD_CONNECT_GRANT_PARAM | \
				OBD_CONNECT_SHORTIO | OBD_CONNECT_FLAGS2)
930

931
932
#define OST_CONNECT_SUPPORTED2 (OBD_CONNECT2_LOCKAHEAD | OBD_CONNECT2_INC_XID |\
				OBD_CONNECT2_ENCRYPT)
933

934
#define ECHO_CONNECT_SUPPORTED (OBD_CONNECT_FID)
935
936
#define ECHO_CONNECT_SUPPORTED2 0

937
#define MGS_CONNECT_SUPPORTED  (OBD_CONNECT_VERSION | OBD_CONNECT_AT | \
938
				OBD_CONNECT_FULL20 | OBD_CONNECT_IMP_RECOV | \
939
				OBD_CONNECT_PINGLESS |\
940
				OBD_CONNECT_BULK_MBITS | OBD_CONNECT_BARRIER)
nathan's avatar
nathan committed
941

942
943
#define MGS_CONNECT_SUPPORTED2 0

944
/* Features required for this version of the client to work with server */
945
#define CLIENT_CONNECT_MDT_REQD (OBD_CONNECT_FID |	\
946
				 OBD_CONNECT_ATTRFID |	\
947
				 OBD_CONNECT_FULL20)
948

nathan's avatar
nathan committed
949
950
951
952
953
/* This structure is used for both request and reply.
 *
 * If we eventually have separate connect data for different types, which we
 * almost certainly will, then perhaps we stick a union in here. */
struct obd_connect_data {
954
955
956
957
958
	__u64 ocd_connect_flags; /* OBD_CONNECT_* per above */
	__u32 ocd_version;	 /* lustre release version number */
	__u32 ocd_grant;	 /* initial cache grant amount (bytes) */
	__u32 ocd_index;	 /* LOV index to connect to */
	__u32 ocd_brw_size;	 /* Maximum BRW size in bytes */
tappro's avatar
tappro committed
959
        __u64 ocd_ibits_known;   /* inode bits this client understands */
960
961
962
963
	__u8  ocd_grant_blkbits; /* log2 of the backend filesystem blocksize */
	__u8  ocd_grant_inobits; /* log2 of the per-inode space consumption */
	__u16 ocd_grant_tax_kb;  /* extent insertion overhead, in 1K blocks */
	__u32 ocd_grant_max_blks;/* maximum number of blocks per extent */
tappro's avatar
tappro committed
964
965
        __u64 ocd_transno;       /* first transno from client to be replayed */
        __u32 ocd_group;         /* MDS group on OST */
johann's avatar
johann committed
966
        __u32 ocd_cksum_types;   /* supported checksum algorithms */
967
        __u32 ocd_max_easize;    /* How big LOV EA can be on MDS */
968
        __u32 ocd_instance;      /* instance # of this target */
969
970
971
972
973
        __u64 ocd_maxbytes;      /* Maximum stripe size in bytes */
        /* Fields after ocd_maxbytes are only accessible by the receiver
         * if the corresponding flag in ocd_connect_flags is set. Accessing
         * any field after ocd_maxbytes on the receiver without a valid flag
         * may result in out-of-bound memory access and kernel oops. */
974
975
976
	__u16 ocd_maxmodrpcs;    /* Maximum modify RPCs in parallel */
	__u16 padding0;          /* added 2.1.0. also fix lustre_swab_connect */
	__u32 padding1;          /* added 2.1.0. also fix lustre_swab_connect */
977
	__u64 ocd_connect_flags2;
978
979
980
981
982
983
984
985
986
987
988
989
990
        __u64 padding3;          /* added 2.1.0. also fix lustre_swab_connect */
        __u64 padding4;          /* added 2.1.0. also fix lustre_swab_connect */
        __u64 padding5;          /* added 2.1.0. also fix lustre_swab_connect */
        __u64 padding6;          /* added 2.1.0. also fix lustre_swab_connect */
        __u64 padding7;          /* added 2.1.0. also fix lustre_swab_connect */
        __u64 padding8;          /* added 2.1.0. also fix lustre_swab_connect */
        __u64 padding9;          /* added 2.1.0. also fix lustre_swab_connect */
        __u64 paddingA;          /* added 2.1.0. also fix lustre_swab_connect */
        __u64 paddingB;          /* added 2.1.0. also fix lustre_swab_connect */
        __u64 paddingC;          /* added 2.1.0. also fix lustre_swab_connect */
        __u64 paddingD;          /* added 2.1.0. also fix lustre_swab_connect */
        __u64 paddingE;          /* added 2.1.0. also fix lustre_swab_connect */
        __u64 paddingF;          /* added 2.1.0. also fix lustre_swab_connect */
nathan's avatar
nathan committed
991
};
992
993
994
995
996
997
998
/* XXX README XXX:
 * Please DO NOT use any fields here before first ensuring that this same
 * field is not in use on some other branch.  Please clear any such changes
 * with senior engineers before starting to use a new field.  Then, submit
 * a small patch against EVERY branch that ONLY adds the new field along with
 * the matching OBD_CONNECT flag, so that can be approved and landed easily to
 * reserve the flag for future use. */
nathan's avatar
nathan committed
999

johann's avatar
johann committed
1000
/*
For faster browsing, not all history is shown. View entire blame