Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _NFS_FS_SB
0003 #define _NFS_FS_SB
0004 
0005 #include <linux/list.h>
0006 #include <linux/backing-dev.h>
0007 #include <linux/idr.h>
0008 #include <linux/wait.h>
0009 #include <linux/nfs_xdr.h>
0010 #include <linux/sunrpc/xprt.h>
0011 
0012 #include <linux/atomic.h>
0013 #include <linux/refcount.h>
0014 
0015 struct nfs4_session;
0016 struct nfs_iostats;
0017 struct nlm_host;
0018 struct nfs4_sequence_args;
0019 struct nfs4_sequence_res;
0020 struct nfs_server;
0021 struct nfs4_minor_version_ops;
0022 struct nfs41_server_scope;
0023 struct nfs41_impl_id;
0024 
0025 /*
0026  * The nfs_client identifies our client state to the server.
0027  */
0028 struct nfs_client {
0029     refcount_t      cl_count;
0030     atomic_t        cl_mds_count;
0031     int         cl_cons_state;  /* current construction state (-ve: init error) */
0032 #define NFS_CS_READY        0       /* ready to be used */
0033 #define NFS_CS_INITING      1       /* busy initialising */
0034 #define NFS_CS_SESSION_INITING  2       /* busy initialising  session */
0035     unsigned long       cl_res_state;   /* NFS resources state */
0036 #define NFS_CS_CALLBACK     1       /* - callback started */
0037 #define NFS_CS_IDMAP        2       /* - idmap started */
0038 #define NFS_CS_RENEWD       3       /* - renewd started */
0039 #define NFS_CS_STOP_RENEW   4       /* no more state to renew */
0040 #define NFS_CS_CHECK_LEASE_TIME 5       /* need to check lease time */
0041     unsigned long       cl_flags;   /* behavior switches */
0042 #define NFS_CS_NORESVPORT   0       /* - use ephemeral src port */
0043 #define NFS_CS_DISCRTRY     1       /* - disconnect on RPC retry */
0044 #define NFS_CS_MIGRATION    2       /* - transparent state migr */
0045 #define NFS_CS_INFINITE_SLOTS   3       /* - don't limit TCP slots */
0046 #define NFS_CS_NO_RETRANS_TIMEOUT   4   /* - Disable retransmit timeouts */
0047 #define NFS_CS_TSM_POSSIBLE 5       /* - Maybe state migration */
0048 #define NFS_CS_NOPING       6       /* - don't ping on connect */
0049 #define NFS_CS_DS       7       /* - Server is a DS */
0050 #define NFS_CS_REUSEPORT    8       /* - reuse src port on reconnect */
0051     struct sockaddr_storage cl_addr;    /* server identifier */
0052     size_t          cl_addrlen;
0053     char *          cl_hostname;    /* hostname of server */
0054     char *          cl_acceptor;    /* GSSAPI acceptor name */
0055     struct list_head    cl_share_link;  /* link in global client list */
0056     struct list_head    cl_superblocks; /* List of nfs_server structs */
0057 
0058     struct rpc_clnt *   cl_rpcclient;
0059     const struct nfs_rpc_ops *rpc_ops;  /* NFS protocol vector */
0060     int         cl_proto;   /* Network transport protocol */
0061     struct nfs_subversion * cl_nfs_mod; /* pointer to nfs version module */
0062 
0063     u32         cl_minorversion;/* NFSv4 minorversion */
0064     unsigned int        cl_nconnect;    /* Number of connections */
0065     unsigned int        cl_max_connect; /* max number of xprts allowed */
0066     const char *        cl_principal;  /* used for machine cred */
0067 
0068 #if IS_ENABLED(CONFIG_NFS_V4)
0069     struct list_head    cl_ds_clients; /* auth flavor data servers */
0070     u64         cl_clientid;    /* constant */
0071     nfs4_verifier       cl_confirm; /* Clientid verifier */
0072     unsigned long       cl_state;
0073 
0074     spinlock_t      cl_lock;
0075 
0076     unsigned long       cl_lease_time;
0077     unsigned long       cl_last_renewal;
0078     struct delayed_work cl_renewd;
0079 
0080     struct rpc_wait_queue   cl_rpcwaitq;
0081 
0082     /* idmapper */
0083     struct idmap *      cl_idmap;
0084 
0085     /* Client owner identifier */
0086     const char *        cl_owner_id;
0087 
0088     u32         cl_cb_ident;    /* v4.0 callback identifier */
0089     const struct nfs4_minor_version_ops *cl_mvops;
0090     unsigned long       cl_mig_gen;
0091 
0092     /* NFSv4.0 transport blocking */
0093     struct nfs4_slot_table  *cl_slot_tbl;
0094 
0095     /* The sequence id to use for the next CREATE_SESSION */
0096     u32         cl_seqid;
0097     /* The flags used for obtaining the clientid during EXCHANGE_ID */
0098     u32         cl_exchange_flags;
0099     struct nfs4_session *cl_session;    /* shared session */
0100     bool            cl_preserve_clid;
0101     struct nfs41_server_owner *cl_serverowner;
0102     struct nfs41_server_scope *cl_serverscope;
0103     struct nfs41_impl_id    *cl_implid;
0104     /* nfs 4.1+ state protection modes: */
0105     unsigned long       cl_sp4_flags;
0106 #define NFS_SP4_MACH_CRED_MINIMAL  1    /* Minimal sp4_mach_cred - state ops
0107                      * must use machine cred */
0108 #define NFS_SP4_MACH_CRED_CLEANUP  2    /* CLOSE and LOCKU */
0109 #define NFS_SP4_MACH_CRED_SECINFO  3    /* SECINFO and SECINFO_NO_NAME */
0110 #define NFS_SP4_MACH_CRED_STATEID  4    /* TEST_STATEID and FREE_STATEID */
0111 #define NFS_SP4_MACH_CRED_WRITE    5    /* WRITE */
0112 #define NFS_SP4_MACH_CRED_COMMIT   6    /* COMMIT */
0113 #define NFS_SP4_MACH_CRED_PNFS_CLEANUP  7 /* LAYOUTRETURN */
0114 #if IS_ENABLED(CONFIG_NFS_V4_1)
0115     wait_queue_head_t   cl_lock_waitq;
0116 #endif /* CONFIG_NFS_V4_1 */
0117 #endif /* CONFIG_NFS_V4 */
0118 
0119     /* Our own IP address, as a null-terminated string.
0120      * This is used to generate the mv0 callback address.
0121      */
0122     char            cl_ipaddr[48];
0123     struct net      *cl_net;
0124     struct list_head    pending_cb_stateids;
0125 };
0126 
0127 /*
0128  * NFS client parameters stored in the superblock.
0129  */
0130 struct nfs_server {
0131     struct nfs_client * nfs_client; /* shared client and NFS4 state */
0132     struct list_head    client_link;    /* List of other nfs_server structs
0133                          * that share the same client
0134                          */
0135     struct list_head    master_link;    /* link in master servers list */
0136     struct rpc_clnt *   client;     /* RPC client handle */
0137     struct rpc_clnt *   client_acl; /* ACL RPC client handle */
0138     struct nlm_host     *nlm_host;  /* NLM client handle */
0139     struct nfs_iostats __percpu *io_stats;  /* I/O statistics */
0140     atomic_long_t       writeback;  /* number of writeback pages */
0141     unsigned int        write_congested;/* flag set when writeback gets too high */
0142     unsigned int        flags;      /* various flags */
0143 
0144 /* The following are for internal use only. Also see uapi/linux/nfs_mount.h */
0145 #define NFS_MOUNT_LOOKUP_CACHE_NONEG    0x10000
0146 #define NFS_MOUNT_LOOKUP_CACHE_NONE 0x20000
0147 #define NFS_MOUNT_NORESVPORT        0x40000
0148 #define NFS_MOUNT_LEGACY_INTERFACE  0x80000
0149 #define NFS_MOUNT_LOCAL_FLOCK       0x100000
0150 #define NFS_MOUNT_LOCAL_FCNTL       0x200000
0151 #define NFS_MOUNT_SOFTERR       0x400000
0152 #define NFS_MOUNT_SOFTREVAL     0x800000
0153 #define NFS_MOUNT_WRITE_EAGER       0x01000000
0154 #define NFS_MOUNT_WRITE_WAIT        0x02000000
0155 #define NFS_MOUNT_TRUNK_DISCOVERY   0x04000000
0156 
0157     unsigned int        fattr_valid;    /* Valid attributes */
0158     unsigned int        caps;       /* server capabilities */
0159     unsigned int        rsize;      /* read size */
0160     unsigned int        rpages;     /* read size (in pages) */
0161     unsigned int        wsize;      /* write size */
0162     unsigned int        wpages;     /* write size (in pages) */
0163     unsigned int        wtmult;     /* server disk block size */
0164     unsigned int        dtsize;     /* readdir size */
0165     unsigned short      port;       /* "port=" setting */
0166     unsigned int        bsize;      /* server block size */
0167 #ifdef CONFIG_NFS_V4_2
0168     unsigned int        gxasize;    /* getxattr size */
0169     unsigned int        sxasize;    /* setxattr size */
0170     unsigned int        lxasize;    /* listxattr size */
0171 #endif
0172     unsigned int        acregmin;   /* attr cache timeouts */
0173     unsigned int        acregmax;
0174     unsigned int        acdirmin;
0175     unsigned int        acdirmax;
0176     unsigned int        namelen;
0177     unsigned int        options;    /* extra options enabled by mount */
0178     unsigned int        clone_blksize;  /* granularity of a CLONE operation */
0179 #define NFS_OPTION_FSCACHE  0x00000001  /* - local caching enabled */
0180 #define NFS_OPTION_MIGRATION    0x00000002  /* - NFSv4 migration enabled */
0181 
0182     enum nfs4_change_attr_type
0183                 change_attr_type;/* Description of change attribute */
0184 
0185     struct nfs_fsid     fsid;
0186     __u64           maxfilesize;    /* maximum file size */
0187     struct timespec64   time_delta; /* smallest time granularity */
0188     unsigned long       mount_time; /* when this fs was mounted */
0189     struct super_block  *super;     /* VFS super block */
0190     dev_t           s_dev;      /* superblock dev numbers */
0191     struct nfs_auth_info    auth_info;  /* parsed auth flavors */
0192 
0193 #ifdef CONFIG_NFS_FSCACHE
0194     struct fscache_volume   *fscache;   /* superblock cookie */
0195     char            *fscache_uniq;  /* Uniquifier (or NULL) */
0196 #endif
0197 
0198     u32         pnfs_blksize;   /* layout_blksize attr */
0199 #if IS_ENABLED(CONFIG_NFS_V4)
0200     u32         attr_bitmask[3];/* V4 bitmask representing the set
0201                            of attributes supported on this
0202                            filesystem */
0203     u32         attr_bitmask_nl[3];
0204                         /* V4 bitmask representing the
0205                            set of attributes supported
0206                            on this filesystem excluding
0207                            the label support bit. */
0208     u32         exclcreat_bitmask[3];
0209                         /* V4 bitmask representing the
0210                            set of attributes supported
0211                            on this filesystem for the
0212                            exclusive create. */
0213     u32         cache_consistency_bitmask[3];
0214                         /* V4 bitmask representing the subset
0215                            of change attribute, size, ctime
0216                            and mtime attributes supported by
0217                            the server */
0218     u32         acl_bitmask;    /* V4 bitmask representing the ACEs
0219                            that are supported on this
0220                            filesystem */
0221     u32         fh_expire_type; /* V4 bitmask representing file
0222                            handle volatility type for
0223                            this filesystem */
0224     struct pnfs_layoutdriver_type  *pnfs_curr_ld; /* Active layout driver */
0225     struct rpc_wait_queue   roc_rpcwaitq;
0226     void            *pnfs_ld_data;  /* per mount point data */
0227 
0228     /* the following fields are protected by nfs_client->cl_lock */
0229     struct rb_root      state_owners;
0230 #endif
0231     struct ida      openowner_id;
0232     struct ida      lockowner_id;
0233     struct list_head    state_owners_lru;
0234     struct list_head    layouts;
0235     struct list_head    delegations;
0236     struct list_head    ss_copies;
0237 
0238     unsigned long       mig_gen;
0239     unsigned long       mig_status;
0240 #define NFS_MIG_IN_TRANSITION       (1)
0241 #define NFS_MIG_FAILED          (2)
0242 #define NFS_MIG_TSM_POSSIBLE        (3)
0243 
0244     void (*destroy)(struct nfs_server *);
0245 
0246     atomic_t active; /* Keep trace of any activity to this server */
0247 
0248     /* mountd-related mount options */
0249     struct sockaddr_storage mountd_address;
0250     size_t          mountd_addrlen;
0251     u32         mountd_version;
0252     unsigned short      mountd_port;
0253     unsigned short      mountd_protocol;
0254     struct rpc_wait_queue   uoc_rpcwaitq;
0255 
0256     /* XDR related information */
0257     unsigned int        read_hdrsize;
0258 
0259     /* User namespace info */
0260     const struct cred   *cred;
0261     bool            has_sec_mnt_opts;
0262 };
0263 
0264 /* Server capabilities */
0265 #define NFS_CAP_READDIRPLUS (1U << 0)
0266 #define NFS_CAP_HARDLINKS   (1U << 1)
0267 #define NFS_CAP_SYMLINKS    (1U << 2)
0268 #define NFS_CAP_ACLS        (1U << 3)
0269 #define NFS_CAP_ATOMIC_OPEN (1U << 4)
0270 #define NFS_CAP_LGOPEN      (1U << 5)
0271 #define NFS_CAP_CASE_INSENSITIVE    (1U << 6)
0272 #define NFS_CAP_CASE_PRESERVING (1U << 7)
0273 #define NFS_CAP_POSIX_LOCK  (1U << 14)
0274 #define NFS_CAP_UIDGID_NOMAP    (1U << 15)
0275 #define NFS_CAP_STATEID_NFSV41  (1U << 16)
0276 #define NFS_CAP_ATOMIC_OPEN_V1  (1U << 17)
0277 #define NFS_CAP_SECURITY_LABEL  (1U << 18)
0278 #define NFS_CAP_SEEK        (1U << 19)
0279 #define NFS_CAP_ALLOCATE    (1U << 20)
0280 #define NFS_CAP_DEALLOCATE  (1U << 21)
0281 #define NFS_CAP_LAYOUTSTATS (1U << 22)
0282 #define NFS_CAP_CLONE       (1U << 23)
0283 #define NFS_CAP_COPY        (1U << 24)
0284 #define NFS_CAP_OFFLOAD_CANCEL  (1U << 25)
0285 #define NFS_CAP_LAYOUTERROR (1U << 26)
0286 #define NFS_CAP_COPY_NOTIFY (1U << 27)
0287 #define NFS_CAP_XATTR       (1U << 28)
0288 #define NFS_CAP_READ_PLUS   (1U << 29)
0289 #define NFS_CAP_FS_LOCATIONS    (1U << 30)
0290 #define NFS_CAP_MOVEABLE    (1U << 31)
0291 #endif