Try to patch fstrim so it works in Koji/Rawhide.

This commit is contained in:
Richard W.M. Jones 2014-03-14 10:13:49 +00:00
parent 931f6bd829
commit c28e621afd
3 changed files with 85 additions and 1 deletions

View File

@ -0,0 +1,49 @@
From 9b883d3c3ec0ff93bbea776572afb54d2a9b3524 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 14 Mar 2014 09:15:49 +0000
Subject: [PATCH 1/2] tests/discard: Ensure a significant number of blocks are
freed up on the host.
It's reasonable to expect megabytes will be freed up and given back to
the host. Previously we just tested that at least 1 block was
released. This test checks that at least 1000 blocks are released
(since stat(2) returns blocks of 512 bytes: 512 bytes * 1000 = approx 0.5 MB).
---
tests/discard/test-blkdiscard.pl | 2 +-
tests/discard/test-discard.pl | 2 +-
tests/discard/test-fstrim.pl | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/discard/test-blkdiscard.pl b/tests/discard/test-blkdiscard.pl
index 77b72b9..e080350 100755
--- a/tests/discard/test-blkdiscard.pl
+++ b/tests/discard/test-blkdiscard.pl
@@ -114,4 +114,4 @@ my $trimmed_size = (stat ($disk))[12];
print "trimmed size:\t$trimmed_size (blocks)\n";
die "$0: looks like the blkdiscard operation did not work\n"
- if $trimmed_size >= $full_size;
+ if $full_size - $trimmed_size < 1000;
diff --git a/tests/discard/test-discard.pl b/tests/discard/test-discard.pl
index 3f350b3..5e2f879 100755
--- a/tests/discard/test-discard.pl
+++ b/tests/discard/test-discard.pl
@@ -114,4 +114,4 @@ print "trimmed size:\t$trimmed_size (blocks)\n";
#system "du -sh $disk";
die "$0: looks like the -o discard mount option did not work\n"
- if $trimmed_size >= $full_size;
+ if $full_size - $trimmed_size < 1000;
diff --git a/tests/discard/test-fstrim.pl b/tests/discard/test-fstrim.pl
index 54451b8..30bb855 100755
--- a/tests/discard/test-fstrim.pl
+++ b/tests/discard/test-fstrim.pl
@@ -122,4 +122,4 @@ print "trimmed size:\t$trimmed_size (blocks)\n";
#system "du -sh $disk";
die "$0: looks like the fstrim operation did not work\n"
- if $trimmed_size >= $full_size;
+ if $full_size - $trimmed_size < 1000;
--
1.8.5.3

View File

@ -0,0 +1,26 @@
From accf1b66aa835714690a2979e990c49243875dab Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 14 Mar 2014 10:09:47 +0000
Subject: [PATCH 2/2] tests: fstrim: Remount the disk.
This makes fstrim work. It's not clear why exactly.
---
tests/discard/test-fstrim.pl | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/discard/test-fstrim.pl b/tests/discard/test-fstrim.pl
index 30bb855..cec853f 100755
--- a/tests/discard/test-fstrim.pl
+++ b/tests/discard/test-fstrim.pl
@@ -113,6 +113,8 @@ die "$0: surprising result: full size <= original size\n"
# Remove the file and then try to trim the filesystem.
$g->rm ("/data");
+$g->umount ("/");
+$g->mount_options ("nodiscard", "/dev/sda", "/");
$g->fstrim ("/");
$g->sync ();
$g->close ();
--
1.8.5.3

View File

@ -20,13 +20,16 @@ Summary: Access and modify virtual machine disk images
Name: libguestfs
Epoch: 1
Version: 1.25.44
Release: 1%{?dist}
Release: 2%{?dist}
License: LGPLv2+
# Source and patches.
URL: http://libguestfs.org/
Source0: http://libguestfs.org/download/1.25-development/%{name}-%{version}.tar.gz
Patch1: 0001-tests-discard-Ensure-a-significant-number-of-blocks-.patch
Patch2: 0002-tests-fstrim-Remount-the-disk.patch
# Basic build requirements:
BuildRequires: perl(Pod::Simple)
BuildRequires: perl(Pod::Man)
@ -670,6 +673,9 @@ for %{name}.
%prep
%setup -q
%patch1 -p1
%patch2 -p1
if [ "$(getenforce | tr '[A-Z]' '[a-z]')" != "disabled" ]; then
# For sVirt to work, the local temporary directory we use in the
# tests must be labelled the same way as /tmp.
@ -1133,6 +1139,9 @@ mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/run/libguestfs
%changelog
* Fri Mar 14 2014 Richard W.M. Jones <rjones@redhat.com> - 1:1.25.44-2
- Try to patch fstrim so it works in Koji/Rawhide.
* Thu Mar 13 2014 Richard W.M. Jones <rjones@redhat.com> - 1:1.25.44-1
- New upstream version 1.25.44.