5

I'm running a synology nas DS1817+ with DSM 6.2.2-24922 with a RAID5 volume formatted with BTRFS.

Deleting a large file either with DSM FileStation or directly in an ssh session with "rm filename" takes a long time.

bash-4.3# ls -al
total 31362720
drwxr-xr-x 1 root root         154 Apr 13 05:09 .
drwxr-xr-x 1 root root          86 Apr 13 05:09 ..
-rw------- 1 root root 42949672960 Apr 13 05:09 Zoll-VM-flat.vmdk

bash-4.3# time rm Zoll-VM-flat.vmdk 

real    7m24.817s
user    0m0.000s
sys     0m6.435s

Why? Looking at iotop it seems to be, that it reads and writes the whole file?!?

Klaus
  • 161
  • 4
  • I believe this to be an issue with BTRFS itsef, (See: https://btrfs.wiki.kernel.org/index.php/RAID56). – oxr463 Jun 05 '19 at 16:46
  • The linux 5.6 kernel has a mount option `discard=async` [1]. I'm keenly curious if that will affect this use case. [1] https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git/commit/?h=for-next&id=717b684118e3c3c73e4beeea8535b3bb90c33ebb – user67327 Sep 27 '20 at 01:32
  • I have a RAID1 system and see 13 seconds to `rm` a 48GB file. – user67327 Sep 27 '20 at 01:38
  • @Klaus Is it possible you are using shingled magnet recording (SMR) disks? See this benchmark... https://arstechnica.com/gadgets/2020/06/western-digitals-smr-disks-arent-great-but-theyre-not-garbage/ – user67327 Sep 27 '20 at 21:42

1 Answers1

1

btrfs is a CoW filesystem which uses 4K blocks as the base "record" size. This, for large files with intense rewrite workload (as your vm disk file) will cause immense data and metadata fragmentation. You can check data fragmentation by running filefrag -v <diskfile> and counting the number or fragments; when altering each fragment, a metadata record should be create/modified.

With volumes on classical mechanical disks, deleting such files will require a fair amount of time, especially when running on raid5/6.

So I don't think you can avoid that long delete time. Give a look here for a similar case.

shodanshok
  • 47,711
  • 7
  • 111
  • 180
  • I should mention that this is only a backup system, so the file was only written once and i doubt that there will be much fragmentation. Sadly there is no `filefrag` tool on the Synology NAS – Klaus Jun 11 '19 at 10:20