From nobody Mon Feb 9 03:29:05 2026 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; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1586586369; cv=none; d=zohomail.com; s=zohoarc; b=fZ2ikW7lUuSHjkX5205lUtIXaPcYV2mKRmrkHcoSrCw5kC7jOewbN6dbYu9br8Wf3NM01ZTMVL5cXoLfYj5W/U3016BagBIh1JdxKsgHQGXzSupdAd2VaK7GbPReVx8HL551F4ES+hpv+gdTLvP/zn+qtFrMljuggKh5hwNbrBA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586586369; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=GzzuzoJO5dzeQyXnKq8icvH6vIhlp30+SlHLfpaP/gY=; b=ZK2G0hbA4///coirWz4xe3ZnylzKUkfY2IQgwYgvm4g5AVc1GYd0Xvp5C5367SX6omWOae1KC+jnk8QkWUemGmzhI67km+jcjAjFfQdgywY6sZBhCcDKb6w+PbTl/O2Clj75TY2adMt48VB8a2xJXkIYlkUfFnwIq6ObZCOzRFA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586586369761814.5532711503008; Fri, 10 Apr 2020 23:26:09 -0700 (PDT) Received: from localhost ([::1]:49234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jN9ah-0000ge-Ex for importer@patchew.org; Sat, 11 Apr 2020 02:26:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56391) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jN9Zt-00008W-Jv for qemu-devel@nongnu.org; Sat, 11 Apr 2020 02:25:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jN9Zs-0000G5-Jw for qemu-devel@nongnu.org; Sat, 11 Apr 2020 02:25:17 -0400 Received: from mail-qk1-x743.google.com ([2607:f8b0:4864:20::743]:46361) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jN9Zs-0000Fa-AQ for qemu-devel@nongnu.org; Sat, 11 Apr 2020 02:25:16 -0400 Received: by mail-qk1-x743.google.com with SMTP id g74so4253415qke.13 for ; Fri, 10 Apr 2020 23:25:15 -0700 (PDT) Received: from host.localdomain ([104.129.187.94]) by smtp.gmail.com with ESMTPSA id z18sm3432044qtz.77.2020.04.10.23.25.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Apr 2020 23:25:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=GzzuzoJO5dzeQyXnKq8icvH6vIhlp30+SlHLfpaP/gY=; b=ejgvmyD1JskgBcdZLwwxIqtwFHZ7rC+vPsOEso4o8uMEiATvBZCRcZqOMZTi4EqMjh 9L9Aq4efvBJvxW3TEXrXbew+kQ3TAeTkJIKZtaDuRFisdI9UrR1G3smNIfR7RRP5s0n6 UlFdPinTpt5mvUZG15qm6jz1CCpGARjWgiKU+RDU+qSmcOUZC1RJjPBVBEfL3dk0/s7Z PgYhp7Hp8pHTsVr9feK7giK4JXGCbqBZB9psCXXkCkgZbc9YkQP2Ebmt9VxuXYo5iMY2 NttClR1uptGwOywEc1IaAdP4AfVZBj1IPcI5r5ilHvwCbQt5AyB6xO6+BDmbFEJ6rTaE RZeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=GzzuzoJO5dzeQyXnKq8icvH6vIhlp30+SlHLfpaP/gY=; b=jVVn7nz1kIiTGNxMTnlrnahL1aULTDP+Hgi40+6GaxijQKgrL0a2NP2cEfsdNC9Fq7 F74XApy5rDP284C61uWZK/Fbw0lgmBEfeEf98LKip+3+hPjqrXubjcyskCgKTV5uPdZu wZ4sxjRA0/uKwvy4p9xbB3yKTSin96WG8D4Elg3NByLLFH0fU2aCPTV5yMC/bxOLLr/A y5ZhdRb8QIsPv1wR1+ZwVAgifmyCe6dfnxk+CUhWT2HnAxaPNQgaObD5c/59B3NWc7qr WxiyVxkIpYi+2vnlGKPTRAKxLvX+wGPQ05So3If6Ll3rwoF0rmulSKlMWmFozZxpocds NgJQ== X-Gm-Message-State: AGi0PuaPsKFGH7gJUOpmI6CuIMhaA52dTQVOgJtUghmc69diPdLW3I1q 25YHk584aKdJMlUykrB/W5g= X-Google-Smtp-Source: APiQypKZCEhKj1pPo6WtNY5eaf61hSrM/8cGaXWWAEXHqsYUv7sqoKKdPcDRYXmsA8ufAxi29CIFNQ== X-Received: by 2002:a05:620a:15f4:: with SMTP id p20mr7058116qkm.496.1586586315225; Fri, 10 Apr 2020 23:25:15 -0700 (PDT) From: Catherine Ho To: "Dr. David Alan Gilbert" , Stefan Hajnoczi , qemu-devel@nongnu.org Subject: [PATCH] virtiofsd/passthrough_ll: don't remove O_DIRECT when cache=none Date: Sat, 11 Apr 2020 02:19:57 -0400 Message-Id: <1586585997-24446-1-git-send-email-catherine.hecx@gmail.com> X-Mailer: git-send-email 1.7.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::743 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: Catherine Ho Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" cache=3Dnone means to bypass host cache. So we can't remove O_DIRECT flag in unconditionally in update_open_flags(); Signed-off-by: Catherine Ho --- tools/virtiofsd/passthrough_ll.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough= _ll.c index 4c35c95..889e144 100644 --- a/tools/virtiofsd/passthrough_ll.c +++ b/tools/virtiofsd/passthrough_ll.c @@ -1677,7 +1677,8 @@ static void lo_releasedir(fuse_req_t req, fuse_ino_t = ino, fuse_reply_err(req, 0); } =20 -static void update_open_flags(int writeback, struct fuse_file_info *fi) +static void update_open_flags(int writeback, int cache_mode, + struct fuse_file_info *fi) { /* * With writeback cache, kernel may send read requests even @@ -1702,10 +1703,13 @@ static void update_open_flags(int writeback, struct= fuse_file_info *fi) =20 /* * O_DIRECT in guest should not necessarily mean bypassing page - * cache on host as well. If somebody needs that behavior, it - * probably should be a configuration knob in daemon. + * cache on host as well. If cache=3Dnone, set the flag to O_DIRECT */ - fi->flags &=3D ~O_DIRECT; + if (cache_mode =3D=3D CACHE_NONE) { + fi->flags |=3D O_DIRECT; + } else { + fi->flags &=3D ~O_DIRECT; + } } =20 static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name, @@ -1737,7 +1741,7 @@ static void lo_create(fuse_req_t req, fuse_ino_t pare= nt, const char *name, goto out; } =20 - update_open_flags(lo->writeback, fi); + update_open_flags(lo->writeback, lo->cache, fi); =20 fd =3D openat(parent_inode->fd, name, (fi->flags | O_CREAT) & ~O_NOFOL= LOW, mode); @@ -1947,7 +1951,7 @@ static void lo_open(fuse_req_t req, fuse_ino_t ino, s= truct fuse_file_info *fi) fuse_log(FUSE_LOG_DEBUG, "lo_open(ino=3D%" PRIu64 ", flags=3D%d)\n", i= no, fi->flags); =20 - update_open_flags(lo->writeback, fi); + update_open_flags(lo->writeback, lo->cache, fi); =20 sprintf(buf, "%i", lo_fd(req, ino)); fd =3D openat(lo->proc_self_fd, buf, fi->flags & ~O_NOFOLLOW); --=20 1.7.1