1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/*
* Copyright © Red Hat 2015
* Author: Orit Wasserman <owasserm@redhat.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* -------------
*/
/**
* @file internal.h
* @brief Internal declarations for the RGW FSAL
*
* This file includes declarations of data types, functions,
* variables, and constants for the RGW FSAL.
*/
#ifndef FSAL_RGW_INTERNAL_INTERNAL
#define FSAL_RGW_INTERNAL_INTERNAL
#include <stdbool.h>
#include <uuid/uuid.h>
#include <dirent.h> /* NAME_MAX */
#include "fsal.h"
#include "fsal_types.h"
#include "fsal_api.h"
#include "fsal_convert.h"
#include "sal_data.h"
#include <include/rados/librgw.h>
#include <include/rados/rgw_file.h>
#if (!GSH_CHECK_VERSION(1, 2, 0, LIBRGW_FILE_VER_MAJOR, LIBRGW_FILE_VER_MINOR, \
LIBRGW_FILE_VER_EXTRA))
#error rados/rgw_file.h version unsupported (require >= 1.2.0)
#endif
/**
* RGW Main (global) module object
*/
struct rgw_fsal_module {
struct fsal_module fsal;
struct fsal_obj_ops handle_ops;
char *conf_path;
char *name;
char *cluster;
char *init_args;
librgw_t rgw;
};
extern struct rgw_fsal_module RGWFSM;
#define MAXUIDLEN 32
#define MAXKEYLEN 20
#define MAXSECRETLEN 40
/**
* RGW internal export object
*/
struct rgw_export {
struct fsal_export export; /*< The public export object */
struct rgw_fs *rgw_fs; /*< "Opaque" fs handle */
struct rgw_handle *root; /*< root handle */
char *rgw_name;
char *rgw_user_id;
char *rgw_access_key_id;
char *rgw_secret_access_key;
};
/**
* The RGW FSAL internal handle
*/
struct rgw_handle {
struct fsal_obj_handle handle; /*< The public handle */
struct rgw_file_handle *rgw_fh; /*< RGW-internal file handle */
/* XXXX remove ptr to up-ops--we can always follow export! */
const struct fsal_up_vector *up_ops; /*< Upcall operations */
struct rgw_export *export; /*< The first export this handle
*< belongs to */
struct fsal_share share;
fsal_openflags_t openflags;
};
/**
* RGW "file descriptor"
*/
struct rgw_open_state {
struct state_t gsh_open;
fsal_openflags_t openflags;
};
/**
* The attributes this FSAL can interpret or supply.
* Currently FSAL_RGW uses posix2fsal_attributes, so we should indicate support
* for at least those attributes.
*/
#ifdef USE_FSAL_RGW_XATTRS
#define RGW_SUPPORTED_ATTRIBUTES ((ATTRS_POSIX | ATTR4_XATTR))
#else
#define RGW_SUPPORTED_ATTRIBUTES (ATTRS_POSIX)
#endif
/**
* The attributes this FSAL can set.
*/
#ifdef USE_FSAL_RGW_XATTRS
#define RGW_SETTABLE_ATTRIBUTES \
((const attrmask_t)(ATTR_MODE | ATTR_OWNER | ATTR_GROUP | ATTR_ATIME | \
ATTR_CTIME | ATTR_MTIME | ATTR_SIZE | \
ATTR_MTIME_SERVER | ATTR_ATIME_SERVER | \
ATTR4_XATTR))
#else
#define RGW_SETTABLE_ATTRIBUTES \
((const attrmask_t)(ATTR_MODE | ATTR_OWNER | ATTR_GROUP | ATTR_ATIME | \
ATTR_CTIME | ATTR_MTIME | ATTR_SIZE | \
ATTR_MTIME_SERVER | ATTR_ATIME_SERVER))
#endif
/**
* Linux supports a stripe pattern with no more than 4096 stripes, but
* for now we stick to 1024 to keep them da_addrs from being too
* gigantic.
*/
static const size_t BIGGEST_PATTERN = 1024;
/* Prototypes */
int construct_handle(struct rgw_export *export,
struct rgw_file_handle *rgw_file_handle, struct stat *st,
struct rgw_handle **obj);
void deconstruct_handle(struct rgw_handle *obj);
fsal_status_t rgw2fsal_error(const int errorcode);
void export_ops_init(struct export_ops *ops);
void handle_ops_init(struct fsal_obj_ops *ops);
struct state_t *rgw_alloc_state(struct fsal_export *exp_hdl,
enum state_type state_type,
struct state_t *related_state);
void rgw_fs_invalidate(void *handle, struct rgw_fh_hk fh_hk);
#endif /* !FSAL_RGW_INTERNAL_INTERNAL */
|