diff --git a/iscsi-scst/kernel/iscsi.c b/iscsi-scst/kernel/iscsi.c index cfca321b8..4e10a5864 100644 --- a/iscsi-scst/kernel/iscsi.c +++ b/iscsi-scst/kernel/iscsi.c @@ -542,7 +542,7 @@ static struct iscsi_cmnd *create_status_rsp(struct iscsi_cmnd *req, int status, if (status == SAM_STAT_CHECK_CONDITION) { TRACE_DBG("%s", "CHECK_CONDITION"); /* ToDo: __GFP_NOFAIL ?? */ - sg = rsp->sg = scst_alloc(PAGE_SIZE, GFP_KERNEL|__GFP_NOFAIL, 0, + sg = rsp->sg = scst_alloc(PAGE_SIZE, GFP_KERNEL|__GFP_NOFAIL, &rsp->sg_cnt); if (sg == NULL) { /* ToDo(); */ @@ -601,7 +601,7 @@ static void iscsi_cmnd_reject(struct iscsi_cmnd *req, int reason) rsp_hdr->reason = reason; /* ToDo: __GFP_NOFAIL ?? */ - sg = rsp->sg = scst_alloc(PAGE_SIZE, GFP_KERNEL|__GFP_NOFAIL, 0, + sg = rsp->sg = scst_alloc(PAGE_SIZE, GFP_KERNEL|__GFP_NOFAIL, &rsp->sg_cnt); if (sg == NULL) { /* ToDo(); */ @@ -791,7 +791,7 @@ static void cmnd_prepare_skip_pdu(struct iscsi_cmnd *cmnd) if (sg == NULL) { /* ToDo: __GFP_NOFAIL ?? */ sg = cmnd->sg = scst_alloc(PAGE_SIZE, GFP_KERNEL|__GFP_NOFAIL, - 0, &cmnd->sg_cnt); + &cmnd->sg_cnt); if (sg == NULL) { /* ToDo(); */ } @@ -1061,7 +1061,7 @@ static int noop_out_start(struct iscsi_cmnd *cmnd) /* ToDo: __GFP_NOFAIL ?? */ cmnd->sg = sg = scst_alloc(size, - GFP_KERNEL|__GFP_NOFAIL, 0, &cmnd->sg_cnt); + GFP_KERNEL|__GFP_NOFAIL, &cmnd->sg_cnt); if (sg == NULL) { /* ToDo(); */ } diff --git a/scst/include/scsi_tgt.h b/scst/include/scsi_tgt.h index a77cf8571..b833e6d7b 100644 --- a/scst/include/scsi_tgt.h +++ b/scst/include/scsi_tgt.h @@ -2339,12 +2339,10 @@ void scst_put(void); /* * Allocates and returns pointer to SG vector with data size "size". - * If use_clustering is not 0, segments in the vector will be merged, - * when possible. In *count returned the count of entries in the vector. + * In *count returned the count of entries in the vector. * Returns NULL for failure. */ -struct scatterlist *scst_alloc(int size, unsigned long gfp_mask, - int use_clustering, int *count); +struct scatterlist *scst_alloc(int size, unsigned long gfp_mask, int *count); /* Frees SG vector returned by scst_alloc() */ void scst_free(struct scatterlist *sg, int count); diff --git a/scst/src/scst_mem.c b/scst/src/scst_mem.c index d4071ca8d..67bc9f8b8 100644 --- a/scst/src/scst_mem.c +++ b/scst/src/scst_mem.c @@ -735,8 +735,7 @@ void sgv_pool_free(struct sgv_pool_obj *sgv) return; } -struct scatterlist *scst_alloc(int size, unsigned long gfp_mask, - int use_clustering, int *count) +struct scatterlist *scst_alloc(int size, unsigned long gfp_mask, int *count) { struct scatterlist *res; int pages = (size >> PAGE_SHIFT) + ((size & ~PAGE_MASK) != 0); @@ -757,8 +756,13 @@ struct scatterlist *scst_alloc(int size, unsigned long gfp_mask, if (res == NULL) goto out; - *count = scst_alloc_sg_entries(res, pages, gfp_mask, use_clustering, - NULL, &sys_alloc_fns, NULL); + /* + * If we allow use clustering here, we will have troubles in + * scst_free() to figure out how many pages are in the SG vector. + * So, always don't use clustering. + */ + *count = scst_alloc_sg_entries(res, pages, gfp_mask, 0, NULL, + &sys_alloc_fns, NULL); if (*count <= 0) goto out_free;