LCOV - code coverage report
Current view: top level - spdk/lib/blob - request.c (source / functions) Hit Total Coverage
Test: Combined Lines: 258 278 92.8 %
Date: 2024-07-15 19:24:52 Functions: 28 29 96.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 81 125 64.8 %

           Branch data     Line data    Source code
       1                 :            : /*   SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  *   Copyright (C) 2017 Intel Corporation.
       3                 :            :  *   All rights reserved.
       4                 :            :  *   Copyright (c) 2022-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
       5                 :            :  */
       6                 :            : 
       7                 :            : #include "spdk/stdinc.h"
       8                 :            : 
       9                 :            : #include "blobstore.h"
      10                 :            : #include "request.h"
      11                 :            : 
      12                 :            : #include "spdk/thread.h"
      13                 :            : #include "spdk/queue.h"
      14                 :            : 
      15                 :            : #include "spdk/log.h"
      16                 :            : 
      17                 :            : void
      18                 :    6991891 : bs_call_cpl(struct spdk_bs_cpl *cpl, int bserrno)
      19                 :            : {
      20   [ +  +  +  +  :    6991891 :         switch (cpl->type) {
             +  -  +  - ]
      21                 :       2474 :         case SPDK_BS_CPL_TYPE_BS_BASIC:
      22                 :       2474 :                 cpl->u.bs_basic.cb_fn(cpl->u.bs_basic.cb_arg,
      23                 :            :                                       bserrno);
      24                 :       2474 :                 break;
      25                 :       9001 :         case SPDK_BS_CPL_TYPE_BS_HANDLE:
      26         [ +  + ]:       9001 :                 cpl->u.bs_handle.cb_fn(cpl->u.bs_handle.cb_arg,
      27                 :            :                                        bserrno == 0 ? cpl->u.bs_handle.bs : NULL,
      28                 :            :                                        bserrno);
      29                 :       9001 :                 break;
      30                 :    6947919 :         case SPDK_BS_CPL_TYPE_BLOB_BASIC:
      31                 :    6947919 :                 cpl->u.blob_basic.cb_fn(cpl->u.blob_basic.cb_arg,
      32                 :            :                                         bserrno);
      33                 :    6947919 :                 break;
      34                 :       6791 :         case SPDK_BS_CPL_TYPE_BLOBID:
      35         [ +  + ]:       6791 :                 cpl->u.blobid.cb_fn(cpl->u.blobid.cb_arg,
      36                 :            :                                     bserrno == 0 ? cpl->u.blobid.blobid : SPDK_BLOBID_INVALID,
      37                 :            :                                     bserrno);
      38                 :       6791 :                 break;
      39                 :      16692 :         case SPDK_BS_CPL_TYPE_BLOB_HANDLE:
      40         [ +  + ]:      16692 :                 cpl->u.blob_handle.cb_fn(cpl->u.blob_handle.cb_arg,
      41                 :            :                                          bserrno == 0 ? cpl->u.blob_handle.blob : NULL,
      42                 :            :                                          bserrno);
      43                 :      16692 :                 break;
      44                 :          0 :         case SPDK_BS_CPL_TYPE_NESTED_SEQUENCE:
      45                 :          0 :                 cpl->u.nested_seq.cb_fn(cpl->u.nested_seq.cb_arg,
      46                 :            :                                         cpl->u.nested_seq.parent,
      47                 :            :                                         bserrno);
      48                 :          0 :                 break;
      49                 :       9014 :         case SPDK_BS_CPL_TYPE_NONE:
      50                 :            :                 /* this completion's callback is handled elsewhere */
      51                 :       9014 :                 break;
      52                 :            :         }
      53                 :    6991891 : }
      54                 :            : 
      55                 :            : static void
      56                 :    6982877 : bs_request_set_complete(struct spdk_bs_request_set *set)
      57                 :            : {
      58                 :    6982877 :         struct spdk_bs_cpl cpl = set->cpl;
      59                 :    6982877 :         int bserrno = set->bserrno;
      60                 :            : 
      61                 :    6982877 :         TAILQ_INSERT_TAIL(&set->channel->reqs, set, link);
      62                 :            : 
      63                 :    6982877 :         bs_call_cpl(&cpl, bserrno);
      64                 :    6982877 : }
      65                 :            : 
      66                 :            : static void
      67                 :    5138354 : bs_sequence_completion(struct spdk_io_channel *channel, void *cb_arg, int bserrno)
      68                 :            : {
      69                 :    5138354 :         struct spdk_bs_request_set *set = cb_arg;
      70                 :            : 
      71                 :    5138354 :         set->bserrno = bserrno;
      72                 :    5138354 :         set->u.sequence.cb_fn((spdk_bs_sequence_t *)set, set->u.sequence.cb_arg, bserrno);
      73                 :    5138354 : }
      74                 :            : 
      75                 :            : static inline spdk_bs_sequence_t *
      76                 :    5120832 : bs_sequence_start(struct spdk_io_channel *_channel, struct spdk_bs_cpl *cpl,
      77                 :            :                   struct spdk_io_channel *back_channel)
      78                 :            : {
      79                 :            :         struct spdk_bs_channel          *channel;
      80                 :            :         struct spdk_bs_request_set      *set;
      81                 :            : 
      82                 :    5120832 :         channel = spdk_io_channel_get_ctx(_channel);
      83         [ -  + ]:    5120832 :         assert(channel != NULL);
      84                 :    5120832 :         set = TAILQ_FIRST(&channel->reqs);
      85         [ +  + ]:    5120832 :         if (!set) {
      86                 :      30989 :                 return NULL;
      87                 :            :         }
      88         [ +  + ]:    5089843 :         TAILQ_REMOVE(&channel->reqs, set, link);
      89                 :            : 
      90                 :    5089843 :         set->cpl = *cpl;
      91                 :    5089843 :         set->bserrno = 0;
      92                 :    5089843 :         set->channel = channel;
      93                 :    5089843 :         set->back_channel = back_channel;
      94                 :            : 
      95                 :    5089843 :         set->cb_args.cb_fn = bs_sequence_completion;
      96                 :    5089843 :         set->cb_args.cb_arg = set;
      97                 :    5089843 :         set->cb_args.channel = channel->dev_channel;
      98                 :    5089843 :         set->ext_io_opts = NULL;
      99                 :            : 
     100                 :    5089843 :         return (spdk_bs_sequence_t *)set;
     101                 :            : }
     102                 :            : 
     103                 :            : /* Use when performing IO directly on the blobstore (e.g. metadata - not a blob). */
     104                 :            : spdk_bs_sequence_t *
     105                 :     106593 : bs_sequence_start_bs(struct spdk_io_channel *_channel, struct spdk_bs_cpl *cpl)
     106                 :            : {
     107                 :     106593 :         return bs_sequence_start(_channel, cpl, _channel);
     108                 :            : }
     109                 :            : 
     110                 :            : /* Use when performing IO on a blob. */
     111                 :            : spdk_bs_sequence_t *
     112                 :    5014239 : bs_sequence_start_blob(struct spdk_io_channel *_channel, struct spdk_bs_cpl *cpl,
     113                 :            :                        struct spdk_blob *blob)
     114                 :            : {
     115                 :    5014239 :         struct spdk_io_channel  *esnap_ch = _channel;
     116                 :            : 
     117         [ +  + ]:    5014239 :         if (spdk_blob_is_esnap_clone(blob)) {
     118                 :      18275 :                 esnap_ch = blob_esnap_get_io_channel(_channel, blob);
     119         [ -  + ]:      18275 :                 if (esnap_ch == NULL) {
     120                 :            :                         /*
     121                 :            :                          * The most likely reason we are here is because of some logic error
     122                 :            :                          * elsewhere that caused channel allocations to fail. We could get here due
     123                 :            :                          * to being out of memory as well. If we are out of memory, the process is
     124                 :            :                          * this will be just one of many problems that this process will be having.
     125                 :            :                          * Killing it off debug builds now due to logic errors is the right thing to
     126                 :            :                          * do and killing it off due to ENOMEM is no big loss.
     127                 :            :                          */
     128                 :          0 :                         assert(false);
     129                 :            :                         return NULL;
     130                 :            :                 }
     131                 :            :         }
     132                 :    5014239 :         return bs_sequence_start(_channel, cpl, esnap_ch);
     133                 :            : }
     134                 :            : 
     135                 :            : void
     136                 :        895 : bs_sequence_read_bs_dev(spdk_bs_sequence_t *seq, struct spdk_bs_dev *bs_dev,
     137                 :            :                         void *payload, uint64_t lba, uint32_t lba_count,
     138                 :            :                         spdk_bs_sequence_cpl cb_fn, void *cb_arg)
     139                 :            : {
     140                 :        895 :         struct spdk_bs_request_set      *set = (struct spdk_bs_request_set *)seq;
     141                 :        895 :         struct spdk_io_channel          *back_channel = set->back_channel;
     142                 :            : 
     143   [ -  +  -  + ]:        895 :         SPDK_DEBUGLOG(blob_rw, "Reading %" PRIu32 " blocks from LBA %" PRIu64 "\n", lba_count,
     144                 :            :                       lba);
     145                 :            : 
     146                 :        895 :         set->u.sequence.cb_fn = cb_fn;
     147                 :        895 :         set->u.sequence.cb_arg = cb_arg;
     148                 :            : 
     149                 :        895 :         bs_dev->read(bs_dev, back_channel, payload, lba, lba_count, &set->cb_args);
     150                 :        895 : }
     151                 :            : 
     152                 :            : void
     153                 :      61137 : bs_sequence_read_dev(spdk_bs_sequence_t *seq, void *payload,
     154                 :            :                      uint64_t lba, uint32_t lba_count,
     155                 :            :                      spdk_bs_sequence_cpl cb_fn, void *cb_arg)
     156                 :            : {
     157                 :      61137 :         struct spdk_bs_request_set      *set = (struct spdk_bs_request_set *)seq;
     158                 :      61137 :         struct spdk_bs_channel       *channel = set->channel;
     159                 :            : 
     160   [ -  +  -  + ]:      61137 :         SPDK_DEBUGLOG(blob_rw, "Reading %" PRIu32 " blocks from LBA %" PRIu64 "\n", lba_count,
     161                 :            :                       lba);
     162                 :            : 
     163                 :      61137 :         set->u.sequence.cb_fn = cb_fn;
     164                 :      61137 :         set->u.sequence.cb_arg = cb_arg;
     165                 :            : 
     166                 :      61137 :         channel->dev->read(channel->dev, channel->dev_channel, payload, lba, lba_count, &set->cb_args);
     167                 :      61137 : }
     168                 :            : 
     169                 :            : void
     170                 :      97291 : bs_sequence_write_dev(spdk_bs_sequence_t *seq, void *payload,
     171                 :            :                       uint64_t lba, uint32_t lba_count,
     172                 :            :                       spdk_bs_sequence_cpl cb_fn, void *cb_arg)
     173                 :            : {
     174                 :      97291 :         struct spdk_bs_request_set      *set = (struct spdk_bs_request_set *)seq;
     175                 :      97291 :         struct spdk_bs_channel       *channel = set->channel;
     176                 :            : 
     177   [ -  +  -  + ]:      97291 :         SPDK_DEBUGLOG(blob_rw, "Writing %" PRIu32 " blocks from LBA %" PRIu64 "\n", lba_count,
     178                 :            :                       lba);
     179                 :            : 
     180                 :      97291 :         set->u.sequence.cb_fn = cb_fn;
     181                 :      97291 :         set->u.sequence.cb_arg = cb_arg;
     182                 :            : 
     183                 :      97291 :         channel->dev->write(channel->dev, channel->dev_channel, payload, lba, lba_count,
     184                 :            :                             &set->cb_args);
     185                 :      97291 : }
     186                 :            : 
     187                 :            : void
     188                 :     941735 : bs_sequence_readv_bs_dev(spdk_bs_sequence_t *seq, struct spdk_bs_dev *bs_dev,
     189                 :            :                          struct iovec *iov, int iovcnt, uint64_t lba, uint32_t lba_count,
     190                 :            :                          spdk_bs_sequence_cpl cb_fn, void *cb_arg)
     191                 :            : {
     192                 :     941735 :         struct spdk_bs_request_set      *set = (struct spdk_bs_request_set *)seq;
     193                 :     941735 :         struct spdk_io_channel          *back_channel = set->back_channel;
     194                 :            : 
     195   [ -  +  -  + ]:     941735 :         SPDK_DEBUGLOG(blob_rw, "Reading %" PRIu32 " blocks from LBA %" PRIu64 "\n", lba_count,
     196                 :            :                       lba);
     197                 :            : 
     198                 :     941735 :         set->u.sequence.cb_fn = cb_fn;
     199                 :     941735 :         set->u.sequence.cb_arg = cb_arg;
     200                 :            : 
     201         [ +  + ]:     941735 :         if (set->ext_io_opts) {
     202         [ -  + ]:     937319 :                 assert(bs_dev->readv_ext);
     203                 :     937319 :                 bs_dev->readv_ext(bs_dev, back_channel, iov, iovcnt, lba, lba_count,
     204                 :            :                                   &set->cb_args, set->ext_io_opts);
     205                 :            :         } else {
     206                 :       4416 :                 bs_dev->readv(bs_dev, back_channel, iov, iovcnt, lba, lba_count, &set->cb_args);
     207                 :            :         }
     208                 :     941735 : }
     209                 :            : 
     210                 :            : void
     211                 :    1486191 : bs_sequence_readv_dev(spdk_bs_sequence_t *seq, struct iovec *iov, int iovcnt,
     212                 :            :                       uint64_t lba, uint32_t lba_count, spdk_bs_sequence_cpl cb_fn, void *cb_arg)
     213                 :            : {
     214                 :    1486191 :         struct spdk_bs_request_set      *set = (struct spdk_bs_request_set *)seq;
     215                 :    1486191 :         struct spdk_bs_channel       *channel = set->channel;
     216                 :            : 
     217   [ -  +  -  + ]:    1486191 :         SPDK_DEBUGLOG(blob_rw, "Reading %" PRIu32 " blocks from LBA %" PRIu64 "\n", lba_count,
     218                 :            :                       lba);
     219                 :            : 
     220                 :    1486191 :         set->u.sequence.cb_fn = cb_fn;
     221                 :    1486191 :         set->u.sequence.cb_arg = cb_arg;
     222         [ +  + ]:    1486191 :         if (set->ext_io_opts) {
     223         [ -  + ]:    1485219 :                 assert(channel->dev->readv_ext);
     224                 :    1485219 :                 channel->dev->readv_ext(channel->dev, channel->dev_channel, iov, iovcnt, lba, lba_count,
     225                 :            :                                         &set->cb_args, set->ext_io_opts);
     226                 :            :         } else {
     227                 :        972 :                 channel->dev->readv(channel->dev, channel->dev_channel, iov, iovcnt, lba, lba_count, &set->cb_args);
     228                 :            :         }
     229                 :    1486191 : }
     230                 :            : 
     231                 :            : void
     232                 :    2550559 : bs_sequence_writev_dev(spdk_bs_sequence_t *seq, struct iovec *iov, int iovcnt,
     233                 :            :                        uint64_t lba, uint32_t lba_count,
     234                 :            :                        spdk_bs_sequence_cpl cb_fn, void *cb_arg)
     235                 :            : {
     236                 :    2550559 :         struct spdk_bs_request_set      *set = (struct spdk_bs_request_set *)seq;
     237                 :    2550559 :         struct spdk_bs_channel       *channel = set->channel;
     238                 :            : 
     239   [ -  +  -  + ]:    2550559 :         SPDK_DEBUGLOG(blob_rw, "Writing %" PRIu32 " blocks from LBA %" PRIu64 "\n", lba_count,
     240                 :            :                       lba);
     241                 :            : 
     242                 :    2550559 :         set->u.sequence.cb_fn = cb_fn;
     243                 :    2550559 :         set->u.sequence.cb_arg = cb_arg;
     244                 :            : 
     245         [ +  + ]:    2550559 :         if (set->ext_io_opts) {
     246         [ -  + ]:    2548333 :                 assert(channel->dev->writev_ext);
     247                 :    2548333 :                 channel->dev->writev_ext(channel->dev, channel->dev_channel, iov, iovcnt, lba, lba_count,
     248                 :            :                                          &set->cb_args, set->ext_io_opts);
     249                 :            :         } else {
     250                 :       2226 :                 channel->dev->writev(channel->dev, channel->dev_channel, iov, iovcnt, lba, lba_count,
     251                 :            :                                      &set->cb_args);
     252                 :            :         }
     253                 :    2550559 : }
     254                 :            : 
     255                 :            : void
     256                 :        108 : bs_sequence_write_zeroes_dev(spdk_bs_sequence_t *seq,
     257                 :            :                              uint64_t lba, uint64_t lba_count,
     258                 :            :                              spdk_bs_sequence_cpl cb_fn, void *cb_arg)
     259                 :            : {
     260                 :        108 :         struct spdk_bs_request_set      *set = (struct spdk_bs_request_set *)seq;
     261                 :        108 :         struct spdk_bs_channel       *channel = set->channel;
     262                 :            : 
     263   [ -  +  -  + ]:        108 :         SPDK_DEBUGLOG(blob_rw, "writing zeroes to %" PRIu64 " blocks at LBA %" PRIu64 "\n",
     264                 :            :                       lba_count, lba);
     265                 :            : 
     266                 :        108 :         set->u.sequence.cb_fn = cb_fn;
     267                 :        108 :         set->u.sequence.cb_arg = cb_arg;
     268                 :            : 
     269                 :        108 :         channel->dev->write_zeroes(channel->dev, channel->dev_channel, lba, lba_count,
     270                 :            :                                    &set->cb_args);
     271                 :        108 : }
     272                 :            : 
     273                 :            : void
     274                 :        438 : bs_sequence_copy_dev(spdk_bs_sequence_t *seq, uint64_t dst_lba, uint64_t src_lba,
     275                 :            :                      uint64_t lba_count, spdk_bs_sequence_cpl cb_fn, void *cb_arg)
     276                 :            : {
     277                 :        438 :         struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)seq;
     278                 :        438 :         struct spdk_bs_channel     *channel = set->channel;
     279                 :            : 
     280   [ -  +  -  + ]:        438 :         SPDK_DEBUGLOG(blob_rw, "Copying %" PRIu64 " blocks from LBA %" PRIu64 " to LBA %" PRIu64 "\n",
     281                 :            :                       lba_count, src_lba, dst_lba);
     282                 :            : 
     283                 :        438 :         set->u.sequence.cb_fn = cb_fn;
     284                 :        438 :         set->u.sequence.cb_arg = cb_arg;
     285                 :            : 
     286                 :        438 :         channel->dev->copy(channel->dev, channel->dev_channel, dst_lba, src_lba, lba_count, &set->cb_args);
     287                 :        438 : }
     288                 :            : 
     289                 :            : void
     290                 :    5089843 : bs_sequence_finish(spdk_bs_sequence_t *seq, int bserrno)
     291                 :            : {
     292         [ +  + ]:    5089843 :         if (bserrno != 0) {
     293                 :       6945 :                 seq->bserrno = bserrno;
     294                 :            :         }
     295                 :    5089843 :         bs_request_set_complete((struct spdk_bs_request_set *)seq);
     296                 :    5089843 : }
     297                 :            : 
     298                 :            : void
     299                 :          0 : bs_user_op_sequence_finish(void *cb_arg, int bserrno)
     300                 :            : {
     301                 :          0 :         spdk_bs_sequence_t *seq = cb_arg;
     302                 :            : 
     303                 :          0 :         bs_sequence_finish(seq, bserrno);
     304                 :          0 : }
     305                 :            : 
     306                 :            : static void
     307                 :    1910748 : bs_batch_completion(struct spdk_io_channel *_channel,
     308                 :            :                     void *cb_arg, int bserrno)
     309                 :            : {
     310                 :    1910748 :         struct spdk_bs_request_set      *set = cb_arg;
     311                 :            : 
     312                 :    1910748 :         set->u.batch.outstanding_ops--;
     313         [ +  + ]:    1910748 :         if (bserrno != 0) {
     314                 :         12 :                 set->bserrno = bserrno;
     315                 :            :         }
     316                 :            : 
     317   [ +  +  +  + ]:    1910748 :         if (set->u.batch.outstanding_ops == 0 && set->u.batch.batch_closed) {
     318         [ +  + ]:    1769421 :                 if (set->u.batch.cb_fn) {
     319                 :      13819 :                         set->cb_args.cb_fn = bs_sequence_completion;
     320                 :      13819 :                         set->u.batch.cb_fn((spdk_bs_sequence_t *)set, set->u.batch.cb_arg, bserrno);
     321                 :            :                 } else {
     322                 :    1755602 :                         bs_request_set_complete(set);
     323                 :            :                 }
     324                 :            :         }
     325                 :    1910748 : }
     326                 :            : 
     327                 :            : spdk_bs_batch_t *
     328                 :    1893034 : bs_batch_open(struct spdk_io_channel *_channel, struct spdk_bs_cpl *cpl, struct spdk_blob *blob)
     329                 :            : {
     330                 :            :         struct spdk_bs_channel          *channel;
     331                 :            :         struct spdk_bs_request_set      *set;
     332                 :    1893034 :         struct spdk_io_channel          *back_channel = _channel;
     333                 :            : 
     334         [ +  + ]:    1893034 :         if (spdk_blob_is_esnap_clone(blob)) {
     335                 :      22020 :                 back_channel = blob_esnap_get_io_channel(_channel, blob);
     336         [ -  + ]:      22020 :                 if (back_channel == NULL) {
     337                 :          0 :                         return NULL;
     338                 :            :                 }
     339                 :            :         }
     340                 :            : 
     341                 :    1893034 :         channel = spdk_io_channel_get_ctx(_channel);
     342         [ -  + ]:    1893034 :         assert(channel != NULL);
     343                 :    1893034 :         set = TAILQ_FIRST(&channel->reqs);
     344         [ -  + ]:    1893034 :         if (!set) {
     345                 :          0 :                 return NULL;
     346                 :            :         }
     347         [ +  - ]:    1893034 :         TAILQ_REMOVE(&channel->reqs, set, link);
     348                 :            : 
     349                 :    1893034 :         set->cpl = *cpl;
     350                 :    1893034 :         set->bserrno = 0;
     351                 :    1893034 :         set->channel = channel;
     352                 :    1893034 :         set->back_channel = back_channel;
     353                 :            : 
     354                 :    1893034 :         set->u.batch.cb_fn = NULL;
     355                 :    1893034 :         set->u.batch.cb_arg = NULL;
     356                 :    1893034 :         set->u.batch.outstanding_ops = 0;
     357                 :    1893034 :         set->u.batch.batch_closed = 0;
     358                 :            : 
     359                 :    1893034 :         set->cb_args.cb_fn = bs_batch_completion;
     360                 :    1893034 :         set->cb_args.cb_arg = set;
     361                 :    1893034 :         set->cb_args.channel = channel->dev_channel;
     362                 :            : 
     363                 :    1893034 :         return (spdk_bs_batch_t *)set;
     364                 :            : }
     365                 :            : 
     366                 :            : void
     367                 :       3264 : bs_batch_read_bs_dev(spdk_bs_batch_t *batch, struct spdk_bs_dev *bs_dev,
     368                 :            :                      void *payload, uint64_t lba, uint32_t lba_count)
     369                 :            : {
     370                 :       3264 :         struct spdk_bs_request_set      *set = (struct spdk_bs_request_set *)batch;
     371                 :       3264 :         struct spdk_io_channel          *back_channel = set->back_channel;
     372                 :            : 
     373   [ -  +  -  + ]:       3264 :         SPDK_DEBUGLOG(blob_rw, "Reading %" PRIu32 " blocks from LBA %" PRIu64 "\n", lba_count,
     374                 :            :                       lba);
     375                 :            : 
     376                 :       3264 :         set->u.batch.outstanding_ops++;
     377                 :       3264 :         bs_dev->read(bs_dev, back_channel, payload, lba, lba_count, &set->cb_args);
     378                 :       3264 : }
     379                 :            : 
     380                 :            : void
     381                 :    1457307 : bs_batch_read_dev(spdk_bs_batch_t *batch, void *payload,
     382                 :            :                   uint64_t lba, uint32_t lba_count)
     383                 :            : {
     384                 :    1457307 :         struct spdk_bs_request_set      *set = (struct spdk_bs_request_set *)batch;
     385                 :    1457307 :         struct spdk_bs_channel          *channel = set->channel;
     386                 :            : 
     387   [ -  +  -  + ]:    1457307 :         SPDK_DEBUGLOG(blob_rw, "Reading %" PRIu32 " blocks from LBA %" PRIu64 "\n", lba_count,
     388                 :            :                       lba);
     389                 :            : 
     390                 :    1457307 :         set->u.batch.outstanding_ops++;
     391                 :    1457307 :         channel->dev->read(channel->dev, channel->dev_channel, payload, lba, lba_count, &set->cb_args);
     392                 :    1457307 : }
     393                 :            : 
     394                 :            : void
     395                 :     290979 : bs_batch_write_dev(spdk_bs_batch_t *batch, void *payload,
     396                 :            :                    uint64_t lba, uint32_t lba_count)
     397                 :            : {
     398                 :     290979 :         struct spdk_bs_request_set      *set = (struct spdk_bs_request_set *)batch;
     399                 :     290979 :         struct spdk_bs_channel          *channel = set->channel;
     400                 :            : 
     401   [ -  +  -  + ]:     290979 :         SPDK_DEBUGLOG(blob_rw, "Writing %" PRIu32 " blocks to LBA %" PRIu64 "\n", lba_count, lba);
     402                 :            : 
     403                 :     290979 :         set->u.batch.outstanding_ops++;
     404                 :     290979 :         channel->dev->write(channel->dev, channel->dev_channel, payload, lba, lba_count,
     405                 :            :                             &set->cb_args);
     406                 :     290979 : }
     407                 :            : 
     408                 :            : void
     409                 :     148752 : bs_batch_unmap_dev(spdk_bs_batch_t *batch,
     410                 :            :                    uint64_t lba, uint64_t lba_count)
     411                 :            : {
     412                 :     148752 :         struct spdk_bs_request_set      *set = (struct spdk_bs_request_set *)batch;
     413                 :     148752 :         struct spdk_bs_channel          *channel = set->channel;
     414                 :            : 
     415   [ -  +  -  + ]:     148752 :         SPDK_DEBUGLOG(blob_rw, "Unmapping %" PRIu64 " blocks at LBA %" PRIu64 "\n", lba_count,
     416                 :            :                       lba);
     417                 :            : 
     418                 :     148752 :         set->u.batch.outstanding_ops++;
     419                 :     148752 :         channel->dev->unmap(channel->dev, channel->dev_channel, lba, lba_count,
     420                 :            :                             &set->cb_args);
     421                 :     148752 : }
     422                 :            : 
     423                 :            : void
     424                 :      10446 : bs_batch_write_zeroes_dev(spdk_bs_batch_t *batch,
     425                 :            :                           uint64_t lba, uint64_t lba_count)
     426                 :            : {
     427                 :      10446 :         struct spdk_bs_request_set      *set = (struct spdk_bs_request_set *)batch;
     428                 :      10446 :         struct spdk_bs_channel          *channel = set->channel;
     429                 :            : 
     430   [ -  +  -  + ]:      10446 :         SPDK_DEBUGLOG(blob_rw, "Zeroing %" PRIu64 " blocks at LBA %" PRIu64 "\n", lba_count, lba);
     431                 :            : 
     432                 :      10446 :         set->u.batch.outstanding_ops++;
     433                 :      10446 :         channel->dev->write_zeroes(channel->dev, channel->dev_channel, lba, lba_count,
     434                 :            :                                    &set->cb_args);
     435                 :      10446 : }
     436                 :            : 
     437                 :            : void
     438                 :    2117632 : bs_batch_close(spdk_bs_batch_t *batch)
     439                 :            : {
     440                 :    2117632 :         struct spdk_bs_request_set      *set = (struct spdk_bs_request_set *)batch;
     441                 :            : 
     442                 :    2117632 :         set->u.batch.batch_closed = 1;
     443                 :            : 
     444         [ +  + ]:    2117632 :         if (set->u.batch.outstanding_ops == 0) {
     445         [ +  + ]:     348211 :                 if (set->u.batch.cb_fn) {
     446                 :     210779 :                         set->cb_args.cb_fn = bs_sequence_completion;
     447                 :     210779 :                         set->u.batch.cb_fn((spdk_bs_sequence_t *)set, set->u.batch.cb_arg, set->bserrno);
     448                 :            :                 } else {
     449                 :     137432 :                         bs_request_set_complete(set);
     450                 :            :                 }
     451                 :            :         }
     452                 :    2117632 : }
     453                 :            : 
     454                 :            : spdk_bs_batch_t *
     455                 :     224598 : bs_sequence_to_batch(spdk_bs_sequence_t *seq, spdk_bs_sequence_cpl cb_fn, void *cb_arg)
     456                 :            : {
     457                 :     224598 :         struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)seq;
     458                 :            : 
     459                 :     224598 :         set->u.batch.cb_fn = cb_fn;
     460                 :     224598 :         set->u.batch.cb_arg = cb_arg;
     461                 :     224598 :         set->u.batch.outstanding_ops = 0;
     462                 :     224598 :         set->u.batch.batch_closed = 0;
     463                 :            : 
     464                 :     224598 :         set->cb_args.cb_fn = bs_batch_completion;
     465                 :            : 
     466                 :     224598 :         return set;
     467                 :            : }
     468                 :            : 
     469                 :            : spdk_bs_user_op_t *
     470                 :      18716 : bs_user_op_alloc(struct spdk_io_channel *_channel, struct spdk_bs_cpl *cpl,
     471                 :            :                  enum spdk_blob_op_type op_type, struct spdk_blob *blob,
     472                 :            :                  void *payload, int iovcnt, uint64_t offset, uint64_t length)
     473                 :            : {
     474                 :            :         struct spdk_bs_channel          *channel;
     475                 :            :         struct spdk_bs_request_set      *set;
     476                 :            :         struct spdk_bs_user_op_args     *args;
     477                 :            : 
     478                 :      18716 :         channel = spdk_io_channel_get_ctx(_channel);
     479         [ -  + ]:      18716 :         assert(channel != NULL);
     480                 :      18716 :         set = TAILQ_FIRST(&channel->reqs);
     481         [ -  + ]:      18716 :         if (!set) {
     482                 :          0 :                 return NULL;
     483                 :            :         }
     484         [ +  - ]:      18716 :         TAILQ_REMOVE(&channel->reqs, set, link);
     485                 :            : 
     486                 :      18716 :         set->cpl = *cpl;
     487                 :      18716 :         set->channel = channel;
     488                 :      18716 :         set->back_channel = NULL;
     489                 :      18716 :         set->ext_io_opts = NULL;
     490                 :            : 
     491                 :      18716 :         args = &set->u.user_op;
     492                 :            : 
     493                 :      18716 :         args->type = op_type;
     494                 :      18716 :         args->iovcnt = iovcnt;
     495                 :      18716 :         args->blob = blob;
     496                 :      18716 :         args->offset = offset;
     497                 :      18716 :         args->length = length;
     498                 :      18716 :         args->payload = payload;
     499                 :            : 
     500                 :      18716 :         return (spdk_bs_user_op_t *)set;
     501                 :            : }
     502                 :            : 
     503                 :            : void
     504                 :      18715 : bs_user_op_execute(spdk_bs_user_op_t *op)
     505                 :            : {
     506                 :            :         struct spdk_bs_request_set      *set;
     507                 :            :         struct spdk_bs_user_op_args     *args;
     508                 :            :         struct spdk_io_channel          *ch;
     509                 :            : 
     510                 :      18715 :         set = (struct spdk_bs_request_set *)op;
     511                 :      18715 :         args = &set->u.user_op;
     512                 :      18715 :         ch = spdk_io_channel_from_ctx(set->channel);
     513                 :            : 
     514   [ +  +  -  -  :      18715 :         switch (args->type) {
                -  +  - ]
     515                 :       1384 :         case SPDK_BLOB_READ:
     516                 :       1384 :                 spdk_blob_io_read(args->blob, ch, args->payload, args->offset, args->length,
     517                 :            :                                   set->cpl.u.blob_basic.cb_fn, set->cpl.u.blob_basic.cb_arg);
     518                 :       1384 :                 break;
     519                 :       1049 :         case SPDK_BLOB_WRITE:
     520                 :       1049 :                 spdk_blob_io_write(args->blob, ch, args->payload, args->offset, args->length,
     521                 :            :                                    set->cpl.u.blob_basic.cb_fn, set->cpl.u.blob_basic.cb_arg);
     522                 :       1049 :                 break;
     523                 :          0 :         case SPDK_BLOB_UNMAP:
     524                 :          0 :                 spdk_blob_io_unmap(args->blob, ch, args->offset, args->length,
     525                 :            :                                    set->cpl.u.blob_basic.cb_fn, set->cpl.u.blob_basic.cb_arg);
     526                 :          0 :                 break;
     527                 :          0 :         case SPDK_BLOB_WRITE_ZEROES:
     528                 :          0 :                 spdk_blob_io_write_zeroes(args->blob, ch, args->offset, args->length,
     529                 :            :                                           set->cpl.u.blob_basic.cb_fn, set->cpl.u.blob_basic.cb_arg);
     530                 :          0 :                 break;
     531                 :          0 :         case SPDK_BLOB_READV:
     532                 :          0 :                 spdk_blob_io_readv_ext(args->blob, ch, args->payload, args->iovcnt,
     533                 :            :                                        args->offset, args->length,
     534                 :            :                                        set->cpl.u.blob_basic.cb_fn, set->cpl.u.blob_basic.cb_arg,
     535                 :            :                                        set->ext_io_opts);
     536                 :          0 :                 break;
     537                 :      16282 :         case SPDK_BLOB_WRITEV:
     538                 :      16282 :                 spdk_blob_io_writev_ext(args->blob, ch, args->payload, args->iovcnt,
     539                 :            :                                         args->offset, args->length,
     540                 :            :                                         set->cpl.u.blob_basic.cb_fn, set->cpl.u.blob_basic.cb_arg,
     541                 :            :                                         set->ext_io_opts);
     542                 :      16282 :                 break;
     543                 :            :         }
     544                 :      18715 :         TAILQ_INSERT_TAIL(&set->channel->reqs, set, link);
     545                 :      18715 : }
     546                 :            : 
     547                 :            : void
     548                 :          1 : bs_user_op_abort(spdk_bs_user_op_t *op, int bserrno)
     549                 :            : {
     550                 :            :         struct spdk_bs_request_set      *set;
     551                 :            : 
     552                 :          1 :         set = (struct spdk_bs_request_set *)op;
     553                 :            : 
     554                 :          1 :         set->cpl.u.blob_basic.cb_fn(set->cpl.u.blob_basic.cb_arg, bserrno);
     555                 :          1 :         TAILQ_INSERT_TAIL(&set->channel->reqs, set, link);
     556                 :          1 : }
     557                 :            : 
     558                 :       2157 : SPDK_LOG_REGISTER_COMPONENT(blob_rw)

Generated by: LCOV version 1.14