"Fossies" - the Fresh Open Source Software Archive

Member "glusterfs-8.2/xlators/features/quota/src/quotad-helpers.c" (16 Sep 2020, 2496 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 "quotad-helpers.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2    Copyright (c) 2008-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 
   11 #include "quotad-helpers.h"
   12 
   13 quotad_aggregator_state_t *
   14 get_quotad_aggregator_state(xlator_t *this, rpcsvc_request_t *req)
   15 {
   16     quotad_aggregator_state_t *state = NULL;
   17     xlator_t *active_subvol = NULL;
   18     quota_priv_t *priv = NULL;
   19 
   20     state = (void *)GF_CALLOC(1, sizeof(*state),
   21                               gf_quota_mt_aggregator_state_t);
   22     if (!state)
   23         return NULL;
   24 
   25     state->this = THIS;
   26     priv = this->private;
   27 
   28     LOCK(&priv->lock);
   29     {
   30         active_subvol = state->active_subvol = FIRST_CHILD(this);
   31     }
   32     UNLOCK(&priv->lock);
   33 
   34     if (active_subvol->itable == NULL)
   35         active_subvol->itable = inode_table_new(4096, active_subvol);
   36 
   37     state->itable = active_subvol->itable;
   38 
   39     state->pool = this->ctx->pool;
   40 
   41     return state;
   42 }
   43 
   44 void
   45 quotad_aggregator_free_state(quotad_aggregator_state_t *state)
   46 {
   47     if (state->xdata)
   48         dict_unref(state->xdata);
   49 
   50     if (state->req_xdata)
   51         dict_unref(state->req_xdata);
   52 
   53     GF_FREE(state);
   54 }
   55 
   56 call_frame_t *
   57 quotad_aggregator_alloc_frame(rpcsvc_request_t *req)
   58 {
   59     call_frame_t *frame = NULL;
   60     quotad_aggregator_state_t *state = NULL;
   61     xlator_t *this = NULL;
   62 
   63     GF_VALIDATE_OR_GOTO("server", req, out);
   64     GF_VALIDATE_OR_GOTO("server", req->trans, out);
   65     GF_VALIDATE_OR_GOTO("server", req->svc, out);
   66     GF_VALIDATE_OR_GOTO("server", req->svc->ctx, out);
   67 
   68     this = req->svc->xl;
   69 
   70     frame = create_frame(this, req->svc->ctx->pool);
   71     if (!frame)
   72         goto out;
   73 
   74     state = get_quotad_aggregator_state(this, req);
   75     if (!state)
   76         goto out;
   77 
   78     frame->root->state = state;
   79 
   80     frame->this = this;
   81 out:
   82     return frame;
   83 }
   84 
   85 call_frame_t *
   86 quotad_aggregator_get_frame_from_req(rpcsvc_request_t *req)
   87 {
   88     call_frame_t *frame = NULL;
   89 
   90     GF_VALIDATE_OR_GOTO("server", req, out);
   91 
   92     frame = quotad_aggregator_alloc_frame(req);
   93     if (!frame)
   94         goto out;
   95 
   96     frame->root->op = req->procnum;
   97 
   98     frame->root->uid = req->uid;
   99     frame->root->gid = req->gid;
  100     frame->root->pid = req->pid;
  101 
  102     frame->root->lk_owner = req->lk_owner;
  103 
  104     frame->local = req;
  105 out:
  106     return frame;
  107 }