All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: Zach Brown <zab@redhat.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: abort unlink trans in missed error case
Date: Wed, 03 Apr 2013 09:36:00 -0500	[thread overview]
Message-ID: <515C3E50.60807@redhat.com> (raw)
In-Reply-To: <1364936536-13130-1-git-send-email-zab@redhat.com>

On 4/2/13 4:02 PM, Zach Brown wrote:
> __btrfs_unlink_inode() aborts its transaction when it sees errors after
> it removes the directory item.  But it missed the case where
> btrfs_del_dir_entries_in_log() returns an error.  If this happens then
> the unlink appears to fail but the items have been removed without
> updating the directory size.  The directory then has leaked bytes in
> i_size and can never be removed.
> 
> Adding the missing transaction abort at least makes this failure
> consistent with the other failure cases.
> 
> I noticed this while reading the code after someone on irc reported
> having a directory with i_size but no entries.  I tested it by forcing
> btrfs_del_dir_entries_in_log() to return -ENOMEM.

I was wondering if the transaction support should just be in the
err: goto case, and went looking.

I'm not familiar enough with this stuff yet, but what if i.e.
btrfs_delete_one_dir_name fails, should that also abort the transaction?

> Signed-off-by: Zach Brown <zab@redhat.com>
> ---
>  fs/btrfs/inode.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index d96ee30..80676ee 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -3619,6 +3619,8 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
>  					   dir, index);
>  	if (ret == -ENOENT)
>  		ret = 0;
> +	else if (ret)
> +		btrfs_abort_transaction(trans, root, ret);
>  err:
>  	btrfs_free_path(path);
>  	if (ret)
> 


  reply	other threads:[~2013-04-03 14:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-02 21:02 [PATCH] btrfs: abort unlink trans in missed error case Zach Brown
2013-04-03 14:36 ` Eric Sandeen [this message]
2013-04-03 16:04   ` Zach Brown
2013-04-03 16:18     ` Eric Sandeen

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=515C3E50.60807@redhat.com \
    --to=sandeen@redhat.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=zab@redhat.com \
    /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.