Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  *  NFSv4 file layout driver data structures.
0003  *
0004  *  Copyright (c) 2002
0005  *  The Regents of the University of Michigan
0006  *  All Rights Reserved
0007  *
0008  *  Dean Hildebrand <dhildebz@umich.edu>
0009  *
0010  *  Permission is granted to use, copy, create derivative works, and
0011  *  redistribute this software and such derivative works for any purpose,
0012  *  so long as the name of the University of Michigan is not used in
0013  *  any advertising or publicity pertaining to the use or distribution
0014  *  of this software without specific, written prior authorization. If
0015  *  the above copyright notice or any other identification of the
0016  *  University of Michigan is included in any copy of any portion of
0017  *  this software, then the disclaimer below must also be included.
0018  *
0019  *  This software is provided as is, without representation or warranty
0020  *  of any kind either express or implied, including without limitation
0021  *  the implied warranties of merchantability, fitness for a particular
0022  *  purpose, or noninfringement.  The Regents of the University of
0023  *  Michigan shall not be liable for any damages, including special,
0024  *  indirect, incidental, or consequential damages, with respect to any
0025  *  claim arising out of or in connection with the use of the software,
0026  *  even if it has been or is hereafter advised of the possibility of
0027  *  such damages.
0028  */
0029 
0030 #ifndef FS_NFS_NFS4FILELAYOUT_H
0031 #define FS_NFS_NFS4FILELAYOUT_H
0032 
0033 #include "../pnfs.h"
0034 
0035 /*
0036  * Field testing shows we need to support up to 4096 stripe indices.
0037  * We store each index as a u8 (u32 on the wire) to keep the memory footprint
0038  * reasonable. This in turn means we support a maximum of 256
0039  * RFC 5661 multipath_list4 structures.
0040  */
0041 #define NFS4_PNFS_MAX_STRIPE_CNT 4096
0042 #define NFS4_PNFS_MAX_MULTI_CNT  256 /* 256 fit into a u8 stripe_index */
0043 
0044 enum stripetype4 {
0045     STRIPE_SPARSE = 1,
0046     STRIPE_DENSE = 2
0047 };
0048 
0049 struct nfs4_file_layout_dsaddr {
0050     struct nfs4_deviceid_node   id_node;
0051     u32             stripe_count;
0052     u8              *stripe_indices;
0053     u32             ds_num;
0054     struct nfs4_pnfs_ds     *ds_list[];
0055 };
0056 
0057 struct nfs4_filelayout_segment {
0058     struct pnfs_layout_segment  generic_hdr;
0059     u32             stripe_type;
0060     u32             commit_through_mds;
0061     u32             stripe_unit;
0062     u32             first_stripe_index;
0063     u64             pattern_offset;
0064     struct nfs4_deviceid        deviceid;
0065     struct nfs4_file_layout_dsaddr  *dsaddr; /* Point to GETDEVINFO data */
0066     unsigned int            num_fh;
0067     struct nfs_fh           **fh_array;
0068 };
0069 
0070 struct nfs4_filelayout {
0071     struct pnfs_layout_hdr generic_hdr;
0072     struct pnfs_ds_commit_info commit_info;
0073 };
0074 
0075 static inline struct nfs4_filelayout *
0076 FILELAYOUT_FROM_HDR(struct pnfs_layout_hdr *lo)
0077 {
0078     return container_of(lo, struct nfs4_filelayout, generic_hdr);
0079 }
0080 
0081 static inline struct nfs4_filelayout_segment *
0082 FILELAYOUT_LSEG(struct pnfs_layout_segment *lseg)
0083 {
0084     return container_of(lseg,
0085                 struct nfs4_filelayout_segment,
0086                 generic_hdr);
0087 }
0088 
0089 static inline struct nfs4_deviceid_node *
0090 FILELAYOUT_DEVID_NODE(struct pnfs_layout_segment *lseg)
0091 {
0092     return &FILELAYOUT_LSEG(lseg)->dsaddr->id_node;
0093 }
0094 
0095 static inline bool
0096 filelayout_test_devid_invalid(struct nfs4_deviceid_node *node)
0097 {
0098     return test_bit(NFS_DEVICEID_INVALID, &node->flags);
0099 }
0100 
0101 extern bool
0102 filelayout_test_devid_unavailable(struct nfs4_deviceid_node *node);
0103 
0104 extern struct nfs_fh *
0105 nfs4_fl_select_ds_fh(struct pnfs_layout_segment *lseg, u32 j);
0106 
0107 u32 nfs4_fl_calc_j_index(struct pnfs_layout_segment *lseg, loff_t offset);
0108 u32 nfs4_fl_calc_ds_index(struct pnfs_layout_segment *lseg, u32 j);
0109 struct nfs4_pnfs_ds *nfs4_fl_prepare_ds(struct pnfs_layout_segment *lseg,
0110                     u32 ds_idx);
0111 
0112 extern struct nfs4_file_layout_dsaddr *
0113 nfs4_fl_alloc_deviceid_node(struct nfs_server *server,
0114     struct pnfs_device *pdev, gfp_t gfp_flags);
0115 extern void nfs4_fl_put_deviceid(struct nfs4_file_layout_dsaddr *dsaddr);
0116 extern void nfs4_fl_free_deviceid(struct nfs4_file_layout_dsaddr *dsaddr);
0117 
0118 #endif /* FS_NFS_NFS4FILELAYOUT_H */