1#ifndef _NFSD_BLOCKLAYOUTXDR_H
2#define _NFSD_BLOCKLAYOUTXDR_H 1
3
4#include <linux/blkdev.h>
5#include "xdr4.h"
6
7struct iomap;
8struct xdr_stream;
9
10enum pnfs_block_extent_state {
11	PNFS_BLOCK_READWRITE_DATA	= 0,
12	PNFS_BLOCK_READ_DATA		= 1,
13	PNFS_BLOCK_INVALID_DATA		= 2,
14	PNFS_BLOCK_NONE_DATA		= 3,
15};
16
17struct pnfs_block_extent {
18	struct nfsd4_deviceid		vol_id;
19	u64				foff;
20	u64				len;
21	u64				soff;
22	enum pnfs_block_extent_state	es;
23};
24#define NFS4_BLOCK_EXTENT_SIZE		44
25
26enum pnfs_block_volume_type {
27	PNFS_BLOCK_VOLUME_SIMPLE	= 0,
28	PNFS_BLOCK_VOLUME_SLICE		= 1,
29	PNFS_BLOCK_VOLUME_CONCAT	= 2,
30	PNFS_BLOCK_VOLUME_STRIPE	= 3,
31};
32
33/*
34 * Random upper cap for the uuid length to avoid unbounded allocation.
35 * Not actually limited by the protocol.
36 */
37#define PNFS_BLOCK_UUID_LEN	128
38
39struct pnfs_block_volume {
40	enum pnfs_block_volume_type	type;
41	union {
42		struct {
43			u64		offset;
44			u32		sig_len;
45			u8		sig[PNFS_BLOCK_UUID_LEN];
46		} simple;
47	};
48};
49
50struct pnfs_block_deviceaddr {
51	u32				nr_volumes;
52	struct pnfs_block_volume	volumes[];
53};
54
55__be32 nfsd4_block_encode_getdeviceinfo(struct xdr_stream *xdr,
56		struct nfsd4_getdeviceinfo *gdp);
57__be32 nfsd4_block_encode_layoutget(struct xdr_stream *xdr,
58		struct nfsd4_layoutget *lgp);
59int nfsd4_block_decode_layoutupdate(__be32 *p, u32 len, struct iomap **iomapp,
60		u32 block_size);
61
62#endif /* _NFSD_BLOCKLAYOUTXDR_H */
63