[Libguestfs] [PATCH 03/18] rhv-upload: Don't flush() in close()

Nir Soffer nirsof at gmail.com
Sun Nov 17 23:04:25 UTC 2019


Closing a file does not issue fsync() for the caller, and is also
unsafe if previous fsync() failed. Clients should issue flush() and
check the result.

In imageio logs we see that every upload ends with 3 flushes:

2019-11-09 20:07:48,223 INFO    (Thread-200) [images] [local] WRITE size=65536 offset=6442385408 flush=False ticket=a3981648-41b4-4b98-9937-6d42e7df1bfa
2019-11-09 20:07:48,228 INFO    (Thread-200) [images] [local] FLUSH ticket=a3981648-41b4-4b98-9937-6d42e7df1bfa
2019-11-09 20:07:48,229 INFO    (Thread-200) [images] [local] FLUSH ticket=a3981648-41b4-4b98-9937-6d42e7df1bfa
2019-11-09 20:07:48,231 INFO    (Thread-200) [images] [local] FLUSH ticket=a3981648-41b4-4b98-9937-6d42e7df1bfa
2019-11-09 20:07:48,233 INFO    (Thread-200) [http] CLOSE client=local [connection=17.320226/1, dispatch=13.651897/2151, operation=12.640790/2151, read=0.517585/1876, write=9.985399/1876, zero=0.652223/272, flush=0.000034/3]

Removing flush() in close() should remove one of the 3 flush calls, so
now we flush() only twice.
---
 v2v/rhv-upload-plugin.py | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py
index 472d483f2..fdb3f1021 100644
--- a/v2v/rhv-upload-plugin.py
+++ b/v2v/rhv-upload-plugin.py
@@ -513,11 +513,6 @@ def close(h):
         return
 
     try:
-        # Issue a flush request on close so that the data is written to
-        # persistent store before we create the VM.
-        if h['can_flush']:
-            flush(h)
-
         http.close()
 
         disk = h['disk']
-- 
2.21.0





More information about the Libguestfs mailing list