"Fossies" - the Fresh Open Source Software Archive

Member "glusterfs-8.2/xlators/features/cloudsync/src/cloudsync-common.h" (16 Sep 2020, 4746 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 "cloudsync-common.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2   Copyright (c) 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 #ifndef _CLOUDSYNC_COMMON_H
   11 #define _CLOUDSYNC_COMMON_H
   12 
   13 #include <glusterfs/glusterfs.h>
   14 #include <glusterfs/call-stub.h>
   15 #include <glusterfs/xlator.h>
   16 #include <glusterfs/syncop.h>
   17 #include <glusterfs/compat-errno.h>
   18 #include "cloudsync-mem-types.h"
   19 #include "cloudsync-messages.h"
   20 
   21 typedef struct cs_loc_xattr {
   22     char *file_path;
   23     uuid_t uuid;
   24     uuid_t gfid;
   25     char *volname;
   26 } cs_loc_xattr_t;
   27 
   28 typedef struct cs_size_xattr {
   29     uint64_t size;
   30     uint64_t blksize;
   31     uint64_t blocks;
   32 } cs_size_xattr_t;
   33 
   34 typedef struct cs_local {
   35     loc_t loc;
   36     fd_t *fd;
   37     call_stub_t *stub;
   38     call_frame_t *main_frame;
   39     int op_errno;
   40     int op_ret;
   41     fd_t *dlfd;
   42     off_t dloffset;
   43     struct iatt stbuf;
   44     dict_t *xattr_rsp;
   45     dict_t *xattr_req;
   46     glusterfs_fop_t fop;
   47     gf_boolean_t locked;
   48     int call_cnt;
   49     inode_t *inode;
   50     char *remotepath;
   51 
   52     struct {
   53         /* offset, flags and size are the information needed
   54          * by read fop for remote read operation. These will be
   55          * populated in cloudsync read fop, before being passed
   56          * on to the plugin performing remote read.
   57          */
   58         off_t offset;
   59         uint32_t flags;
   60         size_t size;
   61         cs_loc_xattr_t *lxattr;
   62     } xattrinfo;
   63 
   64 } cs_local_t;
   65 
   66 typedef int (*fop_download_t)(call_frame_t *frame, void *config);
   67 
   68 typedef int (*fop_remote_read_t)(call_frame_t *, void *);
   69 
   70 typedef void *(*store_init)(xlator_t *this);
   71 
   72 typedef int (*store_reconfigure)(xlator_t *this, dict_t *options);
   73 
   74 typedef void (*store_fini)(void *config);
   75 
   76 struct cs_remote_stores {
   77     char *name;                    /* store name */
   78     void *config;                  /* store related information */
   79     fop_download_t dlfop;          /* store specific download function */
   80     fop_remote_read_t rdfop;       /* store specific read function */
   81     store_init init;               /* store init to initialize store config */
   82     store_reconfigure reconfigure; /* reconfigure store config */
   83     store_fini fini;
   84     void *handle; /* shared library handle*/
   85 };
   86 
   87 typedef struct cs_private {
   88     xlator_t *this;
   89     struct cs_remote_stores *stores;
   90     gf_boolean_t abortdl;
   91     pthread_spinlock_t lock;
   92     gf_boolean_t remote_read;
   93 } cs_private_t;
   94 
   95 void
   96 cs_local_wipe(xlator_t *this, cs_local_t *local);
   97 
   98 void
   99 cs_xattrinfo_wipe(cs_local_t *local);
  100 
  101 #define CS_STACK_UNWIND(fop, frame, params...)                                 \
  102     do {                                                                       \
  103         cs_local_t *__local = NULL;                                            \
  104         xlator_t *__xl = NULL;                                                 \
  105         if (frame) {                                                           \
  106             __xl = frame->this;                                                \
  107             __local = frame->local;                                            \
  108             frame->local = NULL;                                               \
  109         }                                                                      \
  110         STACK_UNWIND_STRICT(fop, frame, params);                               \
  111         cs_local_wipe(__xl, __local);                                          \
  112     } while (0)
  113 
  114 #define CS_STACK_DESTROY(frame)                                                \
  115     do {                                                                       \
  116         cs_local_t *__local = NULL;                                            \
  117         xlator_t *__xl = NULL;                                                 \
  118         __xl = frame->this;                                                    \
  119         __local = frame->local;                                                \
  120         frame->local = NULL;                                                   \
  121         STACK_DESTROY(frame->root);                                            \
  122         cs_local_wipe(__xl, __local);                                          \
  123     } while (0)
  124 
  125 typedef struct store_methods {
  126     int (*fop_download)(call_frame_t *frame, void *config);
  127     int (*fop_remote_read)(call_frame_t *, void *);
  128     /* return type should be the store config */
  129     void *(*fop_init)(xlator_t *this);
  130     int (*fop_reconfigure)(xlator_t *this, dict_t *options);
  131     void (*fop_fini)(void *config);
  132 } store_methods_t;
  133 
  134 #endif /* _CLOUDSYNC_COMMON_H */