SHA256
1
0
forked from pool/libvirt

merge NOCOW patch from Chunyan

OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=366
This commit is contained in:
James Fehlig 2014-04-08 17:26:09 +00:00 committed by Git OBS Bridge
parent 52a7fec2c4
commit f8ebdc5158
3 changed files with 111 additions and 0 deletions

103
add-nocow-to-vol-xml.patch Normal file
View File

@ -0,0 +1,103 @@
Index: libvirt-1.2.3/docs/schemas/storagevol.rng
===================================================================
--- libvirt-1.2.3.orig/docs/schemas/storagevol.rng
+++ libvirt-1.2.3/docs/schemas/storagevol.rng
@@ -139,6 +139,11 @@
<ref name='compat'/>
</optional>
<optional>
+ <element name='nocow'>
+ <empty/>
+ </element>
+ </optional>
+ <optional>
<ref name='fileFormatFeatures'/>
</optional>
</interleave>
Index: libvirt-1.2.3/src/conf/storage_conf.c
===================================================================
--- libvirt-1.2.3.orig/src/conf/storage_conf.c
+++ libvirt-1.2.3/src/conf/storage_conf.c
@@ -1401,6 +1401,9 @@ virStorageVolDefParseXML(virStoragePoolD
virStringFreeList(version);
}
+ if (virXPathNode("./target/nocow", ctxt))
+ ret->target.nocow = true;
+
if (options->featureFromString && virXPathNode("./target/features", ctxt)) {
if ((n = virXPathNodeSet("./target/features/*", ctxt, &nodes)) < 0)
goto error;
Index: libvirt-1.2.3/src/conf/storage_conf.h
===================================================================
--- libvirt-1.2.3.orig/src/conf/storage_conf.h
+++ libvirt-1.2.3/src/conf/storage_conf.h
@@ -90,6 +90,7 @@ struct _virStorageVolTarget {
virStorageEncryptionPtr encryption;
virBitmapPtr features;
char *compat;
+ bool nocow;
};
typedef struct _virStorageVolDef virStorageVolDef;
Index: libvirt-1.2.3/src/storage/storage_backend.c
===================================================================
--- libvirt-1.2.3.orig/src/storage/storage_backend.c
+++ libvirt-1.2.3/src/storage/storage_backend.c
@@ -37,6 +37,9 @@
#ifdef __linux__
# include <sys/ioctl.h>
# include <linux/fs.h>
+# ifndef FS_NOCOW_FL
+# define FS_NOCOW_FL 0x00800000 /* Do not cow file */
+# endif
#endif
#if WITH_SELINUX
@@ -449,6 +452,21 @@ virStorageBackendCreateRaw(virConnectPtr
goto cleanup;
}
+ if (vol->target.nocow) {
+#ifdef __linux__
+ int attr;
+
+ /* Set NOCOW flag. This is an optimisation for btrfs.
+ * The FS_IOC_SETFLAGS ioctl return value will be ignored since any
+ * failure of this operation should not block the left work.
+ */
+ if (ioctl(fd, FS_IOC_GETFLAGS, &attr) == 0) {
+ attr |= FS_NOCOW_FL;
+ ioctl(fd, FS_IOC_SETFLAGS, &attr);
+ }
+#endif
+ }
+
if ((ret = createRawFile(fd, vol, inputvol)) < 0)
/* createRawFile already reported the exact error. */
ret = -1;
@@ -712,6 +730,7 @@ virStorageBackendCreateQemuImgOpts(char
bool preallocate,
int format,
const char *compat,
+ bool nocow,
virBitmapPtr features)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -724,6 +743,8 @@ virStorageBackendCreateQemuImgOpts(char
virBufferAddLit(&buf, "encryption=on,");
if (preallocate)
virBufferAddLit(&buf, "preallocation=metadata,");
+ if (nocow)
+ virBufferAddLit(&buf, "nocow=on,");
if (compat)
virBufferAsprintf(&buf, "compat=%s,", compat);
@@ -945,6 +966,7 @@ virStorageBackendCreateQemuImgCmd(virCon
do_encryption, preallocate,
vol->target.format,
compat,
+ vol->target.nocow,
vol->target.features) < 0) {
virCommandFree(cmd);
return NULL;

View File

@ -5,6 +5,12 @@ Tue Apr 8 09:44:50 MDT 2014 - jfehlig@suse.com
0e0c1a74-domid-fix.patch, 7a1452f5-libxl-empty-cdrom.patch
bnc#872517
-------------------------------------------------------------------
Mon Apr 7 14:34:59 CST 2014 - cyliu@suse.com
- Fate#315125: add NOCOW flag
add-nocow-to-vol-xml.patch
-------------------------------------------------------------------
Wed Apr 2 13:38:50 UTC 2014 - cbosdonnat@suse.com

View File

@ -434,6 +434,7 @@ Patch1: 7a1452f5-libxl-empty-cdrom.patch
Patch100: xen-name-for-devid.patch
Patch101: ia64-clone.patch
Patch102: xen-pv-cdrom.patch
Patch103: add-nocow-to-vol-xml.patch
# Our patches
Patch200: libvirtd-defaults.patch
Patch201: libvirtd-init-script.patch
@ -950,6 +951,7 @@ namespaces.
%patch100 -p1
%patch101 -p1
%patch102 -p1
%patch103 -p1
%patch200 -p1
%patch201 -p1
%patch202 -p1