* [PATCH v2 2/4] libibverbs: Undo changes in memory range tree when madvise() fails
@ 2010-02-01 5:58 Alex Vainman
0 siblings, 0 replies; only message in thread
From: Alex Vainman @ 2010-02-01 5:58 UTC (permalink / raw)
To: roland, Roland Dreier, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
alexr-smomgflXvOZWk0Htik3J/w
ibv_madvise_range() doesn't cleanup if madvise() fails.
This patch comes to handle reference counter update on madvise() failure:
ibv_madvise_range() first updates memory range reference counter
and only then calls to madvise(). If madvise() fails, the reference counter
of the failed node is incorrect. This issue is fixed by updating node's
reference counter only after a successful call to madvise() or if no call to
madvise() was need since it was done in the past.
Signed-off-by: Alex Vainman <alexv-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
src/memory.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/memory.c b/src/memory.c
index 51839e2..6a3305f 100644
--- a/src/memory.c
+++ b/src/memory.c
@@ -521,10 +521,8 @@ static int ibv_madvise_range(void *base, size_t size, int advice)
}
}
- node->refcnt += inc;
-
- if ((inc == -1 && node->refcnt == 0) ||
- (inc == 1 && node->refcnt == 1)) {
+ if ((inc == -1 && node->refcnt == 1) ||
+ (inc == 1 && node->refcnt == 0)) {
/*
* If this is the first time through the loop,
* and we merged this node with the previous
@@ -547,6 +545,7 @@ static int ibv_madvise_range(void *base, size_t size, int advice)
goto out;
}
+ node->refcnt += inc;
node = __mm_next(node);
}
--
1.6.5.3
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2010-02-01 5:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-01 5:58 [PATCH v2 2/4] libibverbs: Undo changes in memory range tree when madvise() fails Alex Vainman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).