LCOV - code coverage report
Current view: top level - spdk/lib/blob - request.c (source / functions) Hit Total Coverage
Test: Combined Lines: 260 280 92.9 %
Date: 2024-07-12 11:58:45 Functions: 28 29 96.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 89 133 66.9 %

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

Generated by: LCOV version 1.14