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.
This commit is contained in:
Augustin Cavalier 2024-10-17 12:05:22 -04:00
parent 72d9beca78
commit 16ecdb595b
7 changed files with 22 additions and 52 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -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<void**>(&buffer));
= block_cache_get_writable_etc(blockCache, 0, -1, reinterpret_cast<void**>(&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<void**>(&rootDirBuffer));
if (status == B_OK) {
direntry* label_direntry = reinterpret_cast<direntry*>(rootDirBuffer + dirOffset);

View File

@ -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<const void**>(&buffer));
if (status != B_OK)
RETURN_ERROR(status);

View File

@ -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 <class Accessor, class Descriptor>
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;
}

View File

@ -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);

View File

@ -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;