Jump to content

btrfs raid1 cache wrong free space


Go to solution Solved by JorgeB,

Recommended Posts

I have been using unraid(4 active hosts) for more than 6-7 years, and had no problems when using xfs for cache.
On one of the hosts,which we use as a test platform in our company,I added a second cache drive(same size,same type as the first one).
The requirements for using raid1 was to convert the filesystem to btrfs.
I managed to create the raid1 cache pool, and everything works as intended.
However, when checking the free size from unraid, main, under pool devices, unraid shows 42.6GB free.

unraid1.thumb.jpg.88ae7004c3296ca3ebb7f32584220183.jpg


If I go to console, start mc, and use command,show directory sizes, the /mnt/cache shows 1448GB out of 1838GB is used.

unraid2.thumb.jpg.e0a9e115f38f6b1eaed7e79870f4d295.jpg
We use this node only as a virtualization platform, so nothing is used for storage (just a few backups).
We only have shares for appdata,domains and isos.
How can I reclaim the missing space without ruining anything ?

Edited by milanp
Link to comment

This is the output:

Overall:
    Device size:                   3.64TiB
    Device allocated:              3.57TiB
    Device unallocated:           71.91GiB
    Device missing:                  0.00B
    Device slack:                    0.00B
    Used:                          3.56TiB
    Free (estimated):             39.70GiB      (min: 39.70GiB)
    Free (statfs, df):            39.69GiB
    Data ratio:                       2.00
    Metadata ratio:                   2.00
    Global reserve:              512.00MiB      (used: 0.00B)
    Multiple profiles:                  no

             Data    Metadata System                             
Id Path      RAID1   RAID1    RAID1     Unallocated Total   Slack
-- --------- ------- -------- --------- ----------- ------- -----
 1 /dev/sdd1 1.78TiB  4.00GiB  32.00MiB    35.95GiB 1.82TiB     -
 2 /dev/sdb1 1.78TiB  4.00GiB  32.00MiB    35.95GiB 1.82TiB     -
-- --------- ------- -------- --------- ----------- ------- -----
   Total     1.78TiB  4.00GiB  32.00MiB    71.91GiB 3.64TiB 0.00B
   Used      1.78TiB  2.49GiB 320.00KiB  

 

I cannot find where I am missing the space, I only need the cache drive for vm's.

Link to comment

As you can see the reported free space is correct, note that vdisks on btrfs can grow in time if not trimmed, see here, another option is to run a defrag, but only do that i you don't use snapshots, or move the vdisks to the array, then move back to the pool with cp --sparse=always

Link to comment

Ok, it seems that btrfs is growing by it own.

There are more than 20 linux vm's on this server, I don't use snapshots, and it's too much hasle to run defrag on each of them.

So if I move the vdisk's elsewhere, and copy each of them back with cp --sparse=always, do I have to do this operation once in a while ?

Link to comment
Posted (edited)
1 hour ago, JorgeB said:

If you don't enable discard in the VMs, you may need to.

Many thanks for the swift reply. I just need two more confirmations.

By enabling discard in the VMs, You mean to put something like this in each vm:

<disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writeback' discard='unmap'/>

Hopefully this solves my problem....

Are there any limitations using the discard option with using different controler type buses i.e. sata,VirtIO ?

Do I have to move the images, even if I put the discard option in the .xml, or it is enough to stop the vms, ,put the discard in the .xml and restarting the vms should reclaim the space?

Edited by milanp
Link to comment
  • Solution
5 minutes ago, milanp said:

You mean to put something like this in each vm:

Yep, it should work with virtIO and SCSI, not sure about SATA, note that you then should run trim inside the VM at least once after the change.

 

6 minutes ago, milanp said:

even if I put the discard option in the .xml, or it is enough to stop the vms, ,put the discard in the .xml and restarting the vms should reclaim the space?

Doing this and running TRIM on all VMs should reclaim most of the space.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...