"Fossies" - the Fresh Open Source Software Archive

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

    1 /*
    2    Copyright (c) 2014 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 __BARRIER_H__
   12 #define __BARRIER_H__
   13 
   14 #include "barrier-mem-types.h"
   15 #include <glusterfs/xlator.h>
   16 #include <glusterfs/timer.h>
   17 #include <glusterfs/call-stub.h>
   18 
   19 #define BARRIER_FOP_CBK(fop_name, label, frame, this, params...)               \
   20     do {                                                                       \
   21         barrier_priv_t *_priv = NULL;                                          \
   22         call_stub_t *_stub = NULL;                                             \
   23         gf_boolean_t _barrier_enabled = _gf_false;                             \
   24         struct list_head queue = {                                             \
   25             0,                                                                 \
   26         };                                                                     \
   27                                                                                \
   28         INIT_LIST_HEAD(&queue);                                                \
   29                                                                                \
   30         _priv = this->private;                                                 \
   31         GF_ASSERT(_priv);                                                      \
   32                                                                                \
   33         LOCK(&_priv->lock);                                                    \
   34         {                                                                      \
   35             if (_priv->barrier_enabled) {                                      \
   36                 _barrier_enabled = _priv->barrier_enabled;                     \
   37                                                                                \
   38                 _stub = fop_##fop_name##_cbk_stub(                             \
   39                     frame, barrier_##fop_name##_cbk_resume, params);           \
   40                 if (!_stub) {                                                  \
   41                     __barrier_disable(this, &queue);                           \
   42                     goto unlock;                                               \
   43                 }                                                              \
   44                                                                                \
   45                 __barrier_enqueue(this, _stub);                                \
   46             }                                                                  \
   47         }                                                                      \
   48     unlock:                                                                    \
   49         UNLOCK(&_priv->lock);                                                  \
   50                                                                                \
   51         if (_stub)                                                             \
   52             goto label;                                                        \
   53                                                                                \
   54         if (_barrier_enabled && !_stub) {                                      \
   55             gf_log(this->name, GF_LOG_CRITICAL,                                \
   56                    "Failed to barrier FOPs, disabling "                        \
   57                    "barrier. FOP: %s, ERROR: %s",                              \
   58                    #fop_name, strerror(ENOMEM));                               \
   59             barrier_dequeue_all(this, &queue);                                 \
   60         }                                                                      \
   61         barrier_local_free_gfid(frame);                                        \
   62         STACK_UNWIND_STRICT(fop_name, frame, params);                          \
   63         goto label;                                                            \
   64     } while (0)
   65 
   66 typedef struct {
   67     gf_timer_t *timer;
   68     gf_lock_t lock;
   69     struct list_head queue;
   70     struct timespec timeout;
   71     uint32_t queue_size;
   72     gf_boolean_t barrier_enabled;
   73     char _pad[3]; /* manual padding */
   74 } barrier_priv_t;
   75 
   76 int
   77 __barrier_enable(xlator_t *this, barrier_priv_t *priv);
   78 void
   79 __barrier_enqueue(xlator_t *this, call_stub_t *stub);
   80 void
   81 __barrier_disable(xlator_t *this, struct list_head *queue);
   82 void
   83 barrier_timeout(void *data);
   84 void
   85 barrier_dequeue_all(xlator_t *this, struct list_head *queue);
   86 call_stub_t *
   87 __barrier_dequeue(xlator_t *this, struct list_head *queue);
   88 
   89 #endif