|
|
15cc96 |
From 33be80700bc594f34818ce697493c17e70430390 Mon Sep 17 00:00:00 2001
|
|
|
15cc96 |
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
|
|
|
15cc96 |
Date: Mon, 17 May 2021 08:50:25 +0200
|
|
|
15cc96 |
Subject: [PATCH] Recover from fsync fail on read-only filesystem
|
|
|
15cc96 |
(RhBug:1956361)
|
|
|
15cc96 |
|
|
|
15cc96 |
When `fsync` fails due to the file not supporting synchronization just log
|
|
|
15cc96 |
the problem instead of failing the whole dnf run. This happens for
|
|
|
15cc96 |
example with filesystems mounted read-only in which case there is no
|
|
|
15cc96 |
point to `fsync` anyway.
|
|
|
15cc96 |
|
|
|
15cc96 |
Currently we also ignore return values from `FSETXATTR` which also fails
|
|
|
15cc96 |
on read-only filesystem (so no checksum cache is set). This is fine however
|
|
|
15cc96 |
since the checksum is recomputed when needed, dnf is just a bit slower.
|
|
|
15cc96 |
|
|
|
15cc96 |
https://bugzilla.redhat.com/show_bug.cgi?id=1956361
|
|
|
15cc96 |
---
|
|
|
15cc96 |
librepo/checksum.c | 10 +++++++---
|
|
|
15cc96 |
1 file changed, 7 insertions(+), 3 deletions(-)
|
|
|
15cc96 |
|
|
|
15cc96 |
diff --git a/librepo/checksum.c b/librepo/checksum.c
|
|
|
15cc96 |
index db37040..6bba53c 100644
|
|
|
15cc96 |
--- a/librepo/checksum.c
|
|
|
15cc96 |
+++ b/librepo/checksum.c
|
|
|
15cc96 |
@@ -266,9 +266,13 @@ lr_checksum_fd_compare(LrChecksumType type,
|
|
|
15cc96 |
*matches = (strcmp(expected, checksum)) ? FALSE : TRUE;
|
|
|
15cc96 |
|
|
|
15cc96 |
if (fsync(fd) != 0) {
|
|
|
15cc96 |
- g_set_error(err, LR_CHECKSUM_ERROR, LRE_FILE,
|
|
|
15cc96 |
- "fsync failed: %s", strerror(errno));
|
|
|
15cc96 |
- return FALSE;
|
|
|
15cc96 |
+ if (errno == EROFS || errno == EINVAL) {
|
|
|
15cc96 |
+ g_debug("fsync failed: %s", strerror(errno));
|
|
|
15cc96 |
+ } else {
|
|
|
15cc96 |
+ g_set_error(err, LR_CHECKSUM_ERROR, LRE_FILE,
|
|
|
15cc96 |
+ "fsync failed: %s", strerror(errno));
|
|
|
15cc96 |
+ return FALSE;
|
|
|
15cc96 |
+ }
|
|
|
15cc96 |
}
|
|
|
15cc96 |
|
|
|
15cc96 |
if (caching && *matches && timestamp != -1) {
|
|
|
15cc96 |
--
|
|
|
15cc96 |
2.31.1
|
|
|
15cc96 |
|