scoutfs: add block visited bit

Add functions for callers to maintain a visited bit in cached blocks.
The radix allocator is going to use this to count the number of clean
blocks it sees across paths through the radix which can share parent
blocks.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2020-02-25 12:03:46 -08:00
committed by Zach Brown
parent 10fd4fcec0
commit 05a8573054
2 changed files with 21 additions and 0 deletions
+17
View File
@@ -67,6 +67,7 @@ enum {
BLOCK_BIT_PAGE_ALLOC, /* page (possibly high order) allocation */
BLOCK_BIT_VIRT, /* mapped virt allocation */
BLOCK_BIT_CRC_VALID, /* crc has been verified */
BLOCK_BIT_VISITED, /* used by callers to track blocks */
};
struct block_private {
@@ -128,6 +129,22 @@ bool scoutfs_block_valid_ref(struct super_block *sb,
hdr->blkno == blkno;
}
bool scoutfs_block_tas_visited(struct super_block *sb,
struct scoutfs_block *bl)
{
struct block_private *bp = BLOCK_PRIVATE(bl);
return test_bit(BLOCK_BIT_VISITED, &bp->bits) != 0;
}
void scoutfs_block_clear_visited(struct super_block *sb,
struct scoutfs_block *bl)
{
struct block_private *bp = BLOCK_PRIVATE(bl);
clear_bit(BLOCK_BIT_VISITED, &bp->bits);
}
static struct block_private *block_alloc(struct super_block *sb, u64 blkno)
{
struct block_private *bp;
+4
View File
@@ -17,6 +17,10 @@ bool scoutfs_block_valid_crc(struct scoutfs_block_header *hdr);
bool scoutfs_block_valid_ref(struct super_block *sb,
struct scoutfs_block_header *hdr,
__le64 seq, __le64 blkno);
bool scoutfs_block_tas_visited(struct super_block *sb,
struct scoutfs_block *bl);
void scoutfs_block_clear_visited(struct super_block *sb,
struct scoutfs_block *bl);
struct scoutfs_block *scoutfs_block_create(struct super_block *sb, u64 blkno);
struct scoutfs_block *scoutfs_block_read(struct super_block *sb, u64 blkno);