"Fossies" - the Fresh Open Source Software Archive

Member "glusterfs-8.2/xlators/nfs/server/src/nfs.h" (16 Sep 2020, 4387 Bytes) of package /linux/misc/glusterfs-8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "nfs.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2   Copyright (c) 2010-2011 Gluster, Inc. <http://www.gluster.com>
    3   This file is part of GlusterFS.
    4 
    5   This file is licensed to you under your choice of the GNU Lesser
    6   General Public License, version 3 or any later version (LGPLv3 or
    7   later), or the GNU General Public License, version 2 (GPLv2), in all
    8   cases as published by the Free Software Foundation.
    9 */
   10 
   11 #ifndef __NFS_H__
   12 #define __NFS_H__
   13 
   14 #include "rpcsvc.h"
   15 #include <glusterfs/dict.h>
   16 #include <glusterfs/xlator.h>
   17 #include <glusterfs/lkowner.h>
   18 #include <glusterfs/gidcache.h>
   19 
   20 #define GF_NFS "nfs"
   21 
   22 #define GF_NFS_CONCURRENT_OPS_MULT 15
   23 
   24 #define GF_NFS_INODE_LRU_MULT 6000
   25 
   26 #define GF_RPC_MIN_THREADS 1
   27 #define GF_RPC_MAX_THREADS 16
   28 
   29 #define GF_NFS_DEFAULT_MEMFACTOR 15
   30 #define GF_NFS_MIN_MEMFACTOR 1
   31 #define GF_NFS_MAX_MEMFACTOR 30
   32 
   33 #define GF_NFS_DVM_ON 1
   34 #define GF_NFS_DVM_OFF 0
   35 
   36 /* Disable using the exports file by default */
   37 #define GF_NFS_DEFAULT_EXPORT_AUTH 0
   38 
   39 #define GF_NFS_DEFAULT_AUTH_REFRESH_INTERVAL_SEC 2
   40 #define GF_NFS_DEFAULT_AUTH_CACHE_TTL_SEC 300 /* 5 min */
   41 
   42 /* This corresponds to the max 16 number of group IDs that are sent through an
   43  * RPC request. Since NFS is the only one going to set this, we can be safe
   44  * in keeping this size hardcoded.
   45  */
   46 #define GF_REQUEST_MAXGROUPS 16
   47 
   48 /* Callback into a version-specific NFS protocol.
   49  * The return type is used by the nfs.c code to register the protocol.
   50  * with the RPC service.
   51  */
   52 typedef rpcsvc_program_t *(*nfs_version_initer_t)(xlator_t *nfsx);
   53 
   54 /* List of version-specific protocol initiators */
   55 struct nfs_initer_list {
   56     struct list_head list;
   57     nfs_version_initer_t init;
   58     rpcsvc_program_t *program;
   59     gf_boolean_t required;
   60 };
   61 
   62 struct nfs_state {
   63     rpcsvc_t *rpcsvc;
   64     struct list_head versions;
   65     struct mount3_state *mstate;
   66     struct nfs3_state *nfs3state;
   67     struct nlm4_state *nlm4state;
   68     struct mem_pool *foppool;
   69     unsigned int memfactor;
   70     xlator_list_t *subvols;
   71 
   72     gf_lock_t svinitlock;
   73     int allsubvols;
   74     int upsubvols;
   75     xlator_t **initedxl;
   76     int subvols_started;
   77     int dynamicvolumes;
   78     int enable_ino32;
   79     unsigned int override_portnum;
   80     int allow_insecure;
   81     int enable_nlm;
   82     int enable_acl;
   83     int mount_udp;
   84 
   85     /* Enable exports auth model */
   86     int exports_auth;
   87     /* Refresh auth params from disk periodically */
   88     int refresh_auth;
   89 
   90     unsigned int auth_refresh_time_secs;
   91     unsigned int auth_cache_ttl_sec;
   92 
   93     char *rmtab;
   94     struct rpc_clnt *rpc_clnt;
   95     gf_boolean_t server_aux_gids;
   96     uint32_t server_aux_gids_max_age;
   97     gid_cache_t gid_cache;
   98     uint32_t generation;
   99     gf_boolean_t register_portmap;
  100     char *rpc_statd;
  101     char *rpc_statd_pid_file;
  102     gf_boolean_t rdirplus;
  103     uint32_t event_threads;
  104 };
  105 
  106 struct nfs_inode_ctx {
  107     struct list_head shares;
  108     uint32_t generation;
  109 };
  110 
  111 #define gf_nfs_dvm_on(nfsstt)                                                  \
  112     (((struct nfs_state *)nfsstt)->dynamicvolumes == GF_NFS_DVM_ON)
  113 #define gf_nfs_dvm_off(nfsstt)                                                 \
  114     (((struct nfs_state *)nfsstt)->dynamicvolumes == GF_NFS_DVM_OFF)
  115 #define __gf_nfs_enable_ino32(nfsstt)                                          \
  116     (((struct nfs_state *)nfsstt)->enable_ino32)
  117 #define gf_nfs_this_private ((struct nfs_state *)((xlator_t *)THIS)->private)
  118 #define gf_nfs_enable_ino32() (__gf_nfs_enable_ino32(gf_nfs_this_private))
  119 
  120 /* We have one gid more than the glusterfs maximum since we pass the primary
  121  * gid as the first element of the array.
  122  */
  123 #define NFS_NGROUPS (GF_REQUEST_MAXGROUPS + 1)
  124 
  125 /* Index of the primary gid */
  126 #define NFS_PRIMGID_IDX 0
  127 
  128 typedef struct nfs_user_info {
  129     uid_t uid;
  130     gid_t gids[NFS_NGROUPS];
  131     int ngrps;
  132     gf_lkowner_t lk_owner;
  133     char identifier[UNIX_PATH_MAX]; /* ip of user */
  134 } nfs_user_t;
  135 
  136 extern int
  137 nfs_user_root_create(nfs_user_t *newnfu);
  138 
  139 extern int
  140 nfs_user_create(nfs_user_t *newnfu, uid_t uid, gid_t gid,
  141                 rpc_transport_t *trans, gid_t *auxgids, int auxcount);
  142 
  143 extern void
  144 nfs_request_user_init(nfs_user_t *nfu, rpcsvc_request_t *req);
  145 
  146 extern void
  147 nfs_request_primary_user_init(nfs_user_t *nfu, rpcsvc_request_t *req, uid_t uid,
  148                               gid_t gid);
  149 extern int
  150 nfs_subvolume_started(struct nfs_state *nfs, xlator_t *xl);
  151 
  152 extern void
  153 nfs_fix_groups(xlator_t *this, call_stack_t *root);
  154 #endif