From: lutz.euler@freenet.de (Lutz Euler)
To: linux-btrfs@vger.kernel.org
Subject: Bulk discard doesn't work after add/delete of devices
Date: Sun, 5 Feb 2012 21:37:13 +0100 [thread overview]
Message-ID: <20270.59513.240729.662692@localhost.localdomain> (raw)
... maybe even the block group cache is nonfunctional then?
I am using a btrfs file system, mirrored data and metadata on two SSDs,
and recently tried for the first time to run fstrim on it. fstrim
unexpectedly said "0 bytes were trimmed". strace -T shows that it spends
only a few microseconds in the ioctl system call (basically the overhead
of strace, it seems), so I engaged in some "printk" debugging and found
that after "btrfs_trim_fs" executes its first statement,
cache = btrfs_lookup_block_group(fs_info, range->start);
cache is 0. As the file system was created with a very recent kernel and
always mounted with the default "space_cache" option I guessed that this
might have something to do with the fact that I exchanged both the
filesystem's devices earlier (as you can see from the devid's in the
following output -- this is the only btrfs file system on the machine):
# btrfs fi show /dev/sda3
Label: none uuid: 88af7576-3027-4a3b-a5ae-34bfd167982f
Total devices 2 FS bytes used 28.13GB
devid 4 size 74.53GB used 38.06GB path /dev/sdb1
devid 3 size 75.24GB used 38.06GB path /dev/sda3
("exchanged" means: I created the filesystem as a mirror of sdb1 and
sdb2, put data on it, then added sda3, balanced, deleted sdb2, balanced
again, then unmounted, repartitioned sdb1 and sdb2 together as a larger
sdb1, mounted degraded, added sdb1, balanced and deleted "missing".)
So I tried to reproduce this and got the following:
# dd if=/dev/zero of=img0 bs=1 count=0 seek=5G
# dd if=/dev/zero of=img1 bs=1 count=0 seek=5G
# losetup -f img0
# losetup -f img1
# mkfs.btrfs -d raid1 -m raid1 /dev/loop0 /dev/loop1
# mount /dev/loop0 /mnt
# fstrim -v /mnt
/mnt: 4332265472 bytes were trimmed
(The above mentioned kernel instrumentation shows that "cache" was
not 0 here.)
# dd if=/dev/zero of=img2 bs=1 count=0 seek=5G
# losetup -f img2
# btrfs device add /dev/loop2 /mnt
# btrfs device delete /dev/loop0 /mnt
# fstrim -v /mnt
/mnt: 0 bytes were trimmed
("cache" was 0 here.)
Software versions: See my earlier mail about degraded mirrors;
reproducing the issue was on v3.3-rc2-172-g23783f8. I built fstrim
from git, that is, util-linux pulled yesterday from git.kernel.org.
What's going on here?
If the space cache is indeed broken on this filesystem, can I repair
it without risk to my data?
By mounting with "nospace_cache" once or somehow using "clear_cache"?
Greetings,
Lutz
next reply other threads:[~2012-02-05 20:37 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-05 20:37 Lutz Euler [this message]
2012-02-09 8:42 ` Bulk discard doesn't work after add/delete of devices Liu Bo
2012-02-09 15:50 ` Lutz Euler
2012-02-10 1:56 ` Liu Bo
2012-02-12 17:01 ` Lutz Euler
2012-02-13 5:57 ` Liu Bo
2012-02-14 17:32 ` Lutz Euler
2012-02-29 0:17 ` Lutz Euler
2012-04-10 17:34 ` Lutz Euler
2012-11-14 21:10 ` Lutz Euler
2012-11-14 21:17 ` [PATCH] Btrfs: really fix trim 0 bytes after a device delete Lutz Euler
2015-01-03 15:30 ` [PATCH V2] " Lutz Euler
2015-01-03 16:16 ` fstrim not working on one of three BTRFS filesystems Lutz Euler
2015-05-19 15:18 ` Rich Freeman
2015-01-05 16:59 ` [PATCH V2] Btrfs: really fix trim 0 bytes after a device delete Martin Steigerwald
2015-01-05 19:29 ` Lutz Euler
2015-05-01 10:43 ` Martin Steigerwald
-- strict thread matches above, loose matches on Subject: below --
2014-12-28 16:58 fstrim not working on one of three BTRFS filesystems Martin Steigerwald
2014-12-29 1:53 ` Robert White
2014-12-29 2:08 ` Duncan
2014-12-29 9:06 ` Martin Steigerwald
2014-12-29 13:23 ` Martin Steigerwald
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=20270.59513.240729.662692@localhost.localdomain \
--to=lutz.euler@freenet.de \
--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 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).