* Correct way to clear a free space cache file invalid error @ 2023-01-16 10:22 Martin Steigerwald 2023-01-16 10:41 ` Qu Wenruo 0 siblings, 1 reply; 5+ messages in thread From: Martin Steigerwald @ 2023-01-16 10:22 UTC (permalink / raw) To: linux-btrfs Sorry for incomplete subject, reposting. Hi! Kernel 6.1, btrfs-progs 6.1.2. Filesystem on NVME SSD, via LVM and dm- crypt. I would like [ 18.657903] BTRFS info (device dm-1): the free space cache file (23912775680) is invalid, skip it [ 18.697033] BTRFS info (device dm-1): the free space cache file (25254952960) is invalid, skip it to be gone. So I tried mount -o remount,clear_cache,space_cache=v1 / as well as mount -o remount,clear_cache / mount -o remount,space_cache=v1 / to no avail. Before that I had space cache v2 on the filesystem as with most of my other BTRFS filesystems. But since it really should not be necessary for a 50 GiB filesystem for the Linux system (not user data), I thought I play it safe this time. At least from what I learned from btrfs manpage. In a page on BTRFS wiki it is stated that one should run "btrfs check" on the filesystem. So what is the correct way to clear that error? I did not perceive any malfunctioning due to the error in dmesg. The filesystem scrubs without errors. Best, -- Martin ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Correct way to clear a free space cache file invalid error 2023-01-16 10:22 Correct way to clear a free space cache file invalid error Martin Steigerwald @ 2023-01-16 10:41 ` Qu Wenruo 2023-01-16 14:07 ` [PATCH] btrfs-progs: docs: improve space cache documentation Christoph Anton Mitterer 2023-01-16 15:30 ` Correct way to clear a free space cache file invalid error Martin Steigerwald 0 siblings, 2 replies; 5+ messages in thread From: Qu Wenruo @ 2023-01-16 10:41 UTC (permalink / raw) To: Martin Steigerwald, linux-btrfs On 2023/1/16 18:22, Martin Steigerwald wrote: > Sorry for incomplete subject, reposting. > > Hi! > > Kernel 6.1, btrfs-progs 6.1.2. Filesystem on NVME SSD, via LVM and dm- > crypt. > > I would like > > [ 18.657903] BTRFS info (device dm-1): the free space cache file > (23912775680) is invalid, skip it > [ 18.697033] BTRFS info (device dm-1): the free space cache file > (25254952960) is invalid, skip it > > to be gone. > > So I tried > > mount -o remount,clear_cache,space_cache=v1 / > > as well as > > mount -o remount,clear_cache / > mount -o remount,space_cache=v1 / > > to no avail. > > Before that I had space cache v2 on the filesystem as with most of my > other BTRFS filesystems. But since it really should not be necessary for > a 50 GiB filesystem for the Linux system (not user data), I thought I > play it safe this time. At least from what I learned from btrfs manpage. > > In a page on BTRFS wiki it is stated that one should run "btrfs check" > on the filesystem. > > So what is the correct way to clear that error? "btrfs check --clear-space-cache v1 <device>". Of course you need to unmount the fs in the first place. The clear_cache mount option only clears the old cache of touched bgs. If the bg is not touched during the runtime, it won't be modified. Or, you can go v2 cache, which would drop the v1 cache at the first mount. Thanks, Qu > > I did not perceive any malfunctioning due to the error in dmesg. The > filesystem scrubs without errors. > > Best, ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] btrfs-progs: docs: improve space cache documentation 2023-01-16 10:41 ` Qu Wenruo @ 2023-01-16 14:07 ` Christoph Anton Mitterer 2023-01-16 15:24 ` Christoph Anton Mitterer 2023-01-16 15:30 ` Correct way to clear a free space cache file invalid error Martin Steigerwald 1 sibling, 1 reply; 5+ messages in thread From: Christoph Anton Mitterer @ 2023-01-16 14:07 UTC (permalink / raw) To: linux-btrfs - "Wipe" in storage terms is often understood as some kind of secure deletion. Use "remove" instead in order to indicate that the space cache is fully removed (and not just cleared and then e.g. automatically rebuild). - The --clear-space-cache option for btrfs check actually clears the whole space cache, just as documented. Thus move any documentation about the clear_cache mount option not doing so for v1 to that. Instead, refer to the mount option. - Also note that when clear_cache is used with v1, the free space cache for block groups that are modified gets always cleared, but rebuilt only if nospace_cache is not used. Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name> --- Documentation/btrfs-check.rst | 12 ++---------- Documentation/ch-mount-options.rst | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Documentation/btrfs-check.rst b/Documentation/btrfs-check.rst index bca0e7f8..1bd35fe2 100644 --- a/Documentation/btrfs-check.rst +++ b/Documentation/btrfs-check.rst @@ -79,17 +79,9 @@ SAFE OR ADVISORY OPTIONS superblock is damaged. --clear-space-cache v1|v2 - completely wipe all free space cache of given type + completely remove the free space cache of the given version - For free space cache *v1*, the *clear_cache* kernel mount option only rebuilds - the free space cache for block groups that are modified while the filesystem is - mounted with that option. Thus, using this option with *v1* makes it possible - to actually clear the entire free space cache. - - For free space cache *v2*, the *clear_cache* kernel mount option destroys - the entire free space cache. This option, with *v2* provides an alternative - method of clearing the free space cache that doesn't require mounting the - filesystem. + See also the *clear_cache* mount option. --clear-ino-cache remove leftover items pertaining to the deprecated inode map feature diff --git a/Documentation/ch-mount-options.rst b/Documentation/ch-mount-options.rst index 3536a5bb..c9b64f19 100644 --- a/Documentation/ch-mount-options.rst +++ b/Documentation/ch-mount-options.rst @@ -86,8 +86,19 @@ check_int, check_int_data, check_int_print_mask=<value> for more information. clear_cache - Force clearing and rebuilding of the disk space cache if something - has gone wrong. See also: *space_cache*. + Force clearing and rebuilding of the free space cache if something + has gone wrong. + + For free space cache *v1*, this only clears (and, unless *nospace_cache* is + used, rebuilds) the free space cache for block groups that are modified while + the filesystem is mounted with that option. To actually clear an entire free + space cache *v1*, see ``btrfs check --clear-space-cache v1``. + + For free space cache *v2*, this clears the entire free space cache. + To do so without requiring to mounting the filesystem, see + ``btrfs check --clear-space-cache v2``. + + See also: *space_cache*. commit=<seconds> (since: 3.12, default: 30) @@ -348,7 +359,8 @@ space_cache, space_cache=<version>, nospace_cache implementation, which adds a new b-tree called the free space tree, addresses this issue. Once enabled, the *v2* space cache will always be used and cannot be disabled unless it is cleared. Use *clear_cache,space_cache=v1* or - *clear_cache,nospace_cache* to do so. If *v2* is enabled, kernels without *v2* + *clear_cache,nospace_cache* to do so. If *v2* is enabled, and *v1* space + cache will be cleared (at the first mount) and kernels without *v2* support will only be able to mount the filesystem in read-only mode. The :doc:`btrfs-check(8)<btrfs-check>` and `:doc:`mkfs.btrfs(8)<mkfs.btrfs>` commands have full *v2* free space -- 2.39.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs-progs: docs: improve space cache documentation 2023-01-16 14:07 ` [PATCH] btrfs-progs: docs: improve space cache documentation Christoph Anton Mitterer @ 2023-01-16 15:24 ` Christoph Anton Mitterer 0 siblings, 0 replies; 5+ messages in thread From: Christoph Anton Mitterer @ 2023-01-16 15:24 UTC (permalink / raw) To: linux-btrfs Hey Qu, Dave. Since the space cache clearing options remain a source for confusion, I'd have written the above patch (there's also a draft PR) which tries to improve the documentation a bit. What remains open (which why the patch/PR is just a draft) is: a) Does --clear-space-cache v1|v2 really remove (or just clear) any space cache from the fs? Or is there even a difference? Especially, when I ran --clear-space-cache v1|v2 and then mount the fs (without neither nospace_cache nor space_cache[=*])... will it automatically get a new space cache, if so, which? b) Is my assumption correct, that with v1, clear_cache itself really only clears the space cache for written blocks but not automatically rebuilds it. I.e. when clear_cache,nospace_cache would be used, its just cleared but not rebuild. c) What about clear_cache and v2? Is it only clearing? Or is it, unless nospace_cache is used, right after clearing completely rebuilt? Cheers, Chris. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Correct way to clear a free space cache file invalid error 2023-01-16 10:41 ` Qu Wenruo 2023-01-16 14:07 ` [PATCH] btrfs-progs: docs: improve space cache documentation Christoph Anton Mitterer @ 2023-01-16 15:30 ` Martin Steigerwald 1 sibling, 0 replies; 5+ messages in thread From: Martin Steigerwald @ 2023-01-16 15:30 UTC (permalink / raw) To: linux-btrfs, Qu Wenruo Qu Wenruo - 16.01.23, 11:41:07 CET: > On 2023/1/16 18:22, Martin Steigerwald wrote: […] > > So what is the correct way to clear that error? > > "btrfs check --clear-space-cache v1 <device>". > > Of course you need to unmount the fs in the first place. > > The clear_cache mount option only clears the old cache of touched bgs. > If the bg is not touched during the runtime, it won't be modified. > > Or, you can go v2 cache, which would drop the v1 cache at the first > mount. Thanks. I went to v2 cache during rebooting by putting the mount options for that in /etc/fstab temporarily. This appears to have worked. Ciao, -- Martin ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-01-16 15:34 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-01-16 10:22 Correct way to clear a free space cache file invalid error Martin Steigerwald 2023-01-16 10:41 ` Qu Wenruo 2023-01-16 14:07 ` [PATCH] btrfs-progs: docs: improve space cache documentation Christoph Anton Mitterer 2023-01-16 15:24 ` Christoph Anton Mitterer 2023-01-16 15:30 ` Correct way to clear a free space cache file invalid error Martin Steigerwald
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).