nfs-ganesha 1.4

fsal_internal.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2010 The Linx Box Corporation
00003  * Contributor : Adam C. Emerson
00004  *
00005  * Some Portions Copyright CEA/DAM/DIF  (2008)
00006  * contributeur : Philippe DENIEL   philippe.deniel@cea.fr
00007  *                Thomas LEIBOVICI  thomas.leibovici@cea.fr
00008  *
00009  *
00010  * This program is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 3 of the License, or (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00023  *
00024  * ---------------------------------------
00025  */
00026 
00035 #include <sys/types.h>
00036 #include <sys/stat.h>
00037 #include <sys/statvfs.h>
00038 #include <cephfs/libcephfs.h>
00039 #include <string.h>
00040 #include "fsal.h"
00041 #include "fsal_pnfs.h"
00042 
00043 /* the following variables must not be defined in fsal_internal.c */
00044 #ifndef FSAL_INTERNAL_C
00045 
00046 #define ReturnStatus( _st_, _f_ ) Return( (_st_).major, (_st_).minor, _f_ )
00047 
00048 /* static filesystem info.
00049  * read access only.
00050  */
00051 extern fsal_staticfsinfo_t global_fs_info;
00052 
00053 /* Everybody gets to know the server. */
00054 extern cephfs_specific_initinfo_t global_spec_info;
00055 
00056 #endif
00057 
00061 fsal_status_t fsal_internal_init_global(fsal_init_info_t * fsal_info,
00062                                         fs_common_initinfo_t * fs_common_info,
00063                                         fs_specific_initinfo_t * fs_specific_info);
00064 
00068 void fsal_increment_nbcall(int function_index, fsal_status_t status);
00069 
00073 void fsal_internal_getstats(fsal_statistics_t * output_stats);
00074 
00078 void TakeTokenFSCall();
00079 void ReleaseTokenFSCall();
00080 
00081 fsal_status_t CEPHFSAL_access(fsal_handle_t * exthandle,
00082                               fsal_op_context_t * extcontext,
00083                               fsal_accessflags_t access_type,
00084                               fsal_attrib_list_t * object_attributes);
00085 
00086 fsal_status_t CEPHFSAL_getattrs(fsal_handle_t * exthandle,
00087                                 fsal_op_context_t * extcontext,
00088                                 fsal_attrib_list_t * object_attributes);
00089 
00090 fsal_status_t CEPHFSAL_setattrs(fsal_handle_t * exthandle,
00091                                 fsal_op_context_t * extcontext,
00092                                 fsal_attrib_list_t * attrib_set,
00093                                 fsal_attrib_list_t * object_attributes);
00094 
00095 fsal_status_t CEPHFSAL_getextattrs(
00096      fsal_handle_t * p_filehandle,
00097      fsal_op_context_t * p_context,
00098      fsal_extattrib_list_t * p_object_attributes);
00099 
00100 fsal_status_t CEPHFSAL_BuildExportContext(
00101      fsal_export_context_t * extexport_context,
00102      fsal_path_t * export_path,
00103      char *fs_specific_options);
00104 
00105 fsal_status_t CEPHFSAL_CleanUpExportContext(
00106      fsal_export_context_t * export_context);
00107 
00108 fsal_status_t CEPHFSAL_InitClientContext(
00109      fsal_op_context_t* extcontext);
00110 
00111 fsal_status_t CEPHFSAL_GetClientContext(
00112      fsal_op_context_t * extcontext,
00113      fsal_export_context_t * extexport_context,
00114      fsal_uid_t uid,
00115      fsal_gid_t gid,
00116      fsal_gid_t * alt_groups,
00117      fsal_count_t nb_alt_groups);
00118 
00119 fsal_status_t CEPHFSAL_create(fsal_handle_t * extparent,
00120                               fsal_name_t * filename,
00121                               fsal_op_context_t * extcontext,
00122                               fsal_accessmode_t accessmode,
00123                               fsal_handle_t * object_handle,
00124                               fsal_attrib_list_t * object_attributes);
00125 
00126 fsal_status_t CEPHFSAL_mkdir(fsal_handle_t * extparent,
00127                              fsal_name_t * dirname,
00128                              fsal_op_context_t * extcontext,
00129                              fsal_accessmode_t accessmode,
00130                              fsal_handle_t * object_handle,
00131                              fsal_attrib_list_t * object_attributes);
00132 
00133 fsal_status_t CEPHFSAL_link(fsal_handle_t * exttarget,
00134                             fsal_handle_t * extdir,
00135                             fsal_name_t * link_name,
00136                             fsal_op_context_t * extcontext,
00137                             fsal_attrib_list_t * attributes);
00138 
00139 
00140 fsal_status_t CEPHFSAL_mknode(fsal_handle_t * parent,
00141                               fsal_name_t * node_name,
00142                               fsal_op_context_t * p_context,
00143                               fsal_accessmode_t accessmode,
00144                               fsal_nodetype_t nodetype,
00145                               fsal_dev_t * dev,
00146                               fsal_handle_t * p_object_handle,
00147                               fsal_attrib_list_t * node_attributes);
00148 
00149 fsal_status_t CEPHFSAL_opendir(fsal_handle_t * exthandle,
00150                                fsal_op_context_t * extcontext,
00151                                fsal_dir_t * extdescriptor,
00152                                fsal_attrib_list_t * dir_attributes);
00153 
00154 fsal_status_t CEPHFSAL_readdir(fsal_dir_t * extdescriptor,
00155                                fsal_cookie_t extstart,
00156                                fsal_attrib_mask_t attrmask,
00157                                fsal_mdsize_t buffersize,
00158                                fsal_dirent_t * dirents,
00159                                fsal_cookie_t * extend,
00160                                fsal_count_t * count,
00161                                fsal_boolean_t * end_of_dir);
00162 
00163 fsal_status_t CEPHFSAL_closedir(fsal_dir_t * extdescriptor);
00164 
00165 fsal_boolean_t fsal_is_retryable(fsal_status_t status);
00166 
00167 fsal_status_t CEPHFSAL_open(fsal_handle_t * exthandle,
00168                             fsal_op_context_t * extcontext,
00169                             fsal_openflags_t openflags,
00170                             fsal_file_t * extdescriptor,
00171                             fsal_attrib_list_t * file_attributes);
00172 
00173 fsal_status_t CEPHFSAL_open_by_name(fsal_handle_t * exthandle,
00174                                     fsal_name_t * filename,
00175                                     fsal_op_context_t * extcontext,
00176                                     fsal_openflags_t openflags,
00177                                     fsal_file_t * extdescriptor,
00178                                     fsal_attrib_list_t * file_attributes);
00179 
00180 fsal_status_t CEPHFSAL_read(fsal_file_t * extdescriptor,
00181                             fsal_seek_t * seek_descriptor,
00182                             fsal_size_t buffer_size,
00183                             caddr_t buffer,
00184                             fsal_size_t * read_amount,
00185                             fsal_boolean_t * end_of_file);
00186 
00187 fsal_status_t CEPHFSAL_write(fsal_file_t * extdescriptor,
00188                              fsal_op_context_t * p_context,
00189                              fsal_seek_t * seek_descriptor,
00190                              fsal_size_t buffer_size,
00191                              caddr_t buffer,
00192                              fsal_size_t * write_amount);
00193 
00194 fsal_status_t CEPHFSAL_close(fsal_file_t * extdescriptor);
00195 
00196 fsal_status_t CEPHFSAL_open_by_fileid(fsal_handle_t * filehandle,
00197                                       fsal_u64_t fileid,
00198                                       fsal_op_context_t * p_context,
00199                                       fsal_openflags_t openflags,
00200                                       fsal_file_t * file_descriptor,
00201                                       fsal_attrib_list_t * file_attributes);
00202 
00203 fsal_status_t CEPHFSAL_close_by_fileid(fsal_file_t * file_descriptor,
00204                                        fsal_u64_t fileid);
00205 
00206 unsigned int CEPHFSAL_GetFileno(fsal_file_t * pfile);
00207 
00208 fsal_status_t CEPHFSAL_commit(fsal_file_t * extdescriptor,
00209                             fsal_off_t    offset, 
00210                             fsal_size_t   size ) ;
00211 
00212 fsal_status_t CEPHFSAL_static_fsinfo(fsal_handle_t * exthandle,
00213                                      fsal_op_context_t * context,
00214                                      fsal_staticfsinfo_t * staticinfo);
00215 
00216 fsal_status_t CEPHFSAL_dynamic_fsinfo(fsal_handle_t * exthandle,
00217                                       fsal_op_context_t * extcontext,
00218                                       fsal_dynamicfsinfo_t * dynamicinfo);
00219 
00220 fsal_status_t CEPHFSAL_Init(fsal_parameter_t * init_info);
00221 
00222 fsal_status_t CEPHFSAL_terminate();
00223 
00224 fsal_status_t CEPHFSAL_test_access(fsal_op_context_t * extcontext,
00225                                    fsal_accessflags_t access_type,
00226                                    fsal_attrib_list_t * object_attributes);
00227 
00228 fsal_status_t CEPHFSAL_lookup(fsal_handle_t * extparent,
00229                               fsal_name_t * filename,
00230                               fsal_op_context_t * extcontext,
00231                               fsal_handle_t * exthandle,
00232                               fsal_attrib_list_t * object_attributes);
00233 
00234 
00235 fsal_status_t CEPHFSAL_lookupJunction(fsal_handle_t * extjunction,
00236                                       fsal_op_context_t * extcontext,
00237                                       fsal_handle_t * extfsroot,
00238                                       fsal_attrib_list_t * fsroot_attributes);
00239 
00240 fsal_status_t CEPHFSAL_lookupPath(fsal_path_t * path,
00241                                   fsal_op_context_t * extcontext,
00242                                   fsal_handle_t * exthandle,
00243                                   fsal_attrib_list_t * object_attributes);
00244 
00245 fsal_status_t CEPHFSAL_rcp(fsal_handle_t * filehandle,
00246                            fsal_op_context_t * p_context,
00247                            fsal_path_t * p_local_path,
00248                            fsal_rcpflag_t transfer_opt);
00249 
00250 fsal_status_t CEPHFSAL_rename(fsal_handle_t * extold_parent,
00251                               fsal_name_t * old_name,
00252                               fsal_handle_t * extnew_parent,
00253                               fsal_name_t * new_name,
00254                               fsal_op_context_t * extcontext,
00255                               fsal_attrib_list_t * src_dir_attributes,
00256                               fsal_attrib_list_t * tgt_dir_attributes);
00257 
00258 void CEPHFSAL_get_stats(fsal_statistics_t * stats,
00259                         fsal_boolean_t reset);
00260 
00261 fsal_status_t CEPHFSAL_readlink(fsal_handle_t * exthandle,
00262                                 fsal_op_context_t * extcontext,
00263                                 fsal_path_t * link_content,
00264                                 fsal_attrib_list_t * link_attributes);
00265 
00266 fsal_status_t CEPHFSAL_symlink(fsal_handle_t * extparent,
00267                                fsal_name_t * linkname,
00268                                fsal_path_t * linkcontent,
00269                                fsal_op_context_t * extcontext,
00270                                fsal_accessmode_t accessmode,
00271                                fsal_handle_t * extlink,
00272                                fsal_attrib_list_t * link_attributes);
00273 
00274 int CEPHFSAL_handlecmp(fsal_handle_t * exthandle1,
00275                        fsal_handle_t * exthandle2,
00276                        fsal_status_t * status);
00277 
00278 unsigned int CEPHFSAL_Handle_to_HashIndex(fsal_handle_t * exthandle,
00279                                           unsigned int cookie,
00280                                           unsigned int alphabet_len,
00281                                           unsigned int index_size);
00282 
00283 unsigned int CEPHFSAL_Handle_to_RBTIndex(fsal_handle_t * exthandle,
00284                                          unsigned int cookie);
00285 fsal_status_t CEPHFSAL_DigestHandle(fsal_export_context_t *extexport,
00286                                     fsal_digesttype_t output_type,
00287                                     fsal_handle_t *exthandle,
00288                                     struct fsal_handle_desc *fh_desc);
00289 fsal_status_t CEPHFSAL_ExpandHandle(fsal_export_context_t *extexport,
00290                                     fsal_digesttype_t in_type,
00291                                     struct fsal_handle_desc *fh_desc);
00292 
00293 fsal_status_t CEPHFSAL_SetDefault_FSAL_parameter(fsal_parameter_t * out_parameter);
00294 
00295 fsal_status_t CEPHFSAL_SetDefault_FS_common_parameter(fsal_parameter_t * out_parameter);
00296 
00297 fsal_status_t CEPHFSAL_SetDefault_FS_specific_parameter(fsal_parameter_t * out_parameter);
00298 
00299 fsal_status_t CEPHFSAL_load_FSAL_parameter_from_conf(config_file_t in_config,
00300                                                      fsal_parameter_t * out_parameter);
00301 
00302 fsal_status_t CEPHFSAL_load_FS_common_parameter_from_conf(config_file_t in_config,
00303                                                           fsal_parameter_t * out_parameter);
00304 
00305 fsal_status_t CEPHFSAL_load_FS_specific_parameter_from_conf(config_file_t in_config,
00306                                                             fsal_parameter_t * out_parameter);
00307 
00308 fsal_status_t CEPHFSAL_truncate(fsal_handle_t * exthandle,
00309                                 fsal_op_context_t * extcontext,
00310                                 fsal_size_t length,
00311                                 fsal_file_t * file_descriptor,
00312                                 fsal_attrib_list_t * object_attributes);
00313 
00314 fsal_status_t CEPHFSAL_unlink(fsal_handle_t * extparent,
00315                               fsal_name_t * name,
00316                               fsal_op_context_t * extcontext,
00317                               fsal_attrib_list_t * parentdir_attributes);
00318 
00319 fsal_status_t CEPHFSAL_GetXAttrAttrs(fsal_handle_t * exthandle,
00320                                      fsal_op_context_t * extcontext,
00321                                      unsigned int xattr_id,
00322                                      fsal_attrib_list_t * attrs);
00323 
00324 fsal_status_t CEPHFSAL_ListXAttrs(fsal_handle_t * exthandle,
00325                                   unsigned int cookie,
00326                                   fsal_op_context_t * extcontext,
00327                                   fsal_xattrent_t * xattrs_tab,
00328                                   unsigned int xattrs_tabsize,
00329                                   unsigned int *p_nb_returned,
00330                                   int *end_of_list);
00331 
00332 fsal_status_t CEPHFSAL_GetXAttrValueById(fsal_handle_t * exthandle,
00333                                          unsigned int xattr_id,
00334                                          fsal_op_context_t * extcontext,
00335                                          caddr_t buffer_addr,
00336                                          size_t buffer_size,
00337                                          size_t * p_output_size);
00338 
00339 fsal_status_t CEPHFSAL_GetXAttrIdByName(fsal_handle_t * exthandle,
00340                                         const fsal_name_t * xattr_name,
00341                                         fsal_op_context_t * extcontext,
00342                                         unsigned int *pxattr_id);
00343 
00344 fsal_status_t CEPHFSAL_GetXAttrValueByName(fsal_handle_t * exthandle,
00345                                            const fsal_name_t * xattr_name,
00346                                            fsal_op_context_t * extcontext,
00347                                            caddr_t buffer_addr,
00348                                            size_t buffer_size,
00349                                            size_t * p_output_size);
00350 
00351 fsal_status_t CEPHFSAL_SetXAttrValue(fsal_handle_t * exthandle,
00352                                      const fsal_name_t * xattr_name,
00353                                      fsal_op_context_t * extcontext,
00354                                      caddr_t buffer_addr,
00355                                      size_t buffer_size,
00356                                      int create);
00357 
00358 fsal_status_t CEPHFSAL_SetXAttrValueById(fsal_handle_t * exthandle,
00359                                          unsigned int xattr_id,
00360                                          fsal_op_context_t * extcontext,
00361                                          caddr_t buffer_addr,
00362                                          size_t buffer_size);
00363 
00364 fsal_status_t CEPHFSAL_RemoveXAttrById(fsal_handle_t * exthandle,
00365                                        fsal_op_context_t * extcontext,
00366                                        unsigned int xattr_id);
00367 
00368 fsal_status_t CEPHFSAL_RemoveXAttrByName(fsal_handle_t * exthandle,
00369                                          fsal_op_context_t * extcontext,
00370                                          const fsal_name_t * xattr_name);
00371 
00372 
00373 char *CEPHFSAL_GetFSName();
00374 
00375 fsal_status_t fsal_internal_testAccess(cephfsal_op_context_t* context,
00376                                        fsal_accessflags_t access_type,
00377                                        struct stat * st,
00378                                        fsal_attrib_list_t * object_attributes);
00379 #ifdef _PNFS_MDS
00380 nfsstat4 CEPHFSAL_layoutget(fsal_handle_t *exhandle,
00381                             fsal_op_context_t *excontext,
00382                             XDR *loc_body,
00383                             const struct fsal_layoutget_arg *arg,
00384                             struct fsal_layoutget_res *res);
00385 nfsstat4 CEPHFSAL_layoutreturn(fsal_handle_t* handle,
00386                                fsal_op_context_t* context,
00387                                XDR *lrf_body,
00388                                const struct fsal_layoutreturn_arg *arg);
00389 nfsstat4 CEPHFSAL_layoutcommit(fsal_handle_t *handle,
00390                                fsal_op_context_t *context,
00391                                XDR *lou_body,
00392                                const struct fsal_layoutcommit_arg *arg,
00393                                struct fsal_layoutcommit_res *res);
00394 nfsstat4 CEPHFSAL_getdeviceinfo(fsal_op_context_t *context,
00395                                 XDR* da_addr_body,
00396                                 layouttype4 type,
00397                                 const struct pnfs_deviceid *deviceid);
00398 nfsstat4 CEPHFSAL_getdevicelist(fsal_handle_t *handle,
00399                                 fsal_op_context_t *context,
00400                                 const struct fsal_getdevicelist_arg *arg,
00401                                 struct fsal_getdevicelist_res *res);
00402 #endif /* _PNFS_MDS */
00403 
00404 #ifdef _PNFS_DS
00405 nfsstat4 CEPHFSAL_DS_read(fsal_handle_t *handle,
00406                           fsal_op_context_t *context,
00407                           const stateid4 *stateid,
00408                           offset4 offset,
00409                           count4 requested_length,
00410                           caddr_t buffer,
00411                           count4 *supplied_length,
00412                           fsal_boolean_t *end_of_file);
00413 
00414 nfsstat4 CEPHFSAL_DS_write(fsal_handle_t *handle,
00415                            fsal_op_context_t *context,
00416                            const stateid4 *stateid,
00417                            offset4 offset,
00418                            count4 write_length,
00419                            caddr_t buffer,
00420                            stable_how4 stability_wanted,
00421                            count4 *written_length,
00422                            verifier4 *writeverf,
00423                            stable_how4 *stability_got);
00424 
00425 nfsstat4 CEPHFSAL_DS_commit(fsal_handle_t *handle,
00426                             fsal_op_context_t *context,
00427                             offset4 offset,
00428                             count4 count,
00429                             verifier4 *writeverf);
00430 #endif /* _PNFS_DS */