Inode::ShrinkStream() now evaluates the return values from some functions - dunno
if that's a good idea (it may still be a good idea to succeed for shrinking the stream, even if not everything worked), but it looks better :-) Improved debug output in case TrimPreallocation() fails. Journal::FlushLogAndBlocks() no longer ends the current transaction if called from within an ongoing transaction. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13019 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1759,10 +1759,13 @@ status_t
|
||||
Inode::ShrinkStream(Transaction &transaction, off_t size)
|
||||
{
|
||||
data_stream *data = &Node().data;
|
||||
status_t status;
|
||||
|
||||
if (data->MaxDoubleIndirectRange() > size) {
|
||||
FreeStaticStreamArray(transaction, 0, data->double_indirect, size,
|
||||
status = FreeStaticStreamArray(transaction, 0, data->double_indirect, size,
|
||||
data->MaxIndirectRange(), data->max_double_indirect_range);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
if (size <= data->MaxIndirectRange()) {
|
||||
fVolume->Free(transaction, data->double_indirect);
|
||||
@@ -1792,8 +1795,10 @@ Inode::ShrinkStream(Transaction &transaction, off_t size)
|
||||
}
|
||||
if (data->MaxDirectRange() > size) {
|
||||
off_t offset = 0;
|
||||
FreeStreamArray(transaction, data->direct, NUM_DIRECT_BLOCKS, size, offset,
|
||||
data->max_direct_range);
|
||||
status = FreeStreamArray(transaction, data->direct, NUM_DIRECT_BLOCKS,
|
||||
size, offset, data->max_direct_range);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
}
|
||||
|
||||
data->size = HOST_ENDIAN_TO_BFS_INT64(size);
|
||||
|
||||
@@ -336,6 +336,12 @@ Journal::FlushLogAndBlocks()
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
if (fLock.OwnerCount() > 1) {
|
||||
// whoa, FlushLogAndBlocks() was called from inside a transaction
|
||||
fLock.Unlock();
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// write the current log entry to disk
|
||||
|
||||
if (fTransactionID != -1 && TransactionSize() != 0) {
|
||||
@@ -343,6 +349,7 @@ Journal::FlushLogAndBlocks()
|
||||
if (status < B_OK)
|
||||
FATAL(("writing current log entry failed: %s\n", strerror(status)));
|
||||
}
|
||||
|
||||
status = fVolume->FlushDevice();
|
||||
|
||||
fLock.Unlock();
|
||||
|
||||
@@ -1259,8 +1259,13 @@ bfs_free_cookie(void *_ns, void *_node, void *_cookie)
|
||||
|
||||
if (needsTrimming) {
|
||||
status = inode->TrimPreallocation(transaction);
|
||||
if (status < B_OK)
|
||||
FATAL(("Could not trim preallocated blocks!"));
|
||||
if (status < B_OK) {
|
||||
FATAL(("Could not trim preallocated blocks: inode %Ld, transaction %ld: %s!\n",
|
||||
inode->ID(), transaction.ID(), strerror(status)));
|
||||
|
||||
// we still want this transaction to succeed
|
||||
status = B_OK;
|
||||
}
|
||||
}
|
||||
if (needsTrimming || inode->OldSize() != inode->Size()) {
|
||||
index.UpdateSize(transaction, inode);
|
||||
|
||||
Reference in New Issue
Block a user