From nobody Thu Nov 13 22:13:55 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1582782722; cv=none; d=zohomail.com; s=zohoarc; b=inI81zzsndwxmC6DJAN5nLbrSVWAwvWPAHO+2npR2GlfzKa7J0A0vay6Mu0WMQmA2eYRk9HuhoAgHABzmJ/NbzvIflviSvu5qitJWniN8lQhugTfZflYdjVEKcBvTrlHY78rIXyOlaKZj0Wc3xV0il8BEX9FLXANyUwbid8b0/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582782722; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+F8xEGMLBDqWq3s3IXEYPAB3R5DbOgyKAXHtxeDZREM=; b=Z/jwNGsQQls1OKBsyync/2ADB7EQNAEnLm/dA+ba6pdWzcy48eoxyzRB6m/4ZhyINr6gK/NIMAW6WLKaWpE90id2FXwa+C6TKrevCCBNqPIY6nWW0Z1LOMyQX39fL8C2T+4SU4VzOIxTbgzV79lcPoHEb33eURyjO5NUFIhBEts= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582782722532386.9353442690815; Wed, 26 Feb 2020 21:52:02 -0800 (PST) Received: from localhost ([::1]:54154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7C5Z-0000G4-9P for importer@patchew.org; Thu, 27 Feb 2020 00:52:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40527) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7C4K-0007Sc-SN for qemu-devel@nongnu.org; Thu, 27 Feb 2020 00:50:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7C4J-0000uL-PL for qemu-devel@nongnu.org; Thu, 27 Feb 2020 00:50:44 -0500 Received: from mgwkm03.jp.fujitsu.com ([202.219.69.170]:32725) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7C4J-0000nu-32 for qemu-devel@nongnu.org; Thu, 27 Feb 2020 00:50:43 -0500 Received: from kw-mxoi1.gw.nic.fujitsu.com (unknown [192.168.231.131]) by mgwkm03.jp.fujitsu.com with smtp id 6d59_3f25_b7d26c65_e4e8_44c3_946d_499c04aabeb1; Thu, 27 Feb 2020 14:50:32 +0900 Received: from g01jpfmpwyt01.exch.g01.fujitsu.local (g01jpfmpwyt01.exch.g01.fujitsu.local [10.128.193.38]) by kw-mxoi1.gw.nic.fujitsu.com (Postfix) with ESMTP id C98D3AC009A for ; Thu, 27 Feb 2020 14:50:31 +0900 (JST) Received: from g01jpexchyt35.g01.fujitsu.local (unknown [10.128.193.4]) by g01jpfmpwyt01.exch.g01.fujitsu.local (Postfix) with ESMTP id CC59E6D6375; Thu, 27 Feb 2020 14:50:30 +0900 (JST) Received: from luna3.soft.fujitsu.com (10.124.196.199) by g01jpexchyt35.g01.fujitsu.local (10.128.193.50) with Microsoft SMTP Server id 14.3.439.0; Thu, 27 Feb 2020 14:50:31 +0900 From: Misono Tomohiro To: Subject: [PATCH v4 1/2] virtiofsd: passthrough_ll: cleanup getxattr/listxattr Date: Thu, 27 Feb 2020 14:59:26 +0900 Message-ID: <20200227055927.24566-2-misono.tomohiro@jp.fujitsu.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200227055927.24566-1-misono.tomohiro@jp.fujitsu.com> References: <20200227055927.24566-1-misono.tomohiro@jp.fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SecurityPolicyCheck-GC: OK by FENCE-Mail X-TM-AS-GCONF: 00 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 202.219.69.170 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, vgoyal@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This is a cleanup patch to simplify the following xattr fix and there is no functional changes. - Move memory allocation to head of the function - Unify fgetxattr/flistxattr call for both size =3D=3D 0 and size !=3D 0 case - Remove redundant lo_inode_put call in error path (Note: second call is ignored now since @inode is already NULL) Signed-off-by: Misono Tomohiro --- tools/virtiofsd/passthrough_ll.c | 54 +++++++++++++------------------- 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough= _ll.c index 9772823066..7b94300ae0 100644 --- a/tools/virtiofsd/passthrough_ll.c +++ b/tools/virtiofsd/passthrough_ll.c @@ -2384,34 +2384,30 @@ static void lo_getxattr(fuse_req_t req, fuse_ino_t = ino, const char *name, goto out; } =20 + if (size) { + value =3D malloc(size); + if (!value) { + goto out_err; + } + } + sprintf(procname, "%i", inode->fd); fd =3D openat(lo->proc_self_fd, procname, O_RDONLY); if (fd < 0) { goto out_err; } =20 + ret =3D fgetxattr(fd, name, value, size); + if (ret =3D=3D -1) { + goto out_err; + } if (size) { - value =3D malloc(size); - if (!value) { - goto out_err; - } - - ret =3D fgetxattr(fd, name, value, size); - if (ret =3D=3D -1) { - goto out_err; - } saverr =3D 0; if (ret =3D=3D 0) { goto out; } - fuse_reply_buf(req, value, ret); } else { - ret =3D fgetxattr(fd, name, NULL, 0); - if (ret =3D=3D -1) { - goto out_err; - } - fuse_reply_xattr(req, ret); } out_free: @@ -2427,7 +2423,6 @@ out_free: out_err: saverr =3D errno; out: - lo_inode_put(lo, &inode); fuse_reply_err(req, saverr); goto out_free; } @@ -2462,34 +2457,30 @@ static void lo_listxattr(fuse_req_t req, fuse_ino_t= ino, size_t size) goto out; } =20 + if (size) { + value =3D malloc(size); + if (!value) { + goto out_err; + } + } + sprintf(procname, "%i", inode->fd); fd =3D openat(lo->proc_self_fd, procname, O_RDONLY); if (fd < 0) { goto out_err; } =20 + ret =3D flistxattr(fd, value, size); + if (ret =3D=3D -1) { + goto out_err; + } if (size) { - value =3D malloc(size); - if (!value) { - goto out_err; - } - - ret =3D flistxattr(fd, value, size); - if (ret =3D=3D -1) { - goto out_err; - } saverr =3D 0; if (ret =3D=3D 0) { goto out; } - fuse_reply_buf(req, value, ret); } else { - ret =3D flistxattr(fd, NULL, 0); - if (ret =3D=3D -1) { - goto out_err; - } - fuse_reply_xattr(req, ret); } out_free: @@ -2505,7 +2496,6 @@ out_free: out_err: saverr =3D errno; out: - lo_inode_put(lo, &inode); fuse_reply_err(req, saverr); goto out_free; } --=20 2.21.1