All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: fdmanana@kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 05/12] btrfs: deal with deletion errors when deleting delayed items
Date: Wed, 1 Jun 2022 07:14:48 +0530	[thread overview]
Message-ID: <ded9e93b-a160-ef14-777f-2d23fe5534d3@oracle.com> (raw)
In-Reply-To: <765e2a5d2f1ae54767fd49fae2fcae2dd34b63ce.1654009356.git.fdmanana@suse.com>

On 5/31/22 20:36, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> Currently, btrfs_delete_delayed_items() ignores any errors returned from
> btrfs_batch_delete_items(). This looks fishy but it's not a problem at
> the moment because:
> 
> 1) Two of the errors returned from btrfs_batch_delete_items() are for
>     impossible cases, cases where a delayed item does not match any item
>     in the leaf the path points to - btrfs_delete_delayed_items() always
>     calls btrfs_batch_delete_items() with a path that points to a leaf
>     that contains an item matching a delayed item;
> 
> 2) btrfs_batch_delete_items() may return an error from btrfs_del_items(),
>     in which case it does not release the delayed items of the batch.
> 
>     At the moment this is harmless because btrfs_del_items() actually is
>     always able to delete items, even if it returns an error - when it
>     returns an error it's because it ended up with a leaf mostly empty
>     (less than 1/3 full) and failed to migrate items from that leaf into
>     its neighbour leaves - this is not critical, as all the items were
>     deleted, we just left the tree a bit unbalanced, but it's still a
>     valid tree and causes no harm, and future operations on the tree will
>     eventually balance it.
> 
>     So even if we get an error from btrfs_del_items(), the delayed items
>     will not be released but the next time we run delayed items we will
>     find out, at btrfs_delete_delayed_items(), that they are not present
>     in the tree anymore and then release them.
> 
> This is all a bit subtle, and it's certainly prone to be a disaster in
> case btrfs_del_items() changes one day and may return errors before being
> able to delete all the requested items, in which case we could leave the
> filesystem in an inconsistent state as we would commit a transaction
> despite a failure from deleting items from the tree.
> 
> So make btrfs_delete_delayed_items() check for any erros from the call to
> btrfs_batch_delete_items().
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

LGTM
Reviewed-by: Anand Jain <anand.jain@oracle.com>



> ---
>   fs/btrfs/delayed-inode.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
> index bb9955e74a51..3c6368c29bb9 100644
> --- a/fs/btrfs/delayed-inode.c
> +++ b/fs/btrfs/delayed-inode.c
> @@ -889,7 +889,9 @@ static int btrfs_delete_delayed_items(struct btrfs_trans_handle *trans,
>   			goto delete_fail;
>   	}
>   
> -	btrfs_batch_delete_items(trans, root, path, curr);
> +	ret = btrfs_batch_delete_items(trans, root, path, curr);
> +	if (ret)
> +		goto delete_fail;
>   	btrfs_release_path(path);
>   	mutex_unlock(&node->mutex);
>   	goto do_again;


  reply	other threads:[~2022-06-01  1:45 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-31 15:06 [PATCH 00/12] btrfs: some improvements and cleanups around delayed items fdmanana
2022-05-31 15:06 ` [PATCH 01/12] btrfs: balance btree dirty pages and delayed items after a rename fdmanana
2022-05-31 15:16   ` Nikolay Borisov
2022-05-31 23:13   ` Anand Jain
2022-05-31 15:06 ` [PATCH 02/12] btrfs: free the path earlier when creating a new inode fdmanana
2022-05-31 15:21   ` Nikolay Borisov
2022-05-31 23:22   ` Anand Jain
2022-06-01  9:34     ` Filipe Manana
2022-06-01 11:11       ` Anand Jain
2022-06-01 11:51         ` David Sterba
2022-05-31 15:06 ` [PATCH 03/12] btrfs: balance btree dirty pages and delayed items after clone and dedupe fdmanana
2022-06-01  0:54   ` Anand Jain
2022-05-31 15:06 ` [PATCH 04/12] btrfs: add assertions when deleting batches of delayed items fdmanana
2022-06-01  1:34   ` Anand Jain
2022-05-31 15:06 ` [PATCH 05/12] btrfs: deal with deletion errors when deleting " fdmanana
2022-06-01  1:44   ` Anand Jain [this message]
2022-05-31 15:06 ` [PATCH 06/12] btrfs: refactor the delayed item deletion entry point fdmanana
2022-05-31 15:06 ` [PATCH 07/12] btrfs: improve batch deletion of delayed dir index items fdmanana
2022-06-02  8:24   ` Nikolay Borisov
2022-06-02  8:55     ` Filipe Manana
2022-05-31 15:06 ` [PATCH 08/12] btrfs: assert that delayed item is a dir index item when adding it fdmanana
2022-05-31 15:06 ` [PATCH 09/12] btrfs: improve batch insertion of delayed dir index items fdmanana
2022-05-31 15:06 ` [PATCH 10/12] btrfs: do not BUG_ON() on failure to reserve metadata for delayed item fdmanana
2022-05-31 15:06 ` [PATCH 11/12] btrfs: set delayed item type when initializing it fdmanana
2022-05-31 15:06 ` [PATCH 12/12] btrfs: reduce amount of reserved metadata for delayed item insertion fdmanana
2022-06-08 15:23   ` [btrfs] 62bd8124e2: WARNING:at_fs/btrfs/block-rsv.c:#btrfs_release_global_block_rsv[btrfs] kernel test robot
2022-06-08 15:23     ` kernel test robot
2022-06-09  9:46     ` Filipe Manana
2022-06-09  9:46       ` Filipe Manana
2022-06-10  1:26       ` Oliver Sang
2022-06-10  1:26         ` Oliver Sang
2022-06-12 14:36         ` Oliver Sang
2022-06-12 14:36           ` Oliver Sang
2022-06-13 10:50           ` Filipe Manana
2022-06-13 10:50             ` Filipe Manana
2022-06-16  2:42             ` Oliver Sang
2022-06-16  2:42               ` Oliver Sang
2022-06-17 10:32               ` Filipe Manana
2022-06-17 10:32                 ` Filipe Manana
2022-06-01 18:35 ` [PATCH 00/12] btrfs: some improvements and cleanups around delayed items David Sterba
2022-06-02  9:34 ` Nikolay Borisov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ded9e93b-a160-ef14-777f-2d23fe5534d3@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=fdmanana@kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.