On 10.05.2018 09:21, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@xxxxxx>
>
> Currently, if btrfs_insert_orphan_item() fails, we release the reserved
> space and decrement root->orphan_inodes. However, we also ignore -EEXIST
> errors, so we still want the space reservation for when we delete the
> item, and we still need to count the orphan because we're still going to
> decrement root->orphan_inodes from btrfs_orphan_del() later.
>
> Fixes: 4ef31a45a009 ("Btrfs: fix the error handling wrt orphan items")
> Signed-off-by: Omar Sandoval <osandov@xxxxxx>
Reviewed-by: Nikolay Borisov <nborisov@xxxxxxxx>
> ---
> fs/btrfs/inode.c | 13 +++++--------
> 1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 1460823951d7..e77df96de642 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -3408,7 +3408,7 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans,
> /* insert an orphan item to track this unlinked file */
> if (insert) {
> ret = btrfs_insert_orphan_item(trans, root, btrfs_ino(inode));
> - if (ret) {
> + if (ret && ret != -EEXIST) {
> if (reserve) {
> clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED,
> &inode->runtime_flags);
> @@ -3420,14 +3420,11 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans,
> * decrease ->orphan_inodes after everything is done.
> */
> atomic_dec(&root->orphan_inodes);
> - if (ret != -EEXIST) {
> - clear_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,
> - &inode->runtime_flags);
> - btrfs_abort_transaction(trans, ret);
> - return ret;
> - }
> + clear_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,
> + &inode->runtime_flags);
> + btrfs_abort_transaction(trans, ret);
> + return ret;
> }
> - ret = 0;
> }
>
> return 0;
>
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html