"Fossies" - the Fresh Open Source Software Archive

Member "glusterfs-8.2/xlators/meta/src/volfile-file.c" (16 Sep 2020, 1882 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 "volfile-file.c" 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 #include <glusterfs/xlator.h>
   12 #include <glusterfs/defaults.h>
   13 
   14 #include "meta-mem-types.h"
   15 #include "meta.h"
   16 #include <glusterfs/strfd.h>
   17 
   18 static int
   19 xldump_options(dict_t *this, char *key, data_t *value, void *strfd)
   20 {
   21     strprintf(strfd, "    option %s %s\n", key, value->data);
   22     return 0;
   23 }
   24 
   25 static void
   26 xldump_subvolumes(xlator_t *this, void *strfd)
   27 {
   28     xlator_list_t *subv = NULL;
   29 
   30     if (!this->children)
   31         return;
   32 
   33     strprintf(strfd, "    subvolumes");
   34 
   35     for (subv = this->children; subv; subv = subv->next)
   36         strprintf(strfd, " %s", subv->xlator->name);
   37 
   38     strprintf(strfd, "\n");
   39 }
   40 
   41 static void
   42 xldump(xlator_t *each, void *strfd)
   43 {
   44     strprintf(strfd, "volume %s\n", each->name);
   45     strprintf(strfd, "    type %s\n", each->type);
   46     dict_foreach(each->options, xldump_options, strfd);
   47 
   48     xldump_subvolumes(each, strfd);
   49 
   50     strprintf(strfd, "end-volume\n");
   51     strprintf(strfd, "\n");
   52 }
   53 
   54 static int
   55 volfile_file_fill(xlator_t *this, inode_t *file, strfd_t *strfd)
   56 {
   57     glusterfs_graph_t *graph = NULL;
   58 
   59     graph = meta_ctx_get(file, this);
   60 
   61     xlator_foreach_depth_first(graph->top, xldump, strfd);
   62 
   63     return strfd->size;
   64 }
   65 
   66 static struct meta_ops volfile_file_ops = {
   67     .file_fill = volfile_file_fill,
   68 };
   69 
   70 int
   71 meta_volfile_file_hook(call_frame_t *frame, xlator_t *this, loc_t *loc,
   72                        dict_t *xdata)
   73 {
   74     meta_ops_set(loc->inode, this, &volfile_file_ops);
   75 
   76     meta_ctx_set(loc->inode, this, meta_ctx_get(loc->parent, this));
   77 
   78     return 0;
   79 }