What to do about subvolumes?
Subsystems (2)
Hello,
Various people have complained about how BTRFS deals with subvolumes recently, specifically the fact that they all have the same inode number, and there's no discrete seperation from one subvolume to another. Christoph asked that I lay out a basic design document of how we want subvolumes to work so we can hash everything out now, fix what is broken, and then move forward with a design that everybody is more or less happy with. I apologize in advance for how freaking long this email is going to be. I assume that most people are generally familiar with how BTRFS works, so I'm not going to bother explaining in great detail some stuff.
=== What are subvolumes? ===
They are just another tree. In BTRFS we have various b-trees to describe the filesystem. A few of them are filesystem wide, such as the extent tree, chunk tree, root tree etc. The tree's that hold the actual filesystem data, that is inodes and such, are kept in their own b-tree. This is how subvolumes and snapshots appear on disk, they are simply new b-trees with all of the file data contained within them.
=== What do subvolumes look like? ===
All the user sees are directories. They act like any other directory acts, with a few exceptions
1) You cannot hardlink between subvolumes. This is because subvolumes have their own inode numbers and such, think of them as seperate mounts in this case, you cannot hardlink between two mounts because the link needs to point to the same on disk inode, which is impossible between two different filesystems. The same is true for subvolumes, they have their own trees with their own inodes and inode numbers, so it's impossible to hardlink between them.
1a) In case it wasn't clear from above, each subvolume has their own inode numbers, so you can have the same inode numbers used between two different subvolumes, since they are two different trees.
2) Obviously you can't just rm -rf subvolumes. Because they are roots there's extra metadata to keep track of them, so you have to use one of our ioctls to delete subvolumes/snapshots.
But permissions and everything else they are the same.
There is one tricky thing. When you create a subvolume, the directory inode that is created in the parent subvolume has the inode number of 256. So if you have a bunch of subvolumes in the same parent subvolume, you are going to have a bunch of directories with the inode number of 256. This is so when users cd into a subvolume we can know its a subvolume and do all the normal voodoo to start looking in the subvolumes tree instead of the parent subvolumes tree.
This is where things go a bit sideways. We had serious problems with NFS, but thankfully NFS gives us a bunch of hooks to get around these problems. CIFS/Samba do not, so we will have problems there, not to mention any other userspace application that looks at inode numbers.
=== How do we want subvolumes to work from a user perspective? ===
1) Users need to be able to create their own subvolumes. The permission semantics will be absolutely the same as creating directories, so I don't think this is too tricky. We want this because you can only take snapshots of subvolumes, and so it is important that users be able to create their own discrete snapshottable targets.
2) Users need to be able to snapshot their subvolumes. This is basically the same as #1, but it bears repeating.
3) Subvolumes shouldn't need to be specifically mounted. This is also important, we don't want users to have to go around mounting their subvolumes up manually one-by-one. Today users just cd into subvolumes and it works, just like cd'ing into a directory.
=== Quotas ===
This is a huge topic in and of itself, but Christoph mentioned wanting to have an idea of what we wanted to do with it, so I'm putting it here. There are really 2 things here
1) Limiting the size of subvolumes. This is really easy for us, just create a subvolume and at creation time set a maximum size it can grow to and not let it go farther than that. Nice, simple and straightforward.
2) Normal quotas, via the quota tools. This just comes down to how do we want to charge users, do we want to do it per subvolume, or per filesystem. My vote is per filesystem. Obviously this will make it tricky with snapshots, but I think if we're just charging the diff's between the original volume and the snapshot to the user then that will be the easiest for people to understand, rather than making a snapshot all of a sudden count the users currently used quota * 2.
=== What do we do? ===
This is where I expect to see the most discussion. Here is what I want to do
1) Scrap the 256 inode number thing. Instead we'll just put a flag in the inode to say "Hey, I'm a subvolume" and then we can do all of the appropriate magic that way. This unfortunately will be an incompatible format change, but the sooner we get this adressed the easier it will be in the long run. Obviously when I say format change I mean via the incompat bits we have, so old fs's won't be broken and such.
2) Do something like NFS's referral mounts when we cd into a subvolume. Now we just do dentry trickery, but that doesn't make the boundary between subvolumes clear, so it will confuse people (and samba) when they walk into a subvolume and all of a sudden the inode numbers are the same as in the directory behind them. With doing the referral mount thing, each subvolume appears to be its own mount and that way things like NFS and samba will work properly.
I feel like I'm forgetting something here, hopefully somebody will point it out.
=== Conclusion ===
There are definitely some wonky things with subvolumes, but I don't think they are things that cannot be fixed now. Some of these changes will require incompat format changes, but it's either we fix it now, or later on down the road when BTRFS starts getting used in production really find out how many things our current scheme breaks and then have to do the changes then. Thanks,
Josef
Quoted 6 lines · Josef Bacik
1) Users need to be able to create their own subvolumes. The permission semantics will be absolutely the same as creating directories, so I don't think this is too tricky. We want this because you can only take snapshots of subvolumes, and so it is important that users be able to create their own discrete snapshottable targets.
Quoted 7 lines
2) Users need to be able to snapshot their subvolumes. This is basically the same as #1, but it bears repeating.
3) Subvolumes shouldn't need to be specifically mounted. This is also important, we don't want users to have to go around mounting their subvolumes up manually one-by-one. Today users just cd into subvolumes and it works, just like cd'ing into a directory.
It would be helpful to be able to create subvolumes off existing directories, instead of creating a subvolume and having to copy all the data around.
Mike
Quoted 2 lines · Josef Bacik
=3D=3D=3D How do we want subvolumes to work from a user perspective? =
=3D=3D=3D
Quoted 2 lines
1) Users need to be able to create their own subvolumes. =A0The permi=
ssion
Quoted 1 line
semantics will be absolutely the same as creating directories, so I d=
on't think
Quoted 1 line
this is too tricky. =A0We want this because you can only take snapsho=
ts of
Quoted 1 line
subvolumes, and so it is important that users be able to create their=
own
Quoted 3 lines
discrete snapshottable targets.
2) Users need to be able to snapshot their subvolumes. =A0This is bas=
ically the
Quoted 1 line
same as #1, but it bears repeating.
could it be possible to convert a directory into a volume? or at least base a snapshot off it?
C Anthony
--
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
Excerpts from Josef Bacik's message of 2010-12-01 09:21:36 -0500:
Quoted 11 lines
Hello,
Various people have complained about how BTRFS deals with subvolumes recently, specifically the fact that they all have the same inode number, and there's no discrete seperation from one subvolume to another. Christoph asked that I lay out a basic design document of how we want subvolumes to work so we can hash everything out now, fix what is broken, and then move forward with a design that everybody is more or less happy with. I apologize in advance for how freaking long this email is going to be. I assume that most people are generally familiar with how BTRFS works, so I'm not going to bother explaining in great detail some stuff.
Thanks for writing this up.
Quoted 10 lines
=== What do we do? ===
This is where I expect to see the most discussion. Here is what I want to do
1) Scrap the 256 inode number thing. Instead we'll just put a flag in the inode to say "Hey, I'm a subvolume" and then we can do all of the appropriate magic that way. This unfortunately will be an incompatible format change, but the sooner we get this adressed the easier it will be in the long run. Obviously when I say format change I mean via the incompat bits we have, so old fs's won't be broken and such.
If they don't have inode number 256, what inode number do they have? I'm assuming you mean the subvolume is given an inode number in the parent directory just like any other dir, but this doesn't get rid of the duplicate inode problem. I think it ends up making it less clear, but I'm open to suggestions ;)
We could give each subvol a different devt, which is something Christoph had asked about as well.
-chris
Excerpts from C Anthony Risinger's message of 2010-12-01 09:51:55 -0500= :
Quoted 3 lines · Josef Bacik
Quoted 2 lines
=3D=3D=3D How do we want subvolumes to work from a user perspective=
? =3D=3D=3D
Quoted 2 lines
Quoted 2 lines
1) Users need to be able to create their own subvolumes. =C2=A0The =
permission
Quoted 1 line
Quoted 1 line
semantics will be absolutely the same as creating directories, so I=
don't think
Quoted 1 line
Quoted 1 line
this is too tricky. =C2=A0We want this because you can only take sn=
apshots of
Quoted 1 line
Quoted 1 line
subvolumes, and so it is important that users be able to create the=
ir own
Quoted 3 lines
Quoted 3 lines
discrete snapshottable targets.
2) Users need to be able to snapshot their subvolumes. =C2=A0This i=
s basically the
Quoted 4 lines
Quoted 1 line
same as #1, but it bears repeating.
=20
could it be possible to convert a directory into a volume? or at least base a snapshot off it?
I'm afraid this turns into the same complexity as creating a new volume and copying all the files/dirs in by hand.
-chris
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Dec 1, 2010 at 10:01 AM, Chris Mason <[email protected]> w= rote:
Quoted 1 line
Excerpts from C Anthony Risinger's message of 2010-12-01 09:51:55 -05=
00:
Quoted 1 line
Quoted 1 line
On Wed, Dec 1, 2010 at 8:21 AM, Josef Bacik <[email protected]> wrote=
:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
=3D=3D=3D How do we want subvolumes to work from a user perspectiv=
e? =3D=3D=3D
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
1) Users need to be able to create their own subvolumes. =A0The pe=
rmission
Quoted 1 line
Quoted 1 line
Quoted 1 line
semantics will be absolutely the same as creating directories, so =
I don't think
Quoted 1 line
Quoted 1 line
Quoted 1 line
this is too tricky. =A0We want this because you can only take snap=
shots of
Quoted 1 line
Quoted 1 line
Quoted 1 line
subvolumes, and so it is important that users be able to create th=
eir own
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
discrete snapshottable targets.
2) Users need to be able to snapshot their subvolumes. =A0This is =
basically the
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
same as #1, but it bears repeating.
could it be possible to convert a directory into a volume? =A0or at least base a snapshot off it?
I'm afraid this turns into the same complexity as creating a new volu=
me
Quoted 1 line
and copying all the files/dirs in by hand.
ok; if i create an empty volume, and use cp --reflink, it would have the desired affect though, right?
C Anthony
--
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
Excerpts from C Anthony Risinger's message of 2010-12-01 11:03:23 -0500= :
Quoted 1 line
On Wed, Dec 1, 2010 at 10:01 AM, Chris Mason <[email protected]>=
Quoted 1 line · wrote:
Quoted 1 line
Excerpts from C Anthony Risinger's message of 2010-12-01 09:51:55 -=
0500:
Quoted 1 line
Quoted 1 line
Quoted 1 line
On Wed, Dec 1, 2010 at 8:21 AM, Josef Bacik <[email protected]> wro=
te:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
=3D=3D=3D How do we want subvolumes to work from a user perspect=
ive? =3D=3D=3D
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
1) Users need to be able to create their own subvolumes. =C2=A0T=
he permission
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
semantics will be absolutely the same as creating directories, s=
o I don't think
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
this is too tricky. =C2=A0We want this because you can only take=
snapshots of
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
subvolumes, and so it is important that users be able to create =
their own
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
discrete snapshottable targets.
2) Users need to be able to snapshot their subvolumes. =C2=A0Thi=
s is basically the
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
same as #1, but it bears repeating.
could it be possible to convert a directory into a volume? =C2=A0o=
r at
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
least base a snapshot off it?
I'm afraid this turns into the same complexity as creating a new vo=
lume
Quoted 4 lines
Quoted 1 line
and copying all the files/dirs in by hand.
=20
ok; if i create an empty volume, and use cp --reflink, it would have the desired affect though, right?
Almost, for no good reason at all our cp --reflink doesn't reflink across subvols. I'll get that fixed up.
-chris
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 1 line · Chris Mason
Excerpts from C Anthony Risinger's message of 2010-12-01 09:51:55 -05=
00:
Quoted 1 line
Quoted 1 line
On Wed, Dec 1, 2010 at 8:21 AM, Josef Bacik <[email protected]> wrot=
e:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
=3D=3D=3D How do we want subvolumes to work from a user perspecti=
ve? =3D=3D=3D
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
1) Users need to be able to create their own subvolumes. =C2=A0Th=
e permission
Quoted 1 line
Quoted 1 line
Quoted 1 line
semantics will be absolutely the same as creating directories, so=
I don't think
Quoted 1 line
Quoted 1 line
Quoted 1 line
this is too tricky. =C2=A0We want this because you can only take =
snapshots of
Quoted 1 line
Quoted 1 line
Quoted 1 line
subvolumes, and so it is important that users be able to create t=
heir own
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
discrete snapshottable targets.
2) Users need to be able to snapshot their subvolumes. =C2=A0This=
is basically the
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
same as #1, but it bears repeating.
=20
could it be possible to convert a directory into a volume? or at least base a snapshot off it?=20
I'm afraid this turns into the same complexity as creating a new volu=
me
Quoted 1 line
and copying all the files/dirs in by hand.
Except you wouldn't have to copy data, only metadata.
Mike
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 10 lines · Josef Bacik
=== Quotas ===
This is a huge topic in and of itself, but Christoph mentioned wanting to have an idea of what we wanted to do with it, so I'm putting it here. There are really 2 things here
1) Limiting the size of subvolumes. This is really easy for us, just create a subvolume and at creation time set a maximum size it can grow to and not let it go farther than that. Nice, simple and straightforward.
Quoted 7 lines
2) Normal quotas, via the quota tools. This just comes down to how do we want to charge users, do we want to do it per subvolume, or per filesystem. My vote is per filesystem. Obviously this will make it tricky with snapshots, but I think if we're just charging the diff's between the original volume and the snapshot to the user then that will be the easiest for people to understand, rather than making a snapshot all of a sudden count the users currently used quota * 2.
This is going to be tricky to get the semantics right, I suspect.
Say you've created a subvolume, A, containing 10G of Useful Stuff
(say, a base image for VMs). This counts 10G against your quota. Now, I come along and snapshot that subvolume (as a writable subvolume) -- call it B. This is essentially free for me, because I've got a COW copy of your subvolume (and the original counts against your quota).
If I now modify a file in subvolume B, the full modified section
goes onto my quota. This is all well and good. But what happens if you delete your subvolume, A? Suddenly, I get lumbered with 10G of extra files. Worse, what happens if someone else had made a snapshot of A, too? Who gets the 10G added to their quota, me or them? What if I'd filled up my quota? Would that stop you from deleting your copy, because my copy can't be charged against my quota? Would I just end up unexpectedly 10G over quota?
This is a whole gigantic can of worms, as far as I can see, and I
don't think it's going to be possible to implement quotas, even on a filesystem level, until there's some good and functional model for dealing with all the implications of COW copies. :(
Hugo.
Signature · 4 lines
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
--- I believe that it's closely correlated with ---
the aeroswine coefficient. Quoted 36 lines · Hugo Mills
Quoted 10 lines · Josef Bacik
=== Quotas ===
This is a huge topic in and of itself, but Christoph mentioned wanting to have an idea of what we wanted to do with it, so I'm putting it here. There are really 2 things here
1) Limiting the size of subvolumes. This is really easy for us, just create a subvolume and at creation time set a maximum size it can grow to and not let it go farther than that. Nice, simple and straightforward.
Quoted 7 lines
2) Normal quotas, via the quota tools. This just comes down to how do we want to charge users, do we want to do it per subvolume, or per filesystem. My vote is per filesystem. Obviously this will make it tricky with snapshots, but I think if we're just charging the diff's between the original volume and the snapshot to the user then that will be the easiest for people to understand, rather than making a snapshot all of a sudden count the users currently used quota * 2.
This is going to be tricky to get the semantics right, I suspect.
Say you've created a subvolume, A, containing 10G of Useful Stuff
(say, a base image for VMs). This counts 10G against your quota. Now, I come along and snapshot that subvolume (as a writable subvolume) -- call it B. This is essentially free for me, because I've got a COW copy of your subvolume (and the original counts against your quota).If I now modify a file in subvolume B, the full modified section
goes onto my quota. This is all well and good. But what happens if you delete your subvolume, A? Suddenly, I get lumbered with 10G of extra files. Worse, what happens if someone else had made a snapshot of A, too? Who gets the 10G added to their quota, me or them? What if I'd filled up my quota? Would that stop you from deleting your copy, because my copy can't be charged against my quota? Would I just end up unexpectedly 10G over quota?
Quoted 4 lines
This is a whole gigantic can of worms, as far as I can see, and I
don't think it's going to be possible to implement quotas, even on a filesystem level, until there's some good and functional model for dealing with all the implications of COW copies. :(
I would argue that a simple and probably correct solution is to have the files count toward the quota of everyone who has a COW copy. i.e. if I have a volume A and you make a snapshot B, the du content of B should count toward your quota as well, rather than being "free". I don't see any reason why this would not be the correct and intuitive way to do it. Simply treat it as you would transparent block-level deduplication.
Gordan
Quoted 36 lines · Hugo Mills
Quoted 10 lines · Josef Bacik
=== Quotas ===
This is a huge topic in and of itself, but Christoph mentioned wanting to have an idea of what we wanted to do with it, so I'm putting it here. There are really 2 things here
1) Limiting the size of subvolumes. This is really easy for us, just create a subvolume and at creation time set a maximum size it can grow to and not let it go farther than that. Nice, simple and straightforward.
Quoted 7 lines
2) Normal quotas, via the quota tools. This just comes down to how do we want to charge users, do we want to do it per subvolume, or per filesystem. My vote is per filesystem. Obviously this will make it tricky with snapshots, but I think if we're just charging the diff's between the original volume and the snapshot to the user then that will be the easiest for people to understand, rather than making a snapshot all of a sudden count the users currently used quota * 2.
This is going to be tricky to get the semantics right, I suspect.
Say you've created a subvolume, A, containing 10G of Useful Stuff
(say, a base image for VMs). This counts 10G against your quota. Now, I come along and snapshot that subvolume (as a writable subvolume) -- call it B. This is essentially free for me, because I've got a COW copy of your subvolume (and the original counts against your quota).If I now modify a file in subvolume B, the full modified section
goes onto my quota. This is all well and good. But what happens if you delete your subvolume, A? Suddenly, I get lumbered with 10G of extra files. Worse, what happens if someone else had made a snapshot of A, too? Who gets the 10G added to their quota, me or them? What if I'd filled up my quota? Would that stop you from deleting your copy, because my copy can't be charged against my quota? Would I just end up unexpectedly 10G over quota?
Quoted 4 lines
This is a whole gigantic can of worms, as far as I can see, and I
don't think it's going to be possible to implement quotas, even on a filesystem level, until there's some good and functional model for dealing with all the implications of COW copies. :(
In your case, it would sound fair that everyone is "simply" charged 10G. What Josef is refering to would probably only apply to volumes and snapshots owned by the same user: If I have a subvolume of 10G, and a snapshot of it where I only changed 1G, the charged quota would be 11G, not 20G.
Mike
On Wed, Dec 1, 2010 at 10:38 AM, Hugo Mills <[email protected]> w= rote:
Quoted 4 lines · Josef Bacik
Quoted 3 lines
=3D=3D=3D Quotas =3D=3D=3D
This is a huge topic in and of itself, but Christoph mentioned wanti=
ng to have
Quoted 1 line
Quoted 1 line
an idea of what we wanted to do with it, so I'm putting it here. =A0=
There are
Quoted 3 lines
Quoted 3 lines
really 2 things here
1) Limiting the size of subvolumes. =A0This is really easy for us, j=
ust create a
Quoted 1 line
Quoted 1 line
subvolume and at creation time set a maximum size it can grow to and=
not let it
Quoted 3 lines
Quoted 3 lines
go farther than that. =A0Nice, simple and straightforward.
2) Normal quotas, via the quota tools. =A0This just comes down to ho=
w do we want
Quoted 1 line
Quoted 1 line
to charge users, do we want to do it per subvolume, or per filesyste=
m. =A0My vote
Quoted 1 line
Quoted 1 line
is per filesystem. =A0Obviously this will make it tricky with snapsh=
ots, but I
Quoted 1 line
Quoted 1 line
think if we're just charging the diff's between the original volume =
and the
Quoted 1 line
Quoted 1 line
snapshot to the user then that will be the easiest for people to und=
erstand,
Quoted 1 line
Quoted 1 line
rather than making a snapshot all of a sudden count the users curren=
tly used
Quoted 4 lines
Quoted 1 line
quota * 2.
=A0 This is going to be tricky to get the semantics right, I suspect.
Quoted 8 lines
=A0 Say you've created a subvolume, A, containing 10G of Useful Stuff (say, a base image for VMs). This counts 10G against your quota. Now, I come along and snapshot that subvolume (as a writable subvolume) -- call it B. This is essentially free for me, because I've got a COW copy of your subvolume (and the original counts against your quota).
=A0 If I now modify a file in subvolume B, the full modified section goes onto my quota. This is all well and good. But what happens if yo=
u
Quoted 2 lines
delete your subvolume, A? Suddenly, I get lumbered with 10G of extra files. =A0Worse, what happens if someone else had made a snapshot of =
A,
Quoted 3 lines
too? Who gets the 10G added to their quota, me or them? What if I'd filled up my quota? Would that stop you from deleting your copy, because my copy can't be charged against my quota? Would I just end u=
p
Quoted 6 lines
unexpectedly 10G over quota?
=A0 This is a whole gigantic can of worms, as far as I can see, and I don't think it's going to be possible to implement quotas, even on a filesystem level, until there's some good and functional model for dealing with all the implications of COW copies. :(
i'd expect that as a separate user, you should both be whacked 10G. imo, the whole benefit of transparent COW is to the administrators advantage, thus i would even think the _uncompressed_ volume size would go against quota (which could possibly be artificially inflated to account for the space saving of compression). users just need a nice steadily predictable number to monitor.
thought maybe these users could be grouped, such that the COW'ed portions of the files they share are balanced across each users quota, but this would have to be a soprt of "opt in" thing else you get the wild fluctuations because of other user's actions. additionally, some users could be marked as "system", where COW'ing their subvol results in 0 quota -- you only pay for what you change -- but if the system subvol gets removed, then you pay for it all. in this way you would have to keep reusing system subvols to get any advantage as a regular user.
i dont know the existing systems though so i dont know what it would take to do such balancing.
C Anthony
--
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
Quoted 27 lines · Hugo Mills
Quoted 10 lines · Josef Bacik
=== Quotas ===
This is a huge topic in and of itself, but Christoph mentioned wanting to have an idea of what we wanted to do with it, so I'm putting it here. There are really 2 things here
1) Limiting the size of subvolumes. This is really easy for us, just create a subvolume and at creation time set a maximum size it can grow to and not let it go farther than that. Nice, simple and straightforward.
Quoted 7 lines
2) Normal quotas, via the quota tools. This just comes down to how do we want to charge users, do we want to do it per subvolume, or per filesystem. My vote is per filesystem. Obviously this will make it tricky with snapshots, but I think if we're just charging the diff's between the original volume and the snapshot to the user then that will be the easiest for people to understand, rather than making a snapshot all of a sudden count the users currently used quota * 2.
This is going to be tricky to get the semantics right, I suspect.
Say you've created a subvolume, A, containing 10G of Useful Stuff
(say, a base image for VMs). This counts 10G against your quota. Now, I come along and snapshot that subvolume (as a writable subvolume) -- call it B. This is essentially free for me, because I've got a COW copy of your subvolume (and the original counts against your quota).
Quoted 9 lines
If I now modify a file in subvolume B, the full modified section
goes onto my quota. This is all well and good. But what happens if you delete your subvolume, A? Suddenly, I get lumbered with 10G of extra files. Worse, what happens if someone else had made a snapshot of A, too? Who gets the 10G added to their quota, me or them? What if I'd filled up my quota? Would that stop you from deleting your copy, because my copy can't be charged against my quota? Would I just end up unexpectedly 10G over quota?
If you delete your subvolume A, like use the btrfs tool to delete it, you will only be stuck with what you changed in snapshot B. So if you only changed 5gig worth of information, and you deleted the original subvolume, you would have 5gig charged to your quota. The idea is you are only charged for what blocks you have on the disk. Thanks,
Josef
Quoted 2 lines · Josef Bacik
Hello,
Hi Josef
Quoted 4 lines
=== What are subvolumes? ===
They are just another tree. In BTRFS we have various b-trees to describe
the
Quoted 1 line
filesystem. A few of them are filesystem wide, such as the extent tree,
chunk
Quoted 1 line
tree, root tree etc. The tree's that hold the actual filesystem data, that
is
Quoted 2 lines
inodes and such, are kept in their own b-tree. This is how subvolumes and snapshots appear on disk, they are simply new b-trees with all of the file
data
Quoted 4 lines
contained within them.
=== What do subvolumes look like? ===
[...]
Quoted 2 lines
2) Obviously you can't just rm -rf subvolumes. Because they are roots
there's
Quoted 1 line
extra metadata to keep track of them, so you have to use one of our ioctls
to
Quoted 1 line
delete subvolumes/snapshots.
Sorry, but I can't understand this sentence. It is clear that a directory and a subvolume have a totally different on-disk format. But why it would be not possible to remove a subvolume via the normal rmdir(2) syscall ? I posted a patch some months ago: when the rmdir is invoked on a subvolume, the same action of the ioctl BTRFS_IOC_SNAP_DESTROY is performed.
See https://patchwork.kernel.org/patch/260301/
[...]
Quoted 3 lines
There is one tricky thing. When you create a subvolume, the directory inode that is created in the parent subvolume has the inode number of 256. So if
you
Quoted 1 line
have a bunch of subvolumes in the same parent subvolume, you are going to
have a
Quoted 5 lines
bunch of directories with the inode number of 256. This is so when users cd into a subvolume we can know its a subvolume and do all the normal voodoo to start looking in the subvolumes tree instead of the parent subvolumes tree.
This is where things go a bit sideways. We had serious problems with NFS,
but
Quoted 3 lines
thankfully NFS gives us a bunch of hooks to get around these problems. CIFS/Samba do not, so we will have problems there, not to mention any other userspace application that looks at inode numbers.
How this is/should be different of a mounted filesystem ? For example:
# cd /tmp
# btrfs subvolume create sub-a
# btrfs subvolume create sub-b
# mkdir mount -a; mkdir mount-b
# mount /dev/sda6 mount-a # an ext4 fs
# mount /dev/sdb2 mount-b # an ext3 fs
# $ stat -c "%8i %n" sub-a sub-b mount-a mount-b
256 sub-a
256 sub-b
2 mount-a
2 mount-bIn this case the inode-number returned are equal for both the mounted filesystems and the subvolumes. However, the fsid is different.
# stat -fc "%8i %n" sub-a sub-b mount-a mount-b . cdc937c1a203df74 sub-a cdc937c1a203df77 sub-b b27d147f003561c8 mount-a d49e1a3d2333d2e1 mount-b cdc937c1a203df75 .
Moreover I suggest to look at the difference of the inode returned by readdir(3) and stat(3)..
[...]
Quoted 1 line
I feel like I'm forgetting something here, hopefully somebody will point it
out.
Quoted 1 line
Another point that I want like to discuss is how manage the "pivoting" between the subvolumes. One of the most beautiful feature of btrfs is the snapshot capability. In fact it is possible to make a snapshot of the root of the filesystem and to mount it in a subsequent reboot.
But is very complicated to manage the pivoting of a snapshot of a root filesystem, because I cannot delete the "old root" due to the fact that the "new root" is placed in the "old root".
A possible solution is not to put the root of the filesystem (where are placed /usr, /etc....) in the root of the btrfs filesystem; but it should be accepted from the beginning the idea that the root of a filesystem should be placed in a subvolume which int turn is placed in the root of a btrfs filesystem...
I am open to other opinions.
Quoted 3 lines
=== Conclusion ===
There are definitely some wonky things with subvolumes, but I don't think
they
Quoted 4 lines
are things that cannot be fixed now. Some of these changes will require incompat format changes, but it's either we fix it now, or later on down the road when BTRFS starts getting used in production really find out how many things our current scheme breaks and then have to do the changes then.
Thanks,
Quoted 7 lines
Josef
--
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
Signature · 2 lines
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <[email protected]> Key fingerprint = 4769 7E51 5293 D36C 814E C054 BF04 F161 3DC5 0512
Quoted 30 lines · Goffredo Baroncelli
Quoted 2 lines · Josef Bacik
Hello,
Hi Josef
Quoted 4 lines
=== What are subvolumes? ===
They are just another tree. In BTRFS we have various b-trees to describe
the
Quoted 1 line
filesystem. A few of them are filesystem wide, such as the extent tree,
chunk
Quoted 1 line
tree, root tree etc. The tree's that hold the actual filesystem data, that
is
Quoted 2 lines
inodes and such, are kept in their own b-tree. This is how subvolumes and snapshots appear on disk, they are simply new b-trees with all of the file
data
Quoted 4 lines
contained within them.
=== What do subvolumes look like? ===
[...]
Quoted 2 lines
2) Obviously you can't just rm -rf subvolumes. Because they are roots
there's
Quoted 1 line
extra metadata to keep track of them, so you have to use one of our ioctls
to
Quoted 1 line
delete subvolumes/snapshots.
Quoted 8 lines
Sorry, but I can't understand this sentence. It is clear that a directory and a subvolume have a totally different on-disk format. But why it would be not possible to remove a subvolume via the normal rmdir(2) syscall ? I posted a patch some months ago: when the rmdir is invoked on a subvolume, the same action of the ioctl
BTRFS_IOC_SNAP_DESTROYis performed.
Oh hey thats cool. That would be reasonable I think. I was just saying that currently we can't remove subvolumes/snapshots via rm, not that it wasn't possible at all. So I think what you did would be a good thing to have.
Quoted 42 lines
[...]
Quoted 3 lines
There is one tricky thing. When you create a subvolume, the directory inode that is created in the parent subvolume has the inode number of 256. So if
you
Quoted 1 line
have a bunch of subvolumes in the same parent subvolume, you are going to
have a
Quoted 5 lines
bunch of directories with the inode number of 256. This is so when users cd into a subvolume we can know its a subvolume and do all the normal voodoo to start looking in the subvolumes tree instead of the parent subvolumes tree.
This is where things go a bit sideways. We had serious problems with NFS,
but
Quoted 3 lines
thankfully NFS gives us a bunch of hooks to get around these problems. CIFS/Samba do not, so we will have problems there, not to mention any other userspace application that looks at inode numbers.
How this is/should be different of a mounted filesystem ? For example:
# cd /tmp # btrfs subvolume create sub-a # btrfs subvolume create sub-b # mkdir mount -a; mkdir mount-b # mount /dev/sda6 mount-a # an ext4 fs # mount /dev/sdb2 mount-b # an ext3 fs # $ stat -c "%8i %n" sub-a sub-b mount-a mount-b 256 sub-a 256 sub-b 2 mount-a 2 mount-bIn this case the inode-number returned are equal for both the mounted filesystems and the subvolumes. However, the fsid is different.
# stat -fc "%8i %n" sub-a sub-b mount-a mount-b . cdc937c1a203df74 sub-a cdc937c1a203df77 sub-b b27d147f003561c8 mount-a d49e1a3d2333d2e1 mount-b cdc937c1a203df75 .
Quoted 3 lines
Moreover I suggest to look at the difference of the inode returned by readdir(3) and stat(3)..
Yeah you are right, the inode numbering can probably be the same, we just need to make them logically different mounts so things like NFS and samba still work right.
Quoted 13 lines
[...]
Quoted 1 line
I feel like I'm forgetting something here, hopefully somebody will point it
out.
Quoted 1 line
Another point that I want like to discuss is how manage the "pivoting" between the subvolumes. One of the most beautiful feature of btrfs is the snapshot capability. In fact it is possible to make a snapshot of the root of the filesystem and to mount it in a subsequent reboot.
But is very complicated to manage the pivoting of a snapshot of a root filesystem, because I cannot delete the "old root" due to the fact that the "new root" is placed in the "old root".
Quoted 7 lines
A possible solution is not to put the root of the filesystem (where are placed /usr, /etc....) in the root of the btrfs filesystem; but it should be accepted from the beginning the idea that the root of a filesystem should be placed in a subvolume which int turn is placed in the root of a btrfs filesystem...
I am open to other opinions.
Agreed, one of the things that Chris and I have discussed is the possiblity of just having dangling roots, since really the directories are just an easy way to get to the subvolumes. This would let you delete the original volume and use the snapshot from then on out. Something to do in the future for sure. Thanks,
Josef
Quoted 3 lines · Josef Bacik
Quoted 1 line · Goffredo Baroncelli
Another point that I want like to discuss is how manage the "pivotin=
g" between
Quoted 1 line
Quoted 1 line
the subvolumes. One of the most beautiful feature of btrfs is the sn=
apshot
Quoted 1 line
Quoted 1 line
capability. In fact it is possible to make a snapshot of the root of=
the
Quoted 2 lines
Quoted 2 lines
filesystem and to mount it in a subsequent reboot.
But is very complicated to manage the pivoting of a snapshot of a ro=
ot
Quoted 1 line
Quoted 1 line
filesystem, because I cannot delete the "old root" due to the fact t=
hat the
Quoted 3 lines
Quoted 3 lines
"new root" is placed in the "old root".
A possible solution is not to put the root of the filesystem (where =
are placed
Quoted 1 line
Quoted 1 line
/usr, /etc....) in the root of the btrfs filesystem; but it should b=
e accepted
Quoted 1 line
Quoted 1 line
from the beginning the idea that the root of a filesystem should be =
placed in
Quoted 1 line
Quoted 1 line
a subvolume which int turn is placed in the root of a btrfs filesyst=
em...
Quoted 5 lines
Quoted 3 lines
I am open to other opinions.
Agreed, one of the things that Chris and I have discussed is the poss=
iblity of
Quoted 1 line
just having dangling roots, since really the directories are just an =
easy way to
Quoted 1 line
get to the subvolumes. =A0This would let you delete the original volu=
me and use
Quoted 1 line
the snapshot from then on out. =A0Something to do in the future for s=
ure.
i would really like to see a solution to this particular issue. i may be missing something, but the dangling subvol roots doesn't seem to address the management of the root volume itself.
for example... most people will install their whole system into the real root (id=3D5), but this renders the system unmanageable, because there is no way to ever empty it without manually issuing an rm -rf.
i'm having a really hard time controlling this with the initramfs hook i provide for archlinux users. the hook requires a specific structure "underneath" what the user perceives as /, but i can only accomplish this for new installs -- for existing installs i can setup the proper "subroot" structure, and snapshot their current root... but i cannot remove the stagnant files in the real root (id=3D5) that well never, ever be accessed again.
=2E.. or does dangling roots address this?
C Anthony
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 1 line · On Wed, Dec 1, 2010 at 12:48 PM, C Anthony Risinger <[email protected]> = wrote:
On Wed, Dec 1, 2010 at 12:36 PM, Josef Bacik <[email protected]> wrote=
:
Quoted 3 lines
Quoted 3 lines · Goffredo Baroncelli
Quoted 2 lines
Another point that I want like to discuss is how manage the "pivoti=
ng" between
Quoted 1 line
Quoted 1 line
Quoted 1 line
the subvolumes. One of the most beautiful feature of btrfs is the s=
napshot
Quoted 1 line
Quoted 1 line
Quoted 1 line
capability. In fact it is possible to make a snapshot of the root o=
f the
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
filesystem and to mount it in a subsequent reboot.
But is very complicated to manage the pivoting of a snapshot of a r=
oot
Quoted 1 line
Quoted 1 line
Quoted 1 line
filesystem, because I cannot delete the "old root" due to the fact =
that the
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
"new root" is placed in the "old root".
A possible solution is not to put the root of the filesystem (where=
are placed
Quoted 1 line
Quoted 1 line
Quoted 1 line
/usr, /etc....) in the root of the btrfs filesystem; but it should =
be accepted
Quoted 1 line
Quoted 1 line
Quoted 1 line
from the beginning the idea that the root of a filesystem should be=
placed in
Quoted 1 line
Quoted 1 line
Quoted 1 line
a subvolume which int turn is placed in the root of a btrfs filesys=
tem...
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
I am open to other opinions.
Agreed, one of the things that Chris and I have discussed is the pos=
siblity of
Quoted 1 line
Quoted 1 line
just having dangling roots, since really the directories are just an=
easy way to
Quoted 1 line
Quoted 1 line
get to the subvolumes. =A0This would let you delete the original vol=
ume and use
Quoted 1 line
Quoted 1 line
the snapshot from then on out. =A0Something to do in the future for =
sure.
Quoted 2 lines
i would really like to see a solution to this particular issue. =A0i =
may
Quoted 6 lines
be missing something, but the dangling subvol roots doesn't seem to address the management of the root volume itself.
for example... most people will install their whole system into the real root (id=3D5), but this renders the system unmanageable, because there is no way to ever empty it without manually issuing an
rm -rf=
=2E
Quoted 2 lines
i'm having a really hard time controlling this with the initramfs hoo=
k
Quoted 1 line
i provide for archlinux users. =A0the hook requires a specific struct=
ure
Quoted 7 lines
"underneath" what the user perceives as /, but i can only accomplish this for new installs -- for existing installs i can setup the proper "subroot" structure, and snapshot their current root... but i cannot remove the stagnant files in the real root (id=3D5) that well never, ever be accessed again.
... or does dangling roots address this?
i forgot to mention, but a quick 'n dirty solution would be to simply not enable users to do this by accident. mkfs.btrfs could create a new subvol, then mark it as default... this way the user has to manually mount with id=3D0, or remark 0 as the default.
effectively, users would be unknowingly be installing into a subvolume, rather then the top-level root (apologies if my terminology is incorrect).
C Anthony
--
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
On Wednesday, 01 December, 2010, you (C Anthony Risinger) wrote:
[...]
Quoted 8 lines
i forgot to mention, but a quick 'n dirty solution would be to simply not enable users to do this by accident. mkfs.btrfs could create a new subvol, then mark it as default... this way the user has to manually mount with id=0, or remark 0 as the default.
effectively, users would be unknowingly be installing into a subvolume, rather then the top-level root (apologies if my terminology is incorrect).
I fully agree: it fulfill the KISS principle :-)
Quoted 2 lines
C Anthony
Signature · 2 lines
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <[email protected]> Key fingerprint = 4769 7E51 5293 D36C 814E C054 BF04 F161 3DC5 0512
Quoted 38 lines · Josef Bacik
Quoted 27 lines · Hugo Mills
Quoted 10 lines · Josef Bacik
=== Quotas ===
This is a huge topic in and of itself, but Christoph mentioned wanting to have an idea of what we wanted to do with it, so I'm putting it here. There are really 2 things here
1) Limiting the size of subvolumes. This is really easy for us, just create a subvolume and at creation time set a maximum size it can grow to and not let it go farther than that. Nice, simple and straightforward.
Quoted 7 lines
2) Normal quotas, via the quota tools. This just comes down to how do we want to charge users, do we want to do it per subvolume, or per filesystem. My vote is per filesystem. Obviously this will make it tricky with snapshots, but I think if we're just charging the diff's between the original volume and the snapshot to the user then that will be the easiest for people to understand, rather than making a snapshot all of a sudden count the users currently used quota * 2.
This is going to be tricky to get the semantics right, I suspect.
Say you've created a subvolume, A, containing 10G of Useful Stuff
(say, a base image for VMs). This counts 10G against your quota. Now, I come along and snapshot that subvolume (as a writable subvolume) -- call it B. This is essentially free for me, because I've got a COW copy of your subvolume (and the original counts against your quota).Quoted 9 lines
If I now modify a file in subvolume B, the full modified section
goes onto my quota. This is all well and good. But what happens if you delete your subvolume, A? Suddenly, I get lumbered with 10G of extra files. Worse, what happens if someone else had made a snapshot of A, too? Who gets the 10G added to their quota, me or them? What if I'd filled up my quota? Would that stop you from deleting your copy, because my copy can't be charged against my quota? Would I just end up unexpectedly 10G over quota?
Quoted 4 lines
If you delete your subvolume A, like use the btrfs tool to delete it, you will only be stuck with what you changed in snapshot B. So if you only changed 5gig worth of information, and you deleted the original subvolume, you would have 5gig charged to your quota.
This doesn't work, though, if the owners of the "original" and
"new" subvolume are different:
Case 1:
* Porthos creates 10G data.
* Athos makes a snapshot of Porthos's data.
* A sysadmin (Richelieu) changes the ownership on Athos's snapshot of Porthos's data to Athos.
* Porthos deletes his copy of the data.
Case 2:
* Porthos creates 10G of data.
* Athos makes a snapshot of Porthos's data.
* Porthos deletes his copy of the data.
* A sysadmin (Richelieu) changes the ownership on Athos's snapshot of Porthos's data to Athos.
Case 3:
* Porthos creates 10G data.
* Athos makes a snapshot of Porthos's data.
* Aramis makes a snapshot of Porthos's data.
* A sysadmin (Richelieu) changes the ownership on Athos's snapshot of Porthos's data to Athos.
* Porthos deletes his copy of the data.
Case 4:
* Porthos creates 10G data.
* Athos makes a snapshot of Porthos's data.
* Aramis makes a snapshot of Athos's data.
* Porthos deletes his copy of the data.
[Consider also Richelieu changing ownerships of Athos's and Aramis's data at alternative points in this sequence]
In each of these, who gets charged (and how much) for their copy of
the data?
Quoted 2 lines
The idea is you are only charged for what blocks
you have on the disk. Thanks,
My point was that it's perfectly possible to have blocks on the
disk that are effectively owned by two people, and that the person to charge for those blocks is, to me, far from clear. You either end up charging twice for a single set of blocks on the disk, or you end up in a situation where one person's actions can cause another person's quota to fill up. Neither of these is particularly obvious behaviour.
Hugo.
Signature · 4 lines
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
--- I believe that it's closely correlated with ---
the aeroswine coefficient. Quoted 26 lines · Josef Bacik
Hello,
Various people have complained about how BTRFS deals with subvolumes recently, specifically the fact that they all have the same inode number, and there's no discrete seperation from one subvolume to another. Christoph asked that I lay out a basic design document of how we want subvolumes to work so we can hash everything out now, fix what is broken, and then move forward with a design that everybody is more or less happy with. I apologize in advance for how freaking long this email is going to be. I assume that most people are generally familiar with how BTRFS works, so I'm not going to bother explaining in great detail some stuff.
=== What are subvolumes? ===
They are just another tree. In BTRFS we have various b-trees to describe the filesystem. A few of them are filesystem wide, such as the extent tree, chunk tree, root tree etc. The tree's that hold the actual filesystem data, that is inodes and such, are kept in their own b-tree. This is how subvolumes and snapshots appear on disk, they are simply new b-trees with all of the file data contained within them.
=== What do subvolumes look like? ===
All the user sees are directories. They act like any other directory acts, with a few exceptions
Quoted 6 lines
1) You cannot hardlink between subvolumes. This is because subvolumes have their own inode numbers and such, think of them as seperate mounts in this case, you cannot hardlink between two mounts because the link needs to point to the same on disk inode, which is impossible between two different filesystems. The same is true for subvolumes, they have their own trees with their own inodes and inode numbers, so it's impossible to hardlink between them.
OK, so I'm unclear: would it be possible for nfsd to export subvolumes independently?
For that to work, we need to be able to take an inode that we just looked up by filehandle, and see which subvolume it belongs in. So if two subvolumes can point to the same inode, it doesn't work, but if st_dev is different between them, e.g., that'd be fine. Sounds like you're seeing the latter is possible, good!
Quoted 5 lines
1a) In case it wasn't clear from above, each subvolume has their own inode numbers, so you can have the same inode numbers used between two different subvolumes, since they are two different trees.
Quoted 8 lines
2) Obviously you can't just rm -rf subvolumes. Because they are roots there's extra metadata to keep track of them, so you have to use one of our ioctls to delete subvolumes/snapshots.
But permissions and everything else they are the same.
There is one tricky thing. When you create a subvolume, the directory inode that is created in the parent subvolume has the inode number of 256.
Is that the right way to say this? Doing a quick test, the inode numbers that a readdir of the parent directory returns *are* distinct. It's just the inode number that you get when you stat that is different.
Which is all fine and normal, *if* you treat this as a real mountpoint with its own vfsmount, st_dev, etc.
Quoted 8 lines
=== How do we want subvolumes to work from a user perspective? ===
1) Users need to be able to create their own subvolumes. The permission semantics will be absolutely the same as creating directories, so I don't think this is too tricky. We want this because you can only take snapshots of subvolumes, and so it is important that users be able to create their own discrete snapshottable targets.
Quoted 7 lines
2) Users need to be able to snapshot their subvolumes. This is basically the same as #1, but it bears repeating.
3) Subvolumes shouldn't need to be specifically mounted. This is also important, we don't want users to have to go around mounting their subvolumes up manually one-by-one. Today users just cd into subvolumes and it works, just like cd'ing into a directory.
And the separate nfsd exports is another thing I'd really love to see
work: currently you can export a subtree of a filesystem if you want, but it's trivial to escape the subtree by guessing filehandles. So this gives us an easy way for administrators to create secure separate exports without having to manage entirely separate volumes.
If subvolumes got real mountpoints and so on, this would be easy.
--b.
Quoted 34 lines · J. Bruce Fields
Quoted 26 lines · Josef Bacik
Hello,
Various people have complained about how BTRFS deals with subvolumes recently, specifically the fact that they all have the same inode number, and there's no discrete seperation from one subvolume to another. Christoph asked that I lay out a basic design document of how we want subvolumes to work so we can hash everything out now, fix what is broken, and then move forward with a design that everybody is more or less happy with. I apologize in advance for how freaking long this email is going to be. I assume that most people are generally familiar with how BTRFS works, so I'm not going to bother explaining in great detail some stuff.
=== What are subvolumes? ===
They are just another tree. In BTRFS we have various b-trees to describe the filesystem. A few of them are filesystem wide, such as the extent tree, chunk tree, root tree etc. The tree's that hold the actual filesystem data, that is inodes and such, are kept in their own b-tree. This is how subvolumes and snapshots appear on disk, they are simply new b-trees with all of the file data contained within them.
=== What do subvolumes look like? ===
All the user sees are directories. They act like any other directory acts, with a few exceptions
Quoted 6 lines
1) You cannot hardlink between subvolumes. This is because subvolumes have their own inode numbers and such, think of them as seperate mounts in this case, you cannot hardlink between two mounts because the link needs to point to the same on disk inode, which is impossible between two different filesystems. The same is true for subvolumes, they have their own trees with their own inodes and inode numbers, so it's impossible to hardlink between them.
Quoted 3 lines
OK, so I'm unclear: would it be possible for nfsd to export subvolumes independently?
Yeah.
Quoted 6 lines
For that to work, we need to be able to take an inode that we just looked up by filehandle, and see which subvolume it belongs in. So if two subvolumes can point to the same inode, it doesn't work, but if
st_devis different between them, e.g., that'd be fine. Sounds like you're seeing the latter is possible, good!
So you can't have the same inode in two subvolumes, since they are different trees. You can have the same inode numbers between two subvolumes, because they are different trees.
Quoted 14 lines
Quoted 5 lines
1a) In case it wasn't clear from above, each subvolume has their own inode numbers, so you can have the same inode numbers used between two different subvolumes, since they are two different trees.
Quoted 8 lines
2) Obviously you can't just rm -rf subvolumes. Because they are roots there's extra metadata to keep track of them, so you have to use one of our ioctls to delete subvolumes/snapshots.
But permissions and everything else they are the same.
There is one tricky thing. When you create a subvolume, the directory inode that is created in the parent subvolume has the inode number of 256.
Quoted 7 lines
Is that the right way to say this? Doing a quick test, the inode numbers that a readdir of the parent directory returns *are* distinct. It's just the inode number that you get when you stat that is different.
Which is all fine and normal, *if* you treat this as a real mountpoint with its own vfsmount,
st_dev, etc.
Oh well crud, I was hoping that I could leave the inode numbers as 256 for everything, but I forgot about readdir. So the inode item in the parent would have to have a unique inode number that would get spit out in readdir, but then if we stat'ed the directory we'd get 256 for the inode number. Oh well, incompat flag it is then.
Quoted 16 lines
Quoted 8 lines
=== How do we want subvolumes to work from a user perspective? ===
1) Users need to be able to create their own subvolumes. The permission semantics will be absolutely the same as creating directories, so I don't think this is too tricky. We want this because you can only take snapshots of subvolumes, and so it is important that users be able to create their own discrete snapshottable targets.
Quoted 7 lines
2) Users need to be able to snapshot their subvolumes. This is basically the same as #1, but it bears repeating.
3) Subvolumes shouldn't need to be specifically mounted. This is also important, we don't want users to have to go around mounting their subvolumes up manually one-by-one. Today users just cd into subvolumes and it works, just like cd'ing into a directory.
Quoted 7 lines
And the separate nfsd exports is another thing I'd really love to see
work: currently you can export a subtree of a filesystem if you want, but it's trivial to escape the subtree by guessing filehandles. So this gives us an easy way for administrators to create secure separate exports without having to manage entirely separate volumes.If subvolumes got real mountpoints and so on, this would be easy.
Thats the idea, we'll see how well it works out ;). Thanks,
Josef
Quoted 5 lines · Josef Bacik
Oh well crud, I was hoping that I could leave the inode numbers as 256 for everything, but I forgot about readdir. So the inode item in the parent would have to have a unique inode number that would get spit out in readdir, but then if we stat'ed the directory we'd get 256 for the inode number. Oh well, incompat flag it is then.
I think you're already fine:
# mkdir TMP # dd if=/dev/zero of=TMP-image bs=1M count=512 # mkfs.btrfs TMP-image # mount -oloop TMP-image TMP/ # btrfs subvolume create sub-a # btrfs subvolume create sub-b ../readdir-inos . . 256 256 .. 256 4130609 sub-a 256 256 sub-b 257 256
Where readdir-inos is my silly test program below, and the first number is from readdir, the second from stat.
?
--b.
#include <stdio.h>
#include <err.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
/* demonstrate that for mountpoints, readdir ino of mounted-on
* directory, stat returns ino of mounted directory. */
int main(int argc, char *argv[])
{
struct dirent *de;
int ret;
DIR *d;
if (argc != 2)
errx(1, "usage: %s <directory>", argv[0]);
ret = chdir(argv[1]);
if (ret)
errx(1, "chdir /");
d = opendir(".");
if (!d)
errx(1, "opendir .");
while (de = readdir(d)) {
struct stat st;
ret = stat(de->d_name, &st);
if (ret)
errx(1, "stat %s", de->d_name);
printf("%s %d %d\n", de->d_name, de->d_ino, st.st_ino);
}
}Quoted 11 lines · On Wed, 1 Dec 2010 09:21:36 -0500 Josef Bacik <[email protected]> wrote:
There is one tricky thing. When you create a subvolume, the directory inode that is created in the parent subvolume has the inode number of 256. So if you have a bunch of subvolumes in the same parent subvolume, you are going to have a bunch of directories with the inode number of 256. This is so when users cd into a subvolume we can know its a subvolume and do all the normal voodoo to start looking in the subvolumes tree instead of the parent subvolumes tree.
This is where things go a bit sideways. We had serious problems with NFS, but thankfully NFS gives us a bunch of hooks to get around these problems. CIFS/Samba do not, so we will have problems there, not to mention any other userspace application that looks at inode numbers.
A more common use case than CIFS or samba is going to be things like backup programs. They commonly look at inode numbers in order to identify hardlinks and may be horribly confused when there files that have a link count >1 and inode number collisions with other files.
That probably qualifies as an "enterprise-ready" show stopper...
Quoted 11 lines
=== What do we do? ===
This is where I expect to see the most discussion. Here is what I want to do
1) Scrap the 256 inode number thing. Instead we'll just put a flag in the inode to say "Hey, I'm a subvolume" and then we can do all of the appropriate magic that way. This unfortunately will be an incompatible format change, but the sooner we get this adressed the easier it will be in the long run. Obviously when I say format change I mean via the incompat bits we have, so old fs's won't be broken and such.
Quoted 7 lines
2) Do something like NFS's referral mounts when we cd into a subvolume. Now we just do dentry trickery, but that doesn't make the boundary between subvolumes clear, so it will confuse people (and samba) when they walk into a subvolume and all of a sudden the inode numbers are the same as in the directory behind them. With doing the referral mount thing, each subvolume appears to be its own mount and that way things like NFS and samba will work properly.
Sounds like you're on the right track.
The key concept is really that an inode number should be unique within the scope of the st_dev. The simplest solution for you here is simply to give each subvol its own st_dev and mount it up via a shrinkable mount automagically when someone walks into the directory. In addition to the examples of this in NFS, CIFS does this for DFS referrals.
Today, this is mostly done by hijacking the follow_link operation, but David Howells proposed some patches a while back to do this via a more formalized interface. It may be reasonable to target this work on top of that, depending on the state of those changes...
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 21 lines · J. Bruce Fields
Quoted 5 lines · Josef Bacik
Oh well crud, I was hoping that I could leave the inode numbers as 256 for everything, but I forgot about readdir. So the inode item in the parent would have to have a unique inode number that would get spit out in readdir, but then if we stat'ed the directory we'd get 256 for the inode number. Oh well, incompat flag it is then.
I think you're already fine:
# mkdir TMP # dd if=/dev/zero of=TMP-image bs=1M count=512 # mkfs.btrfs TMP-image # mount -oloop TMP-image TMP/ # btrfs subvolume create sub-a # btrfs subvolume create sub-b ../readdir-inos . . 256 256 .. 256 4130609 sub-a 256 256 sub-b 257 256
Quoted 3 lines
Where readdir-inos is my silly test program below, and the first number is from readdir, the second from stat.
Heh as soon as I typed my email I went and actually looked at the code, looks like for readdir we fill in the root id, which will be unique, so hotdamn we are good and I don't have to use a stupid incompat flag. Thanks for checking that :),
Josef
Quoted 22 lines · Josef Bacik
Quoted 21 lines · J. Bruce Fields
Quoted 5 lines · Josef Bacik
Oh well crud, I was hoping that I could leave the inode numbers as 256 for everything, but I forgot about readdir. So the inode item in the parent would have to have a unique inode number that would get spit out in readdir, but then if we stat'ed the directory we'd get 256 for the inode number. Oh well, incompat flag it is then.
I think you're already fine:
# mkdir TMP # dd if=/dev/zero of=TMP-image bs=1M count=512 # mkfs.btrfs TMP-image # mount -oloop TMP-image TMP/ # btrfs subvolume create sub-a # btrfs subvolume create sub-b ../readdir-inos . . 256 256 .. 256 4130609 sub-a 256 256 sub-b 257 256
Quoted 8 lines
Quoted 3 lines
Where readdir-inos is my silly test program below, and the first number is from readdir, the second from stat.
Heh as soon as I typed my email I went and actually looked at the code, looks like for readdir we fill in the root id, which will be unique, so hotdamn we are good and I don't have to use a stupid incompat flag. Thanks for checking that :),
My only complaint was just about how you said this:
"When you create a subvolume, the directory inode that is created in the parent subvolume has the inode number of 256"
If you revise that you might want to clarify. (Maybe "Every subvolume has a root directory inode with inode number 256"?)
The way you've stated it sounds like you're talking about the readdir-returned number, which would normally come from the inode that has been covered up by the mount, and which really is an inode in the parent filesystem....
--b.
On Wed, Dec 1, 2010 at 11:35 AM, Hugo Mills <[email protected]> w= rote:
Quoted 2 lines · Josef Bacik
Quoted 1 line
If you delete your subvolume A, like use the btrfs tool to delete it=
, you will
Quoted 1 line
Quoted 1 line
only be stuck with what you changed in snapshot B. =C2=A0So if you o=
nly changed 5gig
Quoted 1 line
Quoted 1 line
worth of information, and you deleted the original subvolume, you wo=
uld have
Quoted 10 lines
Quoted 1 line
5gig charged to your quota.
=C2=A0 This doesn't work, though, if the owners of the "original" and "new" subvolume are different:
Case 1:
=C2=A0* Porthos creates 10G data.
=C2=A0* Athos makes a snapshot of Porthos's data.
=C2=A0* A sysadmin (Richelieu) changes the ownership on Athos's snaps=
hot of
Quoted 9 lines
=C2=A0 Porthos's data to Athos.
=C2=A0* Porthos deletes his copy of the data.Case 2:
=C2=A0* Porthos creates 10G of data.
=C2=A0* Athos makes a snapshot of Porthos's data.
=C2=A0* Porthos deletes his copy of the data.
=C2=A0* A sysadmin (Richelieu) changes the ownership on Athos's snaps=
hot of
Quoted 8 lines
=C2=A0 Porthos's data to Athos.
Case 3:
=C2=A0* Porthos creates 10G data.
=C2=A0* Athos makes a snapshot of Porthos's data.
=C2=A0* Aramis makes a snapshot of Porthos's data.
=C2=A0* A sysadmin (Richelieu) changes the ownership on Athos's snaps=
hot of
Quoted 10 lines
=C2=A0 Porthos's data to Athos.
=C2=A0* Porthos deletes his copy of the data.Case 4:
=C2=A0* Porthos creates 10G data.
=C2=A0* Athos makes a snapshot of Porthos's data.
=C2=A0* Aramis makes a snapshot of Athos's data.
=C2=A0* Porthos deletes his copy of the data.
=C2=A0 [Consider also Richelieu changing ownerships of Athos's and Ar=
amis's
Quoted 3 lines
=C2=A0 data at alternative points in this sequence]
=C2=A0 In each of these, who gets charged (and how much) for their co=
py of
Quoted 6 lines
the data?
Quoted 2 lines
=C2=A0The idea is you are only charged for what blocks you have on the disk. =C2=A0Thanks,
=C2=A0 My point was that it's perfectly possible to have blocks on th=
e
Quoted 5 lines
disk that are effectively owned by two people, and that the person to charge for those blocks is, to me, far from clear. You either end up charging twice for a single set of blocks on the disk, or you end up in a situation where one person's actions can cause another person's quota to fill up. Neither of these is particularly obvious behaviour.
As a sysadmin and as a user, quotas shouldn't be about "physical blocks of storage used" but should be about "logical storage used".
IOW, if the filesystem is compressed, using 1 GB of physical space to store 10 GB of data, my "quota used" should be 10 GB.
Similar for deduplication. The quota is based on the storage *before* the file is deduped. Not after.
Similar for snapshots. If UserA has 10 GB of quota used, I snapshot their filesystem, then my "quota used" would be 10 GB as well. As data in my snapshot changes, my "quota used" is updated to reflect that (change 1 GB of data compared to snapshot, use 1 GB of quota).
You have to (or at least should) keep two sets of stats for storage usa= ge:
- logical amount used ("real" file size, before compression, before
de-dupe, before snapshots, etc)
- physical amount used (what's actually written to disk)
User-level quotas are based on the logical storage used. Admin-level quotas (if you want to implement them) would be based on physical storage used.
Thus, the output of things like df, du, ls would show the "logical" storage used and file sizes. And you would either have an additional option to those apps (--real or something) to show the "actual" storage used and file sizes as stored on disk.
Trying to make quotas and disk usage utilities to work based on what's physically on disk is just backwards, imo. And prone to a lot of confusion.
--=20
=46reddie Cash
[email protected]
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Jeff Layton
A more common use case than CIFS or samba is going to be things like backup programs. They commonly look at inode numbers in order to identify hardlinks and may be horribly confused when there files that have a link count >1 and inode number collisions with other files.
That probably qualifies as an "enterprise-ready" show stopper...
I hope that a backup program, uses the pair (inode,fsid) to identify if two file are hardlinked... otherwise a backup of two filesystem mounted can be quite danguerous...
Quoted 1 line
From the statfs(2) man page:
[..]
The f_fsid field
[...]
The general idea is that f_fsid contains some random stuff such that the pair (f_fsid,ino) uniquely determines a file. Some operating systems use (a variation on) the device number, or the device number combined with the
file-system type. Several OSes restrict giving out the f_fsid field to the
superuser only (and zero it for unprivileged users), because this field is used in the filehandle of the file system when NFS-exported, and giving it out is a security concern.
And the btrfs_statfs function returns a different fsid for every subvolume.
Signature · 2 lines
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <[email protected]> Key fingerprint = 4769 7E51 5293 D36C 814E C054 BF04 F161 3DC5 0512
Quoted 26 lines · On Wed, 1 Dec 2010 21:46:03 +0100 Goffredo Baroncelli <[email protected]>…
Quoted 6 lines · Jeff Layton
A more common use case than CIFS or samba is going to be things like backup programs. They commonly look at inode numbers in order to identify hardlinks and may be horribly confused when there files that have a link count >1 and inode number collisions with other files.
That probably qualifies as an "enterprise-ready" show stopper...
I hope that a backup program, uses the pair (inode,fsid) to identify if two file are hardlinked... otherwise a backup of two filesystem mounted can be quite danguerous...
From the statfs(2) man page:
[..]
Thef_fsidfield
[...]
The general idea is thatf_fsidcontains some random stuff such that the pair (f_fsid,ino) uniquely determines a file. Some operating systems use (a variation on) the device number, or the device number combined with the
file-system type. Several OSes restrict giving out thef_fsidfield to the
superuser only (and zero it for unprivileged users), because this field is used in the filehandle of the file system when NFS-exported, and giving it out is a security concern.
Quoted 2 lines
And the
btrfs_statfsfunction returns a different fsid for every subvolume.
Ahh, interesting. I've never read that blurb on f_fsid...
Unfortunately, it looks like not all filesystems fill that field out. NFS and CIFS leave it conspicuously blank. Those are probably bugs...
OTOH, the GLibc docs say this:
dev_t st_dev
Identifies the device containing the file. The st_ino and st_dev, taken together, uniquely identify the file. The st_dev value is not necessarily consistent across reboots or system crashes, however.
...and it's always been my understanding that a st_dev/st_ino combination should be unique.
Is there some definitive POSIX statement on why one should prefer to use f_fsid over st_dev in this situation?
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 17 lines · Freddie Cash
Quoted 9 lines · Hugo Mills
Quoted 2 lines
The idea is you are only charged for what blocks
you have on the disk. Thanks,My point was that it's perfectly possible to have blocks on the disk that are effectively owned by two people, and that the person to charge for those blocks is, to me, far from clear. You either end up charging twice for a single set of blocks on the disk, or you end up in a situation where one person's actions can cause another person's quota to fill up. Neither of these is particularly obvious behaviour.
As a sysadmin and as a user, quotas shouldn't be about "physical blocks of storage used" but should be about "logical storage used".
IOW, if the filesystem is compressed, using 1 GB of physical space to store 10 GB of data, my "quota used" should be 10 GB.
Quoted 7 lines
Similar for deduplication. The quota is based on the storage *before* the file is deduped. Not after.
Similar for snapshots. If UserA has 10 GB of quota used, I snapshot their filesystem, then my "quota used" would be 10 GB as well. As data in my snapshot changes, my "quota used" is updated to reflect that (change 1 GB of data compared to snapshot, use 1 GB of quota).
So if I've got 10G of data, and I snapshot it, I've just used
another 10G of quota?
Quoted 9 lines
You have to (or at least should) keep two sets of stats for storage usage:
- logical amount used ("real" file size, before compression, before
de-dupe, before snapshots, etc)
- physical amount used (what's actually written to disk)User-level quotas are based on the logical storage used. Admin-level quotas (if you want to implement them) would be based on physical storage used.
Quoted 8 lines
Thus, the output of things like df, du, ls would show the "logical" storage used and file sizes. And you would either have an additional option to those apps (--real or something) to show the "actual" storage used and file sizes as stored on disk.
Trying to make quotas and disk usage utilities to work based on what's physically on disk is just backwards, imo. And prone to a lot of confusion.
Trying to make quotas work based on what's physically on the disk
appears to have serious issues on the semantics of "using up space", so I agree with you on this point (and, indeed, it was the point I was trying to make).
However, doing it that way also effectively penalises users and
prevents (or severely discourages) them from using the advanced functions of the filesystem. There's no benefit (in disk usage terms) to the user in using a snapshot -- they might as well use plain cp.
Hugo.
Signature · 4 lines
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
--- I believe that it's closely correlated with ---
the aeroswine coefficient. On Wed, Dec 1, 2010 at 1:28 PM, Hugo Mills <[email protected]> wr= ote:
Quoted 7 lines · Freddie Cash
Quoted 1 line
On Wed, Dec 1, 2010 at 11:35 AM, Hugo Mills <[email protected]=
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 2 lines
=C2=A0The idea is you are only charged for what blocks you have on the disk. =C2=A0Thanks,
=C2=A0 My point was that it's perfectly possible to have blocks on=
the
Quoted 1 line
Quoted 1 line
Quoted 1 line
disk that are effectively owned by two people, and that the person=
to
Quoted 1 line
Quoted 1 line
Quoted 1 line
charge for those blocks is, to me, far from clear. You either end =
up
Quoted 1 line
Quoted 1 line
Quoted 1 line
charging twice for a single set of blocks on the disk, or you end =
up
Quoted 1 line
Quoted 1 line
Quoted 1 line
in a situation where one person's actions can cause another person=
's
Quoted 1 line
Quoted 1 line
Quoted 1 line
quota to fill up. Neither of these is particularly obvious behavio=
ur.
Quoted 5 lines
Quoted 5 lines
As a sysadmin and as a user, quotas shouldn't be about "physical blocks of storage used" but should be about "logical storage used".
IOW, if the filesystem is compressed, using 1 GB of physical space t=
o
Quoted 3 lines
Quoted 3 lines
store 10 GB of data, my "quota used" should be 10 GB.
Similar for deduplication. =C2=A0The quota is based on the storage *=
before*
Quoted 3 lines
Quoted 3 lines
the file is deduped. =C2=A0Not after.
Similar for snapshots. =C2=A0If UserA has 10 GB of quota used, I sna=
pshot
Quoted 1 line
Quoted 1 line
their filesystem, then my "quota used" would be 10 GB as well. =C2=A0=
As
Quoted 5 lines
Quoted 2 lines
data in my snapshot changes, my "quota used" is updated to reflect that (change 1 GB of data compared to snapshot, use 1 GB of quota).
=C2=A0 So if I've got 10G of data, and I snapshot it, I've just used another 10G of quota?
Sorry, forgot the "per user" bit above.
If UserA has 10 GB of data, then UserB snapshots it, UserB's quota usage is 10 GB.
If UserA has 10 GB of data and snapshots it, then only 10 GB of quota usage is used, as there is 0 difference between the snapshot and the filesystem. As UserA modifies data, their quota usage increases by the amount that is modified (ie 10 GB data, snapshot, modify 1 GB data =3D=3D 11 GB quota usage).
If you combine the two scenarios, you end up with:
- UserA has 10 GB of data =3D=3D 10 GB quota usage
- UserB snapshots UserA's filesystem (clone), so UserB has 10 GB
quota usage (even though 0 blocks have changed on disk)
- UserA snapshots UserA's filesystem =3D=3D no change to quota usage =
(no
blocks on disk have changed)
- UserA modifies 1 GB of data in the filesystem =3D=3D 1 GB new quota
usage (11 GB total) (1 GB of blocks owned by UserA have changed, plus the 10 GB in the snapshot)
- UserB still only has 10 GB quota usage, since their snapshot
hasn't changed (0 blocks changed)
If UserA deletes their filesystem and all their snapshots, freeing up 11 GB of quota usage on their account, UserB's quota will still be 10 GB, and the blocks on the disk aren't actually removed (still referenced by UserB's snapshot).
Basically, within a user's account, only the data unique to a snapshot should count toward the quota.
Across accounts, the original (root) snapshot would count completely to the new user's quota, and then only data unique to subsequent snapshots would count.
I hope that makes it more clear. :) All the different layers and whatnot get confusing. :)
--=20
=46reddie Cash
[email protected]
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 15 lines · Josef Bacik
Quoted 14 lines · J. Bruce Fields
I think you're already fine:
# mkdir TMP # dd if=/dev/zero of=TMP-image bs=1M count=512 # mkfs.btrfs TMP-image # mount -oloop TMP-image TMP/ # btrfs subvolume create sub-a # btrfs subvolume create sub-b ../readdir-inos . . 256 256 .. 256 4130609 sub-a 256 256 sub-b 257 256
Quoted 4 lines
Quoted 2 lines
Where readdir-inos is my silly test program below, and the first number is from readdir, the second from stat.
Heh as soon as I typed my email I went and actually looked at the code, looks like for readdir we fill in the root id, which will be unique, so hotdamn we are good and I don't have to use a stupid incompat flag. Thanks for checking that :),
Except, aren't the inode numbers within a filesystem and the sunbvolume tree IDs allocated out of separate namespaces? I don't think there's anything preventing a file/directory from having an inode number that clashes with one of the snapshots.
In fact, this already happens in the example above: "." (inode 256 in the root subvolume) and "sub-a" (subvolume ID 256).
(Though I still don't understand the semantics well enough to say whether we need all the inode numbers returned by readdir to be distinct.)
--Michael Vrable
Quoted 1 line · Freddie Cash
On Wed, Dec 1, 2010 at 1:28 PM, Hugo Mills <[email protected]> =
Quoted 2 lines · wrote:
Quoted 2 lines · Freddie Cash
Quoted 1 line
On Wed, Dec 1, 2010 at 11:35 AM, Hugo Mills <[email protected]=
Quoted 4 lines · k> wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
=C2=A0The idea is you are only charged for what blocks you have on the disk. =C2=A0Thanks,
=C2=A0 My point was that it's perfectly possible to have blocks o=
n the
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
disk that are effectively owned by two people, and that the perso=
n to
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
charge for those blocks is, to me, far from clear. You either end=
up
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
charging twice for a single set of blocks on the disk, or you end=
up
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
in a situation where one person's actions can cause another perso=
n's
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
quota to fill up. Neither of these is particularly obvious behavi=
our.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
As a sysadmin and as a user, quotas shouldn't be about "physical blocks of storage used" but should be about "logical storage used".
IOW, if the filesystem is compressed, using 1 GB of physical space =
to
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
store 10 GB of data, my "quota used" should be 10 GB.
Similar for deduplication. =C2=A0The quota is based on the storage =
*before*
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
the file is deduped. =C2=A0Not after.
Similar for snapshots. =C2=A0If UserA has 10 GB of quota used, I sn=
apshot
Quoted 1 line
Quoted 1 line
Quoted 1 line
their filesystem, then my "quota used" would be 10 GB as well. =C2=A0=
As
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
data in my snapshot changes, my "quota used" is updated to reflect that (change 1 GB of data compared to snapshot, use 1 GB of quota).
=C2=A0 So if I've got 10G of data, and I snapshot it, I've just used another 10G of quota?
Quoted 8 lines
Sorry, forgot the "per user" bit above.
If UserA has 10 GB of data, then UserB snapshots it, UserB's quota usage is 10 GB.
If UserA has 10 GB of data and snapshots it, then only 10 GB of quota usage is used, as there is 0 difference between the snapshot and the filesystem. =C2=A0As UserA modifies data, their quota usage increases=
by
Quoted 1 line
the amount that is modified (ie 10 GB data, snapshot, modify 1 GB dat=
a
Quoted 5 lines
=3D=3D 11 GB quota usage).
If you combine the two scenarios, you end up with:
=C2=A0- UserA has 10 GB of data =3D=3D 10 GB quota usage =C2=A0- UserB snapshots UserA's filesystem (clone), so UserB has 10 G=
B
Quoted 1 line
quota usage (even though 0 blocks have changed on disk)
Please define where the owner of a subvolume/snapshot is stored.
To my knowledge when you make a snapshot, you have the same set of files with the same set of owners and groups. Whatever user does the snapshot this does not change this unless chown or chgrp are used.
Also a non-root user (or a process without CAP_whatever) should not be able to snapshot a subvolume where the root directory of that
subvolume is not owned by the user attempting the snapshot. If you
do not do so then you end up with the same security and quota issues that hard links have when you don't have separate filesystems.
You could have separate subvolumes for / and /home/foo and user foo could snapshot / to /home/foo/exploit_later_001 and then foo can just wait for an exploit to come along for one of the binaries or libs in /home/foo/exploit_later_001 and own.
Yes, snapshot creation should be more restricted than hard links, for good reason.
I have other questions but the answer to this fundamental game changer may solve many of the mentioned issues.
Quoted 1 line
=C2=A0- UserA snapshots UserA's filesystem =3D=3D no change to quota =
usage (no
Quoted 2 lines
blocks on disk have changed)
=C2=A0- UserA modifies 1 GB of data in the filesystem =3D=3D 1 GB new=
quota
Quoted 11 lines
usage (11 GB total) (1 GB of blocks owned by UserA have changed, plus the 10 GB in the snapshot)
=C2=A0- UserB still only has 10 GB quota usage, since their snapshot hasn't changed (0 blocks changed)If UserA deletes their filesystem and all their snapshots, freeing up 11 GB of quota usage on their account, UserB's quota will still be 10 GB, and the blocks on the disk aren't actually removed (still referenced by UserB's snapshot).
Basically, within a user's account, only the data unique to a snapsho=
t
Quoted 7 lines
should count toward the quota.
Across accounts, the original (root) snapshot would count completely to the new user's quota, and then only data unique to subsequent snapshots would count.
I hope that makes it more clear. =C2=A0:) =C2=A0All the different lay=
ers and
Quoted 1 line
whatnot get confusing. =C2=A0:)
--
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
Quoted 9 lines · Josef Bacik
This is a huge topic in and of itself, but Christoph mentioned wanting to have an idea of what we wanted to do with it, so I'm putting it here. There are really 2 things here
1) Limiting the size of subvolumes. This is really easy for us, just create a subvolume and at creation time set a maximum size it can grow to and not let it go farther than that. Nice, simple and straightforward.
I'd love to be able to limit the size of a subvolume. Here the size comprises all blocks this subvolume refers to.
But at least as important to me is a mode where one can build groups of sub- volumes and snapshots and define a quota for the complete group. Again, the size here comprises all blocks any of the subvolumes/snapshots refer to. If a block is referred to more than once, it counts only once.
A subvolume/snapshot can be configured to be part of multiple groups.
With this I can do interesting things:
a) The user pays only for the space he occupies, not for read-only snapshots
b) The user pays for his space and for all the snapshots
c) The user pays for his space and snapshots, but not for snapshots generated for internal backup purposes
d) Hierarchical quotas. I can limit /home and set an additional quota on each homedir
Thanks,
Arne
Quoted 8 lines · Josef Bacik
1) Scrap the 256 inode number thing. Instead we'll just put a flag in the inode to say "Hey, I'm a subvolume" and then we can do all of the appropriate magic that way. This unfortunately will be an incompatible format change, but the sooner we get this adressed the easier it will be in the long run. Obviously when I say format change I mean via the incompat bits we have, so old fs's won't be broken and such.
Quoted 7 lines
2) Do something like NFS's referral mounts when we cd into a subvolume. Now we just do dentry trickery, but that doesn't make the boundary between subvolumes clear, so it will confuse people (and samba) when they walk into a subvolume and all of a sudden the inode numbers are the same as in the directory behind them. With doing the referral mount thing, each subvolume appears to be its own mount and that way things like NFS and samba will work properly.
What about the alternative and allocating inode numbers globally? The only problem would be with snapshots as they share the inum with the source, but one could just remap inode numbers in snapshots by sparing some bits at the top of this 64 bit field.
Having one mount per subvolume/snapshots is the cleaner solution, but quickly leads to situations where you have _lots_ of mounts, especially when you export them via NFS and mount it somewhere else. I've seen a machine which had to handle > 100,000 mounts from a zfs server. This definitely brings it's own problems, so I'd love to see a full fs exported as a single mount. This will also keep output from tools like iostat (for nfs mounts) and df readable.
Thanks,
Arne
Excerpts from Arne Jansen's message of 2010-12-02 04:49:39 -0500:
Quoted 17 lines
Quoted 8 lines · Josef Bacik
1) Scrap the 256 inode number thing. Instead we'll just put a flag in the inode to say "Hey, I'm a subvolume" and then we can do all of the appropriate magic that way. This unfortunately will be an incompatible format change, but the sooner we get this adressed the easier it will be in the long run. Obviously when I say format change I mean via the incompat bits we have, so old fs's won't be broken and such.
Quoted 7 lines
2) Do something like NFS's referral mounts when we cd into a subvolume. Now we just do dentry trickery, but that doesn't make the boundary between subvolumes clear, so it will confuse people (and samba) when they walk into a subvolume and all of a sudden the inode numbers are the same as in the directory behind them. With doing the referral mount thing, each subvolume appears to be its own mount and that way things like NFS and samba will work properly.
Quoted 4 lines
What about the alternative and allocating inode numbers globally? The only problem would be with snapshots as they share the inum with the source, but one could just remap inode numbers in snapshots by sparing some bits at the top of this 64 bit field.
The global inode number is possible, it's just another btree that must be maintained on disk in order to map which inodes are free and which ones aren't. It also needs to have a reference count on each inode, since each snapshot effectively increases the reference count on every file and directory it contains.
The cost of maintaining that reference count is very very high.
-chris
Quoted 11 lines
Having one mount per subvolume/snapshots is the cleaner solution, but quickly leads to situations where you have _lots_ of mounts, especially when you export them via NFS and mount it somewhere else. I've seen a machine which had to handle > 100,000 mounts from a zfs server. This definitely brings it's own problems, so I'd love to see a full fs exported as a single mount. This will also keep output from tools like iostat (for nfs mounts) and df readable.
Thanks,
Arne
Quoted 24 lines · Chris Mason
Excerpts from Arne Jansen's message of 2010-12-02 04:49:39 -0500:
Quoted 17 lines
Quoted 7 lines · Josef Bacik
1) Scrap the 256 inode number thing. Instead we'll just put a flag in the inode to say "Hey, I'm a subvolume" and then we can do all of the appropriate magic that way. This unfortunately will be an incompatible format change, but the sooner we get this adressed the easier it will be in the long run. Obviously when I say format change I mean via the incompat bits we have, so old fs's won't be broken and such.
Quoted 8 lines
2) Do something like NFS's referral mounts when we cd into a subvolume. Now we just do dentry trickery, but that doesn't make the boundary between subvolumes clear, so it will confuse people (and samba) when they walk into a subvolume and all of a sudden the inode numbers are the same as in the directory behind them. With doing the referral mount thing, each subvolume appears to be its own mount and that way things like NFS and samba will work properly.
Quoted 5 lines
What about the alternative and allocating inode numbers globally? The only problem would be with snapshots as they share the inum with the source, but one could just remap inode numbers in snapshots by sparing some bits at the top of this 64 bit field.
Quoted 8 lines
The global inode number is possible, it's just another btree that must be maintained on disk in order to map which inodes are free and which ones aren't. It also needs to have a reference count on each inode, since each snapshot effectively increases the reference count on every file and directory it contains.
The cost of maintaining that reference count is very very high.
A couple of years ago I was suffering from the problem of different files having the same inode number on Netapp servers. On a Netapp device if you snapshot a volume then the files in the snapshot have the same inode number as the original, even if the original changes. (Netapp snapshots are read only).
This means that if you attempt to see what has changed since your last snapshot using a command line such as:
diff src/file.c .snapshots/hourly.12/src.file.c
Then the diff tool will tell you that the files are the same even if they are different, because it is assuming that files with the same inode number will have identical contents.
Therefore I think it is a bad idea if potentially different files on btrfs can have the same inode number. It will break all sorts of tools.
Instead of maintaining a big complicated reference count of used inode numbers, could btrfs use bit masks to create a the userland visible inode number from the subvolume id and the real internal inode number. Something like:
userland_inode = ( volume_id << 48 ) & internal_inode;
Please forgive me if this is impossible, or if that C snippet is syntactically incorrect. I am not a filesystem or kernel developer, and I have not coded in C for many years.
Signature · 1 line
David Pottage
Quoted 4 lines · Arne Jansen
What about the alternative and allocating inode numbers globally? The only problem would be with snapshots as they share the inum with the source, but one could just remap inode numbers in snapshots by sparing some bits at the top of this 64 bit field.
I was wondering this as well. Why give each subvol its own inode number space? To avoid breaking assumptions of various programs, if they each have their own inode space, they must each have a unique st_dev. How are inode numbers currently allocated, and why wouldn't it be simple to just have a single pool of inode numbers for all subvols? It seems obvious to me that snapshots start out inheriting the inode numbers of the original subvol, but must be given a new st_dev.
Hi Josef,
Quoted 7 lines
1) Scrap the 256 inode number thing. Instead we'll just put a flag in the inode to say "Hey, I'm a subvolume" and then we can do all of the appropriate magic that way. This unfortunately will be an incompatible format change, but the sooner we get this adressed the easier it will be in the long run. Obviously when I say format change I mean via the incompat bits we have, so old fs's won't be broken and such.
Sorry if I've missed this elsewhere in the thread -- will we still have an efficient operation for enumerating subvolumes and snapshots, and how will that work? We're going to want tools like plymouth and grub to be able to list all snapshots without running a large scan.
Thanks,
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> One Laptop Per Child
2010/12/2 David Pottage <[email protected]>:
Quoted 2 lines
Therefore I think it is a bad idea if potentially different files on =
btrfs
Quoted 3 lines
can have the same inode number. It will break all sorts of tools.
Instead of maintaining a big complicated reference count of used inod=
e
Quoted 1 line
numbers, could btrfs use bit masks to create a the userland visible i=
node
Quoted 1 line
number from the subvolume id and the real internal inode number. Some=
thing
Quoted 6 lines
like:
userland_inode=3D (volume_id<< 48 ) &internal_inode;Please forgive me if this is impossible, or if that C snippet is syntactically incorrect. I am not a filesystem or kernel developer, a=
nd I
Quoted 5 lines
have not coded in C for many years.
--
David Pottage
Expanding on the idea: what about a pool of IDs for subvolumes and inode numbers inside a subvolume having the subvolume ID as a prefix? It gives each inode a unique number, doesn't require cheating the userland and is less costly than keeping reference count for each inode. The obvious downside that I can see is limitation on number of subvolumes that it would be possible to create. It also lowers the maximum number of inodes in a filesystem (because of bits taken up by subvolume ID). I expect there are also less-than obvious downsides.
Just an idea by a kernel and FS ignorant.
--
Pawe=C5=82 Brodacki
--
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
Quoted 10 lines · Chris Ball
Hi Josef,
Quoted 7 lines
1) Scrap the 256 inode number thing. Instead we'll just put a flag in the inode to say "Hey, I'm a subvolume" and then we can do all of the appropriate magic that way. This unfortunately will be an incompatible format change, but the sooner we get this adressed the easier it will be in the long run. Obviously when I say format change I mean via the incompat bits we have, so old fs's won't be broken and such.
Quoted 5 lines
Sorry if I've missed this elsewhere in the thread -- will we still have an efficient operation for enumerating subvolumes and snapshots, and how will that work? We're going to want tools like plymouth and grub to be able to list all snapshots without running a large scan.
Yeah the idea is we want to fix the problems with the design without breaking anything that currently works. So all the changes I want to make are going to be invisible for the user. Thanks,
Josef
Quoted 25 lines · Michael Vrable
Quoted 15 lines · Josef Bacik
Quoted 14 lines · J. Bruce Fields
I think you're already fine:
# mkdir TMP # dd if=/dev/zero of=TMP-image bs=1M count=512 # mkfs.btrfs TMP-image # mount -oloop TMP-image TMP/ # btrfs subvolume create sub-a # btrfs subvolume create sub-b ../readdir-inos . . 256 256 .. 256 4130609 sub-a 256 256 sub-b 257 256Quoted 8 lines
Quoted 3 lines
Where readdir-inos is my silly test program below, and the first number is from readdir, the second from stat.
Heh as soon as I typed my email I went and actually looked at the code, looks like for readdir we fill in the root id, which will be unique, so hotdamn we are good and I don't have to use a stupid incompat flag. Thanks for checking that :),
Quoted 7 lines
Except, aren't the inode numbers within a filesystem and the sunbvolume tree IDs allocated out of separate namespaces? I don't think there's anything preventing a file/directory from having an inode number that clashes with one of the snapshots.
In fact, this already happens in the example above: "." (inode 256 in the root subvolume) and "sub-a" (subvolume ID 256).
Oof, yes, I overlooked that.
Quoted 3 lines
(Though I still don't understand the semantics well enough to say whether we need all the inode numbers returned by readdir to be distinct.)
On normal mounts they're the number of the inode that was mounted over, so normally they'd be unique across the parent filesystem..... I don't know if anything depends on that.
--b.
Quoted 6 lines · David Pottage
A couple of years ago I was suffering from the problem of different files having the same inode number on Netapp servers. On a Netapp device if you snapshot a volume then the files in the snapshot have the same inode number as the original, even if the original changes. (Netapp snapshots are read only).
Quoted 8 lines
This means that if you attempt to see what has changed since your last snapshot using a command line such as:
diff
src/file.c.snapshots/hourly.12/src.file.cThen the diff tool will tell you that the files are the same even if they are different, because it is assuming that files with the same inode number will have identical contents.
diff should also recognize when they're on different filesystem, so this should also be fixable if subvolumes are treated as different filesystem (in the sense that they have different vfsmounts and fsid's).
--b.
Quoted 23 lines
Therefore I think it is a bad idea if potentially different files on btrfs can have the same inode number. It will break all sorts of tools.
Instead of maintaining a big complicated reference count of used inode numbers, could btrfs use bit masks to create a the userland visible inode number from the subvolume id and the real internal inode number. Something like:
userland_inode= (volume_id<< 48 ) &internal_inode;Please forgive me if this is impossible, or if that C snippet is syntactically incorrect. I am not a filesystem or kernel developer, and I have not coded in C for many years.
Signature · 6 lines
David Pottage -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 109 lines · Josef Bacik
Hello,
Various people have complained about how BTRFS deals with subvolumes recently, specifically the fact that they all have the same inode number, and there's no discrete seperation from one subvolume to another. Christoph asked that I lay out a basic design document of how we want subvolumes to work so we can hash everything out now, fix what is broken, and then move forward with a design that everybody is more or less happy with. I apologize in advance for how freaking long this email is going to be. I assume that most people are generally familiar with how BTRFS works, so I'm not going to bother explaining in great detail some stuff.
=== What are subvolumes? ===
They are just another tree. In BTRFS we have various b-trees to describe the filesystem. A few of them are filesystem wide, such as the extent tree, chunk tree, root tree etc. The tree's that hold the actual filesystem data, that is inodes and such, are kept in their own b-tree. This is how subvolumes and snapshots appear on disk, they are simply new b-trees with all of the file data contained within them.
=== What do subvolumes look like? ===
All the user sees are directories. They act like any other directory acts, with a few exceptions
1) You cannot hardlink between subvolumes. This is because subvolumes have their own inode numbers and such, think of them as seperate mounts in this case, you cannot hardlink between two mounts because the link needs to point to the same on disk inode, which is impossible between two different filesystems. The same is true for subvolumes, they have their own trees with their own inodes and inode numbers, so it's impossible to hardlink between them.
1a) In case it wasn't clear from above, each subvolume has their own inode numbers, so you can have the same inode numbers used between two different subvolumes, since they are two different trees.
2) Obviously you can't just rm -rf subvolumes. Because they are roots there's extra metadata to keep track of them, so you have to use one of our ioctls to delete subvolumes/snapshots.
But permissions and everything else they are the same.
There is one tricky thing. When you create a subvolume, the directory inode that is created in the parent subvolume has the inode number of 256. So if you have a bunch of subvolumes in the same parent subvolume, you are going to have a bunch of directories with the inode number of 256. This is so when users cd into a subvolume we can know its a subvolume and do all the normal voodoo to start looking in the subvolumes tree instead of the parent subvolumes tree.
This is where things go a bit sideways. We had serious problems with NFS, but thankfully NFS gives us a bunch of hooks to get around these problems. CIFS/Samba do not, so we will have problems there, not to mention any other userspace application that looks at inode numbers.
=== How do we want subvolumes to work from a user perspective? ===
1) Users need to be able to create their own subvolumes. The permission semantics will be absolutely the same as creating directories, so I don't think this is too tricky. We want this because you can only take snapshots of subvolumes, and so it is important that users be able to create their own discrete snapshottable targets.
2) Users need to be able to snapshot their subvolumes. This is basically the same as #1, but it bears repeating.
3) Subvolumes shouldn't need to be specifically mounted. This is also important, we don't want users to have to go around mounting their subvolumes up manually one-by-one. Today users just cd into subvolumes and it works, just like cd'ing into a directory.
=== Quotas ===
This is a huge topic in and of itself, but Christoph mentioned wanting to have an idea of what we wanted to do with it, so I'm putting it here. There are really 2 things here
1) Limiting the size of subvolumes. This is really easy for us, just create a subvolume and at creation time set a maximum size it can grow to and not let it go farther than that. Nice, simple and straightforward.
2) Normal quotas, via the quota tools. This just comes down to how do we want to charge users, do we want to do it per subvolume, or per filesystem. My vote is per filesystem. Obviously this will make it tricky with snapshots, but I think if we're just charging the diff's between the original volume and the snapshot to the user then that will be the easiest for people to understand, rather than making a snapshot all of a sudden count the users currently used quota * 2.
=== What do we do? ===
This is where I expect to see the most discussion. Here is what I want to do
1) Scrap the 256 inode number thing. Instead we'll just put a flag in the inode to say "Hey, I'm a subvolume" and then we can do all of the appropriate magic that way. This unfortunately will be an incompatible format change, but the sooner we get this adressed the easier it will be in the long run. Obviously when I say format change I mean via the incompat bits we have, so old fs's won't be broken and such.
2) Do something like NFS's referral mounts when we cd into a subvolume. Now we just do dentry trickery, but that doesn't make the boundary between subvolumes clear, so it will confuse people (and samba) when they walk into a subvolume and all of a sudden the inode numbers are the same as in the directory behind them. With doing the referral mount thing, each subvolume appears to be its own mount and that way things like NFS and samba will work properly.
I feel like I'm forgetting something here, hopefully somebody will point it out.
Quoted 8 lines
=== Conclusion ===
There are definitely some wonky things with subvolumes, but I don't think they are things that cannot be fixed now. Some of these changes will require incompat format changes, but it's either we fix it now, or later on down the road when BTRFS starts getting used in production really find out how many things our current scheme breaks and then have to do the changes then. Thanks,
So now that I've actually looked at everything, it looks like the semantics are all right for subvolumes
1) readdir - we return the root id in d_ino, which is unique across the fs
2) stat - we return 256 for all subvolumes, because that is their inode number
3) dev_t - we setup an anon super for all volumes, so they all get their own dev_t, which is set properly for all of their children, see below
[root@test1244 btrfs-test]# stat .
File: `.'
Size: 20 Blocks: 8 IO Block: 4096 directory
Device: 15h/21d Inode: 256 Links: 1
Access: (0555/dr-xr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2010-12-03 15:35:41.931679393 -0500
Modify: 2010-12-03 15:35:20.405679493 -0500
Change: 2010-12-03 15:35:20.405679493 -0500
[root@test1244 btrfs-test]# stat foo
File: `foo'
Size: 12 Blocks: 0 IO Block: 4096 directory
Device: 19h/25d Inode: 256 Links: 1
Access: (0700/drwx------) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2010-12-03 15:35:17.501679393 -0500
Modify: 2010-12-03 15:35:59.150680051 -0500
Change: 2010-12-03 15:35:59.150680051 -0500
[root@test1244 btrfs-test]# stat foo/foobar
File: `foo/foobar'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 19h/25d Inode: 257 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2010-12-03 15:35:59.150680051 -0500
Modify: 2010-12-03 15:35:59.150680051 -0500
Change: 2010-12-03 15:35:59.150680051 -0500
So as far as the user is concerned, everything should come out right. Obviously we had to do the NFS trickery still because as far as VFS is concerned the subvolumes are all on the same mount. So the question is this (and really this is directed at Christoph and Bruce and anybody else who may care), is this good enough, or do we want to have a seperate vfsmount for each subvolume? Thanks,
Josef
Quoted 4 lines · Josef Bacik
So now that I've actually looked at everything, it looks like the semantics are all right for subvolumes
1) readdir - we return the root id in
d_ino, which is unique across the fs
Though Michael Vrable pointed out an apparent collision with "normal" inode numbers on the parent filesystem?
Quoted 31 lines
2) stat - we return 256 for all subvolumes, because that is their inode number
3)dev_t- we setup an anon super for all volumes, so they all get their owndev_t, which is set properly for all of their children, see below[root@test1244 btrfs-test]# stat .
File: `.'
Size: 20 Blocks: 8 IO Block: 4096 directory
Device: 15h/21d Inode: 256 Links: 1
Access: (0555/dr-xr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2010-12-03 15:35:41.931679393 -0500
Modify: 2010-12-03 15:35:20.405679493 -0500
Change: 2010-12-03 15:35:20.405679493 -0500[root@test1244 btrfs-test]# stat foo
File: `foo'
Size: 12 Blocks: 0 IO Block: 4096 directory
Device: 19h/25d Inode: 256 Links: 1
Access: (0700/drwx------) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2010-12-03 15:35:17.501679393 -0500
Modify: 2010-12-03 15:35:59.150680051 -0500
Change: 2010-12-03 15:35:59.150680051 -0500[root@test1244 btrfs-test]# stat foo/foobar
File: `foo/foobar'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 19h/25d Inode: 257 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2010-12-03 15:35:59.150680051 -0500
Modify: 2010-12-03 15:35:59.150680051 -0500
Change: 2010-12-03 15:35:59.150680051 -0500
Quoted 5 lines
So as far as the user is concerned, everything should come out right. Obviously we had to do the NFS trickery still because as far as VFS is concerned the subvolumes are all on the same mount. So the question is this (and really this is directed at Christoph and Bruce and anybody else who may care), is this good enough, or do we want to have a seperate vfsmount for each subvolume? Thanks,
For nfsd's purposes, we need to be able find out about filesystems in two different ways:
1. Lookup by filehandle: we need to be able to identify which subvolume we're dealing with from a filehandle.
2. Lookup by path: we need to notice when we cross into a subvolume.
Looks like #1 already works. Not #2: the current nfsd code just checks for mountpoints. We could modify nfsd to also check whether dev_t changed each time it did a lookup. I suppose it would work, though it's annoying to have to do it just for the case of btrfs.
As far as I can tell, crossing into a subvolume is like crossing a mountpoint in every way except for the lack of a separate vfsmount. I'd worry that the inconsistency will end up requiring more special cases down the road, but I don't have any in mind.
--b.
Quoted 13 lines · Josef Bacik
Quoted 12 lines · Josef Bacik
Hello,
Various people have complained about how BTRFS deals with subvolumes recently, specifically the fact that they all have the same inode number, and there's no discrete seperation from one subvolume to another. Christoph asked that I lay out a basic design document of how we want subvolumes to work so we can hash everything out now, fix what is broken, and then move forward with a design that everybody is more or less happy with. I apologize in advance for how freaking long this email is going to be. I assume that most people are generally familiar with how BTRFS works, so I'm not going to bother explaining in great detail some stuff.
....
Quoted 6 lines
Quoted 5 lines
are things that cannot be fixed now. Some of these changes will require incompat format changes, but it's either we fix it now, or later on down the road when BTRFS starts getting used in production really find out how many things our current scheme breaks and then have to do the changes then. Thanks,
Quoted 7 lines
So now that I've actually looked at everything, it looks like the semantics are all right for subvolumes
1) readdir - we return the root id in
d_ino, which is unique across the fs
2) stat - we return 256 for all subvolumes, because that is their inode number
3)dev_t- we setup an anon super for all volumes, so they all get their owndev_t, which is set properly for all of their children, see below
A property of NFS fileshandles is that they must be stable across server reboots. Is this anon dev_t used as part of the NFS filehandle and if so how can you guarantee that it is stable?
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Excerpts from Dave Chinner's message of 2010-12-03 17:27:56 -0500:
Quoted 24 lines · Josef Bacik
Quoted 13 lines · Josef Bacik
Quoted 12 lines
Hello,
Various people have complained about how BTRFS deals with subvolumes recently, specifically the fact that they all have the same inode number, and there's no discrete seperation from one subvolume to another. Christoph asked that I lay out a basic design document of how we want subvolumes to work so we can hash everything out now, fix what is broken, and then move forward with a design that everybody is more or less happy with. I apologize in advance for how freaking long this email is going to be. I assume that most people are generally familiar with how BTRFS works, so I'm not going to bother explaining in great detail some stuff.
....
Quoted 9 lines
Quoted 5 lines
are things that cannot be fixed now. Some of these changes will require incompat format changes, but it's either we fix it now, or later on down the road when BTRFS starts getting used in production really find out how many things our current scheme breaks and then have to do the changes then. Thanks,
So now that I've actually looked at everything, it looks like the semantics are all right for subvolumes
Quoted 8 lines
Quoted 4 lines
1) readdir - we return the root id in
d_ino, which is unique across the fs
2) stat - we return 256 for all subvolumes, because that is their inode number
3)dev_t- we setup an anon super for all volumes, so they all get their owndev_t, which is set properly for all of their children, see belowA property of NFS fileshandles is that they must be stable across server reboots. Is this anon
dev_tused as part of the NFS filehandle and if so how can you guarantee that it is stable?
It isn't today, that's something we'll have to address.
-chris
Quoted 30 lines · Chris Mason
Excerpts from Dave Chinner's message of 2010-12-03 17:27:56 -0500:
Quoted 29 lines · Josef Bacik
Quoted 13 lines · Josef Bacik
Quoted 12 lines
Hello,
Various people have complained about how BTRFS deals with subvolumes recently, specifically the fact that they all have the same inode number, and there's no discrete seperation from one subvolume to another. Christoph asked that I lay out a basic design document of how we want subvolumes to work so we can hash everything out now, fix what is broken, and then move forward with a design that everybody is more or less happy with. I apologize in advance for how freaking long this email is going to be. I assume that most people are generally familiar with how BTRFS works, so I'm not going to bother explaining in great detail some stuff.
....
Quoted 13 lines
Quoted 5 lines
are things that cannot be fixed now. Some of these changes will require incompat format changes, but it's either we fix it now, or later on down the road when BTRFS starts getting used in production really find out how many things our current scheme breaks and then have to do the changes then. Thanks,
So now that I've actually looked at everything, it looks like the semantics are all right for subvolumes
1) readdir - we return the root id in
d_ino, which is unique across the fs
2) stat - we return 256 for all subvolumes, because that is their inode number
3)dev_t- we setup an anon super for all volumes, so they all get their owndev_t, which is set properly for all of their children, see below
Quoted 5 lines
Quoted 3 lines
A property of NFS fileshandles is that they must be stable across server reboots. Is this anon
dev_tused as part of the NFS filehandle and if so how can you guarantee that it is stable?It isn't today, that's something we'll have to address.
We're using statfs64.fs_fsid for this; I believe that's both stable across reboots and distinguishes between subvolumes, so that's OK.
(That said, since fs_fsid doesn't work for other filesystems, we depend on an explicit check for a filesystem type of "btrfs", which is awful--btrfs won't always be the only filesystem that wants to do this kind of thing, etc.)
--b.
Quoted 7 lines · J. Bruce Fields
We're using statfs64.fs_fsid for this; I believe that's both stable across reboots and distinguishes between subvolumes, so that's OK.
(That said, since
fs_fsiddoesn't work for other filesystems, we depend on an explicit check for a filesystem type of "btrfs", which is awful--btrfs won't always be the only filesystem that wants to do this kind of thing, etc.)
Sigh, I wanted to be able to specify the NFS FSID directly from within the kernel for Lustre many years already. Glad to see that this is moving forward.
Any chance we can add a ->get_fsid(sb, inode) method to export_operations
(or something simiar), that allows the filesystem to generate an FSID based on the volume and inode that is being exported?
Cheers, Andreas
Quoted 4 lines · Josef Bacik
Quoted 3 lines · Josef Bacik
Hello,
Various people have complained about how BTRFS deals with subvolumes=
recently,
Quoted 1 line
Quoted 1 line
specifically the fact that they all have the same inode number, and =
there's no
Quoted 1 line
Quoted 1 line
discrete seperation from one subvolume to another. =C2=A0Christoph a=
sked that I lay
Quoted 1 line
Quoted 1 line
out a basic design document of how we want subvolumes to work so we =
can hash
Quoted 1 line
Quoted 1 line
everything out now, fix what is broken, and then move forward with a=
design that
Quoted 1 line
Quoted 1 line
everybody is more or less happy with. =C2=A0I apologize in advance f=
or how freaking
Quoted 1 line
Quoted 1 line
long this email is going to be. =C2=A0I assume that most people are =
generally
Quoted 1 line
Quoted 1 line
familiar with how BTRFS works, so I'm not going to bother explaining=
in great
Quoted 5 lines
Quoted 5 lines
detail some stuff.
=3D=3D=3D What are subvolumes? =3D=3D=3D
They are just another tree. =C2=A0In BTRFS we have various b-trees t=
o describe the
Quoted 1 line
Quoted 1 line
filesystem. =C2=A0A few of them are filesystem wide, such as the ext=
ent tree, chunk
Quoted 1 line
Quoted 1 line
tree, root tree etc. =C2=A0The tree's that hold the actual filesyste=
m data, that is
Quoted 1 line
Quoted 1 line
inodes and such, are kept in their own b-tree. =C2=A0This is how sub=
volumes and
Quoted 1 line
Quoted 1 line
snapshots appear on disk, they are simply new b-trees with all of th=
e file data
Quoted 5 lines
Quoted 5 lines
contained within them.
=3D=3D=3D What do subvolumes look like? =3D=3D=3D
All the user sees are directories. =C2=A0They act like any other dir=
ectory acts, with
Quoted 3 lines
Quoted 3 lines
a few exceptions
1) You cannot hardlink between subvolumes. =C2=A0This is because sub=
volumes have
Quoted 1 line
Quoted 1 line
their own inode numbers and such, think of them as seperate mounts i=
n this case,
Quoted 1 line
Quoted 1 line
you cannot hardlink between two mounts because the link needs to poi=
nt to the
Quoted 1 line
Quoted 1 line
same on disk inode, which is impossible between two different filesy=
stems. =C2=A0The
Quoted 1 line
Quoted 1 line
same is true for subvolumes, they have their own trees with their ow=
n inodes and
Quoted 3 lines
Quoted 3 lines
inode numbers, so it's impossible to hardlink between them.
1a) In case it wasn't clear from above, each subvolume has their own=
inode
Quoted 1 line
Quoted 1 line
numbers, so you can have the same inode numbers used between two dif=
ferent
Quoted 3 lines
Quoted 3 lines
subvolumes, since they are two different trees.
2) Obviously you can't just rm -rf subvolumes. =C2=A0Because they ar=
e roots there's
Quoted 1 line
Quoted 1 line
extra metadata to keep track of them, so you have to use one of our =
ioctls to
Quoted 5 lines
Quoted 5 lines
delete subvolumes/snapshots.
But permissions and everything else they are the same.
There is one tricky thing. =C2=A0When you create a subvolume, the di=
rectory inode
Quoted 1 line
Quoted 1 line
that is created in the parent subvolume has the inode number of 256.=
=C2=A0So if you
Quoted 1 line
Quoted 1 line
have a bunch of subvolumes in the same parent subvolume, you are goi=
ng to have a
Quoted 1 line
Quoted 1 line
bunch of directories with the inode number of 256. =C2=A0This is so =
when users cd
Quoted 1 line
Quoted 1 line
into a subvolume we can know its a subvolume and do all the normal v=
oodoo to
Quoted 1 line
Quoted 1 line
start looking in the subvolumes tree instead of the parent subvolume=
s tree.
Quoted 2 lines
Quoted 2 lines
This is where things go a bit sideways. =C2=A0We had serious problem=
s with NFS, but
Quoted 1 line
Quoted 1 line
thankfully NFS gives us a bunch of hooks to get around these problem=
s.
Quoted 1 line
Quoted 1 line
CIFS/Samba do not, so we will have problems there, not to mention an=
y other
Quoted 3 lines
Quoted 3 lines
userspace application that looks at inode numbers.
=3D=3D=3D How do we want subvolumes to work from a user perspective?=
=3D=3D=3D
Quoted 2 lines
Quoted 2 lines
1) Users need to be able to create their own subvolumes. =C2=A0The p=
ermission
Quoted 1 line
Quoted 1 line
semantics will be absolutely the same as creating directories, so I =
don't think
Quoted 1 line
Quoted 1 line
this is too tricky. =C2=A0We want this because you can only take sna=
pshots of
Quoted 1 line
Quoted 1 line
subvolumes, and so it is important that users be able to create thei=
r own
Quoted 3 lines
Quoted 3 lines
discrete snapshottable targets.
2) Users need to be able to snapshot their subvolumes. =C2=A0This is=
basically the
Quoted 3 lines
Quoted 3 lines
same as #1, but it bears repeating.
3) Subvolumes shouldn't need to be specifically mounted. =C2=A0This =
is also
Quoted 1 line
Quoted 1 line
important, we don't want users to have to go around mounting their s=
ubvolumes up
Quoted 1 line
Quoted 1 line
manually one-by-one. =C2=A0Today users just cd into subvolumes and i=
t works, just
Quoted 5 lines
Quoted 5 lines
like cd'ing into a directory.
=3D=3D=3D Quotas =3D=3D=3D
This is a huge topic in and of itself, but Christoph mentioned wanti=
ng to have
Quoted 1 line
Quoted 1 line
an idea of what we wanted to do with it, so I'm putting it here. =C2=
=A0There are
Quoted 3 lines
Quoted 3 lines
really 2 things here
1) Limiting the size of subvolumes. =C2=A0This is really easy for us=
, just create a
Quoted 1 line
Quoted 1 line
subvolume and at creation time set a maximum size it can grow to and=
not let it
Quoted 3 lines
Quoted 3 lines
go farther than that. =C2=A0Nice, simple and straightforward.
2) Normal quotas, via the quota tools. =C2=A0This just comes down to=
how do we want
Quoted 1 line
Quoted 1 line
to charge users, do we want to do it per subvolume, or per filesyste=
m. =C2=A0My vote
Quoted 1 line
Quoted 1 line
is per filesystem. =C2=A0Obviously this will make it tricky with sna=
pshots, but I
Quoted 1 line
Quoted 1 line
think if we're just charging the diff's between the original volume =
and the
Quoted 1 line
Quoted 1 line
snapshot to the user then that will be the easiest for people to und=
erstand,
Quoted 1 line
Quoted 1 line
rather than making a snapshot all of a sudden count the users curren=
tly used
Quoted 5 lines
Quoted 5 lines
quota * 2.
=3D=3D=3D What do we do? =3D=3D=3D
This is where I expect to see the most discussion. =C2=A0Here is wha=
t I want to do
Quoted 2 lines
Quoted 2 lines
1) Scrap the 256 inode number thing. =C2=A0Instead we'll just put a =
flag in the inode
Quoted 1 line
Quoted 1 line
to say "Hey, I'm a subvolume" and then we can do all of the appropri=
ate magic
Quoted 1 line
Quoted 1 line
that way. =C2=A0This unfortunately will be an incompatible format ch=
ange, but the
Quoted 1 line
Quoted 1 line
sooner we get this adressed the easier it will be in the long run. =C2=
=A0Obviously
Quoted 1 line
Quoted 1 line
when I say format change I mean via the incompat bits we have, so ol=
d fs's won't
Quoted 3 lines
Quoted 3 lines
be broken and such.
2) Do something like NFS's referral mounts when we cd into a subvolu=
me. =C2=A0Now we
Quoted 1 line
Quoted 1 line
just do dentry trickery, but that doesn't make the boundary between =
subvolumes
Quoted 1 line
Quoted 1 line
clear, so it will confuse people (and samba) when they walk into a s=
ubvolume and
Quoted 1 line
Quoted 1 line
all of a sudden the inode numbers are the same as in the directory b=
ehind them.
Quoted 1 line
Quoted 1 line
With doing the referral mount thing, each subvolume appears to be it=
s own mount
Quoted 3 lines
Quoted 3 lines
and that way things like NFS and samba will work properly.
I feel like I'm forgetting something here, hopefully somebody will p=
oint it out.
Quoted 4 lines
Quoted 4 lines
=3D=3D=3D Conclusion =3D=3D=3D
There are definitely some wonky things with subvolumes, but I don't =
think they
Quoted 1 line
Quoted 1 line
are things that cannot be fixed now. =C2=A0Some of these changes wil=
l require
Quoted 1 line
Quoted 1 line
incompat format changes, but it's either we fix it now, or later on =
down the
Quoted 1 line
Quoted 1 line
road when BTRFS starts getting used in production really find out ho=
w many
Quoted 1 line
Quoted 1 line
things our current scheme breaks and then have to do the changes the=
n. =C2=A0Thanks,
Quoted 3 lines
Quoted 1 line
So now that I've actually looked at everything, it looks like the sem=
antics are
Quoted 3 lines
all right for subvolumes
1) readdir - we return the root id in
d_ino, which is unique across t=
he fs
Quoted 1 line
2) stat - we return 256 for all subvolumes, because that is their ino=
de number
Quoted 1 line
3)
dev_t- we setup an anon super for all volumes, so they all get th=
eir own
Quoted 5 lines
dev_t, which is set properly for all of their children, see below[root@test1244 btrfs-test]# stat .
=C2=A0File: `.'
=C2=A0Size: 20 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Blocks=
: 8 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0IO Block: 4096 =C2=A0 directory
Quoted 2 lines
Device: 15h/21d Inode: 256 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Links: 1
Access: (0555/dr-xr-xr-x) =C2=A0Uid: ( =C2=A0 =C2=A00/ =C2=A0 =C2=A0r=
oot) =C2=A0 Gid: ( =C2=A0 =C2=A00/ =C2=A0 =C2=A0root)
Quoted 7 lines
Access: 2010-12-03 15:35:41.931679393 -0500
Modify: 2010-12-03 15:35:20.405679493 -0500
Change: 2010-12-03 15:35:20.405679493 -0500[root@test1244 btrfs-test]# stat foo
=C2=A0File: `foo'
=C2=A0Size: 12 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Blocks=
: 0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0IO Block: 4096 =C2=A0 directory
Quoted 2 lines
Device: 19h/25d Inode: 256 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Links: 1
Access: (0700/drwx------) =C2=A0Uid: ( =C2=A0 =C2=A00/ =C2=A0 =C2=A0r=
oot) =C2=A0 Gid: ( =C2=A0 =C2=A00/ =C2=A0 =C2=A0root)
Quoted 7 lines
Access: 2010-12-03 15:35:17.501679393 -0500
Modify: 2010-12-03 15:35:59.150680051 -0500
Change: 2010-12-03 15:35:59.150680051 -0500[root@test1244 btrfs-test]# stat foo/foobar
=C2=A0File: `foo/foobar'
=C2=A0Size: 0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Blocks=
: 0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0IO Block: 4096 =C2=A0 regular emp= ty file
Quoted 2 lines
Device: 19h/25d Inode: 257 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Links: 1
Access: (0644/-rw-r--r--) =C2=A0Uid: ( =C2=A0 =C2=A00/ =C2=A0 =C2=A0r=
oot) =C2=A0 Gid: ( =C2=A0 =C2=A00/ =C2=A0 =C2=A0root)
Quoted 5 lines
Access: 2010-12-03 15:35:59.150680051 -0500
Modify: 2010-12-03 15:35:59.150680051 -0500
Change: 2010-12-03 15:35:59.150680051 -0500So as far as the user is concerned, everything should come out right.=
=C2=A0Obviously
Quoted 1 line
we had to do the NFS trickery still because as far as VFS is concerne=
d the
Quoted 1 line
subvolumes are all on the same mount. =C2=A0So the question is this (=
and really this
Quoted 1 line
is directed at Christoph and Bruce and anybody else who may care), is=
this good
Quoted 1 line
enough, or do we want to have a seperate vfsmount for each subvolume?=
=C2=A0Thanks,
Quoted 1 line
What are the drawbacks of having a vfsmount for each subvolume?
Why (besides having to code it up) are you trying to avoid doing it tha= t way?
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines · Mike Fedyk
Quoted 4 lines · Josef Bacik
Quoted 3 lines · Josef Bacik
Hello,
Various people have complained about how BTRFS deals with subvolum=
es recently,
Quoted 1 line
Quoted 1 line
Quoted 1 line
specifically the fact that they all have the same inode number, an=
d there's no
Quoted 1 line
Quoted 1 line
Quoted 1 line
discrete seperation from one subvolume to another. =A0Christoph as=
ked that I lay
Quoted 1 line
Quoted 1 line
Quoted 1 line
out a basic design document of how we want subvolumes to work so w=
e can hash
Quoted 1 line
Quoted 1 line
Quoted 1 line
everything out now, fix what is broken, and then move forward with=
a design that
Quoted 1 line
Quoted 1 line
Quoted 1 line
everybody is more or less happy with. =A0I apologize in advance fo=
r how freaking
Quoted 1 line
Quoted 1 line
Quoted 1 line
long this email is going to be. =A0I assume that most people are g=
enerally
Quoted 1 line
Quoted 1 line
Quoted 1 line
familiar with how BTRFS works, so I'm not going to bother explaini=
ng in great
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
detail some stuff.
=3D=3D=3D What are subvolumes? =3D=3D=3D
They are just another tree. =A0In BTRFS we have various b-trees to=
describe the
Quoted 1 line
Quoted 1 line
Quoted 1 line
filesystem. =A0A few of them are filesystem wide, such as the exte=
nt tree, chunk
Quoted 1 line
Quoted 1 line
Quoted 1 line
tree, root tree etc. =A0The tree's that hold the actual filesystem=
data, that is
Quoted 1 line
Quoted 1 line
Quoted 1 line
inodes and such, are kept in their own b-tree. =A0This is how subv=
olumes and
Quoted 1 line
Quoted 1 line
Quoted 1 line
snapshots appear on disk, they are simply new b-trees with all of =
the file data
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
contained within them.
=3D=3D=3D What do subvolumes look like? =3D=3D=3D
All the user sees are directories. =A0They act like any other dire=
ctory acts, with
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
a few exceptions
1) You cannot hardlink between subvolumes. =A0This is because subv=
olumes have
Quoted 1 line
Quoted 1 line
Quoted 1 line
their own inode numbers and such, think of them as seperate mounts=
in this case,
Quoted 1 line
Quoted 1 line
Quoted 1 line
you cannot hardlink between two mounts because the link needs to p=
oint to the
Quoted 1 line
Quoted 1 line
Quoted 1 line
same on disk inode, which is impossible between two different file=
systems. =A0The
Quoted 1 line
Quoted 1 line
Quoted 1 line
same is true for subvolumes, they have their own trees with their =
own inodes and
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
inode numbers, so it's impossible to hardlink between them.
1a) In case it wasn't clear from above, each subvolume has their o=
wn inode
Quoted 1 line
Quoted 1 line
Quoted 1 line
numbers, so you can have the same inode numbers used between two d=
ifferent
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
subvolumes, since they are two different trees.
2) Obviously you can't just rm -rf subvolumes. =A0Because they are=
roots there's
Quoted 1 line
Quoted 1 line
Quoted 1 line
extra metadata to keep track of them, so you have to use one of ou=
r ioctls to
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
delete subvolumes/snapshots.
But permissions and everything else they are the same.
There is one tricky thing. =A0When you create a subvolume, the dir=
ectory inode
Quoted 1 line
Quoted 1 line
Quoted 1 line
that is created in the parent subvolume has the inode number of 25=
6. =A0So if you
Quoted 1 line
Quoted 1 line
Quoted 1 line
have a bunch of subvolumes in the same parent subvolume, you are g=
oing to have a
Quoted 1 line
Quoted 1 line
Quoted 1 line
bunch of directories with the inode number of 256. =A0This is so w=
hen users cd
Quoted 1 line
Quoted 1 line
Quoted 1 line
into a subvolume we can know its a subvolume and do all the normal=
voodoo to
Quoted 1 line
Quoted 1 line
Quoted 1 line
start looking in the subvolumes tree instead of the parent subvolu=
mes tree.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
This is where things go a bit sideways. =A0We had serious problems=
with NFS, but
Quoted 1 line
Quoted 1 line
Quoted 1 line
thankfully NFS gives us a bunch of hooks to get around these probl=
ems.
Quoted 1 line
Quoted 1 line
Quoted 1 line
CIFS/Samba do not, so we will have problems there, not to mention =
any other
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
userspace application that looks at inode numbers.
=3D=3D=3D How do we want subvolumes to work from a user perspectiv=
e? =3D=3D=3D
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
1) Users need to be able to create their own subvolumes. =A0The pe=
rmission
Quoted 1 line
Quoted 1 line
Quoted 1 line
semantics will be absolutely the same as creating directories, so =
I don't think
Quoted 1 line
Quoted 1 line
Quoted 1 line
this is too tricky. =A0We want this because you can only take snap=
shots of
Quoted 1 line
Quoted 1 line
Quoted 1 line
subvolumes, and so it is important that users be able to create th=
eir own
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
discrete snapshottable targets.
2) Users need to be able to snapshot their subvolumes. =A0This is =
basically the
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
same as #1, but it bears repeating.
3) Subvolumes shouldn't need to be specifically mounted. =A0This i=
s also
Quoted 1 line
Quoted 1 line
Quoted 1 line
important, we don't want users to have to go around mounting their=
subvolumes up
Quoted 1 line
Quoted 1 line
Quoted 1 line
manually one-by-one. =A0Today users just cd into subvolumes and it=
works, just
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
like cd'ing into a directory.
=3D=3D=3D Quotas =3D=3D=3D
This is a huge topic in and of itself, but Christoph mentioned wan=
ting to have
Quoted 1 line
Quoted 1 line
Quoted 1 line
an idea of what we wanted to do with it, so I'm putting it here. =A0=
There are
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
really 2 things here
1) Limiting the size of subvolumes. =A0This is really easy for us,=
just create a
Quoted 1 line
Quoted 1 line
Quoted 1 line
subvolume and at creation time set a maximum size it can grow to a=
nd not let it
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
go farther than that. =A0Nice, simple and straightforward.
2) Normal quotas, via the quota tools. =A0This just comes down to =
how do we want
Quoted 1 line
Quoted 1 line
Quoted 1 line
to charge users, do we want to do it per subvolume, or per filesys=
tem. =A0My vote
Quoted 1 line
Quoted 1 line
Quoted 1 line
is per filesystem. =A0Obviously this will make it tricky with snap=
shots, but I
Quoted 1 line
Quoted 1 line
Quoted 1 line
think if we're just charging the diff's between the original volum=
e and the
Quoted 1 line
Quoted 1 line
Quoted 1 line
snapshot to the user then that will be the easiest for people to u=
nderstand,
Quoted 1 line
Quoted 1 line
Quoted 1 line
rather than making a snapshot all of a sudden count the users curr=
ently used
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
quota * 2.
=3D=3D=3D What do we do? =3D=3D=3D
This is where I expect to see the most discussion. =A0Here is what=
I want to do
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
1) Scrap the 256 inode number thing. =A0Instead we'll just put a f=
lag in the inode
Quoted 1 line
Quoted 1 line
Quoted 1 line
to say "Hey, I'm a subvolume" and then we can do all of the approp=
riate magic
Quoted 1 line
Quoted 1 line
Quoted 1 line
that way. =A0This unfortunately will be an incompatible format cha=
nge, but the
Quoted 1 line
Quoted 1 line
Quoted 1 line
sooner we get this adressed the easier it will be in the long run.=
=A0Obviously
Quoted 1 line
Quoted 1 line
Quoted 1 line
when I say format change I mean via the incompat bits we have, so =
old fs's won't
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
be broken and such.
2) Do something like NFS's referral mounts when we cd into a subvo=
lume. =A0Now we
Quoted 1 line
Quoted 1 line
Quoted 1 line
just do dentry trickery, but that doesn't make the boundary betwee=
n subvolumes
Quoted 1 line
Quoted 1 line
Quoted 1 line
clear, so it will confuse people (and samba) when they walk into a=
subvolume and
Quoted 1 line
Quoted 1 line
Quoted 1 line
all of a sudden the inode numbers are the same as in the directory=
behind them.
Quoted 1 line
Quoted 1 line
Quoted 1 line
With doing the referral mount thing, each subvolume appears to be =
its own mount
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
and that way things like NFS and samba will work properly.
I feel like I'm forgetting something here, hopefully somebody will=
point it out.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
=3D=3D=3D Conclusion =3D=3D=3D
There are definitely some wonky things with subvolumes, but I don'=
t think they
Quoted 1 line
Quoted 1 line
Quoted 1 line
are things that cannot be fixed now. =A0Some of these changes will=
require
Quoted 1 line
Quoted 1 line
Quoted 1 line
incompat format changes, but it's either we fix it now, or later o=
n down the
Quoted 1 line
Quoted 1 line
Quoted 1 line
road when BTRFS starts getting used in production really find out =
how many
Quoted 1 line
Quoted 1 line
Quoted 1 line
things our current scheme breaks and then have to do the changes t=
hen. =A0Thanks,
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
So now that I've actually looked at everything, it looks like the s=
emantics are
Quoted 3 lines
Quoted 3 lines
all right for subvolumes
1) readdir - we return the root id in
d_ino, which is unique across=
the fs
Quoted 1 line
Quoted 1 line
2) stat - we return 256 for all subvolumes, because that is their i=
node number
Quoted 1 line
Quoted 1 line
3)
dev_t- we setup an anon super for all volumes, so they all get =
their own
Quoted 5 lines
Quoted 5 lines
dev_t, which is set properly for all of their children, see below[root@test1244 btrfs-test]# stat .
=A0File: `.'
=A0Size: 20 =A0 =A0 =A0 =A0 =A0 =A0 =A0Blocks: 8 =A0 =A0 =A0 =A0 =A0=
IO Block: 4096 =A0 directory
Quoted 2 lines
Quoted 2 lines
Device: 15h/21d Inode: 256 =A0 =A0 =A0 =A0 Links: 1
Access: (0555/dr-xr-xr-x) =A0Uid: ( =A0 =A00/ =A0 =A0root) =A0 Gid:=
( =A0 =A00/ =A0 =A0root)
Quoted 7 lines
Quoted 7 lines
Access: 2010-12-03 15:35:41.931679393 -0500
Modify: 2010-12-03 15:35:20.405679493 -0500
Change: 2010-12-03 15:35:20.405679493 -0500[root@test1244 btrfs-test]# stat foo
=A0File: `foo'
=A0Size: 12 =A0 =A0 =A0 =A0 =A0 =A0 =A0Blocks: 0 =A0 =A0 =A0 =A0 =A0=
IO Block: 4096 =A0 directory
Quoted 2 lines
Quoted 2 lines
Device: 19h/25d Inode: 256 =A0 =A0 =A0 =A0 Links: 1
Access: (0700/drwx------) =A0Uid: ( =A0 =A00/ =A0 =A0root) =A0 Gid:=
( =A0 =A00/ =A0 =A0root)
Quoted 7 lines
Quoted 7 lines
Access: 2010-12-03 15:35:17.501679393 -0500
Modify: 2010-12-03 15:35:59.150680051 -0500
Change: 2010-12-03 15:35:59.150680051 -0500[root@test1244 btrfs-test]# stat foo/foobar
=A0File: `foo/foobar'
=A0Size: 0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Blocks: 0 =A0 =A0 =A0 =A0 =A0=
IO Block: 4096 =A0 regular empty file
Quoted 2 lines
Quoted 2 lines
Device: 19h/25d Inode: 257 =A0 =A0 =A0 =A0 Links: 1
Access: (0644/-rw-r--r--) =A0Uid: ( =A0 =A00/ =A0 =A0root) =A0 Gid:=
( =A0 =A00/ =A0 =A0root)
Quoted 5 lines
Quoted 5 lines
Access: 2010-12-03 15:35:59.150680051 -0500
Modify: 2010-12-03 15:35:59.150680051 -0500
Change: 2010-12-03 15:35:59.150680051 -0500So as far as the user is concerned, everything should come out righ=
t. =A0Obviously
Quoted 1 line
Quoted 1 line
we had to do the NFS trickery still because as far as VFS is concer=
ned the
Quoted 1 line
Quoted 1 line
subvolumes are all on the same mount. =A0So the question is this (a=
nd really this
Quoted 1 line
Quoted 1 line
is directed at Christoph and Bruce and anybody else who may care), =
is this good
Quoted 1 line
Quoted 1 line
enough, or do we want to have a seperate vfsmount for each subvolum=
e? =A0Thanks,
Quoted 5 lines
Quoted 1 line
=20
What are the drawbacks of having a vfsmount for each subvolume? =20
Why (besides having to code it up) are you trying to avoid doing it t=
hat way?
It's the having to code it up that way thing, I'm nothing if not lazy.
Josef
--
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
Quoted 9 lines · Andreas Dilger
Quoted 7 lines · J. Bruce Fields
We're using statfs64.fs_fsid for this; I believe that's both stable across reboots and distinguishes between subvolumes, so that's OK.
(That said, since
fs_fsiddoesn't work for other filesystems, we depend on an explicit check for a filesystem type of "btrfs", which is awful--btrfs won't always be the only filesystem that wants to do this kind of thing, etc.)
Quoted 4 lines
Sigh, I wanted to be able to specify the NFS FSID directly from within the kernel for Lustre many years already. Glad to see that this is moving forward.
Any chance we can add a ->get_fsid(sb, inode) method to
export_operations
(or something simiar), that allows the filesystem to generate an FSID based on the volume and inode that is being exported?
No objection from here.
(Though I don't understand the inode argument--aren't "subvolumes" usually expected to have separate superblocks?)
--b.
Quoted 11 lines
=== What do subvolumes look like? ===
All the user sees are directories. They act like any other directory acts, with a few exceptions
1) You cannot hardlink between subvolumes. This is because subvolumes have their own inode numbers and such, think of them as seperate mounts in this case, you cannot hardlink between two mounts because the link needs to point to the same on disk inode, which is impossible between two different filesystems. The same is true for subvolumes, they have their own trees with their own inodes and inode numbers, so it's impossible to hardlink between them.
which means they act like a different mount point.
Quoted 3 lines
1a) In case it wasn't clear from above, each subvolume has their own inode numbers, so you can have the same inode numbers used between two different subvolumes, since they are two different trees.
which means they act like not just a different mount point, but they also act like beeing a separate superblock.
Quoted 3 lines
2) Obviously you can't just rm -rf subvolumes. Because they are roots there's extra metadata to keep track of them, so you have to use one of our ioctls to delete subvolumes/snapshots.
Again this means they act like a mount point.
Quoted 5 lines
1) Users need to be able to create their own subvolumes. The permission semantics will be absolutely the same as creating directories, so I don't think this is too tricky. We want this because you can only take snapshots of subvolumes, and so it is important that users be able to create their own discrete snapshottable targets.
Not that I'm entirely against this, but instead of just stating they must can you also state the detailed reason? Allowing users to create your subvolumes is a mostly equivalent problem to allowing user mounts, so handling those two under one umbrella makes a lot of sense.
Quoted 10 lines
This is where I expect to see the most discussion. Here is what I want to do
1) Scrap the 256 inode number thing. Instead we'll just put a flag in the inode to say "Hey, I'm a subvolume" and then we can do all of the appropriate magic that way. This unfortunately will be an incompatible format change, but the sooner we get this adressed the easier it will be in the long run. Obviously when I say format change I mean via the incompat bits we have, so old fs's won't be broken and such.
From reading later post in this threads readddir already seems to take
care of this in some way. But is there a chance of collisions between real inode numbers and the ones faked up for the subvolume roots?
Quoted 8 lines
2) Do something like NFS's referral mounts when we cd into a subvolume. Now we just do dentry trickery, but that doesn't make the boundary between subvolumes clear, so it will confuse people (and samba) when they walk into a subvolume and all of a sudden the inode numbers are the same as in the directory behind them. With doing the referral mount thing, each subvolume appears to be its own mount and that way things like NFS and samba will work properly.
I feel like I'm forgetting something here, hopefully somebody will point it out.
The current code requires the automount trigger points to be links, which is something that Chris didn't like at all. But that issue is solved by building upong David Howell's series to replace that follow_link magic with a new d_automount dentry operation. I'd suggest building the new code on top of that.
And most importantly:
3) allocate a different anon dev_t for each subvolume.
One thing that really confuses me is that the the actual root of the subvolume appears directly in the parent namespace. Given that you have your subvolume identifiers that doesn't even seems nessecary.
To me the following scheme seems more useful:
- all subvolumes/snapshots only show up in a virtual below-root directory, similar to how the existing "default" one doesn't sit on the top.
- the entries inside a namespace that are to be automounted have an entry in the filesystem that just marks them as an auto-mount point that redirects to the actual subvolume.
- we still allow mounting subvolumes (and only those) directly from get_sb by specifying the subvolume name.
This is especially important for snapshots, as just having them hang off the filesystem that is to be snapshotted is extremly confusing.
Quoted 3 lines · Dave Chinner
A property of NFS fileshandles is that they must be stable across server reboots. Is this anon
dev_tused as part of the NFS filehandle and if so how can you guarantee that it is stable?
It's just as stable as a real dev_t in the times of hotplug and udev. As long as you don't touch anything including not upgrading the kernel it's remain stable, otherwise it will break. That's why modern nfs-utils default to using the uuid-based filehandle schemes instead of the dev_t based ones. At least that's what I told - I really hope it's using the real UUIDs from the filesystem and not the horrible fsid hack that was once added - for some filesystems like XFS that field does not actually have any relation to the UUID historically. And while we could have changed that it's too late now that nfs was hacked into abusing that field.
Quoted 2 lines · J. Bruce Fields
We're using statfs64.fs_fsid for this; I believe that's both stable across reboots and distinguishes between subvolumes, so that's OK.
It's a field that doesn't have any useful specification and basically contains random garbage that a filesystem put into it. Using it is a very bad idea.
Quoted 5 lines · Christoph Hellwig
Quoted 3 lines · Dave Chinner
A property of NFS fileshandles is that they must be stable across server reboots. Is this anon
dev_tused as part of the NFS filehandle and if so how can you guarantee that it is stable?
Quoted 10 lines
It's just as stable as a real
dev_tin the times of hotplug and udev. As long as you don't touch anything including not upgrading the kernel it's remain stable, otherwise it will break. That's why modern nfs-utils default to using the uuid-based filehandle schemes instead of thedev_tbased ones. At least that's what I told - I really hope it's using the real UUIDs from the filesystem and not the horrible fsid hack that was once added - for some filesystems like XFS that field does not actually have any relation to the UUID historically. And while we could have changed that it's too late now that nfs was hacked into abusing that field.
IIRC, NFS uses the full true uuid for NFSv3 and NFSv4 filehandles, but they won't fit into the NFSv2 32-byte filehandles, so there is an '8-byte fsid' and '4-byte fsid + inode number' workaround for that...
See the mk_fsid() helper in fs/nfsd/nfsfh.h
Cheers
Trond
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
Quoted 7 lines · hch
Quoted 2 lines · J. Bruce Fields
We're using statfs64.fs_fsid for this; I believe that's both stable across reboots and distinguishes between subvolumes, so that's OK.
It's a field that doesn't have any useful specification and basically contains random garbage that a filesystem put into it. Using it is a very bad idea.
I meant the above statement to apply only to btrfs; and nfs-utils is using fs_fsid only in the case where the filesystem type is "btrfs". So I believe the current code does work.
But I agree that constructing filehandles differently based on a strcmp() of the filesystem type is not a sustainable design, to say the least.
--b.
On 2010-12-06, at 09:48, J. Bruce Fields wrote:
Quoted 8 lines · Andreas Dilger
Quoted 3 lines
Any chance we can add a ->get_fsid(sb, inode) method to
export_operations(or something simiar), that allows the filesystem to generate an FSID based on the volume and inode that is being exported?No objection from here.
(Though I don't understand the inode argument--aren't "subvolumes" usually expected to have separate superblocks?)
I thought that if two directories from the same filesystem are both being exported at the same time that they would need to have different FSID values, hence the inode parameter to allow generating an FSID that is a function of both the filesystem (sb) and the directory being exported (inode)?
Cheers, Andreas
Quoted 12 lines · Trond Myklebust
Quoted 10 lines · Christoph Hellwig
It's just as stable as a real
dev_tin the times of hotplug and udev. As long as you don't touch anything including not upgrading the kernel it's remain stable, otherwise it will break. That's why modern nfs-utils default to using the uuid-based filehandle schemes instead of thedev_tbased ones. At least that's what I told - I really hope it's using the real UUIDs from the filesystem and not the horrible fsid hack that was once added - for some filesystems like XFS that field does not actually have any relation to the UUID historically. And while we could have changed that it's too late now that nfs was hacked into abusing that field.
Quoted 5 lines
IIRC, NFS uses the full true uuid for NFSv3 and NFSv4 filehandles, but they won't fit into the NFSv2 32-byte filehandles, so there is an '8-byte fsid' and '4-byte fsid + inode number' workaround for that...
See the
mk_fsid()helper infs/nfsd/nfsfh.h
It looks like mk_fsid() is only actually using the UUID if it is specified in the /etc/exports file (AFAICS, this depends on ex_uuid being set from a uuid="..." option).
There was a patch in the open_by_handle() patch series that added an s_uuid field to the superblock, that could be used if no uuid= option is specified in the /etc/exports file.
Cheers, Andreas
Quoted 14 lines · Andreas Dilger
Quoted 12 lines · Trond Myklebust
Quoted 10 lines · Christoph Hellwig
It's just as stable as a real
dev_tin the times of hotplug and udev. As long as you don't touch anything including not upgrading the kernel it's remain stable, otherwise it will break. That's why modern nfs-utils default to using the uuid-based filehandle schemes instead of thedev_tbased ones. At least that's what I told - I really hope it's using the real UUIDs from the filesystem and not the horrible fsid hack that was once added - for some filesystems like XFS that field does not actually have any relation to the UUID historically. And while we could have changed that it's too late now that nfs was hacked into abusing that field.
Quoted 7 lines
Quoted 5 lines
IIRC, NFS uses the full true uuid for NFSv3 and NFSv4 filehandles, but they won't fit into the NFSv2 32-byte filehandles, so there is an '8-byte fsid' and '4-byte fsid + inode number' workaround for that...
See the
mk_fsid()helper infs/nfsd/nfsfh.hIt looks like
mk_fsid()is only actually using the UUID if it is specified in the/etc/exportsfile (AFAICS, this depends onex_uuidbeing set from a uuid="..." option).
No, if you look at the nfs-utils source you'll find mountd sets a uuid by default (in utils/mountd/cache.c:uuid_by_path()).
Quoted 1 line
There was a patch in the
open_by_handle()patch series that added ans_uuidfield to the superblock, that could be used if no uuid= option is specified in the/etc/exportsfile.
Agreed that doing this in the kernel would probably be simpler.
--b.
Quoted 5 lines · J. Bruce Fields
Quoted 1 line · Andreas Dilger
It looks like
mk_fsid()is only actually using the UUID if it is specified in the/etc/exportsfile (AFAICS, this depends onex_uuidbeing set from a uuid="..." option).No, if you look at the nfs-utils source you'll find mountd sets a uuid by default (in utils/mountd/cache.c:uuid_by_path()).
Unfortunately, this only works for block devices, not network filesystems.
Quoted 3 lines
Quoted 1 line
There was a patch in the
open_by_handle()patch series that added ans_uuidfield to the superblock, that could be used if no uuid= option is specified in the/etc/exportsfile.Agreed that doing this in the kernel would probably be simpler.
Agreed.
Cheers, Andreas
Quoted 10 lines · On Mon, 6 Dec 2010 11:48:45 -0500 "J. Bruce Fields" <[email protected]> wrote:
Quoted 9 lines · Andreas Dilger
Quoted 7 lines · J. Bruce Fields
We're using statfs64.fs_fsid for this; I believe that's both stable across reboots and distinguishes between subvolumes, so that's OK.
(That said, since
fs_fsiddoesn't work for other filesystems, we depend on an explicit check for a filesystem type of "btrfs", which is awful--btrfs won't always be the only filesystem that wants to do this kind of thing, etc.)
Quoted 6 lines
Quoted 4 lines
Sigh, I wanted to be able to specify the NFS FSID directly from within the kernel for Lustre many years already. Glad to see that this is moving forward.
Any chance we can add a ->get_fsid(sb, inode) method to
export_operations
(or something simiar), that allows the filesystem to generate an FSID based on the volume and inode that is being exported?No objection from here.
My standard objection here is that you cannot guarantee that the fsid is 100% guarantied to be unique across all filesystems in the system (including filesystems mounted from dm snapshots of filesystems that are currently mounted). NFSd needs this uniqueness.
This is only really an objection if user-space cannot over-ride the fsid provided by the filesystem.
I'd be very happy to see an interface to user-space whereby user-space can get a reasonably unique fsid for a given filesystem. Whether this is an export_operations method or some field in the 'struct super' which gets copied out doesn't matter to me.
NeilBrown
Quoted 9 lines
(Though I don't understand the inode argument--aren't "subvolumes" usually expected to have separate superblocks?)
--b.
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines · Neil Brown
Quoted 6 lines · On Mon, 6 Dec 2010 11:48:45 -0500 "J. Bruce Fields" <[email protected]> wrote:
Quoted 4 lines · Andreas Dilger
Any chance we can add a ->get_fsid(sb, inode) method to
export_operations(or something simiar), that allows the filesystem to generate an FSID based on the volume and inode that is being exported?
Quoted 6 lines
Quoted 1 line
No objection from here.
My standard objection here is that you cannot guarantee that the fsid is 100% guarantied to be unique across all filesystems in the system (including filesystems mounted from dm snapshots of filesystems that are currently mounted). NFSd needs this uniqueness.
Sure, but you also cannot guarantee that the devno is constant across reboots, yet NFS continues to use this much-less-constant value...
Quoted 2 lines
This is only really an objection if user-space cannot over-ride the fsid provided by the filesystem.
Agreed. It definitely makes sense to allow this, for whatever strange circumstances might arise. However, defaulting to using the filesystem UUID definitely makes the most sense, and looking at the nfs-utils mountd code, it seems that this is already standard behaviour for local block devices (excluding "btrfs" filesystems).
Quoted 3 lines
I'd be very happy to see an interface to user-space whereby user-space can get a reasonably unique fsid for a given filesystem.
Hmm, maybe I'm missing something, but why does userspace need to be able to get this value? I would think that nfsd gets it from the filesystem directly in the kernel, but if a "uuid=" option is present in the exports file that is preferentially used over the value from the filesystem.
That said, I think Aneesh's open_by_handle patchset also made the UUID visible in /proc/<pid>/mountinfo, after the filesystems stored it in sb->s_uuid at mount time. That _should_ make it visible for non-block mountpoints as well, assuming they fill in s_uuid.
Quoted 2 lines
Whether this is an
export_operationsmethod or some field in the 'struct super' which gets copied out doesn't matter to me.
Since Aneesh has already developed patches, is there any objection to using those (last sent to linux-fsdevel on 2010-10-29):
[PATCH -V22 12/14] vfs: Export file system uuid via /proc/<pid>/mountinfo [PATCH -V22 13/14] ext3: Copy fs UUID to superblock.
[PATCH -V22 14/14] ext4: Copy fs UUID to superblock
Cheers, Andreas
Quoted 22 lines · Andreas Dilger
Quoted 9 lines · Neil Brown
Quoted 6 lines · On Mon, 6 Dec 2010 11:48:45 -0500 "J. Bruce Fields" <[email protected]> wrote:
Quoted 4 lines · Andreas Dilger
Any chance we can add a ->get_fsid(sb, inode) method to
export_operations(or something simiar), that allows the filesystem to generate an FSID based on the volume and inode that is being exported?Quoted 6 lines
Quoted 1 line
No objection from here.
My standard objection here is that you cannot guarantee that the fsid is 100% guarantied to be unique across all filesystems in the system (including filesystems mounted from dm snapshots of filesystems that are currently mounted). NFSd needs this uniqueness.
Sure, but you also cannot guarantee that the devno is constant across reboots, yet NFS continues to use this much-less-constant value...
Quoted 2 lines
This is only really an objection if user-space cannot over-ride the fsid provided by the filesystem.
Quoted 7 lines
Agreed. It definitely makes sense to allow this, for whatever strange circumstances might arise. However, defaulting to using the filesystem UUID definitely makes the most sense, and looking at the nfs-utils mountd code, it seems that this is already standard behaviour for local block devices (excluding "btrfs" filesystems).
Quoted 3 lines
I'd be very happy to see an interface to user-space whereby user-space can get a reasonably unique fsid for a given filesystem.
Hmm, maybe I'm missing something, but why does userspace need to be able to get this value? I would think that nfsd gets it from the filesystem directly in the kernel, but if a "uuid=" option is present in the exports file that is preferentially used over the value from the filesystem.
Well, the kernel can't distinguish the case of an explicit "uuid=" option in /etc/exports from one that was (as is the normal default) generated automatically by mountd. Maybe not a big deal.
The uuid seems like a useful thing to have access to from userspace anyway, for userspace nfs servers if for no other reason:
Quoted 11 lines
That said, I think Aneesh's
open_by_handlepatchset also made the UUID visible in /proc/<pid>/mountinfo, after the filesystems stored it insb->s_uuidat mount time. That _should_ make it visible for non-block mountpoints as well, assuming they fill ins_uuid.Quoted 2 lines
Whether this is an
export_operationsmethod or some field in the 'struct super' which gets copied out doesn't matter to me.Since Aneesh has already developed patches, is there any objection to using those (last sent to linux-fsdevel on 2010-10-29):
[PATCH -V22 12/14] vfs: Export file system uuid via /proc/<pid>/mountinfo [PATCH -V22 13/14] ext3: Copy fs UUID to superblock.
[PATCH -V22 14/14] ext4: Copy fs UUID to superblock
I can't see anything wrong with that.
--b.
Am Mittwoch 01 Dezember 2010 schrieb Mike Hommey:
Quoted 2 lines · Chris Mason
Quoted 1 line
Excerpts from C Anthony Risinger's message of 2010-12-01 09:51:55
-0500:
Quoted 1 line
Quoted 1 line
Quoted 1 line
On Wed, Dec 1, 2010 at 8:21 AM, Josef Bacik <[email protected]>
Quoted 13 lines · wrote:
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
=== How do we want subvolumes to work from a user perspective?
===1) Users need to be able to create their own subvolumes. Â The permission semantics will be absolutely the same as creating directories, so I don't think this is too tricky. Â We want this because you can only take snapshots of subvolumes, and so it is important that users be able to create their own discrete snapshottable targets.
2) Users need to be able to snapshot their subvolumes. Â This is basically the same as #1, but it bears repeating.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
could it be possible to convert a directory into a volume? or at least base a snapshot off it?
I'm afraid this turns into the same complexity as creating a new volume and copying all the files/dirs in by hand.
Except you wouldn't have to copy data, only metadata.
And it could probably be race-free. If I'd cp -reflink or rsync stuff from a real directory to a subvolume and then rename the old directory to an other name and the subvolume to the directory name then I might be missing files that have been created during the copy process and missing changes to files that have been already copied.
What I would like is an easy way to make ~/.kde or whatever a subvolume to be able to snapshot it independently while KDE applications or whatever is using and writing to it, *without* any userland even noticing it and without - except for metadata for managing the subvolume - any additional space consumption.
So
deepdance:/#12> btrfs subvolume create /home/martin/.kde
ERROR: '/home/martin/.kde' exists
would just make a subvolume out of ~/.kde even if it needs splitting out the tree or even copying the tree data into a new tree.
There are other filesystem operations like btrfs filesystem balance that can be expensive as well.
All that said from a user point of view. Maybe technical its not feasible. But it would be nice if it can be made feasible without loosing existing advantages.
And maybe
deepdance:/> btrfs subvolume create .
ERROR: '.' exists
should really remain this way ;).
Signature · 2 lines
Martin 'Helios' Steigerwald - http://www.Lichtvoll.de GPG: 03B0 0D6C 0040 0710 4AFA B82F 991B EAAC A599 84C7
Quoted 22 lines · Arne Jansen
Quoted 8 lines · Josef Bacik
1) Scrap the 256 inode number thing. Instead we'll just put a flag in the inode to say "Hey, I'm a subvolume" and then we can do all of the appropriate magic that way. This unfortunately will be an incompatible format change, but the sooner we get this adressed the easier it will be in the long run. Obviously when I say format change I mean via the incompat bits we have, so old fs's won't be broken and such.
Quoted 7 lines
2) Do something like NFS's referral mounts when we cd into a subvolume. Now we just do dentry trickery, but that doesn't make the boundary between subvolumes clear, so it will confuse people (and samba) when they walk into a subvolume and all of a sudden the inode numbers are the same as in the directory behind them. With doing the referral mount thing, each subvolume appears to be its own mount and that way things like NFS and samba will work properly.
What about the alternative and allocating inode numbers globally? The only problem would be with snapshots as they share the inum with the source, but one could just remap inode numbers in snapshots by sparing some bits at the top of this 64 bit field.
Quoted 7 lines
Having one mount per subvolume/snapshots is the cleaner solution, but quickly leads to situations where you have _lots_ of mounts, especially when you export them via NFS and mount it somewhere else. I've seen a machine which had to handle > 100,000 mounts from a zfs server. This definitely brings it's own problems, so I'd love to see a full fs exported as a single mount. This will also keep output from tools like iostat (for nfs mounts) and df readable.
Having a lot of mounts will be a problem when the mount table is exposed directly from the kernel, something that must be done, and is being done in the latest util-linux.
Ian
Quoted 163 lines · Josef Bacik
Quoted 162 lines · Mike Fedyk
Quoted 160 lines · Josef Bacik
Quoted 109 lines · Josef Bacik
Hello,
Various people have complained about how BTRFS deals with subvolumes recently, specifically the fact that they all have the same inode number, and there's no discrete seperation from one subvolume to another. Christoph asked that I lay out a basic design document of how we want subvolumes to work so we can hash everything out now, fix what is broken, and then move forward with a design that everybody is more or less happy with. I apologize in advance for how freaking long this email is going to be. I assume that most people are generally familiar with how BTRFS works, so I'm not going to bother explaining in great detail some stuff.
=== What are subvolumes? ===
They are just another tree. In BTRFS we have various b-trees to describe the filesystem. A few of them are filesystem wide, such as the extent tree, chunk tree, root tree etc. The tree's that hold the actual filesystem data, that is inodes and such, are kept in their own b-tree. This is how subvolumes and snapshots appear on disk, they are simply new b-trees with all of the file data contained within them.
=== What do subvolumes look like? ===
All the user sees are directories. They act like any other directory acts, with a few exceptions
1) You cannot hardlink between subvolumes. This is because subvolumes have their own inode numbers and such, think of them as seperate mounts in this case, you cannot hardlink between two mounts because the link needs to point to the same on disk inode, which is impossible between two different filesystems. The same is true for subvolumes, they have their own trees with their own inodes and inode numbers, so it's impossible to hardlink between them.
1a) In case it wasn't clear from above, each subvolume has their own inode numbers, so you can have the same inode numbers used between two different subvolumes, since they are two different trees.
2) Obviously you can't just rm -rf subvolumes. Because they are roots there's extra metadata to keep track of them, so you have to use one of our ioctls to delete subvolumes/snapshots.
But permissions and everything else they are the same.
There is one tricky thing. When you create a subvolume, the directory inode that is created in the parent subvolume has the inode number of 256. So if you have a bunch of subvolumes in the same parent subvolume, you are going to have a bunch of directories with the inode number of 256. This is so when users cd into a subvolume we can know its a subvolume and do all the normal voodoo to start looking in the subvolumes tree instead of the parent subvolumes tree.
This is where things go a bit sideways. We had serious problems with NFS, but thankfully NFS gives us a bunch of hooks to get around these problems. CIFS/Samba do not, so we will have problems there, not to mention any other userspace application that looks at inode numbers.
=== How do we want subvolumes to work from a user perspective? ===
1) Users need to be able to create their own subvolumes. The permission semantics will be absolutely the same as creating directories, so I don't think this is too tricky. We want this because you can only take snapshots of subvolumes, and so it is important that users be able to create their own discrete snapshottable targets.
2) Users need to be able to snapshot their subvolumes. This is basically the same as #1, but it bears repeating.
3) Subvolumes shouldn't need to be specifically mounted. This is also important, we don't want users to have to go around mounting their subvolumes up manually one-by-one. Today users just cd into subvolumes and it works, just like cd'ing into a directory.
=== Quotas ===
This is a huge topic in and of itself, but Christoph mentioned wanting to have an idea of what we wanted to do with it, so I'm putting it here. There are really 2 things here
1) Limiting the size of subvolumes. This is really easy for us, just create a subvolume and at creation time set a maximum size it can grow to and not let it go farther than that. Nice, simple and straightforward.
2) Normal quotas, via the quota tools. This just comes down to how do we want to charge users, do we want to do it per subvolume, or per filesystem. My vote is per filesystem. Obviously this will make it tricky with snapshots, but I think if we're just charging the diff's between the original volume and the snapshot to the user then that will be the easiest for people to understand, rather than making a snapshot all of a sudden count the users currently used quota * 2.
=== What do we do? ===
This is where I expect to see the most discussion. Here is what I want to do
1) Scrap the 256 inode number thing. Instead we'll just put a flag in the inode to say "Hey, I'm a subvolume" and then we can do all of the appropriate magic that way. This unfortunately will be an incompatible format change, but the sooner we get this adressed the easier it will be in the long run. Obviously when I say format change I mean via the incompat bits we have, so old fs's won't be broken and such.
2) Do something like NFS's referral mounts when we cd into a subvolume. Now we just do dentry trickery, but that doesn't make the boundary between subvolumes clear, so it will confuse people (and samba) when they walk into a subvolume and all of a sudden the inode numbers are the same as in the directory behind them. With doing the referral mount thing, each subvolume appears to be its own mount and that way things like NFS and samba will work properly.
I feel like I'm forgetting something here, hopefully somebody will point it out.
Quoted 8 lines
=== Conclusion ===
There are definitely some wonky things with subvolumes, but I don't think they are things that cannot be fixed now. Some of these changes will require incompat format changes, but it's either we fix it now, or later on down the road when BTRFS starts getting used in production really find out how many things our current scheme breaks and then have to do the changes then. Thanks,
So now that I've actually looked at everything, it looks like the semantics are all right for subvolumes
1) readdir - we return the root id in
d_ino, which is unique across the fs
2) stat - we return 256 for all subvolumes, because that is their inode number
3)dev_t- we setup an anon super for all volumes, so they all get their owndev_t, which is set properly for all of their children, see below[root@test1244 btrfs-test]# stat .
File: `.'
Size: 20 Blocks: 8 IO Block: 4096 directory
Device: 15h/21d Inode: 256 Links: 1
Access: (0555/dr-xr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2010-12-03 15:35:41.931679393 -0500
Modify: 2010-12-03 15:35:20.405679493 -0500
Change: 2010-12-03 15:35:20.405679493 -0500[root@test1244 btrfs-test]# stat foo
File: `foo'
Size: 12 Blocks: 0 IO Block: 4096 directory
Device: 19h/25d Inode: 256 Links: 1
Access: (0700/drwx------) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2010-12-03 15:35:17.501679393 -0500
Modify: 2010-12-03 15:35:59.150680051 -0500
Change: 2010-12-03 15:35:59.150680051 -0500[root@test1244 btrfs-test]# stat foo/foobar
File: `foo/foobar'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 19h/25d Inode: 257 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2010-12-03 15:35:59.150680051 -0500
Modify: 2010-12-03 15:35:59.150680051 -0500
Change: 2010-12-03 15:35:59.150680051 -0500So as far as the user is concerned, everything should come out right. Obviously we had to do the NFS trickery still because as far as VFS is concerned the subvolumes are all on the same mount. So the question is this (and really this is directed at Christoph and Bruce and anybody else who may care), is this good enough, or do we want to have a seperate vfsmount for each subvolume? Thanks,
Quoted 5 lines
Quoted 3 lines
What are the drawbacks of having a vfsmount for each subvolume?
Why (besides having to code it up) are you trying to avoid doing it that way?
It's the having to code it up that way thing, I'm nothing if not lazy.
And, anything that uses the mount table, exposed from the kernel, will grind a system to a halt with only a few thousand mounts, not to mention that user space utilities, like df, du ..., will become painful to use for more than a hundred or so entries.
Quoted 6 lines
Josef
--
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