|
|
c401cc |
From 35dd0575934117ccef069b751000fa8a1b7a67fd Mon Sep 17 00:00:00 2001
|
|
|
c401cc |
Message-Id: <35dd0575934117ccef069b751000fa8a1b7a67fd@dist-git>
|
|
|
c401cc |
From: Eric Blake <eblake@redhat.com>
|
|
|
c401cc |
Date: Wed, 26 Feb 2014 14:54:25 +0100
|
|
|
c401cc |
Subject: [PATCH] storage: improve directory support in gluster pool
|
|
|
c401cc |
|
|
|
c401cc |
https://bugzilla.redhat.com/show_bug.cgi?id=1032370
|
|
|
c401cc |
|
|
|
c401cc |
Take advantage of the previous patch's addition of 'netdir' as
|
|
|
c401cc |
a distinct volume type, to expose rather than silently skip
|
|
|
c401cc |
directories embedded in a gluster pool. Also serves as an XML
|
|
|
c401cc |
validation for the previous patch.
|
|
|
c401cc |
|
|
|
c401cc |
* src/storage/storage_backend_gluster.c
|
|
|
c401cc |
(virStorageBackendGlusterRefreshVol): Don't skip directories.
|
|
|
c401cc |
* tests/storagevolxml2xmltest.c (mymain): Add test.
|
|
|
c401cc |
* tests/storagevolxml2xmlin/vol-gluster-dir.xml: New file.
|
|
|
c401cc |
* tests/storagevolxml2xmlout/vol-gluster-dir.xml: Likewise.
|
|
|
c401cc |
|
|
|
c401cc |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
c401cc |
(cherry picked from commit 1458b2e963c65108f691f77ac10e6ff7d6805a39)
|
|
|
c401cc |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c401cc |
---
|
|
|
c401cc |
src/storage/storage_backend_gluster.c | 14 ++++++++++----
|
|
|
c401cc |
tests/storagevolxml2xmlin/vol-gluster-dir.xml | 12 ++++++++++++
|
|
|
c401cc |
tests/storagevolxml2xmlout/vol-gluster-dir.xml | 17 +++++++++++++++++
|
|
|
c401cc |
tests/storagevolxml2xmltest.c | 1 +
|
|
|
c401cc |
4 files changed, 40 insertions(+), 4 deletions(-)
|
|
|
c401cc |
create mode 100644 tests/storagevolxml2xmlin/vol-gluster-dir.xml
|
|
|
c401cc |
create mode 100644 tests/storagevolxml2xmlout/vol-gluster-dir.xml
|
|
|
c401cc |
|
|
|
c401cc |
diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
|
|
|
c401cc |
index d57427e..3f4e9f7 100644
|
|
|
c401cc |
--- a/src/storage/storage_backend_gluster.c
|
|
|
c401cc |
+++ b/src/storage/storage_backend_gluster.c
|
|
|
c401cc |
@@ -165,9 +165,6 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
|
|
|
c401cc |
/* Silently skip '.' and '..'. */
|
|
|
c401cc |
if (STREQ(name, ".") || STREQ(name, ".."))
|
|
|
c401cc |
return 0;
|
|
|
c401cc |
- /* FIXME: support directories. For now, silently skip them. */
|
|
|
c401cc |
- if (S_ISDIR(st->st_mode))
|
|
|
c401cc |
- return 0;
|
|
|
c401cc |
|
|
|
c401cc |
if (VIR_ALLOC(vol) < 0)
|
|
|
c401cc |
goto cleanup;
|
|
|
c401cc |
@@ -177,7 +174,6 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
|
|
|
c401cc |
vol->name) < 0)
|
|
|
c401cc |
goto cleanup;
|
|
|
c401cc |
|
|
|
c401cc |
- vol->type = VIR_STORAGE_VOL_NETWORK;
|
|
|
c401cc |
tmp = state->uri->path;
|
|
|
c401cc |
state->uri->path = vol->key;
|
|
|
c401cc |
if (!(vol->target.path = virURIFormat(state->uri))) {
|
|
|
c401cc |
@@ -186,7 +182,17 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
|
|
|
c401cc |
}
|
|
|
c401cc |
state->uri->path = tmp;
|
|
|
c401cc |
|
|
|
c401cc |
+ if (S_ISDIR(st->st_mode)) {
|
|
|
c401cc |
+ vol->type = VIR_STORAGE_VOL_NETDIR;
|
|
|
c401cc |
+ vol->target.format = VIR_STORAGE_FILE_DIR;
|
|
|
c401cc |
+ *volptr = vol;
|
|
|
c401cc |
+ vol = NULL;
|
|
|
c401cc |
+ ret = 0;
|
|
|
c401cc |
+ goto cleanup;
|
|
|
c401cc |
+ }
|
|
|
c401cc |
+
|
|
|
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 |
diff --git a/tests/storagevolxml2xmlin/vol-gluster-dir.xml b/tests/storagevolxml2xmlin/vol-gluster-dir.xml
|
|
|
c401cc |
new file mode 100644
|
|
|
c401cc |
index 0000000..208c2c2
|
|
|
c401cc |
--- /dev/null
|
|
|
c401cc |
+++ b/tests/storagevolxml2xmlin/vol-gluster-dir.xml
|
|
|
c401cc |
@@ -0,0 +1,12 @@
|
|
|
c401cc |
+<volume type='netdir'>
|
|
|
c401cc |
+ <name>dir</name>
|
|
|
c401cc |
+ <key>vol/dir</key>
|
|
|
c401cc |
+ <source>
|
|
|
c401cc |
+ </source>
|
|
|
c401cc |
+ <capacity unit='bytes'>0</capacity>
|
|
|
c401cc |
+ <allocation unit='bytes'>0</allocation>
|
|
|
c401cc |
+ <target>
|
|
|
c401cc |
+ <format type='dir'/>
|
|
|
c401cc |
+ <path>gluster://example.com/vol/dir</path>
|
|
|
c401cc |
+ </target>
|
|
|
c401cc |
+</volume>
|
|
|
c401cc |
diff --git a/tests/storagevolxml2xmlout/vol-gluster-dir.xml b/tests/storagevolxml2xmlout/vol-gluster-dir.xml
|
|
|
c401cc |
new file mode 100644
|
|
|
c401cc |
index 0000000..f188ceb
|
|
|
c401cc |
--- /dev/null
|
|
|
c401cc |
+++ b/tests/storagevolxml2xmlout/vol-gluster-dir.xml
|
|
|
c401cc |
@@ -0,0 +1,17 @@
|
|
|
c401cc |
+<volume type='netdir'>
|
|
|
c401cc |
+ <name>dir</name>
|
|
|
c401cc |
+ <key>vol/dir</key>
|
|
|
c401cc |
+ <source>
|
|
|
c401cc |
+ </source>
|
|
|
c401cc |
+ <capacity unit='bytes'>0</capacity>
|
|
|
c401cc |
+ <allocation unit='bytes'>0</allocation>
|
|
|
c401cc |
+ <target>
|
|
|
c401cc |
+ <path>gluster://example.com/vol/dir</path>
|
|
|
c401cc |
+ <format type='dir'/>
|
|
|
c401cc |
+ <permissions>
|
|
|
c401cc |
+ <mode>0600</mode>
|
|
|
c401cc |
+ <owner>4294967295</owner>
|
|
|
c401cc |
+ <group>4294967295</group>
|
|
|
c401cc |
+ </permissions>
|
|
|
c401cc |
+ </target>
|
|
|
c401cc |
+</volume>
|
|
|
c401cc |
diff --git a/tests/storagevolxml2xmltest.c b/tests/storagevolxml2xmltest.c
|
|
|
c401cc |
index d62c29f..f502e42 100644
|
|
|
c401cc |
--- a/tests/storagevolxml2xmltest.c
|
|
|
c401cc |
+++ b/tests/storagevolxml2xmltest.c
|
|
|
c401cc |
@@ -121,6 +121,7 @@ mymain(void)
|
|
|
c401cc |
DO_TEST("pool-logical", "vol-logical");
|
|
|
c401cc |
DO_TEST("pool-logical", "vol-logical-backing");
|
|
|
c401cc |
DO_TEST("pool-sheepdog", "vol-sheepdog");
|
|
|
c401cc |
+ DO_TEST("pool-gluster", "vol-gluster-dir");
|
|
|
c401cc |
|
|
|
c401cc |
return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
|
c401cc |
}
|
|
|
c401cc |
--
|
|
|
c401cc |
1.9.0
|
|
|
c401cc |
|