linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Bug: misleading free space tree messages when mounting ro
@ 2017-03-30 22:40 Hans van Kranenburg
  0 siblings, 0 replies; only message in thread
From: Hans van Kranenburg @ 2017-03-30 22:40 UTC (permalink / raw)
  To: linux-btrfs

Today I wanted to convert a filesystem to free space tree, because it's
great. But, the filesystem is the root fs, so I could not just umount
and mount it.

I wanted to try to get the conversion done during boot, so I started
messing around with initramfs and grub.

When trying this and doing things like update initramfs, edit grub
settings with rootflags=space_cache=v2 etc, the filesystem *seemed* to
start using the free space tree, but was actually not. Mount output and
dmesg output says: "enabling free space tree", "using free space tree"
etc, but it actually never created the free space tree.

After trying some things, I realized that when doing a readonly mount
the first time, it would be quite understandable that the filesystem
would not do a free space conversion on a readonly target. So, after
using rw instead of ro once in the grub line, it actually happened.

However, when mounting with space_cache=v2 the first time, in
combination with readonly, the messages are quite misleading:

It's easily reproducable with a small test fs:

-# mount -o ro,space_cache=v2 /dev/sdx /mnt/btrfs

BTRFS info (device sdx): enabling free space tree
BTRFS info (device sdx): using free space tree

mount says:

/dev/sdx on /mnt/btrfs type btrfs
(ro,relatime,ssd,space_cache=v2,subvolid=5,subvol=/)

but:

-# ./show_tree_keys.py 10 /mnt/btrfs/
Traceback (most recent call last):
  File "./show_tree_keys.py", line 13, in <module>
    for header, _ in btrfs.ioctl.search_v2(fs.fd, tree):
  File "/home/knorrie/src/git/python-btrfs/examples/btrfs/ioctl.py",
line 265, in search_v2
    fcntl.ioctl(fd, IOC_TREE_SEARCH_V2, buf)
FileNotFoundError: [Errno 2] No such file or directory

Nope, no FST. Not even close.

When mounting rw,space_cache=v2, it actually happens:

BTRFS info (device sdx): creating free space tree
BTRFS info (device sdx): setting 1 ro feature flag
BTRFS info (device sdx): setting 2 ro feature flag

Well... there it is:

-# ./show_tree_keys.py 10 /mnt/btrfs/
(20971520 FREE_SPACE_INFO 8388608)
(20971520 FREE_SPACE_EXTENT 16384)
(21004288 FREE_SPACE_EXTENT 8355840)
(29360128 FREE_SPACE_INFO 1073741824)
(29360128 FREE_SPACE_EXTENT 49152)
(29507584 FREE_SPACE_EXTENT 114688)
(29638656 FREE_SPACE_EXTENT 98304)
(29769728 FREE_SPACE_EXTENT 49152)
(29835264 FREE_SPACE_EXTENT 16384)
(29868032 FREE_SPACE_EXTENT 1073233920)
(1103101952 FREE_SPACE_INFO 2147483648)
(1103101952 FREE_SPACE_EXTENT 2147483648)


So: it would be better to print something in dmesg about "not creating
free space tree, ignoring space_cache=v2 because mounting read only",
instead of keeping the mount option active and printing those messages.

And, of course not displaying the option as active afterwards.

Moo,

-- 
Hans van Kranenburg

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-03-30 22:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-30 22:40 Bug: misleading free space tree messages when mounting ro Hans van Kranenburg

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