diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index d66f3a6fc..53e96f4ab 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -886,6 +886,7 @@ go: res = 0; cmd->completed = 1; + cmd->resid_possible = 1; out: TRACE_EXIT_RES(res); @@ -957,6 +958,7 @@ go: res = 0; cmd->completed = 1; + cmd->resid_possible = 1; out: TRACE_EXIT_RES(res); diff --git a/scst/src/scst_mem.c b/scst/src/scst_mem.c index b0da819d9..45ce23bd5 100644 --- a/scst/src/scst_mem.c +++ b/scst/src/scst_mem.c @@ -1254,6 +1254,7 @@ struct scatterlist *scst_alloc(int size, gfp_t gfp_mask, int *count) struct sgv_pool_alloc_fns sys_alloc_fns = { sgv_alloc_sys_pages, sgv_free_sys_sg_entries }; int no_fail = ((gfp_mask & __GFP_NOFAIL) == __GFP_NOFAIL); + int cnt; TRACE_ENTRY(); @@ -1285,15 +1286,20 @@ struct scatterlist *scst_alloc(int size, gfp_t gfp_mask, int *count) /* * 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. + * So, let's always don't use clustering. */ - *count = sgv_alloc_sg_entries(res, pages, gfp_mask, sgv_no_clustering, + cnt = sgv_alloc_sg_entries(res, pages, gfp_mask, sgv_no_clustering, NULL, &sys_alloc_fns, NULL); - if (*count <= 0) + if (cnt <= 0) goto out_free; + if (size & ~PAGE_MASK) + res[cnt-1].length -= PAGE_SIZE - (size & ~PAGE_MASK); + + *count = cnt; + out: - TRACE_MEM("Alloced sg %p (count %d) \"no fail\" %d", res, *count, no_fail); + TRACE_MEM("Alloced sg %p (count %d, no_fail %d)", res, *count, no_fail); TRACE_EXIT_HRES(res); return res;