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: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: Ia3005dffaa93a6bca16f19bb467fb5b64ae1aad2 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6366 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: sunshihao <sunshihao@huawei.com> Reviewed-by: Ziye Yang <ziye.yang@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
3de09f8ece
commit
7a783b5b38
@ -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);
|
data_len, SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pdu->mobj = spdk_mempool_get(pool);
|
pdu->mobj = iscsi_datapool_get(pool);
|
||||||
if (pdu->mobj == NULL) {
|
if (pdu->mobj == NULL) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#define SPDK_ISCSI_H
|
#define SPDK_ISCSI_H
|
||||||
|
|
||||||
#include "spdk/stdinc.h"
|
#include "spdk/stdinc.h"
|
||||||
|
#include "spdk/env.h"
|
||||||
#include "spdk/bdev.h"
|
#include "spdk/bdev.h"
|
||||||
#include "spdk/iscsi_spec.h"
|
#include "spdk/iscsi_spec.h"
|
||||||
#include "spdk/thread.h"
|
#include "spdk/thread.h"
|
||||||
@ -454,6 +454,20 @@ void iscsi_op_abort_task_set(struct spdk_iscsi_task *task,
|
|||||||
uint8_t function);
|
uint8_t function);
|
||||||
void iscsi_queue_task(struct spdk_iscsi_conn *conn, struct spdk_iscsi_task *task);
|
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
|
static inline uint32_t
|
||||||
iscsi_get_max_immediate_data_size(void)
|
iscsi_get_max_immediate_data_size(void)
|
||||||
{
|
{
|
||||||
|
@ -32,10 +32,7 @@
|
|||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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/string.h"
|
||||||
#include "spdk/sock.h"
|
|
||||||
#include "spdk/likely.h"
|
#include "spdk/likely.h"
|
||||||
|
|
||||||
#include "iscsi/iscsi.h"
|
#include "iscsi/iscsi.h"
|
||||||
@ -233,8 +230,9 @@ void iscsi_put_pdu(struct spdk_iscsi_pdu *pdu)
|
|||||||
pdu->ref--;
|
pdu->ref--;
|
||||||
|
|
||||||
if (pdu->ref == 0) {
|
if (pdu->ref == 0) {
|
||||||
|
|
||||||
if (pdu->mobj) {
|
if (pdu->mobj) {
|
||||||
spdk_mempool_put(pdu->mobj->mp, (void *)pdu->mobj);
|
iscsi_datapool_put(pdu->mobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pdu->data && !pdu->data_from_mempool) {
|
if (pdu->data && !pdu->data_from_mempool) {
|
||||||
|
Loading…
Reference in New Issue
Block a user