linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Cc: sandeen@redhat.com, dsterba@suse.cz
Subject: [PATCH 4/5 v5] btrfs-progs: introduce passing flags to btrfs_scan_one_device
Date: Wed, 27 Mar 2013 18:07:35 +0800	[thread overview]
Message-ID: <1364378856-21053-5-git-send-email-anand.jain@oracle.com> (raw)
In-Reply-To: <1364378856-21053-1-git-send-email-anand.jain@oracle.com>

check_mounted would need to check backup SB to see if the
device is mounted to accommodate the situation when the
primary SB is corrupted (even in multi dev btrfs).
so we need flag to communicate to btrfs_read_dev_super
to check backup SB.

this patch will just introduce the flag with access
to backup SB disable.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 cmds-replace.c | 2 +-
 disk-io.c      | 2 +-
 find-root.c    | 3 ++-
 utils.c        | 9 ++++++---
 volumes.c      | 2 +-
 volumes.h      | 2 +-
 6 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/cmds-replace.c b/cmds-replace.c
index 6397bb5..ab34388 100644
--- a/cmds-replace.c
+++ b/cmds-replace.c
@@ -280,7 +280,7 @@ static int cmd_start_replace(int argc, char **argv)
 		goto leave_with_error;
 	}
 	ret = btrfs_scan_one_device(fddstdev, dstdev, &fs_devices_mnt,
-				    &total_devs, BTRFS_SUPER_INFO_OFFSET);
+				    &total_devs, BTRFS_SUPER_INFO_OFFSET, 0ull);
 	if (ret >= 0 && !force_using_targetdev) {
 		fprintf(stderr,
 			"Error, target device %s contains filesystem, use '-f' to force overwriting.\n",
diff --git a/disk-io.c b/disk-io.c
index 8d68c2e..82c3b66 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -827,7 +827,7 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const char *path,
 		fprintf(stderr, "Warning, could not drop caches\n");
 
 	ret = btrfs_scan_one_device(fp, path, &fs_devices,
-				    &total_devs, sb_bytenr);
+				    &total_devs, sb_bytenr, 0ull);
 
 	if (ret) {
 		fprintf(stderr, "No valid Btrfs found on %s\n", path);
diff --git a/find-root.c b/find-root.c
index 0b08358..eac3d79 100644
--- a/find-root.c
+++ b/find-root.c
@@ -102,7 +102,8 @@ static struct btrfs_root *open_ctree_broken(int fd, const char *device)
 	u64 features;
 
 	ret = btrfs_scan_one_device(fd, device, &fs_devices,
-				    &total_devs, BTRFS_SUPER_INFO_OFFSET);
+				    &total_devs, BTRFS_SUPER_INFO_OFFSET,
+				    0ull);
 
 	if (ret) {
 		fprintf(stderr, "No valid Btrfs found on %s\n", device);
diff --git a/utils.c b/utils.c
index 15645c1..a2001de 100644
--- a/utils.c
+++ b/utils.c
@@ -922,7 +922,8 @@ int check_mounted_where(int fd, const char *file, char *where, int size,
 
 	/* scan the initial device */
 	ret = btrfs_scan_one_device(fd, file, &fs_devices_mnt,
-				    &total_devs, BTRFS_SUPER_INFO_OFFSET);
+				    &total_devs, BTRFS_SUPER_INFO_OFFSET,
+				    0ull);
 	is_btrfs = (ret >= 0);
 
 	/* scan other devices */
@@ -1126,7 +1127,8 @@ again:
 		fd = open(fullpath, O_RDONLY);
 		ret = btrfs_scan_one_device(fd, fullpath, &tmp_devices,
 					    &num_devices,
-					    BTRFS_SUPER_INFO_OFFSET);
+					    BTRFS_SUPER_INFO_OFFSET,
+					    0ull);
 		close(fd);
 
 		if (ret == 0 && flags & BTRFS_SCAN_REGISTER) {
@@ -1468,7 +1470,8 @@ scan_again:
 		fd = open(fullpath, O_RDONLY);
 		ret = btrfs_scan_one_device(fd, fullpath, &tmp_devices,
 					    &num_devices,
-					    BTRFS_SUPER_INFO_OFFSET);
+					    BTRFS_SUPER_INFO_OFFSET,
+					    0ull);
 		close(fd);
 		if (ret == 0 && flags & BTRFS_SCAN_REGISTER) {
 			btrfs_register_one_device(fullpath);
diff --git a/volumes.c b/volumes.c
index 1113cb5..a18b219 100644
--- a/volumes.c
+++ b/volumes.c
@@ -213,7 +213,7 @@ fail:
 
 int btrfs_scan_one_device(int fd, const char *path,
 			  struct btrfs_fs_devices **fs_devices_ret,
-			  u64 *total_devs, u64 super_offset)
+			  u64 *total_devs, u64 super_offset, u64 flags)
 {
 	struct btrfs_super_block *disk_super;
 	char *buf;
diff --git a/volumes.h b/volumes.h
index 911f788..f87aa5b 100644
--- a/volumes.h
+++ b/volumes.h
@@ -179,7 +179,7 @@ int btrfs_update_device(struct btrfs_trans_handle *trans,
 			struct btrfs_device *device);
 int btrfs_scan_one_device(int fd, const char *path,
 			  struct btrfs_fs_devices **fs_devices_ret,
-			  u64 *total_devs, u64 super_offset);
+			  u64 *total_devs, u64 super_offset, u64 flags);
 int btrfs_num_copies(struct btrfs_mapping_tree *map_tree, u64 logical, u64 len);
 int btrfs_bootstrap_super_map(struct btrfs_mapping_tree *map_tree,
 			      struct btrfs_fs_devices *fs_devices);
-- 
1.8.1.227.g44fe835


  parent reply	other threads:[~2013-03-27 10:07 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-22  5:29 [bug] mkfs.btrfs reports device busy for ext4 mounted disk Anand Jain
2013-02-22 19:03 ` Zach Brown
2013-02-22 22:30   ` David Sterba
2013-03-01 10:18     ` Anand Jain
2013-03-01 10:13 ` [PATCH] btrfs-progs: traverse to backup super-block only when indicated Anand Jain
2013-03-01 17:37   ` Eric Sandeen
2013-03-04  5:20     ` Anand Jain
2013-03-01 18:27   ` Zach Brown
2013-03-27 10:07   ` [PATCH 0/5 v5] access to backup-sb and btrfs' multipath aware Anand Jain
2013-03-27 10:07     ` [PATCH 1/5 v5] btrfs-progs: make btrfs dev scan multi path aware Anand Jain
2013-04-11  9:57       ` [obsoleted] " Anand Jain
2013-03-27 10:07     ` [PATCH 2/5 v5] btrfs-progs: Introduce flag BTRFS_SCAN_REGISTER to replace run_ioctl Anand Jain
2013-03-27 10:07     ` [PATCH 3/5 v5] btrfs-progs: Introduce flag BTRFS_SCAN_BACKUP_SB for btrfs_read_dev_super Anand Jain
2013-03-27 10:07     ` Anand Jain [this message]
2013-03-27 10:07     ` [PATCH 5/5 v5] btrfs-progs: disable using backup superblock by default Anand Jain
2013-03-27 23:17     ` [PATCH 0/5 v5] access to backup-sb and btrfs' multipath aware anand jain
2013-04-05  5:54 ` v6: access to backup superblock Anand Jain
2013-04-05  5:54   ` [PATCH 1/5] btrfs-progs: Introduce flag BTRFS_SCAN_REGISTER to replace run_ioctl Anand Jain
2013-04-05  5:54   ` [PATCH 2/5] btrfs-progs: Introduce flag BTRFS_SCAN_BACKUP_SB for btrfs_read_dev_super Anand Jain
2013-04-05  5:54   ` [PATCH 3/5] btrfs-progs: introduce passing flags to btrfs_scan_one_device Anand Jain
2013-04-05  5:54   ` [PATCH 4/5] btrfs-progs: disable using backup superblock by default Anand Jain
2013-04-05  5:54   ` [PATCH 5/5] btrfs-progs: btrfs-find-root should scan backup-sb 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=1364378856-21053-5-git-send-email-anand.jain@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=sandeen@redhat.com \
    /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).