linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: delete dead code in btrfs_orphan_add()
@ 2018-01-25 23:56 Omar Sandoval
  2018-01-26 10:54 ` Nikolay Borisov
  0 siblings, 1 reply; 3+ messages in thread
From: Omar Sandoval @ 2018-01-25 23:56 UTC (permalink / raw)
  To: linux-btrfs; +Cc: kernel-team

From: Omar Sandoval <osandov@fb.com>

btrfs_orphan_add() has had this case commented out since it was first
introduced in commit d68fc57b7e32 ("Btrfs: Metadata reservation for
orphan inodes"). Most of the orphan cleanup code has been rewritten
since then, so it's safe to say that this code isn't needed.

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 fs/btrfs/inode.c | 22 +---------------------
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e1a7f3cb5be9..d4e3a09c0ea4 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3334,17 +3334,6 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans,
 
 	if (!test_and_set_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,
 			      &inode->runtime_flags)) {
-#if 0
-		/*
-		 * For proper ENOSPC handling, we should do orphan
-		 * cleanup when mounting. But this introduces backward
-		 * compatibility issue.
-		 */
-		if (!xchg(&root->orphan_item_inserted, 1))
-			insert = 2;
-		else
-			insert = 1;
-#endif
 		insert = 1;
 		atomic_inc(&root->orphan_inodes);
 	}
@@ -3370,7 +3359,7 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans,
 	}
 
 	/* insert an orphan item to track this unlinked/truncated file */
-	if (insert >= 1) {
+	if (insert) {
 		ret = btrfs_insert_orphan_item(trans, root, btrfs_ino(inode));
 		if (ret) {
 			atomic_dec(&root->orphan_inodes);
@@ -3389,15 +3378,6 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans,
 		ret = 0;
 	}
 
-	/* insert an orphan item to track subvolume contains orphan files */
-	if (insert >= 2) {
-		ret = btrfs_insert_orphan_item(trans, fs_info->tree_root,
-					       root->root_key.objectid);
-		if (ret && ret != -EEXIST) {
-			btrfs_abort_transaction(trans, ret);
-			return ret;
-		}
-	}
 	return 0;
 }
 
-- 
2.16.1


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

* Re: [PATCH] Btrfs: delete dead code in btrfs_orphan_add()
  2018-01-25 23:56 [PATCH] Btrfs: delete dead code in btrfs_orphan_add() Omar Sandoval
@ 2018-01-26 10:54 ` Nikolay Borisov
  2018-03-22 15:59   ` David Sterba
  0 siblings, 1 reply; 3+ messages in thread
From: Nikolay Borisov @ 2018-01-26 10:54 UTC (permalink / raw)
  To: Omar Sandoval, linux-btrfs; +Cc: kernel-team



On 26.01.2018 01:56, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
> 
> btrfs_orphan_add() has had this case commented out since it was first
> introduced in commit d68fc57b7e32 ("Btrfs: Metadata reservation for
> orphan inodes"). Most of the orphan cleanup code has been rewritten
> since then, so it's safe to say that this code isn't needed.

I've tried removing this a couple of times but David objected due to
missing historical context and whether we might need it. I'm totally
fine with killing it.

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

> 
> Signed-off-by: Omar Sandoval <osandov@fb.com>
> ---
>  fs/btrfs/inode.c | 22 +---------------------
>  1 file changed, 1 insertion(+), 21 deletions(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index e1a7f3cb5be9..d4e3a09c0ea4 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -3334,17 +3334,6 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans,
>  
>  	if (!test_and_set_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,
>  			      &inode->runtime_flags)) {
> -#if 0
> -		/*
> -		 * For proper ENOSPC handling, we should do orphan
> -		 * cleanup when mounting. But this introduces backward
> -		 * compatibility issue.
> -		 */
> -		if (!xchg(&root->orphan_item_inserted, 1))
> -			insert = 2;
> -		else
> -			insert = 1;
> -#endif
>  		insert = 1;
>  		atomic_inc(&root->orphan_inodes);
>  	}
> @@ -3370,7 +3359,7 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans,
>  	}
>  
>  	/* insert an orphan item to track this unlinked/truncated file */
> -	if (insert >= 1) {
> +	if (insert) {
>  		ret = btrfs_insert_orphan_item(trans, root, btrfs_ino(inode));
>  		if (ret) {
>  			atomic_dec(&root->orphan_inodes);
> @@ -3389,15 +3378,6 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans,
>  		ret = 0;
>  	}
>  
> -	/* insert an orphan item to track subvolume contains orphan files */
> -	if (insert >= 2) {
> -		ret = btrfs_insert_orphan_item(trans, fs_info->tree_root,
> -					       root->root_key.objectid);
> -		if (ret && ret != -EEXIST) {
> -			btrfs_abort_transaction(trans, ret);
> -			return ret;
> -		}
> -	}
>  	return 0;
>  }
>  
> 

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

* Re: [PATCH] Btrfs: delete dead code in btrfs_orphan_add()
  2018-01-26 10:54 ` Nikolay Borisov
@ 2018-03-22 15:59   ` David Sterba
  0 siblings, 0 replies; 3+ messages in thread
From: David Sterba @ 2018-03-22 15:59 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: Omar Sandoval, linux-btrfs, kernel-team

On Fri, Jan 26, 2018 at 12:54:38PM +0200, Nikolay Borisov wrote:
> 
> 
> On 26.01.2018 01:56, Omar Sandoval wrote:
> > From: Omar Sandoval <osandov@fb.com>
> > 
> > btrfs_orphan_add() has had this case commented out since it was first
> > introduced in commit d68fc57b7e32 ("Btrfs: Metadata reservation for
> > orphan inodes"). Most of the orphan cleanup code has been rewritten
> > since then, so it's safe to say that this code isn't needed.
> 
> I've tried removing this a couple of times but David objected due to
> missing historical context and whether we might need it. I'm totally
> fine with killing it.
> 
> Reviewed-by: Nikolay Borisov <nborisov@suse.com>

So be it. Added to next.

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

end of thread, other threads:[~2018-03-22 16:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-25 23:56 [PATCH] Btrfs: delete dead code in btrfs_orphan_add() Omar Sandoval
2018-01-26 10:54 ` Nikolay Borisov
2018-03-22 15:59   ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).