From: Christoph Hellwig <hch@lst.de>
To: Chandan Babu R <chandan.babu@oracle.com>,
"Darrick J. Wong" <djwong@kernel.org>
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 2/5] xfs: remove struct xfboff_bitmap
Date: Wed, 3 Jan 2024 21:38:33 +0100 [thread overview]
Message-ID: <20240103203836.608391-3-hch@lst.de> (raw)
In-Reply-To: <20240103203836.608391-1-hch@lst.de>
Just use struct xbitmap64 directly.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/scrub/xfbtree.c | 41 +++++------------------------------------
fs/xfs/scrub/xfbtree.h | 14 +++++---------
2 files changed, 10 insertions(+), 45 deletions(-)
diff --git a/fs/xfs/scrub/xfbtree.c b/fs/xfs/scrub/xfbtree.c
index 3620acc008aa59..63b69aeadc623d 100644
--- a/fs/xfs/scrub/xfbtree.c
+++ b/fs/xfs/scrub/xfbtree.c
@@ -24,37 +24,6 @@
#include "scrub/bitmap.h"
#include "scrub/trace.h"
-/* Bitmaps, but for type-checked for xfileoff_t */
-
-static inline void xfboff_bitmap_init(struct xfboff_bitmap *bitmap)
-{
- xbitmap64_init(&bitmap->xfoffbitmap);
-}
-
-static inline void xfboff_bitmap_destroy(struct xfboff_bitmap *bitmap)
-{
- xbitmap64_destroy(&bitmap->xfoffbitmap);
-}
-
-static inline int xfboff_bitmap_set(struct xfboff_bitmap *bitmap,
- xfs_fileoff_t start, xfs_filblks_t len)
-{
- return xbitmap64_set(&bitmap->xfoffbitmap, start, len);
-}
-
-static inline int xfboff_bitmap_take_first_set(struct xfboff_bitmap *bitmap,
- xfileoff_t *valp)
-{
- uint64_t val;
- int error;
-
- error = xbitmap64_take_first_set(&bitmap->xfoffbitmap, 0, -1ULL, &val);
- if (error)
- return error;
- *valp = val;
- return 0;
-}
-
/* Extract the buftarg target for this xfile btree. */
struct xfs_buftarg *
xfbtree_target(struct xfbtree *xfbtree)
@@ -295,7 +264,7 @@ void
xfbtree_destroy(
struct xfbtree *xfbt)
{
- xfboff_bitmap_destroy(&xfbt->freespace);
+ xbitmap64_destroy(&xfbt->freespace);
xfs_buftarg_drain(xfbt->target);
kfree(xfbt);
}
@@ -377,7 +346,7 @@ xfbtree_create(
if (cfg->flags & XFBTREE_DIRECT_MAP)
xfbt->target->bt_flags |= XFS_BUFTARG_DIRECT_MAP;
- xfboff_bitmap_init(&xfbt->freespace);
+ xbitmap64_init(&xfbt->freespace);
/* Set up min/maxrecs for this btree. */
if (cfg->btree_ops->geom_flags & XFS_BTREE_LONG_PTRS)
@@ -402,7 +371,7 @@ xfbtree_create(
return 0;
err_freesp:
- xfboff_bitmap_destroy(&xfbt->freespace);
+ xbitmap64_destroy(&xfbt->freespace);
xfs_buftarg_drain(xfbt->target);
kfree(xfbt);
return error;
@@ -432,7 +401,7 @@ xfbtree_alloc_block(
* Find the first free block in the free space bitmap and take it. If
* none are found, seek to end of the file.
*/
- error = xfboff_bitmap_take_first_set(&xfbt->freespace, &bt_xfoff);
+ error = xbitmap64_take_first_set(&xfbt->freespace, 0, -1ULL, &bt_xfoff);
if (error == -ENODATA) {
bt_xfoff = xfbt->highest_offset++;
error = 0;
@@ -479,7 +448,7 @@ xfbtree_free_block(
trace_xfbtree_free_block(xfbt, cur, bt_xfoff);
- return xfboff_bitmap_set(&xfbt->freespace, bt_xfoff, bt_xflen);
+ return xbitmap64_set(&xfbt->freespace, bt_xfoff, bt_xflen);
}
/* Return the minimum number of records for a btree block. */
diff --git a/fs/xfs/scrub/xfbtree.h b/fs/xfs/scrub/xfbtree.h
index e98f9261464a06..d17be23aca7dbb 100644
--- a/fs/xfs/scrub/xfbtree.h
+++ b/fs/xfs/scrub/xfbtree.h
@@ -12,24 +12,20 @@
/* xfile-backed in-memory btrees */
-struct xfboff_bitmap {
- struct xbitmap64 xfoffbitmap;
-};
-
struct xfbtree {
/* buffer cache target for the xfile backing this in-memory btree */
struct xfs_buftarg *target;
- /* Bitmap of free space from pos to used */
- struct xfboff_bitmap freespace;
+ /* Highest xfile offset that has been written to. */
+ xfileoff_t highest_offset;
+
+ /* Bitmap of free space from pos to highest_offset */
+ struct xbitmap64 freespace;
/* Fake header block information */
union xfs_btree_ptr root;
uint32_t nlevels;
- /* Highest xfile offset that has been written to. */
- xfileoff_t highest_offset;
-
/* Owner of this btree. */
unsigned long long owner;
--
2.39.2
next prev parent reply other threads:[~2024-01-03 20:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-03 20:38 RFC: in-memory btree simplifications Christoph Hellwig
2024-01-03 20:38 ` [PATCH 1/5] xfs: remove the in-memory btree header block Christoph Hellwig
2024-01-04 1:24 ` Darrick J. Wong
2024-01-04 6:27 ` Christoph Hellwig
2024-01-04 17:25 ` Darrick J. Wong
2024-01-03 20:38 ` Christoph Hellwig [this message]
2024-01-03 20:38 ` [PATCH 3/5] xfs: remove bc_ino.flags Christoph Hellwig
2024-01-04 1:10 ` Darrick J. Wong
2024-01-03 20:38 ` [PATCH 4/5] xfs: factor out a xfs_btree_owner helper Christoph Hellwig
2024-01-04 1:14 ` Darrick J. Wong
2024-01-04 6:28 ` Christoph Hellwig
2024-01-03 20:38 ` [PATCH 5/5] xfs: embedd struct xfbtree into the owning structure Christoph Hellwig
2024-01-04 1:21 ` Darrick J. Wong
2024-01-04 6:32 ` Christoph Hellwig
2024-01-04 7:14 ` Darrick J. Wong
2024-01-04 7:17 ` Christoph Hellwig
2024-01-04 7:22 ` Darrick J. Wong
2024-01-04 19:28 ` Darrick J. Wong
2024-01-05 4:27 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240103203836.608391-3-hch@lst.de \
--to=hch@lst.de \
--cc=chandan.babu@oracle.com \
--cc=djwong@kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).