Fix missing entries in listing of subvolumes
authorLi Zefan <lizf@cn.fujitsu.com>
Wed, 15 Dec 2010 03:33:33 +0000 (03:33 +0000)
committerChris Mason <chris.mason@oracle.com>
Wed, 2 Nov 2011 15:36:30 +0000 (11:36 -0400)
Stephane Chazelas <stephane.chazelas@gmail.com> writes:
> I've got a btrfs FS with 84 subvolumes in it (some created with
> "btrfs sub create", some with "btrfs sub snap" of the other
> ones). There's no nesting of subvolumes at all (all direct children
> of the root subvolume).
>
> The "btrfs subvolume list" is only showing 80 subvolumes. The 4
> missing ones (1 original volume, 3 snapshots) do exist on disk and
> files in there have different st_devs from any other subvolume.
>
> I found
> http://thread.gmane.org/gmane.comp.file-systems.btrfs/8123/focus=8208
>
> which looks like the same issue, with Li Zefan saying he had a
> fix, but I couldn't find any mention that it was actually fixed.

Li Zefan <lizf@cn.fujitsu.com> replied:
> After that, I posted a patch to fix btrfs-progs, which Chris aggreed
> on:
>
> http://marc.info/?l=linux-btrfs&m=129238454714319&w=2

So this btrfs-progs patch should fix missing subvolumes in the output of
"subvolume list":

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
btrfs-list.c

index bd0df9e..5751f1d 100644 (file)
@@ -636,7 +636,10 @@ static int __list_subvol_search(int fd, struct root_lookup *root_lookup)
                /* this iteration is done, step forward one root for the next
                 * ioctl
                 */
-               if (sk->min_objectid < (u64)-1) {
+               if (sk->min_type < BTRFS_ROOT_BACKREF_KEY) {
+                       sk->min_type = BTRFS_ROOT_BACKREF_KEY;
+                       sk->min_offset = 0;
+               } else  if (sk->min_objectid < (u64)-1) {
                        sk->min_objectid++;
                        sk->min_type = BTRFS_ROOT_BACKREF_KEY;
                        sk->min_offset = 0;