LCOV - code coverage report
Current view: top level - lib/fsdev - fsdev_io.c (source / functions) Hit Total Coverage
Test: ut_cov_unit.info Lines: 492 558 88.2 %
Date: 2024-08-13 06:03:55 Functions: 67 67 100.0 %

          Line data    Source code
       1             : /*   SPDX-License-Identifier: BSD-3-Clause
       2             :  *   Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
       3             :  */
       4             : 
       5             : #include "spdk/stdinc.h"
       6             : #include "spdk/fsdev.h"
       7             : #include "spdk/fsdev_module.h"
       8             : #include "fsdev_internal.h"
       9             : 
      10             : #define CALL_USR_CLB(_fsdev_io, ch, type, ...) \
      11             :         do { \
      12             :                 type *usr_cb_fn = _fsdev_io->internal.usr_cb_fn; \
      13             :                 usr_cb_fn(_fsdev_io->internal.usr_cb_arg, ch, _fsdev_io->internal.status, ## __VA_ARGS__); \
      14             :         } while (0)
      15             : 
      16             : static struct spdk_fsdev_io *
      17          34 : fsdev_io_get_and_fill(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
      18             :                       void *usr_cb_fn, void *usr_cb_arg, spdk_fsdev_io_completion_cb cb_fn, void *cb_arg,
      19             :                       enum spdk_fsdev_io_type type)
      20             : {
      21             :         struct spdk_fsdev_io *fsdev_io;
      22          34 :         struct spdk_fsdev_channel *channel = __io_ch_to_fsdev_ch(ch);
      23             : 
      24          34 :         fsdev_io = fsdev_channel_get_io(channel);
      25          34 :         if (!fsdev_io) {
      26           0 :                 return NULL;
      27             :         }
      28             : 
      29          34 :         fsdev_io->fsdev = spdk_fsdev_desc_get_fsdev(desc);
      30          34 :         fsdev_io->internal.ch = channel;
      31          34 :         fsdev_io->internal.desc = desc;
      32          34 :         fsdev_io->internal.type = type;
      33          34 :         fsdev_io->internal.unique = unique;
      34          34 :         fsdev_io->internal.usr_cb_fn = usr_cb_fn;
      35          34 :         fsdev_io->internal.usr_cb_arg = usr_cb_arg;
      36          34 :         fsdev_io->internal.cb_arg = cb_arg;
      37          34 :         fsdev_io->internal.cb_fn = cb_fn;
      38          34 :         fsdev_io->internal.status = -ENOSYS;
      39          34 :         fsdev_io->internal.in_submit_request = false;
      40             : 
      41          34 :         return fsdev_io;
      42             : }
      43             : 
      44             : static inline void
      45          34 : fsdev_io_free(struct spdk_fsdev_io *fsdev_io)
      46             : {
      47          34 :         spdk_fsdev_free_io(fsdev_io);
      48          34 : }
      49             : 
      50             : static void
      51           2 : _spdk_fsdev_lookup_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
      52             : {
      53           2 :         struct spdk_io_channel *ch = cb_arg;
      54             : 
      55           2 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_lookup_cpl_cb, fsdev_io->u_out.lookup.fobject,
      56             :                      &fsdev_io->u_out.lookup.attr);
      57             : 
      58           2 :         free(fsdev_io->u_in.lookup.name);
      59           2 :         fsdev_io_free(fsdev_io);
      60           2 : }
      61             : 
      62             : int
      63           2 : spdk_fsdev_lookup(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
      64             :                   struct spdk_fsdev_file_object *parent_fobject, const char *name,
      65             :                   spdk_fsdev_lookup_cpl_cb cb_fn, void *cb_arg)
      66             : {
      67             :         struct spdk_fsdev_io *fsdev_io;
      68             : 
      69           2 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_lookup_cb, ch,
      70             :                                          SPDK_FSDEV_IO_LOOKUP);
      71           2 :         if (!fsdev_io) {
      72           0 :                 return -ENOBUFS;
      73             :         }
      74             : 
      75           2 :         fsdev_io->u_in.lookup.name = strdup(name);
      76           2 :         if (!fsdev_io->u_in.lookup.name) {
      77           0 :                 fsdev_io_free(fsdev_io);
      78           0 :                 return -ENOMEM;
      79             :         }
      80             : 
      81           2 :         fsdev_io->u_in.lookup.parent_fobject = parent_fobject;
      82             : 
      83           2 :         fsdev_io_submit(fsdev_io);
      84           2 :         return 0;
      85             : }
      86             : 
      87             : static void
      88           1 : _spdk_fsdev_forget_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
      89             : {
      90           1 :         struct spdk_io_channel *ch = cb_arg;
      91             : 
      92           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_forget_cpl_cb);
      93             : 
      94           1 :         fsdev_io_free(fsdev_io);
      95           1 : }
      96             : 
      97             : int
      98           1 : spdk_fsdev_forget(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
      99             :                   struct spdk_fsdev_file_object *fobject, uint64_t nlookup,
     100             :                   spdk_fsdev_forget_cpl_cb cb_fn, void *cb_arg)
     101             : {
     102             :         struct spdk_fsdev_io *fsdev_io;
     103             : 
     104           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_forget_cb, ch,
     105             :                                          SPDK_FSDEV_IO_FORGET);
     106           1 :         if (!fsdev_io) {
     107           0 :                 return -ENOBUFS;
     108             :         }
     109             : 
     110           1 :         fsdev_io->u_in.forget.fobject = fobject;
     111           1 :         fsdev_io->u_in.forget.nlookup = nlookup;
     112             : 
     113           1 :         fsdev_io_submit(fsdev_io);
     114           1 :         return 0;
     115             : }
     116             : 
     117             : static void
     118           1 : _spdk_fsdev_getattr_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     119             : {
     120           1 :         struct spdk_io_channel *ch = cb_arg;
     121             : 
     122           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_getattr_cpl_cb, &fsdev_io->u_out.getattr.attr);
     123             : 
     124           1 :         fsdev_io_free(fsdev_io);
     125           1 : }
     126             : 
     127             : int
     128           1 : spdk_fsdev_getattr(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     129             :                    struct spdk_fsdev_file_object *fobject, struct spdk_fsdev_file_handle *fhandle,
     130             :                    spdk_fsdev_getattr_cpl_cb cb_fn, void *cb_arg)
     131             : {
     132             :         struct spdk_fsdev_io *fsdev_io;
     133             : 
     134           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_getattr_cb, ch,
     135             :                                          SPDK_FSDEV_IO_GETATTR);
     136           1 :         if (!fsdev_io) {
     137           0 :                 return -ENOBUFS;
     138             :         }
     139             : 
     140           1 :         fsdev_io->u_in.getattr.fobject = fobject;
     141           1 :         fsdev_io->u_in.getattr.fhandle = fhandle;
     142             : 
     143           1 :         fsdev_io_submit(fsdev_io);
     144           1 :         return 0;
     145             : }
     146             : 
     147             : static void
     148           1 : _spdk_fsdev_setattr_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     149             : {
     150           1 :         struct spdk_io_channel *ch = cb_arg;
     151             : 
     152           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_setattr_cpl_cb, &fsdev_io->u_out.setattr.attr);
     153             : 
     154           1 :         fsdev_io_free(fsdev_io);
     155           1 : }
     156             : 
     157             : int
     158           1 : spdk_fsdev_setattr(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     159             :                    struct spdk_fsdev_file_object *fobject, struct spdk_fsdev_file_handle *fhandle,
     160             :                    const struct spdk_fsdev_file_attr *attr, uint32_t to_set,
     161             :                    spdk_fsdev_setattr_cpl_cb cb_fn, void *cb_arg)
     162             : {
     163             :         struct spdk_fsdev_io *fsdev_io;
     164             : 
     165           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_setattr_cb, ch,
     166             :                                          SPDK_FSDEV_IO_SETATTR);
     167           1 :         if (!fsdev_io) {
     168           0 :                 return -ENOBUFS;
     169             :         }
     170             : 
     171           1 :         fsdev_io->u_in.setattr.fobject = fobject;
     172           1 :         fsdev_io->u_in.setattr.fhandle = fhandle;
     173           1 :         fsdev_io->u_in.setattr.attr = *attr;
     174           1 :         fsdev_io->u_in.setattr.to_set = to_set;
     175             : 
     176           1 :         fsdev_io_submit(fsdev_io);
     177           1 :         return 0;
     178             : }
     179             : 
     180             : static void
     181           1 : _spdk_fsdev_readlink_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     182             : {
     183           1 :         struct spdk_io_channel *ch = cb_arg;
     184             : 
     185           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_readlink_cpl_cb, fsdev_io->u_out.readlink.linkname);
     186             : 
     187           1 :         free(fsdev_io->u_out.readlink.linkname);
     188           1 :         fsdev_io_free(fsdev_io);
     189           1 : }
     190             : 
     191             : int
     192           1 : spdk_fsdev_readlink(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     193             :                     struct spdk_fsdev_file_object *fobject, spdk_fsdev_readlink_cpl_cb cb_fn, void *cb_arg)
     194             : {
     195             :         struct spdk_fsdev_io *fsdev_io;
     196             : 
     197           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_readlink_cb, ch,
     198             :                                          SPDK_FSDEV_IO_READLINK);
     199           1 :         if (!fsdev_io) {
     200           0 :                 return -ENOBUFS;
     201             :         }
     202             : 
     203           1 :         fsdev_io->u_in.readlink.fobject = fobject;
     204           1 :         fsdev_io->u_out.readlink.linkname = NULL;
     205             : 
     206           1 :         fsdev_io_submit(fsdev_io);
     207           1 :         return 0;
     208             : }
     209             : 
     210             : static void
     211           1 : _spdk_fsdev_symlink_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     212             : {
     213           1 :         struct spdk_io_channel *ch = cb_arg;
     214             : 
     215           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_symlink_cpl_cb, fsdev_io->u_out.symlink.fobject,
     216             :                      &fsdev_io->u_out.symlink.attr);
     217             : 
     218           1 :         free(fsdev_io->u_in.symlink.target);
     219           1 :         free(fsdev_io->u_in.symlink.linkpath);
     220             : 
     221           1 :         fsdev_io_free(fsdev_io);
     222           1 : }
     223             : 
     224             : int
     225           1 : spdk_fsdev_symlink(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     226             :                    struct spdk_fsdev_file_object *parent_fobject, const char *target, const char *linkpath,
     227             :                    uid_t euid, gid_t egid, spdk_fsdev_symlink_cpl_cb cb_fn, void *cb_arg)
     228             : {
     229             :         struct spdk_fsdev_io *fsdev_io;
     230             : 
     231           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_symlink_cb, ch,
     232             :                                          SPDK_FSDEV_IO_SYMLINK);
     233           1 :         if (!fsdev_io) {
     234           0 :                 return -ENOBUFS;
     235             :         }
     236             : 
     237           1 :         fsdev_io->u_in.symlink.target = strdup(target);
     238           1 :         if (!fsdev_io) {
     239           0 :                 fsdev_io_free(fsdev_io);
     240           0 :                 return -ENOMEM;
     241             :         }
     242             : 
     243           1 :         fsdev_io->u_in.symlink.linkpath = strdup(linkpath);
     244           1 :         if (!fsdev_io) {
     245           0 :                 fsdev_io_free(fsdev_io);
     246           0 :                 free(fsdev_io->u_in.symlink.target);
     247           0 :                 return -ENOMEM;
     248             :         }
     249             : 
     250           1 :         fsdev_io->u_in.symlink.parent_fobject = parent_fobject;
     251           1 :         fsdev_io->u_in.symlink.euid = euid;
     252           1 :         fsdev_io->u_in.symlink.egid = egid;
     253             : 
     254           1 :         fsdev_io_submit(fsdev_io);
     255           1 :         return 0;
     256             : }
     257             : 
     258             : static void
     259           1 : _spdk_fsdev_mknod_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     260             : {
     261           1 :         struct spdk_io_channel *ch = cb_arg;
     262             : 
     263           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_mknod_cpl_cb, fsdev_io->u_out.mknod.fobject,
     264             :                      &fsdev_io->u_out.mknod.attr);
     265             : 
     266           1 :         free(fsdev_io->u_in.mknod.name);
     267             : 
     268           1 :         fsdev_io_free(fsdev_io);
     269           1 : }
     270             : 
     271             : int
     272           1 : spdk_fsdev_mknod(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     273             :                  struct spdk_fsdev_file_object *parent_fobject, const char *name, mode_t mode, dev_t rdev,
     274             :                  uid_t euid, gid_t egid, spdk_fsdev_mknod_cpl_cb cb_fn, void *cb_arg)
     275             : {
     276             :         struct spdk_fsdev_io *fsdev_io;
     277             : 
     278           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_mknod_cb, ch,
     279             :                                          SPDK_FSDEV_IO_MKNOD);
     280           1 :         if (!fsdev_io) {
     281           0 :                 return -ENOBUFS;
     282             :         }
     283             : 
     284           1 :         fsdev_io->u_in.mknod.name = strdup(name);
     285           1 :         if (!fsdev_io->u_in.mknod.name) {
     286           0 :                 fsdev_io_free(fsdev_io);
     287           0 :                 return -ENOMEM;
     288             :         }
     289             : 
     290           1 :         fsdev_io->u_in.mknod.parent_fobject = parent_fobject;
     291           1 :         fsdev_io->u_in.mknod.mode = mode;
     292           1 :         fsdev_io->u_in.mknod.rdev = rdev;
     293           1 :         fsdev_io->u_in.mknod.euid = euid;
     294           1 :         fsdev_io->u_in.mknod.egid = egid;
     295             : 
     296           1 :         fsdev_io_submit(fsdev_io);
     297           1 :         return 0;
     298             : }
     299             : 
     300             : static void
     301           1 : _spdk_fsdev_mkdir_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     302             : {
     303           1 :         struct spdk_io_channel *ch = cb_arg;
     304             : 
     305           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_mkdir_cpl_cb, fsdev_io->u_out.mkdir.fobject,
     306             :                      &fsdev_io->u_out.mkdir.attr);
     307             : 
     308           1 :         free(fsdev_io->u_in.mkdir.name);
     309             : 
     310           1 :         fsdev_io_free(fsdev_io);
     311           1 : }
     312             : 
     313             : int
     314           1 : spdk_fsdev_mkdir(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     315             :                  struct spdk_fsdev_file_object *parent_fobject, const char *name, mode_t mode,
     316             :                  uid_t euid, gid_t egid, spdk_fsdev_mkdir_cpl_cb cb_fn, void *cb_arg)
     317             : {
     318             :         struct spdk_fsdev_io *fsdev_io;
     319             : 
     320           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_mkdir_cb, ch,
     321             :                                          SPDK_FSDEV_IO_MKDIR);
     322           1 :         if (!fsdev_io) {
     323           0 :                 return -ENOBUFS;
     324             :         }
     325             : 
     326           1 :         fsdev_io->u_in.mkdir.name = strdup(name);
     327           1 :         if (!fsdev_io->u_in.mkdir.name) {
     328           0 :                 fsdev_io_free(fsdev_io);
     329           0 :                 return -ENOMEM;
     330             :         }
     331             : 
     332           1 :         fsdev_io->u_in.mkdir.parent_fobject = parent_fobject;
     333           1 :         fsdev_io->u_in.mkdir.mode = mode;
     334           1 :         fsdev_io->u_in.mkdir.euid = euid;
     335           1 :         fsdev_io->u_in.mkdir.egid = egid;
     336             : 
     337           1 :         fsdev_io_submit(fsdev_io);
     338           1 :         return 0;
     339             : }
     340             : 
     341             : static void
     342           1 : _spdk_fsdev_unlink_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     343             : {
     344           1 :         struct spdk_io_channel *ch = cb_arg;
     345             : 
     346           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_unlink_cpl_cb);
     347             : 
     348           1 :         free(fsdev_io->u_in.unlink.name);
     349             : 
     350           1 :         fsdev_io_free(fsdev_io);
     351           1 : }
     352             : 
     353             : int
     354           1 : spdk_fsdev_unlink(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     355             :                   struct spdk_fsdev_file_object *parent_fobject, const char *name,
     356             :                   spdk_fsdev_unlink_cpl_cb cb_fn, void *cb_arg)
     357             : {
     358             :         struct spdk_fsdev_io *fsdev_io;
     359             : 
     360           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_unlink_cb, ch,
     361             :                                          SPDK_FSDEV_IO_UNLINK);
     362           1 :         if (!fsdev_io) {
     363           0 :                 return -ENOBUFS;
     364             :         }
     365             : 
     366           1 :         fsdev_io->u_in.unlink.name = strdup(name);
     367           1 :         if (!fsdev_io->u_in.unlink.name) {
     368           0 :                 fsdev_io_free(fsdev_io);
     369           0 :                 return -ENOMEM;
     370             :         }
     371             : 
     372           1 :         fsdev_io->u_in.unlink.parent_fobject = parent_fobject;
     373             : 
     374           1 :         fsdev_io_submit(fsdev_io);
     375           1 :         return 0;
     376             : }
     377             : 
     378             : static void
     379           1 : _spdk_fsdev_rmdir_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     380             : {
     381           1 :         struct spdk_io_channel *ch = cb_arg;
     382             : 
     383           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_rmdir_cpl_cb);
     384             : 
     385           1 :         free(fsdev_io->u_in.rmdir.name);
     386             : 
     387           1 :         fsdev_io_free(fsdev_io);
     388           1 : }
     389             : 
     390             : int
     391           1 : spdk_fsdev_rmdir(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     392             :                  struct spdk_fsdev_file_object *parent_fobject, const char *name,
     393             :                  spdk_fsdev_rmdir_cpl_cb cb_fn, void *cb_arg)
     394             : {
     395             :         struct spdk_fsdev_io *fsdev_io;
     396             : 
     397           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_rmdir_cb, ch,
     398             :                                          SPDK_FSDEV_IO_RMDIR);
     399           1 :         if (!fsdev_io) {
     400           0 :                 return -ENOBUFS;
     401             :         }
     402             : 
     403           1 :         fsdev_io->u_in.rmdir.name = strdup(name);
     404           1 :         if (!fsdev_io->u_in.rmdir.name) {
     405           0 :                 fsdev_io_free(fsdev_io);
     406           0 :                 return -ENOMEM;
     407             :         }
     408             : 
     409           1 :         fsdev_io->u_in.rmdir.parent_fobject = parent_fobject;
     410             : 
     411           1 :         fsdev_io_submit(fsdev_io);
     412           1 :         return 0;
     413             : }
     414             : 
     415             : static void
     416           1 : _spdk_fsdev_rename_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     417             : {
     418           1 :         struct spdk_io_channel *ch = cb_arg;
     419             : 
     420           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_rename_cpl_cb);
     421             : 
     422           1 :         free(fsdev_io->u_in.rename.name);
     423           1 :         free(fsdev_io->u_in.rename.new_name);
     424             : 
     425           1 :         fsdev_io_free(fsdev_io);
     426           1 : }
     427             : 
     428             : int
     429           1 : spdk_fsdev_rename(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     430             :                   struct spdk_fsdev_file_object *parent_fobject, const char *name,
     431             :                   struct spdk_fsdev_file_object *new_parent_fobject, const char *new_name,
     432             :                   uint32_t flags, spdk_fsdev_rename_cpl_cb cb_fn, void *cb_arg)
     433             : {
     434             :         struct spdk_fsdev_io *fsdev_io;
     435             : 
     436           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_rename_cb, ch,
     437             :                                          SPDK_FSDEV_IO_RENAME);
     438           1 :         if (!fsdev_io) {
     439           0 :                 return -ENOBUFS;
     440             :         }
     441             : 
     442           1 :         fsdev_io->u_in.rename.name = strdup(name);
     443           1 :         if (!fsdev_io->u_in.rename.name) {
     444           0 :                 fsdev_io_free(fsdev_io);
     445           0 :                 return -ENOMEM;
     446             :         }
     447             : 
     448           1 :         fsdev_io->u_in.rename.new_name = strdup(new_name);
     449           1 :         if (!fsdev_io->u_in.rename.new_name) {
     450           0 :                 free(fsdev_io->u_in.rename.name);
     451           0 :                 fsdev_io_free(fsdev_io);
     452           0 :                 return -ENOMEM;
     453             :         }
     454             : 
     455           1 :         fsdev_io->u_in.rename.parent_fobject = parent_fobject;
     456           1 :         fsdev_io->u_in.rename.new_parent_fobject = new_parent_fobject;
     457           1 :         fsdev_io->u_in.rename.flags = flags;
     458             : 
     459           1 :         fsdev_io_submit(fsdev_io);
     460           1 :         return 0;
     461             : }
     462             : 
     463             : static void
     464           1 : _spdk_fsdev_link_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     465             : {
     466           1 :         struct spdk_io_channel *ch = cb_arg;
     467             : 
     468           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_link_cpl_cb, fsdev_io->u_out.link.fobject,
     469             :                      &fsdev_io->u_out.link.attr);
     470             : 
     471           1 :         free(fsdev_io->u_in.link.name);
     472             : 
     473           1 :         fsdev_io_free(fsdev_io);
     474           1 : }
     475             : 
     476             : int
     477           1 : spdk_fsdev_link(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     478             :                 struct spdk_fsdev_file_object *fobject, struct spdk_fsdev_file_object *new_parent_fobject,
     479             :                 const char *name, spdk_fsdev_link_cpl_cb cb_fn, void *cb_arg)
     480             : {
     481             :         struct spdk_fsdev_io *fsdev_io;
     482             : 
     483           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_link_cb, ch,
     484             :                                          SPDK_FSDEV_IO_LINK);
     485           1 :         if (!fsdev_io) {
     486           0 :                 return -ENOBUFS;
     487             :         }
     488             : 
     489           1 :         fsdev_io->u_in.link.name = strdup(name);
     490           1 :         if (!fsdev_io->u_in.link.name) {
     491           0 :                 fsdev_io_free(fsdev_io);
     492           0 :                 return -ENOMEM;
     493             :         }
     494             : 
     495           1 :         fsdev_io->u_in.link.fobject = fobject;
     496           1 :         fsdev_io->u_in.link.new_parent_fobject = new_parent_fobject;
     497             : 
     498           1 :         fsdev_io_submit(fsdev_io);
     499           1 :         return 0;
     500             : }
     501             : 
     502             : static void
     503           1 : _spdk_fsdev_fopen_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     504             : {
     505           1 :         struct spdk_io_channel *ch = cb_arg;
     506             : 
     507           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_fopen_cpl_cb, fsdev_io->u_out.open.fhandle);
     508             : 
     509           1 :         fsdev_io_free(fsdev_io);
     510           1 : }
     511             : 
     512             : int
     513           1 : spdk_fsdev_fopen(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     514             :                  struct spdk_fsdev_file_object *fobject, uint32_t flags,
     515             :                  spdk_fsdev_fopen_cpl_cb cb_fn, void *cb_arg)
     516             : {
     517             :         struct spdk_fsdev_io *fsdev_io;
     518             : 
     519           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_fopen_cb, ch,
     520             :                                          SPDK_FSDEV_IO_OPEN);
     521           1 :         if (!fsdev_io) {
     522           0 :                 return -ENOBUFS;
     523             :         }
     524             : 
     525           1 :         fsdev_io->u_in.open.fobject = fobject;
     526           1 :         fsdev_io->u_in.open.flags = flags;
     527             : 
     528           1 :         fsdev_io_submit(fsdev_io);
     529           1 :         return 0;
     530             : }
     531             : 
     532             : static void
     533           1 : _spdk_fsdev_read_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     534             : {
     535           1 :         struct spdk_io_channel *ch = cb_arg;
     536             : 
     537           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_read_cpl_cb, fsdev_io->u_out.read.data_size);
     538             : 
     539           1 :         fsdev_io_free(fsdev_io);
     540           1 : }
     541             : 
     542             : int
     543           1 : spdk_fsdev_read(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     544             :                 struct spdk_fsdev_file_object *fobject, struct spdk_fsdev_file_handle *fhandle,
     545             :                 size_t size, uint64_t offs, uint32_t flags,
     546             :                 struct iovec *iov, uint32_t iovcnt, struct spdk_fsdev_io_opts *opts,
     547             :                 spdk_fsdev_read_cpl_cb cb_fn, void *cb_arg)
     548             : {
     549             :         struct spdk_fsdev_io *fsdev_io;
     550             : 
     551           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_read_cb, ch,
     552             :                                          SPDK_FSDEV_IO_READ);
     553           1 :         if (!fsdev_io) {
     554           0 :                 return -ENOBUFS;
     555             :         }
     556             : 
     557           1 :         fsdev_io->u_in.read.fobject = fobject;
     558           1 :         fsdev_io->u_in.read.fhandle = fhandle;
     559           1 :         fsdev_io->u_in.read.size = size;
     560           1 :         fsdev_io->u_in.read.offs = offs;
     561           1 :         fsdev_io->u_in.read.flags = flags;
     562           1 :         fsdev_io->u_in.read.iov = iov;
     563           1 :         fsdev_io->u_in.read.iovcnt = iovcnt;
     564           1 :         fsdev_io->u_in.read.opts = opts;
     565             : 
     566           1 :         fsdev_io_submit(fsdev_io);
     567           1 :         return 0;
     568             : }
     569             : 
     570             : static void
     571           1 : _spdk_fsdev_write_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     572             : {
     573           1 :         struct spdk_io_channel *ch = cb_arg;
     574             : 
     575           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_write_cpl_cb, fsdev_io->u_out.write.data_size);
     576             : 
     577           1 :         fsdev_io_free(fsdev_io);
     578           1 : }
     579             : 
     580             : int
     581           1 : spdk_fsdev_write(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     582             :                  struct spdk_fsdev_file_object *fobject, struct spdk_fsdev_file_handle *fhandle,
     583             :                  size_t size, uint64_t offs, uint64_t flags,
     584             :                  const struct iovec *iov, uint32_t iovcnt, struct spdk_fsdev_io_opts *opts,
     585             :                  spdk_fsdev_write_cpl_cb cb_fn, void *cb_arg)
     586             : {
     587             :         struct spdk_fsdev_io *fsdev_io;
     588             : 
     589           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_write_cb, ch,
     590             :                                          SPDK_FSDEV_IO_WRITE);
     591           1 :         if (!fsdev_io) {
     592           0 :                 return -ENOBUFS;
     593             :         }
     594             : 
     595           1 :         fsdev_io->u_in.write.fobject = fobject;
     596           1 :         fsdev_io->u_in.write.fhandle = fhandle;
     597           1 :         fsdev_io->u_in.write.size = size;
     598           1 :         fsdev_io->u_in.write.offs = offs;
     599           1 :         fsdev_io->u_in.write.flags = flags;
     600           1 :         fsdev_io->u_in.write.iov = iov;
     601           1 :         fsdev_io->u_in.write.iovcnt = iovcnt;
     602           1 :         fsdev_io->u_in.write.opts = opts;
     603             : 
     604           1 :         fsdev_io_submit(fsdev_io);
     605           1 :         return 0;
     606             : }
     607             : 
     608             : static void
     609           1 : _spdk_fsdev_statfs_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     610             : {
     611           1 :         struct spdk_io_channel *ch = cb_arg;
     612             : 
     613           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_statfs_cpl_cb, &fsdev_io->u_out.statfs.statfs);
     614             : 
     615           1 :         fsdev_io_free(fsdev_io);
     616           1 : }
     617             : 
     618             : int
     619           1 : spdk_fsdev_statfs(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     620             :                   struct spdk_fsdev_file_object *fobject, spdk_fsdev_statfs_cpl_cb cb_fn, void *cb_arg)
     621             : {
     622             :         struct spdk_fsdev_io *fsdev_io;
     623             : 
     624           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_statfs_cb, ch,
     625             :                                          SPDK_FSDEV_IO_STATFS);
     626           1 :         if (!fsdev_io) {
     627           0 :                 return -ENOBUFS;
     628             :         }
     629             : 
     630           1 :         fsdev_io->u_in.statfs.fobject = fobject;
     631             : 
     632           1 :         fsdev_io_submit(fsdev_io);
     633           1 :         return 0;
     634             : }
     635             : 
     636             : static void
     637           1 : _spdk_fsdev_release_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     638             : {
     639           1 :         struct spdk_io_channel *ch = cb_arg;
     640             : 
     641           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_release_cpl_cb);
     642             : 
     643           1 :         fsdev_io_free(fsdev_io);
     644           1 : }
     645             : 
     646             : int
     647           1 : spdk_fsdev_release(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     648             :                    struct spdk_fsdev_file_object *fobject, struct spdk_fsdev_file_handle *fhandle,
     649             :                    spdk_fsdev_release_cpl_cb cb_fn, void *cb_arg)
     650             : {
     651             :         struct spdk_fsdev_io *fsdev_io;
     652             : 
     653           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_release_cb, ch,
     654             :                                          SPDK_FSDEV_IO_RELEASE);
     655           1 :         if (!fsdev_io) {
     656           0 :                 return -ENOBUFS;
     657             :         }
     658             : 
     659           1 :         fsdev_io->u_in.release.fobject = fobject;
     660           1 :         fsdev_io->u_in.release.fhandle = fhandle;
     661             : 
     662           1 :         fsdev_io_submit(fsdev_io);
     663           1 :         return 0;
     664             : }
     665             : 
     666             : static void
     667           1 : _spdk_fsdev_fsync_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     668             : {
     669           1 :         struct spdk_io_channel *ch = cb_arg;
     670             : 
     671           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_fsync_cpl_cb);
     672             : 
     673           1 :         fsdev_io_free(fsdev_io);
     674           1 : }
     675             : 
     676             : int
     677           1 : spdk_fsdev_fsync(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     678             :                  struct spdk_fsdev_file_object *fobject, struct spdk_fsdev_file_handle *fhandle, bool datasync,
     679             :                  spdk_fsdev_fsync_cpl_cb cb_fn, void *cb_arg)
     680             : {
     681             :         struct spdk_fsdev_io *fsdev_io;
     682             : 
     683           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_fsync_cb, ch,
     684             :                                          SPDK_FSDEV_IO_FSYNC);
     685           1 :         if (!fsdev_io) {
     686           0 :                 return -ENOBUFS;
     687             :         }
     688             : 
     689           1 :         fsdev_io->u_in.fsync.fobject = fobject;
     690           1 :         fsdev_io->u_in.fsync.fhandle = fhandle;
     691           1 :         fsdev_io->u_in.fsync.datasync = datasync;
     692             : 
     693           1 :         fsdev_io_submit(fsdev_io);
     694           1 :         return 0;
     695             : }
     696             : 
     697             : static void
     698           1 : _spdk_fsdev_setxattr_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     699             : {
     700           1 :         struct spdk_io_channel *ch = cb_arg;
     701             : 
     702           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_setxattr_cpl_cb);
     703             : 
     704           1 :         free(fsdev_io->u_in.setxattr.value);
     705           1 :         free(fsdev_io->u_in.setxattr.name);
     706             : 
     707           1 :         fsdev_io_free(fsdev_io);
     708           1 : }
     709             : 
     710             : int
     711           1 : spdk_fsdev_setxattr(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     712             :                     struct spdk_fsdev_file_object *fobject, const char *name, const char *value, size_t size,
     713             :                     uint32_t flags, spdk_fsdev_setxattr_cpl_cb cb_fn, void *cb_arg)
     714             : {
     715             :         struct spdk_fsdev_io *fsdev_io;
     716             : 
     717           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_setxattr_cb, ch,
     718             :                                          SPDK_FSDEV_IO_SETXATTR);
     719           1 :         if (!fsdev_io) {
     720           0 :                 return -ENOBUFS;
     721             :         }
     722             : 
     723           1 :         fsdev_io->u_in.setxattr.name = strdup(name);
     724           1 :         if (!fsdev_io->u_in.setxattr.name) {
     725           0 :                 fsdev_io_free(fsdev_io);
     726           0 :                 return -ENOMEM;
     727             :         }
     728             : 
     729           1 :         fsdev_io->u_in.setxattr.value = malloc(size);
     730           1 :         if (!fsdev_io->u_in.setxattr.value) {
     731           0 :                 free(fsdev_io->u_in.setxattr.name);
     732           0 :                 fsdev_io_free(fsdev_io);
     733           0 :                 return -ENOMEM;
     734             :         }
     735             : 
     736           1 :         memcpy(fsdev_io->u_in.setxattr.value, value, size);
     737           1 :         fsdev_io->u_in.setxattr.fobject = fobject;
     738           1 :         fsdev_io->u_in.setxattr.size = size;
     739           1 :         fsdev_io->u_in.setxattr.flags = flags;
     740             : 
     741           1 :         fsdev_io_submit(fsdev_io);
     742           1 :         return 0;
     743             : }
     744             : 
     745             : static void
     746           1 : _spdk_fsdev_getxattr_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     747             : {
     748           1 :         struct spdk_io_channel *ch = cb_arg;
     749             : 
     750           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_getxattr_cpl_cb, fsdev_io->u_out.getxattr.value_size);
     751             : 
     752           1 :         free(fsdev_io->u_in.getxattr.name);
     753             : 
     754           1 :         fsdev_io_free(fsdev_io);
     755           1 : }
     756             : 
     757             : int
     758           1 : spdk_fsdev_getxattr(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     759             :                     struct spdk_fsdev_file_object *fobject, const char *name, void *buffer, size_t size,
     760             :                     spdk_fsdev_getxattr_cpl_cb cb_fn, void *cb_arg)
     761             : {
     762             :         struct spdk_fsdev_io *fsdev_io;
     763             : 
     764           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_getxattr_cb, ch,
     765             :                                          SPDK_FSDEV_IO_GETXATTR);
     766           1 :         if (!fsdev_io) {
     767           0 :                 return -ENOBUFS;
     768             :         }
     769             : 
     770           1 :         fsdev_io->u_in.getxattr.name = strdup(name);
     771           1 :         if (!fsdev_io->u_in.getxattr.name) {
     772           0 :                 fsdev_io_free(fsdev_io);
     773           0 :                 return -ENOMEM;
     774             :         }
     775             : 
     776           1 :         fsdev_io->u_in.getxattr.fobject = fobject;
     777           1 :         fsdev_io->u_in.getxattr.buffer = buffer;
     778           1 :         fsdev_io->u_in.getxattr.size = size;
     779             : 
     780           1 :         fsdev_io_submit(fsdev_io);
     781           1 :         return 0;
     782             : }
     783             : 
     784             : static void
     785           2 : _spdk_fsdev_listxattr_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     786             : {
     787           2 :         struct spdk_io_channel *ch = cb_arg;
     788             : 
     789           2 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_listxattr_cpl_cb, fsdev_io->u_out.listxattr.data_size,
     790             :                      fsdev_io->u_out.listxattr.size_only);
     791             : 
     792           2 :         fsdev_io_free(fsdev_io);
     793           2 : }
     794             : 
     795             : int
     796           2 : spdk_fsdev_listxattr(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     797             :                      struct spdk_fsdev_file_object *fobject, char *buffer, size_t size,
     798             :                      spdk_fsdev_listxattr_cpl_cb cb_fn, void *cb_arg)
     799             : {
     800             :         struct spdk_fsdev_io *fsdev_io;
     801             : 
     802           2 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_listxattr_cb, ch,
     803             :                                          SPDK_FSDEV_IO_LISTXATTR);
     804           2 :         if (!fsdev_io) {
     805           0 :                 return -ENOBUFS;
     806             :         }
     807             : 
     808           2 :         fsdev_io->u_in.listxattr.fobject = fobject;
     809           2 :         fsdev_io->u_in.listxattr.buffer = buffer;
     810           2 :         fsdev_io->u_in.listxattr.size = size;
     811             : 
     812           2 :         fsdev_io_submit(fsdev_io);
     813           2 :         return 0;
     814             : }
     815             : 
     816             : static void
     817           1 : _spdk_fsdev_removexattr_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     818             : {
     819           1 :         struct spdk_io_channel *ch = cb_arg;
     820             : 
     821           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_removexattr_cpl_cb);
     822             : 
     823           1 :         free(fsdev_io->u_in.removexattr.name);
     824             : 
     825           1 :         fsdev_io_free(fsdev_io);
     826           1 : }
     827             : 
     828             : int
     829           1 : spdk_fsdev_removexattr(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     830             :                        struct spdk_fsdev_file_object *fobject, const char *name,
     831             :                        spdk_fsdev_removexattr_cpl_cb cb_fn, void *cb_arg)
     832             : {
     833             :         struct spdk_fsdev_io *fsdev_io;
     834             : 
     835           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_removexattr_cb, ch,
     836             :                                          SPDK_FSDEV_IO_REMOVEXATTR);
     837           1 :         if (!fsdev_io) {
     838           0 :                 return -ENOBUFS;
     839             :         }
     840             : 
     841           1 :         fsdev_io->u_in.removexattr.name = strdup(name);
     842           1 :         if (!fsdev_io->u_in.removexattr.name) {
     843           0 :                 fsdev_io_free(fsdev_io);
     844           0 :                 return -ENOMEM;
     845             :         }
     846             : 
     847           1 :         fsdev_io->u_in.removexattr.fobject = fobject;
     848             : 
     849           1 :         fsdev_io_submit(fsdev_io);
     850           1 :         return 0;
     851             : }
     852             : 
     853             : static void
     854           1 : _spdk_fsdev_flush_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     855             : {
     856           1 :         struct spdk_io_channel *ch = cb_arg;
     857             : 
     858           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_flush_cpl_cb);
     859             : 
     860           1 :         fsdev_io_free(fsdev_io);
     861           1 : }
     862             : 
     863             : int
     864           1 : spdk_fsdev_flush(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     865             :                  struct spdk_fsdev_file_object *fobject, struct spdk_fsdev_file_handle *fhandle,
     866             :                  spdk_fsdev_flush_cpl_cb cb_fn, void *cb_arg)
     867             : {
     868             :         struct spdk_fsdev_io *fsdev_io;
     869             : 
     870           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_flush_cb, ch,
     871             :                                          SPDK_FSDEV_IO_FLUSH);
     872           1 :         if (!fsdev_io) {
     873           0 :                 return -ENOBUFS;
     874             :         }
     875             : 
     876           1 :         fsdev_io->u_in.flush.fobject = fobject;
     877           1 :         fsdev_io->u_in.flush.fhandle = fhandle;
     878             : 
     879           1 :         fsdev_io_submit(fsdev_io);
     880           1 :         return 0;
     881             : }
     882             : 
     883             : static void
     884           1 : _spdk_fsdev_opendir_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     885             : {
     886           1 :         struct spdk_io_channel *ch = cb_arg;
     887             : 
     888           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_opendir_cpl_cb, fsdev_io->u_out.opendir.fhandle);
     889             : 
     890           1 :         fsdev_io_free(fsdev_io);
     891           1 : }
     892             : 
     893             : int
     894           1 : spdk_fsdev_opendir(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     895             :                    struct spdk_fsdev_file_object *fobject, uint32_t flags,
     896             :                    spdk_fsdev_opendir_cpl_cb cb_fn, void *cb_arg)
     897             : {
     898             :         struct spdk_fsdev_io *fsdev_io;
     899             : 
     900           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_opendir_cb, ch,
     901             :                                          SPDK_FSDEV_IO_OPENDIR);
     902           1 :         if (!fsdev_io) {
     903           0 :                 return -ENOBUFS;
     904             :         }
     905             : 
     906           1 :         fsdev_io->u_in.opendir.fobject = fobject;
     907           1 :         fsdev_io->u_in.opendir.flags = flags;
     908             : 
     909           1 :         fsdev_io_submit(fsdev_io);
     910           1 :         return 0;
     911             : }
     912             : 
     913             : static int
     914          20 : _spdk_fsdev_readdir_entry_clb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     915             : {
     916          20 :         spdk_fsdev_readdir_entry_cb *usr_entry_cb_fn = fsdev_io->u_in.readdir.usr_entry_cb_fn;
     917          20 :         struct spdk_io_channel *ch = cb_arg;
     918             : 
     919          40 :         return usr_entry_cb_fn(fsdev_io->internal.usr_cb_arg, ch, fsdev_io->u_out.readdir.name,
     920          20 :                                fsdev_io->u_out.readdir.fobject, &fsdev_io->u_out.readdir.attr, fsdev_io->u_out.readdir.offset);
     921             : }
     922             : 
     923             : static void
     924           1 : _spdk_fsdev_readdir_emum_clb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     925             : {
     926           1 :         struct spdk_io_channel *ch = cb_arg;
     927             : 
     928           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_readdir_cpl_cb);
     929             : 
     930           1 :         fsdev_io_free(fsdev_io);
     931           1 : }
     932             : 
     933             : int
     934           1 : spdk_fsdev_readdir(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     935             :                    struct spdk_fsdev_file_object *fobject, struct spdk_fsdev_file_handle *fhandle, uint64_t offset,
     936             :                    spdk_fsdev_readdir_entry_cb entry_cb_fn, spdk_fsdev_readdir_cpl_cb cpl_cb_fn, void *cb_arg)
     937             : {
     938             :         struct spdk_fsdev_io *fsdev_io;
     939             : 
     940           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cpl_cb_fn, cb_arg,
     941             :                                          _spdk_fsdev_readdir_emum_clb, ch, SPDK_FSDEV_IO_READDIR);
     942           1 :         if (!fsdev_io) {
     943           0 :                 return -ENOBUFS;
     944             :         }
     945             : 
     946           1 :         fsdev_io->u_in.readdir.fobject = fobject;
     947           1 :         fsdev_io->u_in.readdir.fhandle = fhandle;
     948           1 :         fsdev_io->u_in.readdir.offset = offset;
     949           1 :         fsdev_io->u_in.readdir.entry_cb_fn = _spdk_fsdev_readdir_entry_clb;
     950           1 :         fsdev_io->u_in.readdir.usr_entry_cb_fn = entry_cb_fn;
     951             : 
     952           1 :         fsdev_io_submit(fsdev_io);
     953           1 :         return 0;
     954             : }
     955             : 
     956             : static void
     957           1 : _spdk_fsdev_releasedir_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     958             : {
     959           1 :         struct spdk_io_channel *ch = cb_arg;
     960             : 
     961           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_releasedir_cpl_cb);
     962             : 
     963           1 :         fsdev_io_free(fsdev_io);
     964           1 : }
     965             : 
     966             : int
     967           1 : spdk_fsdev_releasedir(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     968             :                       struct spdk_fsdev_file_object *fobject, struct spdk_fsdev_file_handle *fhandle,
     969             :                       spdk_fsdev_releasedir_cpl_cb cb_fn, void *cb_arg)
     970             : {
     971             :         struct spdk_fsdev_io *fsdev_io;
     972             : 
     973           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_releasedir_cb, ch,
     974             :                                          SPDK_FSDEV_IO_RELEASEDIR);
     975           1 :         if (!fsdev_io) {
     976           0 :                 return -ENOBUFS;
     977             :         }
     978             : 
     979           1 :         fsdev_io->u_in.releasedir.fobject = fobject;
     980           1 :         fsdev_io->u_in.releasedir.fhandle = fhandle;
     981             : 
     982           1 :         fsdev_io_submit(fsdev_io);
     983           1 :         return 0;
     984             : }
     985             : 
     986             : static void
     987           1 : _spdk_fsdev_fsyncdir_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
     988             : {
     989           1 :         struct spdk_io_channel *ch = cb_arg;
     990             : 
     991           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_fsyncdir_cpl_cb);
     992             : 
     993           1 :         fsdev_io_free(fsdev_io);
     994           1 : }
     995             : 
     996             : int
     997           1 : spdk_fsdev_fsyncdir(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
     998             :                     struct spdk_fsdev_file_object *fobject, struct spdk_fsdev_file_handle *fhandle, bool datasync,
     999             :                     spdk_fsdev_fsyncdir_cpl_cb cb_fn, void *cb_arg)
    1000             : {
    1001             :         struct spdk_fsdev_io *fsdev_io;
    1002             : 
    1003           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_fsyncdir_cb, ch,
    1004             :                                          SPDK_FSDEV_IO_FSYNCDIR);
    1005           1 :         if (!fsdev_io) {
    1006           0 :                 return -ENOBUFS;
    1007             :         }
    1008             : 
    1009           1 :         fsdev_io->u_in.fsyncdir.fobject = fobject;
    1010           1 :         fsdev_io->u_in.fsyncdir.fhandle = fhandle;
    1011           1 :         fsdev_io->u_in.fsyncdir.datasync = datasync;
    1012             : 
    1013           1 :         fsdev_io_submit(fsdev_io);
    1014           1 :         return 0;
    1015             : }
    1016             : 
    1017             : static void
    1018           1 : _spdk_fsdev_flock_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
    1019             : {
    1020           1 :         struct spdk_io_channel *ch = cb_arg;
    1021             : 
    1022           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_flock_cpl_cb);
    1023             : 
    1024           1 :         fsdev_io_free(fsdev_io);
    1025           1 : }
    1026             : 
    1027             : int
    1028           1 : spdk_fsdev_flock(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
    1029             :                  struct spdk_fsdev_file_object *fobject, struct spdk_fsdev_file_handle *fhandle, int operation,
    1030             :                  spdk_fsdev_flock_cpl_cb cb_fn, void *cb_arg)
    1031             : {
    1032             :         struct spdk_fsdev_io *fsdev_io;
    1033             : 
    1034           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_flock_cb, ch,
    1035             :                                          SPDK_FSDEV_IO_FLOCK);
    1036           1 :         if (!fsdev_io) {
    1037           0 :                 return -ENOBUFS;
    1038             :         }
    1039             : 
    1040           1 :         fsdev_io->u_in.flock.fobject = fobject;
    1041           1 :         fsdev_io->u_in.flock.fhandle = fhandle;
    1042           1 :         fsdev_io->u_in.flock.operation = operation;
    1043             : 
    1044           1 :         fsdev_io_submit(fsdev_io);
    1045           1 :         return 0;
    1046             : }
    1047             : 
    1048             : static void
    1049           1 : _spdk_fsdev_create_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
    1050             : {
    1051           1 :         struct spdk_io_channel *ch = cb_arg;
    1052             : 
    1053           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_create_cpl_cb, fsdev_io->u_out.create.fobject,
    1054             :                      &fsdev_io->u_out.create.attr, fsdev_io->u_out.create.fhandle);
    1055             : 
    1056           1 :         free(fsdev_io->u_in.create.name);
    1057             : 
    1058           1 :         fsdev_io_free(fsdev_io);
    1059           1 : }
    1060             : 
    1061             : int
    1062           1 : spdk_fsdev_create(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
    1063             :                   struct spdk_fsdev_file_object *parent_fobject, const char *name, mode_t mode, uint32_t flags,
    1064             :                   mode_t umask, uid_t euid, gid_t egid, spdk_fsdev_create_cpl_cb cb_fn, void *cb_arg)
    1065             : {
    1066             :         struct spdk_fsdev_io *fsdev_io;
    1067             : 
    1068           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_create_cb, ch,
    1069             :                                          SPDK_FSDEV_IO_CREATE);
    1070           1 :         if (!fsdev_io) {
    1071           0 :                 return -ENOBUFS;
    1072             :         }
    1073             : 
    1074           1 :         fsdev_io->u_in.create.name = strdup(name);
    1075           1 :         if (!fsdev_io->u_in.create.name) {
    1076           0 :                 fsdev_io_free(fsdev_io);
    1077           0 :                 return -ENOMEM;
    1078             :         }
    1079             : 
    1080           1 :         fsdev_io->u_in.create.parent_fobject = parent_fobject;
    1081           1 :         fsdev_io->u_in.create.mode = mode;
    1082           1 :         fsdev_io->u_in.create.flags = flags;
    1083           1 :         fsdev_io->u_in.create.umask = umask;
    1084           1 :         fsdev_io->u_in.create.euid = euid;
    1085           1 :         fsdev_io->u_in.create.egid = egid;
    1086             : 
    1087           1 :         fsdev_io_submit(fsdev_io);
    1088           1 :         return 0;
    1089             : }
    1090             : 
    1091             : static void
    1092           1 : _spdk_fsdev_interrupt_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
    1093             : {
    1094           1 :         struct spdk_io_channel *ch = cb_arg;
    1095             : 
    1096           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_abort_cpl_cb);
    1097             : 
    1098           1 :         fsdev_io_free(fsdev_io);
    1099           1 : }
    1100             : 
    1101             : int
    1102           1 : spdk_fsdev_abort(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch,
    1103             :                  uint64_t unique_to_abort, spdk_fsdev_abort_cpl_cb cb_fn, void *cb_arg)
    1104             : {
    1105             :         struct spdk_fsdev_io *fsdev_io;
    1106             : 
    1107           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, 0, cb_fn, cb_arg, _spdk_fsdev_interrupt_cb, ch,
    1108             :                                          SPDK_FSDEV_IO_ABORT);
    1109           1 :         if (!fsdev_io) {
    1110           0 :                 return -ENOBUFS;
    1111             :         }
    1112             : 
    1113           1 :         fsdev_io->u_in.abort.unique_to_abort = unique_to_abort;
    1114             : 
    1115           1 :         fsdev_io_submit(fsdev_io);
    1116           1 :         return 0;
    1117             : }
    1118             : 
    1119             : static void
    1120           1 : _spdk_fsdev_fallocate_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
    1121             : {
    1122           1 :         struct spdk_io_channel *ch = cb_arg;
    1123             : 
    1124           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_fallocate_cpl_cb);
    1125             : 
    1126           1 :         fsdev_io_free(fsdev_io);
    1127           1 : }
    1128             : 
    1129             : int
    1130           1 : spdk_fsdev_fallocate(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch, uint64_t unique,
    1131             :                      struct spdk_fsdev_file_object *fobject, struct spdk_fsdev_file_handle *fhandle,
    1132             :                      int mode, off_t offset, off_t length,
    1133             :                      spdk_fsdev_fallocate_cpl_cb cb_fn, void *cb_arg)
    1134             : {
    1135             :         struct spdk_fsdev_io *fsdev_io;
    1136             : 
    1137           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_fallocate_cb, ch,
    1138             :                                          SPDK_FSDEV_IO_FALLOCATE);
    1139           1 :         if (!fsdev_io) {
    1140           0 :                 return -ENOBUFS;
    1141             :         }
    1142             : 
    1143           1 :         fsdev_io->u_in.fallocate.fobject = fobject;
    1144           1 :         fsdev_io->u_in.fallocate.fhandle = fhandle;
    1145           1 :         fsdev_io->u_in.fallocate.mode = mode;
    1146           1 :         fsdev_io->u_in.fallocate.offset = offset;
    1147           1 :         fsdev_io->u_in.fallocate.length = length;
    1148             : 
    1149           1 :         fsdev_io_submit(fsdev_io);
    1150           1 :         return 0;
    1151             : }
    1152             : 
    1153             : static void
    1154           1 : _spdk_fsdev_copy_file_range_cb(struct spdk_fsdev_io *fsdev_io, void *cb_arg)
    1155             : {
    1156           1 :         struct spdk_io_channel *ch = cb_arg;
    1157             : 
    1158           1 :         CALL_USR_CLB(fsdev_io, ch, spdk_fsdev_copy_file_range_cpl_cb,
    1159             :                      fsdev_io->u_out.copy_file_range.data_size);
    1160             : 
    1161           1 :         fsdev_io_free(fsdev_io);
    1162           1 : }
    1163             : 
    1164             : int
    1165           1 : spdk_fsdev_copy_file_range(struct spdk_fsdev_desc *desc, struct spdk_io_channel *ch,
    1166             :                            uint64_t unique,
    1167             :                            struct spdk_fsdev_file_object *fobject_in, struct spdk_fsdev_file_handle *fhandle_in, off_t off_in,
    1168             :                            struct spdk_fsdev_file_object *fobject_out, struct spdk_fsdev_file_handle *fhandle_out,
    1169             :                            off_t off_out, size_t len, uint32_t flags,
    1170             :                            spdk_fsdev_copy_file_range_cpl_cb cb_fn, void *cb_arg)
    1171             : {
    1172             :         struct spdk_fsdev_io *fsdev_io;
    1173             : 
    1174           1 :         fsdev_io = fsdev_io_get_and_fill(desc, ch, unique, cb_fn, cb_arg, _spdk_fsdev_copy_file_range_cb,
    1175             :                                          ch,
    1176             :                                          SPDK_FSDEV_IO_COPY_FILE_RANGE);
    1177           1 :         if (!fsdev_io) {
    1178           0 :                 return -ENOBUFS;
    1179             :         }
    1180             : 
    1181           1 :         fsdev_io->u_in.copy_file_range.fobject_in = fobject_in;
    1182           1 :         fsdev_io->u_in.copy_file_range.fhandle_in = fhandle_in;
    1183           1 :         fsdev_io->u_in.copy_file_range.off_in = off_in;
    1184           1 :         fsdev_io->u_in.copy_file_range.fobject_out = fobject_out;
    1185           1 :         fsdev_io->u_in.copy_file_range.fhandle_out = fhandle_out;
    1186           1 :         fsdev_io->u_in.copy_file_range.off_out = off_out;
    1187           1 :         fsdev_io->u_in.copy_file_range.len = len;
    1188           1 :         fsdev_io->u_in.copy_file_range.flags = flags;
    1189             : 
    1190           1 :         fsdev_io_submit(fsdev_io);
    1191           1 :         return 0;
    1192             : }

Generated by: LCOV version 1.15