From: <vl...@us...> - 2007-09-25 09:21:11
|
Revision: 193 http://scst.svn.sourceforge.net/scst/?rev=193&view=rev Author: vlnb Date: 2007-09-25 02:20:30 -0700 (Tue, 25 Sep 2007) Log Message: ----------- - Patch from Krzysztof Blaszkowski <kb...@sy...>: 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. Modified Paths: -------------- trunk/iscsi-scst/kernel/iscsi.c trunk/scst/include/scsi_tgt.h trunk/scst/src/scst_mem.c Modified: trunk/iscsi-scst/kernel/iscsi.c =================================================================== --- trunk/iscsi-scst/kernel/iscsi.c 2007-09-25 09:17:16 UTC (rev 192) +++ trunk/iscsi-scst/kernel/iscsi.c 2007-09-25 09:20:30 UTC (rev 193) @@ -542,7 +542,7 @@ 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 @@ 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 @@ 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 @@ /* 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(); */ } Modified: trunk/scst/include/scsi_tgt.h =================================================================== --- trunk/scst/include/scsi_tgt.h 2007-09-25 09:17:16 UTC (rev 192) +++ trunk/scst/include/scsi_tgt.h 2007-09-25 09:20:30 UTC (rev 193) @@ -2339,12 +2339,10 @@ /* * 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); Modified: trunk/scst/src/scst_mem.c =================================================================== --- trunk/scst/src/scst_mem.c 2007-09-25 09:17:16 UTC (rev 192) +++ trunk/scst/src/scst_mem.c 2007-09-25 09:20:30 UTC (rev 193) @@ -735,8 +735,7 @@ 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 @@ 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; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |