* root subvol id is 0 or 5? @ 2014-11-30 3:31 Shriramana Sharma 2014-11-30 7:48 ` Goffredo Baroncelli 2014-11-30 11:59 ` Hugo Mills 0 siblings, 2 replies; 8+ messages in thread From: Shriramana Sharma @ 2014-11-30 3:31 UTC (permalink / raw) To: linux-btrfs I am confused with this: should I call it the "root subvol" or "top-level subvol" or "default subvol" or doesn't it matter? Are all subvols equal, or some are more equal than others [hark to Orwell's Animal Farm ;-)]? And more importantly, is the ID of the root subvol 0 or 5? The Oracle guide (https://docs.oracle.com/cd/E37670_01/E37355/html/ol_use_case3_btrfs.html) seems to say it's 0 : "By default, the operating system mounts the parent btrfs volume, which has an ID of 0" but the BtrFS wiki (and btrfs subvol manpage) reads 5: "every btrfs filesystem has a default subvolume as its initially top-level subvolume, whose subvolume id is 5(FS_TREE)." as also the Ubuntu Wiki: "The default subvolume to mount is always the top of the btrfs tree (subvolid=5)." Now this Oracle page http://www.oracle.com/technetwork/articles/servers-storage-admin/advanced-btrfs-1734952.html says: "The only clean way to destroy the default subvolume is to rerun the mkfs.btrfs command, which would destroy existing data." So from what I've (confusedly) understood so far, 0 refers to the superstructure (or whatchamacallit) of the entire BtrFS-based contents of the device(s) and hence cannot be deleted but only reset by a mkfs.btrfs, but 5 is only the default subvol (mounted when the FS as a whole is mounted without subvol spec) provided by mkfs.btrfs, and subvol set-default can have another subvol mounted as default instead, after which 5 can actually be deleted? [confused]... -- Shriramana Sharma ஶ்ரீரமணஶர்மா श्रीरमणशर्मा ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: root subvol id is 0 or 5? 2014-11-30 3:31 root subvol id is 0 or 5? Shriramana Sharma @ 2014-11-30 7:48 ` Goffredo Baroncelli 2014-11-30 11:59 ` Hugo Mills 1 sibling, 0 replies; 8+ messages in thread From: Goffredo Baroncelli @ 2014-11-30 7:48 UTC (permalink / raw) To: Shriramana Sharma, linux-btrfs On 11/30/2014 04:31 AM, Shriramana Sharma wrote: > I am confused with this: should I call it the "root subvol" or > "top-level subvol" or "default subvol" or doesn't it matter? Are all > subvols equal, or some are more equal than others [hark to Orwell's > Animal Farm ;-)]? > > And more importantly, is the ID of the root subvol 0 or 5? IIRC the real ID is 5. But if you pass 0, this value is converted in 5 $ grep BTRFS_FS_TREE_OBJECTID *.h ctree.h:#define BTRFS_FS_TREE_OBJECTID 5ULL [...] And in super.c: [...] case Opt_subvolid: num = match_strdup(&args[0]); if (num) { *subvol_objectid = memparse(num, NULL); kfree(num); /* we want the original fs_tree */ if (!*subvol_objectid) *subvol_objectid = BTRFS_FS_TREE_OBJECTID; [...] -- gpg @keyserver.linux.it: Goffredo Baroncelli <kreijackATinwind.it> Key fingerprint BBF5 1610 0B64 DAC6 5F7D 17B2 0EDA 9B37 8B82 E0B5 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: root subvol id is 0 or 5? 2014-11-30 3:31 root subvol id is 0 or 5? Shriramana Sharma 2014-11-30 7:48 ` Goffredo Baroncelli @ 2014-11-30 11:59 ` Hugo Mills 2014-11-30 13:38 ` Shriramana Sharma 1 sibling, 1 reply; 8+ messages in thread From: Hugo Mills @ 2014-11-30 11:59 UTC (permalink / raw) To: Shriramana Sharma; +Cc: linux-btrfs [-- Attachment #1: Type: text/plain, Size: 2723 bytes --] On Sun, Nov 30, 2014 at 09:01:37AM +0530, Shriramana Sharma wrote: > I am confused with this: should I call it the "root subvol" or > "top-level subvol" or "default subvol" or doesn't it matter? Are all > subvols equal, or some are more equal than others [hark to Orwell's > Animal Farm ;-)]? I try to use "top level" for subvolid=5. "root subvol" is hugely confusing, as it could be one of several things. If you mean the subvol mounted at /, then I call that "/" or "the / subvol". "default subvol" is the one marked as default. This starts out as subvolid=5, but can be set to any other subvol. > And more importantly, is the ID of the root subvol 0 or 5? In the data structures on disk, it's 5. The kernel aliases 0 to mean subvolid 5. > The Oracle guide > (https://docs.oracle.com/cd/E37670_01/E37355/html/ol_use_case3_btrfs.html) > seems to say it's 0 : > > "By default, the operating system mounts the parent btrfs volume, > which has an ID of 0" > > but the BtrFS wiki (and btrfs subvol manpage) reads 5: > > "every btrfs filesystem has a default subvolume as its initially > top-level subvolume, whose subvolume id is 5(FS_TREE)." > > as also the Ubuntu Wiki: > > "The default subvolume to mount is always the top of the btrfs tree > (subvolid=5)." As above, both are correct here. > Now this Oracle page > http://www.oracle.com/technetwork/articles/servers-storage-admin/advanced-btrfs-1734952.html > says: > > "The only clean way to destroy the default subvolume is to rerun the > mkfs.btrfs command, which would destroy existing data." OK, this is actually wrong. It's not the default subvolume if someone's run set-default on the FS. They're correct that you can't delete the top-level subvol. You can't delete the subvol marked as default, either. Assuming (or implying) that the two are the same is just plain wrong. > So from what I've (confusedly) understood so far, 0 refers to the > superstructure (or whatchamacallit) of the entire BtrFS-based contents > of the device(s) and hence cannot be deleted but only reset by a > mkfs.btrfs, but 5 is only the default subvol (mounted when the FS as a > whole is mounted without subvol spec) provided by mkfs.btrfs, and > subvol set-default can have another subvol mounted as default instead, > after which 5 can actually be deleted? You can't delete subvolid=5. It's part of the "fundamental whatchamacallit" of the FS (a good name). Even if you change the default subvol, you still can't delete it. Hugo. -- Hugo Mills | People are too unreliable to be replaced by hugo@... carfax.org.uk | machines. http://carfax.org.uk/ | PGP: 65E74AC0 | Nathan Spring, Star Cops [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: root subvol id is 0 or 5? 2014-11-30 11:59 ` Hugo Mills @ 2014-11-30 13:38 ` Shriramana Sharma 2014-11-30 13:42 ` Shriramana Sharma 2014-11-30 13:53 ` Hugo Mills 0 siblings, 2 replies; 8+ messages in thread From: Shriramana Sharma @ 2014-11-30 13:38 UTC (permalink / raw) To: Hugo Mills, Shriramana Sharma, linux-btrfs [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 484 bytes --] On Sun, Nov 30, 2014 at 5:29 PM, Hugo Mills <hugo@carfax.org.uk> wrote: > > In the data structures on disk, it's 5. The kernel aliases 0 to > mean subvolid 5. So why 5 and not just 0 which seems a logical choice? On top of this, one needs to alias 0 to 5! -- Shriramana Sharma à®¶à¯à®°à¯à®°à®®à®£à®¶à®°à¯à®®à®¾ शà¥à¤°à¥à¤°à¤®à¤£à¤¶à¤°à¥à¤®à¤¾ ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±ý»k~ÏâØ^nr¡ö¦zË\x1aëh¨èÚ&£ûàz¿äz¹Þú+Ê+zf£¢·h§~Ûiÿÿïêÿêçz_è®\x0fæj:+v¨þ)ߣøm ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: root subvol id is 0 or 5? 2014-11-30 13:38 ` Shriramana Sharma @ 2014-11-30 13:42 ` Shriramana Sharma 2015-02-27 16:50 ` David Sterba 2014-11-30 13:53 ` Hugo Mills 1 sibling, 1 reply; 8+ messages in thread From: Shriramana Sharma @ 2014-11-30 13:42 UTC (permalink / raw) To: Hugo Mills, Shriramana Sharma, linux-btrfs [-- Attachment #1: Type: text/plain, Size: 416 bytes --] On Sun, Nov 30, 2014 at 7:08 PM, Shriramana Sharma <samjnaa@gmail.com> wrote: > > So why 5 and not just 0 which seems a logical choice? On top of this, > one needs to alias 0 to 5! Attached patch clarifying this in the documentation. (Should have done this with the previous mail. Sorry for multiple mails.) -- Shriramana Sharma ஶ்ரீரமணஶர்மா श्रीरमणशर्मा [-- Attachment #2: 0002-btrfs-subvolume-doc-clarifications.patch --] [-- Type: text/x-patch, Size: 1332 bytes --] From 54387ff2155423d990b5a9aca95315fe6e649303 Mon Sep 17 00:00:00 2001 From: Shriramana Sharma <samjnaa@gmail.com> Date: Sun, 30 Nov 2014 19:11:39 +0530 Subject: [PATCH 2/2] btrfs subvolume doc clarifications --- Documentation/btrfs-subvolume.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/btrfs-subvolume.txt b/Documentation/btrfs-subvolume.txt index 1360aba..34abdef 100644 --- a/Documentation/btrfs-subvolume.txt +++ b/Documentation/btrfs-subvolume.txt @@ -31,7 +31,7 @@ When `mount`(8) using 'subvol' or 'subvolid' mount option, one can access files/directories/subvolumes inside it, but nothing in parent subvolumes. Also every btrfs filesystem has a default subvolume as its initially top-level -subvolume, whose subvolume id is 5(FS_TREE). +subvolume, whose subvolume id is 5. (0 is also acceptable as an alias.) A btrfs snapshot is much like a subvolume, but shares its data(and metadata) with other subvolume/snapshot. Due to the capabilities of COW, modifications @@ -166,7 +166,7 @@ sleep N seconds between checks (default: 1) EXIT STATUS ----------- -*btrfs subvolume* returns a zero exit status if it succeeds. Non zero is +*btrfs subvolume* returns a zero exit status if it succeeds. A non-zero value is returned in case of failure. AVAILABILITY -- 2.1.3 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: root subvol id is 0 or 5? 2014-11-30 13:42 ` Shriramana Sharma @ 2015-02-27 16:50 ` David Sterba 0 siblings, 0 replies; 8+ messages in thread From: David Sterba @ 2015-02-27 16:50 UTC (permalink / raw) To: Shriramana Sharma; +Cc: Hugo Mills, linux-btrfs On Sun, Nov 30, 2014 at 07:12:46PM +0530, Shriramana Sharma wrote: > On Sun, Nov 30, 2014 at 7:08 PM, Shriramana Sharma <samjnaa@gmail.com> wrote: > > > > So why 5 and not just 0 which seems a logical choice? On top of this, > > one needs to alias 0 to 5! > > Attached patch clarifying this in the documentation. (Should have done > this with the previous mail. Sorry for multiple mails.) > > -- > Shriramana Sharma ஶ்ரீரமணஶர்மா श्रीरमणशर्मा > From 54387ff2155423d990b5a9aca95315fe6e649303 Mon Sep 17 00:00:00 2001 > From: Shriramana Sharma <samjnaa@gmail.com> > Date: Sun, 30 Nov 2014 19:11:39 +0530 > Subject: [PATCH 2/2] btrfs subvolume doc clarifications Applied, thanks. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: root subvol id is 0 or 5? 2014-11-30 13:38 ` Shriramana Sharma 2014-11-30 13:42 ` Shriramana Sharma @ 2014-11-30 13:53 ` Hugo Mills 2014-12-01 3:49 ` Duncan 1 sibling, 1 reply; 8+ messages in thread From: Hugo Mills @ 2014-11-30 13:53 UTC (permalink / raw) To: Shriramana Sharma; +Cc: linux-btrfs [-- Attachment #1: Type: text/plain, Size: 2097 bytes --] On Sun, Nov 30, 2014 at 07:08:51PM +0530, Shriramana Sharma wrote: > On Sun, Nov 30, 2014 at 5:29 PM, Hugo Mills <hugo@carfax.org.uk> wrote: > > > > In the data structures on disk, it's 5. The kernel aliases 0 to > > mean subvolid 5. > > So why 5 and not just 0 which seems a logical choice? On top of this, > one needs to alias 0 to 5! All of the trees used in the FS metadata have an ID number. The "well-known" trees have small, fixed IDs: #define BTRFS_ROOT_TREE_OBJECTID 1ULL #define BTRFS_EXTENT_TREE_OBJECTID 2ULL #define BTRFS_CHUNK_TREE_OBJECTID 3ULL #define BTRFS_DEV_TREE_OBJECTID 4ULL #define BTRFS_FS_TREE_OBJECTID 5ULL #define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL #define BTRFS_CSUM_TREE_OBJECTID 7ULL #define BTRFS_QUOTA_TREE_OBJECTID 8ULL #define BTRFS_UUID_TREE_OBJECTID 9ULL Note that "the" FS tree has ID 5. A subvolume is basically another FS tree. Subvolumes other than the top level are given dynamically- allocated IDs starting from 256. Note also that the root, chunk, device and extent trees are all more important, lower level information than any FS tree, so they logically have lower numbers (and were probably implemented earlier). There's no particular reason that it couldn't have been designed with the initial FS tree as ID 0, but it simply wasn't. However, changing this value now would result in two incompatible versions of btrfs -- neither one would be able to deal with the other's filesystems, because the FS tree has a different ID. (And writing code to cope with both would be painful, disruptive and error-prone.) The cost of fixing this minor nit would, I think, far outweigh any benefits you'd get from it. Hence the "alias" for 0, which is (IIRC) done up-front in the ioctl interface, and therefore has few places that it could go wrong or affect the main code of the FS. Hugo. -- Hugo Mills | "How deep will this sub go?" hugo@... carfax.org.uk | "Oh, she'll go all the way to the bottom if we don't http://carfax.org.uk/ | stop her." PGP: 65E74AC0 | U571 [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: root subvol id is 0 or 5? 2014-11-30 13:53 ` Hugo Mills @ 2014-12-01 3:49 ` Duncan 0 siblings, 0 replies; 8+ messages in thread From: Duncan @ 2014-12-01 3:49 UTC (permalink / raw) To: linux-btrfs Hugo Mills posted on Sun, 30 Nov 2014 13:53:28 +0000 as excerpted: > On Sun, Nov 30, 2014 at 07:08:51PM +0530, Shriramana Sharma wrote: >> On Sun, Nov 30, 2014 at 5:29 PM, Hugo Mills <hugo@carfax.org.uk> wrote: >> > >> > In the data structures on disk, it's 5. The kernel aliases 0 to >> > mean subvolid 5. >> >> So why 5 and not just 0 which seems a logical choice? On top of this, >> one needs to alias 0 to 5! > > All of the trees used in the FS metadata have an ID number. The > "well-known" trees have small, fixed IDs: Thanks, Hugo. You might wish to find a place in the wiki (probably in the FAQ) for that, since your explanation was both the clearest I can imagine and cleared up some lingering "but why?" questions along that line for me, as well. And if an answer to that basic a btrfs question is still clearing stuff up for me, I expect it could be useful to well over 90% of potential btrfs wiki FAQ readers... -- Duncan - List replies preferred. No HTML msgs. "Every nonfree program has a lord, a master -- and if you use the program, he is your master." Richard Stallman ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-02-27 16:50 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-11-30 3:31 root subvol id is 0 or 5? Shriramana Sharma 2014-11-30 7:48 ` Goffredo Baroncelli 2014-11-30 11:59 ` Hugo Mills 2014-11-30 13:38 ` Shriramana Sharma 2014-11-30 13:42 ` Shriramana Sharma 2015-02-27 16:50 ` David Sterba 2014-11-30 13:53 ` Hugo Mills 2014-12-01 3:49 ` Duncan
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.