From: Anand Jain <anand.jain@oracle.com>
To: dsterba@suse.cz
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v4 06/10] btrfs: start transaction in btrfs_set_prop_trans
Date: Thu, 28 Feb 2019 18:36:40 +0800 [thread overview]
Message-ID: <742192e4-ce6e-df4e-aa64-1145a4e3f44a@oracle.com> (raw)
In-Reply-To: <20190227160826.GT24609@twin.jikos.cz>
On 2/28/19 12:08 AM, David Sterba wrote:
> On Sat, Feb 23, 2019 at 01:39:48AM +0800, Anand Jain wrote:
>> In preparation to make trans argument of btrfs_setxattr() a mandatory,
>> start the transaction in btrfs_set_prop_trans.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>> v4: born
>> fs/btrfs/props.c | 21 ++++++++++++++++++++-
>> 1 file changed, 20 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c
>> index e581da1bfbb6..f878ba3160f0 100644
>> --- a/fs/btrfs/props.c
>> +++ b/fs/btrfs/props.c
>> @@ -4,6 +4,7 @@
>> */
>>
>> #include <linux/hashtable.h>
>> +#include <linux/iversion.h>
>> #include "props.h"
>> #include "btrfs_inode.h"
>> #include "transaction.h"
>> @@ -103,7 +104,25 @@ static int btrfs_set_prop(struct btrfs_trans_handle *trans, struct inode *inode,
>> int btrfs_set_prop_trans(struct inode *inode, const char *name,
>> const char *value, size_t value_len, int flags)
>> {
>> - return btrfs_set_prop(NULL, inode, name, value, value_len, flags);
>> + struct btrfs_root *root = BTRFS_I(inode)->root;
>> + struct btrfs_trans_handle *trans;
>> + int ret;
>> +
>> + trans = btrfs_start_transaction(root, 2);
>> + if (IS_ERR(trans))
>> + return PTR_ERR(trans);
>> +
>> + ret = btrfs_set_prop(trans, inode, name, value, value_len, flags);
>> +
>> + if (!ret) {
>> + inode_inc_iversion(inode);
>> + inode->i_ctime = current_time(inode);
>> + set_bit(BTRFS_INODE_COPY_EVERYTHING, &BTRFS_I(inode)->runtime_flags);
>> + ret = btrfs_update_inode(trans, root, inode);
>> + ASSERT(!ret);
>
> This is not right. The previous code uses BUG_ON which is also not
> right, but does not silently continue if asserts are compiled out.
> Please add proper error handling here.
Error handling should save and undo of inode version, i_ctime and
runtime_flags. Is a new patch for this OK? and here will use BUG_ON
as in the original.
Thanks, Anand
>> + }
>> + btrfs_end_transaction(trans);
>> + return ret;
>> }
>>
>> static int iterate_object_props(struct btrfs_root *root,
>> --
>> 1.8.3.1
next prev parent reply other threads:[~2019-02-28 10:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-22 17:39 [PATCH v4 00/10] Misc props.c cleanups Anand Jain
2019-02-22 17:39 ` [PATCH v4 01/10] btrfs: kill __btrfs_set_prop() Anand Jain
2019-02-22 17:39 ` [PATCH v4 02/10] btrfs: drop redundant forward declaration in props.c Anand Jain
2019-02-22 17:39 ` [PATCH v4 03/10] btrfs: trivial, fix c coding style Anand Jain
2019-02-27 16:05 ` David Sterba
2019-02-28 9:50 ` Anand Jain
2019-02-22 17:39 ` [PATCH v4 04/10] btrfs: rename fs_info argument to fs_private Anand Jain
2019-02-27 16:10 ` David Sterba
2019-02-22 17:39 ` [PATCH v4 05/10] btrfs: refactor btrfs_set_prop add btrfs_set_prop_trans Anand Jain
2019-02-22 17:39 ` [PATCH v4 06/10] btrfs: start transaction in btrfs_set_prop_trans Anand Jain
2019-02-27 16:08 ` David Sterba
2019-02-28 10:36 ` Anand Jain [this message]
2019-02-28 16:00 ` David Sterba
2019-02-22 17:39 ` [PATCH v4 07/10] btrfs: start transaction in btrfs_set_acl Anand Jain
2019-02-22 17:39 ` [PATCH v4 08/10] btrfs: start transaction in btrfs_xattr_handler_set Anand Jain
2019-02-22 17:39 ` [PATCH v4 09/10] btrfs: btrfs_setxattr argument trans is never NULL Anand Jain
2019-02-27 16:16 ` David Sterba
2019-02-28 10:40 ` Anand Jain
2019-02-22 17:39 ` [PATCH v4 10/10] btrfs: kill btrfs_setxattr Anand Jain
2019-02-27 16:21 ` David Sterba
2019-02-28 11:10 ` Anand Jain
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=742192e4-ce6e-df4e-aa64-1145a4e3f44a@oracle.com \
--to=anand.jain@oracle.com \
--cc=dsterba@suse.cz \
--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).