btrfs: handle errors returned from unpin_extent_cache()
We've had numerous attempts to let function unpin_extent_cache() return void as it only returns 0. There are still error cases to handle so do that, in addition to the verbose messages. The only caller btrfs_finish_one_ordered() will now abort the transaction, previously it let it continue which could lead to further problems. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
835cd82649
commit
c03c89f821
2 changed files with 16 additions and 3 deletions
|
@ -290,6 +290,10 @@ static void try_merge_map(struct extent_map_tree *tree, struct extent_map *em)
|
||||||
* Called after an extent has been written to disk properly. Set the generation
|
* Called after an extent has been written to disk properly. Set the generation
|
||||||
* to the generation that actually added the file item to the inode so we know
|
* to the generation that actually added the file item to the inode so we know
|
||||||
* we need to sync this extent when we call fsync().
|
* we need to sync this extent when we call fsync().
|
||||||
|
*
|
||||||
|
* Returns: 0 on success
|
||||||
|
* -ENOENT when the extent is not found in the tree
|
||||||
|
* -EUCLEAN if the found extent does not match the expected start
|
||||||
*/
|
*/
|
||||||
int unpin_extent_cache(struct btrfs_inode *inode, u64 start, u64 len, u64 gen)
|
int unpin_extent_cache(struct btrfs_inode *inode, u64 start, u64 len, u64 gen)
|
||||||
{
|
{
|
||||||
|
@ -307,14 +311,18 @@ int unpin_extent_cache(struct btrfs_inode *inode, u64 start, u64 len, u64 gen)
|
||||||
"no extent map found for inode %llu (root %lld) when unpinning extent range [%llu, %llu), generation %llu",
|
"no extent map found for inode %llu (root %lld) when unpinning extent range [%llu, %llu), generation %llu",
|
||||||
btrfs_ino(inode), btrfs_root_id(inode->root),
|
btrfs_ino(inode), btrfs_root_id(inode->root),
|
||||||
start, len, gen);
|
start, len, gen);
|
||||||
|
ret = -ENOENT;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WARN_ON(em->start != start))
|
if (WARN_ON(em->start != start)) {
|
||||||
btrfs_warn(fs_info,
|
btrfs_warn(fs_info,
|
||||||
"found extent map for inode %llu (root %lld) with unexpected start offset %llu when unpinning extent range [%llu, %llu), generation %llu",
|
"found extent map for inode %llu (root %lld) with unexpected start offset %llu when unpinning extent range [%llu, %llu), generation %llu",
|
||||||
btrfs_ino(inode), btrfs_root_id(inode->root),
|
btrfs_ino(inode), btrfs_root_id(inode->root),
|
||||||
em->start, start, len, gen);
|
em->start, start, len, gen);
|
||||||
|
ret = -EUCLEAN;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
em->generation = gen;
|
em->generation = gen;
|
||||||
em->flags &= ~EXTENT_FLAG_PINNED;
|
em->flags &= ~EXTENT_FLAG_PINNED;
|
||||||
|
|
|
@ -3125,8 +3125,13 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)
|
||||||
ordered_extent->disk_num_bytes);
|
ordered_extent->disk_num_bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unpin_extent_cache(inode, ordered_extent->file_offset,
|
if (ret < 0) {
|
||||||
ordered_extent->num_bytes, trans->transid);
|
btrfs_abort_transaction(trans, ret);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = unpin_extent_cache(inode, ordered_extent->file_offset,
|
||||||
|
ordered_extent->num_bytes, trans->transid);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
btrfs_abort_transaction(trans, ret);
|
btrfs_abort_transaction(trans, ret);
|
||||||
goto out;
|
goto out;
|
||||||
|
|
Loading…
Add table
Reference in a new issue