From 16ecdb595b0b89c0e84fc233a501a98245e92161 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Thu, 17 Oct 2024 12:05:22 -0400 Subject: [PATCH] kernel: Drop base, length parameters from block_cache...etc methods. They were ignored and unused; and in fact can't be made to work properly since the block_cache always operates on exactly block-sized buffers, and doesn't have contiguous buffers of multiple blocks to hand out at all. No functional change intended. --- headers/os/drivers/fs_cache.h | 4 +-- .../kernel/file_systems/bfs/CachedBlock.h | 28 +++---------------- .../file_systems/fat/kernel_interface.cpp | 4 +-- .../kernel/file_systems/fat/support.cpp | 2 +- .../kernel/file_systems/udf/CachedBlock.h | 12 ++------ src/add-ons/kernel/file_systems/udf/Icb.cpp | 2 +- src/system/kernel/cache/block_cache.cpp | 22 +++++++-------- 7 files changed, 22 insertions(+), 52 deletions(-) diff --git a/headers/os/drivers/fs_cache.h b/headers/os/drivers/fs_cache.h index fce3ea9042..90d760c9fb 100644 --- a/headers/os/drivers/fs_cache.h +++ b/headers/os/drivers/fs_cache.h @@ -67,13 +67,13 @@ extern void block_cache_discard(void *cache, off_t blockNumber, extern status_t block_cache_make_writable(void *cache, off_t blockNumber, int32 transaction); extern status_t block_cache_get_writable_etc(void *cache, off_t blockNumber, - off_t base, off_t length, int32 transaction, void** _block); + int32 transaction, void** _block); extern void *block_cache_get_writable(void *cache, off_t blockNumber, int32 transaction); extern void *block_cache_get_empty(void *cache, off_t blockNumber, int32 transaction); extern status_t block_cache_get_etc(void *cache, off_t blockNumber, - off_t base, off_t length, const void** _block); + const void** _block); extern const void *block_cache_get(void *cache, off_t blockNumber); extern status_t block_cache_set_dirty(void *cache, off_t blockNumber, bool isDirty, int32 transaction); diff --git a/src/add-ons/kernel/file_systems/bfs/CachedBlock.h b/src/add-ons/kernel/file_systems/bfs/CachedBlock.h index 07e8e7bcb4..f13f1eeab4 100644 --- a/src/add-ons/kernel/file_systems/bfs/CachedBlock.h +++ b/src/add-ons/kernel/file_systems/bfs/CachedBlock.h @@ -30,12 +30,8 @@ public: inline void Keep(); inline void Unset(); - inline status_t SetTo(off_t block, off_t base, size_t length); inline status_t SetTo(off_t block); inline status_t SetTo(block_run run); - inline status_t SetToWritable(Transaction& transaction, - off_t block, off_t base, size_t length, - bool empty = false); inline status_t SetToWritable(Transaction& transaction, off_t block, bool empty = false); inline status_t SetToWritable(Transaction& transaction, @@ -111,19 +107,11 @@ CachedBlock::Unset() inline status_t -CachedBlock::SetTo(off_t block, off_t base, size_t length) +CachedBlock::SetTo(off_t block) { Unset(); fBlockNumber = block; - return block_cache_get_etc(fVolume->BlockCache(), block, base, length, - (const void**)&fBlock); -} - - -inline status_t -CachedBlock::SetTo(off_t block) -{ - return SetTo(block, block, 1); + return block_cache_get_etc(fVolume->BlockCache(), block, (const void**)&fBlock); } @@ -135,8 +123,7 @@ CachedBlock::SetTo(block_run run) inline status_t -CachedBlock::SetToWritable(Transaction& transaction, off_t block, off_t base, - size_t length, bool empty) +CachedBlock::SetToWritable(Transaction& transaction, off_t block, bool empty) { Unset(); fBlockNumber = block; @@ -148,14 +135,7 @@ CachedBlock::SetToWritable(Transaction& transaction, off_t block, off_t base, } return block_cache_get_writable_etc(fVolume->BlockCache(), - block, base, length, transaction.ID(), (void**)&fBlock); -} - - -inline status_t -CachedBlock::SetToWritable(Transaction& transaction, off_t block, bool empty) -{ - return SetToWritable(transaction, block, block, 1, empty); + block, transaction.ID(), (void**)&fBlock); } diff --git a/src/add-ons/kernel/file_systems/fat/kernel_interface.cpp b/src/add-ons/kernel/file_systems/fat/kernel_interface.cpp index 274cfad67b..6001dcae36 100644 --- a/src/add-ons/kernel/file_systems/fat/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/fat/kernel_interface.cpp @@ -549,7 +549,7 @@ dosfs_write_fs_stat(fs_volume* volume, const struct fs_info* info, uint32 mask) void* blockCache = bsdVolume->mnt_cache; u_char* buffer; status - = block_cache_get_writable_etc(blockCache, 0, 0, 1, -1, reinterpret_cast(&buffer)); + = block_cache_get_writable_etc(blockCache, 0, -1, reinterpret_cast(&buffer)); if (status != B_OK) return status; // check for the extended boot signature @@ -580,7 +580,7 @@ dosfs_write_fs_stat(fs_volume* volume, const struct fs_info* info, uint32 mask) daddr_t dirOffset = bsdVolume->mnt_volentry * sizeof(direntry); rootDirBlock += dirOffset / DEV_BSIZE; - status = block_cache_get_writable_etc(blockCache, rootDirBlock, 0, 1, -1, + status = block_cache_get_writable_etc(blockCache, rootDirBlock, -1, reinterpret_cast(&rootDirBuffer)); if (status == B_OK) { direntry* label_direntry = reinterpret_cast(rootDirBuffer + dirOffset); diff --git a/src/add-ons/kernel/file_systems/fat/support.cpp b/src/add-ons/kernel/file_systems/fat/support.cpp index e502391417..763de4ca7c 100644 --- a/src/add-ons/kernel/file_systems/fat/support.cpp +++ b/src/add-ons/kernel/file_systems/fat/support.cpp @@ -554,7 +554,7 @@ read_fsinfo(msdosfsmount* volume, const vnode* devNode) const uint8* buffer; const struct fsinfo* fsInfo; - status = block_cache_get_etc(volume->pm_mountp->mnt_cache, volume->pm_fsinfo, 0, 1, + status = block_cache_get_etc(volume->pm_mountp->mnt_cache, volume->pm_fsinfo, reinterpret_cast(&buffer)); if (status != B_OK) RETURN_ERROR(status); diff --git a/src/add-ons/kernel/file_systems/udf/CachedBlock.h b/src/add-ons/kernel/file_systems/udf/CachedBlock.h index 54e4a20970..7e9e133ca4 100644 --- a/src/add-ons/kernel/file_systems/udf/CachedBlock.h +++ b/src/add-ons/kernel/file_systems/udf/CachedBlock.h @@ -36,7 +36,6 @@ public: inline void Unset(); inline status_t SetTo(off_t block); - inline status_t SetTo(off_t block, off_t base, size_t length); inline status_t SetTo(long_address address); template inline status_t SetTo(Accessor &accessor, @@ -96,17 +95,10 @@ CachedBlock::Unset() inline status_t CachedBlock::SetTo(off_t block) -{ - return SetTo(block, block, 1); -} - - -inline status_t -CachedBlock::SetTo(off_t block, off_t base, size_t length) { Unset(); fBlockNumber = block; - return block_cache_get_etc(fVolume->BlockCache(), block, base, length, + return block_cache_get_etc(fVolume->BlockCache(), block, (const void**)&fBlock); } @@ -116,7 +108,7 @@ CachedBlock::SetTo(long_address address) { off_t block; if (fVolume->MapBlock(address, &block) == B_OK) - return SetTo(block, block, 1); + return SetTo(block); return B_BAD_VALUE; } diff --git a/src/add-ons/kernel/file_systems/udf/Icb.cpp b/src/add-ons/kernel/file_systems/udf/Icb.cpp index 1cd2aeff77..914bf3becf 100644 --- a/src/add-ons/kernel/file_systems/udf/Icb.cpp +++ b/src/add-ons/kernel/file_systems/udf/Icb.cpp @@ -453,7 +453,7 @@ Icb::_Read(DescriptorList &list, off_t pos, void *_buffer, size_t *length, uint3 " block_cache_get_etc()\n", readLength, diskBlock)); const uint8 *data; status = block_cache_get_etc(volume->BlockCache(), - diskBlock, 0, readLength, (const void**)&data); + diskBlock, (const void**)&data); if (status != B_OK) break; memcpy(buffer, data + blockOffset, readLength); diff --git a/src/system/kernel/cache/block_cache.cpp b/src/system/kernel/cache/block_cache.cpp index c85884f49c..86a39fb3c7 100644 --- a/src/system/kernel/cache/block_cache.cpp +++ b/src/system/kernel/cache/block_cache.cpp @@ -1999,8 +1999,8 @@ retry: sure that the previous block contents are preserved in that case. */ static status_t -get_writable_cached_block(block_cache* cache, off_t blockNumber, off_t base, - off_t length, int32 transactionID, bool cleared, void** _block) +get_writable_cached_block(block_cache* cache, off_t blockNumber, + int32 transactionID, bool cleared, void** _block) { TRACE(("get_writable_cached_block(blockNumber = %" B_PRIdOFF ", transaction = %" B_PRId32 ")\n", blockNumber, transactionID)); @@ -3617,7 +3617,7 @@ block_cache_make_writable(void* _cache, off_t blockNumber, int32 transaction) // TODO: this can be done better! void* block; status_t status = get_writable_cached_block(cache, blockNumber, - blockNumber, 1, transaction, false, &block); + transaction, false, &block); if (status == B_OK) { put_cached_block((block_cache*)_cache, blockNumber); return B_OK; @@ -3628,8 +3628,8 @@ block_cache_make_writable(void* _cache, off_t blockNumber, int32 transaction) status_t -block_cache_get_writable_etc(void* _cache, off_t blockNumber, off_t base, - off_t length, int32 transaction, void** _block) +block_cache_get_writable_etc(void* _cache, off_t blockNumber, + int32 transaction, void** _block) { block_cache* cache = (block_cache*)_cache; MutexLocker locker(&cache->lock); @@ -3639,7 +3639,7 @@ block_cache_get_writable_etc(void* _cache, off_t blockNumber, off_t base, if (cache->read_only) panic("tried to get writable block on a read-only cache!"); - return get_writable_cached_block(cache, blockNumber, base, length, + return get_writable_cached_block(cache, blockNumber, transaction, false, _block); } @@ -3649,7 +3649,7 @@ block_cache_get_writable(void* _cache, off_t blockNumber, int32 transaction) { void* block; if (block_cache_get_writable_etc(_cache, blockNumber, - blockNumber, 1, transaction, &block) == B_OK) + transaction, &block) == B_OK) return block; return NULL; @@ -3669,7 +3669,7 @@ block_cache_get_empty(void* _cache, off_t blockNumber, int32 transaction) void* block; if (get_writable_cached_block((block_cache*)_cache, blockNumber, - blockNumber, 1, transaction, true, &block) == B_OK) + transaction, true, &block) == B_OK) return block; return NULL; @@ -3677,8 +3677,7 @@ block_cache_get_empty(void* _cache, off_t blockNumber, int32 transaction) status_t -block_cache_get_etc(void* _cache, off_t blockNumber, off_t base, off_t length, - const void** _block) +block_cache_get_etc(void* _cache, off_t blockNumber, const void** _block) { block_cache* cache = (block_cache*)_cache; MutexLocker locker(&cache->lock); @@ -3707,8 +3706,7 @@ const void* block_cache_get(void* _cache, off_t blockNumber) { const void* block; - if (block_cache_get_etc(_cache, blockNumber, blockNumber, 1, &block) - == B_OK) + if (block_cache_get_etc(_cache, blockNumber, &block) == B_OK) return block; return NULL;