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
Subject: [PATCH v2 4/4] btrfs: fix use of error or warning for missing device
Date: Mon,  9 Oct 2017 11:07:46 +0800	[thread overview]
Message-ID: <20171009030746.16680-4-anand.jain@oracle.com> (raw)
In-Reply-To: <20171009030746.16680-1-anand.jain@oracle.com>

When device is missing without the -o degraded option then
its an error so report it as an error instead of warning.
And when -o degraded option is provided, log the missing
device as warning.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2: Rename from
    [PATCH 2/2] btrfs: clean up btrfs_report_missing_device() usage
    Also drop the idea of moving the DEGRADED option checking
    into the function btrfs_report_missing_device() and further
    renaming it to check_report_degraded(). If its such a thing
    is good idea it can be added on top of this patch. Thxs.
 fs/btrfs/volumes.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 6a041bef112c..c76a81938766 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6378,9 +6378,14 @@ static int btrfs_check_chunk_valid(struct btrfs_fs_info *fs_info,
 }
 
 static void btrfs_report_missing_device(struct btrfs_fs_info *fs_info,
-						u64 devid, u8 *uuid)
+					u64 devid, u8 *uuid, int error)
 {
-	btrfs_warn_rl(fs_info, "devid %llu uuid %pU is missing", devid, uuid);
+	if (error)
+		btrfs_err_rl(fs_info, "devid %llu uuid %pU is missing",
+			      devid, uuid);
+	else
+		btrfs_warn_rl(fs_info, "devid %llu uuid %pU is missing",
+			      devid, uuid);
 }
 
 static int read_one_chunk(struct btrfs_fs_info *fs_info, struct btrfs_key *key,
@@ -6453,7 +6458,7 @@ static int read_one_chunk(struct btrfs_fs_info *fs_info, struct btrfs_key *key,
 		if (!map->stripes[i].dev &&
 		    !btrfs_test_opt(fs_info, DEGRADED)) {
 			free_extent_map(em);
-			btrfs_report_missing_device(fs_info, devid, uuid);
+			btrfs_report_missing_device(fs_info, devid, uuid, 1);
 			return -ENOENT;
 		}
 		if (!map->stripes[i].dev) {
@@ -6467,7 +6472,7 @@ static int read_one_chunk(struct btrfs_fs_info *fs_info, struct btrfs_key *key,
 					devid, PTR_ERR(map->stripes[i].dev));
 				return PTR_ERR(map->stripes[i].dev);
 			}
-			btrfs_report_missing_device(fs_info, devid, uuid);
+			btrfs_report_missing_device(fs_info, devid, uuid, 0);
 		}
 		map->stripes[i].dev->in_fs_metadata = 1;
 	}
@@ -6586,19 +6591,24 @@ static int read_one_dev(struct btrfs_fs_info *fs_info,
 	device = btrfs_find_device(fs_info, devid, dev_uuid, fs_uuid);
 	if (!device) {
 		if (!btrfs_test_opt(fs_info, DEGRADED)) {
-			btrfs_report_missing_device(fs_info, devid, dev_uuid);
+			btrfs_report_missing_device(fs_info, devid,
+							dev_uuid, 1);
 			return -ENOENT;
 		}
 
 		device = add_missing_dev(fs_devices, devid, dev_uuid);
 		if (IS_ERR(device))
 			return PTR_ERR(device);
-		btrfs_report_missing_device(fs_info, devid, dev_uuid);
+		btrfs_report_missing_device(fs_info, devid, dev_uuid, 0);
 	} else {
 		if (!device->bdev) {
-			btrfs_report_missing_device(fs_info, devid, dev_uuid);
-			if (!btrfs_test_opt(fs_info, DEGRADED))
+			if (!btrfs_test_opt(fs_info, DEGRADED)) {
+				btrfs_report_missing_device(fs_info,
+						devid, dev_uuid, 1);
 				return -ENOENT;
+			}
+			btrfs_report_missing_device(fs_info, devid,
+							dev_uuid, 0);
 		}
 
 		if(!device->bdev && !device->missing) {
-- 
2.7.0


  parent reply	other threads:[~2017-10-09  3:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-09  3:07 [PATCH v2 1/4] btrfs: add_missing_dev() should return the actual error Anand Jain
2017-10-09  3:07 ` [PATCH v2 2/4] btrfs: fix EIO misuse to report missing degraded option Anand Jain
2017-10-13 12:16   ` David Sterba
2017-10-09  3:07 ` [PATCH v2 3/4] btrfs: declare btrfs_report_missing_device() static Anand Jain
2017-10-09  3:07 ` Anand Jain [this message]
2017-10-11  0:52 ` [PATCH v2 1/4] btrfs: add_missing_dev() should return the actual error Liu Bo
2017-10-11  4:34   ` [PATCH v2.1 " Anand Jain
2017-10-11  4:46   ` [PATCH v3 " Anand Jain
2017-10-13 12:14     ` David Sterba
2017-10-13 12:28 ` [PATCH v2 " David Sterba

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=20171009030746.16680-4-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).