yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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