From: Jan Kara <jack@suse.cz>
To: Karel Zak <kzak@redhat.com>
Cc: util-linux@vger.kernel.org, Jan Kara <jack@suse.cz>
Subject: [PATCH 2/2] loopdev: Do not treat errors when detecting overlap as fatal
Date: Thu, 20 Jan 2022 13:16:39 +0100 [thread overview]
Message-ID: <20220120121639.13047-2-jack@suse.cz> (raw)
In-Reply-To: <20220120121639.13047-1-jack@suse.cz>
When looking for overlapping loop device we can fail getting some loop
device properties when we race with device autoclear. Just squelsh these
errors and try next loop device.
Signed-off-by: Jan Kara <jack@suse.cz>
---
lib/loopdev.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/lib/loopdev.c b/lib/loopdev.c
index 27ab06c66848..d49738fde122 100644
--- a/lib/loopdev.c
+++ b/lib/loopdev.c
@@ -1777,10 +1777,13 @@ int loopcxt_find_overlap(struct loopdev_cxt *lc, const char *filename,
rc = loopcxt_is_used(lc, hasst ? &st : NULL,
filename, offset, sizelimit, 0);
- if (!rc)
- continue; /* unused */
- if (rc < 0)
- break; /* error */
+ /*
+ * Either the loopdev is unused or we've got an error which can
+ * happen when we are racing with device autoclear. Just ignore
+ * this loopdev...
+ */
+ if (rc <= 0)
+ continue;
DBG(CXT, ul_debugobj(lc, "found %s backed by %s",
loopcxt_get_device(lc), filename));
@@ -1789,13 +1792,13 @@ int loopcxt_find_overlap(struct loopdev_cxt *lc, const char *filename,
if (rc) {
DBG(CXT, ul_debugobj(lc, "failed to get offset for device %s",
loopcxt_get_device(lc)));
- break;
+ continue;
}
rc = loopcxt_get_sizelimit(lc, &lc_sizelimit);
if (rc) {
DBG(CXT, ul_debugobj(lc, "failed to get sizelimit for device %s",
loopcxt_get_device(lc)));
- break;
+ continue;
}
/* full match */
--
2.31.1
next prev parent reply other threads:[~2022-01-20 12:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-20 12:16 [PATCH 1/2] loopdev: Properly translate errors from ul_path_read_*() Jan Kara
2022-01-20 12:16 ` Jan Kara [this message]
2022-01-25 16:31 ` Karel Zak
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=20220120121639.13047-2-jack@suse.cz \
--to=jack@suse.cz \
--cc=kzak@redhat.com \
--cc=util-linux@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).