Backport patch: Recover from fsync fail on read-only filesystem (RhBug:1956361)

Resolves: rhbz#1981194
This commit is contained in:
Marek Blaha 2021-07-13 10:40:25 +02:00
parent 9f75838833
commit 9d422f98de
2 changed files with 49 additions and 1 deletions

View File

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

View File

@ -12,13 +12,14 @@
Name: librepo Name: librepo
Version: 1.14.0 Version: 1.14.0
Release: 3%{?dist} Release: 4%{?dist}
Summary: Repodata downloading library Summary: Repodata downloading library
License: LGPLv2+ License: LGPLv2+
URL: https://github.com/rpm-software-management/librepo URL: https://github.com/rpm-software-management/librepo
Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
Patch1: 0001-Replace-python3-flask-with-httpserver-in-python-tests.patch Patch1: 0001-Replace-python3-flask-with-httpserver-in-python-tests.patch
Patch2: 0002-Recover-from-fsync-fail-on-read-only-filesystem-RhBu.patch
BuildRequires: cmake BuildRequires: cmake
BuildRequires: gcc BuildRequires: gcc
@ -97,6 +98,9 @@ Python 3 bindings for the librepo library.
%{python3_sitearch}/%{name}/ %{python3_sitearch}/%{name}/
%changelog %changelog
* Tue Jul 13 2021 Marek Blaha <mblaha@redhat.com> - 1.14.0-4
- Recover from fsync fail on read-only filesystem (RhBug:1981194)
* Wed Jun 16 2021 Mohan Boddu <mboddu@redhat.com> - 1.14.0-3 * Wed Jun 16 2021 Mohan Boddu <mboddu@redhat.com> - 1.14.0-3
- Rebuilt for RHEL 9 BETA for openssl 3.0 - Rebuilt for RHEL 9 BETA for openssl 3.0
Related: rhbz#1971065 Related: rhbz#1971065