aboutsummaryrefslogtreecommitdiffstats
path: root/cmds-subvolume.c
diff options
context:
space:
mode:
authorZhao Lei <zhaolei@cn.fujitsu.com>2015-08-26 22:03:36 +0800
committerDavid Sterba <dsterba@suse.com>2015-09-01 14:02:48 +0200
commit6425752ab29d86594ad1d2411b7efeb74b62d48d (patch)
tree994926da3db6a18ce8399d48d3d78a574ea92784 /cmds-subvolume.c
parent9a99d2b683c23cbfb21df0557fa185b36e9e8540 (diff)
downloadbtrfs-progs-6425752ab29d86594ad1d2411b7efeb74b62d48d.tar.gz
btrfs-progs-6425752ab29d86594ad1d2411b7efeb74b62d48d.tar.xz
btrfs-progs-6425752ab29d86594ad1d2411b7efeb74b62d48d.zip
btrfs-progs: Fix infinite loop of btrfs subvolumn sync
We can trigger the bug by following operation: (no wait between commands 3~5) btrfs subvolume create /mnt/btrfs/mysubvol btrfs subvolume snapshot /mnt/btrfs/mysubvol /mnt/btrfs/mysubvol_snap btrfs subvolume delete /mnt/btrfs/mysubvol_snap btrfs subvolume delete /mnt/btrfs/mysubvol btrfs subvolume sync /mnt/btrfs The last command will not exit. Reason: List of "deleted subvolumes" are not currectly set. It caused by a typo of value assign, in detail: *ids[idx] = sh->offset; should be: (*ids)[idx] = sh->offset; So only first element is set to right memory address. If there are multiple "deleted subvolumes", program will keep wait. Above typo also caused some segment fault in my test. This patch fixed above bug. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'cmds-subvolume.c')
-rw-r--r--cmds-subvolume.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index 4258ea1..fd4de84 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -1201,7 +1201,7 @@ static int enumerate_dead_subvols(int fd, int count, u64 **ids)
off += sizeof(*sh);
if (sh->type == BTRFS_ORPHAN_ITEM_KEY) {
- *ids[idx] = sh->offset;
+ (*ids)[idx] = sh->offset;
idx++;
if (idx >= count) {
u64 *newids;