[PATCH v2 1/5] storage: Add readflags for backend error processing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Similar to the openflags which allow VIR_STORAGE_VOL_OPEN_NOERROR to be
passed to avoid open errors, add a 'readflags' variable so that in the
future various read failures could also be ignored.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/storage/storage_backend.c         | 24 ++++++++++++++++--------
 src/storage/storage_backend.h         |  9 ++++++---
 src/storage/storage_backend_disk.c    |  5 +++--
 src/storage/storage_backend_fs.c      |  8 ++++----
 src/storage/storage_backend_gluster.c |  2 +-
 src/storage/storage_backend_logical.c |  2 +-
 src/storage/storage_backend_mpath.c   |  2 +-
 src/storage/storage_backend_scsi.c    |  2 +-
 8 files changed, 33 insertions(+), 21 deletions(-)

diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 194736b..38ef9fc 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -1391,7 +1391,8 @@ static struct diskType const disk_types[] = {
 
 static int
 virStorageBackendDetectBlockVolFormatFD(virStorageSourcePtr target,
-                                        int fd)
+                                        int fd,
+                                        unsigned int readflags ATTRIBUTE_UNUSED)
 {
     size_t i;
     off_t start;
@@ -1580,7 +1581,8 @@ virStorageBackendVolOpen(const char *path, struct stat *sb,
 int
 virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
                                      bool withBlockVolFormat,
-                                     unsigned int openflags)
+                                     unsigned int openflags,
+                                     unsigned int readflags)
 {
     int ret, fd = -1;
     struct stat sb;
@@ -1592,7 +1594,8 @@ virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
         goto cleanup;
     fd = ret;
 
-    if ((ret = virStorageBackendUpdateVolTargetInfoFD(target, fd, &sb)) < 0)
+    if ((ret = virStorageBackendUpdateVolTargetInfoFD(target, fd, &sb,
+                                                      readflags)) < 0)
         goto cleanup;
 
     if (target->type == VIR_STORAGE_VOL_FILE &&
@@ -1622,7 +1625,8 @@ virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
     }
 
     if (withBlockVolFormat) {
-        if ((ret = virStorageBackendDetectBlockVolFormatFD(target, fd)) < 0)
+        if ((ret = virStorageBackendDetectBlockVolFormatFD(target, fd,
+                                                           readflags)) < 0)
             goto cleanup;
     }
 
@@ -1636,20 +1640,22 @@ virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
 int
 virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
                                bool withBlockVolFormat,
-                               unsigned int openflags)
+                               unsigned int openflags,
+                               unsigned int readflags)
 {
     int ret;
 
     if ((ret = virStorageBackendUpdateVolTargetInfo(&vol->target,
                                                     withBlockVolFormat,
-                                                    openflags)) < 0)
+                                                    openflags, readflags)) < 0)
         return ret;
 
     if (vol->target.backingStore &&
         (ret = virStorageBackendUpdateVolTargetInfo(vol->target.backingStore,
                                                     withBlockVolFormat,
                                                     VIR_STORAGE_VOL_OPEN_DEFAULT |
-                                                    VIR_STORAGE_VOL_OPEN_NOERROR) < 0))
+                                                    VIR_STORAGE_VOL_OPEN_NOERROR,
+                                                    readflags) < 0))
         return ret;
 
     return 0;
@@ -1660,13 +1666,15 @@ virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
  * @target: target definition ptr of volume to update
  * @fd: fd of storage volume to update, via virStorageBackendOpenVol*, or -1
  * @sb: details about file (must match @fd, if that is provided)
+ * @readflags: unused
  *
  * Returns 0 for success, -1 on a legitimate error condition.
  */
 int
 virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
                                        int fd,
-                                       struct stat *sb)
+                                       struct stat *sb,
+                                       unsigned int readflags ATTRIBUTE_UNUSED)
 {
 #if WITH_SELINUX
     security_context_t filecon = NULL;
diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h
index 96b5f39..aa9008e 100644
--- a/src/storage/storage_backend.h
+++ b/src/storage/storage_backend.h
@@ -192,13 +192,16 @@ int virStorageBackendVolOpen(const char *path, struct stat *sb,
 
 int virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
                                    bool withBlockVolFormat,
-                                   unsigned int openflags);
+                                   unsigned int openflags,
+                                   unsigned int readflags);
 int virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
                                          bool withBlockVolFormat,
-                                         unsigned int openflags);
+                                         unsigned int openflags,
+                                         unsigned int readflags);
 int virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
                                            int fd,
-                                           struct stat *sb);
+                                           struct stat *sb,
+                                           unsigned int readflags);
 
 bool virStorageBackendPoolPathIsStable(const char *path);
 char *virStorageBackendStablePath(virStoragePoolObjPtr pool,
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index 7baecc1..a83e340 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -154,14 +154,15 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr pool,
     if (vol->source.partType == VIR_STORAGE_VOL_DISK_TYPE_EXTENDED) {
         if (virStorageBackendUpdateVolInfo(vol, false,
                                            VIR_STORAGE_VOL_OPEN_DEFAULT |
-                                           VIR_STORAGE_VOL_OPEN_NOERROR) == -1)
+                                           VIR_STORAGE_VOL_OPEN_NOERROR,
+                                           0) == -1)
             return -1;
         vol->target.allocation = 0;
         vol->target.capacity =
             (vol->source.extents[0].end - vol->source.extents[0].start);
     } else {
         if (virStorageBackendUpdateVolInfo(vol, false,
-                                           VIR_STORAGE_VOL_OPEN_DEFAULT) < 0)
+                                           VIR_STORAGE_VOL_OPEN_DEFAULT, 0) < 0)
             return -1;
     }
 
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 99ea394..38c7805 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -80,7 +80,7 @@ virStorageBackendProbeTarget(virStorageSourcePtr target,
         return rc; /* Take care to propagate rc, it is not always -1 */
     fd = rc;
 
-    if (virStorageBackendUpdateVolTargetInfoFD(target, fd, &sb) < 0)
+    if (virStorageBackendUpdateVolTargetInfoFD(target, fd, &sb, 0) < 0)
         goto cleanup;
 
     if (S_ISDIR(sb.st_mode)) {
@@ -921,7 +921,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED,
         if (vol->target.backingStore) {
             ignore_value(virStorageBackendUpdateVolTargetInfo(vol->target.backingStore,
                                                               false,
-                                                              VIR_STORAGE_VOL_OPEN_DEFAULT));
+                                                              VIR_STORAGE_VOL_OPEN_DEFAULT, 0));
             /* If this failed, the backing file is currently unavailable,
              * the capacity, allocation, owner, group and mode are unknown.
              * An error message was raised, but we just continue. */
@@ -953,7 +953,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (virStorageBackendUpdateVolTargetInfoFD(target, fd, &statbuf) < 0)
+    if (virStorageBackendUpdateVolTargetInfoFD(target, fd, &statbuf, 0) < 0)
         goto cleanup;
 
     /* VolTargetInfoFD doesn't update capacity correctly for the pool case */
@@ -1245,7 +1245,7 @@ virStorageBackendFileSystemVolRefresh(virConnectPtr conn,
 
     /* Refresh allocation / capacity / permissions info in case its changed */
     ret = virStorageBackendUpdateVolInfo(vol, false,
-                                         VIR_STORAGE_VOL_FS_OPEN_FLAGS);
+                                         VIR_STORAGE_VOL_FS_OPEN_FLAGS, 0);
     if (ret < 0)
         return ret;
 
diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
index d2e79bc..b40db27 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -268,7 +268,7 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
     if (VIR_ALLOC(vol) < 0)
         goto cleanup;
 
-    if (virStorageBackendUpdateVolTargetInfoFD(&vol->target, -1, st) < 0)
+    if (virStorageBackendUpdateVolTargetInfoFD(&vol->target, -1, st, 0) < 0)
         goto cleanup;
 
     if (virStorageBackendGlusterSetMetadata(state, vol, name) < 0)
diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
index 536e617..96bc4c6 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -162,7 +162,7 @@ virStorageBackendLogicalMakeVol(char **const groups,
         goto cleanup;
 
     if (virStorageBackendUpdateVolInfo(vol, false,
-                                       VIR_STORAGE_VOL_OPEN_DEFAULT) < 0)
+                                       VIR_STORAGE_VOL_OPEN_DEFAULT, 0) < 0)
         goto cleanup;
 
     nextents = 1;
diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_backend_mpath.c
index ca9a62f..b5b4bb6 100644
--- a/src/storage/storage_backend_mpath.c
+++ b/src/storage/storage_backend_mpath.c
@@ -61,7 +61,7 @@ virStorageBackendMpathNewVol(virStoragePoolObjPtr pool,
         goto cleanup;
 
     if (virStorageBackendUpdateVolInfo(vol, true,
-                                       VIR_STORAGE_VOL_OPEN_DEFAULT) < 0) {
+                                       VIR_STORAGE_VOL_OPEN_DEFAULT, 0) < 0) {
         goto cleanup;
     }
 
diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
index 7dd7674..cc2c5d7 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -225,7 +225,7 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
     }
 
     if (virStorageBackendUpdateVolInfo(vol, true,
-                                       VIR_STORAGE_VOL_OPEN_DEFAULT) < 0)
+                                       VIR_STORAGE_VOL_OPEN_DEFAULT, 0) < 0)
         goto cleanup;
 
     if (!(vol->key = virStorageBackendSCSISerial(vol->target.path)))
-- 
2.5.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]