linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: dsterba@suse.cz, linux-btrfs@vger.kernel.org, fdmanana@suse.com
Subject: Re: [PATCH 1/2] btrfs: Abort transaction if btrfs_update_root fails in btrfs_ioctl_subvol_setflags
Date: Wed, 27 Sep 2017 11:48:59 +0300	[thread overview]
Message-ID: <6c7f1d0c-d61e-8cab-7f90-01c76e10cd01@suse.com> (raw)
In-Reply-To: <20170926173939.GV31640@twin.jikos.cz>



On 26.09.2017 20:39, David Sterba wrote:
> On Tue, Sep 26, 2017 at 05:27:41PM +0300, Nikolay Borisov wrote:
>> btrfs_update_root can fail for any number of reasons, however the only error
>> handling we do is to revert the modified flags, yet we do not abort the
>> transaction but proceed to commit it.
> 
> AFAICS btrfs_update_root aborts the transaction itself, so it's not
> needed in the caller.
> 
>> Fix this by explicitly checking if the
>> update root routine has failed and abort the transaction.
>>
>> Fixes: 0caa102da827 ("Btrfs: Add BTRFS_IOC_SUBVOL_GETFLAGS/SETFLAGS ioctls")
>> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
>> ---
>>  fs/btrfs/ioctl.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
>> index d6715c2bcdc4..09fcd51f0e8c 100644
>> --- a/fs/btrfs/ioctl.c
>> +++ b/fs/btrfs/ioctl.c
>> @@ -1842,8 +1842,11 @@ static noinline int btrfs_ioctl_subvol_setflags(struct file *file,
>>  
>>  	ret = btrfs_update_root(trans, fs_info->tree_root,
>>  				&root->root_key, &root->root_item);
>> +	if (ret < 0)
>> +		btrfs_abort_transaction(trans, ret);
>>  
>>  	btrfs_commit_transaction(trans);
> 
> I think the error from commit_transaction should be returned as well if
> we get here.
> 
> So:
> 
> ret = btrfs_update_root();
> 
> if (ret < 0) {
> 	end_transaction();
> 	goto out_reset;
> }
> 
> ret = btrfs_commit_transaction();
> 
> out_reset:
> /* and then as it is */
> if (ret)
> 	btrfs_set_root_flags(...);
> 
> etc.

I think even this is not needed, since btrfs_commit_transaction actually
handles aborted transaction by calling btrfs_end_transaction and
returning the error with which the trans was aborted. So I will just
drop this patch


> 
> 
> 
>> +
>>  out_reset:
>>  	if (ret)
>>  		btrfs_set_root_flags(&root->root_item, root_flags);
>> -- 
>> 2.7.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2017-09-27  8:49 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-26 14:27 [PATCH 1/2] btrfs: Abort transaction if btrfs_update_root fails in btrfs_ioctl_subvol_setflags Nikolay Borisov
2017-09-26 14:27 ` [RFC PATCH 2/2] btrfs: Remove received_uuid during received snapshot ro->rw switch Nikolay Borisov
2017-09-27  8:53   ` [PATCH v2] " Nikolay Borisov
2017-09-26 17:39 ` [PATCH 1/2] btrfs: Abort transaction if btrfs_update_root fails in btrfs_ioctl_subvol_setflags David Sterba
2017-09-27  8:48   ` Nikolay Borisov [this message]
2017-09-27 14:00     ` David Sterba
2017-09-27 14:28       ` Nikolay Borisov
2017-09-28  7:53       ` [PATCH 1/2] btrfs: Explicitly handle btrfs_update_root failure Nikolay Borisov
2017-09-28  7:53         ` [PATCH v3 2/2] btrfs: Remove received_uuid during received snapshot ro->rw switch Nikolay Borisov
2017-09-29 17:56           ` David Sterba
2017-09-29 19:15             ` Nikolay Borisov
2017-10-04 15:00               ` David Sterba
2017-10-05  8:22                 ` [PATCH v4] " Nikolay Borisov
2017-10-05  9:03                   ` Anand Jain
2017-10-06 17:24                     ` David Sterba
2017-10-06 17:49                       ` Hans van Kranenburg
2017-10-06 20:07                         ` Andrei Borzenkov
2017-10-06 21:27                           ` Hans van Kranenburg
2017-10-07  7:56                             ` Andrei Borzenkov
2017-11-12 17:11                   ` Hans van Kranenburg
2017-09-29 17:42         ` [PATCH 1/2] btrfs: Explicitly handle btrfs_update_root failure David Sterba

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=6c7f1d0c-d61e-8cab-7f90-01c76e10cd01@suse.com \
    --to=nborisov@suse.com \
    --cc=dsterba@suse.cz \
    --cc=fdmanana@suse.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).