All of lore.kernel.org
 help / color / mirror / Atom feed
From: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
To: Eric Sandeen <esandeen@redhat.com>
Cc: "linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: [PATCH v2] btrfs: remove unnecessary error check
Date: Thu, 10 Jul 2014 15:44:50 +0900	[thread overview]
Message-ID: <53BE3662.5060201@jp.fujitsu.com> (raw)
In-Reply-To: <797384C7-AC2D-45A3-BAAC-B5C717B0C6F1@redhat.com>

(2014/07/10 12:26), Eric Sandeen wrote:
>
>
>> On Jul 9, 2014, at 10:20 PM, Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> wrote:
>>
>> From: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
>>
>> If "(!IS_ERR(trans) || PTR_ERR(trans) != -ENOSPC))" is false,
>> obviously "trans" is -ENOSPC. So we can safely remove the redundant
>> "(PTR_ERR(trans) == -ENOSPC)" check.
>>
>
> True, but now a comment like:
>
> /* Handle ENOSPC */
>
> might still be nice...

Eric, thank you for your comment. I fixed my patch.
How about is it?


===
From: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>

If "(!IS_ERR(trans) || PTR_ERR(trans) != -ENOSPC))" is false,
obviously "trans" is -ENOSPC. So we can safely remove the redundant
"(PTR_ERR(trans) == -ENOSPC)" check.

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>

---
  fs/btrfs/inode.c | 29 +++++++++++++++--------------
  1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 3668048..115aac3 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3803,22 +3803,23 @@ static struct btrfs_trans_handle *__unlink_start_trans(struct inode *dir)
  	if (!IS_ERR(trans) || PTR_ERR(trans) != -ENOSPC)
  		return trans;
  
-	if (PTR_ERR(trans) == -ENOSPC) {
-		u64 num_bytes = btrfs_calc_trans_metadata_size(root, 5);
+	/* Handle ENOSPC */
  
-		trans = btrfs_start_transaction(root, 0);
-		if (IS_ERR(trans))
-			return trans;
-		ret = btrfs_cond_migrate_bytes(root->fs_info,
-					       &root->fs_info->trans_block_rsv,
-					       num_bytes, 5);
-		if (ret) {
-			btrfs_end_transaction(trans, root);
-			return ERR_PTR(ret);
-		}
-		trans->block_rsv = &root->fs_info->trans_block_rsv;
-		trans->bytes_reserved = num_bytes;
+	u64 num_bytes = btrfs_calc_trans_metadata_size(root, 5);
+
+	trans = btrfs_start_transaction(root, 0);
+	if (IS_ERR(trans))
+		return trans;
+	ret = btrfs_cond_migrate_bytes(root->fs_info,
+				       &root->fs_info->trans_block_rsv,
+				       num_bytes, 5);
+	if (ret) {
+		btrfs_end_transaction(trans, root);
+		return ERR_PTR(ret);
  	}
+	trans->block_rsv = &root->fs_info->trans_block_rsv;
+	trans->bytes_reserved = num_bytes;
+
  	return trans;
  }
  
-- 
1.9.3


  reply	other threads:[~2014-07-10  6:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-10  3:19 [PATCH] btrfs: remove unnecessary error check Satoru Takeuchi
2014-07-10  3:26 ` Eric Sandeen
2014-07-10  6:44   ` Satoru Takeuchi [this message]
2014-07-10 13:27     ` [PATCH v2] " Eric Sandeen
2014-07-11  1:35       ` [PATCH v3] " Satoru Takeuchi
2014-07-11 14:23         ` Eric Sandeen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53BE3662.5060201@jp.fujitsu.com \
    --to=takeuchi_satoru@jp.fujitsu.com \
    --cc=esandeen@redhat.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.