Commit 7a783b5b authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

iscsi: Factor out getting data buffer from mempool into helper function



Wrap an operation to get a data buffer from mempool into a helper
function iscsi_datapool_get() and wrap an operation to put a data
buffer to mempool into a helper function iscsi_data_pool_put().

Use inline for both functions.

Besides, as a minor fix, remove duplicated file inclusion between
iscsi.c and iscsi.h.
7

Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ia3005dffaa93a6bca16f19bb467fb5b64ae1aad2
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6366


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarsunshihao <sunshihao@huawei.com>
Reviewed-by: default avatarZiye Yang <ziye.yang@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 3de09f8e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4574,7 +4574,7 @@ iscsi_pdu_payload_read(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
				    data_len, SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH);
			return -1;
		}
		pdu->mobj = spdk_mempool_get(pool);
		pdu->mobj = iscsi_datapool_get(pool);
		if (pdu->mobj == NULL) {
			return 1;
		}
+15 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@
#define SPDK_ISCSI_H

#include "spdk/stdinc.h"

#include "spdk/env.h"
#include "spdk/bdev.h"
#include "spdk/iscsi_spec.h"
#include "spdk/thread.h"
@@ -454,6 +454,20 @@ void iscsi_op_abort_task_set(struct spdk_iscsi_task *task,
			     uint8_t function);
void iscsi_queue_task(struct spdk_iscsi_conn *conn, struct spdk_iscsi_task *task);

static inline struct spdk_mobj *
iscsi_datapool_get(struct spdk_mempool *pool)
{
	return spdk_mempool_get(pool);
}

static inline void
iscsi_datapool_put(struct spdk_mobj *mobj)
{
	assert(mobj != NULL);

	spdk_mempool_put(mobj->mp, (void *)mobj);
}

static inline uint32_t
iscsi_get_max_immediate_data_size(void)
{
+2 −4
Original line number Diff line number Diff line
@@ -32,10 +32,7 @@
 *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "spdk/stdinc.h"
#include "spdk/env.h"
#include "spdk/string.h"
#include "spdk/sock.h"
#include "spdk/likely.h"

#include "iscsi/iscsi.h"
@@ -233,8 +230,9 @@ void iscsi_put_pdu(struct spdk_iscsi_pdu *pdu)
	pdu->ref--;

	if (pdu->ref == 0) {

		if (pdu->mobj) {
			spdk_mempool_put(pdu->mobj->mp, (void *)pdu->mobj);
			iscsi_datapool_put(pdu->mobj);
		}

		if (pdu->data && !pdu->data_from_mempool) {