Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  *  linux/fs/nfs/blocklayout/blocklayout.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *  Module for the NFSv4.1 pNFS block layout driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *  Copyright (c) 2006 The Regents of the University of Michigan.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *  All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *  Andy Adamson <andros@citi.umich.edu>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *  Fred Isaman <iisaman@umich.edu>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * permission is granted to use, copy, create derivative works and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * redistribute this software and such derivative works for any purpose,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * so long as the name of the university of michigan is not used in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * any advertising or publicity pertaining to the use or distribution
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * of this software without specific, written prior authorization.  if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * the above copyright notice or any other identification of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * university of michigan is included in any copy of any portion of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * this software, then the disclaimer below must also be included.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * this software is provided as is, without representation from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * university of michigan as to its fitness for any purpose, and without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * warranty by the university of michigan of any kind, either express
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * or implied, including without limitation the implied warranties of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * merchantability and fitness for a particular purpose.  the regents
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * of the university of michigan shall not be liable for any damages,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * including special, indirect, incidental, or consequential damages,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * with respect to any claim arising out or in connection with the use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * of the software, even if it has been or is hereafter advised of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * possibility of such damages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #ifndef FS_NFS_NFS4BLOCKLAYOUT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define FS_NFS_NFS4BLOCKLAYOUT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #include <linux/device-mapper.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #include <linux/nfs_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #include <linux/sunrpc/rpc_pipe_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #include "../nfs4_fs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #include "../pnfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #include "../netns.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define PAGE_CACHE_SECTORS (PAGE_SIZE >> SECTOR_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define PAGE_CACHE_SECTOR_SHIFT (PAGE_SHIFT - SECTOR_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define SECTOR_SIZE (1 << SECTOR_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) struct pnfs_block_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define PNFS_BLOCK_MAX_UUIDS	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define PNFS_BLOCK_MAX_DEVICES	64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  * Random upper cap for the uuid length to avoid unbounded allocation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * Not actually limited by the protocol.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define PNFS_BLOCK_UUID_LEN	128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) struct pnfs_block_volume {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	enum pnfs_block_volume_type	type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 			int		len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 			int		nr_sigs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 			struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 				u64		offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 				u32		sig_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 				u8		sig[PNFS_BLOCK_UUID_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 			} sigs[PNFS_BLOCK_MAX_UUIDS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		} simple;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 			u64		start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 			u64		len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 			u32		volume;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		} slice;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 			u32		volumes_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 			u32		volumes[PNFS_BLOCK_MAX_DEVICES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		} concat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 			u64		chunk_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 			u32		volumes_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			u32		volumes[PNFS_BLOCK_MAX_DEVICES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		} stripe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 			enum scsi_code_set		code_set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			enum scsi_designator_type	designator_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 			int				designator_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 			u8				designator[256];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 			u64				pr_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		} scsi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) struct pnfs_block_dev_map {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	u64			start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	u64			len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	u64			disk_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	struct block_device		*bdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct pnfs_block_dev {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	struct nfs4_deviceid_node	node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	u64				start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	u64				len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	u32				nr_children;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	struct pnfs_block_dev		*children;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	u64				chunk_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	struct block_device		*bdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	u64				disk_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	u64				pr_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	bool				pr_registered;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	bool (*map)(struct pnfs_block_dev *dev, u64 offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 			struct pnfs_block_dev_map *map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) /* sector_t fields are all in 512-byte sectors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) struct pnfs_block_extent {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		struct rb_node	be_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		struct list_head be_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	struct nfs4_deviceid_node *be_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	sector_t	be_f_offset;	/* the starting offset in the file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	sector_t	be_length;	/* the size of the extent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	sector_t	be_v_offset;	/* the starting offset in the volume */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	enum pnfs_block_extent_state be_state;	/* the state of this extent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) #define EXTENT_WRITTEN		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #define EXTENT_COMMITTING	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	unsigned int	be_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) struct pnfs_block_layout {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	struct pnfs_layout_hdr	bl_layout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	struct rb_root		bl_ext_rw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	struct rb_root		bl_ext_ro;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	spinlock_t		bl_ext_lock;   /* Protects list manipulation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	bool			bl_scsi_layout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	u64			bl_lwb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) static inline struct pnfs_block_layout *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) BLK_LO2EXT(struct pnfs_layout_hdr *lo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	return container_of(lo, struct pnfs_block_layout, bl_layout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) static inline struct pnfs_block_layout *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) BLK_LSEG2EXT(struct pnfs_layout_segment *lseg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	return BLK_LO2EXT(lseg->pls_layout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) struct bl_pipe_msg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	struct rpc_pipe_msg msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	wait_queue_head_t *bl_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) struct bl_msg_hdr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	u8  type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	u16 totallen; /* length of entire message, including hdr itself */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) #define BL_DEVICE_UMOUNT               0x0 /* Umount--delete devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) #define BL_DEVICE_MOUNT                0x1 /* Mount--create devices*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) #define BL_DEVICE_REQUEST_INIT         0x0 /* Start request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) #define BL_DEVICE_REQUEST_PROC         0x1 /* User level process succeeds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) #define BL_DEVICE_REQUEST_ERR          0x2 /* User level process fails */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /* dev.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) struct nfs4_deviceid_node *bl_alloc_deviceid_node(struct nfs_server *server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		struct pnfs_device *pdev, gfp_t gfp_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) void bl_free_deviceid_node(struct nfs4_deviceid_node *d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) /* extent_tree.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) int ext_tree_insert(struct pnfs_block_layout *bl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		struct pnfs_block_extent *new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) int ext_tree_remove(struct pnfs_block_layout *bl, bool rw, sector_t start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		sector_t end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) int ext_tree_mark_written(struct pnfs_block_layout *bl, sector_t start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		sector_t len, u64 lwb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) bool ext_tree_lookup(struct pnfs_block_layout *bl, sector_t isect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		struct pnfs_block_extent *ret, bool rw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) int ext_tree_prepare_commit(struct nfs4_layoutcommit_args *arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) void ext_tree_mark_committed(struct nfs4_layoutcommit_args *arg, int status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) /* rpc_pipefs.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) dev_t bl_resolve_deviceid(struct nfs_server *server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		struct pnfs_block_volume *b, gfp_t gfp_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) int __init bl_init_pipefs(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) void bl_cleanup_pipefs(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) #endif /* FS_NFS_NFS4BLOCKLAYOUT_H */