linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* subvolumes: default and IDs
@ 2012-07-30  7:56 Florian Lindner
  2012-07-30 11:29 ` Calvin Walton
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Florian Lindner @ 2012-07-30  7:56 UTC (permalink / raw)
  To: linux-btrfs

Hey!

I recently starting playing with btrfs and subvolume, but it has left
me puzzled:
Distribution is Archlinux, Kernel is 3.4.6.

>>>
root@horus /mnt # mkfs.btrfs -L test /dev/sdb1

WARNING! - Btrfs Btrfs v0.19 IS EXPERIMENTAL
WARNING! - see http://btrfs.wiki.kernel.org before using

fs created label test on /dev/sdb1
        nodesize 4096 leafsize 4096 sectorsize 4096 size 2.73TB
Btrfs Btrfs v0.19
root@horus /mnt # mount /dev/sdb1 test
root@horus /mnt # cd test
root@horus /mnt/test # btrfs subvolume create sv1
Create subvolume './sv1'
root@horus /mnt/test # btrfs subvolume create sv2
Create subvolume './sv2'
root@horus /mnt/test # touch sv1/sv1.file
root@horus /mnt/test # touch sv2/sv2.file
root@horus /mnt/test # btrfs subvolume get-default .
ID 256 top level 5 path sv1
ID 259 top level 5 path sv2
<<<

What is the default subvolume now? How can I tell?

>>>
root@horus /mnt/test # btrfs subvolume set-default 259 .
root@horus /mnt/test # btrfs subvolume get-default .
ID 256 top level 5 path sv1
ID 259 top level 5 path sv2
<<<

Seems to have changed nothing....?

>>>
root@horus /mnt/test # cd ..
root@horus /mnt # umount test && mount /dev/sdb1 test
root@horus /mnt # ls test
sv2.file
<<<

Ah, sv2 seems to be default, like I had set it.

>>>
root@horus /mnt # btrfs subvolume set-default 5 test
root@horus /mnt # umount test && /mnt # mount /dev/sdb1 test
root@horus /mnt # ls test
sv1/  sv2/
<<<

Ok, 5 seems to be the root subvolume id. Is it always like that? I
remembered to have read somewhere it was 0 ? (which makes a kind of
more sense for me)

>>>
root@horus /mnt # btrfs subvolume set-default 256 test
root@horus /mnt # umount test && mount /dev/sdb1 test
root@horus /mnt # ls test
sv1.file
<<<

Fine! But:

>>>
root@horus /mnt # btrfs subvolume set-default 0 test
root@horus /mnt # umount test && mount /dev/sdb1 test
root@horus /mnt # ls test
sv1.file
<<<

set-default 0 seems to do nothing but does not produce an error
either. What about subvolume 0? Still I can do:

>>>
root@horus /mnt # umount test
root@horus /mnt # mount -o subvolid=0 /dev/sdb1 test
root@horus /mnt # ls test
sv1/  sv2/
<<<

Ok, here 0 as subvolid works. What about subvolid=5?

>>>
root@horus /mnt # umount test
root@horus /mnt # mount -o subvolid=5 /dev/sdb1 test
root@horus /mnt # ls test
sv1/  sv2/
<<<

Works too.

Sorry for the lengthy posting, but writing this posting has puzzled me
even more I was yesterday. I hope someone could shed some light on it.

Thanks!

Florian

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: subvolumes: default and IDs
  2012-07-30  7:56 subvolumes: default and IDs Florian Lindner
@ 2012-07-30 11:29 ` Calvin Walton
  2012-07-30 12:43   ` Swâmi Petaramesh
  2012-07-30 12:18 ` Liu Bo
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Calvin Walton @ 2012-07-30 11:29 UTC (permalink / raw)
  To: Florian Lindner; +Cc: linux-btrfs

On Mon, 2012-07-30 at 09:56 +0200, Florian Lindner wrote:
> Hey!
> 
> I recently starting playing with btrfs and subvolume, but it has left
> me puzzled:

> root@horus /mnt/test # btrfs subvolume get-default .
> ID 256 top level 5 path sv1
> ID 259 top level 5 path sv2
> <<<
> 
> What is the default subvolume now? How can I tell?

It looks like there's currently a bug in btrfs-progs - the 'get-default'
command is actually doing a 'list' instead of printing the default. With
any luck it's just a little error in the command-line parsing and should
be easy to fix...

> >>>
> root@horus /mnt # btrfs subvolume set-default 5 test
> root@horus /mnt # umount test && /mnt # mount /dev/sdb1 test
> root@horus /mnt # ls test
> sv1/  sv2/
> <<<
> 
> Ok, 5 seems to be the root subvolume id. Is it always like that? I
> remembered to have read somewhere it was 0 ? (which makes a kind of
> more sense for me)

The internal ID of the root subvolume is 5, yes. I don't know whether
this is a current implementation detail and subject to change, or if it
will permanently stay that way. I *think* it's part of the disk format,
and it permanent.

In either case, the subvol id '0' is treated as an alias for 'the
original root subvolume', and the two can be used interchangeably in the
mount command. I always find '0' just a bit easier to remember :)

> >>>
> root@horus /mnt # btrfs subvolume set-default 0 test
> root@horus /mnt # umount test && mount /dev/sdb1 test
> root@horus /mnt # ls test
> sv1.file
> <<<
> 
> set-default 0 seems to do nothing but does not produce an error
> either.

Looks like you've found another bug (or maybe just a missing feature);
it would be nice if this command allows you to use '0' as an alias for
the root subvolume.

-- 
Calvin Walton <calvin.walton@kepstin.ca>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: subvolumes: default and IDs
  2012-07-30  7:56 subvolumes: default and IDs Florian Lindner
  2012-07-30 11:29 ` Calvin Walton
@ 2012-07-30 12:18 ` Liu Bo
  2012-07-31  0:28 ` Alexander Karbstein
  2012-07-31  0:50 ` Alexander Karbstein
  3 siblings, 0 replies; 11+ messages in thread
From: Liu Bo @ 2012-07-30 12:18 UTC (permalink / raw)
  To: Florian Lindner; +Cc: linux-btrfs

On 07/30/2012 03:56 PM, Florian Lindner wrote:
> Hey!
>
> I recently starting playing with btrfs and subvolume, but it has left
> me puzzled:
> Distribution is Archlinux, Kernel is 3.4.6.
>
>>>>
> root@horus /mnt # mkfs.btrfs -L test /dev/sdb1
>
> WARNING! - Btrfs Btrfs v0.19 IS EXPERIMENTAL
> WARNING! - see http://btrfs.wiki.kernel.org before using
>
> fs created label test on /dev/sdb1
>          nodesize 4096 leafsize 4096 sectorsize 4096 size 2.73TB
> Btrfs Btrfs v0.19
> root@horus /mnt # mount /dev/sdb1 test
> root@horus /mnt # cd test
> root@horus /mnt/test # btrfs subvolume create sv1
> Create subvolume './sv1'
> root@horus /mnt/test # btrfs subvolume create sv2
> Create subvolume './sv2'
> root@horus /mnt/test # touch sv1/sv1.file
> root@horus /mnt/test # touch sv2/sv2.file
> root@horus /mnt/test # btrfs subvolume get-default .
> ID 256 top level 5 path sv1
> ID 259 top level 5 path sv2
> <<<
>
> What is the default subvolume now? How can I tell?
>
>>>>
> root@horus /mnt/test # btrfs subvolume set-default 259 .
> root@horus /mnt/test # btrfs subvolume get-default .
> ID 256 top level 5 path sv1
> ID 259 top level 5 path sv2
> <<<
>
> Seems to have changed nothing....?
>
>>>>
> root@horus /mnt/test # cd ..
> root@horus /mnt # umount test && mount /dev/sdb1 test
> root@horus /mnt # ls test
> sv2.file
> <<<
>
> Ah, sv2 seems to be default, like I had set it.
>
>>>>
> root@horus /mnt # btrfs subvolume set-default 5 test
> root@horus /mnt # umount test && /mnt # mount /dev/sdb1 test
> root@horus /mnt # ls test
> sv1/  sv2/
> <<<
>
> Ok, 5 seems to be the root subvolume id. Is it always like that? I
> remembered to have read somewhere it was 0 ? (which makes a kind of
> more sense for me)
>
>>>>
> root@horus /mnt # btrfs subvolume set-default 256 test
> root@horus /mnt # umount test && mount /dev/sdb1 test
> root@horus /mnt # ls test
> sv1.file
> <<<
>
> Fine! But:
>
>>>>
> root@horus /mnt # btrfs subvolume set-default 0 test
> root@horus /mnt # umount test && mount /dev/sdb1 test
> root@horus /mnt # ls test
> sv1.file
> <<<
>
> set-default 0 seems to do nothing but does not produce an error
> either. What about subvolume 0? Still I can do:
>
>>>>
> root@horus /mnt # umount test
> root@horus /mnt # mount -o subvolid=0 /dev/sdb1 test
> root@horus /mnt # ls test
> sv1/  sv2/
> <<<
>
> Ok, here 0 as subvolid works. What about subvolid=5?
>
>>>>
> root@horus /mnt # umount test
> root@horus /mnt # mount -o subvolid=5 /dev/sdb1 test
> root@horus /mnt # ls test
> sv1/  sv2/
> <<<
>
> Works too.
>
> Sorry for the lengthy posting, but writing this posting has puzzled me
> even more I was yesterday. I hope someone could shed some light on it.
>

Hi Florian,

Thanks for reporting these!

They are old bugs that had been fixed recently in latest btrfs progs,
you can checkout the latest btrfs-progs from
git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs.git

subvolid=0 will be translated to subvolid=5 since 5 indicates btrfs' fs 
tree (the root subvolume as you mentioned)

thanks,
liubo

> Thanks!
>
> Florian
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: subvolumes: default and IDs
  2012-07-30 11:29 ` Calvin Walton
@ 2012-07-30 12:43   ` Swâmi Petaramesh
  0 siblings, 0 replies; 11+ messages in thread
From: Swâmi Petaramesh @ 2012-07-30 12:43 UTC (permalink / raw)
  To: Calvin Walton; +Cc: Florian Lindner, linux-btrfs

Le 30/07/2012 13:29, Calvin Walton a écrit :
> It looks like there's currently a bug in btrfs-progs - the 'get-default'
> command is actually doing a 'list' instead of printing the default. With
> any luck it's just a little error in the command-line parsing and should
> be easy to fix...

I've fallen upon this one as well.

That's typically the kind of bug that makes one wonder to what extent
the software has ever been tested, and doubt it's anything close to
production quality... :-/

-- 
Swâmi Petaramesh <swami@petaramesh.org> http://petaramesh.org PGP 9076E32E


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: subvolumes: default and IDs
  2012-07-30  7:56 subvolumes: default and IDs Florian Lindner
  2012-07-30 11:29 ` Calvin Walton
  2012-07-30 12:18 ` Liu Bo
@ 2012-07-31  0:28 ` Alexander Karbstein
  2012-07-31  0:50 ` Alexander Karbstein
  3 siblings, 0 replies; 11+ messages in thread
From: Alexander Karbstein @ 2012-07-31  0:28 UTC (permalink / raw)
  To: linux-btrfs

Hi Florian,

in case you would like to have some code references, to better
understand how it works:
1. Why is the default subvolid=5?
The trees in Btrfs all are referenced in the root tree by their
OBJECTIDs. You can find the definitions("magic numbers") for the
"main" trees in ctree.h:
For example, the main FS tree (you have one FS tree per subvolume) is
defined like this:
#define BTRFS_FS_TREE_OBJECTID 5ULL
==> subvolid=5

2. Why can I mount with -o subvolid=0 succesfully, albeit the default
FS tree has subvolid=5?
Have a look at: linux/fs/btrfs/super.c
In early mount options parser: btrfs_parse_early_options
Snippet:
         case Opt_subvolid:
                        intarg = 0;
                        error = match_int(&args[0], &intarg);
                        if (!error) {
                                /* we want the original fs_tree */
/*Here is the trick ==> */              if (!intarg)
                                        *subvol_objectid =
                                           BTRFS_FS_TREE_OBJECTID;
                                else
                                        *subvol_objectid = intarg;
                        }
                        break;
==> So, if intarg is still 0 after the match_int line, it will use
BTRFS_FS_TREE_OBJECTID (which we know from 1. being 5ULL) when
mounting.

Best Regards,
Alex

2012/7/30 Florian Lindner <mailinglists@xgm.de>:
> Hey!
>
> I recently starting playing with btrfs and subvolume, but it has left
> me puzzled:
> Distribution is Archlinux, Kernel is 3.4.6.
>
>>>>
> root@horus /mnt # mkfs.btrfs -L test /dev/sdb1
>
> WARNING! - Btrfs Btrfs v0.19 IS EXPERIMENTAL
> WARNING! - see http://btrfs.wiki.kernel.org before using
>
> fs created label test on /dev/sdb1
>         nodesize 4096 leafsize 4096 sectorsize 4096 size 2.73TB
> Btrfs Btrfs v0.19
> root@horus /mnt # mount /dev/sdb1 test
> root@horus /mnt # cd test
> root@horus /mnt/test # btrfs subvolume create sv1
> Create subvolume './sv1'
> root@horus /mnt/test # btrfs subvolume create sv2
> Create subvolume './sv2'
> root@horus /mnt/test # touch sv1/sv1.file
> root@horus /mnt/test # touch sv2/sv2.file
> root@horus /mnt/test # btrfs subvolume get-default .
> ID 256 top level 5 path sv1
> ID 259 top level 5 path sv2
> <<<
>
> What is the default subvolume now? How can I tell?
>
>>>>
> root@horus /mnt/test # btrfs subvolume set-default 259 .
> root@horus /mnt/test # btrfs subvolume get-default .
> ID 256 top level 5 path sv1
> ID 259 top level 5 path sv2
> <<<
>
> Seems to have changed nothing....?
>
>>>>
> root@horus /mnt/test # cd ..
> root@horus /mnt # umount test && mount /dev/sdb1 test
> root@horus /mnt # ls test
> sv2.file
> <<<
>
> Ah, sv2 seems to be default, like I had set it.
>
>>>>
> root@horus /mnt # btrfs subvolume set-default 5 test
> root@horus /mnt # umount test && /mnt # mount /dev/sdb1 test
> root@horus /mnt # ls test
> sv1/  sv2/
> <<<
>
> Ok, 5 seems to be the root subvolume id. Is it always like that? I
> remembered to have read somewhere it was 0 ? (which makes a kind of
> more sense for me)
>
>>>>
> root@horus /mnt # btrfs subvolume set-default 256 test
> root@horus /mnt # umount test && mount /dev/sdb1 test
> root@horus /mnt # ls test
> sv1.file
> <<<
>
> Fine! But:
>
>>>>
> root@horus /mnt # btrfs subvolume set-default 0 test
> root@horus /mnt # umount test && mount /dev/sdb1 test
> root@horus /mnt # ls test
> sv1.file
> <<<
>
> set-default 0 seems to do nothing but does not produce an error
> either. What about subvolume 0? Still I can do:
>
>>>>
> root@horus /mnt # umount test
> root@horus /mnt # mount -o subvolid=0 /dev/sdb1 test
> root@horus /mnt # ls test
> sv1/  sv2/
> <<<
>
> Ok, here 0 as subvolid works. What about subvolid=5?
>
>>>>
> root@horus /mnt # umount test
> root@horus /mnt # mount -o subvolid=5 /dev/sdb1 test
> root@horus /mnt # ls test
> sv1/  sv2/
> <<<
>
> Works too.
>
> Sorry for the lengthy posting, but writing this posting has puzzled me
> even more I was yesterday. I hope someone could shed some light on it.
>
> Thanks!
>
> Florian
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: subvolumes: default and IDs
  2012-07-30  7:56 subvolumes: default and IDs Florian Lindner
                   ` (2 preceding siblings ...)
  2012-07-31  0:28 ` Alexander Karbstein
@ 2012-07-31  0:50 ` Alexander Karbstein
  2012-07-31  0:53   ` [PATCH] Btrfs-progs: Enabled setting root subvolume with subvolid=0 Alexander Karbstein
  3 siblings, 1 reply; 11+ messages in thread
From: Alexander Karbstein @ 2012-07-31  0:50 UTC (permalink / raw)
  To: linux-btrfs

Hi everybody,

I believe Florian came across some odd behaviour of btrfs subvolume
set-default which might still not be perfect in the current btrfs-progs: It
does not seem to change the default subvolume to the original root fs tree
if he does "btrfs subvolume set-default 0 /path/to/fs".

I am referring to this mail of Chris Mason where he said "btrfs subvolume
set-default 0 /path" should set the default subvolume to the original root
tree:
http://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg04567.html
either this was not implemented, yet, or I just didn't find it.

So to answer Florians third question, and to provide a patch for discussion:
3. Why does btrfs subvolume set-default 0 /path/to/fs seemingly not change
the default subvol?
It goes like this:
3.1 Btrfs-progs:
btrfs subvolume set-default 0 /path/to/fs lands in:
do_set_default_subvol
and
ret = ioctl(fd, BTRFS_IOC_DEFAULT_SUBVOL, &objectid);
then sends the subvolid=0 to the kernel ioctl.

3.2 Kernel fs/btrfs:
ioctl.c reveals the function to look at:
long btrfs_ioctl(struct file *file, unsigned int
                cmd, unsigned long arg)
...
        case BTRFS_IOC_DEFAULT_SUBVOL:
                return btrfs_ioctl_default_subvol(file, argp);
...
=> static long btrfs_ioctl_default_subvol(struct file *file, void __user
*argp)
Here we got this:
        u64 objectid = 0;
...

       /* argp is the the pointer to the "0" supplied from btrfs subvolume
set-default 0 ... */
       if (copy_from_user(&objectid, argp, sizeof(objectid)))
                return -EFAULT;

    /* as objectid now is 0, we use the current mounted subvolumes (FS
tree) objectid */
        if (!objectid)
                objectid = root->root_key.objectid;

==> So, btrfs subvolume set-default 0 /path/to/fs does in fact change the
default subvolume, if the currently mounted subvolume is not the current
default-subvolume. In Florian's example the subvolume seemingly did't
change because he alway had the current default-subvolume mounted.

IMHO, when following the principle of least surprise calling "btrfs
subvolume set-default 0 /path/to/fs" should always change the default
subvolume to be the "root" subvolume. This would actually establish the
same behaviour as the automatic translation from 0ULL to 5ULL in mount -o
subvolid=0.

This can be done either in the kernel code(fs/btrfs/ioctl.c), by just
exchanging:
        if (!objectid)
-                objectid = root->root_key.objectid;
+                objectid = BTRFS_FS_TREE_OBJECTID;

Or in btrfs-tools, which I would prefer. I am gonna send a patch against
the integration branch of btrfs-progs for discussion shortly.

Best Regards,
Alex

2012/7/30 Florian Lindner <mailinglists@xgm.de>
>
> Hey!
>
> I recently starting playing with btrfs and subvolume, but it has left
> me puzzled:
> Distribution is Archlinux, Kernel is 3.4.6.
>
> >>>
> root@horus /mnt # mkfs.btrfs -L test /dev/sdb1
>
> WARNING! - Btrfs Btrfs v0.19 IS EXPERIMENTAL
> WARNING! - see http://btrfs.wiki.kernel.org before using
>
> fs created label test on /dev/sdb1
>         nodesize 4096 leafsize 4096 sectorsize 4096 size 2.73TB
> Btrfs Btrfs v0.19
> root@horus /mnt # mount /dev/sdb1 test
> root@horus /mnt # cd test
> root@horus /mnt/test # btrfs subvolume create sv1
> Create subvolume './sv1'
> root@horus /mnt/test # btrfs subvolume create sv2
> Create subvolume './sv2'
> root@horus /mnt/test # touch sv1/sv1.file
> root@horus /mnt/test # touch sv2/sv2.file
> root@horus /mnt/test # btrfs subvolume get-default .
> ID 256 top level 5 path sv1
> ID 259 top level 5 path sv2
> <<<
>
> What is the default subvolume now? How can I tell?
>
> >>>
> root@horus /mnt/test # btrfs subvolume set-default 259 .
> root@horus /mnt/test # btrfs subvolume get-default .
> ID 256 top level 5 path sv1
> ID 259 top level 5 path sv2
> <<<
>
> Seems to have changed nothing....?
>
> >>>
> root@horus /mnt/test # cd ..
> root@horus /mnt # umount test && mount /dev/sdb1 test
> root@horus /mnt # ls test
> sv2.file
> <<<
>
> Ah, sv2 seems to be default, like I had set it.
>
> >>>
> root@horus /mnt # btrfs subvolume set-default 5 test
> root@horus /mnt # umount test && /mnt # mount /dev/sdb1 test
> root@horus /mnt # ls test
> sv1/  sv2/
> <<<
>
> Ok, 5 seems to be the root subvolume id. Is it always like that? I
> remembered to have read somewhere it was 0 ? (which makes a kind of
> more sense for me)
>
> >>>
> root@horus /mnt # btrfs subvolume set-default 256 test
> root@horus /mnt # umount test && mount /dev/sdb1 test
> root@horus /mnt # ls test
> sv1.file
> <<<
>
> Fine! But:
>
> >>>
> root@horus /mnt # btrfs subvolume set-default 0 test
> root@horus /mnt # umount test && mount /dev/sdb1 test
> root@horus /mnt # ls test
> sv1.file
> <<<
>
> set-default 0 seems to do nothing but does not produce an error
> either. What about subvolume 0? Still I can do:
>
> >>>
> root@horus /mnt # umount test
> root@horus /mnt # mount -o subvolid=0 /dev/sdb1 test
> root@horus /mnt # ls test
> sv1/  sv2/
> <<<
>
> Ok, here 0 as subvolid works. What about subvolid=5?
>
> >>>
> root@horus /mnt # umount test
> root@horus /mnt # mount -o subvolid=5 /dev/sdb1 test
> root@horus /mnt # ls test
> sv1/  sv2/
> <<<
>
> Works too.
>
> Sorry for the lengthy posting, but writing this posting has puzzled me
> even more I was yesterday. I hope someone could shed some light on it.
>
> Thanks!
>
> Florian
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH] Btrfs-progs: Enabled setting root subvolume with subvolid=0
  2012-07-31  0:50 ` Alexander Karbstein
@ 2012-07-31  0:53   ` Alexander Karbstein
  2012-07-31  1:26     ` Liu Bo
  0 siblings, 1 reply; 11+ messages in thread
From: Alexander Karbstein @ 2012-07-31  0:53 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Alexander Karbstein

The command btrfs subvolume set-default 0 /path/to/fs changed the
default subvolume to whatever subvolume was currently mounted on
/path/to/fs. This patch changes this behaviour to set the default
subvolume to BTRFS_FS_TREE_OBJECTID in case the user asks for
subvolid=0

Signed-off-by: Alexander Karbstein <alexander.karbstein@gmail.com>
---
 btrfs_cmds.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/btrfs_cmds.c b/btrfs_cmds.c
index f2b6355..699d9b0 100644
--- a/btrfs_cmds.c
+++ b/btrfs_cmds.c
@@ -964,6 +964,11 @@ int do_set_default_subvol(int nargs, char **argv)
 		fprintf(stderr, "ERROR: invalid tree id (%s)\n",subvolid);
 		return 30;
 	}
+	
+	/* Using the original root fs tree */
+	if (objectid == 0ULL) {
+		objectid = BTRFS_FS_TREE_OBJECTID;
+	}
 	ret = ioctl(fd, BTRFS_IOC_DEFAULT_SUBVOL, &objectid);
 	e = errno;
 	close(fd);
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] Btrfs-progs: Enabled setting root subvolume with subvolid=0
  2012-07-31  0:53   ` [PATCH] Btrfs-progs: Enabled setting root subvolume with subvolid=0 Alexander Karbstein
@ 2012-07-31  1:26     ` Liu Bo
  2012-07-31  2:09       ` Alexander Karbstein
                         ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Liu Bo @ 2012-07-31  1:26 UTC (permalink / raw)
  To: Alexander Karbstein; +Cc: linux-btrfs

On 07/31/2012 08:53 AM, Alexander Karbstein wrote:

> The command btrfs subvolume set-default 0 /path/to/fs changed the
> default subvolume to whatever subvolume was currently mounted on
> /path/to/fs. This patch changes this behaviour to set the default
> subvolume to BTRFS_FS_TREE_OBJECTID in case the user asks for
> subvolid=0
> 

> Signed-off-by: Alexander Karbstein <alexander.karbstein@gmail.com>
> ---
>  btrfs_cmds.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/btrfs_cmds.c b/btrfs_cmds.c
> index f2b6355..699d9b0 100644
> --- a/btrfs_cmds.c
> +++ b/btrfs_cmds.c
> @@ -964,6 +964,11 @@ int do_set_default_subvol(int nargs, char **argv)
>  		fprintf(stderr, "ERROR: invalid tree id (%s)\n",subvolid);
>  		return 30;
>  	}
> +	
> +	/* Using the original root fs tree */
> +	if (objectid == 0ULL) {
> +		objectid = BTRFS_FS_TREE_OBJECTID;
> +	}
>  	ret = ioctl(fd, BTRFS_IOC_DEFAULT_SUBVOL, &objectid);
>  	e = errno;
>  	close(fd);


Seems that you're using an old btrfs-prog source code, now the file is cmds-subvolume.c

And also checkpatch.pl complains about style errors while checking this.

thanks,
liubo

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Btrfs-progs: Enabled setting root subvolume with subvolid=0
  2012-07-31  1:26     ` Liu Bo
@ 2012-07-31  2:09       ` Alexander Karbstein
  2012-07-31 17:11       ` [PATCH V2] " Alexander Karbstein
  2012-07-31 17:11       ` Alexander Karbstein
  2 siblings, 0 replies; 11+ messages in thread
From: Alexander Karbstein @ 2012-07-31  2:09 UTC (permalink / raw)
  To: Liu Bo; +Cc: linux-btrfs

Hello Liu,

thanks, you are so right. I just got it exactly the wrong way (I read
btrfs-progs-unstable and thought this must be the bleeding edge one
;-). I should have read your e-Mail before.
I will revise it asap. But I have to let it wait for tomorrow... Gotta
sleep now.

Best Regards,
Alex


2012/7/31 Liu Bo <liubo2009@cn.fujitsu.com>:
> On 07/31/2012 08:53 AM, Alexander Karbstein wrote:
>
>> The command btrfs subvolume set-default 0 /path/to/fs changed the
>> default subvolume to whatever subvolume was currently mounted on
>> /path/to/fs. This patch changes this behaviour to set the default
>> subvolume to BTRFS_FS_TREE_OBJECTID in case the user asks for
>> subvolid=0
>>
>
>> Signed-off-by: Alexander Karbstein <alexander.karbstein@gmail.com>
>> ---
>>  btrfs_cmds.c |    5 +++++
>>  1 files changed, 5 insertions(+), 0 deletions(-)
>>
>> diff --git a/btrfs_cmds.c b/btrfs_cmds.c
>> index f2b6355..699d9b0 100644
>> --- a/btrfs_cmds.c
>> +++ b/btrfs_cmds.c
>> @@ -964,6 +964,11 @@ int do_set_default_subvol(int nargs, char **argv)
>>               fprintf(stderr, "ERROR: invalid tree id (%s)\n",subvolid);
>>               return 30;
>>       }
>> +
>> +     /* Using the original root fs tree */
>> +     if (objectid == 0ULL) {
>> +             objectid = BTRFS_FS_TREE_OBJECTID;
>> +     }
>>       ret = ioctl(fd, BTRFS_IOC_DEFAULT_SUBVOL, &objectid);
>>       e = errno;
>>       close(fd);
>
>
> Seems that you're using an old btrfs-prog source code, now the file is cmds-subvolume.c
>
> And also checkpatch.pl complains about style errors while checking this.
>
> thanks,
> liubo

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH V2] Btrfs-progs: Enabled setting root subvolume with subvolid=0
  2012-07-31  1:26     ` Liu Bo
  2012-07-31  2:09       ` Alexander Karbstein
@ 2012-07-31 17:11       ` Alexander Karbstein
  2012-07-31 17:11       ` Alexander Karbstein
  2 siblings, 0 replies; 11+ messages in thread
From: Alexander Karbstein @ 2012-07-31 17:11 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Alexander Karbstein

Hello everybody,

here is my revised patch free from checkpatch warnings and based on the right
git tree.

Alexander Karbstein (1):
  Btrfs-progs: Enabled setting root subvolume with subvolid=0

 cmds-subvolume.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

-- 
1.7.2.5


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH V2] Btrfs-progs: Enabled setting root subvolume with subvolid=0
  2012-07-31  1:26     ` Liu Bo
  2012-07-31  2:09       ` Alexander Karbstein
  2012-07-31 17:11       ` [PATCH V2] " Alexander Karbstein
@ 2012-07-31 17:11       ` Alexander Karbstein
  2 siblings, 0 replies; 11+ messages in thread
From: Alexander Karbstein @ 2012-07-31 17:11 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Alexander Karbstein

The command btrfs subvolume set-default 0 /path/to/fs changed the
default subvolume to whatever subvolume was currently mounted on
/path/to/fs. This patch changes this behaviour to set the default
subvolume to BTRFS_FS_TREE_OBJECTID in case the user asks for
subvolid=0

Signed-off-by: Alexander Karbstein <alexander.karbstein@gmail.com>
---
 cmds-subvolume.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index 3508ce6..8f8c918 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -25,6 +25,7 @@
 #include <limits.h>
 
 #include "kerncompat.h"
+#include "ctree.h"
 #include "ioctl.h"
 
 #include "commands.h"
@@ -464,6 +465,9 @@ static int cmd_subvol_set_default(int argc, char **argv)
 		fprintf(stderr, "ERROR: invalid tree id (%s)\n",subvolid);
 		return 30;
 	}
+	/* Using the original root fs tree */
+	if (objectid == 0ULL)
+		objectid = BTRFS_FS_TREE_OBJECTID;
 	ret = ioctl(fd, BTRFS_IOC_DEFAULT_SUBVOL, &objectid);
 	e = errno;
 	close(fd);
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-07-31 17:20 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-30  7:56 subvolumes: default and IDs Florian Lindner
2012-07-30 11:29 ` Calvin Walton
2012-07-30 12:43   ` Swâmi Petaramesh
2012-07-30 12:18 ` Liu Bo
2012-07-31  0:28 ` Alexander Karbstein
2012-07-31  0:50 ` Alexander Karbstein
2012-07-31  0:53   ` [PATCH] Btrfs-progs: Enabled setting root subvolume with subvolid=0 Alexander Karbstein
2012-07-31  1:26     ` Liu Bo
2012-07-31  2:09       ` Alexander Karbstein
2012-07-31 17:11       ` [PATCH V2] " Alexander Karbstein
2012-07-31 17:11       ` Alexander Karbstein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).