Skip to content

Commit 9343387

Browse files
committed
disk map refactoring changes
1 parent a032887 commit 9343387

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

src/blkcache/cache/through.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ def __init__(self, config):
2929
# WRONG: WE HAVE A FUNCTION TO DO THIS DON'T GUESS
3030
self.block_size = config.get("block_size") or DEFAULT_BLOCK_SIZE
3131
self.map_path = self.cache.with_suffix(f"{self.cache.suffix}.log")
32-
self.diskmap = DiskMap(self.map_path)
32+
33+
# Get device size for DiskMap
34+
device_size = get_device_size(self.device)
35+
self.diskmap = DiskMap(self.map_path, device_size)
3336

3437
# Initialize cache
3538
self._initialize()

src/blkcache/plugin.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
DEFAULT_BLOCK_SIZE,
1212
)
1313

14-
# Import Cache class
15-
from blkcache.cache.cache import Cache
14+
# Import BlockCache class
15+
from blkcache.cache.through import BlockCache
1616

1717
# Global state
1818
DEV: Path | None = None
@@ -57,9 +57,8 @@ def config_complete() -> None:
5757
raise RuntimeError("device= and cache= are required")
5858

5959
# Create a BlockCache instance
60-
CACHE_INSTANCE = BlockCache(
61-
device_path=DEV, cache_path=CACHE, block_size=BLOCK if BLOCK != DEFAULT_BLOCK_SIZE else None
62-
)
60+
config = {"device_path": DEV, "cache_path": CACHE, "block_size": BLOCK if BLOCK != DEFAULT_BLOCK_SIZE else None}
61+
CACHE_INSTANCE = BlockCache(config)
6362

6463
# The BlockCache initialization will handle:
6564
# - Loading the mapfile if it exists

tests/unit/test_blocksize.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def test_auto_detection_failure(mock_get_sector_size):
6464
assert error_msg in updates["block_size_source"]
6565

6666

67-
6867
def testdetermine_block_size_with_auto_detect():
6968
"""When auto-detection succeeds, the detected size should be used."""
7069
# We'll test the higher-level determine_block_size function instead

0 commit comments

Comments
 (0)