This source file includes following definitions.
- BLK_LO2EXT
- BLK_LSEG2EXT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 #ifndef FS_NFS_NFS4BLOCKLAYOUT_H
33 #define FS_NFS_NFS4BLOCKLAYOUT_H
34
35 #include <linux/device-mapper.h>
36 #include <linux/nfs_fs.h>
37 #include <linux/sunrpc/rpc_pipe_fs.h>
38
39 #include "../nfs4_fs.h"
40 #include "../pnfs.h"
41 #include "../netns.h"
42
43 #define PAGE_CACHE_SECTORS (PAGE_SIZE >> SECTOR_SHIFT)
44 #define PAGE_CACHE_SECTOR_SHIFT (PAGE_SHIFT - SECTOR_SHIFT)
45 #define SECTOR_SIZE (1 << SECTOR_SHIFT)
46
47 struct pnfs_block_dev;
48
49 #define PNFS_BLOCK_MAX_UUIDS 4
50 #define PNFS_BLOCK_MAX_DEVICES 64
51
52
53
54
55
56 #define PNFS_BLOCK_UUID_LEN 128
57
58 struct pnfs_block_volume {
59 enum pnfs_block_volume_type type;
60 union {
61 struct {
62 int len;
63 int nr_sigs;
64 struct {
65 u64 offset;
66 u32 sig_len;
67 u8 sig[PNFS_BLOCK_UUID_LEN];
68 } sigs[PNFS_BLOCK_MAX_UUIDS];
69 } simple;
70 struct {
71 u64 start;
72 u64 len;
73 u32 volume;
74 } slice;
75 struct {
76 u32 volumes_count;
77 u32 volumes[PNFS_BLOCK_MAX_DEVICES];
78 } concat;
79 struct {
80 u64 chunk_size;
81 u32 volumes_count;
82 u32 volumes[PNFS_BLOCK_MAX_DEVICES];
83 } stripe;
84 struct {
85 enum scsi_code_set code_set;
86 enum scsi_designator_type designator_type;
87 int designator_len;
88 u8 designator[256];
89 u64 pr_key;
90 } scsi;
91 };
92 };
93
94 struct pnfs_block_dev_map {
95 u64 start;
96 u64 len;
97 u64 disk_offset;
98 struct block_device *bdev;
99 };
100
101 struct pnfs_block_dev {
102 struct nfs4_deviceid_node node;
103
104 u64 start;
105 u64 len;
106
107 u32 nr_children;
108 struct pnfs_block_dev *children;
109 u64 chunk_size;
110
111 struct block_device *bdev;
112 u64 disk_offset;
113
114 u64 pr_key;
115 bool pr_registered;
116
117 bool (*map)(struct pnfs_block_dev *dev, u64 offset,
118 struct pnfs_block_dev_map *map);
119 };
120
121
122 struct pnfs_block_extent {
123 union {
124 struct rb_node be_node;
125 struct list_head be_list;
126 };
127 struct nfs4_deviceid_node *be_device;
128 sector_t be_f_offset;
129 sector_t be_length;
130 sector_t be_v_offset;
131 enum pnfs_block_extent_state be_state;
132 #define EXTENT_WRITTEN 1
133 #define EXTENT_COMMITTING 2
134 unsigned int be_tag;
135 };
136
137 struct pnfs_block_layout {
138 struct pnfs_layout_hdr bl_layout;
139 struct rb_root bl_ext_rw;
140 struct rb_root bl_ext_ro;
141 spinlock_t bl_ext_lock;
142 bool bl_scsi_layout;
143 u64 bl_lwb;
144 };
145
146 static inline struct pnfs_block_layout *
147 BLK_LO2EXT(struct pnfs_layout_hdr *lo)
148 {
149 return container_of(lo, struct pnfs_block_layout, bl_layout);
150 }
151
152 static inline struct pnfs_block_layout *
153 BLK_LSEG2EXT(struct pnfs_layout_segment *lseg)
154 {
155 return BLK_LO2EXT(lseg->pls_layout);
156 }
157
158 struct bl_pipe_msg {
159 struct rpc_pipe_msg msg;
160 wait_queue_head_t *bl_wq;
161 };
162
163 struct bl_msg_hdr {
164 u8 type;
165 u16 totallen;
166 };
167
168 #define BL_DEVICE_UMOUNT 0x0
169 #define BL_DEVICE_MOUNT 0x1
170 #define BL_DEVICE_REQUEST_INIT 0x0
171 #define BL_DEVICE_REQUEST_PROC 0x1
172 #define BL_DEVICE_REQUEST_ERR 0x2
173
174
175 struct nfs4_deviceid_node *bl_alloc_deviceid_node(struct nfs_server *server,
176 struct pnfs_device *pdev, gfp_t gfp_mask);
177 void bl_free_deviceid_node(struct nfs4_deviceid_node *d);
178
179
180 int ext_tree_insert(struct pnfs_block_layout *bl,
181 struct pnfs_block_extent *new);
182 int ext_tree_remove(struct pnfs_block_layout *bl, bool rw, sector_t start,
183 sector_t end);
184 int ext_tree_mark_written(struct pnfs_block_layout *bl, sector_t start,
185 sector_t len, u64 lwb);
186 bool ext_tree_lookup(struct pnfs_block_layout *bl, sector_t isect,
187 struct pnfs_block_extent *ret, bool rw);
188 int ext_tree_prepare_commit(struct nfs4_layoutcommit_args *arg);
189 void ext_tree_mark_committed(struct nfs4_layoutcommit_args *arg, int status);
190
191
192 dev_t bl_resolve_deviceid(struct nfs_server *server,
193 struct pnfs_block_volume *b, gfp_t gfp_mask);
194 int __init bl_init_pipefs(void);
195 void bl_cleanup_pipefs(void);
196
197 #endif