linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] Btrfs: Abstract similar code for btrfs_block_rsv_add{, _noflush}()
@ 2011-11-10  6:28 Miao Xie
  2011-11-10  7:31 ` Miao Xie
  0 siblings, 1 reply; 3+ messages in thread
From: Miao Xie @ 2011-11-10  6:28 UTC (permalink / raw)
  To: Linux Btrfs

btrfs_block_rsv_add{, _noflush}() have similar code, so abstract that code.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
---
 fs/btrfs/extent-tree.c |   28 ++++++++++++----------------
 1 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 1311beb..6703a43 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3796,16 +3796,16 @@ void btrfs_free_block_rsv(struct btrfs_root *root,
 	kfree(rsv);
 }
 
-int btrfs_block_rsv_add(struct btrfs_root *root,
-			struct btrfs_block_rsv *block_rsv,
-			u64 num_bytes)
+static inline int __block_rsv_add(struct btrfs_root *root,
+				  struct btrfs_block_rsv *block_rsv,
+				  u64 num_bytes, int flush)
 {
 	int ret;
 
 	if (num_bytes == 0)
 		return 0;
 
-	ret = reserve_metadata_bytes(root, block_rsv, num_bytes, 1);
+	ret = reserve_metadata_bytes(root, block_rsv, num_bytes, flush);
 	if (!ret) {
 		block_rsv_add_bytes(block_rsv, num_bytes, 1);
 		return 0;
@@ -3814,22 +3814,18 @@ int btrfs_block_rsv_add(struct btrfs_root *root,
 	return ret;
 }
 
+int btrfs_block_rsv_add(struct btrfs_root *root,
+			struct btrfs_block_rsv *block_rsv,
+			u64 num_bytes)
+{
+	return __block_rsv_add(root, block_rsv, num_bytes, 1);
+}
+
 int btrfs_block_rsv_add_noflush(struct btrfs_root *root,
 				struct btrfs_block_rsv *block_rsv,
 				u64 num_bytes)
 {
-	int ret;
-
-	if (num_bytes == 0)
-		return 0;
-
-	ret = reserve_metadata_bytes(root, block_rsv, num_bytes, 0);
-	if (!ret) {
-		block_rsv_add_bytes(block_rsv, num_bytes, 1);
-		return 0;
-	}
-
-	return ret;
+	return __block_rsv_add(root, block_rsv, num_bytes, 0);
 }
 
 int btrfs_block_rsv_check(struct btrfs_root *root,
-- 
1.7.6.4

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

* Re: [PATCH 1/6] Btrfs: Abstract similar code for btrfs_block_rsv_add{, _noflush}()
  2011-11-10  6:28 [PATCH 1/6] Btrfs: Abstract similar code for btrfs_block_rsv_add{, _noflush}() Miao Xie
@ 2011-11-10  7:31 ` Miao Xie
  2011-11-11  0:12   ` Chris Mason
  0 siblings, 1 reply; 3+ messages in thread
From: Miao Xie @ 2011-11-10  7:31 UTC (permalink / raw)
  To: Linux Btrfs

The mail of PATCH 0 was always rejected, so I try to send it as the
reply of PATCH 1.
====================
Title: [PATCH 0/6] Random fix of the space relocation

This patchset fixes 5 bugs of the space relocation, one fixes the problem
that we forgot to reserve space for writing out i-node cache, one fixes
that the path is not released, this problem may cause the deadlock.
one fixes the no-cow problem, this problem will break the meta-data.
one fixes the deadlock that caused by the race between the relocation
and the snapshot creation, the last one fixes BUG_ON() which is triggered
by the orphan back-ref nodes.

NOTE: This patchset is based on the danger branch.

Miao Xie (6):
  Btrfs: Abstract similar code for btrfs_block_rsv_add{, _noflush}()
  Btrfs: fix no reserved space for writing out inode cache
  Btrfs: fix unreleased path in btrfs_orphan_cleanup()
  Btrfs: fix nocow when deleting the item
  Btrfs: fix deadlock caused by the race between relocation and snapshot creation
  Btrfs: fix orphan backref nodes

 fs/btrfs/extent-tree.c |   28 ++++++++++++----------------
 fs/btrfs/inode-map.c   |   28 ++++++++++++++++++++++++----
 fs/btrfs/inode.c       |    3 +++
 fs/btrfs/relocation.c  |    2 ++
 fs/btrfs/transaction.c |    4 ++--
 fs/btrfs/volumes.c     |    5 ++++-
 6 files changed, 47 insertions(+), 23 deletions(-)

On thu, 10 Nov 2011 14:28:23 +0800, Miao Xie wrote:
> btrfs_block_rsv_add{, _noflush}() have similar code, so abstract that code.
> 
> Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
> ---
>  fs/btrfs/extent-tree.c |   28 ++++++++++++----------------
>  1 files changed, 12 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 1311beb..6703a43 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -3796,16 +3796,16 @@ void btrfs_free_block_rsv(struct btrfs_root *root,
>  	kfree(rsv);
>  }
>  
> -int btrfs_block_rsv_add(struct btrfs_root *root,
> -			struct btrfs_block_rsv *block_rsv,
> -			u64 num_bytes)
> +static inline int __block_rsv_add(struct btrfs_root *root,
> +				  struct btrfs_block_rsv *block_rsv,
> +				  u64 num_bytes, int flush)
>  {
>  	int ret;
>  
>  	if (num_bytes == 0)
>  		return 0;
>  
> -	ret = reserve_metadata_bytes(root, block_rsv, num_bytes, 1);
> +	ret = reserve_metadata_bytes(root, block_rsv, num_bytes, flush);
>  	if (!ret) {
>  		block_rsv_add_bytes(block_rsv, num_bytes, 1);
>  		return 0;
> @@ -3814,22 +3814,18 @@ int btrfs_block_rsv_add(struct btrfs_root *root,
>  	return ret;
>  }
>  
> +int btrfs_block_rsv_add(struct btrfs_root *root,
> +			struct btrfs_block_rsv *block_rsv,
> +			u64 num_bytes)
> +{
> +	return __block_rsv_add(root, block_rsv, num_bytes, 1);
> +}
> +
>  int btrfs_block_rsv_add_noflush(struct btrfs_root *root,
>  				struct btrfs_block_rsv *block_rsv,
>  				u64 num_bytes)
>  {
> -	int ret;
> -
> -	if (num_bytes == 0)
> -		return 0;
> -
> -	ret = reserve_metadata_bytes(root, block_rsv, num_bytes, 0);
> -	if (!ret) {
> -		block_rsv_add_bytes(block_rsv, num_bytes, 1);
> -		return 0;
> -	}
> -
> -	return ret;
> +	return __block_rsv_add(root, block_rsv, num_bytes, 0);
>  }
>  
>  int btrfs_block_rsv_check(struct btrfs_root *root,


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

* Re: [PATCH 1/6] Btrfs: Abstract similar code for btrfs_block_rsv_add{, _noflush}()
  2011-11-10  7:31 ` Miao Xie
@ 2011-11-11  0:12   ` Chris Mason
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Mason @ 2011-11-11  0:12 UTC (permalink / raw)
  To: Miao Xie; +Cc: Linux Btrfs

On Thu, Nov 10, 2011 at 03:31:08PM +0800, Miao Xie wrote:
> The mail of PATCH 0 was always rejected, so I try to send it as the
> reply of PATCH 1.
> ====================
> Title: [PATCH 0/6] Random fix of the space relocation
> 
> This patchset fixes 5 bugs of the space relocation, one fixes the problem
> that we forgot to reserve space for writing out i-node cache, one fixes
> that the path is not released, this problem may cause the deadlock.
> one fixes the no-cow problem, this problem will break the meta-data.
> one fixes the deadlock that caused by the race between the relocation
> and the snapshot creation, the last one fixes BUG_ON() which is triggered
> by the orphan back-ref nodes.
> 
> NOTE: This patchset is based on the danger branch.

Thanks!  For future patches, please use the for-linus branch instead.
danger still has the subtransid code, which we need to fix

-chris

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

end of thread, other threads:[~2011-11-11  0:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-10  6:28 [PATCH 1/6] Btrfs: Abstract similar code for btrfs_block_rsv_add{, _noflush}() Miao Xie
2011-11-10  7:31 ` Miao Xie
2011-11-11  0:12   ` Chris Mason

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).