From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63B30407CD0 for ; Tue, 16 Jun 2026 23:13:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781651612; cv=none; b=OPNxVf4qdJv2pSBr8/EdLvsU19MXhkN+FazkAX9LBlRHZXPwnauB4wO6whhF2DFjFHy9B7dRDxKFHtqyC2BubGp5Yx3dw5KXDRdYRVfL403q1YFeW4ilj/id2c3rHdied/31gpLYqlEVhda7c5aU6gwN/4SBqBrI4UrMX6/rVc4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781651612; c=relaxed/simple; bh=lkS+KHBqJXeYGJHdOSlajz6hbM4WTk5DhH53EzMx/6Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gqO6TXgIZlYy3tioMtMSKxzyteWCg5m1wYB0wlavkAEns5uU4l8mW3B7FgdEIa402CEnM7OHH/yI5g8kD5SeHABkqT95cEUhbaN1k0vUPoc7KIno3AYuFlum0uC23Q1kuz2yERRJa0aWu3e2WFYE5D7HsVXiXSElGi4pGp/TI/E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NNnWIQkR; arc=none smtp.client-ip=209.85.210.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NNnWIQkR" Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-7e701435806so4507374a34.0 for ; Tue, 16 Jun 2026 16:13:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781651610; x=1782256410; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=84DiwMXLdEq4yqPEouNIMtm8S6/TgLWUF9alM51937s=; b=NNnWIQkRrtGaD2RqE1DhXlNbxcO+qallXnOBUZktB8HgHPC9axHpo6/I4hKL1P5Pad v6SGSPdZRj8E2tL1oawurmZqExgq6oRoOzqLMPiHO3sEJA8GiEoRZyzj5TcgPpGULqpd cDuSDRKiEeX5hy2rKNk5PFQt4btLLgCtnoP9sI+fQWTnCm8y97x8zAxUWmec48DCwNv+ 3F2cy90ythcMX/R+TAjIMpz+CCjcLzAK64JsJDTkHgEtGq8RanXTMbAKUzPwsQtg+XCk a1+jUdxahy7ABT6jfHTbPhZMSgOfhoq4gZVqBaCjAocS4nuC3D6cd6HoIyOt36Utsrvo dacQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781651610; x=1782256410; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=84DiwMXLdEq4yqPEouNIMtm8S6/TgLWUF9alM51937s=; b=VO+tBk5ULKpBJkuHgjRVttxHTqNc2CuH4hvTJvPkNOLlf2xKzD+/P+sc5AtrXadaRW IJrHd/j476+5jUqaKQ4ArFcGVrnIq1SumvUkxprn7eE4/dB7p9xiP5n+e1SxY/oHQTYG NF1jIJbsw6aN8HvhDeRUB4BeduAW266ym7WcJSMFlOwgkf/meaXF0hcxZOM8wQwIY/1q 4hoVoqpy1NvKpURahzrfNU8Y5qLMc+ndUqnZeuSdH2DCYH3bFRlFgfSVtEmU2/ASfSNO wWPqpqqt8ZQo4djb/oAH+wEtQkKVRM5Uul6r10cAkiF3cls0jW53GKriDzFLF4IKRwY1 U2sQ== X-Forwarded-Encrypted: i=1; AFNElJ8YZ0v4zImx6+IrTBpDu3Rafi1kY4rwmquc8rJwkgWTkUuMJiCpyzOhnP/w6IVD+0guE+humKuPXID00Us=@vger.kernel.org X-Gm-Message-State: AOJu0YzwfsFXgIdwvjNiJ0q4HrxPvtuCWif3/OMxkJ97UxHEkrAsQzaj ZY6SeonXWVAuJX/Z54KLUwuZ+hAYoe+lMy26kAxy76uq+rzWgOvlBUsd X-Gm-Gg: Acq92OHVRTEWFI8mzaLJ+UQnNrkVJLeWApcdQltGmK/CLdcExyls5MsNnTXozOj9wxo KihywxAB3IjklWLrTJ0OyH+6bLiLTMiyj+J+3Tlw37O/gVom0khx+Upt34Ykpdu2KShcQQwAJYS jJ0t3nOGp1HUlTNK1mcUNOnBCE8wn8KYgStXFQcSRrgLmbhJgVqCSvk2AmV9hPrYcBqQ//ZvH0y j8GazogZfS+uMro/SrTtwg0UZaax4/rD7l+lwYUUcnkgPtu4x8clsL8/rg1kQBA307TrCsGkid9 yd8czxfJZQVsYUsj9n3fDUBdnoFN8EvhjnIwyztQ3mmB4CmAjjc7npWC7aa3fH6ASUJ1ZKLAAfa hDCb6Y3yp46gos35BgIz2KYQPTY5xXGe12xmpHNwGKedbhYobRQ45YCvc0oJKwKos/LafLioqG1 6CBN8bjvqL+fYZMwAtHLdaWIi0ma5EPpBQ+6a2RXOleqxkiYVfrnl4JzdA7qvyXFncV8/fhe6P7 tqkgl33P7nICRjR8UmpeC7+covwd05isGW9a0ydJp5tgfd+wMEnVeY= X-Received: by 2002:a05:6830:6ae5:b0:7e6:f2ef:e231 with SMTP id 46e09a7af769-7e90b2ae089mr1702940a34.2.1781651610294; Tue, 16 Jun 2026 16:13:30 -0700 (PDT) Received: from rdf-gcp2.us-central1-b.c.storage-xlrait-66065.internal (163.80.112.136.bc.googleusercontent.com. [136.112.80.163]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7e79f5a1b86sm7530924a34.5.2026.06.16.16.13.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2026 16:13:29 -0700 (PDT) From: Russ Fellows To: miklos@szeredi.hu, fuse-devel@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Amir Goldstein , Russ Fellows Subject: [PATCH v3 1/2] fuse: preserve FOPEN_PARALLEL_DIRECT_WRITES for passthrough opens Date: Tue, 16 Jun 2026 23:13:21 +0000 Message-ID: <20260616231325.16788-2-russ.fellows@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260616231325.16788-1-russ.fellows@gmail.com> References: <20260616231325.16788-1-russ.fellows@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fuse_file_io_open() clears FOPEN_PARALLEL_DIRECT_WRITES for any open that lacks FOPEN_DIRECT_IO. That rule is too strict for passthrough opens, which already bypass the page cache through the backing file and do not need FOPEN_DIRECT_IO to guarantee direct-I/O semantics. Clearing the flag before the passthrough write path sees it prevents the kernel from ever taking the shared-lock path for passthrough writes. Introduce FOPEN_IOMODE helper macros to classify the effective I/O mode of an open file: FOPEN_IOMODE_IS_CACHED(oflags) - page-cache I/O (neither flag) FOPEN_IOMODE_IS_DIRECT(oflags) - DIRECT_IO is set FOPEN_IOMODE_IS_PASSTHROUGH(oflags) - PASSTHROUGH only (no DIRECT_IO) Use FOPEN_IOMODE_IS_CACHED to express the PARALLEL_DIRECT_WRITES guard cleanly: the flag is only suppressed for cached iomode, not for passthrough or direct-IO mode. This is a prerequisite for passthrough write parallelism; without it the shared-lock path in the subsequent patch never activates. Signed-off-by: Russ Fellows --- fs/fuse/iomode.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/fs/fuse/iomode.c b/fs/fuse/iomode.c index c99e285f3..46e60b04c 100644 --- a/fs/fuse/iomode.c +++ b/fs/fuse/iomode.c @@ -165,6 +165,23 @@ static void fuse_file_uncached_io_release(struct fuse_file *ff, (FOPEN_PASSTHROUGH | FOPEN_DIRECT_IO | FOPEN_PARALLEL_DIRECT_WRITES | \ FOPEN_NOFLUSH) +/* + * Helpers to classify the effective I/O mode of an open file. + * + * FOPEN_IOMODE() - extract the mode-relevant bits + * FOPEN_IOMODE_IS_CACHED - neither DIRECT_IO nor PASSTHROUGH: page-cache I/O + * FOPEN_IOMODE_IS_DIRECT - DIRECT_IO is set (may also have PASSTHROUGH) + * FOPEN_IOMODE_IS_PASSTHROUGH - PASSTHROUGH only, without DIRECT_IO + */ +#define FOPEN_IOMODE(oflags) \ + ((oflags) & (FOPEN_DIRECT_IO | FOPEN_PASSTHROUGH)) +#define FOPEN_IOMODE_IS_CACHED(oflags) \ + (FOPEN_IOMODE(oflags) == 0) +#define FOPEN_IOMODE_IS_DIRECT(oflags) \ + (FOPEN_IOMODE(oflags) & FOPEN_DIRECT_IO) +#define FOPEN_IOMODE_IS_PASSTHROUGH(oflags) \ + (FOPEN_IOMODE(oflags) == FOPEN_PASSTHROUGH) + static int fuse_file_passthrough_open(struct inode *inode, struct file *file) { struct fuse_file *ff = file->private_data; @@ -216,9 +233,11 @@ int fuse_file_io_open(struct file *file, struct inode *inode) goto fail; /* - * FOPEN_PARALLEL_DIRECT_WRITES requires FOPEN_DIRECT_IO. + * FOPEN_PARALLEL_DIRECT_WRITES is not supported with cached iomode. + * Passthrough and direct-IO both bypass the page cache, so both are + * eligible to enable parallel direct writes. */ - if (!(ff->open_flags & FOPEN_DIRECT_IO)) + if (FOPEN_IOMODE_IS_CACHED(ff->open_flags)) ff->open_flags &= ~FOPEN_PARALLEL_DIRECT_WRITES; /* @@ -228,8 +247,13 @@ int fuse_file_io_open(struct file *file, struct inode *inode) * Note that if user opens a file open with O_DIRECT, but server did * not specify FOPEN_DIRECT_IO, a later fcntl() could remove O_DIRECT, * so we put the inode in caching mode to prevent parallel dio. + * + * Pure direct-IO (DIRECT_IO without PASSTHROUGH) needs no page-cache + * iomode machinery — return early. When DIRECT_IO and PASSTHROUGH are + * both set, write_iter uses the direct-IO path but the backing file + * still needs to be opened below. */ - if ((ff->open_flags & FOPEN_DIRECT_IO) && + if (FOPEN_IOMODE_IS_DIRECT(ff->open_flags) && !(ff->open_flags & FOPEN_PASSTHROUGH)) return 0; -- 2.51.0