summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2021-01-05 17:43:26 -0800
committerDarrick J. Wong <djwong@kernel.org>2021-03-25 17:08:16 -0700
commit61364ad743fad20c0c95d1998b4e02cfc7afe805 (patch)
tree27625dd6195e538f6a516c034b13ccff38cefc64
parent2dac49c2b74226801c9136f31ac62ed9517297a4 (diff)
xfs: drop the _safe behavior from the xbitmap foreach macro
It's not safe to edit bitmap intervals while we're iterating them with for_each_xbitmap_extent. None of the existing callers actually need that ability anyway, so drop the safe variable. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
-rw-r--r--fs/xfs/scrub/bitmap.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/fs/xfs/scrub/bitmap.c b/fs/xfs/scrub/bitmap.c
index 304fcaf1037c..97b1e360a78f 100644
--- a/fs/xfs/scrub/bitmap.c
+++ b/fs/xfs/scrub/bitmap.c
@@ -12,8 +12,9 @@
#include "xfs_btree.h"
#include "scrub/bitmap.h"
-#define for_each_xbitmap_extent(bex, n, bitmap) \
- list_for_each_entry_safe((bex), (n), &(bitmap)->list, list)
+/* Iterate each interval of a bitmap. Do not change the bitmap. */
+#define for_each_xbitmap_extent(bex, bitmap) \
+ list_for_each_entry((bex), &(bitmap)->list, list)
/*
* Set a range of this bitmap. Caller must ensure the range is not set.
@@ -45,10 +46,9 @@ void
xbitmap_destroy(
struct xbitmap *bitmap)
{
- struct xbitmap_range *bmr;
- struct xbitmap_range *n;
+ struct xbitmap_range *bmr, *n;
- for_each_xbitmap_extent(bmr, n, bitmap) {
+ list_for_each_entry_safe(bmr, n, &bitmap->list, list) {
list_del(&bmr->list);
kmem_free(bmr);
}
@@ -307,10 +307,9 @@ xbitmap_hweight(
struct xbitmap *bitmap)
{
struct xbitmap_range *bmr;
- struct xbitmap_range *n;
uint64_t ret = 0;
- for_each_xbitmap_extent(bmr, n, bitmap)
+ for_each_xbitmap_extent(bmr, bitmap)
ret += bmr->len;
return ret;
@@ -323,10 +322,10 @@ xbitmap_walk(
xbitmap_walk_fn fn,
void *priv)
{
- struct xbitmap_range *bex, *n;
+ struct xbitmap_range *bex;
int error = 0;
- for_each_xbitmap_extent(bex, n, bitmap) {
+ for_each_xbitmap_extent(bex, bitmap) {
error = fn(bex->start, bex->len, priv);
if (error)
break;