From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 1/3 v4] btrfs-progs: Introduce flag BTRFS_SCAN_REGISTER to replace run_ioctl
Date: Thu, 14 Mar 2013 11:05:55 +0800 [thread overview]
Message-ID: <1363230357-7438-2-git-send-email-anand.jain@oracle.com> (raw)
In-Reply-To: <1363230357-7438-1-git-send-email-anand.jain@oracle.com>
Introduce flag BTRFS_SCAN_REGISTER to replace the parameter run_ioctl
which controls calling the function btrfs_register_one_device().
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
btrfsctl.c | 2 +-
cmds-device.c | 4 ++--
disk-io.c | 3 ++-
find-root.c | 3 ++-
utils.c | 17 +++++++++--------
utils.h | 7 ++++---
6 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/btrfsctl.c b/btrfsctl.c
index 8fd8cc3..75bc52d 100644
--- a/btrfsctl.c
+++ b/btrfsctl.c
@@ -115,7 +115,7 @@ int main(int ac, char **av)
if (ac == 2 && strcmp(av[1], "-a") == 0) {
fprintf(stderr, "Scanning for Btrfs filesystems\n");
- btrfs_scan_one_dir("/dev", 1);
+ btrfs_scan_one_dir("/dev", BTRFS_SCAN_REGISTER);
exit(0);
}
for (i = 1; i < ac; i++) {
diff --git a/cmds-device.c b/cmds-device.c
index 58df6da..1b8f378 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -203,9 +203,9 @@ static int cmd_scan_dev(int argc, char **argv)
printf("Scanning for Btrfs filesystems\n");
if(checklist)
- ret = btrfs_scan_block_devices(1);
+ ret = btrfs_scan_block_devices(BTRFS_SCAN_REGISTER);
else
- ret = btrfs_scan_one_dir("/dev", 1);
+ ret = btrfs_scan_one_dir("/dev", BTRFS_SCAN_REGISTER);
if (ret){
fprintf(stderr, "ERROR: error %d while scanning\n", ret);
return 18;
diff --git a/disk-io.c b/disk-io.c
index a9fd374..8205b3c 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -834,7 +834,8 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const char *path,
}
if (total_devs != 1) {
- ret = btrfs_scan_for_fsid(fs_devices, total_devs, 1);
+ ret = btrfs_scan_for_fsid(fs_devices, total_devs,
+ BTRFS_SCAN_REGISTER);
if (ret)
goto out;
}
diff --git a/find-root.c b/find-root.c
index f99fb76..ca41447 100644
--- a/find-root.c
+++ b/find-root.c
@@ -110,7 +110,8 @@ static struct btrfs_root *open_ctree_broken(int fd, const char *device)
}
if (total_devs != 1) {
- ret = btrfs_scan_for_fsid(fs_devices, total_devs, 1);
+ ret = btrfs_scan_for_fsid(fs_devices, total_devs,
+ BTRFS_SCAN_REGISTER);
if (ret)
goto out;
}
diff --git a/utils.c b/utils.c
index f68436d..c29861b 100644
--- a/utils.c
+++ b/utils.c
@@ -840,7 +840,8 @@ int check_mounted_where(int fd, const char *file, char *where, int size,
/* scan other devices */
if (is_btrfs && total_devs > 1) {
- if((ret = btrfs_scan_for_fsid(fs_devices_mnt, total_devs, 1)))
+ if((ret = btrfs_scan_for_fsid(fs_devices_mnt, total_devs,
+ BTRFS_SCAN_REGISTER)))
return ret;
}
@@ -951,7 +952,7 @@ void btrfs_register_one_device(char *fname)
close(fd);
}
-int btrfs_scan_one_dir(char *dirname, int run_ioctl)
+int btrfs_scan_one_dir(char *dirname, u64 flags)
{
DIR *dirp = NULL;
struct dirent *dirent;
@@ -1032,7 +1033,7 @@ again:
ret = btrfs_scan_one_device(fd, fullpath, &tmp_devices,
&num_devices,
BTRFS_SUPER_INFO_OFFSET);
- if (ret == 0 && run_ioctl > 0) {
+ if (ret == 0 && flags & BTRFS_SCAN_REGISTER) {
btrfs_register_one_device(fullpath);
}
close(fd);
@@ -1057,13 +1058,13 @@ fail:
}
int btrfs_scan_for_fsid(struct btrfs_fs_devices *fs_devices, u64 total_devs,
- int run_ioctls)
+ u64 flags)
{
int ret;
- ret = btrfs_scan_block_devices(run_ioctls);
+ ret = btrfs_scan_block_devices(flags);
if (ret)
- ret = btrfs_scan_one_dir("/dev", run_ioctls);
+ ret = btrfs_scan_one_dir("/dev", flags);
return ret;
}
@@ -1294,7 +1295,7 @@ int set_label(const char *btrfs_dev, const char *label)
set_label_mounted(btrfs_dev, label);
}
-int btrfs_scan_block_devices(int run_ioctl)
+int btrfs_scan_block_devices(u64 flags)
{
struct stat st;
@@ -1361,7 +1362,7 @@ scan_again:
ret = btrfs_scan_one_device(fd, fullpath, &tmp_devices,
&num_devices,
BTRFS_SUPER_INFO_OFFSET);
- if (ret == 0 && run_ioctl > 0) {
+ if (ret == 0 && flags & BTRFS_SCAN_REGISTER) {
btrfs_register_one_device(fullpath);
}
close(fd);
diff --git a/utils.h b/utils.h
index 0b681ed..c4d0d00 100644
--- a/utils.h
+++ b/utils.h
@@ -22,6 +22,7 @@
#include "ctree.h"
#define BTRFS_MKFS_SYSTEM_GROUP_SIZE (4 * 1024 * 1024)
+#define BTRFS_SCAN_REGISTER (1ULL << 1)
int make_btrfs(int fd, const char *device, const char *label,
u64 blocks[6], u64 num_bytes, u32 nodesize,
@@ -35,9 +36,9 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
u64 block_count, u32 io_width, u32 io_align,
u32 sectorsize);
int btrfs_scan_for_fsid(struct btrfs_fs_devices *fs_devices, u64 total_devs,
- int run_ioctls);
+ u64 flags);
void btrfs_register_one_device(char *fname);
-int btrfs_scan_one_dir(char *dirname, int run_ioctl);
+int btrfs_scan_one_dir(char *dirname, u64 flags);
int check_mounted(const char *devicename);
int check_mounted_where(int fd, const char *file, char *where, int size,
struct btrfs_fs_devices **fs_devices_mnt);
@@ -45,7 +46,7 @@ int btrfs_device_already_in_root(struct btrfs_root *root, int fd,
int super_offset);
char *pretty_sizes(u64 size);
int get_mountpt(char *dev, char *mntpt, size_t size);
-int btrfs_scan_block_devices(int run_ioctl);
+int btrfs_scan_block_devices(u64 flags);
u64 parse_size(char *s);
int open_file_or_dir(const char *fname);
int get_device_info(int fd, u64 devid,
--
1.8.1.227.g44fe835
next prev parent reply other threads:[~2013-03-14 3:05 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-08 15:24 [PATCH 0/3 v2] flags to access backup SB Anand Jain
2013-03-08 15:24 ` [PATCH 1/3] btrfs-progs: Introduce flag BTRFS_SCAN_REGISTER to replace run_ioctl Anand Jain
2013-03-08 15:24 ` [PATCH 2/3] btrfs-progs: Introduce flag BTRFS_SCAN_BACKUP_SB for btrfs_read_dev_super Anand Jain
2013-03-08 15:25 ` [PATCH 3/3] btrfs-progs: use BTRFS_SCAN_BACKUP_SB flag in btrfs_scan_one_device Anand Jain
2013-03-11 15:03 ` Eric Sandeen
2013-03-11 18:16 ` David Sterba
2013-03-13 11:46 ` Anand Jain
2013-03-14 8:51 ` Anand Jain
2013-03-13 11:44 ` [PATCH 0/3 v3] flags to access backup SB Anand Jain
2013-03-13 11:44 ` [PATCH 1/3 v3] btrfs-progs: Introduce flag BTRFS_SCAN_REGISTER to replace run_ioctl Anand Jain
2013-03-13 11:44 ` [PATCH 2/3 v3] btrfs-progs: Introduce flag BTRFS_SCAN_BACKUP_SB for btrfs_read_dev_super Anand Jain
2013-03-13 11:44 ` [PATCH 3/3 v3] btrfs-progs: disable using backup superblock by default Anand Jain
2013-03-14 3:05 ` [PATCH 0/3 v4] flags to access backup SB Anand Jain
2013-03-14 3:05 ` Anand Jain [this message]
2013-03-14 3:05 ` [PATCH 2/3 v4] btrfs-progs: Introduce flag BTRFS_SCAN_BACKUP_SB for btrfs_read_dev_super Anand Jain
2013-03-14 3:05 ` [PATCH 3/3 v4] btrfs-progs: disable using backup superblock by default Anand Jain
2013-03-14 4:36 ` Eric Sandeen
2013-03-14 8:56 ` Anand Jain
2013-03-14 14:47 ` Eric Sandeen
2013-03-14 14:49 ` Eric Sandeen
2013-03-15 12:03 ` Anand Jain
2013-03-15 16:34 ` Eric Sandeen
2013-03-18 3:39 ` Anand Jain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1363230357-7438-2-git-send-email-anand.jain@oracle.com \
--to=anand.jain@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).