1 /*- 2 * BSD LICENSE 3 * 4 * Copyright (c) Intel Corporation. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * * Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * * Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * * Neither the name of Intel Corporation nor the names of its 18 * contributors may be used to endorse or promote products derived 19 * from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 #include "spdk/stdinc.h" 35 36 #include "blobstore.h" 37 #include "request.h" 38 39 #include "spdk/io_channel.h" 40 #include "spdk/queue.h" 41 42 #include "spdk_internal/log.h" 43 44 void 45 spdk_bs_call_cpl(struct spdk_bs_cpl *cpl, int bserrno) 46 { 47 switch (cpl->type) { 48 case SPDK_BS_CPL_TYPE_BS_BASIC: 49 cpl->u.bs_basic.cb_fn(cpl->u.bs_basic.cb_arg, 50 bserrno); 51 break; 52 case SPDK_BS_CPL_TYPE_BS_HANDLE: 53 cpl->u.bs_handle.cb_fn(cpl->u.bs_handle.cb_arg, 54 cpl->u.bs_handle.bs, 55 bserrno); 56 break; 57 case SPDK_BS_CPL_TYPE_BLOB_BASIC: 58 cpl->u.blob_basic.cb_fn(cpl->u.blob_basic.cb_arg, 59 bserrno); 60 break; 61 case SPDK_BS_CPL_TYPE_BLOBID: 62 cpl->u.blobid.cb_fn(cpl->u.blobid.cb_arg, 63 cpl->u.blobid.blobid, 64 bserrno); 65 break; 66 case SPDK_BS_CPL_TYPE_BLOB_HANDLE: 67 cpl->u.blob_handle.cb_fn(cpl->u.blob_handle.cb_arg, 68 cpl->u.blob_handle.blob, 69 bserrno); 70 break; 71 case SPDK_BS_CPL_TYPE_NESTED_SEQUENCE: 72 cpl->u.nested_seq.cb_fn(cpl->u.nested_seq.cb_arg, 73 cpl->u.nested_seq.parent, 74 bserrno); 75 break; 76 case SPDK_BS_CPL_TYPE_NONE: 77 /* this completion's callback is handled elsewhere */ 78 break; 79 } 80 } 81 82 static void 83 spdk_bs_request_set_complete(struct spdk_bs_request_set *set) 84 { 85 struct spdk_bs_cpl cpl = set->cpl; 86 int bserrno = set->bserrno; 87 88 TAILQ_INSERT_TAIL(&set->channel->reqs, set, link); 89 90 spdk_bs_call_cpl(&cpl, bserrno); 91 } 92 93 static void 94 spdk_bs_sequence_completion(struct spdk_io_channel *channel, void *cb_arg, int bserrno) 95 { 96 struct spdk_bs_request_set *set = cb_arg; 97 98 set->bserrno = bserrno; 99 set->u.sequence.cb_fn((spdk_bs_sequence_t *)set, set->u.sequence.cb_arg, bserrno); 100 } 101 102 spdk_bs_sequence_t * 103 spdk_bs_sequence_start(struct spdk_io_channel *_channel, 104 struct spdk_bs_cpl *cpl) 105 { 106 struct spdk_bs_channel *channel; 107 struct spdk_bs_request_set *set; 108 109 channel = spdk_io_channel_get_ctx(_channel); 110 111 set = TAILQ_FIRST(&channel->reqs); 112 if (!set) { 113 return NULL; 114 } 115 TAILQ_REMOVE(&channel->reqs, set, link); 116 117 set->cpl = *cpl; 118 set->bserrno = 0; 119 set->channel = channel; 120 121 set->cb_args.cb_fn = spdk_bs_sequence_completion; 122 set->cb_args.cb_arg = set; 123 set->cb_args.channel = channel->dev_channel; 124 125 return (spdk_bs_sequence_t *)set; 126 } 127 128 void 129 spdk_bs_sequence_read_bs_dev(spdk_bs_sequence_t *seq, struct spdk_bs_dev *bs_dev, 130 void *payload, uint64_t lba, uint32_t lba_count, 131 spdk_bs_sequence_cpl cb_fn, void *cb_arg) 132 { 133 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)seq; 134 struct spdk_bs_channel *channel = set->channel; 135 136 SPDK_DEBUGLOG(SPDK_LOG_BLOB_RW, "Reading %u blocks from LBA %lu\n", lba_count, lba); 137 138 set->u.sequence.cb_fn = cb_fn; 139 set->u.sequence.cb_arg = cb_arg; 140 141 bs_dev->read(bs_dev, spdk_io_channel_from_ctx(channel), payload, lba, lba_count, &set->cb_args); 142 } 143 144 void 145 spdk_bs_sequence_read_dev(spdk_bs_sequence_t *seq, void *payload, 146 uint64_t lba, uint32_t lba_count, 147 spdk_bs_sequence_cpl cb_fn, void *cb_arg) 148 { 149 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)seq; 150 struct spdk_bs_channel *channel = set->channel; 151 152 set->u.sequence.cb_fn = cb_fn; 153 set->u.sequence.cb_arg = cb_arg; 154 155 channel->dev->read(channel->dev, channel->dev_channel, payload, lba, lba_count, &set->cb_args); 156 } 157 158 void 159 spdk_bs_sequence_write_dev(spdk_bs_sequence_t *seq, void *payload, 160 uint64_t lba, uint32_t lba_count, 161 spdk_bs_sequence_cpl cb_fn, void *cb_arg) 162 { 163 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)seq; 164 struct spdk_bs_channel *channel = set->channel; 165 166 SPDK_DEBUGLOG(SPDK_LOG_BLOB_RW, "Writing %u blocks to LBA %lu\n", lba_count, lba); 167 168 set->u.sequence.cb_fn = cb_fn; 169 set->u.sequence.cb_arg = cb_arg; 170 171 channel->dev->write(channel->dev, channel->dev_channel, payload, lba, lba_count, 172 &set->cb_args); 173 } 174 175 void 176 spdk_bs_sequence_readv_bs_dev(spdk_bs_sequence_t *seq, struct spdk_bs_dev *bs_dev, 177 struct iovec *iov, int iovcnt, uint64_t lba, uint32_t lba_count, 178 spdk_bs_sequence_cpl cb_fn, void *cb_arg) 179 { 180 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)seq; 181 struct spdk_bs_channel *channel = set->channel; 182 183 SPDK_DEBUGLOG(SPDK_LOG_BLOB_RW, "Reading %u blocks from LBA %lu\n", lba_count, lba); 184 185 set->u.sequence.cb_fn = cb_fn; 186 set->u.sequence.cb_arg = cb_arg; 187 188 bs_dev->readv(bs_dev, spdk_io_channel_from_ctx(channel), iov, iovcnt, lba, lba_count, 189 &set->cb_args); 190 } 191 192 void 193 spdk_bs_sequence_readv_dev(spdk_bs_sequence_t *seq, struct iovec *iov, int iovcnt, 194 uint64_t lba, uint32_t lba_count, spdk_bs_sequence_cpl cb_fn, void *cb_arg) 195 { 196 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)seq; 197 struct spdk_bs_channel *channel = set->channel; 198 199 set->u.sequence.cb_fn = cb_fn; 200 set->u.sequence.cb_arg = cb_arg; 201 channel->dev->readv(channel->dev, channel->dev_channel, iov, iovcnt, lba, lba_count, 202 &set->cb_args); 203 } 204 205 void 206 spdk_bs_sequence_writev_dev(spdk_bs_sequence_t *seq, struct iovec *iov, int iovcnt, 207 uint64_t lba, uint32_t lba_count, 208 spdk_bs_sequence_cpl cb_fn, void *cb_arg) 209 { 210 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)seq; 211 struct spdk_bs_channel *channel = set->channel; 212 213 SPDK_DEBUGLOG(SPDK_LOG_BLOB_RW, "Writing %u blocks to LBA %lu\n", lba_count, lba); 214 215 set->u.sequence.cb_fn = cb_fn; 216 set->u.sequence.cb_arg = cb_arg; 217 218 channel->dev->writev(channel->dev, channel->dev_channel, iov, iovcnt, lba, lba_count, 219 &set->cb_args); 220 } 221 222 void 223 spdk_bs_sequence_unmap_dev(spdk_bs_sequence_t *seq, 224 uint64_t lba, uint32_t lba_count, 225 spdk_bs_sequence_cpl cb_fn, void *cb_arg) 226 { 227 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)seq; 228 struct spdk_bs_channel *channel = set->channel; 229 230 SPDK_DEBUGLOG(SPDK_LOG_BLOB_RW, "Unmapping %u blocks at LBA %lu\n", lba_count, lba); 231 232 set->u.sequence.cb_fn = cb_fn; 233 set->u.sequence.cb_arg = cb_arg; 234 235 channel->dev->unmap(channel->dev, channel->dev_channel, lba, lba_count, 236 &set->cb_args); 237 } 238 239 void 240 spdk_bs_sequence_write_zeroes_dev(spdk_bs_sequence_t *seq, 241 uint64_t lba, uint32_t lba_count, 242 spdk_bs_sequence_cpl cb_fn, void *cb_arg) 243 { 244 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)seq; 245 struct spdk_bs_channel *channel = set->channel; 246 247 SPDK_DEBUGLOG(SPDK_LOG_BLOB_RW, "writing zeroes to %u blocks at LBA %lu\n", lba_count, lba); 248 249 set->u.sequence.cb_fn = cb_fn; 250 set->u.sequence.cb_arg = cb_arg; 251 252 channel->dev->write_zeroes(channel->dev, channel->dev_channel, lba, lba_count, 253 &set->cb_args); 254 } 255 256 void 257 spdk_bs_sequence_finish(spdk_bs_sequence_t *seq, int bserrno) 258 { 259 if (bserrno != 0) { 260 seq->bserrno = bserrno; 261 } 262 spdk_bs_request_set_complete((struct spdk_bs_request_set *)seq); 263 } 264 265 void 266 spdk_bs_user_op_sequence_finish(void *cb_arg, int bserrno) 267 { 268 spdk_bs_sequence_t *seq = cb_arg; 269 270 spdk_bs_sequence_finish(seq, bserrno); 271 } 272 273 static void 274 spdk_bs_batch_completion(struct spdk_io_channel *_channel, 275 void *cb_arg, int bserrno) 276 { 277 struct spdk_bs_request_set *set = cb_arg; 278 279 set->u.batch.outstanding_ops--; 280 if (bserrno != 0) { 281 set->bserrno = bserrno; 282 } 283 284 if (set->u.batch.outstanding_ops == 0 && set->u.batch.batch_closed) { 285 if (set->u.batch.cb_fn) { 286 set->cb_args.cb_fn = spdk_bs_sequence_completion; 287 set->u.batch.cb_fn((spdk_bs_sequence_t *)set, set->u.batch.cb_arg, bserrno); 288 } else { 289 spdk_bs_request_set_complete(set); 290 } 291 } 292 } 293 294 spdk_bs_batch_t * 295 spdk_bs_batch_open(struct spdk_io_channel *_channel, 296 struct spdk_bs_cpl *cpl) 297 { 298 struct spdk_bs_channel *channel; 299 struct spdk_bs_request_set *set; 300 301 channel = spdk_io_channel_get_ctx(_channel); 302 303 set = TAILQ_FIRST(&channel->reqs); 304 if (!set) { 305 return NULL; 306 } 307 TAILQ_REMOVE(&channel->reqs, set, link); 308 309 set->cpl = *cpl; 310 set->bserrno = 0; 311 set->channel = channel; 312 313 set->u.batch.cb_fn = NULL; 314 set->u.batch.cb_arg = NULL; 315 set->u.batch.outstanding_ops = 0; 316 set->u.batch.batch_closed = 0; 317 318 set->cb_args.cb_fn = spdk_bs_batch_completion; 319 set->cb_args.cb_arg = set; 320 set->cb_args.channel = channel->dev_channel; 321 322 return (spdk_bs_batch_t *)set; 323 } 324 325 void 326 spdk_bs_batch_read_bs_dev(spdk_bs_batch_t *batch, struct spdk_bs_dev *bs_dev, 327 void *payload, uint64_t lba, uint32_t lba_count) 328 { 329 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)batch; 330 struct spdk_bs_channel *channel = set->channel; 331 332 SPDK_DEBUGLOG(SPDK_LOG_BLOB_RW, "Reading %u blocks from LBA %lu\n", lba_count, lba); 333 334 set->u.batch.outstanding_ops++; 335 bs_dev->read(bs_dev, spdk_io_channel_from_ctx(channel), payload, lba, lba_count, &set->cb_args); 336 } 337 338 void 339 spdk_bs_batch_read_dev(spdk_bs_batch_t *batch, void *payload, 340 uint64_t lba, uint32_t lba_count) 341 { 342 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)batch; 343 struct spdk_bs_channel *channel = set->channel; 344 345 set->u.batch.outstanding_ops++; 346 channel->dev->read(channel->dev, channel->dev_channel, payload, lba, lba_count, &set->cb_args); 347 } 348 349 void 350 spdk_bs_batch_write_dev(spdk_bs_batch_t *batch, void *payload, 351 uint64_t lba, uint32_t lba_count) 352 { 353 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)batch; 354 struct spdk_bs_channel *channel = set->channel; 355 356 SPDK_DEBUGLOG(SPDK_LOG_BLOB_RW, "Writing %u blocks to LBA %lu\n", lba_count, lba); 357 358 set->u.batch.outstanding_ops++; 359 channel->dev->write(channel->dev, channel->dev_channel, payload, lba, lba_count, 360 &set->cb_args); 361 } 362 363 void 364 spdk_bs_batch_unmap_dev(spdk_bs_batch_t *batch, 365 uint64_t lba, uint32_t lba_count) 366 { 367 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)batch; 368 struct spdk_bs_channel *channel = set->channel; 369 370 SPDK_DEBUGLOG(SPDK_LOG_BLOB_RW, "Unmapping %u blocks at LBA %lu\n", lba_count, lba); 371 372 set->u.batch.outstanding_ops++; 373 channel->dev->unmap(channel->dev, channel->dev_channel, lba, lba_count, 374 &set->cb_args); 375 } 376 377 void 378 spdk_bs_batch_write_zeroes_dev(spdk_bs_batch_t *batch, 379 uint64_t lba, uint32_t lba_count) 380 { 381 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)batch; 382 struct spdk_bs_channel *channel = set->channel; 383 384 SPDK_DEBUGLOG(SPDK_LOG_BLOB_RW, "Zeroing %u blocks at LBA %lu\n", lba_count, lba); 385 386 set->u.batch.outstanding_ops++; 387 channel->dev->write_zeroes(channel->dev, channel->dev_channel, lba, lba_count, 388 &set->cb_args); 389 } 390 391 static void 392 spdk_bs_batch_blob_op_complete(void *arg, int bserrno) 393 { 394 /* TODO: spdk_bs_batch_completion does not actually use the channel parameter - 395 * just pass NULL here instead of getting the channel from the set cb_arg. 396 */ 397 spdk_bs_batch_completion(NULL, arg, bserrno); 398 } 399 400 void 401 spdk_bs_batch_read_blob(spdk_bs_batch_t *batch, struct spdk_blob *blob, 402 void *payload, uint64_t offset, uint64_t length) 403 { 404 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)batch; 405 struct spdk_bs_channel *channel = set->channel; 406 407 SPDK_DEBUGLOG(SPDK_LOG_BLOB_RW, "Reading %lu pages from offset %lu\n", length, offset); 408 409 set->u.batch.outstanding_ops++; 410 spdk_blob_io_read(blob, spdk_io_channel_from_ctx(channel), payload, offset, 411 length, spdk_bs_batch_blob_op_complete, set); 412 } 413 414 void 415 spdk_bs_batch_write_blob(spdk_bs_batch_t *batch, struct spdk_blob *blob, 416 void *payload, uint64_t offset, uint64_t length) 417 { 418 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)batch; 419 struct spdk_bs_channel *channel = set->channel; 420 421 SPDK_DEBUGLOG(SPDK_LOG_BLOB_RW, "Writing %lu pages from offset %lu\n", length, offset); 422 423 set->u.batch.outstanding_ops++; 424 spdk_blob_io_write(blob, spdk_io_channel_from_ctx(channel), payload, offset, 425 length, spdk_bs_batch_blob_op_complete, set); 426 } 427 428 void 429 spdk_bs_batch_unmap_blob(spdk_bs_batch_t *batch, struct spdk_blob *blob, 430 uint64_t offset, uint64_t length) 431 { 432 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)batch; 433 struct spdk_bs_channel *channel = set->channel; 434 435 SPDK_DEBUGLOG(SPDK_LOG_BLOB_RW, "Unmapping %lu pages from offset %lu\n", length, offset); 436 437 set->u.batch.outstanding_ops++; 438 spdk_blob_io_unmap(blob, spdk_io_channel_from_ctx(channel), offset, length, 439 spdk_bs_batch_blob_op_complete, set); 440 } 441 442 void 443 spdk_bs_batch_write_zeroes_blob(spdk_bs_batch_t *batch, struct spdk_blob *blob, 444 uint64_t offset, uint64_t length) 445 { 446 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)batch; 447 struct spdk_bs_channel *channel = set->channel; 448 449 SPDK_DEBUGLOG(SPDK_LOG_BLOB_RW, "Zeroing %lu pages from offset %lu\n", length, offset); 450 451 set->u.batch.outstanding_ops++; 452 spdk_blob_io_write_zeroes(blob, spdk_io_channel_from_ctx(channel), offset, length, 453 spdk_bs_batch_blob_op_complete, set); 454 } 455 456 void 457 spdk_bs_batch_set_errno(spdk_bs_batch_t *batch, int bserrno) 458 { 459 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)batch; 460 461 set->bserrno = bserrno; 462 } 463 464 void 465 spdk_bs_batch_close(spdk_bs_batch_t *batch) 466 { 467 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)batch; 468 469 set->u.batch.batch_closed = 1; 470 471 if (set->u.batch.outstanding_ops == 0) { 472 if (set->u.batch.cb_fn) { 473 set->cb_args.cb_fn = spdk_bs_sequence_completion; 474 set->u.batch.cb_fn((spdk_bs_sequence_t *)set, set->u.batch.cb_arg, set->bserrno); 475 } else { 476 spdk_bs_request_set_complete(set); 477 } 478 } 479 } 480 481 spdk_bs_batch_t * 482 spdk_bs_sequence_to_batch(spdk_bs_sequence_t *seq, spdk_bs_sequence_cpl cb_fn, void *cb_arg) 483 { 484 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)seq; 485 486 set->u.batch.cb_fn = cb_fn; 487 set->u.batch.cb_arg = cb_arg; 488 set->u.batch.outstanding_ops = 0; 489 set->u.batch.batch_closed = 0; 490 491 set->cb_args.cb_fn = spdk_bs_batch_completion; 492 493 return set; 494 } 495 496 spdk_bs_sequence_t * 497 spdk_bs_batch_to_sequence(spdk_bs_batch_t *batch) 498 { 499 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)batch; 500 501 set->u.batch.outstanding_ops++; 502 503 set->cpl.type = SPDK_BS_CPL_TYPE_BLOB_BASIC; 504 set->cpl.u.blob_basic.cb_fn = spdk_bs_sequence_to_batch_completion; 505 set->cpl.u.blob_basic.cb_arg = set; 506 set->bserrno = 0; 507 508 set->cb_args.cb_fn = spdk_bs_sequence_completion; 509 set->cb_args.cb_arg = set; 510 set->cb_args.channel = set->channel->dev_channel; 511 512 return (spdk_bs_sequence_t *)set; 513 } 514 515 spdk_bs_user_op_t * 516 spdk_bs_user_op_alloc(struct spdk_io_channel *_channel, struct spdk_bs_cpl *cpl, 517 enum spdk_blob_op_type op_type, struct spdk_blob *blob, 518 void *payload, int iovcnt, uint64_t offset, uint64_t length) 519 { 520 struct spdk_bs_channel *channel; 521 struct spdk_bs_request_set *set; 522 struct spdk_bs_user_op_args *args; 523 524 channel = spdk_io_channel_get_ctx(_channel); 525 526 set = TAILQ_FIRST(&channel->reqs); 527 if (!set) { 528 return NULL; 529 } 530 TAILQ_REMOVE(&channel->reqs, set, link); 531 532 set->cpl = *cpl; 533 set->channel = channel; 534 535 args = &set->u.user_op; 536 537 args->type = op_type; 538 args->iovcnt = iovcnt; 539 args->blob = blob; 540 args->offset = offset; 541 args->length = length; 542 args->payload = payload; 543 544 return (spdk_bs_user_op_t *)set; 545 } 546 547 void 548 spdk_bs_user_op_execute(spdk_bs_user_op_t *op) 549 { 550 struct spdk_bs_request_set *set; 551 struct spdk_bs_user_op_args *args; 552 struct spdk_io_channel *ch; 553 554 set = (struct spdk_bs_request_set *)op; 555 args = &set->u.user_op; 556 ch = spdk_io_channel_from_ctx(set->channel); 557 558 switch (args->type) { 559 case SPDK_BLOB_READ: 560 spdk_blob_io_read(args->blob, ch, args->payload, args->offset, args->length, 561 set->cpl.u.blob_basic.cb_fn, set->cpl.u.blob_basic.cb_arg); 562 break; 563 case SPDK_BLOB_WRITE: 564 spdk_blob_io_write(args->blob, ch, args->payload, args->offset, args->length, 565 set->cpl.u.blob_basic.cb_fn, set->cpl.u.blob_basic.cb_arg); 566 break; 567 case SPDK_BLOB_UNMAP: 568 spdk_blob_io_unmap(args->blob, ch, args->offset, args->length, 569 set->cpl.u.blob_basic.cb_fn, set->cpl.u.blob_basic.cb_arg); 570 break; 571 case SPDK_BLOB_WRITE_ZEROES: 572 spdk_blob_io_write_zeroes(args->blob, ch, args->offset, args->length, 573 set->cpl.u.blob_basic.cb_fn, set->cpl.u.blob_basic.cb_arg); 574 break; 575 case SPDK_BLOB_READV: 576 spdk_blob_io_readv(args->blob, ch, args->payload, args->iovcnt, 577 args->offset, args->length, 578 set->cpl.u.blob_basic.cb_fn, set->cpl.u.blob_basic.cb_arg); 579 break; 580 case SPDK_BLOB_WRITEV: 581 spdk_blob_io_writev(args->blob, ch, args->payload, args->iovcnt, 582 args->offset, args->length, 583 set->cpl.u.blob_basic.cb_fn, set->cpl.u.blob_basic.cb_arg); 584 break; 585 } 586 TAILQ_INSERT_TAIL(&set->channel->reqs, set, link); 587 } 588 589 void 590 spdk_bs_user_op_abort(spdk_bs_user_op_t *op) 591 { 592 struct spdk_bs_request_set *set; 593 594 set = (struct spdk_bs_request_set *)op; 595 596 set->cpl.u.blob_basic.cb_fn(set->cpl.u.blob_basic.cb_arg, -EIO); 597 TAILQ_INSERT_TAIL(&set->channel->reqs, set, link); 598 } 599 600 void 601 spdk_bs_sequence_to_batch_completion(void *cb_arg, int bserrno) 602 { 603 struct spdk_bs_request_set *set = (struct spdk_bs_request_set *)cb_arg; 604 605 set->u.batch.outstanding_ops--; 606 607 if (set->u.batch.outstanding_ops == 0 && set->u.batch.batch_closed) { 608 if (set->cb_args.cb_fn) { 609 set->cb_args.cb_fn(set->cb_args.channel, set->cb_args.cb_arg, bserrno); 610 } 611 } 612 } 613 614 SPDK_LOG_REGISTER_COMPONENT("blob_rw", SPDK_LOG_BLOB_RW) 615