diff mbox

Btrfs: avoid warning bomb of btrfs_delayed_inode_reserve_metadata

Message ID 1396431670-9353-1-git-send-email-bo.li.liu@oracle.com (mailing list archive)
State Accepted
Headers show

Commit Message

Liu Bo April 2, 2014, 9:41 a.m. UTC
When we nearly run out of global_block_rsv's reserved space, this WARNING will
be hit for thousands of times, which is not good because the kernel log has
nothing else.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
 fs/btrfs/delayed-inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Sterba April 2, 2014, 5:03 p.m. UTC | #1
On Wed, Apr 02, 2014 at 05:41:10PM +0800, Liu Bo wrote:
> When we nearly run out of global_block_rsv's reserved space, this WARNING will
> be hit for thousands of times, which is not good because the kernel log has
> nothing else.
> 
>  		ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes);
> -		if (!WARN_ON(ret))
> +		if (!WARN_ON_ONCE(ret))
>  			goto out;

The warning has been mistakenly added in

fae7f21cece9a4c181
"btrfs: Use WARN_ON()'s return value in place of WARN_ON(1)"

@@ -649,14 +649,13 @@ static int btrfs_delayed_inode_reserve_metadata(
                        goto out;

                ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes);
-               if (!ret)
+               if (!WARN_ON(ret))
                        goto out;

		[previous WARN_ON removed a few lines below]
---

WARN_ON will trigger because it sees 'ret' though in the previous code
did not reach the WARN_ON below. The correct pattern is

-	if (condition)
+	if (WARN_ON(condition))

I haven't spotted any other bugs from the same class in the patch. I'll
send a fix and cc stable.
--
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
diff mbox

Patch

diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 451b00c..32862f0 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -649,7 +649,7 @@  static int btrfs_delayed_inode_reserve_metadata(
 			goto out;
 
 		ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes);
-		if (!WARN_ON(ret))
+		if (!WARN_ON_ONCE(ret))
 			goto out;
 
 		/*