mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-23 15:35:18 +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);
|
free_root_recs_tree(&root_cache);
|
||||||
close_out:
|
close_out:
|
||||||
close_ctree(root);
|
close_ctree(root);
|
||||||
|
btrfs_close_all_devices();
|
||||||
err_out:
|
err_out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "ctree.h"
|
#include "ctree.h"
|
||||||
#include "ioctl.h"
|
#include "ioctl.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "volumes.h"
|
||||||
#include "cmds-fi-usage.h"
|
#include "cmds-fi-usage.h"
|
||||||
|
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
@ -140,6 +141,7 @@ static int cmd_device_add(int argc, char **argv)
|
|||||||
|
|
||||||
error_out:
|
error_out:
|
||||||
close_file_or_dir(fdmnt, dirstream);
|
close_file_or_dir(fdmnt, dirstream);
|
||||||
|
btrfs_close_all_devices();
|
||||||
return !!ret;
|
return !!ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,6 +292,7 @@ static int cmd_device_scan(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
btrfs_close_all_devices();
|
||||||
return !!ret;
|
return !!ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,6 +470,7 @@ static int cmd_device_stats(int argc, char **argv)
|
|||||||
out:
|
out:
|
||||||
free(di_args);
|
free(di_args);
|
||||||
close_file_or_dir(fdmnt, dirstream);
|
close_file_or_dir(fdmnt, dirstream);
|
||||||
|
btrfs_close_all_devices();
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -330,6 +330,7 @@ static int cmd_replace_start(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
close_file_or_dir(fdmnt, dirstream);
|
close_file_or_dir(fdmnt, dirstream);
|
||||||
|
btrfs_close_all_devices();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
leave_with_error:
|
leave_with_error:
|
||||||
@ -339,6 +340,7 @@ leave_with_error:
|
|||||||
close(fdmnt);
|
close(fdmnt);
|
||||||
if (fddstdev != -1)
|
if (fddstdev != -1)
|
||||||
close(fddstdev);
|
close(fddstdev);
|
||||||
|
btrfs_close_all_devices();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user