Skip to contentSkip to conversation

snapshot space use

DISCUSSION Russell Coker 6 participants 12 messages Apr 9, 2015 – Apr 10, 2015 Btrfs file system

lore
Share & tools
lore
#0 lore raw
# zfs list -t snapshot
NAME                        USED  AVAIL  REFER  MOUNTPOINT
hetz0/be0-mail@2015-03-10  2.88G      -   387G  -
hetz0/be0-mail@2015-03-11  1.12G      -   388G  -
hetz0/be0-mail@2015-03-12  1.11G      -   388G  -
hetz0/be0-mail@2015-03-13  1.19G      -   388G  -
hetz0/be0-mail@2015-03-14  1.02G      -   388G  -
hetz0/be0-mail@2015-03-15   989M      -   386G  -

Is there any way to do something similar to the above ZFS command? It's handy to know which snapshots are taking up the most space, especially when multiple subvols are being snapshotted.

Signature · 2 lines
My Main Blog         http://etbe.coker.com.au/
My Documents Blog    http://doc.coker.com.au/
#1 lore raw

Hi,

You can use btrfs quota feature to do it.
Like this:

# btrfs quota enable <MNT_POINT>
# btrfs quota rescan -w <MNT_POINT>
# btrfs qgroup show -prce <MNT_POINT>
qgroupid rfer    excl    max_rfer max_excl parent  child
-------- ----    ----    -------- -------- ------  -----
0/5      2248704 12288   0        0        ---     ---
0/256    5509120 3272704 0        0        ---     ---

rfer is all the space the subvolume takes.
excl is the exclusive space the subvolume takes.

You can also refer to 'btrfs-quota'(8) and 'btrfs-qgroup'(8), Also the following wiki can help:
https://btrfs.wiki.kernel.org/index.php/Quota_support

NOTE: quota is not so stable and has some problem, but should give you enough info.

Thanks,
Qu

Quoted 13 lines
# zfs list -t snapshot
NAME                        USED  AVAIL  REFER  MOUNTPOINT
hetz0/be0-mail@2015-03-10  2.88G      -   387G  -
hetz0/be0-mail@2015-03-11  1.12G      -   388G  -
hetz0/be0-mail@2015-03-12  1.11G      -   388G  -
hetz0/be0-mail@2015-03-13  1.19G      -   388G  -
hetz0/be0-mail@2015-03-14  1.02G      -   388G  -
hetz0/be0-mail@2015-03-15   989M      -   386G  -

Is there any way to do something similar to the above ZFS command? It's handy to know which snapshots are taking up the most space, especially when multiple subvols are being snapshotted.

#2 lore raw
Quoted 3 lines · Qu Wenruo

*snip*
NOTE: quota is not so stable and has some problem, but should give you enough info.

Those are related to actually using quota or can also hit you when you want to use it just for things like this snapshot space use?

Piotr Szymaniak.

Signature · 4 lines
  - Oo,  jesteś  bystrzejszy,  niż  się  wydaje.  Przechodziłeś  jakieś
szkolenie antyterrorystyczne?
  - W pewnym sensie tak. Byłem żonaty.
 -- Nelson DeMille, "The Lion's Game"
#3 lore raw

-------- Original Message --------
Subject: Re: snapshot space use
From: Piotr Szymaniak <[email protected]>
To: Qu Wenruo <[email protected]>
Date: 2015年04月09日 17:02

Quoted 7 lines · Qu Wenruo
Quoted 3 lines

*snip*
NOTE: quota is not so stable and has some problem, but should give you enough info.

Those are related to actually using quota or can also hit you when you want to use it just for things like this snapshot space use?

Using quota has more problems. Like exceeding quota make you unable to delete any file(like a deadlock).

Your use case, just showing how much space you used, may still hit some unusual problem like inaccurate number or even minus number, with performance drop. But overall, it should be OK and meets your need.

Thanks,
Qu

Quoted 4 lines

Piotr Szymaniak.

#4 lore raw
In reply to Qu Wenruo
Quoted 14 lines · Qu Wenruo

Hi,

You can use btrfs quota feature to do it.
Like this:

# btrfs quota enable <MNT_POINT>
# btrfs quota rescan -w <MNT_POINT>
# btrfs qgroup show -prce <MNT_POINT>
qgroupid rfer    excl    max_rfer max_excl parent  child
-------- ----    ----    -------- -------- ------  -----
0/5      2248704 12288   0        0        ---     ---
0/256    5509120 3272704 0        0        ---     ---
Quoted 3 lines

rfer is all the space the subvolume takes.
excl is the exclusive space the subvolume takes.

Yes, but this isn't as useful as it sounds if you have more than one snapshot. Because if a file is included in at least two snapshots, it's no longer exclusive. So AFAICT even with btrfs qgroups, you still cannot answer the question "How much space are my snapshots using?" for a given subvolume, unless you have only one snapshot. But I'd be happy to be informed otherwise. :-)

-Justin

Quoted 29 lines

You can also refer to 'btrfs-quota'(8) and 'btrfs-qgroup'(8), Also the following wiki can help:
https://btrfs.wiki.kernel.org/index.php/Quota_support

NOTE: quota is not so stable and has some problem, but should give you enough info.

Thanks,
Qu

Quoted 9 lines
# zfs list -t snapshot
NAME                        USED  AVAIL  REFER  MOUNTPOINT
hetz0/be0-mail@2015-03-10  2.88G      -   387G  -
hetz0/be0-mail@2015-03-11  1.12G      -   388G  -
hetz0/be0-mail@2015-03-12  1.11G      -   388G  -
hetz0/be0-mail@2015-03-13  1.19G      -   388G  -
hetz0/be0-mail@2015-03-14  1.02G      -   388G  -
hetz0/be0-mail@2015-03-15   989M      -   386G  -
Quoted 6 lines

Is there any way to do something similar to the above ZFS command? It's handy
to know which snapshots are taking up the most space, especially when multiple
subvols are being snapshotted.

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
Quoted 19 lines · Justin Maggard
Quoted 14 lines · Qu Wenruo

Hi,

You can use btrfs quota feature to do it.
Like this:

# btrfs quota enable <MNT_POINT>
# btrfs quota rescan -w <MNT_POINT>
# btrfs qgroup show -prce <MNT_POINT>
qgroupid rfer    excl    max_rfer max_excl parent  child
-------- ----    ----    -------- -------- ------  -----
0/5      2248704 12288   0        0        ---     ---
0/256    5509120 3272704 0        0        ---     ---
Quoted 3 lines

rfer is all the space the subvolume takes.
excl is the exclusive space the subvolume takes.

Quoted 6 lines

Yes, but this isn't as useful as it sounds if you have more than one snapshot. Because if a file is included in at least two snapshots, it's no longer exclusive. So AFAICT even with btrfs qgroups, you still cannot answer the question "How much space are my snapshots using?" for a given subvolume, unless you have only one snapshot. But I'd be happy to be informed otherwise. :-)

There are basically two useful answers to that question, depending
on how the question is specified, exactly:

1) How much space would I use if I copied this subvolume to a different filesystem?

2) How much space would I free up if I deleted this subvolume?

Part 1 is the rfer answer. Part 2 is the excl answer.

Which of these do you mean by "How much space are my snapshots
using?". The question as posed is highly ambiguous, and needs considerably more precision before it can be answered.

If you can pose the question more precisely, you might wish to ask
one of those questions about N subvolumes as a group -- this is where(*) you would define a qgroup covering the subvols you're interested in, and then use the above interface to ask the question for the group of subvols as a whole.

Hugo.

(*) I'm not an expert in qgroups. I may have the idea completely wrong, but I think this is the right kind of approach.

Quoted 27 lines

-Justin

Quoted 25 lines

You can also refer to 'btrfs-quota'(8) and 'btrfs-qgroup'(8), Also the following wiki can help:
https://btrfs.wiki.kernel.org/index.php/Quota_support

NOTE: quota is not so stable and has some problem, but should give you enough info.

Thanks,
Qu

Quoted 15 lines
# zfs list -t snapshot
NAME                        USED  AVAIL  REFER  MOUNTPOINT
hetz0/be0-mail@2015-03-10  2.88G      -   387G  -
hetz0/be0-mail@2015-03-11  1.12G      -   388G  -
hetz0/be0-mail@2015-03-12  1.11G      -   388G  -
hetz0/be0-mail@2015-03-13  1.19G      -   388G  -
hetz0/be0-mail@2015-03-14  1.02G      -   388G  -
hetz0/be0-mail@2015-03-15   989M      -   386G  -

Is there any way to do something similar to the above ZFS command? It's handy
to know which snapshots are taking up the most space, especially when multiple
subvols are being snapshotted.

Signature · 4 lines
Hugo Mills             | You've read the project plan. Forget that. We're
hugo@... carfax.org.uk | going to Do Stuff and Have Fun doing it.
http://carfax.org.uk/  |
PGP: E2AB1DE4          |                                           Jeremy Frey
#6 lore raw
Quoted 41 lines · Hugo Mills
Quoted 19 lines · Justin Maggard
Quoted 14 lines · Qu Wenruo

Hi,

You can use btrfs quota feature to do it.
Like this:

# btrfs quota enable <MNT_POINT>
# btrfs quota rescan -w <MNT_POINT>
# btrfs qgroup show -prce <MNT_POINT>
qgroupid rfer    excl    max_rfer max_excl parent  child
-------- ----    ----    -------- -------- ------  -----
0/5      2248704 12288   0        0        ---     ---
0/256    5509120 3272704 0        0        ---     ---
Quoted 3 lines

rfer is all the space the subvolume takes.
excl is the exclusive space the subvolume takes.

Quoted 6 lines

Yes, but this isn't as useful as it sounds if you have more than one snapshot. Because if a file is included in at least two snapshots, it's no longer exclusive. So AFAICT even with btrfs qgroups, you still cannot answer the question "How much space are my snapshots using?" for a given subvolume, unless you have only one snapshot. But I'd be happy to be informed otherwise. :-)

There are basically two useful answers to that question, depending
on how the question is specified, exactly:

1) How much space would I use if I copied this subvolume to a different filesystem?

2) How much space would I free up if I deleted this subvolume?

Part 1 is the rfer answer. Part 2 is the excl answer.

Which of these do you mean by "How much space are my snapshots
using?". The question as posed is highly ambiguous, and needs considerably more precision before it can be answered.

Quoted 5 lines

If you can pose the question more precisely, you might wish to ask
one of those questions about N subvolumes as a group -- this is where(*) you would define a qgroup covering the subvols you're interested in, and then use the above interface to ask the question for the group of subvols as a whole.

To be more precise, let's consider an example, where we have a subvolume named "stuff"; and two snapshots of "stuff", "snap1" and "snap2". So the question I'm posing is:

How much space would I free up if I were to remove my snapshots, "snap1" and "snap2", but keep "stuff" intact?

I can't use the rfer value from snap1 and snap2, because in general most of that space is shared by "stuff" and would not be freed. I could look at the excl column for snap1 and snap2 and add them up; but if they shared extents with each other (and not with "stuff"), those extents are no longer exclusive, and thus not accounted for. So I would have to delete either snap1 or snap2 in order to answer my question using qgroups.

I can't think of a way to define a qgroup that would be able to answer my question, although I'm admittedly no expert in qgroups either.

-Justin

Quoted 40 lines

Hugo.

(*) I'm not an expert in qgroups. I may have the idea completely wrong, but I think this is the right kind of approach.

Quoted 27 lines

-Justin

Quoted 25 lines

You can also refer to 'btrfs-quota'(8) and 'btrfs-qgroup'(8), Also the following wiki can help:
https://btrfs.wiki.kernel.org/index.php/Quota_support

NOTE: quota is not so stable and has some problem, but should give you enough info.

Thanks,
Qu

Quoted 15 lines
# zfs list -t snapshot
NAME                        USED  AVAIL  REFER  MOUNTPOINT
hetz0/be0-mail@2015-03-10  2.88G      -   387G  -
hetz0/be0-mail@2015-03-11  1.12G      -   388G  -
hetz0/be0-mail@2015-03-12  1.11G      -   388G  -
hetz0/be0-mail@2015-03-13  1.19G      -   388G  -
hetz0/be0-mail@2015-03-14  1.02G      -   388G  -
hetz0/be0-mail@2015-03-15   989M      -   386G  -

Is there any way to do something similar to the above ZFS command? It's handy
to know which snapshots are taking up the most space, especially when multiple
subvols are being snapshotted.

--

Hugo Mills             | You've read the project plan. Forget that. We're
hugo@... carfax.org.uk | going to Do Stuff and Have Fun doing it.
http://carfax.org.uk/  |
PGP: E2AB1DE4          |                                           Jeremy Frey
#7 lore raw
Quoted 63 lines · Justin Maggard
Quoted 41 lines · Hugo Mills
Quoted 19 lines · Justin Maggard
Quoted 14 lines · Qu Wenruo

Hi,

You can use btrfs quota feature to do it.
Like this:

# btrfs quota enable <MNT_POINT>
# btrfs quota rescan -w <MNT_POINT>
# btrfs qgroup show -prce <MNT_POINT>
qgroupid rfer    excl    max_rfer max_excl parent  child
-------- ----    ----    -------- -------- ------  -----
0/5      2248704 12288   0        0        ---     ---
0/256    5509120 3272704 0        0        ---     ---
Quoted 3 lines

rfer is all the space the subvolume takes.
excl is the exclusive space the subvolume takes.

Quoted 6 lines

Yes, but this isn't as useful as it sounds if you have more than one snapshot. Because if a file is included in at least two snapshots, it's no longer exclusive. So AFAICT even with btrfs qgroups, you still cannot answer the question "How much space are my snapshots using?" for a given subvolume, unless you have only one snapshot. But I'd be happy to be informed otherwise. :-)

There are basically two useful answers to that question, depending
on how the question is specified, exactly:

1) How much space would I use if I copied this subvolume to a different filesystem?

2) How much space would I free up if I deleted this subvolume?

Part 1 is the rfer answer. Part 2 is the excl answer.

Which of these do you mean by "How much space are my snapshots
using?". The question as posed is highly ambiguous, and needs considerably more precision before it can be answered.

Quoted 5 lines

If you can pose the question more precisely, you might wish to ask
one of those questions about N subvolumes as a group -- this is where(*) you would define a qgroup covering the subvols you're interested in, and then use the above interface to ask the question for the group of subvols as a whole.

To be more precise, let's consider an example, where we have a subvolume named "stuff"; and two snapshots of "stuff", "snap1" and "snap2". So the question I'm posing is:

How much space would I free up if I were to remove my snapshots, "snap1" and "snap2", but keep "stuff" intact?

I can't use the rfer value from snap1 and snap2, because in general most of that space is shared by "stuff" and would not be freed. I could look at the excl column for snap1 and snap2 and add them up; but if they shared extents with each other (and not with "stuff"), those extents are no longer exclusive, and thus not accounted for. So I would have to delete either snap1 or snap2 in order to answer my question using qgroups.

Quoted 2 lines

I can't think of a way to define a qgroup that would be able to answer my question, although I'm admittedly no expert in qgroups either.

I think you'd define a qgroup comtaining snap1 and snap2, and look
at the excl value. Anyone out there with qgroups experience who can tell us how/whether that would do the job?

Hugo.

Quoted 37 lines

-Justin

Quoted 35 lines

Hugo.

(*) I'm not an expert in qgroups. I may have the idea completely wrong, but I think this is the right kind of approach.

Quoted 27 lines

-Justin

Quoted 25 lines

You can also refer to 'btrfs-quota'(8) and 'btrfs-qgroup'(8), Also the following wiki can help:
https://btrfs.wiki.kernel.org/index.php/Quota_support

NOTE: quota is not so stable and has some problem, but should give you enough info.

Thanks,
Qu

Quoted 15 lines
# zfs list -t snapshot
NAME                        USED  AVAIL  REFER  MOUNTPOINT
hetz0/be0-mail@2015-03-10  2.88G      -   387G  -
hetz0/be0-mail@2015-03-11  1.12G      -   388G  -
hetz0/be0-mail@2015-03-12  1.11G      -   388G  -
hetz0/be0-mail@2015-03-13  1.19G      -   388G  -
hetz0/be0-mail@2015-03-14  1.02G      -   388G  -
hetz0/be0-mail@2015-03-15   989M      -   386G  -

Is there any way to do something similar to the above ZFS command? It's handy
to know which snapshots are taking up the most space, especially when multiple
subvols are being snapshotted.

Signature · 4 lines
Hugo Mills             | Great films about cricket: The Third Man
hugo@... carfax.org.uk |
http://carfax.org.uk/  |
PGP: E2AB1DE4          |
#8 lore raw
Quoted 61 lines · Hugo Mills
Quoted 60 lines · Justin Maggard
Quoted 39 lines · Hugo Mills
Quoted 18 lines · Justin Maggard
Quoted 14 lines · Qu Wenruo

Hi,

You can use btrfs quota feature to do it.
Like this:

# btrfs quota enable <MNT_POINT>
# btrfs quota rescan -w <MNT_POINT>
# btrfs qgroup show -prce <MNT_POINT>
qgroupid rfer    excl    max_rfer max_excl parent  child
-------- ----    ----    -------- -------- ------  -----
0/5      2248704 12288   0        0        ---     ---
0/256    5509120 3272704 0        0        ---     ---
Quoted 3 lines

rfer is all the space the subvolume takes.
excl is the exclusive space the subvolume takes.

Quoted 6 lines

Yes, but this isn't as useful as it sounds if you have more than one snapshot. Because if a file is included in at least two snapshots, it's no longer exclusive. So AFAICT even with btrfs qgroups, you still cannot answer the question "How much space are my snapshots using?" for a given subvolume, unless you have only one snapshot. But I'd be happy to be informed otherwise. :-)

There are basically two useful answers to that question, depending
on how the question is specified, exactly:

1) How much space would I use if I copied this subvolume to a different filesystem?

2) How much space would I free up if I deleted this subvolume?

Part 1 is the rfer answer. Part 2 is the excl answer.

Which of these do you mean by "How much space are my snapshots
using?". The question as posed is highly ambiguous, and needs considerably more precision before it can be answered.

Quoted 5 lines

If you can pose the question more precisely, you might wish to ask
one of those questions about N subvolumes as a group -- this is where(*) you would define a qgroup covering the subvols you're interested in, and then use the above interface to ask the question for the group of subvols as a whole.

To be more precise, let's consider an example, where we have a subvolume named "stuff"; and two snapshots of "stuff", "snap1" and "snap2". So the question I'm posing is:

How much space would I free up if I were to remove my snapshots, "snap1" and "snap2", but keep "stuff" intact?

I can't use the rfer value from snap1 and snap2, because in general most of that space is shared by "stuff" and would not be freed. I could look at the excl column for snap1 and snap2 and add them up; but if they shared extents with each other (and not with "stuff"), those extents are no longer exclusive, and thus not accounted for. So I would have to delete either snap1 or snap2 in order to answer my question using qgroups.

Quoted 4 lines
Quoted 2 lines

I can't think of a way to define a qgroup that would be able to answer my question, although I'm admittedly no expert in qgroups either.

I think you'd define a qgroup comtaining snap1 and snap2, and look
at the excl value.

Agreed, This is a possible method to get what you want. We can create a qgroup in a higher level, as a pool.

# btrfs qgroup create 1/0 /MNT

And then assign your snapshots into this qgroup.

# btrfs qgroup assign 0/xxx 1/0 /MNT
# btrfs qgroup assign 0/xxx 1/0 /MNT

*Considering we can not update the quota number automatically in moving qgroup we need a rescan here.

# btrfs quota rescan -w /MNT

Then you can get the information you want by
#btrfs qgroup show -prce /MNT

Thanx
Yang

Quoted 40 lines

Anyone out there with qgroups experience who can
tell us how/whether that would do the job?

Hugo.

Quoted 35 lines

-Justin

Quoted 33 lines

Hugo.

(*) I'm not an expert in qgroups. I may have the idea completely wrong, but I think this is the right kind of approach.

Quoted 27 lines

-Justin

Quoted 25 lines

You can also refer to 'btrfs-quota'(8) and 'btrfs-qgroup'(8), Also the following wiki can help:
https://btrfs.wiki.kernel.org/index.php/Quota_support

NOTE: quota is not so stable and has some problem, but should give you enough info.

Thanks,
Qu

Quoted 15 lines
# zfs list -t snapshot
NAME                        USED  AVAIL  REFER  MOUNTPOINT
hetz0/be0-mail@2015-03-10  2.88G      -   387G  -
hetz0/be0-mail@2015-03-11  1.12G      -   388G  -
hetz0/be0-mail@2015-03-12  1.11G      -   388G  -
hetz0/be0-mail@2015-03-13  1.19G      -   388G  -
hetz0/be0-mail@2015-03-14  1.02G      -   388G  -
hetz0/be0-mail@2015-03-15   989M      -   386G  -

Is there any way to do something similar to the above ZFS command? It's handy
to know which snapshots are taking up the most space, especially when multiple
subvols are being snapshotted.

#9 lore raw
Quoted 86 lines · Dongsheng Yang
Quoted 69 lines · Hugo Mills
Quoted 67 lines · Justin Maggard
Quoted 44 lines · Hugo Mills
Quoted 21 lines · Justin Maggard
Quoted 15 lines · Qu Wenruo

Hi,

You can use btrfs quota feature to do it.
Like this:

# btrfs quota enable <MNT_POINT>
# btrfs quota rescan -w <MNT_POINT>
# btrfs qgroup show -prce <MNT_POINT>
qgroupid rfer    excl    max_rfer max_excl parent  child
-------- ----    ----    -------- -------- ------  -----
0/5      2248704 12288   0        0        ---     ---
0/256    5509120 3272704 0        0        ---     ---
Quoted 3 lines

rfer is all the space the subvolume takes.
excl is the exclusive space the subvolume takes.

Quoted 6 lines

Yes, but this isn't as useful as it sounds if you have more than one snapshot. Because if a file is included in at least two snapshots, it's no longer exclusive. So AFAICT even with btrfs qgroups, you still cannot answer the question "How much space are my snapshots using?" for a given subvolume, unless you have only one snapshot. But I'd be happy to be informed otherwise. :-)

There are basically two useful answers to that question, depending
on how the question is specified, exactly:

1) How much space would I use if I copied this subvolume to a different filesystem?

2) How much space would I free up if I deleted this subvolume?

Part 1 is the rfer answer. Part 2 is the excl answer.

Which of these do you mean by "How much space are my snapshots
using?". The question as posed is highly ambiguous, and needs considerably more precision before it can be answered.

Quoted 5 lines

If you can pose the question more precisely, you might wish to ask
one of those questions about N subvolumes as a group -- this is where(*) you would define a qgroup covering the subvols you're interested in, and then use the above interface to ask the question for the group of subvols as a whole.

To be more precise, let's consider an example, where we have a subvolume named "stuff"; and two snapshots of "stuff", "snap1" and "snap2". So the question I'm posing is:

How much space would I free up if I were to remove my snapshots, "snap1" and "snap2", but keep "stuff" intact?

I can't use the rfer value from snap1 and snap2, because in general most of that space is shared by "stuff" and would not be freed. I could look at the excl column for snap1 and snap2 and add them up; but if they shared extents with each other (and not with "stuff"), those extents are no longer exclusive, and thus not accounted for. So I would have to delete either snap1 or snap2 in order to answer my question using qgroups.

Quoted 5 lines
Quoted 2 lines

I can't think of a way to define a qgroup that would be able to answer my question, although I'm admittedly no expert in qgroups either.

I think you'd define a qgroup comtaining snap1 and snap2, and look
at the excl value.

Agreed, This is a possible method to get what you want. We can create a qgroup
in a higher level, as a pool.

# btrfs qgroup create 1/0 /MNT

And then assign your snapshots into this qgroup.

# btrfs qgroup assign 0/xxx 1/0 /MNT
# btrfs qgroup assign 0/xxx 1/0 /MNT
Quoted 8 lines

*Considering we can not update the quota number automatically in moving qgroup
we need a rescan here.

# btrfs quota rescan -w /MNT

Then you can get the information you want by
#btrfs qgroup show -prce /MNT

Nice, thanks for the input Hugo and Yang! I'll play with that a bit. I was assuming the excl value wouldn't be effective since the extents are still shared by the original subvolume.

-Justin

Quoted 45 lines

Thanx
Yang

Quoted 41 lines

Anyone out there with qgroups experience who can
tell us how/whether that would do the job?

Hugo.

Quoted 36 lines

-Justin

Quoted 34 lines

Hugo.

(*) I'm not an expert in qgroups. I may have the idea completely wrong, but I think this is the right kind of approach.

Quoted 28 lines

-Justin

Quoted 26 lines

You can also refer to 'btrfs-quota'(8) and 'btrfs-qgroup'(8), Also the following wiki can help:
https://btrfs.wiki.kernel.org/index.php/Quota_support

NOTE: quota is not so stable and has some problem, but should give you enough info.

Thanks,
Qu

Quoted 16 lines
# zfs list -t snapshot
NAME                        USED  AVAIL  REFER  MOUNTPOINT
hetz0/be0-mail@2015-03-10  2.88G      -   387G  -
hetz0/be0-mail@2015-03-11  1.12G      -   388G  -
hetz0/be0-mail@2015-03-12  1.11G      -   388G  -
hetz0/be0-mail@2015-03-13  1.19G      -   388G  -
hetz0/be0-mail@2015-03-14  1.02G      -   388G  -
hetz0/be0-mail@2015-03-15   989M      -   386G  -

Is there any way to do something similar to the above ZFS command? It's
handy
to know which snapshots are taking up the most space, especially when multiple
subvols are being snapshotted.

#10 lore raw

-------- Original Message --------
Subject: Re: snapshot space use
From: Justin Maggard <[email protected]>
To: Dongsheng Yang <[email protected]>
Date: 2015年04月10日 08:40

Quoted 97 lines
Quoted 86 lines · Dongsheng Yang
Quoted 69 lines · Hugo Mills
Quoted 67 lines · Justin Maggard
Quoted 44 lines · Hugo Mills
Quoted 21 lines · Justin Maggard
Quoted 15 lines · Qu Wenruo

Hi,

You can use btrfs quota feature to do it.
Like this:

# btrfs quota enable <MNT_POINT>
# btrfs quota rescan -w <MNT_POINT>
# btrfs qgroup show -prce <MNT_POINT>
qgroupid rfer    excl    max_rfer max_excl parent  child
-------- ----    ----    -------- -------- ------  -----
0/5      2248704 12288   0        0        ---     ---
0/256    5509120 3272704 0        0        ---     ---
Quoted 3 lines

rfer is all the space the subvolume takes.
excl is the exclusive space the subvolume takes.

Quoted 6 lines

Yes, but this isn't as useful as it sounds if you have more than one snapshot. Because if a file is included in at least two snapshots, it's no longer exclusive. So AFAICT even with btrfs qgroups, you still cannot answer the question "How much space are my snapshots using?" for a given subvolume, unless you have only one snapshot. But I'd be happy to be informed otherwise. :-)

There are basically two useful answers to that question, depending
on how the question is specified, exactly:

1) How much space would I use if I copied this subvolume to a different filesystem?

2) How much space would I free up if I deleted this subvolume?

Part 1 is the rfer answer. Part 2 is the excl answer.

Which of these do you mean by "How much space are my snapshots
using?". The question as posed is highly ambiguous, and needs considerably more precision before it can be answered.

Quoted 5 lines

If you can pose the question more precisely, you might wish to ask
one of those questions about N subvolumes as a group -- this is where(*) you would define a qgroup covering the subvols you're interested in, and then use the above interface to ask the question for the group of subvols as a whole.

To be more precise, let's consider an example, where we have a subvolume named "stuff"; and two snapshots of "stuff", "snap1" and "snap2". So the question I'm posing is:

How much space would I free up if I were to remove my snapshots, "snap1" and "snap2", but keep "stuff" intact?

I can't use the rfer value from snap1 and snap2, because in general most of that space is shared by "stuff" and would not be freed. I could look at the excl column for snap1 and snap2 and add them up; but if they shared extents with each other (and not with "stuff"), those extents are no longer exclusive, and thus not accounted for. So I would have to delete either snap1 or snap2 in order to answer my question using qgroups.

Quoted 5 lines
Quoted 2 lines

I can't think of a way to define a qgroup that would be able to answer my question, although I'm admittedly no expert in qgroups either.

I think you'd define a qgroup comtaining snap1 and snap2, and look
at the excl value.

Agreed, This is a possible method to get what you want. We can create a qgroup
in a higher level, as a pool.

# btrfs qgroup create 1/0 /MNT

And then assign your snapshots into this qgroup.

# btrfs qgroup assign 0/xxx 1/0 /MNT
# btrfs qgroup assign 0/xxx 1/0 /MNT
Quoted 8 lines

*Considering we can not update the quota number automatically in moving qgroup
we need a rescan here.

# btrfs quota rescan -w /MNT

Then you can get the information you want by
#btrfs qgroup show -prce /MNT

Quoted 5 lines

Nice, thanks for the input Hugo and Yang! I'll play with that a bit. I was assuming the excl value wouldn't be effective since the extents are still shared by the original subvolume.

-Justin

The higher level qgroup should archive your goal, if you adds all qgroups(including top-level subvol 5) into it.

But the higher level one can only shows you how much the space all the subvolumes really take. But not exactly one qgroup takes(as explained, no good definition on qgroup space usage due to the complexity in shared extents).

BTW, as you step deeper in btrfs qgroup, more problem may shows up.
For higher level subvolume qgroup, IIRC, deleting a snapshot/subvolume may cause wrong higher level qgroup numbers. Anyway, if you decides to use qgroup, run rescan at a interval is suggested.

Thanks,
Qu

Quoted 46 lines
Quoted 46 lines

Thanx
Yang

Quoted 41 lines

Anyone out there with qgroups experience who can
tell us how/whether that would do the job?

Hugo.

Quoted 36 lines

-Justin

Quoted 34 lines

Hugo.

(*) I'm not an expert in qgroups. I may have the idea completely wrong, but I think this is the right kind of approach.

Quoted 28 lines

-Justin

Quoted 26 lines

You can also refer to 'btrfs-quota'(8) and 'btrfs-qgroup'(8), Also the following wiki can help:
https://btrfs.wiki.kernel.org/index.php/Quota_support

NOTE: quota is not so stable and has some problem, but should give you enough info.

Thanks,
Qu

Quoted 16 lines
# zfs list -t snapshot
NAME                        USED  AVAIL  REFER  MOUNTPOINT
hetz0/be0-mail@2015-03-10  2.88G      -   387G  -
hetz0/be0-mail@2015-03-11  1.12G      -   388G  -
hetz0/be0-mail@2015-03-12  1.11G      -   388G  -
hetz0/be0-mail@2015-03-13  1.19G      -   388G  -
hetz0/be0-mail@2015-03-14  1.02G      -   388G  -
hetz0/be0-mail@2015-03-15   989M      -   386G  -

Is there any way to do something similar to the above ZFS command? It's
handy
to know which snapshots are taking up the most space, especially when multiple
subvols are being snapshotted.

#11 lore raw
In reply to Russell Coker
Quoted 9 lines · Russell Coker
# zfs list -t snapshot
NAME                        USED  AVAIL  REFER  MOUNTPOINT
hetz0/be0-mail@2015-03-10  2.88G      -   387G  -
hetz0/be0-mail@2015-03-11  1.12G      -   388G  -
hetz0/be0-mail@2015-03-12  1.11G      -   388G  -
hetz0/be0-mail@2015-03-13  1.19G      -   388G  -
hetz0/be0-mail@2015-03-14  1.02G      -   388G  -
hetz0/be0-mail@2015-03-15   989M      -   386G  -
Quoted 3 lines

Is there any way to do something similar to the above ZFS command? It's handy to know which snapshots are taking up the most space, especially when multiple subvols are being snapshotted.

Quota isn't really what I want. What I don't want is to go to all the effort of creating quotas on snapshots (and the risk of using such features) just for the ability to see disk usage IF I want it. What I want is to have it just work as it does in ZFS. In the above example I can see that I can free 2.88G of disk space by removing the oldest snapshot, this is useful.

btrfs sub find-new $SNAPSHOT $LASTGEN |
awk '{total = total + $7}END{print total}'

The above command gives a total of the lengths of extents that changed in a snapshot. Of course the total length isn't going to be the total space used (it doesn't count metadata used or space saved through compression), but it does give an idea. Thanks Hugo for the tip in another thread.

Signature · 2 lines
My Main Blog         http://etbe.coker.com.au/
My Documents Blog    http://doc.coker.com.au/