Skip to contentSkip to conversation

btrfs-progs: cleanup and preparatory around device scan

PATCH Superseded Anand Jain 3 participants 22 messages Jun 8, 2023 – Jun 11, 2023 Btrfs file system

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Anand Jain

author
#0 lore raw

v2 cover btrfs-progs: cleanup and preparatory around device scan

v2: I have separated preparatory and cleanups from the introduction of new
features so that they can be easily modified with a smaller set of patches.

Added missing git changelogs. (Looks like sshfs lost my last few changes, now fixed).

In an attempt to enable btrfstune to accept multiple devices from the command line, this patch includes some cleanup around the related preparatory work around the device scan code.

Patches 1 to 5 primarily consist of cleanups. Patches 6 and 7 serve as preparatory changes.

Anand Jain (7):
btrfs-progs: check_mounted_where: declare is_btrfs as bool
btrfs-progs: check_mounted_where: pack varibles type by size
btrfs-progs: rename struct open_ctree_flags to open_ctree_args
btrfs-progs: device_list_add: optimize arguments drop devid
btrfs-progs: btrfs_scan_one_device: drop local variable ret
btrfs-progs: factor out btrfs_scan_stdin_devices
btrfs-progs: refactor check_where_mounted with noscan argument

 btrfs-find-root.c        |  2 +-
 check/main.c             |  2 +-
 cmds/filesystem.c        |  2 +-
 cmds/inspect-dump-tree.c | 39 ++++-----------------------------------
 cmds/rescue.c            |  4 ++--
 cmds/restore.c           |  2 +-
 common/device-scan.c     | 39 +++++++++++++++++++++++++++++++++++++++
 common/device-scan.h     |  1 +
 common/open-utils.c      | 21 ++++++++++++---------
 common/open-utils.h      |  3 ++-
 common/utils.c           |  3 ++-
 image/main.c             |  4 ++--
 kernel-shared/disk-io.c  |  8 ++++----
 kernel-shared/disk-io.h  |  4 ++--
 kernel-shared/volumes.c  | 14 +++++---------
 mkfs/main.c              |  2 +-
 tune/main.c              |  2 +-
 17 files changed, 81 insertions(+), 71 deletions(-)
Signature · 1 line
2.38.1
author
#1 lore raw

PATCH v2 1/7 btrfs-progs: check_mounted_where: declare is_btrfs as bool

The variable 'is_btrfs' is declared as an integer but could be a boolean instead.

---
 common/open-utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/open-utils.c +1 -1
index d4fdb2b01c7f..01d747d8ac43 100644
@@ -57,7 +57,7 @@ int check_mounted_where(int fd, const char *file, char *where, int size,
 {
 	int ret;
 	u64 total_devs = 1;
-	int is_btrfs;
+	bool is_btrfs;
 	struct btrfs_fs_devices *fs_devices_mnt = NULL;
 	FILE *f;
 	struct mntent *mnt;
Signature · 1 line
2.38.1
Reviewed-by on v2 1/7
#2 lore raw

Re: [PATCH 1/7] btrfs-progs: check_mounted_where: declare is_btrfs as bool

Quoted 4 lines · Anand Jain

The variable 'is_btrfs' is declared as an integer but could be a boolean instead.

Thanks,
Qu

Quoted 17 lines
---
  common/open-utils.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
common/open-utils.c +1 -1
index d4fdb2b01c7f..01d747d8ac43 100644
@@ -57,7 +57,7 @@ int check_mounted_where(int fd, const char *file, char *where, int size,
  {
  	int ret;
  	u64 total_devs = 1;
-	int is_btrfs;
+	bool is_btrfs;
  	struct btrfs_fs_devices *fs_devices_mnt = NULL;
  	FILE *f;
  	struct mntent *mnt;
author
#3 lore raw

PATCH v2 2/7 btrfs-progs: check_mounted_where: pack varibles type by size

In reply to Anand Jain

Pack variables by their type; it may save some space. Also, fixes a line indentation.

---
 common/open-utils.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
common/open-utils.c +6 -6
index 01d747d8ac43..1e18fa905b51 100644
@@ -55,16 +55,16 @@ static int blk_file_in_dev_list(struct btrfs_fs_devices* fs_devices,
 int check_mounted_where(int fd, const char *file, char *where, int size,
 			struct btrfs_fs_devices **fs_dev_ret, unsigned sbflags)
 {
-	int ret;
-	u64 total_devs = 1;
-	bool is_btrfs;
 	struct btrfs_fs_devices *fs_devices_mnt = NULL;
-	FILE *f;
 	struct mntent *mnt;
+	u64 total_devs = 1;
+	FILE *f;
+	int ret;
+	bool is_btrfs;
 
 	/* scan the initial device */
-	ret = btrfs_scan_one_device(fd, file, &fs_devices_mnt,
-		    &total_devs, BTRFS_SUPER_INFO_OFFSET, sbflags);
+	ret = btrfs_scan_one_device(fd, file, &fs_devices_mnt, &total_devs,
+				    BTRFS_SUPER_INFO_OFFSET, sbflags);
 	is_btrfs = (ret >= 0);
 
 	/* scan other devices */
Signature · 1 line
2.38.1
Reviewed-by on v2 2/7
#4 lore raw

Re: [PATCH 2/7] btrfs-progs: check_mounted_where: pack varibles type by size

Quoted 4 lines · Anand Jain

Pack variables by their type; it may save some space. Also, fixes a line indentation.

Thanks,
Qu

Quoted 31 lines
---
  common/open-utils.c | 12 ++++++------
  1 file changed, 6 insertions(+), 6 deletions(-)
common/open-utils.c +6 -6
index 01d747d8ac43..1e18fa905b51 100644
@@ -55,16 +55,16 @@ static int blk_file_in_dev_list(struct btrfs_fs_devices* fs_devices,
  int check_mounted_where(int fd, const char *file, char *where, int size,
  			struct btrfs_fs_devices **fs_dev_ret, unsigned sbflags)
  {
-	int ret;
-	u64 total_devs = 1;
-	bool is_btrfs;
  	struct btrfs_fs_devices *fs_devices_mnt = NULL;
-	FILE *f;
  	struct mntent *mnt;
+	u64 total_devs = 1;
+	FILE *f;
+	int ret;
+	bool is_btrfs;
 
  	/* scan the initial device */
-	ret = btrfs_scan_one_device(fd, file, &fs_devices_mnt,
-		    &total_devs, BTRFS_SUPER_INFO_OFFSET, sbflags);
+	ret = btrfs_scan_one_device(fd, file, &fs_devices_mnt, &total_devs,
+				    BTRFS_SUPER_INFO_OFFSET, sbflags);
  	is_btrfs = (ret >= 0);
 
  	/* scan other devices */
#5 lore raw

Re: [PATCH 2/7] btrfs-progs: check_mounted_where: pack varibles type by size

In reply to Anand Jain
Quoted 1 line · Anand Jain

Pack variables by their type; it may save some space.

AFAIK compiler does not stick to the order defined in the sources on stack and is free to reorder variables or completely optimize them out so I don't see point in doing such changes.

Quoted 2 lines

Also, fixes a line
indentation.

And we don't want whitespace-only patches unless it's something that really annoys us. Argument formatting is mixed and as long as it's readable it should not be changed. Acceptable styles are one or two tabs or align under the openeing ( .

author
#6 lore raw

Re: [PATCH 2/7] btrfs-progs: check_mounted_where: pack varibles type by size

Quoted 7 lines · David Sterba
Quoted 1 line · Anand Jain

Pack variables by their type; it may save some space.

AFAIK compiler does not stick to the order defined in the sources on stack and is free to reorder variables or completely optimize them out so I don't see point in doing such changes.

Oh. I don't see any point in packing them.

Quoted 7 lines
Quoted 2 lines

Also, fixes a line
indentation.

And we don't want whitespace-only patches unless it's something that really annoys us. Argument formatting is mixed and as long as it's readable it should not be changed. Acceptable styles are one or two tabs or align under the openeing ( .

Got it.

I will drop this patch in the next reroll.

Thanks.

author
#7 lore raw

PATCH v2 3/7 btrfs-progs: rename struct open_ctree_flags to open_ctree_args

In reply to Anand Jain

The struct open_ctree_flags currently holds arguments for open_ctree_fs_info(), it can be confusing when mixed with a local variable named open_ctree_flags as below in the function cmd_inspect_dump_tree().

	cmd_inspect_dump_tree()
	::
	struct open_ctree_flags ocf = { 0 };
	::
	unsigned open_ctree_flags;

So rename struct open_ctree_flags to struct open_ctree_args.

---
 btrfs-find-root.c        | 2 +-
 check/main.c             | 2 +-
 cmds/filesystem.c        | 2 +-
 cmds/inspect-dump-tree.c | 2 +-
 cmds/rescue.c            | 4 ++--
 cmds/restore.c           | 2 +-
 image/main.c             | 4 ++--
 kernel-shared/disk-io.c  | 8 ++++----
 kernel-shared/disk-io.h  | 4 ++--
 mkfs/main.c              | 2 +-
 10 files changed, 16 insertions(+), 16 deletions(-)
btrfs-find-root.c +1 -1
index 398d7f216ee7..52041d82c182 100644
@@ -335,7 +335,7 @@ int main(int argc, char **argv)
 	struct btrfs_find_root_filter filter = {0};
 	struct cache_tree result;
 	struct cache_extent *found;
-	struct open_ctree_flags ocf = { 0 };
+	struct open_ctree_args ocf = { 0 };
 	int ret;
 
 	/* Default to search root tree */
check/main.c +1 -1
index 7542b49f44f5..f7a2d446370a 100644
@@ -9983,7 +9983,7 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
 {
 	struct cache_tree root_cache;
 	struct btrfs_root *root;
-	struct open_ctree_flags ocf = { 0 };
+	struct open_ctree_args ocf = { 0 };
 	u64 bytenr = 0;
 	u64 subvolid = 0;
 	u64 tree_root_bytenr = 0;
cmds/filesystem.c +1 -1
index 47fd2377f5f4..c9e641b2fa9a 100644
@@ -636,7 +636,7 @@ static int map_seed_devices(struct list_head *all_uuids)
 	fs_uuids = btrfs_scanned_uuids();
 
 	list_for_each_entry(cur_fs, all_uuids, list) {
-		struct open_ctree_flags ocf = { 0 };
+		struct open_ctree_args ocf = { 0 };
 
 		device = list_first_entry(&cur_fs->devices,
 						struct btrfs_device, dev_list);
cmds/inspect-dump-tree.c +1 -1
index bfc0fff148dd..35920d14b7e9 100644
@@ -317,7 +317,7 @@ static int cmd_inspect_dump_tree(const struct cmd_struct *cmd,
 	struct btrfs_disk_key disk_key;
 	struct btrfs_key found_key;
 	struct cache_tree block_root;	/* for multiple --block parameters */
-	struct open_ctree_flags ocf = { 0 };
+	struct open_ctree_args ocf = { 0 };
 	char uuidbuf[BTRFS_UUID_UNPARSED_SIZE];
 	int ret = 0;
 	int slot;
cmds/rescue.c +2 -2
index 5551374d4b75..aee5446e66d0 100644
@@ -233,7 +233,7 @@ static int cmd_rescue_fix_device_size(const struct cmd_struct *cmd,
 				      int argc, char **argv)
 {
 	struct btrfs_fs_info *fs_info;
-	struct open_ctree_flags ocf = { 0 };
+	struct open_ctree_args ocf = { 0 };
 	char *devname;
 	int ret;
 
@@ -368,7 +368,7 @@ static int cmd_rescue_clear_uuid_tree(const struct cmd_struct *cmd,
 				      int argc, char **argv)
 {
 	struct btrfs_fs_info *fs_info;
-	struct open_ctree_flags ocf = {};
+	struct open_ctree_args ocf = {};
 	char *devname;
 	int ret;
 
cmds/restore.c +1 -1
index 9fe7b4d2d07d..aa78d0799c4a 100644
@@ -1216,7 +1216,7 @@ static struct btrfs_root *open_fs(const char *dev, u64 root_location,
 {
 	struct btrfs_fs_info *fs_info = NULL;
 	struct btrfs_root *root = NULL;
-	struct open_ctree_flags ocf = { 0 };
+	struct open_ctree_args ocf = { 0 };
 	u64 bytenr;
 	int i;
 
image/main.c +2 -2
index 50c3f2ca7db5..9e460e7076e7 100644
@@ -2795,7 +2795,7 @@ static int restore_metadump(const char *input, FILE *out, int old_restore,
 
 	/* NOTE: open with write mode */
 	if (fixup_offset) {
-		struct open_ctree_flags ocf = { 0 };
+		struct open_ctree_args ocf = { 0 };
 
 		ocf.filename = target;
 		ocf.flags = OPEN_CTREE_WRITES | OPEN_CTREE_RESTORE |
@@ -3223,7 +3223,7 @@ int BOX_MAIN(image)(int argc, char *argv[])
 
 	 /* extended support for multiple devices */
 	if (!create && multi_devices) {
-		struct open_ctree_flags ocf = { 0 };
+		struct open_ctree_args ocf = { 0 };
 		struct btrfs_fs_info *info;
 		u64 total_devs;
 		int i;
kernel-shared/disk-io.c +4 -4
index 442d3af8bc01..3b709b2c0f7f 100644
@@ -1437,7 +1437,7 @@ int btrfs_setup_chunk_tree_and_device_map(struct btrfs_fs_info *fs_info,
 	return 0;
 }
 
-static struct btrfs_fs_info *__open_ctree_fd(int fp, struct open_ctree_flags *ocf)
+static struct btrfs_fs_info *__open_ctree_fd(int fp, struct open_ctree_args *ocf)
 {
 	struct btrfs_fs_info *fs_info;
 	struct btrfs_super_block *disk_super;
@@ -1608,7 +1608,7 @@ out:
 	return NULL;
 }
 
-struct btrfs_fs_info *open_ctree_fs_info(struct open_ctree_flags *ocf)
+struct btrfs_fs_info *open_ctree_fs_info(struct open_ctree_args *ocf)
 {
 	int fp;
 	int ret;
@@ -1646,7 +1646,7 @@ struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr,
 			      unsigned flags)
 {
 	struct btrfs_fs_info *info;
-	struct open_ctree_flags ocf = { 0 };
+	struct open_ctree_args ocf = { 0 };
 
 	/* This flags may not return fs_info with any valid root */
 	BUG_ON(flags & OPEN_CTREE_IGNORE_CHUNK_TREE_ERROR);
@@ -1665,7 +1665,7 @@ struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
 				 unsigned flags)
 {
 	struct btrfs_fs_info *info;
-	struct open_ctree_flags ocf = { 0 };
+	struct open_ctree_args ocf = { 0 };
 
 	/* This flags may not return fs_info with any valid root */
 	if (flags & OPEN_CTREE_IGNORE_CHUNK_TREE_ERROR) {
kernel-shared/disk-io.h +2 -2
index 3a31667967cc..93572c4297ad 100644
@@ -175,7 +175,7 @@ struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr,
 			      unsigned flags);
 struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
 				 unsigned flags);
-struct open_ctree_flags {
+struct open_ctree_args {
 	const char *filename;
 	u64 sb_bytenr;
 	u64 root_tree_bytenr;
@@ -183,7 +183,7 @@ struct open_ctree_flags {
 	unsigned flags;
 };
 
-struct btrfs_fs_info *open_ctree_fs_info(struct open_ctree_flags *ocf);
+struct btrfs_fs_info *open_ctree_fs_info(struct open_ctree_args *ctree_args);
 int close_ctree_fs_info(struct btrfs_fs_info *fs_info);
 static inline int close_ctree(struct btrfs_root *root)
 {
mkfs/main.c +1 -1
index a31b32c644c9..23db58b7186d 100644
@@ -990,7 +990,7 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
 	struct btrfs_root *root;
 	struct btrfs_fs_info *fs_info;
 	struct btrfs_trans_handle *trans;
-	struct open_ctree_flags ocf = { 0 };
+	struct open_ctree_args ocf = { 0 };
 	int ret = 0;
 	int close_ret;
 	int i;
Signature · 1 line
2.38.1
#8 lore raw

Re: [PATCH 3/7] btrfs-progs: rename struct open_ctree_flags to open_ctree_args

Quoted 11 lines · Anand Jain

The struct open_ctree_flags currently holds arguments for open_ctree_fs_info(), it can be confusing when mixed with a local variable named open_ctree_flags as below in the function cmd_inspect_dump_tree().

	cmd_inspect_dump_tree()
	::
	struct open_ctree_flags ocf = { 0 };
	::
	unsigned open_ctree_flags;

So rename struct open_ctree_flags to struct open_ctree_args.

I don't think this is a big deal.

Any LSP server and compiler can handle it correct.

Furthermore the rename would make a lot of @ocf variables loses its meaning. (The patch doesn't rename it to oca).

To me, the better solution would be remove local variable open_ctree_flags completely, and do all the flags setting using ocf.flags instead.

Thanks,
Qu

Quoted 199 lines
---
  btrfs-find-root.c        | 2 +-
  check/main.c             | 2 +-
  cmds/filesystem.c        | 2 +-
  cmds/inspect-dump-tree.c | 2 +-
  cmds/rescue.c            | 4 ++--
  cmds/restore.c           | 2 +-
  image/main.c             | 4 ++--
  kernel-shared/disk-io.c  | 8 ++++----
  kernel-shared/disk-io.h  | 4 ++--
  mkfs/main.c              | 2 +-
  10 files changed, 16 insertions(+), 16 deletions(-)
btrfs-find-root.c +1 -1
index 398d7f216ee7..52041d82c182 100644
@@ -335,7 +335,7 @@ int main(int argc, char **argv)
  	struct btrfs_find_root_filter filter = {0};
  	struct cache_tree result;
  	struct cache_extent *found;
-	struct open_ctree_flags ocf = { 0 };
+	struct open_ctree_args ocf = { 0 };
  	int ret;
 
  	/* Default to search root tree */
check/main.c +1 -1
index 7542b49f44f5..f7a2d446370a 100644
@@ -9983,7 +9983,7 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
  {
  	struct cache_tree root_cache;
  	struct btrfs_root *root;
-	struct open_ctree_flags ocf = { 0 };
+	struct open_ctree_args ocf = { 0 };
  	u64 bytenr = 0;
  	u64 subvolid = 0;
  	u64 tree_root_bytenr = 0;
cmds/filesystem.c +1 -1
index 47fd2377f5f4..c9e641b2fa9a 100644
@@ -636,7 +636,7 @@ static int map_seed_devices(struct list_head *all_uuids)
  	fs_uuids = btrfs_scanned_uuids();
 
  	list_for_each_entry(cur_fs, all_uuids, list) {
-		struct open_ctree_flags ocf = { 0 };
+		struct open_ctree_args ocf = { 0 };
 
  		device = list_first_entry(&cur_fs->devices,
  						struct btrfs_device, dev_list);
cmds/inspect-dump-tree.c +1 -1
index bfc0fff148dd..35920d14b7e9 100644
@@ -317,7 +317,7 @@ static int cmd_inspect_dump_tree(const struct cmd_struct *cmd,
  	struct btrfs_disk_key disk_key;
  	struct btrfs_key found_key;
  	struct cache_tree block_root;	/* for multiple --block parameters */
-	struct open_ctree_flags ocf = { 0 };
+	struct open_ctree_args ocf = { 0 };
  	char uuidbuf[BTRFS_UUID_UNPARSED_SIZE];
  	int ret = 0;
  	int slot;
cmds/rescue.c +2 -2
index 5551374d4b75..aee5446e66d0 100644
@@ -233,7 +233,7 @@ static int cmd_rescue_fix_device_size(const struct cmd_struct *cmd,
  				      int argc, char **argv)
  {
  	struct btrfs_fs_info *fs_info;
-	struct open_ctree_flags ocf = { 0 };
+	struct open_ctree_args ocf = { 0 };
  	char *devname;
  	int ret;
 
@@ -368,7 +368,7 @@ static int cmd_rescue_clear_uuid_tree(const struct cmd_struct *cmd,
  				      int argc, char **argv)
  {
  	struct btrfs_fs_info *fs_info;
-	struct open_ctree_flags ocf = {};
+	struct open_ctree_args ocf = {};
  	char *devname;
  	int ret;
 
cmds/restore.c +1 -1
index 9fe7b4d2d07d..aa78d0799c4a 100644
@@ -1216,7 +1216,7 @@ static struct btrfs_root *open_fs(const char *dev, u64 root_location,
  {
  	struct btrfs_fs_info *fs_info = NULL;
  	struct btrfs_root *root = NULL;
-	struct open_ctree_flags ocf = { 0 };
+	struct open_ctree_args ocf = { 0 };
  	u64 bytenr;
  	int i;
 
image/main.c +2 -2
index 50c3f2ca7db5..9e460e7076e7 100644
@@ -2795,7 +2795,7 @@ static int restore_metadump(const char *input, FILE *out, int old_restore,
 
  	/* NOTE: open with write mode */
  	if (fixup_offset) {
-		struct open_ctree_flags ocf = { 0 };
+		struct open_ctree_args ocf = { 0 };
 
  		ocf.filename = target;
  		ocf.flags = OPEN_CTREE_WRITES | OPEN_CTREE_RESTORE |
@@ -3223,7 +3223,7 @@ int BOX_MAIN(image)(int argc, char *argv[])
 
  	 /* extended support for multiple devices */
  	if (!create && multi_devices) {
-		struct open_ctree_flags ocf = { 0 };
+		struct open_ctree_args ocf = { 0 };
  		struct btrfs_fs_info *info;
  		u64 total_devs;
  		int i;
kernel-shared/disk-io.c +4 -4
index 442d3af8bc01..3b709b2c0f7f 100644
@@ -1437,7 +1437,7 @@ int btrfs_setup_chunk_tree_and_device_map(struct btrfs_fs_info *fs_info,
  	return 0;
  }
 
-static struct btrfs_fs_info *__open_ctree_fd(int fp, struct open_ctree_flags *ocf)
+static struct btrfs_fs_info *__open_ctree_fd(int fp, struct open_ctree_args *ocf)
  {
  	struct btrfs_fs_info *fs_info;
  	struct btrfs_super_block *disk_super;
@@ -1608,7 +1608,7 @@ out:
  	return NULL;
  }
 
-struct btrfs_fs_info *open_ctree_fs_info(struct open_ctree_flags *ocf)
+struct btrfs_fs_info *open_ctree_fs_info(struct open_ctree_args *ocf)
  {
  	int fp;
  	int ret;
@@ -1646,7 +1646,7 @@ struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr,
  			      unsigned flags)
  {
  	struct btrfs_fs_info *info;
-	struct open_ctree_flags ocf = { 0 };
+	struct open_ctree_args ocf = { 0 };
 
  	/* This flags may not return fs_info with any valid root */
  	BUG_ON(flags & OPEN_CTREE_IGNORE_CHUNK_TREE_ERROR);
@@ -1665,7 +1665,7 @@ struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
  				 unsigned flags)
  {
  	struct btrfs_fs_info *info;
-	struct open_ctree_flags ocf = { 0 };
+	struct open_ctree_args ocf = { 0 };
 
  	/* This flags may not return fs_info with any valid root */
  	if (flags & OPEN_CTREE_IGNORE_CHUNK_TREE_ERROR) {
kernel-shared/disk-io.h +2 -2
index 3a31667967cc..93572c4297ad 100644
@@ -175,7 +175,7 @@ struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr,
  			      unsigned flags);
  struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
  				 unsigned flags);
-struct open_ctree_flags {
+struct open_ctree_args {
  	const char *filename;
  	u64 sb_bytenr;
  	u64 root_tree_bytenr;
@@ -183,7 +183,7 @@ struct open_ctree_flags {
  	unsigned flags;
  };
 
-struct btrfs_fs_info *open_ctree_fs_info(struct open_ctree_flags *ocf);
+struct btrfs_fs_info *open_ctree_fs_info(struct open_ctree_args *ctree_args);
  int close_ctree_fs_info(struct btrfs_fs_info *fs_info);
  static inline int close_ctree(struct btrfs_root *root)
  {
mkfs/main.c +1 -1
index a31b32c644c9..23db58b7186d 100644
@@ -990,7 +990,7 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
  	struct btrfs_root *root;
  	struct btrfs_fs_info *fs_info;
  	struct btrfs_trans_handle *trans;
-	struct open_ctree_flags ocf = { 0 };
+	struct open_ctree_args ocf = { 0 };
  	int ret = 0;
  	int close_ret;
  	int i;
author
#9 lore raw

Re: [PATCH 3/7] btrfs-progs: rename struct open_ctree_flags to open_ctree_args

Quoted 17 lines · Qu Wenruo
Quoted 11 lines · Anand Jain

The struct open_ctree_flags currently holds arguments for open_ctree_fs_info(), it can be confusing when mixed with a local variable named open_ctree_flags as below in the function cmd_inspect_dump_tree().

    cmd_inspect_dump_tree()
    ::
    struct open_ctree_flags ocf = { 0 };
    ::
    unsigned open_ctree_flags;

So rename struct open_ctree_flags to struct open_ctree_args.

I don't think this is a big deal.

Quoted 8 lines

Any LSP server and compiler can handle it correct.

Furthermore the rename would make a lot of @ocf variables loses its meaning. (The patch doesn't rename it to oca).

To me, the better solution would be remove local variable open_ctree_flags completely, and do all the flags setting using ocf.flags instead.

s/open_ctree_flags/open_ctree_args makes sense as this struct is not just about the flags.

struct open_ctree_args {
        const char *filename;
        u64 sb_bytenr;
        u64 root_tree_bytenr;
        u64 chunk_tree_bytenr;
        unsigned flags;
};

PS:
We also have
enum btrfs_open_ctree_flags {
::
}

Thanks, Anand

#10 lore raw

Re: [PATCH 3/7] btrfs-progs: rename struct open_ctree_flags to open_ctree_args

Quoted 32 lines · Anand Jain
Quoted 18 lines · Qu Wenruo
Quoted 5 lines · Anand Jain

The struct open_ctree_flags currently holds arguments for open_ctree_fs_info(), it can be confusing when mixed with a local variable
named open_ctree_flags as below in the function cmd_inspect_dump_tree().

Quoted 7 lines

    cmd_inspect_dump_tree()
    ::
    struct open_ctree_flags ocf = { 0 };
    ::
    unsigned open_ctree_flags;

So rename struct open_ctree_flags to struct open_ctree_args.

I don't think this is a big deal.

Quoted 8 lines

Any LSP server and compiler can handle it correct.

Furthermore the rename would make a lot of @ocf variables loses its meaning. (The patch doesn't rename it to oca).

To me, the better solution would be remove local variable open_ctree_flags completely, and do all the flags setting using ocf.flags instead.

s/open_ctree_flags/open_ctree_args makes sense as this struct is not just about the flags.

Quoted 7 lines

struct open_ctree_args {
        const char *filename;
        u64 sb_bytenr;
        u64 root_tree_bytenr;
        u64 chunk_tree_bytenr;
        unsigned flags;
};

OK, then you may want to also rename @ocf to @oca.

And since we're already here, removing @open_ctree_flags also makes sense, as we can directly use oca.flags.

Thanks,
Qu

Quoted 9 lines

PS:
We also have
enum btrfs_open_ctree_flags {
::
}

Thanks, Anand

author
#11 lore raw

Re: [PATCH 3/7] btrfs-progs: rename struct open_ctree_flags to open_ctree_args

Quoted 11 lines
Quoted 8 lines

struct open_ctree_args {
         const char *filename;
         u64 sb_bytenr;
         u64 root_tree_bytenr;
         u64 chunk_tree_bytenr;
         unsigned flags;
};

OK, then you may want to also rename @ocf to @oca.

Will do.

Quoted 2 lines

And since we're already here, removing @open_ctree_flags also makes sense, as we can directly use oca.flags.

Included in the next reroll.

Thanks,

author
#12 lore raw

PATCH v2 4/7 btrfs-progs: device_list_add: optimize arguments drop devid

In reply to Anand Jain

Drop the devid argument; instead, it can be fetched from the disk_super argument.

---
 kernel-shared/volumes.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel-shared/volumes.c +4 -4
index 95d5930b95d8..81abda3f7d1c 100644
@@ -334,11 +334,12 @@ static struct btrfs_fs_devices *find_fsid(u8 *fsid, u8 *metadata_uuid)
 
 static int device_list_add(const char *path,
 			   struct btrfs_super_block *disk_super,
-			   u64 devid, struct btrfs_fs_devices **fs_devices_ret)
+			   struct btrfs_fs_devices **fs_devices_ret)
 {
 	struct btrfs_device *device;
 	struct btrfs_fs_devices *fs_devices;
 	u64 found_transid = btrfs_super_generation(disk_super);
+	u64 devid = btrfs_stack_device_id(&disk_super->dev_item);
 	bool metadata_uuid = (btrfs_super_incompat_flags(disk_super) &
 		BTRFS_FEATURE_INCOMPAT_METADATA_UUID);
 
@@ -545,18 +546,17 @@ int btrfs_scan_one_device(int fd, const char *path,
 {
 	struct btrfs_super_block disk_super;
 	int ret;
-	u64 devid;
 
 	ret = btrfs_read_dev_super(fd, &disk_super, super_offset, sbflags);
 	if (ret < 0)
 		return -EIO;
-	devid = btrfs_stack_device_id(&disk_super.dev_item);
+
 	if (btrfs_super_flags(&disk_super) & BTRFS_SUPER_FLAG_METADUMP)
 		*total_devs = 1;
 	else
 		*total_devs = btrfs_super_num_devices(&disk_super);
 
-	ret = device_list_add(path, &disk_super, devid, fs_devices_ret);
+	ret = device_list_add(path, &disk_super, fs_devices_ret);
 
 	return ret;
 }
Signature · 1 line
2.38.1
Reviewed-by on v2 4/7
#13 lore raw

Re: [PATCH 4/7] btrfs-progs: device_list_add: optimize arguments drop devid

Quoted 3 lines · Anand Jain

Drop the devid argument; instead, it can be fetched from the disk_super argument. >

Thanks,
Qu

Quoted 43 lines
---
  kernel-shared/volumes.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
kernel-shared/volumes.c +4 -4
index 95d5930b95d8..81abda3f7d1c 100644
@@ -334,11 +334,12 @@ static struct btrfs_fs_devices *find_fsid(u8 *fsid, u8 *metadata_uuid)
 
  static int device_list_add(const char *path,
  			   struct btrfs_super_block *disk_super,
-			   u64 devid, struct btrfs_fs_devices **fs_devices_ret)
+			   struct btrfs_fs_devices **fs_devices_ret)
  {
  	struct btrfs_device *device;
  	struct btrfs_fs_devices *fs_devices;
  	u64 found_transid = btrfs_super_generation(disk_super);
+	u64 devid = btrfs_stack_device_id(&disk_super->dev_item);
  	bool metadata_uuid = (btrfs_super_incompat_flags(disk_super) &
  		BTRFS_FEATURE_INCOMPAT_METADATA_UUID);
 
@@ -545,18 +546,17 @@ int btrfs_scan_one_device(int fd, const char *path,
  {
  	struct btrfs_super_block disk_super;
  	int ret;
-	u64 devid;
 
  	ret = btrfs_read_dev_super(fd, &disk_super, super_offset, sbflags);
  	if (ret < 0)
  		return -EIO;
-	devid = btrfs_stack_device_id(&disk_super.dev_item);
+
  	if (btrfs_super_flags(&disk_super) & BTRFS_SUPER_FLAG_METADUMP)
  		*total_devs = 1;
  	else
  		*total_devs = btrfs_super_num_devices(&disk_super);
 
-	ret = device_list_add(path, &disk_super, devid, fs_devices_ret);
+	ret = device_list_add(path, &disk_super, fs_devices_ret);
 
  	return ret;
  }
author
#14 lore raw

PATCH v2 5/7 btrfs-progs: btrfs_scan_one_device: drop local variable ret

In reply to Anand Jain

Local variable int ret is unnecessary, drop it.

---
 kernel-shared/volumes.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
kernel-shared/volumes.c +2 -6
index 81abda3f7d1c..c8053ae1c7f7 100644
@@ -545,10 +545,8 @@ int btrfs_scan_one_device(int fd, const char *path,
 			  u64 *total_devs, u64 super_offset, unsigned sbflags)
 {
 	struct btrfs_super_block disk_super;
-	int ret;
 
-	ret = btrfs_read_dev_super(fd, &disk_super, super_offset, sbflags);
-	if (ret < 0)
+	if (btrfs_read_dev_super(fd, &disk_super, super_offset, sbflags) < 0)
 		return -EIO;
 
 	if (btrfs_super_flags(&disk_super) & BTRFS_SUPER_FLAG_METADUMP)
@@ -556,9 +554,7 @@ int btrfs_scan_one_device(int fd, const char *path,
 	else
 		*total_devs = btrfs_super_num_devices(&disk_super);
 
-	ret = device_list_add(path, &disk_super, fs_devices_ret);
-
-	return ret;
+	return device_list_add(path, &disk_super, fs_devices_ret);
 }
 
 static u64 dev_extent_search_start(struct btrfs_device *device, u64 start)
Signature · 1 line
2.38.1
#15 lore raw

Re: [PATCH 5/7] btrfs-progs: btrfs_scan_one_device: drop local variable ret

Quoted 3 lines · Anand Jain

Local variable int ret is unnecessary, drop it.

I'm not sure if this change is really necessary.

To me it's more nature to go "ret = what_ever();" then handling @ret. And compiler is definitely clever enough for those optimization.

Thanks,
Qu

Quoted 31 lines
---
  kernel-shared/volumes.c | 8 ++------
  1 file changed, 2 insertions(+), 6 deletions(-)
kernel-shared/volumes.c +2 -6
index 81abda3f7d1c..c8053ae1c7f7 100644
@@ -545,10 +545,8 @@ int btrfs_scan_one_device(int fd, const char *path,
  			  u64 *total_devs, u64 super_offset, unsigned sbflags)
  {
  	struct btrfs_super_block disk_super;
-	int ret;
 
-	ret = btrfs_read_dev_super(fd, &disk_super, super_offset, sbflags);
-	if (ret < 0)
+	if (btrfs_read_dev_super(fd, &disk_super, super_offset, sbflags) < 0)
  		return -EIO;
 
  	if (btrfs_super_flags(&disk_super) & BTRFS_SUPER_FLAG_METADUMP)
@@ -556,9 +554,7 @@ int btrfs_scan_one_device(int fd, const char *path,
  	else
  		*total_devs = btrfs_super_num_devices(&disk_super);
 
-	ret = device_list_add(path, &disk_super, fs_devices_ret);
-
-	return ret;
+	return device_list_add(path, &disk_super, fs_devices_ret);
  }
 
  static u64 dev_extent_search_start(struct btrfs_device *device, u64 start)
#16 lore raw

Re: [PATCH 5/7] btrfs-progs: btrfs_scan_one_device: drop local variable ret

Quoted 11 lines · Qu Wenruo
Quoted 3 lines · Anand Jain

Local variable int ret is unnecessary, drop it.

I'm not sure if this change is really necessary.

To me it's more nature to go "ret = what_ever();" then handling @ret. And compiler is definitely clever enough for those optimization.

Yeah we do

	ret = function(...)
	if (ret < 0)
		...

almost everywhere. I find it clear, there's something happening is on a separate line and the condtion check should have as little side effects as possible.

author
#17 lore raw

Re: [PATCH 5/7] btrfs-progs: btrfs_scan_one_device: drop local variable ret

Quoted 15 lines · David Sterba
Quoted 11 lines · Qu Wenruo
Quoted 3 lines · Anand Jain

Local variable int ret is unnecessary, drop it.

I'm not sure if this change is really necessary.

To me it's more nature to go "ret = what_ever();" then handling @ret. And compiler is definitely clever enough for those optimization.

Yeah we do

Quoted 7 lines
	ret = function(...)
	if (ret < 0)
		...

almost everywhere. I find it clear, there's something happening is on a separate line and the condtion check should have as little side effects as possible.

I noticed that the partner will leave the ret to stay. I am okay with dropping this patch in the next reroll.

I assume you also meant the following is not needed?

@@ -556,9 +554,7 @@ int btrfs_scan_one_device(int fd, const char *path,
else
*total_devs = btrfs_super_num_devices(&disk_super);

- ret = device_list_add(path, &disk_super, fs_devices_ret);
-
- return ret;
+ return device_list_add(path, &disk_super, fs_devices_ret);

Thanks

author
#18 lore raw

PATCH v2 6/7 btrfs-progs: factor out btrfs_scan_stdin_devices

In reply to Anand Jain

To prepare for handling command line given devices factor out btrfs_scan_stdin_devices().

---
 cmds/inspect-dump-tree.c | 37 +++----------------------------------
 common/device-scan.c     | 39 +++++++++++++++++++++++++++++++++++++++
 common/device-scan.h     |  1 +
 3 files changed, 43 insertions(+), 34 deletions(-)
cmds/inspect-dump-tree.c +3 -34
index 35920d14b7e9..311dfbfddab6 100644
@@ -327,7 +327,6 @@ static int cmd_inspect_dump_tree(const struct cmd_struct *cmd,
 	bool roots_only = false;
 	bool root_backups = false;
 	int traverse = BTRFS_PRINT_TREE_DEFAULT;
-	int dev_optind;
 	unsigned open_ctree_flags;
 	u64 block_bytenr;
 	struct btrfs_root *tree_root_scan;
@@ -456,39 +455,9 @@ static int cmd_inspect_dump_tree(const struct cmd_struct *cmd,
 	if (check_argc_min(argc - optind, 1))
 		return 1;
 
-	dev_optind = optind;
-	while (dev_optind < argc) {
-		int fd;
-		struct btrfs_fs_devices *fs_devices;
-		u64 num_devices;
-
-		ret = check_arg_type(argv[optind]);
-		if (ret != BTRFS_ARG_BLKDEV && ret != BTRFS_ARG_REG) {
-			if (ret < 0) {
-				errno = -ret;
-				error("invalid argument %s: %m", argv[dev_optind]);
-			} else {
-				error("not a block device or regular file: %s",
-				       argv[dev_optind]);
-			}
-		}
-		fd = open(argv[dev_optind], O_RDONLY);
-		if (fd < 0) {
-			error("cannot open %s: %m", argv[dev_optind]);
-			return -EINVAL;
-		}
-		ret = btrfs_scan_one_device(fd, argv[dev_optind], &fs_devices,
-					    &num_devices,
-					    BTRFS_SUPER_INFO_OFFSET,
-					    SBREAD_DEFAULT);
-		close(fd);
-		if (ret < 0) {
-			errno = -ret;
-			error("device scan %s: %m", argv[dev_optind]);
-			return ret;
-		}
-		dev_optind++;
-	}
+	ret = btrfs_scan_stdin_devices(optind, argc, argv);
+	if (ret)
+		return ret;
 
 	pr_verbose(LOG_DEFAULT, "%s\n", PACKAGE_STRING);
 
common/device-scan.c +39 -0
index 515481a6efa9..38f986df810f 100644
@@ -500,3 +500,42 @@ int btrfs_scan_devices(int verbose)
 	return 0;
 }
 
+int btrfs_scan_stdin_devices(int dev_optind, int argc, char **argv)
+{
+	int ret;
+
+	while (dev_optind < argc) {
+		int fd;
+		u64 num_devices;
+		struct btrfs_fs_devices *fs_devices;
+
+		ret = check_arg_type(argv[optind]);
+		if (ret != BTRFS_ARG_BLKDEV && ret != BTRFS_ARG_REG) {
+			if (ret < 0) {
+				errno = -ret;
+				error("invalid argument %s: %m", argv[dev_optind]);
+			} else {
+				error("not a block device or regular file: %s",
+				       argv[dev_optind]);
+			}
+		}
+		fd = open(argv[dev_optind], O_RDONLY);
+		if (fd < 0) {
+			error("cannot open %s: %m", argv[dev_optind]);
+			return -EINVAL;
+		}
+		ret = btrfs_scan_one_device(fd, argv[dev_optind], &fs_devices,
+					    &num_devices,
+					    BTRFS_SUPER_INFO_OFFSET,
+					    SBREAD_DEFAULT);
+		close(fd);
+		if (ret < 0) {
+			errno = -ret;
+			error("device scan %s: %m", argv[dev_optind]);
+			return ret;
+		}
+		dev_optind++;
+	}
+
+	return 0;
+}
common/device-scan.h +1 -0
index f805b489f595..e2480d3eb168 100644
@@ -58,5 +58,6 @@ int add_seen_fsid(u8 *fsid, struct seen_fsid *seen_fsid_hash[],
 		int fd, DIR *dirstream);
 void free_seen_fsid(struct seen_fsid *seen_fsid_hash[]);
 int test_uuid_unique(const char *uuid_str);
+int btrfs_scan_stdin_devices(int dev_optind, int argc, char **argv);
 
 #endif
Signature · 1 line
2.38.1
#19 lore raw

Re: [PATCH 6/7] btrfs-progs: factor out btrfs_scan_stdin_devices

Quoted 70 lines · Anand Jain

To prepare for handling command line given devices factor out btrfs_scan_stdin_devices().

---
  cmds/inspect-dump-tree.c | 37 +++----------------------------------
  common/device-scan.c     | 39 +++++++++++++++++++++++++++++++++++++++
  common/device-scan.h     |  1 +
  3 files changed, 43 insertions(+), 34 deletions(-)
cmds/inspect-dump-tree.c +3 -34
index 35920d14b7e9..311dfbfddab6 100644
@@ -327,7 +327,6 @@ static int cmd_inspect_dump_tree(const struct cmd_struct *cmd,
  	bool roots_only = false;
  	bool root_backups = false;
  	int traverse = BTRFS_PRINT_TREE_DEFAULT;
-	int dev_optind;
  	unsigned open_ctree_flags;
  	u64 block_bytenr;
  	struct btrfs_root *tree_root_scan;
@@ -456,39 +455,9 @@ static int cmd_inspect_dump_tree(const struct cmd_struct *cmd,
  	if (check_argc_min(argc - optind, 1))
  		return 1;
 
-	dev_optind = optind;
-	while (dev_optind < argc) {
-		int fd;
-		struct btrfs_fs_devices *fs_devices;
-		u64 num_devices;
-
-		ret = check_arg_type(argv[optind]);
-		if (ret != BTRFS_ARG_BLKDEV && ret != BTRFS_ARG_REG) {
-			if (ret < 0) {
-				errno = -ret;
-				error("invalid argument %s: %m", argv[dev_optind]);
-			} else {
-				error("not a block device or regular file: %s",
-				       argv[dev_optind]);
-			}
-		}
-		fd = open(argv[dev_optind], O_RDONLY);
-		if (fd < 0) {
-			error("cannot open %s: %m", argv[dev_optind]);
-			return -EINVAL;
-		}
-		ret = btrfs_scan_one_device(fd, argv[dev_optind], &fs_devices,
-					    &num_devices,
-					    BTRFS_SUPER_INFO_OFFSET,
-					    SBREAD_DEFAULT);
-		close(fd);
-		if (ret < 0) {
-			errno = -ret;
-			error("device scan %s: %m", argv[dev_optind]);
-			return ret;
-		}
-		dev_optind++;
-	}
+	ret = btrfs_scan_stdin_devices(optind, argc, argv);
+	if (ret)
+		return ret;
 
  	pr_verbose(LOG_DEFAULT, "%s\n", PACKAGE_STRING);
 
common/device-scan.c +0 -0
index 515481a6efa9..38f986df810f 100644

common/device-scan.c int btrfs_scan_devices(int verbose) · line 507

Quoted 8 lines
common/device-scan.c +5 -0
@@ -500,3 +500,42 @@ int btrfs_scan_devices(int verbose)
  	return 0;
  }
 
+int btrfs_scan_stdin_devices(int dev_optind, int argc, char **argv)
+{
+	int ret;
+
+	while (dev_optind < argc) {

In this case, I believe "--device dev1 --device dev2" would be much easier to parse, and would not lead to any confusion between the device scan and target fs.

Thanks,
Qu

Quoted 45 lines
common/device-scan.c +34 -0
+		int fd;
+		u64 num_devices;
+		struct btrfs_fs_devices *fs_devices;
+
+		ret = check_arg_type(argv[optind]);
+		if (ret != BTRFS_ARG_BLKDEV && ret != BTRFS_ARG_REG) {
+			if (ret < 0) {
+				errno = -ret;
+				error("invalid argument %s: %m", argv[dev_optind]);
+			} else {
+				error("not a block device or regular file: %s",
+				       argv[dev_optind]);
+			}
+		}
+		fd = open(argv[dev_optind], O_RDONLY);
+		if (fd < 0) {
+			error("cannot open %s: %m", argv[dev_optind]);
+			return -EINVAL;
+		}
+		ret = btrfs_scan_one_device(fd, argv[dev_optind], &fs_devices,
+					    &num_devices,
+					    BTRFS_SUPER_INFO_OFFSET,
+					    SBREAD_DEFAULT);
+		close(fd);
+		if (ret < 0) {
+			errno = -ret;
+			error("device scan %s: %m", argv[dev_optind]);
+			return ret;
+		}
+		dev_optind++;
+	}
+
+	return 0;
+}
common/device-scan.h +1 -0
index f805b489f595..e2480d3eb168 100644
@@ -58,5 +58,6 @@ int add_seen_fsid(u8 *fsid, struct seen_fsid *seen_fsid_hash[],
  		int fd, DIR *dirstream);
  void free_seen_fsid(struct seen_fsid *seen_fsid_hash[]);
  int test_uuid_unique(const char *uuid_str);
+int btrfs_scan_stdin_devices(int dev_optind, int argc, char **argv);
 
  #endif
#20 lore raw

Re: [PATCH 6/7] btrfs-progs: factor out btrfs_scan_stdin_devices

In reply to Anand Jain
Quoted 2 lines · Anand Jain

To prepare for handling command line given devices factor out btrfs_scan_stdin_devices().

I find using 'stdin' in this context confusion, the tool is not taking the devices from stdin, but command line arguments. You can use 'argv' for that.

author
#21 lore raw

PATCH v2 7/7 btrfs-progs: refactor check_where_mounted with noscan argument

In reply to Anand Jain

The function check_where_mounted() scans the system for all other btrfs devices, which is necessary for its operation.

However, in certain cases, devices remained in the scanned state is undesirable.

So introduces the 'noscan' argument to make devices unscanned before return.

---
 common/open-utils.c | 9 ++++++---
 common/open-utils.h | 3 ++-
 common/utils.c      | 3 ++-
 tune/main.c         | 2 +-
 4 files changed, 11 insertions(+), 6 deletions(-)
common/open-utils.c +6 -3
index 1e18fa905b51..e34abee97f60 100644
@@ -53,7 +53,8 @@ static int blk_file_in_dev_list(struct btrfs_fs_devices* fs_devices,
 }
 
 int check_mounted_where(int fd, const char *file, char *where, int size,
-			struct btrfs_fs_devices **fs_dev_ret, unsigned sbflags)
+			struct btrfs_fs_devices **fs_dev_ret, unsigned sbflags,
+			bool noscan)
 {
 	struct btrfs_fs_devices *fs_devices_mnt = NULL;
 	struct mntent *mnt;
@@ -108,6 +109,8 @@ int check_mounted_where(int fd, const char *file, char *where, int size,
 	}
 	if (fs_dev_ret)
 		*fs_dev_ret = fs_devices_mnt;
+	else if (noscan)
+		btrfs_close_all_devices();
 
 	ret = (mnt != NULL);
 
@@ -132,7 +135,7 @@ int check_mounted(const char* file)
 		return -errno;
 	}
 
-	ret =  check_mounted_where(fd, file, NULL, 0, NULL, SBREAD_DEFAULT);
+	ret =  check_mounted_where(fd, file, NULL, 0, NULL, SBREAD_DEFAULT, false);
 	close(fd);
 
 	return ret;
@@ -168,7 +171,7 @@ int get_btrfs_mount(const char *dev, char *mp, size_t mp_size)
 		goto out;
 	}
 
-	ret = check_mounted_where(fd, dev, mp, mp_size, NULL, SBREAD_DEFAULT);
+	ret = check_mounted_where(fd, dev, mp, mp_size, NULL, SBREAD_DEFAULT, false);
 	if (!ret) {
 		ret = -EINVAL;
 	} else { /* mounted, all good */
common/open-utils.h +2 -1
index 3924be36e2ea..27000cdbd626 100644
@@ -23,7 +23,8 @@
 struct btrfs_fs_devices;
 
 int check_mounted_where(int fd, const char *file, char *where, int size,
-			struct btrfs_fs_devices **fs_dev_ret, unsigned sbflags);
+			struct btrfs_fs_devices **fs_dev_ret, unsigned sbflags,
+			bool noscan);
 int check_mounted(const char* file);
 int get_btrfs_mount(const char *dev, char *mp, size_t mp_size);
 int open_path_or_dev_mnt(const char *path, DIR **dirstream, int verbose);
common/utils.c +2 -1
index 436ff8c2a827..b62f9f04ad5a 100644
@@ -230,7 +230,8 @@ int get_fs_info(const char *path, struct btrfs_ioctl_fs_info_args *fi_args,
 			goto out;
 		}
 		ret = check_mounted_where(fd, path, mp, sizeof(mp),
-					  &fs_devices_mnt, SBREAD_DEFAULT);
+					  &fs_devices_mnt, SBREAD_DEFAULT,
+					  false);
 		if (!ret) {
 			ret = -EINVAL;
 			goto out;
tune/main.c +1 -1
index e38c1f6d3729..0ca1e01282c9 100644
@@ -268,7 +268,7 @@ int BOX_MAIN(btrfstune)(int argc, char *argv[])
 	}
 
 	ret = check_mounted_where(fd, device, NULL, 0, NULL,
-			SBREAD_IGNORE_FSID_MISMATCH);
+				  SBREAD_IGNORE_FSID_MISMATCH, false);
 	if (ret < 0) {
 		errno = -ret;
 		error("could not check mount status of %s: %m", device);
Signature · 1 line
2.38.1