linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* btrfs -o discard bug in latest dev branches
@ 2015-08-26  4:04 Jun He
  2015-08-26  6:14 ` Duncan
  2015-08-26 13:24 ` Jeff Mahoney
  0 siblings, 2 replies; 6+ messages in thread
From: Jun He @ 2015-08-26  4:04 UTC (permalink / raw)
  To: linux-btrfs, jeffm

Hi,
I have been playing with btrfs discard for a while and found that btrfs may
fail to discard some extents with 'mount -o discard'. I am aware of Jeff
Mahoney's patches ( https://patchwork.kernel.org/patch/6609491/ ). It seems
that the patches do not fix the problem. I have seen the same problematic
behavior for the following versions 

- https://git.kernel.org/cgit/linux/kernel/git/fdmanana/linux.git/
  integration-4.3 commit:477594f93c43b1ee685
- 3.16.0
- 4.2.0-rc7

The problem can be reproduced by writing and fsyncing a 4MB file for 50 times
on a 256MB empty FS (mount option: -o discard). You will find that some extents
are not discarded (my expected behavior is that, after overwriting, an old
version of a file extent should be discarded). I use several ways to confirm
this:

1. I created a loop device back by a sparse file in tmpfs. After running the
workload, I found the file is 29MB (ls -lsh). If you fstrim the file system,
the sparse file will become 4.1MB. This proves that there are a lot of data not
discarded.

2. I collected blktrace + blkparse output and plotted the write and discard
operations in a space-time graph, where you can intuitively see some extents
are overwritten but not discarded. Here is the space-time graph
https://gist.githubusercontent.com/junhe/b6ce39eeb6de8887e66a/raw/825a3c2946b52a50c2b6032a98d637f5a32bc5c3/integration-4.3.png

Is it a known problem or is it not a problem? If it is a known problem and
there exists a patch that I am not aware of, can somebody direct me to it? If
it is specifically designed this way, can the designers give the rationale of
discarding some, but not all of, old extents?

The reproducer can be run by:
git clone https://gist.github.com/b6ce39eeb6de8887e66a.git
cd b6ce39eeb6de8887e66a
sudo python main.py

It also has a readme.

Thanks,
Jun




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

end of thread, other threads:[~2015-08-27  3:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-26  4:04 btrfs -o discard bug in latest dev branches Jun He
2015-08-26  6:14 ` Duncan
2015-08-26 19:09   ` Jun He
2015-08-26 13:24 ` Jeff Mahoney
2015-08-26 16:02   ` Jun He
2015-08-27  3:03     ` Jun He

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