From 05a8573054b3ef2047a2a19e2a5978c3b55e1b29 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Thu, 20 Feb 2020 13:41:03 -0800 Subject: [PATCH] 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 --- kmod/src/block.c | 17 +++++++++++++++++ kmod/src/block.h | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/kmod/src/block.c b/kmod/src/block.c index 18f3b37e..641d9c3d 100644 --- a/kmod/src/block.c +++ b/kmod/src/block.c @@ -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; diff --git a/kmod/src/block.h b/kmod/src/block.h index dbb0d54c..abcdd440 100644 --- a/kmod/src/block.h +++ b/kmod/src/block.h @@ -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);