BTRFS Problem read-only / free space

I own a Samsung U.2 pro ssd, it’s pcie 3 / nvme interface.
Today i get strange behavior… I have error in qbittorrent that said there is no more free space on the device (there is 2.7 TB to free space…). It also said the device is in read only mode, and indeed i couldn’t access my data anyhow. A reboot solve the problem but it seems temporary.
I must specify i have a power-down in my home today and the device was in use.

I tried a btrfs check with gparted, and it gives an error.

btrfs check ‘/dev/nvme1n1p1’ 00:00:21 ( ERREUR )

[1/7] checking root items
[2/7] checking extents
[3/7] checking free space cache
there is no free space entry for 3554107473920-3554107523072
cache appears valid but isn’t 3554107457536
Duplicate entries in free space cache
failed to load free space cache for block group 6284632915968
btrfs: unable to add free space :-17
kernel-shared/free-space-cache.c:883: merge_space_tree: BUG_ON ret triggered, value -17

The result of

sudo smartctl -x -q noserial /dev/nvme1

smartctl 7.3 2022-02-28 r5338 [x86_64-linux-6.0.2-2-MANJARO] (local build)
Copyright (C) 2002-22, Bruce Allen, Christian Franke,

Model Number: SAMSUNG MZQLB7T6HMLA-00007
Firmware Version: EDB5002Q
PCI Vendor/Subsystem ID: 0x144d
IEEE OUI Identifier: 0x002538
Total NVM Capacity: 7 681 501 126 656 [7,68 TB]
Unallocated NVM Capacity: 0
Controller ID: 4
NVMe Version: 1.2
Number of Namespaces: 1
Namespace 1 Size/Capacity: 7 681 501 126 656 [7,68 TB]
Namespace 1 Utilization: 6 317 451 087 872 [6,31 TB]
Namespace 1 Formatted LBA Size: 512
Local Time is: Sun Oct 23 02:56:54 2022 CEST
Firmware Updates (0x17): 3 Slots, Slot 1 R/O, no Reset required
Optional Admin Commands (0x000f): Security Format Frmw_DL NS_Mngmt
Optional NVM Commands (0x001f): Comp Wr_Unc DS_Mngmt Wr_Zero Sav/Sel_Feat
Log Page Attributes (0x03): S/H_per_NS Cmd_Eff_Lg
Maximum Data Transfer Size: 512 Pages
Warning Comp. Temp. Threshold: 86 Celsius
Critical Comp. Temp. Threshold: 87 Celsius
Namespace 1 Features (0x02): NA_Fields

Supported Power States
St Op Max Active Idle RL RT WL WT Ent_Lat Ex_Lat
0 + 10.60W - - 0 0 0 0 0 0

Supported LBA Sizes (NSID 0x1)
Id Fmt Data Metadt Rel_Perf
0 + 512 0 0
1 - 4096 0 0

SMART overall-health self-assessment test result: PASSED

SMART/Health Information (NVMe Log 0x02)
Critical Warning: 0x00
Temperature: 35 Celsius
Available Spare: 100%
Available Spare Threshold: 10%
Percentage Used: 0%
Data Units Read: 134 841 383 [69,0 TB]
Data Units Written: 80 366 567 [41,1 TB]
Host Read Commands: 261 484 642
Host Write Commands: 257 476 881
Controller Busy Time: 1 141
Power Cycles: 1 731
Power On Hours: 14 885
Unsafe Shutdowns: 272
Media and Data Integrity Errors: 2
Error Information Log Entries: 3 613
Warning Comp. Temperature Time: 0
Critical Comp. Temperature Time: 0
Temperature Sensor 1: 35 Celsius
Temperature Sensor 2: 40 Celsius
Temperature Sensor 3: 47 Celsius

Error Information (NVMe Log 0x01, 16 of 64 entries)
Num ErrCount SQId CmdId Status PELoc LBA NSID VS
0 3613 0 0x0000 0x4004 - 0 0 -

Seems to be a space_cache problem…

# try v1 or v2 ... no idea which one is used here...
sudo btrfs check --clear-space-cache v2 /dev/nvme1n1p1
sudo mount -m /dev/nvme1n1p1 /mnt/nvme1n1p1
sudo btrfs filesystem usage /mnt/nvme1n1p1

I would recommend disabling space_cache on nvme’s and ssd’s with the mount option: nospace_cache in fstab.

You find good Information about Btrfs in the wiki

there is a special section about NO SPACE - problems

and in

Welcome to Manjaro! :smiling_face_with_three_hearts:

  1. Please read the information behind this link. It will help you to post necessary information. [HowTo] Provide System Information
  2. Please press the three dots below your post and then press the :pencil2:
  • If you give us information about your system, we can see what we’re talking about and make better suggestions.
  • You can do this by using inxi in a terminal or in console.
inxi --admin --verbosity=7 --filter --no-host --width
  • Personally identifiable information such as serial numbers and MAC addresses are filtered out by this command
  • Presenting the information in this way allows everyone to be familiar with the format and quickly find the items they need without missing anything.
  1. Copy the output from inxi (including the command) and paste it into your post.
  • To make it more readable, add 3 backticks ``` on an extra line before and after the pasted text.
    (Wisdom lies in reading :wink: )


Thank you it solves the problem.
I try to use nospace_cache in my fstab but the other ssd i have make an error at boot, so i also use the command to clear space cache and now it’s ok.

Thank you !

1 Like