From: WenRuo Qu <wqu@suse.com>
To: Nikolay Borisov <nborisov@suse.com>,
"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] btrfs: transaction: Commit transaction more frequently for BPF
Date: Tue, 6 Aug 2019 22:47:51 +0000 [thread overview]
Message-ID: <7a1d90b0-968f-33b4-79ff-4cb155e93ef4@suse.com> (raw)
In-Reply-To: <94e81fef-1dff-28e7-0d2d-a366ccdbe8c8@suse.com>
On 2019/8/6 下午11:23, Nikolay Borisov wrote:
>
>
> On 6.08.19 г. 11:22 ч., Qu Wenruo wrote:
>> Btrfs has btrfs_end_transaction_throttle() which could try to commit
>> transaction when needed.
>>
>> However under most cases btrfs_end_transaction_throttle() won't really
>> commit transaction, due to the hard timing requirement.
>>
>> Now introduce a new error injection point, btrfs_need_trans_pressure(),
>> to allow btrfs_should_end_transaction() to return 1 and
>> btrfs_end_transaction_throttle() to fallback to
>> btrfs_commit_transaction().
>>
>> With such more aggressive transaction commit, we can dig deeper into
>> cases like snapshot drop.
>> Now each reference drop of btrfs_drop_snapshot() will lead to a
>> transaction commit, allowing dm-logwrites to catch more details, other
>> than one big transaction dropping everything.
>>
>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>> ---
>> fs/btrfs/transaction.c | 11 +++++++++++
>> 1 file changed, 11 insertions(+)
>>
>> diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
>> index 248d535bb14d..2e758957126e 100644
>> --- a/fs/btrfs/transaction.c
>> +++ b/fs/btrfs/transaction.c
>> @@ -10,6 +10,7 @@
>> #include <linux/pagemap.h>
>> #include <linux/blkdev.h>
>> #include <linux/uuid.h>
>> +#include <linux/error-injection.h>
>> #include "ctree.h"
>> #include "disk-io.h"
>> #include "transaction.h"
>> @@ -781,10 +782,18 @@ void btrfs_throttle(struct btrfs_fs_info *fs_info)
>> wait_current_trans(fs_info);
>> }
>>
>> +static noinline bool btrfs_need_trans_pressure(struct btrfs_trans_handle *trans)
>> +{
>> + return false;
>> +}
>> +ALLOW_ERROR_INJECTION(btrfs_need_trans_pressure, TRUE);
>> +
>> static int should_end_transaction(struct btrfs_trans_handle *trans)
>> {
>> struct btrfs_fs_info *fs_info = trans->fs_info;
>>
>> + if (btrfs_need_trans_pressure(trans))
>> + return 1;
>> if (btrfs_check_space_for_delayed_refs(fs_info))
>> return 1;
>>
>> @@ -845,6 +854,8 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
>>
>> btrfs_trans_release_chunk_metadata(trans);
>>
>> + if (throttle && btrfs_need_trans_pressure(trans))
>> + return btrfs_commit_transaction(trans);
>
> I'd rather have this gated behind CONFIG_BTRFS_DEBUG.
Then we need both CONFIG_BTRFS_DEBUG and CONFIG_BPF_KPROBE_OVERRIDE to
enable this feature.
And for CONFIG_BTRFS_DEBUG not enabled case, that function would not be
used at all (if you also gate the one in should_end_transaction()).
Not sure if extra hassle is really worthy for such a simple debug feature.
Thanks,
Qu
>
>
>> if (lock && READ_ONCE(cur_trans->state) == TRANS_STATE_BLOCKED) {
>> if (throttle)
>> return btrfs_commit_transaction(trans);
>>
prev parent reply other threads:[~2019-08-06 22:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-06 8:22 [PATCH] btrfs: transaction: Commit transaction more frequently for BPF Qu Wenruo
2019-08-06 14:07 ` David Sterba
2019-08-06 15:23 ` Nikolay Borisov
2019-08-06 22:47 ` WenRuo Qu [this message]
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=7a1d90b0-968f-33b4-79ff-4cb155e93ef4@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=nborisov@suse.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 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).