"Fossies" - the Fresh Open Source Software Archive

Member "glusterfs-7.6/api/src/glfs-internal.h" (18 May 2020, 27741 Bytes) of package /linux/misc/glusterfs-7.6.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 "glfs-internal.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 7.5_vs_7.6.

    1 /*
    2   Copyright (c) 2012-2018 Red Hat, Inc. <http://www.redhat.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 _GLFS_INTERNAL_H
   12 #define _GLFS_INTERNAL_H
   13 
   14 #include <glusterfs/xlator.h>
   15 #include <glusterfs/glusterfs.h>
   16 #include <glusterfs/upcall-utils.h>
   17 #include "glfs-handles.h"
   18 #include <glusterfs/refcount.h>
   19 #include <glusterfs/syncop.h>
   20 
   21 #define GLFS_SYMLINK_MAX_FOLLOW 2048
   22 
   23 #define DEFAULT_REVAL_COUNT 1
   24 
   25 /*
   26  * According to  pthread mutex and conditional variable ( cond,
   27  * child_down_count, upcall mutex and mutex) initialization of struct glfs
   28  * members, below GLFS_INIT_* flags are set in 'pthread_flags' member of struct
   29  * glfs. The flags are set from glfs_init() and  glfs_new_from_ctx() functions
   30  * as part of fs inititialization.
   31  *
   32  * These flag bits are validated in glfs_fini() to destroy all or partially
   33  * initialized mutex and conditional variables of glfs object.
   34  * If you introduce new pthread mutex or conditional variable in glfs object,
   35  * please make sure you have a flag bit intorduced here for proper cleanup
   36  * in glfs_fini().
   37  *
   38  */
   39 
   40 #define PTHREAD_MUTEX_INIT(mutex, attr, flags, mask, label)                    \
   41     do {                                                                       \
   42         int __ret = -1;                                                        \
   43         __ret = pthread_mutex_init(mutex, attr);                               \
   44         if (__ret == 0)                                                        \
   45             flags |= mask;                                                     \
   46         else                                                                   \
   47             goto label;                                                        \
   48     } while (0)
   49 
   50 #define PTHREAD_MUTEX_DESTROY(mutex, flags, mask)                              \
   51     do {                                                                       \
   52         if (flags & mask)                                                      \
   53             (void)pthread_mutex_destroy(mutex);                                \
   54     } while (0)
   55 
   56 #define PTHREAD_COND_INIT(cond, attr, flags, mask, label)                      \
   57     do {                                                                       \
   58         int __ret = -1;                                                        \
   59         __ret = pthread_cond_init(cond, attr);                                 \
   60         if (__ret == 0)                                                        \
   61             flags |= mask;                                                     \
   62         else                                                                   \
   63             goto label;                                                        \
   64     } while (0)
   65 
   66 #define PTHREAD_COND_DESTROY(cond, flags, mask)                                \
   67     do {                                                                       \
   68         if (flags & mask)                                                      \
   69             (void)pthread_cond_destroy(cond);                                  \
   70     } while (0)
   71 
   72 #define GLFS_INIT_MUTEX 0x00000001        /* pthread_mutex_flag */
   73 #define GLFS_INIT_COND 0x00000002         /* pthread_cond_flag */
   74 #define GLFS_INIT_COND_CHILD 0x00000004   /* pthread_cond_child_down_flag */
   75 #define GLFS_INIT_MUTEX_UPCALL 0x00000008 /* pthread_mutex_upcall_flag */
   76 
   77 #ifndef GF_DARWIN_HOST_OS
   78 #ifndef GFAPI_PUBLIC
   79 #define GFAPI_PUBLIC(sym, ver) /**/
   80 #endif
   81 #ifndef GFAPI_PRIVATE
   82 #define GFAPI_PRIVATE(sym, ver) /**/
   83 #endif
   84 #define GFAPI_SYMVER_PUBLIC_DEFAULT(fn, ver)                                   \
   85     asm(".symver pub_" STR(fn) ", " STR(fn) "@@GFAPI_" STR(ver))
   86 
   87 #define GFAPI_SYMVER_PRIVATE_DEFAULT(fn, ver)                                  \
   88     asm(".symver priv_" STR(fn) ", " STR(fn) "@@GFAPI_PRIVATE_" STR(ver))
   89 
   90 #define GFAPI_SYMVER_PUBLIC(fn1, fn2, ver)                                     \
   91     asm(".symver pub_" STR(fn1) ", " STR(fn2) "@GFAPI_" STR(ver))
   92 
   93 #define GFAPI_SYMVER_PRIVATE(fn1, fn2, ver)                                    \
   94     asm(".symver priv_" STR(fn1) ", " STR(fn2) "@GFAPI_PRIVATE_" STR(ver))
   95 #define STR(str) #str
   96 #else
   97 #ifndef GFAPI_PUBLIC
   98 #define GFAPI_PUBLIC(sym, ver) __asm("_" __STRING(sym) "$GFAPI_" __STRING(ver))
   99 #endif
  100 #ifndef GFAPI_PRIVATE
  101 #define GFAPI_PRIVATE(sym, ver)                                                \
  102     __asm("_" __STRING(sym) "$GFAPI_PRIVATE_" __STRING(ver))
  103 #endif
  104 #define GFAPI_SYMVER_PUBLIC_DEFAULT(fn, dotver)  /**/
  105 #define GFAPI_SYMVER_PRIVATE_DEFAULT(fn, dotver) /**/
  106 #define GFAPI_SYMVER_PUBLIC(fn1, fn2, dotver)    /**/
  107 #define GFAPI_SYMVER_PRIVATE(fn1, fn2, dotver)   /**/
  108 #endif
  109 
  110 #define ESTALE_RETRY(ret, errno, reval, loc, label)                            \
  111     do {                                                                       \
  112         if (ret == -1 && errno == ESTALE) {                                    \
  113             if (reval < DEFAULT_REVAL_COUNT) {                                 \
  114                 reval++;                                                       \
  115                 loc_wipe(loc);                                                 \
  116                 goto label;                                                    \
  117             }                                                                  \
  118         }                                                                      \
  119     } while (0)
  120 
  121 #define GLFS_LOC_FILL_INODE(oinode, loc, label)                                \
  122     do {                                                                       \
  123         loc.inode = inode_ref(oinode);                                         \
  124         gf_uuid_copy(loc.gfid, oinode->gfid);                                  \
  125         ret = glfs_loc_touchup(&loc);                                          \
  126         if (ret != 0) {                                                        \
  127             errno = EINVAL;                                                    \
  128             goto label;                                                        \
  129         }                                                                      \
  130     } while (0)
  131 
  132 #define GLFS_LOC_FILL_PINODE(pinode, loc, ret, errno, label, path)             \
  133     do {                                                                       \
  134         loc.inode = inode_new(pinode->table);                                  \
  135         if (!loc.inode) {                                                      \
  136             ret = -1;                                                          \
  137             errno = ENOMEM;                                                    \
  138             goto label;                                                        \
  139         }                                                                      \
  140         loc.parent = inode_ref(pinode);                                        \
  141         loc.name = path;                                                       \
  142         ret = glfs_loc_touchup(&loc);                                          \
  143         if (ret != 0) {                                                        \
  144             errno = EINVAL;                                                    \
  145             goto label;                                                        \
  146         }                                                                      \
  147     } while (0)
  148 
  149 struct glfs;
  150 
  151 struct _upcall_entry {
  152     struct list_head upcall_list;
  153     struct gf_upcall upcall_data;
  154 };
  155 typedef struct _upcall_entry upcall_entry;
  156 
  157 typedef int (*glfs_init_cbk)(struct glfs *fs, int ret);
  158 
  159 struct glfs {
  160     char *volname;
  161     uuid_t vol_uuid;
  162 
  163     glusterfs_ctx_t *ctx;
  164 
  165     pthread_t poller;
  166 
  167     glfs_init_cbk init_cbk;
  168     pthread_mutex_t mutex;
  169     pthread_cond_t cond;
  170     pthread_cond_t child_down_cond; /* for broadcasting CHILD_DOWN */
  171     int init;
  172     int ret;
  173     int err;
  174 
  175     xlator_t *active_subvol; /* active graph */
  176     xlator_t *mip_subvol;    /* graph for which migration is in
  177                               * progress */
  178     xlator_t *next_subvol;   /* Any new graph is put to
  179                               * next_subvol, the graph in
  180                               * next_subvol can either be moved
  181                               * to mip_subvol (if any IO picks it
  182                               * up for migration), or be
  183                               * destroyed (if there is a new
  184                               * graph, and this was never picked
  185                               * for migration) */
  186     xlator_t *old_subvol;
  187 
  188     char *oldvolfile;
  189     ssize_t oldvollen;
  190 
  191     inode_t *cwd;
  192 
  193     uint32_t dev_id; /* Used to fill st_dev in struct stat */
  194 
  195     struct list_head openfds;
  196 
  197     gf_boolean_t migration_in_progress;
  198 
  199     gf_boolean_t cache_upcalls; /* add upcalls to the upcall_list? */
  200     struct list_head upcall_list;
  201     pthread_mutex_t upcall_list_mutex; /* mutex for upcall entry list */
  202 
  203     uint32_t pin_refcnt;
  204     uint32_t pthread_flags; /* GLFS_INIT_* # defines set this flag */
  205 
  206     uint32_t upcall_events; /* Mask of upcall events application
  207                              * is interested in */
  208     glfs_upcall_cbk up_cbk; /* upcall cbk function to be registered */
  209     void *up_data;          /* Opaque data provided by application
  210                              * during upcall registration */
  211     struct list_head waitq; /* waiting synctasks */
  212 };
  213 
  214 /* This enum is used to maintain the state of glfd. In case of async fops
  215  * fd might be closed before the actual fop is complete. Therefore we need
  216  * to track whether the fd is closed or not, instead actually closing it.*/
  217 enum glfs_fd_state { GLFD_INIT, GLFD_OPEN, GLFD_CLOSE };
  218 
  219 struct glfs_fd {
  220     struct list_head openfds;
  221     struct list_head list;
  222     GF_REF_DECL;
  223     struct glfs *fs;
  224     enum glfs_fd_state state;
  225     off_t offset;
  226     fd_t *fd; /* Currently guared by @fs->mutex. TODO: per-glfd lock */
  227     struct list_head entries;
  228     gf_dirent_t *next;
  229     struct dirent *readdirbuf;
  230     gf_lkowner_t lk_owner;
  231     glfs_leaseid_t lease_id; /* Stores lease_id of client in glfd */
  232     gf_lock_t lock;          /* lock taken before updating fd state */
  233     glfs_recall_cbk cbk;
  234     void *cookie;
  235 };
  236 
  237 /* glfs object handle introduced for the alternate gfapi implementation based
  238    on glfs handles/gfid/inode
  239 */
  240 struct glfs_object {
  241     inode_t *inode;
  242     uuid_t gfid;
  243 };
  244 
  245 struct glfs_upcall {
  246     struct glfs *fs;                /* glfs object */
  247     enum glfs_upcall_reason reason; /* Upcall event type */
  248     void *event;                    /* changes based in the event type */
  249     void (*free_event)(void *);     /* free event after the usage */
  250 };
  251 
  252 struct glfs_upcall_inode {
  253     struct glfs_object *object;      /* Object which need to be acted upon */
  254     int flags;                       /* Cache UPDATE/INVALIDATE flags */
  255     struct stat buf;                 /* Latest stat of this entry */
  256     unsigned int expire_time_attr;   /* the amount of time for which
  257                                       * the application need to cache
  258                                       * this entry */
  259     struct glfs_object *p_object;    /* parent Object to be updated */
  260     struct stat p_buf;               /* Latest stat of parent dir handle */
  261     struct glfs_object *oldp_object; /* Old parent Object to be updated */
  262     struct stat oldp_buf;            /* Latest stat of old parent dir handle */
  263 };
  264 
  265 struct glfs_upcall_lease {
  266     struct glfs_object *object; /* Object which need to be acted upon */
  267     uint32_t lease_type;        /* Lease type to which client can downgrade to*/
  268 };
  269 
  270 struct glfs_upcall_lease_fd {
  271     uint32_t lease_type; /* Lease type to which client can downgrade to*/
  272     void *fd_cookie;     /* Object which need to be acted upon */
  273 };
  274 
  275 struct glfs_xreaddirp_stat {
  276     struct stat
  277         st; /* Stat for that dirent - corresponds to GFAPI_XREADDIRP_STAT */
  278     struct glfs_object *object; /* handled for GFAPI_XREADDIRP_HANDLE */
  279     uint32_t flags_handled;     /* final set of flags successfulyy handled */
  280 };
  281 
  282 #define DEFAULT_EVENT_POOL_SIZE 16384
  283 #define GF_MEMPOOL_COUNT_OF_DICT_T 4096
  284 #define GF_MEMPOOL_COUNT_OF_DATA_T (GF_MEMPOOL_COUNT_OF_DICT_T * 4)
  285 #define GF_MEMPOOL_COUNT_OF_DATA_PAIR_T (GF_MEMPOOL_COUNT_OF_DICT_T * 4)
  286 
  287 #define GF_MEMPOOL_COUNT_OF_LRU_BUF_T 256
  288 
  289 typedef void(glfs_mem_release_t)(void *ptr);
  290 
  291 struct glfs_mem_header {
  292     uint32_t magic;
  293     size_t nmemb;
  294     size_t size;
  295     glfs_mem_release_t *release;
  296 };
  297 
  298 #define GLFS_MEM_HEADER_SIZE (sizeof(struct glfs_mem_header))
  299 #define GLFS_MEM_HEADER_MAGIC 0x20170830
  300 
  301 static inline void *
  302 __glfs_calloc(size_t nmemb, size_t size, glfs_mem_release_t release,
  303               uint32_t type, const char *typestr)
  304 {
  305     struct glfs_mem_header *header = NULL;
  306 
  307     header = __gf_calloc(nmemb, (size + GLFS_MEM_HEADER_SIZE), type, typestr);
  308     if (!header)
  309         return NULL;
  310 
  311     header->magic = GLFS_MEM_HEADER_MAGIC;
  312     header->nmemb = nmemb;
  313     header->size = size;
  314     header->release = release;
  315 
  316     return header + 1;
  317 }
  318 
  319 static inline void *
  320 __glfs_malloc(size_t size, glfs_mem_release_t release, uint32_t type,
  321               const char *typestr)
  322 {
  323     struct glfs_mem_header *header = NULL;
  324 
  325     header = __gf_malloc((size + GLFS_MEM_HEADER_SIZE), type, typestr);
  326     if (!header)
  327         return NULL;
  328 
  329     header->magic = GLFS_MEM_HEADER_MAGIC;
  330     header->nmemb = 1;
  331     header->size = size;
  332     header->release = release;
  333 
  334     return header + 1;
  335 }
  336 
  337 static inline void *
  338 __glfs_realloc(void *ptr, size_t size)
  339 {
  340     struct glfs_mem_header *old_header = NULL;
  341     struct glfs_mem_header *new_header = NULL;
  342     struct glfs_mem_header tmp_header;
  343     void *new_ptr = NULL;
  344 
  345     GF_ASSERT(NULL != ptr);
  346 
  347     old_header = (struct glfs_mem_header *)(ptr - GLFS_MEM_HEADER_SIZE);
  348     GF_ASSERT(old_header->magic == GLFS_MEM_HEADER_MAGIC);
  349     tmp_header = *old_header;
  350 
  351     new_ptr = __gf_realloc(old_header, (size + GLFS_MEM_HEADER_SIZE));
  352     if (!new_ptr)
  353         return NULL;
  354 
  355     new_header = (struct glfs_mem_header *)new_ptr;
  356     *new_header = tmp_header;
  357     new_header->size = size;
  358 
  359     return new_header + 1;
  360 }
  361 
  362 static inline void
  363 __glfs_free(void *free_ptr)
  364 {
  365     struct glfs_mem_header *header = NULL;
  366     void *release_ptr = NULL;
  367     int i = 0;
  368 
  369     if (!free_ptr)
  370         return;
  371 
  372     header = (struct glfs_mem_header *)(free_ptr - GLFS_MEM_HEADER_SIZE);
  373     GF_ASSERT(header->magic == GLFS_MEM_HEADER_MAGIC);
  374 
  375     if (header->release) {
  376         release_ptr = free_ptr;
  377         for (i = 0; i < header->nmemb; i++) {
  378             header->release(release_ptr);
  379             release_ptr += header->size;
  380         }
  381     }
  382 
  383     __gf_free(header);
  384 }
  385 
  386 #define GLFS_CALLOC(nmemb, size, release, type)                                \
  387     __glfs_calloc(nmemb, size, release, type, #type)
  388 
  389 #define GLFS_MALLOC(size, release, type)                                       \
  390     __glfs_malloc(size, release, type, #type)
  391 
  392 #define GLFS_REALLOC(ptr, size) __glfs_realloc(ptr, size)
  393 
  394 #define GLFS_FREE(free_ptr) __glfs_free(free_ptr)
  395 
  396 int
  397 glfs_mgmt_init(struct glfs *fs);
  398 void
  399 glfs_init_done(struct glfs *fs, int ret) GFAPI_PRIVATE(glfs_init_done, 3.4.0);
  400 int
  401 glfs_process_volfp(struct glfs *fs, FILE *fp);
  402 int
  403 glfs_resolve(struct glfs *fs, xlator_t *subvol, const char *path, loc_t *loc,
  404              struct iatt *iatt, int reval) GFAPI_PRIVATE(glfs_resolve, 3.7.0);
  405 int
  406 glfs_lresolve(struct glfs *fs, xlator_t *subvol, const char *path, loc_t *loc,
  407               struct iatt *iatt, int reval);
  408 fd_t *
  409 glfs_resolve_fd(struct glfs *fs, xlator_t *subvol, struct glfs_fd *glfd);
  410 
  411 fd_t *
  412 __glfs_migrate_fd(struct glfs *fs, xlator_t *subvol, struct glfs_fd *glfd);
  413 
  414 int
  415 glfs_first_lookup(xlator_t *subvol);
  416 
  417 void
  418 glfs_process_upcall_event(struct glfs *fs, void *data)
  419     GFAPI_PRIVATE(glfs_process_upcall_event, 3.7.0);
  420 
  421 #define __GLFS_ENTRY_VALIDATE_FS(fs, label)                                    \
  422     do {                                                                       \
  423         if (!fs) {                                                             \
  424             errno = EINVAL;                                                    \
  425             goto label;                                                        \
  426         }                                                                      \
  427         old_THIS = THIS;                                                       \
  428         THIS = fs->ctx->master;                                                \
  429     } while (0)
  430 
  431 #define __GLFS_EXIT_FS                                                         \
  432     do {                                                                       \
  433         THIS = old_THIS;                                                       \
  434     } while (0)
  435 
  436 #define __GLFS_ENTRY_VALIDATE_FD(glfd, label)                                  \
  437     do {                                                                       \
  438         if (!glfd || !glfd->fd || !glfd->fd->inode ||                          \
  439             glfd->state != GLFD_OPEN) {                                        \
  440             errno = EBADF;                                                     \
  441             goto label;                                                        \
  442         }                                                                      \
  443         old_THIS = THIS;                                                       \
  444         THIS = glfd->fd->inode->table->xl->ctx->master;                        \
  445     } while (0)
  446 
  447 #define __GLFS_LOCK_WAIT(fs)                                                   \
  448     do {                                                                       \
  449         struct synctask *task = NULL;                                          \
  450                                                                                \
  451         task = synctask_get();                                                 \
  452                                                                                \
  453         if (task) {                                                            \
  454             list_add_tail(&task->waitq, &fs->waitq);                           \
  455             pthread_mutex_unlock(&fs->mutex);                                  \
  456             synctask_yield(task);                                              \
  457             pthread_mutex_lock(&fs->mutex);                                    \
  458         } else {                                                               \
  459             /* non-synctask */                                                 \
  460             pthread_cond_wait(&fs->cond, &fs->mutex);                          \
  461         }                                                                      \
  462     } while (0)
  463 
  464 #define __GLFS_SYNCTASK_WAKE(fs)                                               \
  465     do {                                                                       \
  466         struct synctask *waittask = NULL;                                      \
  467                                                                                \
  468         while (!list_empty(&fs->waitq)) {                                      \
  469             waittask = list_entry(fs->waitq.next, struct synctask, waitq);     \
  470             list_del_init(&waittask->waitq);                                   \
  471             synctask_wake(waittask);                                           \
  472         }                                                                      \
  473     } while (0)
  474 
  475 /*
  476   By default all lock attempts from user context must
  477   use glfs_lock() and glfs_unlock(). This allows
  478   for a safe implementation of graph migration where
  479   we can give up the mutex during syncop calls so
  480   that bottom up calls (particularly CHILD_UP notify)
  481   can do a mutex_lock() on @glfs without deadlocking
  482   the filesystem.
  483 
  484   All the fops should wait for graph migration to finish
  485   before starting the fops. Therefore these functions should
  486   call glfs_lock with wait_for_migration as true. But waiting
  487   for migration to finish in call-back path can result thread
  488   dead-locks. The reason for this is we only have finite
  489   number of epoll threads. so if we wait on epoll threads
  490   there will not be any thread left to handle outstanding
  491   rpc replies.
  492 */
  493 static inline int
  494 glfs_lock(struct glfs *fs, gf_boolean_t wait_for_migration)
  495 {
  496     pthread_mutex_lock(&fs->mutex);
  497 
  498     while (!fs->init)
  499         __GLFS_LOCK_WAIT(fs);
  500 
  501     while (wait_for_migration && fs->migration_in_progress)
  502         __GLFS_LOCK_WAIT(fs);
  503 
  504     return 0;
  505 }
  506 
  507 static inline void
  508 glfs_unlock(struct glfs *fs)
  509 {
  510     pthread_mutex_unlock(&fs->mutex);
  511 }
  512 
  513 struct glfs_fd *
  514 glfs_fd_new(struct glfs *fs);
  515 void
  516 glfs_fd_bind(struct glfs_fd *glfd);
  517 void
  518 glfd_set_state_bind(struct glfs_fd *glfd);
  519 
  520 xlator_t *
  521 glfs_active_subvol(struct glfs *fs) GFAPI_PRIVATE(glfs_active_subvol, 3.4.0);
  522 xlator_t *
  523 __glfs_active_subvol(struct glfs *fs);
  524 void
  525 glfs_subvol_done(struct glfs *fs, xlator_t *subvol)
  526     GFAPI_PRIVATE(glfs_subvol_done, 3.4.0);
  527 
  528 inode_t *
  529 glfs_refresh_inode(xlator_t *subvol, inode_t *inode);
  530 
  531 inode_t *
  532 glfs_cwd_get(struct glfs *fs);
  533 int
  534 glfs_cwd_set(struct glfs *fs, inode_t *inode);
  535 inode_t *
  536 glfs_resolve_inode(struct glfs *fs, xlator_t *subvol,
  537                    struct glfs_object *object);
  538 int
  539 glfs_create_object(loc_t *loc, struct glfs_object **retobject);
  540 int
  541 __glfs_cwd_set(struct glfs *fs, inode_t *inode);
  542 
  543 int
  544 glfs_resolve_base(struct glfs *fs, xlator_t *subvol, inode_t *inode,
  545                   struct iatt *iatt);
  546 
  547 int
  548 glfs_resolve_at(struct glfs *fs, xlator_t *subvol, inode_t *at,
  549                 const char *origpath, loc_t *loc, struct iatt *iatt, int follow,
  550                 int reval) GFAPI_PRIVATE(glfs_resolve_at, 3.4.0);
  551 int
  552 glfs_loc_touchup(loc_t *loc) GFAPI_PRIVATE(glfs_loc_touchup, 3.4.0);
  553 void
  554 glfs_iatt_to_stat(struct glfs *fs, struct iatt *iatt, struct stat *stat);
  555 void
  556 glfs_iatt_from_stat(struct stat *stat, int valid, struct iatt *iatt,
  557                     int *gvalid);
  558 int
  559 glfs_loc_link(loc_t *loc, struct iatt *iatt);
  560 int
  561 glfs_loc_unlink(loc_t *loc);
  562 int
  563 glfs_getxattr_process(void *value, size_t size, dict_t *xattr,
  564                       const char *name);
  565 
  566 /* Sends RPC call to glusterd to fetch required volume info */
  567 int
  568 glfs_get_volume_info(struct glfs *fs);
  569 
  570 /*
  571   SYNOPSIS
  572 
  573        glfs_new_from_ctx: Creates a virtual mount object by taking a
  574        glusterfs_ctx_t object.
  575 
  576   DESCRIPTION
  577 
  578        glfs_new_from_ctx() is not same as glfs_new(). It takes the
  579        glusterfs_ctx_t object instead of creating one by glusterfs_ctx_new().
  580        Again the usage is restricted to NFS MOUNT over UDP i.e. in
  581        glfs_resolve_at() which would take fs object as input but never use
  582        (purpose is not to change the ABI of glfs_resolve_at()).
  583 
  584   PARAMETERS
  585 
  586        @ctx: glusterfs_ctx_t object
  587 
  588   RETURN VALUES
  589 
  590        fs     : Pointer to the newly created glfs_t object.
  591        NULL   : Otherwise.
  592 */
  593 
  594 struct glfs *
  595 glfs_new_from_ctx(glusterfs_ctx_t *ctx) GFAPI_PRIVATE(glfs_new_from_ctx, 3.7.0);
  596 
  597 /*
  598   SYNOPSIS
  599 
  600        glfs_free_from_ctx: Free up the memory occupied by glfs_t object
  601        created by glfs_new_from_ctx().
  602 
  603   DESCRIPTION
  604 
  605        The glfs_t object allocated by glfs_new_from_ctx() must be released
  606        by the caller using this routine. The usage can be found
  607        at glfs_fini() or NFS, MOUNT over UDP i.e.
  608                         __mnt3udp_get_export_subdir_inode ()
  609                                 => glfs_resolve_at().
  610 
  611   PARAMETERS
  612 
  613        @fs: The glfs_t object to be deallocated.
  614 
  615   RETURN VALUES
  616 
  617        void
  618 */
  619 
  620 void
  621 glfs_free_from_ctx(struct glfs *fs) GFAPI_PRIVATE(glfs_free_from_ctx, 3.7.0);
  622 
  623 int
  624 glfs_recall_lease_fd(struct glfs *fs, struct gf_upcall *up_data);
  625 
  626 int
  627 glfs_get_upcall_cache_invalidation(struct gf_upcall *to_up_data,
  628                                    struct gf_upcall *from_up_data);
  629 int
  630 glfs_h_poll_cache_invalidation(struct glfs *fs, struct glfs_upcall *up_arg,
  631                                struct gf_upcall *upcall_data);
  632 
  633 ssize_t
  634 glfs_anonymous_preadv(struct glfs *fs, struct glfs_object *object,
  635                       const struct iovec *iovec, int iovcnt, off_t offset,
  636                       int flags);
  637 ssize_t
  638 glfs_anonymous_pwritev(struct glfs *fs, struct glfs_object *object,
  639                        const struct iovec *iovec, int iovcnt, off_t offset,
  640                        int flags);
  641 
  642 struct glfs_object *
  643 glfs_h_resolve_symlink(struct glfs *fs, struct glfs_object *object);
  644 
  645 /* Deprecated structures that were passed to client applications, replaced by
  646  * accessor functions. Do not use these in new applications, and update older
  647  * usage.
  648  *
  649  * See http://review.gluster.org/14701 for more details.
  650  *
  651  * WARNING: These structures will be removed in the future.
  652  */
  653 struct glfs_callback_arg {
  654     struct glfs *fs;
  655     enum glfs_upcall_reason reason;
  656     void *event_arg;
  657 };
  658 
  659 struct glfs_callback_inode_arg {
  660     struct glfs_object *object;      /* Object which need to be acted upon */
  661     int flags;                       /* Cache UPDATE/INVALIDATE flags */
  662     struct stat buf;                 /* Latest stat of this entry */
  663     unsigned int expire_time_attr;   /* the amount of time for which
  664                                       * the application need to cache
  665                                       * this entry
  666                                       */
  667     struct glfs_object *p_object;    /* parent Object to be updated */
  668     struct stat p_buf;               /* Latest stat of parent dir handle */
  669     struct glfs_object *oldp_object; /* Old parent Object
  670                                       * to be updated */
  671     struct stat oldp_buf;            /* Latest stat of old parent
  672                                       * dir handle */
  673 };
  674 struct dirent *
  675 glfs_readdirbuf_get(struct glfs_fd *glfd);
  676 
  677 gf_dirent_t *
  678 glfd_entry_next(struct glfs_fd *glfd, int plus);
  679 
  680 void
  681 gf_dirent_to_dirent(gf_dirent_t *gf_dirent, struct dirent *dirent);
  682 
  683 void
  684 gf_lease_to_glfs_lease(struct gf_lease *gf_lease, struct glfs_lease *lease);
  685 
  686 void
  687 glfs_lease_to_gf_lease(struct glfs_lease *lease, struct gf_lease *gf_lease);
  688 
  689 void
  690 glfs_release_upcall(void *ptr);
  691 
  692 int
  693 get_fop_attr_glfd(dict_t **fop_attr, struct glfs_fd *glfd);
  694 
  695 int
  696 set_fop_attr_glfd(struct glfs_fd *glfd);
  697 
  698 int
  699 get_fop_attr_thrd_key(dict_t **fop_attr);
  700 
  701 void
  702 unset_fop_attr(dict_t **fop_attr);
  703 
  704 /*
  705   SYNOPSIS
  706   glfs_statx: Fetch extended file attributes for the given path.
  707 
  708   DESCRIPTION
  709   This function fetches extended file attributes for the given path.
  710 
  711   PARAMETERS
  712   @fs: The 'virtual mount' object referencing a volume, under which file exists.
  713   @path: Path of the file within the virtual mount.
  714   @mask: Requested extended file attributes mask, (See mask defines above)
  715 
  716   RETURN VALUES
  717   -1 : Failure. @errno will be set with the type of failure.
  718   0  : Filled in statxbuf with appropriate masks for valid items in the
  719        structure.
  720 
  721   ERRNO VALUES
  722     EINVAL: fs is invalid
  723     EINVAL: mask has unsupported bits set
  724     Other errors as returned by stat(2)
  725  */
  726 
  727 int
  728 glfs_statx(struct glfs *fs, const char *path, unsigned int mask,
  729            struct glfs_stat *statxbuf) GFAPI_PRIVATE(glfs_statx, 6.0);
  730 
  731 void
  732 glfs_iatt_from_statx(struct iatt *, const struct glfs_stat *)
  733     GFAPI_PRIVATE(glfs_iatt_from_statx, 6.0);
  734 
  735 /*
  736  * This API is a per thread setting, similar to glfs_setfs{u/g}id, because of
  737  * the call to syncopctx_setfspid.
  738  */
  739 int
  740 glfs_setfspid(struct glfs *, pid_t) GFAPI_PRIVATE(glfs_setfspid, 6.1);
  741 #endif /* !_GLFS_INTERNAL_H */