I ran compsize on my debian box. Most files on my btrfs drive are around 20 GB. Almost all are uncompressed. I have 6000 files and 221000 regular extents.

Is that too much fragmentation? The ideal case is 1 extent per file.

I am reading around 100 MiBps from the drive out of a theoretical max of ~119 MiBps on a 1 Gbps line.

edit: On a local read I am getting 130-150 MiBps which exceeds the 1 Gbps network. pv /path/to/file >/dev/null

  • There is no “normal” amount of fragmentation on modern filesystems that do things like CoW. That’s kind of the point.

    If you’re reading and writing large files with a consistent amount of I/O, you’re going to have a higher amount of fragmentation because of the nature of CoW. This is by design. This doesn’t mean anything is wrong with the filesystem, just that peak performance soon after writing is not achieved. Btrfs and ZFS do online defrag and deferred scheduling of tasks for it to allow for EVENTUAL consistency as far as contiguous block forms go. The more free space you have, the sooner it will become cleaner.

    • 11 minutes

      Note: BTRFS defrag will result in a different copy at the end of the day. If you’re using snapshots this will lead to increased utilization.

    • Btrfs and ZFS do online defrag

      News to me for ZFS. Are you talking about the recently implemented rewrite? Because “defrag” isnt really what that does, it simply consolidates metaslab data to (possibly) free up low-use blocks.

      Using ZFS fragmentation profile import/export and/or enabling dynamic gang headers can certainly help with high fragmentation.

    • Btrfs … do online defrag and deferred scheduling of tasks for it to allow for EVENTUAL consistency as far as contiguous block forms go. The more free space you have, the sooner it will become cleaner.

      Based on my research, this has to be requested by the user/OS. I don’t think Openmediavault (Debian derivative) enables auto defrag out of the box. If I set this up manually, I definitely didn’t enable it. You can run a defrag command online (while the system is running) or set the mount to do it automatically.

      • It should be a default, but I can see why it would be disabled for SSDs to prevent using cycles unnecessarily. If you’re using HDDs, check and see if it’s enabled.

        Either way, unless you’re REALLY needing some minor performance improvements out of your disks, it shouldn’t make a huge difference.