From 0cf7566b9380fbc423c54db69fbedec792595ba6 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 19 Feb 2009 19:06:13 +0000 Subject: [PATCH] Patch from Krzysztof Blaszkowski with some cleanups: I realized yesterday that the fix missed one rare case still. if the hiwmk_check() returned with error and no_fail override was set then the counter would still cross 0 on free. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@677 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_mem.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scst/src/scst_mem.c b/scst/src/scst_mem.c index 445edc45d..05383b26d 100644 --- a/scst/src/scst_mem.c +++ b/scst/src/scst_mem.c @@ -899,7 +899,14 @@ struct scatterlist *scst_alloc(int size, gfp_t gfp_mask, int *count) if (!no_fail) { res = NULL; goto out; - } + } else { + /* + * Update active_pages_total since alloc can't fail. + * If it wasn't updated then the counter would cross 0 + * on free again. + */ + sgv_pool_hiwmk_uncheck(-pages); + } } res = kmalloc(pages*sizeof(*res), gfp_mask); @@ -1007,7 +1014,6 @@ int sgv_pool_init(struct sgv_pool *pool, const char *name, sizeof(obj->trans_tbl[0]) : 0)); } else { size = sizeof(*obj); - /* both sgv and ttbl are kallocated() */ }