linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: linux-btrfs@vger.kernel.org, linux-xfs@vger.kernel.org
Cc: "Darrick J. Wong" <darrick.wong@oracle.com>,
	Qu Wenruo <quwenruo@cn.fujitsu.com>,
	Christoph Hellwig <hch@infradead.org>,
	kernel-team@fb.com
Subject: [RFC PATCH 1/2] Btrfs: refactor btrfs_extent_same() slightly
Date: Thu, 17 Nov 2016 16:07:49 -0800	[thread overview]
Message-ID: <35c668f0a23e0424569f812523c76a1828219f76.1479427384.git.osandov@fb.com> (raw)
In-Reply-To: <cover.1479427384.git.osandov@fb.com>
In-Reply-To: <cover.1479427384.git.osandov@fb.com>

From: Omar Sandoval <osandov@fb.com>

This just makes the following patch cleaner.

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

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 7acbd2c..e23f945 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3124,26 +3124,27 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
 	int ret;
 	u64 len = olen;
 	struct cmp_pages cmp;
-	int same_inode = 0;
+	bool same_inode = (src == dst);
 	u64 same_lock_start = 0;
 	u64 same_lock_len = 0;
 
-	if (src == dst)
-		same_inode = 1;
-
 	if (len == 0)
 		return 0;
 
-	if (same_inode) {
+	if (same_inode)
 		inode_lock(src);
+	else
+		btrfs_double_inode_lock(src, dst);
 
-		ret = extent_same_check_offsets(src, loff, &len, olen);
-		if (ret)
-			goto out_unlock;
-		ret = extent_same_check_offsets(src, dst_loff, &len, olen);
-		if (ret)
-			goto out_unlock;
+	ret = extent_same_check_offsets(src, loff, &len, olen);
+	if (ret)
+		goto out_unlock;
 
+	ret = extent_same_check_offsets(dst, dst_loff, &len, olen);
+	if (ret)
+		goto out_unlock;
+
+	if (same_inode) {
 		/*
 		 * Single inode case wants the same checks, except we
 		 * don't want our length pushed out past i_size as
@@ -3171,16 +3172,6 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
 
 		same_lock_start = min_t(u64, loff, dst_loff);
 		same_lock_len = max_t(u64, loff, dst_loff) + len - same_lock_start;
-	} else {
-		btrfs_double_inode_lock(src, dst);
-
-		ret = extent_same_check_offsets(src, loff, &len, olen);
-		if (ret)
-			goto out_unlock;
-
-		ret = extent_same_check_offsets(dst, dst_loff, &len, olen);
-		if (ret)
-			goto out_unlock;
 	}
 
 	/* don't make the dst file partly checksummed */
-- 
2.10.2


  reply	other threads:[~2016-11-18  0:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-18  0:07 [RFC PATCH 0/2] Btrfs: make a source length of 0 imply EOF for dedupe Omar Sandoval
2016-11-18  0:07 ` Omar Sandoval [this message]
2016-11-18  3:22   ` [RFC PATCH 1/2] Btrfs: refactor btrfs_extent_same() slightly Qu Wenruo
2016-11-18  0:07 ` [RFC PATCH 2/2] Btrfs: make a source length of 0 imply EOF for dedupe Omar Sandoval
2016-11-18  5:38 ` [RFC PATCH 0/2] " Christoph Hellwig
2016-11-22 21:17   ` Darrick J. Wong
2016-11-23  2:02 ` Zygo Blaxell
2016-11-23  2:44   ` Darrick J. Wong
2016-11-24  5:16     ` Zygo Blaxell
2016-11-23  4:26   ` Dave Chinner
2016-11-23 13:55     ` Zygo Blaxell
2016-11-23 22:13       ` Dave Chinner
2016-11-23 23:14         ` Zygo Blaxell
2016-11-23 23:53           ` Dave Chinner
2016-11-24  1:26             ` Darrick J. Wong
2016-11-25  4:20               ` Zygo Blaxell
2016-11-28 17:58                 ` Darrick J. Wong

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=35c668f0a23e0424569f812523c76a1828219f76.1479427384.git.osandov@fb.com \
    --to=osandov@osandov.com \
    --cc=darrick.wong@oracle.com \
    --cc=hch@infradead.org \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=quwenruo@cn.fujitsu.com \
    /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 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).