[libvirt] [PATCH 7/9] Revert "Restore skipping of setting capacity"

Ján Tomko jtomko at redhat.com
Thu Feb 19 14:59:15 UTC 2015


This reverts commit f1856eb622fde2e6c3a6a932d1dded7f1691d205.

Now that we can update capacity from image metadata,
we don't need to skip the update.
---
 src/storage/storage_backend.c         | 20 +++++---------------
 src/storage/storage_backend.h         |  5 +----
 src/storage/storage_backend_disk.c    |  4 ++--
 src/storage/storage_backend_fs.c      | 10 ++++------
 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, 16 insertions(+), 31 deletions(-)

diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 8471744..ea5cabe 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -1508,7 +1508,6 @@ virStorageBackendVolOpen(const char *path, struct stat *sb,
 
 int
 virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
-                                     bool updateCapacity,
                                      bool withBlockVolFormat,
                                      unsigned int openflags)
 {
@@ -1522,8 +1521,7 @@ virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
         goto cleanup;
     fd = ret;
 
-    if ((ret = virStorageBackendUpdateVolTargetInfoFD(target, fd, &sb,
-                                                      updateCapacity)) < 0)
+    if ((ret = virStorageBackendUpdateVolTargetInfoFD(target, fd, &sb)) < 0)
         goto cleanup;
 
     if (target->type == VIR_STORAGE_VOL_FILE &&
@@ -1566,21 +1564,18 @@ virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
 
 int
 virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
-                               bool updateCapacity,
                                bool withBlockVolFormat,
                                unsigned int openflags)
 {
     int ret;
 
     if ((ret = virStorageBackendUpdateVolTargetInfo(&vol->target,
-                                                    updateCapacity,
                                                     withBlockVolFormat,
                                                     openflags)) < 0)
         return ret;
 
     if (vol->target.backingStore &&
         (ret = virStorageBackendUpdateVolTargetInfo(vol->target.backingStore,
-                                                    updateCapacity,
                                                     withBlockVolFormat,
                                                     VIR_STORAGE_VOL_OPEN_DEFAULT |
                                                     VIR_STORAGE_VOL_OPEN_NOERROR) < 0))
@@ -1594,15 +1589,13 @@ 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)
- * @updateCapacity: If true, updated capacity info will be stored
  *
  * Returns 0 for success, -1 on a legitimate error condition.
  */
 int
 virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
                                        int fd,
-                                       struct stat *sb,
-                                       bool updateCapacity)
+                                       struct stat *sb)
 {
 #if WITH_SELINUX
     security_context_t filecon = NULL;
@@ -1618,12 +1611,10 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
         /* Regular files may be sparse, so logical size (capacity) is not same
          * as actual allocation above
          */
-        if (updateCapacity)
-            target->capacity = sb->st_size;
+        target->capacity = sb->st_size;
     } else if (S_ISDIR(sb->st_mode)) {
         target->allocation = 0;
-        if (updateCapacity)
-            target->capacity = 0;
+        target->capacity = 0;
     } else if (fd >= 0) {
         off_t end;
         /* XXX this is POSIX compliant, but doesn't work for CHAR files,
@@ -1639,8 +1630,7 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
             return -1;
         }
         target->allocation = end;
-        if (updateCapacity)
-            target->capacity = end;
+        target->capacity = end;
     }
 
     if (!target->perms && VIR_ALLOC(target->perms) < 0)
diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h
index a93df5d..9f1db60 100644
--- a/src/storage/storage_backend.h
+++ b/src/storage/storage_backend.h
@@ -179,17 +179,14 @@ int virStorageBackendVolOpen(const char *path, struct stat *sb,
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
 
 int virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
-                                   bool updateCapacity,
                                    bool withBlockVolFormat,
                                    unsigned int openflags);
 int virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
-                                         bool updateCapacity,
                                          bool withBlockVolFormat,
                                          unsigned int openflags);
 int virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
                                            int fd,
-                                           struct stat *sb,
-                                           bool updateCapacity);
+                                           struct stat *sb);
 
 char *virStorageBackendStablePath(virStoragePoolObjPtr pool,
                                   const char *devpath,
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index 9f4d76a..f62b23e 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -152,14 +152,14 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr pool,
      * -1 was returned indicating some other error than an open error.
      */
     if (vol->source.partType == VIR_STORAGE_VOL_DISK_TYPE_EXTENDED) {
-        if (virStorageBackendUpdateVolInfo(vol, true, false,
+        if (virStorageBackendUpdateVolInfo(vol, false,
                                            VIR_STORAGE_VOL_OPEN_DEFAULT |
                                            VIR_STORAGE_VOL_OPEN_NOERROR) == -1)
             return -1;
         vol->target.allocation = vol->target.capacity =
             (vol->source.extents[0].end - vol->source.extents[0].start);
     } else {
-        if (virStorageBackendUpdateVolInfo(vol, true, false,
+        if (virStorageBackendUpdateVolInfo(vol, false,
                                            VIR_STORAGE_VOL_OPEN_DEFAULT) < 0)
             return -1;
     }
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 2af5dd7..77d894c 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, true) < 0)
+    if (virStorageBackendUpdateVolTargetInfoFD(target, fd, &sb) < 0)
         goto cleanup;
 
     if (S_ISDIR(sb.st_mode)) {
@@ -902,7 +902,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED,
 
         if (vol->target.backingStore) {
             ignore_value(virStorageBackendUpdateVolTargetInfo(vol->target.backingStore,
-                                                              true, false,
+                                                              false,
                                                               VIR_STORAGE_VOL_OPEN_DEFAULT));
             /* If this failed, the backing file is currently unavailable,
              * the capacity, allocation, owner, group and mode are unknown.
@@ -1183,10 +1183,8 @@ virStorageBackendFileSystemVolRefresh(virConnectPtr conn,
 {
     int ret;
 
-    /* Refresh allocation / permissions info in case its changed
-     * don't update the capacity value for this pass
-     */
-    ret = virStorageBackendUpdateVolInfo(vol, false, false,
+    /* Refresh allocation / capacity / permissions info in case its changed */
+    ret = virStorageBackendUpdateVolInfo(vol, false,
                                          VIR_STORAGE_VOL_FS_OPEN_FLAGS);
     if (ret < 0)
         return ret;
diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
index 53e4632..d2e79bc 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, true) < 0)
+    if (virStorageBackendUpdateVolTargetInfoFD(&vol->target, -1, st) < 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 8aa68a6..7ba8ded 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -161,7 +161,7 @@ virStorageBackendLogicalMakeVol(char **const groups,
     if (!vol->key && VIR_STRDUP(vol->key, groups[2]) < 0)
         goto cleanup;
 
-    if (virStorageBackendUpdateVolInfo(vol, true, false,
+    if (virStorageBackendUpdateVolInfo(vol, false,
                                        VIR_STORAGE_VOL_OPEN_DEFAULT) < 0)
         goto cleanup;
 
diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_backend_mpath.c
index b67dc2a..44bcd60 100644
--- a/src/storage/storage_backend_mpath.c
+++ b/src/storage/storage_backend_mpath.c
@@ -60,7 +60,7 @@ virStorageBackendMpathNewVol(virStoragePoolObjPtr pool,
     if (virAsprintf(&vol->target.path, "/dev/%s", dev) < 0)
         goto cleanup;
 
-    if (virStorageBackendUpdateVolInfo(vol, true, true,
+    if (virStorageBackendUpdateVolInfo(vol, true,
                                        VIR_STORAGE_VOL_OPEN_DEFAULT) < 0) {
         goto cleanup;
     }
diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
index c4879b0..58e7e6d 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -206,7 +206,7 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
         goto free_vol;
     }
 
-    if (virStorageBackendUpdateVolInfo(vol, true, true,
+    if (virStorageBackendUpdateVolInfo(vol, true,
                                        VIR_STORAGE_VOL_OPEN_DEFAULT) < 0) {
         retval = -1;
         goto free_vol;
-- 
2.0.5




More information about the libvir-list mailing list