"Fossies" - the Fresh Open Source Software Archive

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

    1 /*
    2    Copyright (c) 2006-2012 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 __TRASH_H__
   11 #define __TRASH_H__
   12 
   13 #include <glusterfs/glusterfs.h>
   14 #include <glusterfs/logging.h>
   15 #include <glusterfs/dict.h>
   16 #include <glusterfs/xlator.h>
   17 #include <glusterfs/defaults.h>
   18 #include "inode.c"
   19 #include "fnmatch.h"
   20 
   21 #include <libgen.h>
   22 
   23 #ifndef GF_BLOCK_READV_SIZE
   24 #define GF_BLOCK_READV_SIZE (128 * GF_UNIT_KB)
   25 #endif
   26 
   27 #ifndef GF_DEFAULT_MAX_FILE_SIZE
   28 #define GF_DEFAULT_MAX_FILE_SIZE (200 * GF_UNIT_MB)
   29 #endif
   30 
   31 struct trash_struct {
   32     fd_t *fd;         /* for the fd of existing file */
   33     fd_t *newfd;      /* for the newly created file */
   34     loc_t loc;        /* to store the location of the existing file */
   35     loc_t newloc;     /* to store the location for the new file */
   36     size_t fsize;     /* for keeping the size of existing file */
   37     off_t cur_offset; /* current offset for read and write ops */
   38     off_t fop_offset; /* original offset received with the fop */
   39     pid_t pid;
   40     char origpath[PATH_MAX];
   41     char newpath[PATH_MAX];
   42     int32_t loop_count;
   43     gf_boolean_t is_set_pid;
   44     struct iatt preparent;
   45     struct iatt postparent;
   46     gf_boolean_t ctr_link_count_req;
   47 };
   48 typedef struct trash_struct trash_local_t;
   49 
   50 struct _trash_elim_path {
   51     struct _trash_elim_path *next;
   52     char *path;
   53 };
   54 typedef struct _trash_elim_path trash_elim_path;
   55 
   56 struct trash_priv {
   57     char *oldtrash_dir;
   58     char *newtrash_dir;
   59     char *brick_path;
   60     trash_elim_path *eliminate;
   61     size_t max_trash_file_size;
   62     gf_boolean_t state;
   63     gf_boolean_t internal;
   64     inode_t *trash_inode;
   65     inode_table_t *trash_itable;
   66 };
   67 typedef struct trash_priv trash_private_t;
   68 
   69 #define TRASH_SET_PID(frame, local)                                            \
   70     do {                                                                       \
   71         GF_ASSERT(!local->is_set_pid);                                         \
   72         if (!local->is_set_pid) {                                              \
   73             local->pid = frame->root->pid;                                     \
   74             frame->root->pid = GF_SERVER_PID_TRASH;                            \
   75             local->is_set_pid = _gf_true;                                      \
   76         }                                                                      \
   77     } while (0)
   78 
   79 #define TRASH_UNSET_PID(frame, local)                                          \
   80     do {                                                                       \
   81         GF_ASSERT(local->is_set_pid);                                          \
   82         if (local->is_set_pid) {                                               \
   83             frame->root->pid = local->pid;                                     \
   84             local->is_set_pid = _gf_false;                                     \
   85         }                                                                      \
   86     } while (0)
   87 
   88 #define TRASH_STACK_UNWIND(op, frame, params...)                               \
   89     do {                                                                       \
   90         trash_local_t *__local = NULL;                                         \
   91         __local = frame->local;                                                \
   92         frame->local = NULL;                                                   \
   93         STACK_UNWIND_STRICT(op, frame, params);                                \
   94         trash_local_wipe(__local);                                             \
   95     } while (0)
   96 
   97 #endif /* __TRASH_H__ */