|
|
c401cc |
From 30b3be8f6ae6ba406166b75376c7edf54a9493c8 Mon Sep 17 00:00:00 2001
|
|
|
c401cc |
Message-Id: <30b3be8f6ae6ba406166b75376c7edf54a9493c8@dist-git>
|
|
|
c401cc |
From: Eric Blake <eblake@redhat.com>
|
|
|
c401cc |
Date: Wed, 26 Feb 2014 14:54:26 +0100
|
|
|
c401cc |
Subject: [PATCH] storage: improve allocation stats reported on gluster files
|
|
|
c401cc |
|
|
|
c401cc |
https://bugzilla.redhat.com/show_bug.cgi?id=1032370
|
|
|
c401cc |
|
|
|
c401cc |
We already had code for handling allocation different than
|
|
|
c401cc |
capacity for sparse files; we just had to wire it up to be
|
|
|
c401cc |
used when inspecting gluster images.
|
|
|
c401cc |
|
|
|
c401cc |
* src/storage/storage_backend.c
|
|
|
c401cc |
(virStorageBackendUpdateVolTargetInfoFD): Handle no fd.
|
|
|
c401cc |
* src/storage/storage_backend_gluster.c
|
|
|
c401cc |
(virStorageBackendGlusterRefreshVol): Handle sparse files.
|
|
|
c401cc |
|
|
|
c401cc |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
c401cc |
(cherry picked from commit 13e738cc0a02db47f8b1958759699b5b06b4d647)
|
|
|
c401cc |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c401cc |
---
|
|
|
c401cc |
src/storage/storage_backend.c | 8 ++++----
|
|
|
c401cc |
src/storage/storage_backend_gluster.c | 7 ++++++-
|
|
|
c401cc |
2 files changed, 10 insertions(+), 5 deletions(-)
|
|
|
c401cc |
|
|
|
c401cc |
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
|
|
|
c401cc |
index d19c250..086642c 100644
|
|
|
c401cc |
--- a/src/storage/storage_backend.c
|
|
|
c401cc |
+++ b/src/storage/storage_backend.c
|
|
|
c401cc |
@@ -1264,9 +1264,9 @@ int virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
|
|
|
c401cc |
|
|
|
c401cc |
/*
|
|
|
c401cc |
* virStorageBackendUpdateVolTargetInfoFD:
|
|
|
c401cc |
- * @conn: connection to report errors on
|
|
|
c401cc |
* @target: target definition ptr of volume to update
|
|
|
c401cc |
- * @fd: fd of storage volume to update, via virStorageBackendOpenVol*
|
|
|
c401cc |
+ * @fd: fd of storage volume to update, via virStorageBackendOpenVol*, or -1
|
|
|
c401cc |
+ * @sb: details about file (must match @fd, if that is provided)
|
|
|
c401cc |
* @allocation: If not NULL, updated allocation information will be stored
|
|
|
c401cc |
* @capacity: If not NULL, updated capacity info will be stored
|
|
|
c401cc |
*
|
|
|
c401cc |
@@ -1308,7 +1308,7 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target,
|
|
|
c401cc |
if (capacity)
|
|
|
c401cc |
*capacity = 0;
|
|
|
c401cc |
|
|
|
c401cc |
- } else {
|
|
|
c401cc |
+ } else if (fd >= 0) {
|
|
|
c401cc |
off_t end;
|
|
|
c401cc |
/* XXX this is POSIX compliant, but doesn't work for CHAR files,
|
|
|
c401cc |
* only BLOCK. There is a Linux specific ioctl() for getting
|
|
|
c401cc |
@@ -1343,7 +1343,7 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target,
|
|
|
c401cc |
|
|
|
c401cc |
#if WITH_SELINUX
|
|
|
c401cc |
/* XXX: make this a security driver call */
|
|
|
c401cc |
- if (fgetfilecon_raw(fd, &filecon) == -1) {
|
|
|
c401cc |
+ if (fd >= 0 && fgetfilecon_raw(fd, &filecon) == -1) {
|
|
|
c401cc |
if (errno != ENODATA && errno != ENOTSUP) {
|
|
|
c401cc |
virReportSystemError(errno,
|
|
|
c401cc |
_("cannot get file context of '%s'"),
|
|
|
c401cc |
diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
|
|
|
c401cc |
index 3f4e9f7..685ad57 100644
|
|
|
c401cc |
--- a/src/storage/storage_backend_gluster.c
|
|
|
c401cc |
+++ b/src/storage/storage_backend_gluster.c
|
|
|
c401cc |
@@ -168,6 +168,12 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
|
|
|
c401cc |
|
|
|
c401cc |
if (VIR_ALLOC(vol) < 0)
|
|
|
c401cc |
goto cleanup;
|
|
|
c401cc |
+
|
|
|
c401cc |
+ if (virStorageBackendUpdateVolTargetInfoFD(&vol->target, -1, st,
|
|
|
c401cc |
+ &vol->allocation,
|
|
|
c401cc |
+ &vol->capacity) < 0)
|
|
|
c401cc |
+ goto cleanup;
|
|
|
c401cc |
+
|
|
|
c401cc |
if (VIR_STRDUP(vol->name, name) < 0)
|
|
|
c401cc |
goto cleanup;
|
|
|
c401cc |
if (virAsprintf(&vol->key, "%s%s%s", state->volname, state->dir,
|
|
|
c401cc |
@@ -194,7 +200,6 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
|
|
|
c401cc |
/* FIXME - must open files to determine if they are non-raw */
|
|
|
c401cc |
vol->type = VIR_STORAGE_VOL_NETWORK;
|
|
|
c401cc |
vol->target.format = VIR_STORAGE_FILE_RAW;
|
|
|
c401cc |
- vol->capacity = vol->allocation = st->st_size;
|
|
|
c401cc |
|
|
|
c401cc |
*volptr = vol;
|
|
|
c401cc |
vol = NULL;
|
|
|
c401cc |
--
|
|
|
c401cc |
1.9.0
|
|
|
c401cc |
|