LCOV - code coverage report
Current view: top level - lib/iscsi - task.c (source / functions) Hit Total Coverage
Test: ut_cov_unit.info Lines: 0 44 0.0 %
Date: 2024-11-05 10:06:02 Functions: 0 2 0.0 %

          Line data    Source code
       1             : /*   SPDX-License-Identifier: BSD-3-Clause
       2             :  *   Copyright (C) 2008-2012 Daisuke Aoyama <aoyama@peach.ne.jp>.
       3             :  *   Copyright (C) 2016 Intel Corporation.
       4             :  *   All rights reserved.
       5             :  */
       6             : 
       7             : #include "spdk/env.h"
       8             : #include "spdk/log.h"
       9             : #include "iscsi/conn.h"
      10             : #include "iscsi/task.h"
      11             : #include "iscsi/tgt_node.h"
      12             : 
      13             : static void
      14           0 : iscsi_task_free(struct spdk_scsi_task *scsi_task)
      15             : {
      16             :         uint64_t tsc_diff;
      17           0 :         struct spdk_iscsi_task *task = iscsi_task_from_scsi_task(scsi_task);
      18             : 
      19           0 :         if (task->conn->target->histogram) {
      20           0 :                 tsc_diff = spdk_get_ticks() - task->start_tsc;
      21           0 :                 spdk_histogram_data_tally(task->conn->target->histogram, tsc_diff);
      22             :         }
      23             : 
      24           0 :         if (task->parent) {
      25           0 :                 if (task->scsi.dxfer_dir == SPDK_SCSI_DIR_FROM_DEV) {
      26           0 :                         assert(task->conn->data_in_cnt > 0);
      27           0 :                         task->conn->data_in_cnt--;
      28             :                 }
      29             : 
      30           0 :                 spdk_scsi_task_put(&task->parent->scsi);
      31           0 :                 task->parent = NULL;
      32             :         }
      33             : 
      34           0 :         if (iscsi_task_get_mobj(task)) {
      35           0 :                 iscsi_datapool_put(iscsi_task_get_mobj(task));
      36             :         }
      37             : 
      38           0 :         iscsi_task_disassociate_pdu(task);
      39           0 :         assert(task->conn->pending_task_cnt > 0);
      40           0 :         task->conn->pending_task_cnt--;
      41           0 :         spdk_mempool_put(g_iscsi.task_pool, (void *)task);
      42           0 : }
      43             : 
      44             : struct spdk_iscsi_task *
      45           0 : iscsi_task_get(struct spdk_iscsi_conn *conn, struct spdk_iscsi_task *parent,
      46             :                spdk_scsi_task_cpl cpl_fn)
      47             : {
      48             :         struct spdk_iscsi_task *task;
      49             : 
      50           0 :         task = spdk_mempool_get(g_iscsi.task_pool);
      51           0 :         if (!task) {
      52           0 :                 SPDK_ERRLOG("Unable to get task\n");
      53           0 :                 abort();
      54             :         }
      55             : 
      56           0 :         assert(conn != NULL);
      57           0 :         memset(task, 0, sizeof(*task));
      58           0 :         task->start_tsc = spdk_get_ticks();
      59           0 :         task->conn = conn;
      60           0 :         assert(conn->pending_task_cnt < UINT32_MAX);
      61           0 :         conn->pending_task_cnt++;
      62           0 :         spdk_scsi_task_construct(&task->scsi,
      63             :                                  cpl_fn,
      64             :                                  iscsi_task_free);
      65           0 :         if (parent) {
      66           0 :                 parent->scsi.ref++;
      67           0 :                 task->parent = parent;
      68           0 :                 task->tag = parent->tag;
      69           0 :                 task->lun_id = parent->lun_id;
      70           0 :                 task->scsi.dxfer_dir = parent->scsi.dxfer_dir;
      71           0 :                 task->scsi.transfer_len = parent->scsi.transfer_len;
      72           0 :                 task->scsi.lun = parent->scsi.lun;
      73           0 :                 task->scsi.cdb = parent->scsi.cdb;
      74           0 :                 task->scsi.target_port = parent->scsi.target_port;
      75           0 :                 task->scsi.initiator_port = parent->scsi.initiator_port;
      76           0 :                 if (task->scsi.dxfer_dir == SPDK_SCSI_DIR_FROM_DEV) {
      77           0 :                         conn->data_in_cnt++;
      78             :                 }
      79             :         }
      80             : 
      81           0 :         return task;
      82             : }

Generated by: LCOV version 1.15