mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-09 02:31:19 +00:00
btrfs-progs: close all fs_devices before exit in some commands
mkfs creates more than one fs_devices in fs_uuids. 1: one is for file system being created 2: others are created in test_dev_for_mkfs in order to check mount point test_dev_for_mkfs()-> ... -> btrfs_scan_one_device() Current code only closes 1, and this patch also closes in case 2. Similar problem exist in other tools, eg.:: cmd-check.c: the function is: cmd_check()->check_mounted()-> ... -> btrfs_scan_one_device() ... Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
b0f760c91a
commit
ec1fc69d39
@ -9588,6 +9588,7 @@ out:
|
||||
free_root_recs_tree(&root_cache);
|
||||
close_out:
|
||||
close_ctree(root);
|
||||
btrfs_close_all_devices();
|
||||
err_out:
|
||||
return ret;
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "ctree.h"
|
||||
#include "ioctl.h"
|
||||
#include "utils.h"
|
||||
#include "volumes.h"
|
||||
#include "cmds-fi-usage.h"
|
||||
|
||||
#include "commands.h"
|
||||
@ -140,6 +141,7 @@ static int cmd_device_add(int argc, char **argv)
|
||||
|
||||
error_out:
|
||||
close_file_or_dir(fdmnt, dirstream);
|
||||
btrfs_close_all_devices();
|
||||
return !!ret;
|
||||
}
|
||||
|
||||
@ -290,6 +292,7 @@ static int cmd_device_scan(int argc, char **argv)
|
||||
}
|
||||
|
||||
out:
|
||||
btrfs_close_all_devices();
|
||||
return !!ret;
|
||||
}
|
||||
|
||||
@ -467,6 +470,7 @@ static int cmd_device_stats(int argc, char **argv)
|
||||
out:
|
||||
free(di_args);
|
||||
close_file_or_dir(fdmnt, dirstream);
|
||||
btrfs_close_all_devices();
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -330,6 +330,7 @@ static int cmd_replace_start(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
close_file_or_dir(fdmnt, dirstream);
|
||||
btrfs_close_all_devices();
|
||||
return 0;
|
||||
|
||||
leave_with_error:
|
||||
@ -339,6 +340,7 @@ leave_with_error:
|
||||
close(fdmnt);
|
||||
if (fddstdev != -1)
|
||||
close(fddstdev);
|
||||
btrfs_close_all_devices();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user