thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-virtiofsd-passthrough_ll-cleanup-getxattr-listxattr.patch

ddf19c
From f93ea308351cbe2630d7ecf637c3b69894d84a11 Mon Sep 17 00:00:00 2001
ddf19c
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
ddf19c
Date: Tue, 3 Mar 2020 18:43:13 +0000
ddf19c
Subject: [PATCH 17/18] virtiofsd: passthrough_ll: cleanup getxattr/listxattr
ddf19c
MIME-Version: 1.0
ddf19c
Content-Type: text/plain; charset=UTF-8
ddf19c
Content-Transfer-Encoding: 8bit
ddf19c
ddf19c
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
ddf19c
Message-id: <20200303184314.155564-7-dgilbert@redhat.com>
ddf19c
Patchwork-id: 94125
ddf19c
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH 6/7] virtiofsd: passthrough_ll: cleanup getxattr/listxattr
ddf19c
Bugzilla: 1797064
ddf19c
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ddf19c
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
ddf19c
RH-Acked-by: Ján Tomko <jtomko@redhat.com>
ddf19c
ddf19c
From: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
ddf19c
ddf19c
This is a cleanup patch to simplify the following xattr fix and
ddf19c
there is no functional changes.
ddf19c
ddf19c
- Move memory allocation to head of the function
ddf19c
- Unify fgetxattr/flistxattr call for both size == 0 and
ddf19c
  size != 0 case
ddf19c
- Remove redundant lo_inode_put call in error path
ddf19c
  (Note: second call is ignored now since @inode is already NULL)
ddf19c
ddf19c
Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
ddf19c
Message-Id: <20200227055927.24566-2-misono.tomohiro@jp.fujitsu.com>
ddf19c
Acked-by: Vivek Goyal <vgoyal@redhat.com>
ddf19c
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
ddf19c
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
ddf19c
(cherry picked from commit 16e15a73089102c3d8846792d514e769300fcc3c)
ddf19c
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ddf19c
---
ddf19c
 tools/virtiofsd/passthrough_ll.c | 54 ++++++++++++++++------------------------
ddf19c
 1 file changed, 22 insertions(+), 32 deletions(-)
ddf19c
ddf19c
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
ddf19c
index c635fc8..50c7273 100644
ddf19c
--- a/tools/virtiofsd/passthrough_ll.c
ddf19c
+++ b/tools/virtiofsd/passthrough_ll.c
ddf19c
@@ -2199,34 +2199,30 @@ static void lo_getxattr(fuse_req_t req, fuse_ino_t ino, const char *name,
ddf19c
         goto out;
ddf19c
     }
ddf19c
 
ddf19c
+    if (size) {
ddf19c
+        value = malloc(size);
ddf19c
+        if (!value) {
ddf19c
+            goto out_err;
ddf19c
+        }
ddf19c
+    }
ddf19c
+
ddf19c
     sprintf(procname, "%i", inode->fd);
ddf19c
     fd = openat(lo->proc_self_fd, procname, O_RDONLY);
ddf19c
     if (fd < 0) {
ddf19c
         goto out_err;
ddf19c
     }
ddf19c
 
ddf19c
+    ret = fgetxattr(fd, name, value, size);
ddf19c
+    if (ret == -1) {
ddf19c
+        goto out_err;
ddf19c
+    }
ddf19c
     if (size) {
ddf19c
-        value = malloc(size);
ddf19c
-        if (!value) {
ddf19c
-            goto out_err;
ddf19c
-        }
ddf19c
-
ddf19c
-        ret = fgetxattr(fd, name, value, size);
ddf19c
-        if (ret == -1) {
ddf19c
-            goto out_err;
ddf19c
-        }
ddf19c
         saverr = 0;
ddf19c
         if (ret == 0) {
ddf19c
             goto out;
ddf19c
         }
ddf19c
-
ddf19c
         fuse_reply_buf(req, value, ret);
ddf19c
     } else {
ddf19c
-        ret = fgetxattr(fd, name, NULL, 0);
ddf19c
-        if (ret == -1) {
ddf19c
-            goto out_err;
ddf19c
-        }
ddf19c
-
ddf19c
         fuse_reply_xattr(req, ret);
ddf19c
     }
ddf19c
 out_free:
ddf19c
@@ -2242,7 +2238,6 @@ out_free:
ddf19c
 out_err:
ddf19c
     saverr = errno;
ddf19c
 out:
ddf19c
-    lo_inode_put(lo, &inode;;
ddf19c
     fuse_reply_err(req, saverr);
ddf19c
     goto out_free;
ddf19c
 }
ddf19c
@@ -2277,34 +2272,30 @@ static void lo_listxattr(fuse_req_t req, fuse_ino_t ino, size_t size)
ddf19c
         goto out;
ddf19c
     }
ddf19c
 
ddf19c
+    if (size) {
ddf19c
+        value = malloc(size);
ddf19c
+        if (!value) {
ddf19c
+            goto out_err;
ddf19c
+        }
ddf19c
+    }
ddf19c
+
ddf19c
     sprintf(procname, "%i", inode->fd);
ddf19c
     fd = openat(lo->proc_self_fd, procname, O_RDONLY);
ddf19c
     if (fd < 0) {
ddf19c
         goto out_err;
ddf19c
     }
ddf19c
 
ddf19c
+    ret = flistxattr(fd, value, size);
ddf19c
+    if (ret == -1) {
ddf19c
+        goto out_err;
ddf19c
+    }
ddf19c
     if (size) {
ddf19c
-        value = malloc(size);
ddf19c
-        if (!value) {
ddf19c
-            goto out_err;
ddf19c
-        }
ddf19c
-
ddf19c
-        ret = flistxattr(fd, value, size);
ddf19c
-        if (ret == -1) {
ddf19c
-            goto out_err;
ddf19c
-        }
ddf19c
         saverr = 0;
ddf19c
         if (ret == 0) {
ddf19c
             goto out;
ddf19c
         }
ddf19c
-
ddf19c
         fuse_reply_buf(req, value, ret);
ddf19c
     } else {
ddf19c
-        ret = flistxattr(fd, NULL, 0);
ddf19c
-        if (ret == -1) {
ddf19c
-            goto out_err;
ddf19c
-        }
ddf19c
-
ddf19c
         fuse_reply_xattr(req, ret);
ddf19c
     }
ddf19c
 out_free:
ddf19c
@@ -2320,7 +2311,6 @@ out_free:
ddf19c
 out_err:
ddf19c
     saverr = errno;
ddf19c
 out:
ddf19c
-    lo_inode_put(lo, &inode;;
ddf19c
     fuse_reply_err(req, saverr);
ddf19c
     goto out_free;
ddf19c
 }
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c