"Fossies" - the Fresh Open Source Software Archive

Member "glusterfs-8.2/xlators/meta/src/meta.c" (16 Sep 2020, 6319 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 "meta.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 
   17 #include "meta-hooks.h"
   18 
   19 int
   20 meta_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
   21 {
   22     inode_t *inode = NULL;
   23 
   24     if (META_HOOK(loc) || IS_META_ROOT_GFID(loc->gfid)) {
   25         struct iatt iatt = {};
   26         struct iatt parent = {};
   27 
   28         meta_root_dir_hook(frame, this, loc, xdata);
   29 
   30         meta_iatt_fill(&iatt, loc->inode, IA_IFDIR);
   31         gf_uuid_parse(META_ROOT_GFID, iatt.ia_gfid);
   32 
   33         META_STACK_UNWIND(lookup, frame, 0, 0, loc->inode, &iatt, xdata,
   34                           &parent);
   35         return 0;
   36     }
   37 
   38     if (loc->parent)
   39         inode = loc->parent;
   40     else
   41         inode = loc->inode;
   42 
   43     META_FOP(inode, lookup, frame, this, loc, xdata);
   44 
   45     return 0;
   46 }
   47 
   48 int
   49 meta_opendir(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
   50              dict_t *xdata)
   51 {
   52     META_FOP(fd->inode, opendir, frame, this, loc, fd, xdata);
   53 
   54     return 0;
   55 }
   56 
   57 int
   58 meta_open(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, fd_t *fd,
   59           dict_t *xdata)
   60 {
   61     META_FOP(fd->inode, open, frame, this, loc, flags, fd, xdata);
   62 
   63     return 0;
   64 }
   65 
   66 int
   67 meta_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
   68            off_t offset, uint32_t flags, dict_t *xdata)
   69 {
   70     META_FOP(fd->inode, readv, frame, this, fd, size, offset, flags, xdata);
   71 
   72     return 0;
   73 }
   74 
   75 int
   76 meta_flush(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
   77 {
   78     META_FOP(fd->inode, flush, frame, this, fd, xdata);
   79 
   80     return 0;
   81 }
   82 
   83 int
   84 meta_stat(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
   85 {
   86     META_FOP(loc->inode, stat, frame, this, loc, xdata);
   87 
   88     return 0;
   89 }
   90 
   91 int
   92 meta_fstat(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
   93 {
   94     META_FOP(fd->inode, fstat, frame, this, fd, xdata);
   95 
   96     return 0;
   97 }
   98 
   99 int
  100 meta_readdir(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
  101              off_t offset, dict_t *xdata)
  102 {
  103     META_FOP(fd->inode, readdir, frame, this, fd, size, offset, xdata);
  104 
  105     return 0;
  106 }
  107 
  108 int
  109 meta_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
  110               off_t offset, dict_t *xdata)
  111 {
  112     META_FOP(fd->inode, readdirp, frame, this, fd, size, offset, xdata);
  113 
  114     return 0;
  115 }
  116 
  117 int
  118 meta_readlink(call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size,
  119               dict_t *xdata)
  120 {
  121     META_FOP(loc->inode, readlink, frame, this, loc, size, xdata);
  122 
  123     return 0;
  124 }
  125 
  126 int
  127 meta_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *iov,
  128             int count, off_t offset, uint32_t flags, struct iobref *iobref,
  129             dict_t *xdata)
  130 {
  131     META_FOP(fd->inode, writev, frame, this, fd, iov, count, offset, flags,
  132              iobref, xdata);
  133     return 0;
  134 }
  135 
  136 int
  137 meta_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
  138               dict_t *xdata)
  139 {
  140     META_FOP(loc->inode, truncate, frame, this, loc, offset, xdata);
  141 
  142     return 0;
  143 }
  144 
  145 int
  146 meta_ftruncate(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
  147                dict_t *xdata)
  148 {
  149     META_FOP(fd->inode, ftruncate, frame, this, fd, offset, xdata);
  150 
  151     return 0;
  152 }
  153 
  154 int32_t
  155 meta_fsync(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags,
  156            dict_t *xdata)
  157 {
  158     META_FOP(fd->inode, fsync, frame, this, fd, flags, xdata);
  159 
  160     return 0;
  161 }
  162 
  163 int32_t
  164 meta_fsyncdir(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags,
  165               dict_t *xdata)
  166 {
  167     META_FOP(fd->inode, fsyncdir, frame, this, fd, flags, xdata);
  168 
  169     return 0;
  170 }
  171 
  172 int
  173 meta_forget(xlator_t *this, inode_t *inode)
  174 {
  175     return 0;
  176 }
  177 
  178 int
  179 meta_release(xlator_t *this, fd_t *fd)
  180 {
  181     return meta_fd_release(fd, this);
  182 }
  183 
  184 int
  185 meta_releasedir(xlator_t *this, fd_t *fd)
  186 {
  187     return meta_fd_release(fd, this);
  188 }
  189 
  190 int
  191 mem_acct_init(xlator_t *this)
  192 {
  193     int ret = -1;
  194 
  195     if (!this)
  196         return ret;
  197 
  198     ret = xlator_mem_acct_init(this, gf_meta_mt_end + 1);
  199 
  200     if (ret != 0) {
  201         gf_log(this->name, GF_LOG_ERROR, "Memory accounting init failed");
  202         return ret;
  203     }
  204 
  205     return ret;
  206 }
  207 
  208 int
  209 init(xlator_t *this)
  210 {
  211     meta_priv_t *priv = NULL;
  212     int ret = -1;
  213 
  214     priv = GF_CALLOC(sizeof(*priv), 1, gf_meta_mt_priv_t);
  215     if (!priv)
  216         return ret;
  217 
  218     GF_OPTION_INIT("meta-dir-name", priv->meta_dir_name, str, out);
  219 
  220     this->private = priv;
  221     ret = 0;
  222 out:
  223     if (ret)
  224         GF_FREE(priv);
  225 
  226     return ret;
  227 }
  228 
  229 void
  230 fini(xlator_t *this)
  231 {
  232     GF_FREE(this->private);
  233     return;
  234 }
  235 
  236 struct xlator_fops fops = {.lookup = meta_lookup,
  237                            .opendir = meta_opendir,
  238                            .open = meta_open,
  239                            .readv = meta_readv,
  240                            .flush = meta_flush,
  241                            .stat = meta_stat,
  242                            .fstat = meta_fstat,
  243                            .readdir = meta_readdir,
  244                            .readdirp = meta_readdirp,
  245                            .readlink = meta_readlink,
  246                            .writev = meta_writev,
  247                            .truncate = meta_truncate,
  248                            .ftruncate = meta_ftruncate,
  249                            .fsync = meta_fsync,
  250                            .fsyncdir = meta_fsyncdir};
  251 
  252 struct xlator_cbks cbks = {
  253     .forget = meta_forget,
  254     .release = meta_release,
  255     .releasedir = meta_releasedir,
  256 };
  257 
  258 struct volume_options options[] = {
  259     {.key = {"meta-dir-name"},
  260      .type = GF_OPTION_TYPE_STR,
  261      .default_value = DEFAULT_META_DIR_NAME,
  262      .description = "Name of default meta directory."},
  263     {.key = {NULL}},
  264 };
  265 
  266 xlator_api_t xlator_api = {
  267     .init = init,
  268     .fini = fini,
  269     .mem_acct_init = mem_acct_init,
  270     .op_version = {1}, /* Present from the initial version */
  271     .fops = &fops,
  272     .cbks = &cbks,
  273     .options = options,
  274     .identifier = "meta",
  275     .category = GF_TECH_PREVIEW,
  276 };