All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: DEBUG fiemap: Show more info about extent_fiemap
@ 2017-06-21  9:28 Qu Wenruo
       [not found] ` <20170621121021.3lx3chb23flvu2re@angband.pl>
  0 siblings, 1 reply; 2+ messages in thread
From: Qu Wenruo @ 2017-06-21  9:28 UTC (permalink / raw)
  To: linux-btrfs, kilobyte

Hi Adam,

Would you please try this patch based on v4.12-rc5 and try to reproduce
the kernel warning?

It would be better to eliminate the noisy by ensure there is no other fiemap
caller on btrfs.

Thanks,
Qu

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 fs/btrfs/extent_io.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index d3619e0..ebebfb0 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -4406,6 +4406,8 @@ static int emit_fiemap_extent(struct fiemap_extent_info *fieinfo,
 {
 	int ret = 0;
 
+	pr_info("%s: entered: offset=%llu phys=%llu len=%llu flags=0x%x\n",
+		__func__, offset, phys, len, flags);
 	if (!cache->cached)
 		goto assign;
 
@@ -4417,7 +4419,7 @@ static int emit_fiemap_extent(struct fiemap_extent_info *fieinfo,
 	 * NOTE: Physical address can overlap, due to compression
 	 */
 	if (cache->offset + cache->len > offset) {
-		WARN_ON(1);
+		pr_info("%s: Sanity check failed\n", __func__);
 		return -EINVAL;
 	}
 
@@ -4438,16 +4440,23 @@ static int emit_fiemap_extent(struct fiemap_extent_info *fieinfo,
 			(flags & ~FIEMAP_EXTENT_LAST)) {
 		cache->len += len;
 		cache->flags |= flags;
+		pr_info("%s: merged, new offset=%llu len=%llu flags=0x%x\n", __func__,
+			cache->offset, cache->len, cache->flags);
 		goto try_submit_last;
 	}
 
+	pr_info("%s: submit cached fiemap: offset=%llu len=%llu flags=0x%x\n",
+		__func__, cache->offset, cache->len, cache->flags);
 	/* Not mergeable, need to submit cached one */
 	ret = fiemap_fill_next_extent(fieinfo, cache->offset, cache->phys,
 				      cache->len, cache->flags);
 	cache->cached = false;
-	if (ret)
+	if (ret) {
+		pr_info("%s: cached submit exit ret=%d\n", __func__, ret);
 		return ret;
+	}
 assign:
+	pr_info("%s: assigning new fiemap\n", __func__);
 	cache->cached = true;
 	cache->offset = offset;
 	cache->phys = phys;
@@ -4455,10 +4464,13 @@ static int emit_fiemap_extent(struct fiemap_extent_info *fieinfo,
 	cache->flags = flags;
 try_submit_last:
 	if (cache->flags & FIEMAP_EXTENT_LAST) {
+		pr_info("%s: submit last fiemap: offset=%llu len=%llu flags=0x%x\n",
+			__func__, cache->offset, cache->len, cache->flags);
 		ret = fiemap_fill_next_extent(fieinfo, cache->offset,
 				cache->phys, cache->len, cache->flags);
 		cache->cached = false;
 	}
+	pr_info("%s: last exit ret=%d\n", __func__, ret);
 	return ret;
 }
 
@@ -4525,6 +4537,9 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 		return -ENOMEM;
 	path->leave_spinning = 1;
 
+	pr_info("%s: enter: root=%llu inode=%llu start=%llu len=%llu\n",
+		__func__, root->objectid, btrfs_ino(BTRFS_I(inode)),
+		start, len);
 	start = round_down(start, btrfs_inode_sectorsize(inode));
 	len = round_up(max, btrfs_inode_sectorsize(inode)) - start;
 
@@ -4696,6 +4711,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 		if (ret) {
 			if (ret == 1)
 				ret = 0;
+			pr_info("%s: out_free after emit_fiemap_extent\n", __func__);
 			goto out_free;
 		}
 	}
@@ -4707,6 +4723,9 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 	btrfs_free_path(path);
 	unlock_extent_cached(&BTRFS_I(inode)->io_tree, start, start + len - 1,
 			     &cached_state, GFP_NOFS);
+	pr_info("%s: exit: ret=%d root=%llu inode=%llu start=%llu len=%llu\n",
+		__func__, ret, root->objectid, btrfs_ino(BTRFS_I(inode)),
+		start, len);
 	return ret;
 }
 
-- 
2.9.3




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

* Re: [PATCH] btrfs: DEBUG fiemap: Show more info about extent_fiemap
       [not found] ` <20170621121021.3lx3chb23flvu2re@angband.pl>
@ 2017-06-22  0:39   ` Qu Wenruo
  0 siblings, 0 replies; 2+ messages in thread
From: Qu Wenruo @ 2017-06-22  0:39 UTC (permalink / raw)
  To: Adam Borowski; +Cc: linux-btrfs



At 06/21/2017 08:10 PM, Adam Borowski wrote:
> On Wed, Jun 21, 2017 at 05:28:50PM +0800, Qu Wenruo wrote:
>> Would you please try this patch based on v4.12-rc5 and try to reproduce
>> the kernel warning?
>>
>> It would be better to eliminate the noisy by ensure there is no other fiemap
>> caller on btrfs.
> 
> Here's my current dmesg buffer from a single dpkg --reinstall invocation.
>

Thanks for the dmesg!

The problem is if the fiemap range is smaller than the extent, we will 
exit without emit fiemap extent to VFS, leaving it cached.

As shown in your dmesg:
---
  extent_fiemap: enter: root=10152 inode=5353157 start=0 len=4096
  emit_fiemap_extent: entered: offset=0 phys=2012381351936 len=131072 
flags=0x2008
  emit_fiemap_extent: assigning new fiemap
  emit_fiemap_extent: last exit ret=0
  ------------[ cut here ]------------
---

Your dmesg really helps a lot!

I'll send the fix in this week.

Thanks,
Qu



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

end of thread, other threads:[~2017-06-22  0:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-21  9:28 [PATCH] btrfs: DEBUG fiemap: Show more info about extent_fiemap Qu Wenruo
     [not found] ` <20170621121021.3lx3chb23flvu2re@angband.pl>
2017-06-22  0:39   ` Qu Wenruo

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.