All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Slightly how START_SYNC and WAIT_SYNC work
@ 2021-06-03 15:20 David Sterba
  2021-06-03 15:20 ` [PATCH 1/4] btrfs: sink wait_for_unblock parameter to async commit David Sterba
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: David Sterba @ 2021-06-03 15:20 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The async transaction commit ioctl has a subtle semantics that used to
work for ceph. We need more straightforward semantics in progs (eg. when
waiting for commit after subvolume deletion) and otherwise the async
commit does a few annoying things.

Long explanation is in patch 3. I hope it works, but somebody please
double check. It's a minor change in the commit logic, but merely
removing some waiting, no other changes in state transitions.

David Sterba (4):
  btrfs: sink wait_for_unblock parameter to async commit
  btrfs: inline wait_current_trans_commit_start in its caller
  btrfs: replace async commit by pending actions
  btrfs: remove fs_info::transaction_blocked_wait

 fs/btrfs/ctree.h       |   1 -
 fs/btrfs/disk-io.c     |   5 +-
 fs/btrfs/ioctl.c       |  12 ++---
 fs/btrfs/super.c       |   1 -
 fs/btrfs/transaction.c | 103 +----------------------------------------
 fs/btrfs/transaction.h |   2 -
 6 files changed, 9 insertions(+), 115 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/4] btrfs: sink wait_for_unblock parameter to async commit
  2021-06-03 15:20 [PATCH 0/4] Slightly how START_SYNC and WAIT_SYNC work David Sterba
@ 2021-06-03 15:20 ` David Sterba
  2021-06-04 12:35   ` Anand Jain
  2021-06-03 15:20 ` [PATCH 2/4] btrfs: inline wait_current_trans_commit_start in its caller David Sterba
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: David Sterba @ 2021-06-03 15:20 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

There's only one caller left btrfs_ioctl_start_sync that passes 0, so we
can remove the switch in btrfs_commit_transaction_async.

A cleanup 9babda9f33fd ("btrfs: Remove async_transid from
btrfs_mksubvol/create_subvol/create_snapshot") removed calls that passed
1, so this is a followup.

As this removes last call of wait_current_trans_commit_start_and_unblock,
remove the function as well.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/ioctl.c       |  2 +-
 fs/btrfs/transaction.c | 24 ++----------------------
 fs/btrfs/transaction.h |  3 +--
 3 files changed, 4 insertions(+), 25 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 2bdaf2018197..f83eb4a225cc 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3643,7 +3643,7 @@ static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root,
 		goto out;
 	}
 	transid = trans->transid;
-	ret = btrfs_commit_transaction_async(trans, 0);
+	ret = btrfs_commit_transaction_async(trans);
 	if (ret) {
 		btrfs_end_transaction(trans);
 		return ret;
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 22951621363f..30347e660027 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1882,19 +1882,6 @@ static void wait_current_trans_commit_start(struct btrfs_fs_info *fs_info,
 		   TRANS_ABORTED(trans));
 }
 
-/*
- * wait for the current transaction to start and then become unblocked.
- * caller holds ref.
- */
-static void wait_current_trans_commit_start_and_unblock(
-					struct btrfs_fs_info *fs_info,
-					struct btrfs_transaction *trans)
-{
-	wait_event(fs_info->transaction_wait,
-		   trans->state >= TRANS_STATE_UNBLOCKED ||
-		   TRANS_ABORTED(trans));
-}
-
 /*
  * commit transactions asynchronously. once btrfs_commit_transaction_async
  * returns, any subsequent transaction will not be allowed to join.
@@ -1922,8 +1909,7 @@ static void do_async_commit(struct work_struct *work)
 	kfree(ac);
 }
 
-int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans,
-				   int wait_for_unblock)
+int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans)
 {
 	struct btrfs_fs_info *fs_info = trans->fs_info;
 	struct btrfs_async_commit *ac;
@@ -1955,13 +1941,7 @@ int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans,
 		__sb_writers_release(fs_info->sb, SB_FREEZE_FS);
 
 	schedule_work(&ac->work);
-
-	/* wait for transaction to start and unblock */
-	if (wait_for_unblock)
-		wait_current_trans_commit_start_and_unblock(fs_info, cur_trans);
-	else
-		wait_current_trans_commit_start(fs_info, cur_trans);
-
+	wait_current_trans_commit_start(fs_info, cur_trans);
 	if (current->journal_info == trans)
 		current->journal_info = NULL;
 
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h
index c49e2266b28b..0702e8d9b30e 100644
--- a/fs/btrfs/transaction.h
+++ b/fs/btrfs/transaction.h
@@ -226,8 +226,7 @@ void btrfs_add_dead_root(struct btrfs_root *root);
 int btrfs_defrag_root(struct btrfs_root *root);
 int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root);
 int btrfs_commit_transaction(struct btrfs_trans_handle *trans);
-int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans,
-				   int wait_for_unblock);
+int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans);
 int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans);
 bool btrfs_should_end_transaction(struct btrfs_trans_handle *trans);
 void btrfs_throttle(struct btrfs_fs_info *fs_info);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] btrfs: inline wait_current_trans_commit_start in its caller
  2021-06-03 15:20 [PATCH 0/4] Slightly how START_SYNC and WAIT_SYNC work David Sterba
  2021-06-03 15:20 ` [PATCH 1/4] btrfs: sink wait_for_unblock parameter to async commit David Sterba
@ 2021-06-03 15:20 ` David Sterba
  2021-06-04 12:37   ` Anand Jain
  2021-06-03 15:20 ` [PATCH 3/4] btrfs: replace async commit by pending actions David Sterba
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: David Sterba @ 2021-06-03 15:20 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Function wait_current_trans_commit_start is now fairly trivial so it can
be inlined in its only caller.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/transaction.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 30347e660027..73df8b81496e 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1870,18 +1870,6 @@ int btrfs_transaction_blocked(struct btrfs_fs_info *info)
 	return ret;
 }
 
-/*
- * wait for the current transaction commit to start and block subsequent
- * transaction joins
- */
-static void wait_current_trans_commit_start(struct btrfs_fs_info *fs_info,
-					    struct btrfs_transaction *trans)
-{
-	wait_event(fs_info->transaction_blocked_wait,
-		   trans->state >= TRANS_STATE_COMMIT_START ||
-		   TRANS_ABORTED(trans));
-}
-
 /*
  * commit transactions asynchronously. once btrfs_commit_transaction_async
  * returns, any subsequent transaction will not be allowed to join.
@@ -1941,7 +1929,13 @@ int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans)
 		__sb_writers_release(fs_info->sb, SB_FREEZE_FS);
 
 	schedule_work(&ac->work);
-	wait_current_trans_commit_start(fs_info, cur_trans);
+	/*
+	 * Wait for the current transaction commit to start and block
+	 * subsequent transaction joins
+	 */
+	wait_event(fs_info->transaction_blocked_wait,
+		   cur_trans->state >= TRANS_STATE_COMMIT_START ||
+		   TRANS_ABORTED(cur_trans));
 	if (current->journal_info == trans)
 		current->journal_info = NULL;
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] btrfs: replace async commit by pending actions
  2021-06-03 15:20 [PATCH 0/4] Slightly how START_SYNC and WAIT_SYNC work David Sterba
  2021-06-03 15:20 ` [PATCH 1/4] btrfs: sink wait_for_unblock parameter to async commit David Sterba
  2021-06-03 15:20 ` [PATCH 2/4] btrfs: inline wait_current_trans_commit_start in its caller David Sterba
@ 2021-06-03 15:20 ` David Sterba
  2021-06-03 15:20 ` [PATCH 4/4] btrfs: remove fs_info::transaction_blocked_wait David Sterba
  2021-06-04 10:59 ` [PATCH 0/4] Slightly how START_SYNC and WAIT_SYNC work David Sterba
  4 siblings, 0 replies; 8+ messages in thread
From: David Sterba @ 2021-06-03 15:20 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Note: this is a semantic change of what the async transaction ioctl
does. This used to be utilized by ceph, together with the now removed
user transaction ioctls. Last external code that can be found using this
ioctl is a test in ceph testsuite. As btrfs and ceph have taken
independent routes, we don't need to keep the code around.

The btrfs-progs use the start and wait transaction ioctls in a simpler
way, that does not require to block new transaction on the start. The
new semantics is to eventually get transaction id of the running
transaction if there is anything pending for a commit. The wait for
transaction ioctl will block until it's finished.

If there's nothing to be done since start, wait will return
immediately. This effectively implements "wait for current transaction,
if any".

Any action started before the start, like deleting a subvolume, may take
long time to finish. In case it's fast enough to finish before the
start, the following wait will also finish immediately. A long running
operation will catch the transaction and block at wait call until it's
done. Both cases are expected and shall be the new semantics.

This is implemented by the pending action infrastructure, that allows to
asynchronously and safely request a commit by just setting a bit and
waking the transaction kthread.

This is different, because originally start would block, but now it
returns immediately. However, the new behaviour still corresponds with
the documentation of libbtrfsutil so this should not cause any
surprises.

This also simplifies a few transaction commit things:

- another quirky freezing protection removed
- fs_info::transaction_blocked_wait is now never populated, so it's a
  no-op and can be simplified as well
- one less current->journal_info usage, that's been problematic in some
  cases

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/ioctl.c       | 12 +++----
 fs/btrfs/transaction.c | 74 ------------------------------------------
 fs/btrfs/transaction.h |  1 -
 3 files changed, 5 insertions(+), 82 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index f83eb4a225cc..445bb19d8a57 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3629,9 +3629,9 @@ static long btrfs_ioctl_space_info(struct btrfs_fs_info *fs_info,
 static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root,
 					    void __user *argp)
 {
+	struct btrfs_fs_info *fs_info = root->fs_info;
 	struct btrfs_trans_handle *trans;
 	u64 transid;
-	int ret;
 
 	trans = btrfs_attach_transaction_barrier(root);
 	if (IS_ERR(trans)) {
@@ -3639,15 +3639,13 @@ static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root,
 			return PTR_ERR(trans);
 
 		/* No running transaction, don't bother */
-		transid = root->fs_info->last_trans_committed;
+		transid = fs_info->last_trans_committed;
 		goto out;
 	}
 	transid = trans->transid;
-	ret = btrfs_commit_transaction_async(trans);
-	if (ret) {
-		btrfs_end_transaction(trans);
-		return ret;
-	}
+	/* Trigger commit via the pending action */
+	btrfs_set_pending(fs_info, COMMIT);
+	wake_up_process(fs_info->transaction_kthread);
 out:
 	if (argp)
 		if (copy_to_user(argp, &transid, sizeof(transid)))
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 73df8b81496e..5f3c95c876c8 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1870,80 +1870,6 @@ int btrfs_transaction_blocked(struct btrfs_fs_info *info)
 	return ret;
 }
 
-/*
- * commit transactions asynchronously. once btrfs_commit_transaction_async
- * returns, any subsequent transaction will not be allowed to join.
- */
-struct btrfs_async_commit {
-	struct btrfs_trans_handle *newtrans;
-	struct work_struct work;
-};
-
-static void do_async_commit(struct work_struct *work)
-{
-	struct btrfs_async_commit *ac =
-		container_of(work, struct btrfs_async_commit, work);
-
-	/*
-	 * We've got freeze protection passed with the transaction.
-	 * Tell lockdep about it.
-	 */
-	if (ac->newtrans->type & __TRANS_FREEZABLE)
-		__sb_writers_acquired(ac->newtrans->fs_info->sb, SB_FREEZE_FS);
-
-	current->journal_info = ac->newtrans;
-
-	btrfs_commit_transaction(ac->newtrans);
-	kfree(ac);
-}
-
-int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans)
-{
-	struct btrfs_fs_info *fs_info = trans->fs_info;
-	struct btrfs_async_commit *ac;
-	struct btrfs_transaction *cur_trans;
-
-	ac = kmalloc(sizeof(*ac), GFP_NOFS);
-	if (!ac)
-		return -ENOMEM;
-
-	INIT_WORK(&ac->work, do_async_commit);
-	ac->newtrans = btrfs_join_transaction(trans->root);
-	if (IS_ERR(ac->newtrans)) {
-		int err = PTR_ERR(ac->newtrans);
-		kfree(ac);
-		return err;
-	}
-
-	/* take transaction reference */
-	cur_trans = trans->transaction;
-	refcount_inc(&cur_trans->use_count);
-
-	btrfs_end_transaction(trans);
-
-	/*
-	 * Tell lockdep we've released the freeze rwsem, since the
-	 * async commit thread will be the one to unlock it.
-	 */
-	if (ac->newtrans->type & __TRANS_FREEZABLE)
-		__sb_writers_release(fs_info->sb, SB_FREEZE_FS);
-
-	schedule_work(&ac->work);
-	/*
-	 * Wait for the current transaction commit to start and block
-	 * subsequent transaction joins
-	 */
-	wait_event(fs_info->transaction_blocked_wait,
-		   cur_trans->state >= TRANS_STATE_COMMIT_START ||
-		   TRANS_ABORTED(cur_trans));
-	if (current->journal_info == trans)
-		current->journal_info = NULL;
-
-	btrfs_put_transaction(cur_trans);
-	return 0;
-}
-
-
 static void cleanup_transaction(struct btrfs_trans_handle *trans, int err)
 {
 	struct btrfs_fs_info *fs_info = trans->fs_info;
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h
index 0702e8d9b30e..0bdb804fddcb 100644
--- a/fs/btrfs/transaction.h
+++ b/fs/btrfs/transaction.h
@@ -226,7 +226,6 @@ void btrfs_add_dead_root(struct btrfs_root *root);
 int btrfs_defrag_root(struct btrfs_root *root);
 int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root);
 int btrfs_commit_transaction(struct btrfs_trans_handle *trans);
-int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans);
 int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans);
 bool btrfs_should_end_transaction(struct btrfs_trans_handle *trans);
 void btrfs_throttle(struct btrfs_fs_info *fs_info);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] btrfs: remove fs_info::transaction_blocked_wait
  2021-06-03 15:20 [PATCH 0/4] Slightly how START_SYNC and WAIT_SYNC work David Sterba
                   ` (2 preceding siblings ...)
  2021-06-03 15:20 ` [PATCH 3/4] btrfs: replace async commit by pending actions David Sterba
@ 2021-06-03 15:20 ` David Sterba
  2021-06-04 10:59 ` [PATCH 0/4] Slightly how START_SYNC and WAIT_SYNC work David Sterba
  4 siblings, 0 replies; 8+ messages in thread
From: David Sterba @ 2021-06-03 15:20 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Previous commit removed last use of transaction_blocked_wait. There were
still the waking call sites, that are now without use as there's nothing
populating the wait list.

As wake_up has a memory barrier semantics, it's directly replaced by
smp_mb. The transaction state TRANS_STATE_COMMIT_START is now perhaps
trivial, but there's more code relying on that, it's left in place to
keep the behaviour as close as possible to the original code.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/ctree.h       | 1 -
 fs/btrfs/disk-io.c     | 5 ++---
 fs/btrfs/super.c       | 1 -
 fs/btrfs/transaction.c | 3 ++-
 4 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index c601f6733576..384c00c982ab 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -683,7 +683,6 @@ struct btrfs_fs_info {
 	struct btrfs_transaction *running_transaction;
 	wait_queue_head_t transaction_throttle;
 	wait_queue_head_t transaction_wait;
-	wait_queue_head_t transaction_blocked_wait;
 	wait_queue_head_t async_submit_wait;
 
 	/*
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index d1d5091a8385..bad7df788458 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2986,7 +2986,6 @@ void btrfs_init_fs_info(struct btrfs_fs_info *fs_info)
 
 	init_waitqueue_head(&fs_info->transaction_throttle);
 	init_waitqueue_head(&fs_info->transaction_wait);
-	init_waitqueue_head(&fs_info->transaction_blocked_wait);
 	init_waitqueue_head(&fs_info->async_submit_wait);
 	init_waitqueue_head(&fs_info->delayed_iputs_wait);
 
@@ -4918,8 +4917,8 @@ void btrfs_cleanup_one_transaction(struct btrfs_transaction *cur_trans,
 	btrfs_destroy_delayed_refs(cur_trans, fs_info);
 
 	cur_trans->state = TRANS_STATE_COMMIT_START;
-	wake_up(&fs_info->transaction_blocked_wait);
-
+	/* Serialize state change, but there are no waiters */
+	smp_mb();
 	cur_trans->state = TRANS_STATE_UNBLOCKED;
 	wake_up(&fs_info->transaction_wait);
 
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index bc613218c8c5..8d87da2b2377 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -302,7 +302,6 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
 	WRITE_ONCE(trans->transaction->aborted, errno);
 	/* Wake up anybody who may be waiting on this transaction */
 	wake_up(&fs_info->transaction_wait);
-	wake_up(&fs_info->transaction_blocked_wait);
 	__btrfs_handle_fs_error(fs_info, function, line, errno, NULL);
 }
 /*
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 5f3c95c876c8..1fd04170b0bf 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -2057,7 +2057,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
 	}
 
 	cur_trans->state = TRANS_STATE_COMMIT_START;
-	wake_up(&fs_info->transaction_blocked_wait);
+	/* Serialize state change, but there are no waiters */
+	smp_mb();
 
 	if (cur_trans->list.prev != &fs_info->trans_list) {
 		enum btrfs_trans_state want_state = TRANS_STATE_COMPLETED;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/4] Slightly how START_SYNC and WAIT_SYNC work
  2021-06-03 15:20 [PATCH 0/4] Slightly how START_SYNC and WAIT_SYNC work David Sterba
                   ` (3 preceding siblings ...)
  2021-06-03 15:20 ` [PATCH 4/4] btrfs: remove fs_info::transaction_blocked_wait David Sterba
@ 2021-06-04 10:59 ` David Sterba
  4 siblings, 0 replies; 8+ messages in thread
From: David Sterba @ 2021-06-04 10:59 UTC (permalink / raw)
  To: David Sterba; +Cc: linux-btrfs

On Thu, Jun 03, 2021 at 05:20:19PM +0200, David Sterba wrote:
> The async transaction commit ioctl has a subtle semantics that used to
> work for ceph. We need more straightforward semantics in progs (eg. when
> waiting for commit after subvolume deletion) and otherwise the async
> commit does a few annoying things.
> 
> Long explanation is in patch 3. I hope it works, but somebody please
> double check. It's a minor change in the commit logic, but merely
> removing some waiting, no other changes in state transitions.
> 
> David Sterba (4):
>   btrfs: sink wait_for_unblock parameter to async commit
>   btrfs: inline wait_current_trans_commit_start in its caller
>   btrfs: replace async commit by pending actions
>   btrfs: remove fs_info::transaction_blocked_wait

btrfs/011 hangs so no dice. I maybe pick the two first patches as
cleanups, and the rest will go to some future dev cycle.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/4] btrfs: sink wait_for_unblock parameter to async commit
  2021-06-03 15:20 ` [PATCH 1/4] btrfs: sink wait_for_unblock parameter to async commit David Sterba
@ 2021-06-04 12:35   ` Anand Jain
  0 siblings, 0 replies; 8+ messages in thread
From: Anand Jain @ 2021-06-04 12:35 UTC (permalink / raw)
  To: David Sterba, linux-btrfs

On 3/6/21 11:20 pm, David Sterba wrote:
> There's only one caller left btrfs_ioctl_start_sync that passes 0, so we
> can remove the switch in btrfs_commit_transaction_async.
> 
> A cleanup 9babda9f33fd ("btrfs: Remove async_transid from
> btrfs_mksubvol/create_subvol/create_snapshot") removed calls that passed
> 1, so this is a followup.
> 
> As this removes last call of wait_current_trans_commit_start_and_unblock,
> remove the function as well.
> 
> Signed-off-by: David Sterba <dsterba@suse.com>

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

Thanks, Anand

> ---
>   fs/btrfs/ioctl.c       |  2 +-
>   fs/btrfs/transaction.c | 24 ++----------------------
>   fs/btrfs/transaction.h |  3 +--
>   3 files changed, 4 insertions(+), 25 deletions(-)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 2bdaf2018197..f83eb4a225cc 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -3643,7 +3643,7 @@ static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root,
>   		goto out;
>   	}
>   	transid = trans->transid;
> -	ret = btrfs_commit_transaction_async(trans, 0);
> +	ret = btrfs_commit_transaction_async(trans);
>   	if (ret) {
>   		btrfs_end_transaction(trans);
>   		return ret;
> diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
> index 22951621363f..30347e660027 100644
> --- a/fs/btrfs/transaction.c
> +++ b/fs/btrfs/transaction.c
> @@ -1882,19 +1882,6 @@ static void wait_current_trans_commit_start(struct btrfs_fs_info *fs_info,
>   		   TRANS_ABORTED(trans));
>   }
>   
> -/*
> - * wait for the current transaction to start and then become unblocked.
> - * caller holds ref.
> - */
> -static void wait_current_trans_commit_start_and_unblock(
> -					struct btrfs_fs_info *fs_info,
> -					struct btrfs_transaction *trans)
> -{
> -	wait_event(fs_info->transaction_wait,
> -		   trans->state >= TRANS_STATE_UNBLOCKED ||
> -		   TRANS_ABORTED(trans));
> -}
> -
>   /*
>    * commit transactions asynchronously. once btrfs_commit_transaction_async
>    * returns, any subsequent transaction will not be allowed to join.
> @@ -1922,8 +1909,7 @@ static void do_async_commit(struct work_struct *work)
>   	kfree(ac);
>   }
>   
> -int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans,
> -				   int wait_for_unblock)
> +int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans)
>   {
>   	struct btrfs_fs_info *fs_info = trans->fs_info;
>   	struct btrfs_async_commit *ac;
> @@ -1955,13 +1941,7 @@ int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans,
>   		__sb_writers_release(fs_info->sb, SB_FREEZE_FS);
>   
>   	schedule_work(&ac->work);
> -
> -	/* wait for transaction to start and unblock */
> -	if (wait_for_unblock)
> -		wait_current_trans_commit_start_and_unblock(fs_info, cur_trans);
> -	else
> -		wait_current_trans_commit_start(fs_info, cur_trans);
> -
> +	wait_current_trans_commit_start(fs_info, cur_trans);
>   	if (current->journal_info == trans)
>   		current->journal_info = NULL;
>   
> diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h
> index c49e2266b28b..0702e8d9b30e 100644
> --- a/fs/btrfs/transaction.h
> +++ b/fs/btrfs/transaction.h
> @@ -226,8 +226,7 @@ void btrfs_add_dead_root(struct btrfs_root *root);
>   int btrfs_defrag_root(struct btrfs_root *root);
>   int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root);
>   int btrfs_commit_transaction(struct btrfs_trans_handle *trans);
> -int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans,
> -				   int wait_for_unblock);
> +int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans);
>   int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans);
>   bool btrfs_should_end_transaction(struct btrfs_trans_handle *trans);
>   void btrfs_throttle(struct btrfs_fs_info *fs_info);
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] btrfs: inline wait_current_trans_commit_start in its caller
  2021-06-03 15:20 ` [PATCH 2/4] btrfs: inline wait_current_trans_commit_start in its caller David Sterba
@ 2021-06-04 12:37   ` Anand Jain
  0 siblings, 0 replies; 8+ messages in thread
From: Anand Jain @ 2021-06-04 12:37 UTC (permalink / raw)
  To: David Sterba, linux-btrfs

On 3/6/21 11:20 pm, David Sterba wrote:
> Function wait_current_trans_commit_start is now fairly trivial so it can
> be inlined in its only caller.
> 
> Signed-off-by: David Sterba <dsterba@suse.com>

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

Thanks, Anand

> ---
>   fs/btrfs/transaction.c | 20 +++++++-------------
>   1 file changed, 7 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
> index 30347e660027..73df8b81496e 100644
> --- a/fs/btrfs/transaction.c
> +++ b/fs/btrfs/transaction.c
> @@ -1870,18 +1870,6 @@ int btrfs_transaction_blocked(struct btrfs_fs_info *info)
>   	return ret;
>   }
>   
> -/*
> - * wait for the current transaction commit to start and block subsequent
> - * transaction joins
> - */
> -static void wait_current_trans_commit_start(struct btrfs_fs_info *fs_info,
> -					    struct btrfs_transaction *trans)
> -{
> -	wait_event(fs_info->transaction_blocked_wait,
> -		   trans->state >= TRANS_STATE_COMMIT_START ||
> -		   TRANS_ABORTED(trans));
> -}
> -
>   /*
>    * commit transactions asynchronously. once btrfs_commit_transaction_async
>    * returns, any subsequent transaction will not be allowed to join.
> @@ -1941,7 +1929,13 @@ int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans)
>   		__sb_writers_release(fs_info->sb, SB_FREEZE_FS);
>   
>   	schedule_work(&ac->work);
> -	wait_current_trans_commit_start(fs_info, cur_trans);
> +	/*
> +	 * Wait for the current transaction commit to start and block
> +	 * subsequent transaction joins
> +	 */
> +	wait_event(fs_info->transaction_blocked_wait,
> +		   cur_trans->state >= TRANS_STATE_COMMIT_START ||
> +		   TRANS_ABORTED(cur_trans));
>   	if (current->journal_info == trans)
>   		current->journal_info = NULL;
>   
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-06-04 12:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-03 15:20 [PATCH 0/4] Slightly how START_SYNC and WAIT_SYNC work David Sterba
2021-06-03 15:20 ` [PATCH 1/4] btrfs: sink wait_for_unblock parameter to async commit David Sterba
2021-06-04 12:35   ` Anand Jain
2021-06-03 15:20 ` [PATCH 2/4] btrfs: inline wait_current_trans_commit_start in its caller David Sterba
2021-06-04 12:37   ` Anand Jain
2021-06-03 15:20 ` [PATCH 3/4] btrfs: replace async commit by pending actions David Sterba
2021-06-03 15:20 ` [PATCH 4/4] btrfs: remove fs_info::transaction_blocked_wait David Sterba
2021-06-04 10:59 ` [PATCH 0/4] Slightly how START_SYNC and WAIT_SYNC work David Sterba

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.