All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Finally remove userspace transaction support
@ 2018-01-10 13:21 Nikolay Borisov
  2018-01-10 13:21 ` [PATCH 1/4] btrfs: Remove userspace transaction ioctls Nikolay Borisov
                   ` (7 more replies)
  0 siblings, 8 replies; 25+ messages in thread
From: Nikolay Borisov @ 2018-01-10 13:21 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

Userspace transaction were initially added to he benefit of Ceph, however 
in recent times it became clear that btrfs is not suitable for Ceph's workload
and has even been actively discoured. Additionaly, the userspace transaction
mechanism has always been a sort of a hack, which could easily lead to a 
deadlock unless care is taken. 

All things considered there is no point in keeping the code around. Userspace
transaction interface was deprecated in kernel version 4.14. Now it's time to 
completely remove it in 4.17. 

The first patch removes the ioctl-related code. Following patches just deal 
with unused functions/values following ioctl removal. 

Nikolay Borisov (4):
  btrfs: Remove userspace transaction ioctls
  btrfs: Remove code referencing unused TRANS_USERSPACE
  btrfs: Remove transaction handle from btrfs_file_private
  btrfs: Remove btrfs_fs_info::open_ioctl_trans

 fs/btrfs/ctree.h       |  2 --
 fs/btrfs/extent-tree.c |  3 +-
 fs/btrfs/file.c        |  2 --
 fs/btrfs/ioctl.c       | 95 --------------------------------------------------
 fs/btrfs/transaction.c | 36 +++++--------------
 fs/btrfs/transaction.h |  5 +--
 6 files changed, 11 insertions(+), 132 deletions(-)

-- 
2.7.4


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

* [PATCH 1/4] btrfs: Remove userspace transaction ioctls
  2018-01-10 13:21 [PATCH 0/4] Finally remove userspace transaction support Nikolay Borisov
@ 2018-01-10 13:21 ` Nikolay Borisov
  2018-01-10 13:37   ` [PATCH v2] " Nikolay Borisov
  2018-01-10 13:40   ` [PATCH v3] " Nikolay Borisov
  2018-01-10 13:21 ` [PATCH 2/4] btrfs: Remove code referencing unused TRANS_USERSPACE Nikolay Borisov
                   ` (6 subsequent siblings)
  7 siblings, 2 replies; 25+ messages in thread
From: Nikolay Borisov @ 2018-01-10 13:21 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

Commit 3558d4f88ec8 ("btrfs: Deprecate userspace transaction ioctls")
marked the beginning of the end of userspace transaction. This commit
finishes the job!
---
 fs/btrfs/ioctl.c | 95 --------------------------------------------------------
 1 file changed, 95 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index f573cad72b7e..3094e079fc4f 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3935,73 +3935,6 @@ int btrfs_clone_file_range(struct file *src_file, loff_t off,
 	return btrfs_clone_files(dst_file, src_file, off, len, destoff);
 }
 
-/*
- * there are many ways the trans_start and trans_end ioctls can lead
- * to deadlocks.  They should only be used by applications that
- * basically own the machine, and have a very in depth understanding
- * of all the possible deadlocks and enospc problems.
- */
-static long btrfs_ioctl_trans_start(struct file *file)
-{
-	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
-	struct btrfs_root *root = BTRFS_I(inode)->root;
-	struct btrfs_trans_handle *trans;
-	struct btrfs_file_private *private;
-	int ret;
-	static bool warned = false;
-
-	ret = -EPERM;
-	if (!capable(CAP_SYS_ADMIN))
-		goto out;
-
-	if (!warned) {
-		btrfs_warn(fs_info,
-			"Userspace transaction mechanism is considered "
-			"deprecated and slated to be removed in 4.17. "
-			"If you have a valid use case please "
-			"speak up on the mailing list");
-		WARN_ON(1);
-		warned = true;
-	}
-
-	ret = -EINPROGRESS;
-	private = file->private_data;
-	if (private && private->trans)
-		goto out;
-	if (!private) {
-		private = kzalloc(sizeof(struct btrfs_file_private),
-				  GFP_KERNEL);
-		if (!private)
-			return -ENOMEM;
-		file->private_data = private;
-	}
-
-	ret = -EROFS;
-	if (btrfs_root_readonly(root))
-		goto out;
-
-	ret = mnt_want_write_file(file);
-	if (ret)
-		goto out;
-
-	atomic_inc(&fs_info->open_ioctl_trans);
-
-	ret = -ENOMEM;
-	trans = btrfs_start_ioctl_transaction(root);
-	if (IS_ERR(trans))
-		goto out_drop;
-
-	private->trans = trans;
-	return 0;
-
-out_drop:
-	atomic_dec(&fs_info->open_ioctl_trans);
-	mnt_drop_write_file(file);
-out:
-	return ret;
-}
-
 static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
 {
 	struct inode *inode = file_inode(file);
@@ -4243,30 +4176,6 @@ static long btrfs_ioctl_space_info(struct btrfs_fs_info *fs_info,
 	return ret;
 }
 
-/*
- * there are many ways the trans_start and trans_end ioctls can lead
- * to deadlocks.  They should only be used by applications that
- * basically own the machine, and have a very in depth understanding
- * of all the possible deadlocks and enospc problems.
- */
-long btrfs_ioctl_trans_end(struct file *file)
-{
-	struct inode *inode = file_inode(file);
-	struct btrfs_root *root = BTRFS_I(inode)->root;
-	struct btrfs_file_private *private = file->private_data;
-
-	if (!private || !private->trans)
-		return -EINVAL;
-
-	btrfs_end_transaction(private->trans);
-	private->trans = NULL;
-
-	atomic_dec(&root->fs_info->open_ioctl_trans);
-
-	mnt_drop_write_file(file);
-	return 0;
-}
-
 static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root,
 					    void __user *argp)
 {
@@ -5573,10 +5482,6 @@ long btrfs_ioctl(struct file *file, unsigned int
 		return btrfs_ioctl_dev_info(fs_info, argp);
 	case BTRFS_IOC_BALANCE:
 		return btrfs_ioctl_balance(file, NULL);
-	case BTRFS_IOC_TRANS_START:
-		return btrfs_ioctl_trans_start(file);
-	case BTRFS_IOC_TRANS_END:
-		return btrfs_ioctl_trans_end(file);
 	case BTRFS_IOC_TREE_SEARCH:
 		return btrfs_ioctl_tree_search(file, argp);
 	case BTRFS_IOC_TREE_SEARCH_V2:
-- 
2.7.4


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

* [PATCH 2/4] btrfs: Remove code referencing unused TRANS_USERSPACE
  2018-01-10 13:21 [PATCH 0/4] Finally remove userspace transaction support Nikolay Borisov
  2018-01-10 13:21 ` [PATCH 1/4] btrfs: Remove userspace transaction ioctls Nikolay Borisov
@ 2018-01-10 13:21 ` Nikolay Borisov
  2018-01-10 13:21 ` [PATCH 3/4] btrfs: Remove transaction handle from btrfs_file_private Nikolay Borisov
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 25+ messages in thread
From: Nikolay Borisov @ 2018-01-10 13:21 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

Now that the userspace transaction ioctls have been removed,
TRANS_USERSPACE is no longer used hence we can remove it.
---
 fs/btrfs/transaction.c | 27 ++++++---------------------
 fs/btrfs/transaction.h |  5 +----
 2 files changed, 7 insertions(+), 25 deletions(-)

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 04f07144b45c..d61d1fd59ccd 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -37,22 +37,16 @@
 
 static const unsigned int btrfs_blocked_trans_types[TRANS_STATE_MAX] = {
 	[TRANS_STATE_RUNNING]		= 0U,
-	[TRANS_STATE_BLOCKED]		= (__TRANS_USERSPACE |
-					   __TRANS_START),
-	[TRANS_STATE_COMMIT_START]	= (__TRANS_USERSPACE |
-					   __TRANS_START |
-					   __TRANS_ATTACH),
-	[TRANS_STATE_COMMIT_DOING]	= (__TRANS_USERSPACE |
-					   __TRANS_START |
+	[TRANS_STATE_BLOCKED]		=  __TRANS_START,
+	[TRANS_STATE_COMMIT_START]	= (__TRANS_START | __TRANS_ATTACH),
+	[TRANS_STATE_COMMIT_DOING]	= (__TRANS_START |
 					   __TRANS_ATTACH |
 					   __TRANS_JOIN),
-	[TRANS_STATE_UNBLOCKED]		= (__TRANS_USERSPACE |
-					   __TRANS_START |
+	[TRANS_STATE_UNBLOCKED]		= (__TRANS_START |
 					   __TRANS_ATTACH |
 					   __TRANS_JOIN |
 					   __TRANS_JOIN_NOLOCK),
-	[TRANS_STATE_COMPLETED]		= (__TRANS_USERSPACE |
-					   __TRANS_START |
+	[TRANS_STATE_COMPLETED]		= (__TRANS_START |
 					   __TRANS_ATTACH |
 					   __TRANS_JOIN |
 					   __TRANS_JOIN_NOLOCK),
@@ -449,9 +443,6 @@ static int may_wait_transaction(struct btrfs_fs_info *fs_info, int type)
 	if (test_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags))
 		return 0;
 
-	if (type == TRANS_USERSPACE)
-		return 1;
-
 	if (type == TRANS_START &&
 	    !atomic_read(&fs_info->open_ioctl_trans))
 		return 1;
@@ -593,7 +584,7 @@ start_transaction(struct btrfs_root *root, unsigned int num_items,
 got_it:
 	btrfs_record_root_in_trans(h, root);
 
-	if (!current->journal_info && type != TRANS_USERSPACE)
+	if (!current->journal_info)
 		current->journal_info = h;
 	return h;
 
@@ -678,12 +669,6 @@ struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root
 				 BTRFS_RESERVE_NO_FLUSH, true);
 }
 
-struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root)
-{
-	return start_transaction(root, 0, TRANS_USERSPACE,
-				 BTRFS_RESERVE_NO_FLUSH, true);
-}
-
 /*
  * btrfs_attach_transaction() - catch the running transaction
  *
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h
index 6beee072b1bd..8bc25c7cca7b 100644
--- a/fs/btrfs/transaction.h
+++ b/fs/btrfs/transaction.h
@@ -89,21 +89,18 @@ struct btrfs_transaction {
 
 #define __TRANS_FREEZABLE	(1U << 0)
 
-#define __TRANS_USERSPACE	(1U << 8)
 #define __TRANS_START		(1U << 9)
 #define __TRANS_ATTACH		(1U << 10)
 #define __TRANS_JOIN		(1U << 11)
 #define __TRANS_JOIN_NOLOCK	(1U << 12)
 #define __TRANS_DUMMY		(1U << 13)
 
-#define TRANS_USERSPACE		(__TRANS_USERSPACE | __TRANS_FREEZABLE)
 #define TRANS_START		(__TRANS_START | __TRANS_FREEZABLE)
 #define TRANS_ATTACH		(__TRANS_ATTACH)
 #define TRANS_JOIN		(__TRANS_JOIN | __TRANS_FREEZABLE)
 #define TRANS_JOIN_NOLOCK	(__TRANS_JOIN_NOLOCK)
 
-#define TRANS_EXTWRITERS	(__TRANS_USERSPACE | __TRANS_START |	\
-				 __TRANS_ATTACH)
+#define TRANS_EXTWRITERS	(__TRANS_START | __TRANS_ATTACH)
 
 #define BTRFS_SEND_TRANS_STUB	((void *)1)
 
-- 
2.7.4


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

* [PATCH 3/4] btrfs: Remove transaction handle from btrfs_file_private
  2018-01-10 13:21 [PATCH 0/4] Finally remove userspace transaction support Nikolay Borisov
  2018-01-10 13:21 ` [PATCH 1/4] btrfs: Remove userspace transaction ioctls Nikolay Borisov
  2018-01-10 13:21 ` [PATCH 2/4] btrfs: Remove code referencing unused TRANS_USERSPACE Nikolay Borisov
@ 2018-01-10 13:21 ` Nikolay Borisov
  2018-01-10 13:21 ` [PATCH 4/4] btrfs: Remove btrfs_fs_info::open_ioctl_trans Nikolay Borisov
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 25+ messages in thread
From: Nikolay Borisov @ 2018-01-10 13:21 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

Since we no longer support userspace transaction there is no need to
keep this member variable, so remove it.
---
 fs/btrfs/ctree.h | 1 -
 fs/btrfs/file.c  | 2 --
 2 files changed, 3 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 1a462ab85c49..a3911d86bab9 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1265,7 +1265,6 @@ struct btrfs_root {
 };
 
 struct btrfs_file_private {
-	struct btrfs_trans_handle *trans;
 	void *filldir_buf;
 };
 
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index cba2ac371ce0..5638b85a570f 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1996,8 +1996,6 @@ int btrfs_release_file(struct inode *inode, struct file *filp)
 {
 	struct btrfs_file_private *private = filp->private_data;
 
-	if (private && private->trans)
-		btrfs_ioctl_trans_end(filp);
 	if (private && private->filldir_buf)
 		kfree(private->filldir_buf);
 	kfree(private);
-- 
2.7.4


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

* [PATCH 4/4] btrfs: Remove btrfs_fs_info::open_ioctl_trans
  2018-01-10 13:21 [PATCH 0/4] Finally remove userspace transaction support Nikolay Borisov
                   ` (2 preceding siblings ...)
  2018-01-10 13:21 ` [PATCH 3/4] btrfs: Remove transaction handle from btrfs_file_private Nikolay Borisov
@ 2018-01-10 13:21 ` Nikolay Borisov
  2018-01-10 15:47 ` [PATCH 0/4] Finally remove userspace transaction support Josef Bacik
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 25+ messages in thread
From: Nikolay Borisov @ 2018-01-10 13:21 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

Since userspace transaction have been removed we no longer have use
for this field so delete it.
---
 fs/btrfs/ctree.h       | 1 -
 fs/btrfs/extent-tree.c | 3 +--
 fs/btrfs/transaction.c | 9 +++------
 3 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index a3911d86bab9..1d7dd7cb4989 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -877,7 +877,6 @@ struct btrfs_fs_info {
 	struct rb_root tree_mod_log;
 
 	atomic_t async_delalloc_pages;
-	atomic_t open_ioctl_trans;
 
 	/*
 	 * this is used to protect the following list -- ordered_roots.
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 8d51e4bb67c1..dcb059a46b77 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4329,8 +4329,7 @@ int btrfs_alloc_data_chunk_ondemand(struct btrfs_inode *inode, u64 bytes)
 
 		/* commit the current transaction and try again */
 commit_trans:
-		if (need_commit &&
-		    !atomic_read(&fs_info->open_ioctl_trans)) {
+		if (need_commit) {
 			need_commit--;
 
 			if (need_commit > 0) {
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index d61d1fd59ccd..c5ef42318058 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -443,8 +443,7 @@ static int may_wait_transaction(struct btrfs_fs_info *fs_info, int type)
 	if (test_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags))
 		return 0;
 
-	if (type == TRANS_START &&
-	    !atomic_read(&fs_info->open_ioctl_trans))
+	if (type == TRANS_START)
 		return 1;
 
 	return 0;
@@ -774,8 +773,7 @@ int btrfs_wait_for_commit(struct btrfs_fs_info *fs_info, u64 transid)
 
 void btrfs_throttle(struct btrfs_fs_info *fs_info)
 {
-	if (!atomic_read(&fs_info->open_ioctl_trans))
-		wait_current_trans(fs_info);
+	wait_current_trans(fs_info);
 }
 
 static int should_end_transaction(struct btrfs_trans_handle *trans)
@@ -857,8 +855,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
 
 	btrfs_trans_release_chunk_metadata(trans);
 
-	if (lock && !atomic_read(&info->open_ioctl_trans) &&
-	    should_end_transaction(trans) &&
+	if (lock && should_end_transaction(trans) &&
 	    READ_ONCE(cur_trans->state) == TRANS_STATE_RUNNING) {
 		spin_lock(&info->trans_lock);
 		if (cur_trans->state == TRANS_STATE_RUNNING)
-- 
2.7.4


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

* [PATCH v2] btrfs: Remove userspace transaction ioctls
  2018-01-10 13:21 ` [PATCH 1/4] btrfs: Remove userspace transaction ioctls Nikolay Borisov
@ 2018-01-10 13:37   ` Nikolay Borisov
  2018-01-10 13:40   ` [PATCH v3] " Nikolay Borisov
  1 sibling, 0 replies; 25+ messages in thread
From: Nikolay Borisov @ 2018-01-10 13:37 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

Commit 3558d4f88ec8 ("btrfs: Deprecate userspace transaction ioctls")
marked the beginning of the end of userspace transaction. This commit
finishes the job!

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---

V2: 
 Remove btrfs_ioctl_trans_end reference in btrfs_sync_fil

 fs/btrfs/file.c  |  6 ----
 fs/btrfs/ioctl.c | 95 --------------------------------------------------------
 2 files changed, 101 deletions(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index cba2ac371ce0..291036513017 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2189,12 +2189,6 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 	}
 
 	/*
-	 * ok we haven't committed the transaction yet, lets do a commit
-	 */
-	if (file->private_data)
-		btrfs_ioctl_trans_end(file);
-
-	/*
 	 * We use start here because we will need to wait on the IO to complete
 	 * in btrfs_sync_log, which could require joining a transaction (for
 	 * example checking cross references in the nocow path).  If we use join
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index f573cad72b7e..3094e079fc4f 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3935,73 +3935,6 @@ int btrfs_clone_file_range(struct file *src_file, loff_t off,
 	return btrfs_clone_files(dst_file, src_file, off, len, destoff);
 }
 
-/*
- * there are many ways the trans_start and trans_end ioctls can lead
- * to deadlocks.  They should only be used by applications that
- * basically own the machine, and have a very in depth understanding
- * of all the possible deadlocks and enospc problems.
- */
-static long btrfs_ioctl_trans_start(struct file *file)
-{
-	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
-	struct btrfs_root *root = BTRFS_I(inode)->root;
-	struct btrfs_trans_handle *trans;
-	struct btrfs_file_private *private;
-	int ret;
-	static bool warned = false;
-
-	ret = -EPERM;
-	if (!capable(CAP_SYS_ADMIN))
-		goto out;
-
-	if (!warned) {
-		btrfs_warn(fs_info,
-			"Userspace transaction mechanism is considered "
-			"deprecated and slated to be removed in 4.17. "
-			"If you have a valid use case please "
-			"speak up on the mailing list");
-		WARN_ON(1);
-		warned = true;
-	}
-
-	ret = -EINPROGRESS;
-	private = file->private_data;
-	if (private && private->trans)
-		goto out;
-	if (!private) {
-		private = kzalloc(sizeof(struct btrfs_file_private),
-				  GFP_KERNEL);
-		if (!private)
-			return -ENOMEM;
-		file->private_data = private;
-	}
-
-	ret = -EROFS;
-	if (btrfs_root_readonly(root))
-		goto out;
-
-	ret = mnt_want_write_file(file);
-	if (ret)
-		goto out;
-
-	atomic_inc(&fs_info->open_ioctl_trans);
-
-	ret = -ENOMEM;
-	trans = btrfs_start_ioctl_transaction(root);
-	if (IS_ERR(trans))
-		goto out_drop;
-
-	private->trans = trans;
-	return 0;
-
-out_drop:
-	atomic_dec(&fs_info->open_ioctl_trans);
-	mnt_drop_write_file(file);
-out:
-	return ret;
-}
-
 static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
 {
 	struct inode *inode = file_inode(file);
@@ -4243,30 +4176,6 @@ static long btrfs_ioctl_space_info(struct btrfs_fs_info *fs_info,
 	return ret;
 }
 
-/*
- * there are many ways the trans_start and trans_end ioctls can lead
- * to deadlocks.  They should only be used by applications that
- * basically own the machine, and have a very in depth understanding
- * of all the possible deadlocks and enospc problems.
- */
-long btrfs_ioctl_trans_end(struct file *file)
-{
-	struct inode *inode = file_inode(file);
-	struct btrfs_root *root = BTRFS_I(inode)->root;
-	struct btrfs_file_private *private = file->private_data;
-
-	if (!private || !private->trans)
-		return -EINVAL;
-
-	btrfs_end_transaction(private->trans);
-	private->trans = NULL;
-
-	atomic_dec(&root->fs_info->open_ioctl_trans);
-
-	mnt_drop_write_file(file);
-	return 0;
-}
-
 static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root,
 					    void __user *argp)
 {
@@ -5573,10 +5482,6 @@ long btrfs_ioctl(struct file *file, unsigned int
 		return btrfs_ioctl_dev_info(fs_info, argp);
 	case BTRFS_IOC_BALANCE:
 		return btrfs_ioctl_balance(file, NULL);
-	case BTRFS_IOC_TRANS_START:
-		return btrfs_ioctl_trans_start(file);
-	case BTRFS_IOC_TRANS_END:
-		return btrfs_ioctl_trans_end(file);
 	case BTRFS_IOC_TREE_SEARCH:
 		return btrfs_ioctl_tree_search(file, argp);
 	case BTRFS_IOC_TREE_SEARCH_V2:
-- 
2.7.4


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

* [PATCH v3] btrfs: Remove userspace transaction ioctls
  2018-01-10 13:21 ` [PATCH 1/4] btrfs: Remove userspace transaction ioctls Nikolay Borisov
  2018-01-10 13:37   ` [PATCH v2] " Nikolay Borisov
@ 2018-01-10 13:40   ` Nikolay Borisov
  1 sibling, 0 replies; 25+ messages in thread
From: Nikolay Borisov @ 2018-01-10 13:40 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

Commit 3558d4f88ec8 ("btrfs: Deprecate userspace transaction ioctls")
marked the beginning of the end of userspace transaction. This commit
finishes the job!

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
V3: 
 Remove btrfs_ioctl_trans_end declaration in ctree.h 
V2: 
 Remove btrfs_ioctl_trans_end reference in btrfs_sync_fil
 fs/btrfs/ctree.h |  1 -
 fs/btrfs/file.c  |  6 ----
 fs/btrfs/ioctl.c | 95 --------------------------------------------------------
 3 files changed, 102 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 1a462ab85c49..6a4752177ad8 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3193,7 +3193,6 @@ void btrfs_destroy_inode(struct inode *inode);
 int btrfs_drop_inode(struct inode *inode);
 int __init btrfs_init_cachep(void);
 void btrfs_destroy_cachep(void);
-long btrfs_ioctl_trans_end(struct file *file);
 struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location,
 			 struct btrfs_root *root, int *was_new);
 struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index cba2ac371ce0..291036513017 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2189,12 +2189,6 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 	}
 
 	/*
-	 * ok we haven't committed the transaction yet, lets do a commit
-	 */
-	if (file->private_data)
-		btrfs_ioctl_trans_end(file);
-
-	/*
 	 * We use start here because we will need to wait on the IO to complete
 	 * in btrfs_sync_log, which could require joining a transaction (for
 	 * example checking cross references in the nocow path).  If we use join
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index f573cad72b7e..3094e079fc4f 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3935,73 +3935,6 @@ int btrfs_clone_file_range(struct file *src_file, loff_t off,
 	return btrfs_clone_files(dst_file, src_file, off, len, destoff);
 }
 
-/*
- * there are many ways the trans_start and trans_end ioctls can lead
- * to deadlocks.  They should only be used by applications that
- * basically own the machine, and have a very in depth understanding
- * of all the possible deadlocks and enospc problems.
- */
-static long btrfs_ioctl_trans_start(struct file *file)
-{
-	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
-	struct btrfs_root *root = BTRFS_I(inode)->root;
-	struct btrfs_trans_handle *trans;
-	struct btrfs_file_private *private;
-	int ret;
-	static bool warned = false;
-
-	ret = -EPERM;
-	if (!capable(CAP_SYS_ADMIN))
-		goto out;
-
-	if (!warned) {
-		btrfs_warn(fs_info,
-			"Userspace transaction mechanism is considered "
-			"deprecated and slated to be removed in 4.17. "
-			"If you have a valid use case please "
-			"speak up on the mailing list");
-		WARN_ON(1);
-		warned = true;
-	}
-
-	ret = -EINPROGRESS;
-	private = file->private_data;
-	if (private && private->trans)
-		goto out;
-	if (!private) {
-		private = kzalloc(sizeof(struct btrfs_file_private),
-				  GFP_KERNEL);
-		if (!private)
-			return -ENOMEM;
-		file->private_data = private;
-	}
-
-	ret = -EROFS;
-	if (btrfs_root_readonly(root))
-		goto out;
-
-	ret = mnt_want_write_file(file);
-	if (ret)
-		goto out;
-
-	atomic_inc(&fs_info->open_ioctl_trans);
-
-	ret = -ENOMEM;
-	trans = btrfs_start_ioctl_transaction(root);
-	if (IS_ERR(trans))
-		goto out_drop;
-
-	private->trans = trans;
-	return 0;
-
-out_drop:
-	atomic_dec(&fs_info->open_ioctl_trans);
-	mnt_drop_write_file(file);
-out:
-	return ret;
-}
-
 static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
 {
 	struct inode *inode = file_inode(file);
@@ -4243,30 +4176,6 @@ static long btrfs_ioctl_space_info(struct btrfs_fs_info *fs_info,
 	return ret;
 }
 
-/*
- * there are many ways the trans_start and trans_end ioctls can lead
- * to deadlocks.  They should only be used by applications that
- * basically own the machine, and have a very in depth understanding
- * of all the possible deadlocks and enospc problems.
- */
-long btrfs_ioctl_trans_end(struct file *file)
-{
-	struct inode *inode = file_inode(file);
-	struct btrfs_root *root = BTRFS_I(inode)->root;
-	struct btrfs_file_private *private = file->private_data;
-
-	if (!private || !private->trans)
-		return -EINVAL;
-
-	btrfs_end_transaction(private->trans);
-	private->trans = NULL;
-
-	atomic_dec(&root->fs_info->open_ioctl_trans);
-
-	mnt_drop_write_file(file);
-	return 0;
-}
-
 static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root,
 					    void __user *argp)
 {
@@ -5573,10 +5482,6 @@ long btrfs_ioctl(struct file *file, unsigned int
 		return btrfs_ioctl_dev_info(fs_info, argp);
 	case BTRFS_IOC_BALANCE:
 		return btrfs_ioctl_balance(file, NULL);
-	case BTRFS_IOC_TRANS_START:
-		return btrfs_ioctl_trans_start(file);
-	case BTRFS_IOC_TRANS_END:
-		return btrfs_ioctl_trans_end(file);
 	case BTRFS_IOC_TREE_SEARCH:
 		return btrfs_ioctl_tree_search(file, argp);
 	case BTRFS_IOC_TREE_SEARCH_V2:
-- 
2.7.4


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

* Re: [PATCH 0/4] Finally remove userspace transaction support
  2018-01-10 13:21 [PATCH 0/4] Finally remove userspace transaction support Nikolay Borisov
                   ` (3 preceding siblings ...)
  2018-01-10 13:21 ` [PATCH 4/4] btrfs: Remove btrfs_fs_info::open_ioctl_trans Nikolay Borisov
@ 2018-01-10 15:47 ` Josef Bacik
  2018-01-10 16:26 ` David Sterba
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 25+ messages in thread
From: Josef Bacik @ 2018-01-10 15:47 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: linux-btrfs

On Wed, Jan 10, 2018 at 03:21:13PM +0200, Nikolay Borisov wrote:
> Userspace transaction were initially added to he benefit of Ceph, however 
> in recent times it became clear that btrfs is not suitable for Ceph's workload
> and has even been actively discoured. Additionaly, the userspace transaction
> mechanism has always been a sort of a hack, which could easily lead to a 
> deadlock unless care is taken. 
> 
> All things considered there is no point in keeping the code around. Userspace
> transaction interface was deprecated in kernel version 4.14. Now it's time to 
> completely remove it in 4.17. 
> 
> The first patch removes the ioctl-related code. Following patches just deal 
> with unused functions/values following ioctl removal. 
> 

Reviewed-by: Josef Bacik <jbacik@fb.com>

for the whole series.  Thanks,

Josef

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

* Re: [PATCH 0/4] Finally remove userspace transaction support
  2018-01-10 13:21 [PATCH 0/4] Finally remove userspace transaction support Nikolay Borisov
                   ` (4 preceding siblings ...)
  2018-01-10 15:47 ` [PATCH 0/4] Finally remove userspace transaction support Josef Bacik
@ 2018-01-10 16:26 ` David Sterba
  2018-01-10 16:32 ` [PATCH RESEND 1/4] btrfs: Remove userspace transaction ioctls Nikolay Borisov
  2018-02-05  8:41 ` [PATCH v2 " Nikolay Borisov
  7 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2018-01-10 16:26 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: linux-btrfs

On Wed, Jan 10, 2018 at 03:21:13PM +0200, Nikolay Borisov wrote:
> Userspace transaction were initially added to he benefit of Ceph, however 
> in recent times it became clear that btrfs is not suitable for Ceph's workload
> and has even been actively discoured. Additionaly, the userspace transaction
> mechanism has always been a sort of a hack, which could easily lead to a 
> deadlock unless care is taken. 
> 
> All things considered there is no point in keeping the code around. Userspace
> transaction interface was deprecated in kernel version 4.14. Now it's time to 
> completely remove it in 4.17. 
> 
> The first patch removes the ioctl-related code. Following patches just deal 
> with unused functions/values following ioctl removal. 
> 
> Nikolay Borisov (4):
>   btrfs: Remove userspace transaction ioctls
>   btrfs: Remove code referencing unused TRANS_USERSPACE
>   btrfs: Remove transaction handle from btrfs_file_private
>   btrfs: Remove btrfs_fs_info::open_ioctl_trans

Please resend and add the missing Signed-off-by lines.

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

* [PATCH RESEND 1/4] btrfs: Remove userspace transaction ioctls
  2018-01-10 13:21 [PATCH 0/4] Finally remove userspace transaction support Nikolay Borisov
                   ` (5 preceding siblings ...)
  2018-01-10 16:26 ` David Sterba
@ 2018-01-10 16:32 ` Nikolay Borisov
  2018-01-10 16:32   ` [PATCH RESEND 2/4] btrfs: Remove code referencing unused TRANS_USERSPACE Nikolay Borisov
                     ` (4 more replies)
  2018-02-05  8:41 ` [PATCH v2 " Nikolay Borisov
  7 siblings, 5 replies; 25+ messages in thread
From: Nikolay Borisov @ 2018-01-10 16:32 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

Commit 3558d4f88ec8 ("btrfs: Deprecate userspace transaction ioctls")
marked the beginning of the end of userspace transaction. This commit
finishes the job!

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/ctree.h |  1 -
 fs/btrfs/file.c  |  6 ----
 fs/btrfs/ioctl.c | 95 --------------------------------------------------------
 3 files changed, 102 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 1a462ab85c49..6a4752177ad8 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3193,7 +3193,6 @@ void btrfs_destroy_inode(struct inode *inode);
 int btrfs_drop_inode(struct inode *inode);
 int __init btrfs_init_cachep(void);
 void btrfs_destroy_cachep(void);
-long btrfs_ioctl_trans_end(struct file *file);
 struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location,
 			 struct btrfs_root *root, int *was_new);
 struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index cba2ac371ce0..291036513017 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2189,12 +2189,6 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 	}
 
 	/*
-	 * ok we haven't committed the transaction yet, lets do a commit
-	 */
-	if (file->private_data)
-		btrfs_ioctl_trans_end(file);
-
-	/*
 	 * We use start here because we will need to wait on the IO to complete
 	 * in btrfs_sync_log, which could require joining a transaction (for
 	 * example checking cross references in the nocow path).  If we use join
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index f573cad72b7e..3094e079fc4f 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3935,73 +3935,6 @@ int btrfs_clone_file_range(struct file *src_file, loff_t off,
 	return btrfs_clone_files(dst_file, src_file, off, len, destoff);
 }
 
-/*
- * there are many ways the trans_start and trans_end ioctls can lead
- * to deadlocks.  They should only be used by applications that
- * basically own the machine, and have a very in depth understanding
- * of all the possible deadlocks and enospc problems.
- */
-static long btrfs_ioctl_trans_start(struct file *file)
-{
-	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
-	struct btrfs_root *root = BTRFS_I(inode)->root;
-	struct btrfs_trans_handle *trans;
-	struct btrfs_file_private *private;
-	int ret;
-	static bool warned = false;
-
-	ret = -EPERM;
-	if (!capable(CAP_SYS_ADMIN))
-		goto out;
-
-	if (!warned) {
-		btrfs_warn(fs_info,
-			"Userspace transaction mechanism is considered "
-			"deprecated and slated to be removed in 4.17. "
-			"If you have a valid use case please "
-			"speak up on the mailing list");
-		WARN_ON(1);
-		warned = true;
-	}
-
-	ret = -EINPROGRESS;
-	private = file->private_data;
-	if (private && private->trans)
-		goto out;
-	if (!private) {
-		private = kzalloc(sizeof(struct btrfs_file_private),
-				  GFP_KERNEL);
-		if (!private)
-			return -ENOMEM;
-		file->private_data = private;
-	}
-
-	ret = -EROFS;
-	if (btrfs_root_readonly(root))
-		goto out;
-
-	ret = mnt_want_write_file(file);
-	if (ret)
-		goto out;
-
-	atomic_inc(&fs_info->open_ioctl_trans);
-
-	ret = -ENOMEM;
-	trans = btrfs_start_ioctl_transaction(root);
-	if (IS_ERR(trans))
-		goto out_drop;
-
-	private->trans = trans;
-	return 0;
-
-out_drop:
-	atomic_dec(&fs_info->open_ioctl_trans);
-	mnt_drop_write_file(file);
-out:
-	return ret;
-}
-
 static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
 {
 	struct inode *inode = file_inode(file);
@@ -4243,30 +4176,6 @@ static long btrfs_ioctl_space_info(struct btrfs_fs_info *fs_info,
 	return ret;
 }
 
-/*
- * there are many ways the trans_start and trans_end ioctls can lead
- * to deadlocks.  They should only be used by applications that
- * basically own the machine, and have a very in depth understanding
- * of all the possible deadlocks and enospc problems.
- */
-long btrfs_ioctl_trans_end(struct file *file)
-{
-	struct inode *inode = file_inode(file);
-	struct btrfs_root *root = BTRFS_I(inode)->root;
-	struct btrfs_file_private *private = file->private_data;
-
-	if (!private || !private->trans)
-		return -EINVAL;
-
-	btrfs_end_transaction(private->trans);
-	private->trans = NULL;
-
-	atomic_dec(&root->fs_info->open_ioctl_trans);
-
-	mnt_drop_write_file(file);
-	return 0;
-}
-
 static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root,
 					    void __user *argp)
 {
@@ -5573,10 +5482,6 @@ long btrfs_ioctl(struct file *file, unsigned int
 		return btrfs_ioctl_dev_info(fs_info, argp);
 	case BTRFS_IOC_BALANCE:
 		return btrfs_ioctl_balance(file, NULL);
-	case BTRFS_IOC_TRANS_START:
-		return btrfs_ioctl_trans_start(file);
-	case BTRFS_IOC_TRANS_END:
-		return btrfs_ioctl_trans_end(file);
 	case BTRFS_IOC_TREE_SEARCH:
 		return btrfs_ioctl_tree_search(file, argp);
 	case BTRFS_IOC_TREE_SEARCH_V2:
-- 
2.7.4


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

* [PATCH RESEND 2/4] btrfs: Remove code referencing unused TRANS_USERSPACE
  2018-01-10 16:32 ` [PATCH RESEND 1/4] btrfs: Remove userspace transaction ioctls Nikolay Borisov
@ 2018-01-10 16:32   ` Nikolay Borisov
  2018-02-02 17:40     ` David Sterba
  2018-01-10 16:32   ` [PATCH RESEND 3/4] btrfs: Remove transaction handle from btrfs_file_private Nikolay Borisov
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 25+ messages in thread
From: Nikolay Borisov @ 2018-01-10 16:32 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

Now that the userspace transaction ioctls have been removed,
TRANS_USERSPACE is no longer used hence we can remove it.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/transaction.c | 27 ++++++---------------------
 fs/btrfs/transaction.h |  5 +----
 2 files changed, 7 insertions(+), 25 deletions(-)

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 04f07144b45c..d61d1fd59ccd 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -37,22 +37,16 @@
 
 static const unsigned int btrfs_blocked_trans_types[TRANS_STATE_MAX] = {
 	[TRANS_STATE_RUNNING]		= 0U,
-	[TRANS_STATE_BLOCKED]		= (__TRANS_USERSPACE |
-					   __TRANS_START),
-	[TRANS_STATE_COMMIT_START]	= (__TRANS_USERSPACE |
-					   __TRANS_START |
-					   __TRANS_ATTACH),
-	[TRANS_STATE_COMMIT_DOING]	= (__TRANS_USERSPACE |
-					   __TRANS_START |
+	[TRANS_STATE_BLOCKED]		=  __TRANS_START,
+	[TRANS_STATE_COMMIT_START]	= (__TRANS_START | __TRANS_ATTACH),
+	[TRANS_STATE_COMMIT_DOING]	= (__TRANS_START |
 					   __TRANS_ATTACH |
 					   __TRANS_JOIN),
-	[TRANS_STATE_UNBLOCKED]		= (__TRANS_USERSPACE |
-					   __TRANS_START |
+	[TRANS_STATE_UNBLOCKED]		= (__TRANS_START |
 					   __TRANS_ATTACH |
 					   __TRANS_JOIN |
 					   __TRANS_JOIN_NOLOCK),
-	[TRANS_STATE_COMPLETED]		= (__TRANS_USERSPACE |
-					   __TRANS_START |
+	[TRANS_STATE_COMPLETED]		= (__TRANS_START |
 					   __TRANS_ATTACH |
 					   __TRANS_JOIN |
 					   __TRANS_JOIN_NOLOCK),
@@ -449,9 +443,6 @@ static int may_wait_transaction(struct btrfs_fs_info *fs_info, int type)
 	if (test_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags))
 		return 0;
 
-	if (type == TRANS_USERSPACE)
-		return 1;
-
 	if (type == TRANS_START &&
 	    !atomic_read(&fs_info->open_ioctl_trans))
 		return 1;
@@ -593,7 +584,7 @@ start_transaction(struct btrfs_root *root, unsigned int num_items,
 got_it:
 	btrfs_record_root_in_trans(h, root);
 
-	if (!current->journal_info && type != TRANS_USERSPACE)
+	if (!current->journal_info)
 		current->journal_info = h;
 	return h;
 
@@ -678,12 +669,6 @@ struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root
 				 BTRFS_RESERVE_NO_FLUSH, true);
 }
 
-struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root)
-{
-	return start_transaction(root, 0, TRANS_USERSPACE,
-				 BTRFS_RESERVE_NO_FLUSH, true);
-}
-
 /*
  * btrfs_attach_transaction() - catch the running transaction
  *
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h
index 6beee072b1bd..8bc25c7cca7b 100644
--- a/fs/btrfs/transaction.h
+++ b/fs/btrfs/transaction.h
@@ -89,21 +89,18 @@ struct btrfs_transaction {
 
 #define __TRANS_FREEZABLE	(1U << 0)
 
-#define __TRANS_USERSPACE	(1U << 8)
 #define __TRANS_START		(1U << 9)
 #define __TRANS_ATTACH		(1U << 10)
 #define __TRANS_JOIN		(1U << 11)
 #define __TRANS_JOIN_NOLOCK	(1U << 12)
 #define __TRANS_DUMMY		(1U << 13)
 
-#define TRANS_USERSPACE		(__TRANS_USERSPACE | __TRANS_FREEZABLE)
 #define TRANS_START		(__TRANS_START | __TRANS_FREEZABLE)
 #define TRANS_ATTACH		(__TRANS_ATTACH)
 #define TRANS_JOIN		(__TRANS_JOIN | __TRANS_FREEZABLE)
 #define TRANS_JOIN_NOLOCK	(__TRANS_JOIN_NOLOCK)
 
-#define TRANS_EXTWRITERS	(__TRANS_USERSPACE | __TRANS_START |	\
-				 __TRANS_ATTACH)
+#define TRANS_EXTWRITERS	(__TRANS_START | __TRANS_ATTACH)
 
 #define BTRFS_SEND_TRANS_STUB	((void *)1)
 
-- 
2.7.4


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

* [PATCH RESEND 3/4] btrfs: Remove transaction handle from btrfs_file_private
  2018-01-10 16:32 ` [PATCH RESEND 1/4] btrfs: Remove userspace transaction ioctls Nikolay Borisov
  2018-01-10 16:32   ` [PATCH RESEND 2/4] btrfs: Remove code referencing unused TRANS_USERSPACE Nikolay Borisov
@ 2018-01-10 16:32   ` Nikolay Borisov
  2018-02-02 17:40     ` David Sterba
  2018-01-10 16:32   ` [PATCH RESEND 4/4] btrfs: Remove btrfs_fs_info::open_ioctl_trans Nikolay Borisov
                     ` (2 subsequent siblings)
  4 siblings, 1 reply; 25+ messages in thread
From: Nikolay Borisov @ 2018-01-10 16:32 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

Since we no longer support userspace transaction there is no need to
keep this member variable, so remove it.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/ctree.h | 1 -
 fs/btrfs/file.c  | 2 --
 2 files changed, 3 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 6a4752177ad8..dc679246b8e8 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1265,7 +1265,6 @@ struct btrfs_root {
 };
 
 struct btrfs_file_private {
-	struct btrfs_trans_handle *trans;
 	void *filldir_buf;
 };
 
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 291036513017..101e0c7fea92 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1996,8 +1996,6 @@ int btrfs_release_file(struct inode *inode, struct file *filp)
 {
 	struct btrfs_file_private *private = filp->private_data;
 
-	if (private && private->trans)
-		btrfs_ioctl_trans_end(filp);
 	if (private && private->filldir_buf)
 		kfree(private->filldir_buf);
 	kfree(private);
-- 
2.7.4


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

* [PATCH RESEND 4/4] btrfs: Remove btrfs_fs_info::open_ioctl_trans
  2018-01-10 16:32 ` [PATCH RESEND 1/4] btrfs: Remove userspace transaction ioctls Nikolay Borisov
  2018-01-10 16:32   ` [PATCH RESEND 2/4] btrfs: Remove code referencing unused TRANS_USERSPACE Nikolay Borisov
  2018-01-10 16:32   ` [PATCH RESEND 3/4] btrfs: Remove transaction handle from btrfs_file_private Nikolay Borisov
@ 2018-01-10 16:32   ` Nikolay Borisov
  2018-02-02 17:40     ` David Sterba
  2018-02-02 17:39   ` [PATCH RESEND 1/4] btrfs: Remove userspace transaction ioctls David Sterba
  2018-02-02 17:45   ` David Sterba
  4 siblings, 1 reply; 25+ messages in thread
From: Nikolay Borisov @ 2018-01-10 16:32 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

Since userspace transaction have been removed we no longer have use
for this field so delete it.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/ctree.h       | 1 -
 fs/btrfs/extent-tree.c | 3 +--
 fs/btrfs/transaction.c | 9 +++------
 3 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index dc679246b8e8..57a0d0b0ea74 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -877,7 +877,6 @@ struct btrfs_fs_info {
 	struct rb_root tree_mod_log;
 
 	atomic_t async_delalloc_pages;
-	atomic_t open_ioctl_trans;
 
 	/*
 	 * this is used to protect the following list -- ordered_roots.
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 8d51e4bb67c1..dcb059a46b77 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4329,8 +4329,7 @@ int btrfs_alloc_data_chunk_ondemand(struct btrfs_inode *inode, u64 bytes)
 
 		/* commit the current transaction and try again */
 commit_trans:
-		if (need_commit &&
-		    !atomic_read(&fs_info->open_ioctl_trans)) {
+		if (need_commit) {
 			need_commit--;
 
 			if (need_commit > 0) {
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index d61d1fd59ccd..c5ef42318058 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -443,8 +443,7 @@ static int may_wait_transaction(struct btrfs_fs_info *fs_info, int type)
 	if (test_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags))
 		return 0;
 
-	if (type == TRANS_START &&
-	    !atomic_read(&fs_info->open_ioctl_trans))
+	if (type == TRANS_START)
 		return 1;
 
 	return 0;
@@ -774,8 +773,7 @@ int btrfs_wait_for_commit(struct btrfs_fs_info *fs_info, u64 transid)
 
 void btrfs_throttle(struct btrfs_fs_info *fs_info)
 {
-	if (!atomic_read(&fs_info->open_ioctl_trans))
-		wait_current_trans(fs_info);
+	wait_current_trans(fs_info);
 }
 
 static int should_end_transaction(struct btrfs_trans_handle *trans)
@@ -857,8 +855,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
 
 	btrfs_trans_release_chunk_metadata(trans);
 
-	if (lock && !atomic_read(&info->open_ioctl_trans) &&
-	    should_end_transaction(trans) &&
+	if (lock && should_end_transaction(trans) &&
 	    READ_ONCE(cur_trans->state) == TRANS_STATE_RUNNING) {
 		spin_lock(&info->trans_lock);
 		if (cur_trans->state == TRANS_STATE_RUNNING)
-- 
2.7.4


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

* Re: [PATCH RESEND 1/4] btrfs: Remove userspace transaction ioctls
  2018-01-10 16:32 ` [PATCH RESEND 1/4] btrfs: Remove userspace transaction ioctls Nikolay Borisov
                     ` (2 preceding siblings ...)
  2018-01-10 16:32   ` [PATCH RESEND 4/4] btrfs: Remove btrfs_fs_info::open_ioctl_trans Nikolay Borisov
@ 2018-02-02 17:39   ` David Sterba
  2018-02-02 17:45   ` David Sterba
  4 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2018-02-02 17:39 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: linux-btrfs

On Wed, Jan 10, 2018 at 06:32:10PM +0200, Nikolay Borisov wrote:
> Commit 3558d4f88ec8 ("btrfs: Deprecate userspace transaction ioctls")
> marked the beginning of the end of userspace transaction. This commit
> finishes the job!
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>

Reviewed-by: David Sterba <dsterba@suse.com>

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

* Re: [PATCH RESEND 2/4] btrfs: Remove code referencing unused TRANS_USERSPACE
  2018-01-10 16:32   ` [PATCH RESEND 2/4] btrfs: Remove code referencing unused TRANS_USERSPACE Nikolay Borisov
@ 2018-02-02 17:40     ` David Sterba
  0 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2018-02-02 17:40 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: linux-btrfs

On Wed, Jan 10, 2018 at 06:32:11PM +0200, Nikolay Borisov wrote:
> Now that the userspace transaction ioctls have been removed,
> TRANS_USERSPACE is no longer used hence we can remove it.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>

Reviewed-by: David Sterba <dsterba@suse.com>

> -struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root)

The declaration removal from transaction.h is missing, I'll fix that.

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

* Re: [PATCH RESEND 3/4] btrfs: Remove transaction handle from btrfs_file_private
  2018-01-10 16:32   ` [PATCH RESEND 3/4] btrfs: Remove transaction handle from btrfs_file_private Nikolay Borisov
@ 2018-02-02 17:40     ` David Sterba
  0 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2018-02-02 17:40 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: linux-btrfs

On Wed, Jan 10, 2018 at 06:32:12PM +0200, Nikolay Borisov wrote:
> Since we no longer support userspace transaction there is no need to
> keep this member variable, so remove it.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>

Reviewed-by: David Sterba <dsterba@suse.com>

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

* Re: [PATCH RESEND 4/4] btrfs: Remove btrfs_fs_info::open_ioctl_trans
  2018-01-10 16:32   ` [PATCH RESEND 4/4] btrfs: Remove btrfs_fs_info::open_ioctl_trans Nikolay Borisov
@ 2018-02-02 17:40     ` David Sterba
  0 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2018-02-02 17:40 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: linux-btrfs

On Wed, Jan 10, 2018 at 06:32:13PM +0200, Nikolay Borisov wrote:
> Since userspace transaction have been removed we no longer have use
> for this field so delete it.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>

Reviewed-by: David Sterba <dsterba@suse.com>

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

* Re: [PATCH RESEND 1/4] btrfs: Remove userspace transaction ioctls
  2018-01-10 16:32 ` [PATCH RESEND 1/4] btrfs: Remove userspace transaction ioctls Nikolay Borisov
                     ` (3 preceding siblings ...)
  2018-02-02 17:39   ` [PATCH RESEND 1/4] btrfs: Remove userspace transaction ioctls David Sterba
@ 2018-02-02 17:45   ` David Sterba
  4 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2018-02-02 17:45 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: linux-btrfs

On Wed, Jan 10, 2018 at 06:32:10PM +0200, Nikolay Borisov wrote:
> Commit 3558d4f88ec8 ("btrfs: Deprecate userspace transaction ioctls")
> marked the beginning of the end of userspace transaction. This commit
> finishes the job!
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>

This does not compile without the other patches, the last use of
btrfs_ioctl_trans_end is in patch 3/4. All patches should compile and
work separately, not just as the whole series.

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

* [PATCH v2 1/4] btrfs: Remove userspace transaction ioctls
  2018-01-10 13:21 [PATCH 0/4] Finally remove userspace transaction support Nikolay Borisov
                   ` (6 preceding siblings ...)
  2018-01-10 16:32 ` [PATCH RESEND 1/4] btrfs: Remove userspace transaction ioctls Nikolay Borisov
@ 2018-02-05  8:41 ` Nikolay Borisov
  2018-02-05  8:41   ` [PATCH v2 2/4] btrfs: Remove btrfs_file_private::trans Nikolay Borisov
                     ` (3 more replies)
  7 siblings, 4 replies; 25+ messages in thread
From: Nikolay Borisov @ 2018-02-05  8:41 UTC (permalink / raw)
  To: dsterba; +Cc: linux-btrfs, Nikolay Borisov

Commit 3558d4f88ec8 ("btrfs: Deprecate userspace transaction ioctls")
marked the beginning of the end of userspace transaction. This commit
finishes the job!

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---

V2:
 * Also remove the usage of btrfs_ioctl_trans_end from btrfs_release_file so 
 that the patch compiles on its own as well.

 fs/btrfs/ctree.h |  1 -
 fs/btrfs/file.c  |  8 -----
 fs/btrfs/ioctl.c | 95 --------------------------------------------------------
 3 files changed, 104 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 1a462ab85c49..6a4752177ad8 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3193,7 +3193,6 @@ void btrfs_destroy_inode(struct inode *inode);
 int btrfs_drop_inode(struct inode *inode);
 int __init btrfs_init_cachep(void);
 void btrfs_destroy_cachep(void);
-long btrfs_ioctl_trans_end(struct file *file);
 struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location,
 			 struct btrfs_root *root, int *was_new);
 struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index cba2ac371ce0..101e0c7fea92 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1996,8 +1996,6 @@ int btrfs_release_file(struct inode *inode, struct file *filp)
 {
 	struct btrfs_file_private *private = filp->private_data;
 
-	if (private && private->trans)
-		btrfs_ioctl_trans_end(filp);
 	if (private && private->filldir_buf)
 		kfree(private->filldir_buf);
 	kfree(private);
@@ -2189,12 +2187,6 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 	}
 
 	/*
-	 * ok we haven't committed the transaction yet, lets do a commit
-	 */
-	if (file->private_data)
-		btrfs_ioctl_trans_end(file);
-
-	/*
 	 * We use start here because we will need to wait on the IO to complete
 	 * in btrfs_sync_log, which could require joining a transaction (for
 	 * example checking cross references in the nocow path).  If we use join
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index f573cad72b7e..3094e079fc4f 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3935,73 +3935,6 @@ int btrfs_clone_file_range(struct file *src_file, loff_t off,
 	return btrfs_clone_files(dst_file, src_file, off, len, destoff);
 }
 
-/*
- * there are many ways the trans_start and trans_end ioctls can lead
- * to deadlocks.  They should only be used by applications that
- * basically own the machine, and have a very in depth understanding
- * of all the possible deadlocks and enospc problems.
- */
-static long btrfs_ioctl_trans_start(struct file *file)
-{
-	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
-	struct btrfs_root *root = BTRFS_I(inode)->root;
-	struct btrfs_trans_handle *trans;
-	struct btrfs_file_private *private;
-	int ret;
-	static bool warned = false;
-
-	ret = -EPERM;
-	if (!capable(CAP_SYS_ADMIN))
-		goto out;
-
-	if (!warned) {
-		btrfs_warn(fs_info,
-			"Userspace transaction mechanism is considered "
-			"deprecated and slated to be removed in 4.17. "
-			"If you have a valid use case please "
-			"speak up on the mailing list");
-		WARN_ON(1);
-		warned = true;
-	}
-
-	ret = -EINPROGRESS;
-	private = file->private_data;
-	if (private && private->trans)
-		goto out;
-	if (!private) {
-		private = kzalloc(sizeof(struct btrfs_file_private),
-				  GFP_KERNEL);
-		if (!private)
-			return -ENOMEM;
-		file->private_data = private;
-	}
-
-	ret = -EROFS;
-	if (btrfs_root_readonly(root))
-		goto out;
-
-	ret = mnt_want_write_file(file);
-	if (ret)
-		goto out;
-
-	atomic_inc(&fs_info->open_ioctl_trans);
-
-	ret = -ENOMEM;
-	trans = btrfs_start_ioctl_transaction(root);
-	if (IS_ERR(trans))
-		goto out_drop;
-
-	private->trans = trans;
-	return 0;
-
-out_drop:
-	atomic_dec(&fs_info->open_ioctl_trans);
-	mnt_drop_write_file(file);
-out:
-	return ret;
-}
-
 static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
 {
 	struct inode *inode = file_inode(file);
@@ -4243,30 +4176,6 @@ static long btrfs_ioctl_space_info(struct btrfs_fs_info *fs_info,
 	return ret;
 }
 
-/*
- * there are many ways the trans_start and trans_end ioctls can lead
- * to deadlocks.  They should only be used by applications that
- * basically own the machine, and have a very in depth understanding
- * of all the possible deadlocks and enospc problems.
- */
-long btrfs_ioctl_trans_end(struct file *file)
-{
-	struct inode *inode = file_inode(file);
-	struct btrfs_root *root = BTRFS_I(inode)->root;
-	struct btrfs_file_private *private = file->private_data;
-
-	if (!private || !private->trans)
-		return -EINVAL;
-
-	btrfs_end_transaction(private->trans);
-	private->trans = NULL;
-
-	atomic_dec(&root->fs_info->open_ioctl_trans);
-
-	mnt_drop_write_file(file);
-	return 0;
-}
-
 static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root,
 					    void __user *argp)
 {
@@ -5573,10 +5482,6 @@ long btrfs_ioctl(struct file *file, unsigned int
 		return btrfs_ioctl_dev_info(fs_info, argp);
 	case BTRFS_IOC_BALANCE:
 		return btrfs_ioctl_balance(file, NULL);
-	case BTRFS_IOC_TRANS_START:
-		return btrfs_ioctl_trans_start(file);
-	case BTRFS_IOC_TRANS_END:
-		return btrfs_ioctl_trans_end(file);
 	case BTRFS_IOC_TREE_SEARCH:
 		return btrfs_ioctl_tree_search(file, argp);
 	case BTRFS_IOC_TREE_SEARCH_V2:
-- 
2.7.4


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

* [PATCH v2 2/4] btrfs: Remove btrfs_file_private::trans
  2018-02-05  8:41 ` [PATCH v2 " Nikolay Borisov
@ 2018-02-05  8:41   ` Nikolay Borisov
  2018-02-05  8:41   ` [PATCH v2 3/4] btrfs: Remove code referencing unused TRANS_USERSPACE Nikolay Borisov
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 25+ messages in thread
From: Nikolay Borisov @ 2018-02-05  8:41 UTC (permalink / raw)
  To: dsterba; +Cc: linux-btrfs, Nikolay Borisov

Now that the userspace transaction IOCTL have been removed, this member
is no longer used so just remove it

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---

V2: 
 * This was 3/4 before, but now move it to 2/4 since it makes more sense
 * Reword the subject to be more concise

 fs/btrfs/ctree.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 6a4752177ad8..dc679246b8e8 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1265,7 +1265,6 @@ struct btrfs_root {
 };
 
 struct btrfs_file_private {
-	struct btrfs_trans_handle *trans;
 	void *filldir_buf;
 };
 
-- 
2.7.4


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

* [PATCH v2 3/4] btrfs: Remove code referencing unused TRANS_USERSPACE
  2018-02-05  8:41 ` [PATCH v2 " Nikolay Borisov
  2018-02-05  8:41   ` [PATCH v2 2/4] btrfs: Remove btrfs_file_private::trans Nikolay Borisov
@ 2018-02-05  8:41   ` Nikolay Borisov
  2018-02-05  8:41   ` [PATCH v2 4/4] btrfs: Remove btrfs_fs_info::open_ioctl_trans Nikolay Borisov
  2018-02-05  8:52   ` [PATCH v2 1/4] btrfs: Remove userspace transaction ioctls Wang Shilong
  3 siblings, 0 replies; 25+ messages in thread
From: Nikolay Borisov @ 2018-02-05  8:41 UTC (permalink / raw)
  To: dsterba; +Cc: linux-btrfs, Nikolay Borisov

Now that the userspace transaction ioctls have been removed,
TRANS_USERSPACE is no longer used hence we can remove it.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---

V2: 
 * This was 2/4 but now is 3/4
 * Also remove the declaration of btrfs_start_ioctl_transaction from 
 transaction.h
 fs/btrfs/transaction.c | 27 ++++++---------------------
 fs/btrfs/transaction.h |  6 +-----
 2 files changed, 7 insertions(+), 26 deletions(-)

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 04f07144b45c..d61d1fd59ccd 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -37,22 +37,16 @@
 
 static const unsigned int btrfs_blocked_trans_types[TRANS_STATE_MAX] = {
 	[TRANS_STATE_RUNNING]		= 0U,
-	[TRANS_STATE_BLOCKED]		= (__TRANS_USERSPACE |
-					   __TRANS_START),
-	[TRANS_STATE_COMMIT_START]	= (__TRANS_USERSPACE |
-					   __TRANS_START |
-					   __TRANS_ATTACH),
-	[TRANS_STATE_COMMIT_DOING]	= (__TRANS_USERSPACE |
-					   __TRANS_START |
+	[TRANS_STATE_BLOCKED]		=  __TRANS_START,
+	[TRANS_STATE_COMMIT_START]	= (__TRANS_START | __TRANS_ATTACH),
+	[TRANS_STATE_COMMIT_DOING]	= (__TRANS_START |
 					   __TRANS_ATTACH |
 					   __TRANS_JOIN),
-	[TRANS_STATE_UNBLOCKED]		= (__TRANS_USERSPACE |
-					   __TRANS_START |
+	[TRANS_STATE_UNBLOCKED]		= (__TRANS_START |
 					   __TRANS_ATTACH |
 					   __TRANS_JOIN |
 					   __TRANS_JOIN_NOLOCK),
-	[TRANS_STATE_COMPLETED]		= (__TRANS_USERSPACE |
-					   __TRANS_START |
+	[TRANS_STATE_COMPLETED]		= (__TRANS_START |
 					   __TRANS_ATTACH |
 					   __TRANS_JOIN |
 					   __TRANS_JOIN_NOLOCK),
@@ -449,9 +443,6 @@ static int may_wait_transaction(struct btrfs_fs_info *fs_info, int type)
 	if (test_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags))
 		return 0;
 
-	if (type == TRANS_USERSPACE)
-		return 1;
-
 	if (type == TRANS_START &&
 	    !atomic_read(&fs_info->open_ioctl_trans))
 		return 1;
@@ -593,7 +584,7 @@ start_transaction(struct btrfs_root *root, unsigned int num_items,
 got_it:
 	btrfs_record_root_in_trans(h, root);
 
-	if (!current->journal_info && type != TRANS_USERSPACE)
+	if (!current->journal_info)
 		current->journal_info = h;
 	return h;
 
@@ -678,12 +669,6 @@ struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root
 				 BTRFS_RESERVE_NO_FLUSH, true);
 }
 
-struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root)
-{
-	return start_transaction(root, 0, TRANS_USERSPACE,
-				 BTRFS_RESERVE_NO_FLUSH, true);
-}
-
 /*
  * btrfs_attach_transaction() - catch the running transaction
  *
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h
index 6beee072b1bd..8a6361828c69 100644
--- a/fs/btrfs/transaction.h
+++ b/fs/btrfs/transaction.h
@@ -89,21 +89,18 @@ struct btrfs_transaction {
 
 #define __TRANS_FREEZABLE	(1U << 0)
 
-#define __TRANS_USERSPACE	(1U << 8)
 #define __TRANS_START		(1U << 9)
 #define __TRANS_ATTACH		(1U << 10)
 #define __TRANS_JOIN		(1U << 11)
 #define __TRANS_JOIN_NOLOCK	(1U << 12)
 #define __TRANS_DUMMY		(1U << 13)
 
-#define TRANS_USERSPACE		(__TRANS_USERSPACE | __TRANS_FREEZABLE)
 #define TRANS_START		(__TRANS_START | __TRANS_FREEZABLE)
 #define TRANS_ATTACH		(__TRANS_ATTACH)
 #define TRANS_JOIN		(__TRANS_JOIN | __TRANS_FREEZABLE)
 #define TRANS_JOIN_NOLOCK	(__TRANS_JOIN_NOLOCK)
 
-#define TRANS_EXTWRITERS	(__TRANS_USERSPACE | __TRANS_START |	\
-				 __TRANS_ATTACH)
+#define TRANS_EXTWRITERS	(__TRANS_START | __TRANS_ATTACH)
 
 #define BTRFS_SEND_TRANS_STUB	((void *)1)
 
@@ -194,7 +191,6 @@ struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root
 struct btrfs_trans_handle *btrfs_attach_transaction(struct btrfs_root *root);
 struct btrfs_trans_handle *btrfs_attach_transaction_barrier(
 					struct btrfs_root *root);
-struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root);
 int btrfs_wait_for_commit(struct btrfs_fs_info *fs_info, u64 transid);
 
 void btrfs_add_dead_root(struct btrfs_root *root);
-- 
2.7.4


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

* [PATCH v2 4/4] btrfs: Remove btrfs_fs_info::open_ioctl_trans
  2018-02-05  8:41 ` [PATCH v2 " Nikolay Borisov
  2018-02-05  8:41   ` [PATCH v2 2/4] btrfs: Remove btrfs_file_private::trans Nikolay Borisov
  2018-02-05  8:41   ` [PATCH v2 3/4] btrfs: Remove code referencing unused TRANS_USERSPACE Nikolay Borisov
@ 2018-02-05  8:41   ` Nikolay Borisov
  2018-02-05  8:52   ` [PATCH v2 1/4] btrfs: Remove userspace transaction ioctls Wang Shilong
  3 siblings, 0 replies; 25+ messages in thread
From: Nikolay Borisov @ 2018-02-05  8:41 UTC (permalink / raw)
  To: dsterba; +Cc: linux-btrfs, Nikolay Borisov

Since userspace transaction have been removed we no longer have use
for this field so delete it.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---

V2: 
 * No changes
 fs/btrfs/ctree.h       | 1 -
 fs/btrfs/extent-tree.c | 3 +--
 fs/btrfs/transaction.c | 9 +++------
 3 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index dc679246b8e8..57a0d0b0ea74 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -877,7 +877,6 @@ struct btrfs_fs_info {
 	struct rb_root tree_mod_log;
 
 	atomic_t async_delalloc_pages;
-	atomic_t open_ioctl_trans;
 
 	/*
 	 * this is used to protect the following list -- ordered_roots.
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 8d51e4bb67c1..dcb059a46b77 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4329,8 +4329,7 @@ int btrfs_alloc_data_chunk_ondemand(struct btrfs_inode *inode, u64 bytes)
 
 		/* commit the current transaction and try again */
 commit_trans:
-		if (need_commit &&
-		    !atomic_read(&fs_info->open_ioctl_trans)) {
+		if (need_commit) {
 			need_commit--;
 
 			if (need_commit > 0) {
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index d61d1fd59ccd..c5ef42318058 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -443,8 +443,7 @@ static int may_wait_transaction(struct btrfs_fs_info *fs_info, int type)
 	if (test_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags))
 		return 0;
 
-	if (type == TRANS_START &&
-	    !atomic_read(&fs_info->open_ioctl_trans))
+	if (type == TRANS_START)
 		return 1;
 
 	return 0;
@@ -774,8 +773,7 @@ int btrfs_wait_for_commit(struct btrfs_fs_info *fs_info, u64 transid)
 
 void btrfs_throttle(struct btrfs_fs_info *fs_info)
 {
-	if (!atomic_read(&fs_info->open_ioctl_trans))
-		wait_current_trans(fs_info);
+	wait_current_trans(fs_info);
 }
 
 static int should_end_transaction(struct btrfs_trans_handle *trans)
@@ -857,8 +855,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
 
 	btrfs_trans_release_chunk_metadata(trans);
 
-	if (lock && !atomic_read(&info->open_ioctl_trans) &&
-	    should_end_transaction(trans) &&
+	if (lock && should_end_transaction(trans) &&
 	    READ_ONCE(cur_trans->state) == TRANS_STATE_RUNNING) {
 		spin_lock(&info->trans_lock);
 		if (cur_trans->state == TRANS_STATE_RUNNING)
-- 
2.7.4


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

* Re: [PATCH v2 1/4] btrfs: Remove userspace transaction ioctls
  2018-02-05  8:41 ` [PATCH v2 " Nikolay Borisov
                     ` (2 preceding siblings ...)
  2018-02-05  8:41   ` [PATCH v2 4/4] btrfs: Remove btrfs_fs_info::open_ioctl_trans Nikolay Borisov
@ 2018-02-05  8:52   ` Wang Shilong
  2018-02-05 13:30     ` David Sterba
  3 siblings, 1 reply; 25+ messages in thread
From: Wang Shilong @ 2018-02-05  8:52 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: Wang Shilong, David Sterba, linux-btrfs, sage


   These ioctl are originally introduced by Sage Weil for Ceph use?
Not sure whether it still useful, Cc Sage just in case.


在 2018年2月5日,下午5:41,Nikolay Borisov <nborisov@suse.com> 写道:

Commit 3558d4f88ec8 ("btrfs: Deprecate userspace transaction ioctls")
marked the beginning of the end of userspace transaction. This commit
finishes the job!

Signed-off-by: Nikolay Borisov <nborisov@suse.com>

---

V2:
* Also remove the usage of btrfs_ioctl_trans_end from btrfs_release_file so 
that the patch compiles on its own as well.

fs/btrfs/ctree.h |  1 -
fs/btrfs/file.c  |  8 -----
fs/btrfs/ioctl.c | 95 --------------------------------------------------------
3 files changed, 104 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 1a462ab85c49..6a4752177ad8 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3193,7 +3193,6 @@ void btrfs_destroy_inode(struct inode *inode);
int btrfs_drop_inode(struct inode *inode);
int __init btrfs_init_cachep(void);
void btrfs_destroy_cachep(void);
-long btrfs_ioctl_trans_end(struct file *file);
struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location,
			 struct btrfs_root *root, int *was_new);
struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index cba2ac371ce0..101e0c7fea92 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1996,8 +1996,6 @@ int btrfs_release_file(struct inode *inode, struct file *filp)
{
	struct btrfs_file_private *private = filp->private_data;

-	if (private && private->trans)
-		btrfs_ioctl_trans_end(filp);
	if (private && private->filldir_buf)
		kfree(private->filldir_buf);
	kfree(private);
@@ -2189,12 +2187,6 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
	}

	/*
-	 * ok we haven't committed the transaction yet, lets do a commit
-	 */
-	if (file->private_data)
-		btrfs_ioctl_trans_end(file);
-
-	/*
	 * We use start here because we will need to wait on the IO to complete
	 * in btrfs_sync_log, which could require joining a transaction (for
	 * example checking cross references in the nocow path).  If we use join
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index f573cad72b7e..3094e079fc4f 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3935,73 +3935,6 @@ int btrfs_clone_file_range(struct file *src_file, loff_t off,
	return btrfs_clone_files(dst_file, src_file, off, len, destoff);
}

-/*
- * there are many ways the trans_start and trans_end ioctls can lead
- * to deadlocks.  They should only be used by applications that
- * basically own the machine, and have a very in depth understanding
- * of all the possible deadlocks and enospc problems.
- */
-static long btrfs_ioctl_trans_start(struct file *file)
-{
-	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
-	struct btrfs_root *root = BTRFS_I(inode)->root;
-	struct btrfs_trans_handle *trans;
-	struct btrfs_file_private *private;
-	int ret;
-	static bool warned = false;
-
-	ret = -EPERM;
-	if (!capable(CAP_SYS_ADMIN))
-		goto out;
-
-	if (!warned) {
-		btrfs_warn(fs_info,
-			"Userspace transaction mechanism is considered "
-			"deprecated and slated to be removed in 4.17. "
-			"If you have a valid use case please "
-			"speak up on the mailing list");
-		WARN_ON(1);
-		warned = true;
-	}
-
-	ret = -EINPROGRESS;
-	private = file->private_data;
-	if (private && private->trans)
-		goto out;
-	if (!private) {
-		private = kzalloc(sizeof(struct btrfs_file_private),
-				  GFP_KERNEL);
-		if (!private)
-			return -ENOMEM;
-		file->private_data = private;
-	}
-
-	ret = -EROFS;
-	if (btrfs_root_readonly(root))
-		goto out;
-
-	ret = mnt_want_write_file(file);
-	if (ret)
-		goto out;
-
-	atomic_inc(&fs_info->open_ioctl_trans);
-
-	ret = -ENOMEM;
-	trans = btrfs_start_ioctl_transaction(root);
-	if (IS_ERR(trans))
-		goto out_drop;
-
-	private->trans = trans;
-	return 0;
-
-out_drop:
-	atomic_dec(&fs_info->open_ioctl_trans);
-	mnt_drop_write_file(file);
-out:
-	return ret;
-}
-
static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
{
	struct inode *inode = file_inode(file);
@@ -4243,30 +4176,6 @@ static long btrfs_ioctl_space_info(struct btrfs_fs_info *fs_info,
	return ret;
}

-/*
- * there are many ways the trans_start and trans_end ioctls can lead
- * to deadlocks.  They should only be used by applications that
- * basically own the machine, and have a very in depth understanding
- * of all the possible deadlocks and enospc problems.
- */
-long btrfs_ioctl_trans_end(struct file *file)
-{
-	struct inode *inode = file_inode(file);
-	struct btrfs_root *root = BTRFS_I(inode)->root;
-	struct btrfs_file_private *private = file->private_data;
-
-	if (!private || !private->trans)
-		return -EINVAL;
-
-	btrfs_end_transaction(private->trans);
-	private->trans = NULL;
-
-	atomic_dec(&root->fs_info->open_ioctl_trans);
-
-	mnt_drop_write_file(file);
-	return 0;
-}
-
static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root,
					    void __user *argp)
{
@@ -5573,10 +5482,6 @@ long btrfs_ioctl(struct file *file, unsigned int
		return btrfs_ioctl_dev_info(fs_info, argp);
	case BTRFS_IOC_BALANCE:
		return btrfs_ioctl_balance(file, NULL);
-	case BTRFS_IOC_TRANS_START:
-		return btrfs_ioctl_trans_start(file);
-	case BTRFS_IOC_TRANS_END:
-		return btrfs_ioctl_trans_end(file);
	case BTRFS_IOC_TREE_SEARCH:
		return btrfs_ioctl_tree_search(file, argp);
	case BTRFS_IOC_TREE_SEARCH_V2:
-- 
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


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

* Re: [PATCH v2 1/4] btrfs: Remove userspace transaction ioctls
  2018-02-05  8:52   ` [PATCH v2 1/4] btrfs: Remove userspace transaction ioctls Wang Shilong
@ 2018-02-05 13:30     ` David Sterba
  2018-02-05 14:27       ` Sage Weil
  0 siblings, 1 reply; 25+ messages in thread
From: David Sterba @ 2018-02-05 13:30 UTC (permalink / raw)
  To: Wang Shilong; +Cc: Nikolay Borisov, linux-btrfs, sage

On Mon, Feb 05, 2018 at 05:52:52PM +0900, Wang Shilong wrote:
>    These ioctl are originally introduced by Sage Weil for Ceph use?
> Not sure whether it still useful, Cc Sage just in case.

We have checked that the ioctl is not used in ceph, the reasons why we
think it's ok to remove the ioctl were in the cover letter of v1.

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

* Re: [PATCH v2 1/4] btrfs: Remove userspace transaction ioctls
  2018-02-05 13:30     ` David Sterba
@ 2018-02-05 14:27       ` Sage Weil
  0 siblings, 0 replies; 25+ messages in thread
From: Sage Weil @ 2018-02-05 14:27 UTC (permalink / raw)
  To: David Sterba; +Cc: Wang Shilong, Nikolay Borisov, linux-btrfs

On Mon, 5 Feb 2018, David Sterba wrote:
> On Mon, Feb 05, 2018 at 05:52:52PM +0900, Wang Shilong wrote:
> >    These ioctl are originally introduced by Sage Weil for Ceph use?
> > Not sure whether it still useful, Cc Sage just in case.
> 
> We have checked that the ioctl is not used in ceph, the reasons why we
> think it's ok to remove the ioctl were in the cover letter of v1.

Yeah, +1 on removal.

Acked-by: Sage Weil <sage@redhat.com>

sage

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

end of thread, other threads:[~2018-02-05 14:35 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-10 13:21 [PATCH 0/4] Finally remove userspace transaction support Nikolay Borisov
2018-01-10 13:21 ` [PATCH 1/4] btrfs: Remove userspace transaction ioctls Nikolay Borisov
2018-01-10 13:37   ` [PATCH v2] " Nikolay Borisov
2018-01-10 13:40   ` [PATCH v3] " Nikolay Borisov
2018-01-10 13:21 ` [PATCH 2/4] btrfs: Remove code referencing unused TRANS_USERSPACE Nikolay Borisov
2018-01-10 13:21 ` [PATCH 3/4] btrfs: Remove transaction handle from btrfs_file_private Nikolay Borisov
2018-01-10 13:21 ` [PATCH 4/4] btrfs: Remove btrfs_fs_info::open_ioctl_trans Nikolay Borisov
2018-01-10 15:47 ` [PATCH 0/4] Finally remove userspace transaction support Josef Bacik
2018-01-10 16:26 ` David Sterba
2018-01-10 16:32 ` [PATCH RESEND 1/4] btrfs: Remove userspace transaction ioctls Nikolay Borisov
2018-01-10 16:32   ` [PATCH RESEND 2/4] btrfs: Remove code referencing unused TRANS_USERSPACE Nikolay Borisov
2018-02-02 17:40     ` David Sterba
2018-01-10 16:32   ` [PATCH RESEND 3/4] btrfs: Remove transaction handle from btrfs_file_private Nikolay Borisov
2018-02-02 17:40     ` David Sterba
2018-01-10 16:32   ` [PATCH RESEND 4/4] btrfs: Remove btrfs_fs_info::open_ioctl_trans Nikolay Borisov
2018-02-02 17:40     ` David Sterba
2018-02-02 17:39   ` [PATCH RESEND 1/4] btrfs: Remove userspace transaction ioctls David Sterba
2018-02-02 17:45   ` David Sterba
2018-02-05  8:41 ` [PATCH v2 " Nikolay Borisov
2018-02-05  8:41   ` [PATCH v2 2/4] btrfs: Remove btrfs_file_private::trans Nikolay Borisov
2018-02-05  8:41   ` [PATCH v2 3/4] btrfs: Remove code referencing unused TRANS_USERSPACE Nikolay Borisov
2018-02-05  8:41   ` [PATCH v2 4/4] btrfs: Remove btrfs_fs_info::open_ioctl_trans Nikolay Borisov
2018-02-05  8:52   ` [PATCH v2 1/4] btrfs: Remove userspace transaction ioctls Wang Shilong
2018-02-05 13:30     ` David Sterba
2018-02-05 14:27       ` Sage Weil

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.