blob: dd25f1b3fe1ec21a4903a078ed2de7aaa5f7f5e7 [file] [log] [blame]
Fred Isaman155e7522011-07-30 20:52:39 -04001/*
2 * linux/fs/nfs/blocklayout/blocklayout.h
3 *
4 * Module for the NFSv4.1 pNFS block layout driver.
5 *
6 * Copyright (c) 2006 The Regents of the University of Michigan.
7 * All rights reserved.
8 *
9 * Andy Adamson <andros@citi.umich.edu>
10 * Fred Isaman <iisaman@umich.edu>
11 *
12 * permission is granted to use, copy, create derivative works and
13 * redistribute this software and such derivative works for any purpose,
14 * so long as the name of the university of michigan is not used in
15 * any advertising or publicity pertaining to the use or distribution
16 * of this software without specific, written prior authorization. if
17 * the above copyright notice or any other identification of the
18 * university of michigan is included in any copy of any portion of
19 * this software, then the disclaimer below must also be included.
20 *
21 * this software is provided as is, without representation from the
22 * university of michigan as to its fitness for any purpose, and without
23 * warranty by the university of michigan of any kind, either express
24 * or implied, including without limitation the implied warranties of
25 * merchantability and fitness for a particular purpose. the regents
26 * of the university of michigan shall not be liable for any damages,
27 * including special, indirect, incidental, or consequential damages,
28 * with respect to any claim arising out or in connection with the use
29 * of the software, even if it has been or is hereafter advised of the
30 * possibility of such damages.
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>
Jim Reesfe0a9b72011-07-30 20:52:42 -040037#include <linux/sunrpc/rpc_pipe_fs.h>
38
Fred Isaman155e7522011-07-30 20:52:39 -040039#include "../pnfs.h"
40
Jim Reesfe0a9b72011-07-30 20:52:42 -040041struct pnfs_block_dev {
42 struct list_head bm_node;
43 struct nfs4_deviceid bm_mdevid; /* associated devid */
44 struct block_device *bm_mdev; /* meta device itself */
45};
46
Fred Isaman155e7522011-07-30 20:52:39 -040047enum exstate4 {
48 PNFS_BLOCK_READWRITE_DATA = 0,
49 PNFS_BLOCK_READ_DATA = 1,
50 PNFS_BLOCK_INVALID_DATA = 2, /* mapped, but data is invalid */
51 PNFS_BLOCK_NONE_DATA = 3 /* unmapped, it's a hole */
52};
53
54struct pnfs_inval_markings {
55 /* STUB */
56};
57
58/* sector_t fields are all in 512-byte sectors */
59struct pnfs_block_extent {
60 struct kref be_refcnt;
61 struct list_head be_node; /* link into lseg list */
62 struct nfs4_deviceid be_devid; /* FIXME: could use device cache instead */
63 struct block_device *be_mdev;
64 sector_t be_f_offset; /* the starting offset in the file */
65 sector_t be_length; /* the size of the extent */
66 sector_t be_v_offset; /* the starting offset in the volume */
67 enum exstate4 be_state; /* the state of this extent */
68 struct pnfs_inval_markings *be_inval; /* tracks INVAL->RW transition */
69};
70
71static inline void
72BL_INIT_INVAL_MARKS(struct pnfs_inval_markings *marks, sector_t blocksize)
73{
74 /* STUB */
75}
76
77enum extentclass4 {
78 RW_EXTENT = 0, /* READWRTE and INVAL */
79 RO_EXTENT = 1, /* READ and NONE */
80 EXTENT_LISTS = 2,
81};
82
83struct pnfs_block_layout {
84 struct pnfs_layout_hdr bl_layout;
85 struct pnfs_inval_markings bl_inval; /* tracks INVAL->RW transition */
86 spinlock_t bl_ext_lock; /* Protects list manipulation */
87 struct list_head bl_extents[EXTENT_LISTS]; /* R and RW extents */
88 struct list_head bl_commit; /* Needs layout commit */
89 struct list_head bl_committing; /* Layout committing */
90 unsigned int bl_count; /* entries in bl_commit */
91 sector_t bl_blocksize; /* Server blocksize in sectors */
92};
93
94static inline struct pnfs_block_layout *BLK_LO2EXT(struct pnfs_layout_hdr *lo)
95{
96 return container_of(lo, struct pnfs_block_layout, bl_layout);
97}
98
Jim Reesfe0a9b72011-07-30 20:52:42 -040099struct bl_dev_msg {
100 int status;
101 uint32_t major, minor;
102};
103
104struct bl_msg_hdr {
105 u8 type;
106 u16 totallen; /* length of entire message, including hdr itself */
107};
108
109extern struct dentry *bl_device_pipe;
110extern wait_queue_head_t bl_wq;
111
112#define BL_DEVICE_UMOUNT 0x0 /* Umount--delete devices */
113#define BL_DEVICE_MOUNT 0x1 /* Mount--create devices*/
114#define BL_DEVICE_REQUEST_INIT 0x0 /* Start request */
115#define BL_DEVICE_REQUEST_PROC 0x1 /* User level process succeeds */
116#define BL_DEVICE_REQUEST_ERR 0x2 /* User level process fails */
117
118/* blocklayoutdev.c */
119ssize_t bl_pipe_upcall(struct file *, struct rpc_pipe_msg *,
120 char __user *, size_t);
121ssize_t bl_pipe_downcall(struct file *, const char __user *, size_t);
122void bl_pipe_destroy_msg(struct rpc_pipe_msg *);
123struct block_device *nfs4_blkdev_get(dev_t dev);
124int nfs4_blkdev_put(struct block_device *bdev);
125struct pnfs_block_dev *nfs4_blk_decode_device(struct nfs_server *server,
126 struct pnfs_device *dev,
127 struct list_head *sdlist);
128int nfs4_blk_process_layoutget(struct pnfs_layout_hdr *lo,
129 struct nfs4_layoutget_res *lgr, gfp_t gfp_flags);
130
Fred Isaman9e692962011-07-30 20:52:41 -0400131void bl_put_extent(struct pnfs_block_extent *be);
Fred Isaman155e7522011-07-30 20:52:39 -0400132#endif /* FS_NFS_NFS4BLOCKLAYOUT_H */