- Patch from Krzysztof Blaszkowski <kb@sysmikro.com.pl>: fixes possible active_pages_total corruption in scst_free() if use_clustering was enabled in scst_alloc().

- Now scst_alloc() always doesn't use clustering. 


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@193 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2007-09-25 09:20:30 +00:00
parent d7dc51c031
commit 154a4eda43
3 changed files with 14 additions and 12 deletions

View File

@@ -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(); */
}

View File

@@ -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);

View File

@@ -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;