From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (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 D94A635E1B0 for ; Sun, 26 Jul 2026 01:59:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785031199; cv=none; b=H+2Z6FjYWNuEwjsTAE3VT5/1SPyW8NO8APjrNQd/k7NyRMxwkzeAdBkHVS05RZ9/LUhJs7K+g3cqskkvUeLIeiPed60gucuI0MK/hxBepUlP9CBVXjiKQDPHIiSQYCozXgApqrKS6T0bQot62ORCtm4LwMjmhyke57zSFVJqElU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785031199; c=relaxed/simple; bh=2V+3m0fgntJtbg8ymQ5J7H5s4f+81WfW9BhXC4k8GHo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=auZ+1jQkiBQIiZnYw2xhbP9IIlWG1lnOGyCZ1X73/bNpjlnTOyft8hCrt4ceCots+1DjB3vtdXaYQcWhUL4MMuMNG3forNYB0xAthRgd9oGMHoykVF5d3/fUY2pXug/VHZ+5eF29OGpUbH34WW1abr1xy5Siw0oj6MhtT8fo+og= 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=izDqyoD6; arc=none smtp.client-ip=209.85.210.44 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="izDqyoD6" Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-7eb545db3afso941241a34.0 for ; Sat, 25 Jul 2026 18:59:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785031197; x=1785635997; 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:content-type; bh=DsHLlh0udDqVC+emmPBCCltHi5t5SZsNobdjX3Jo96c=; b=izDqyoD6HC2S+9wCGI5Dek+lE+PwSAEdQTLEgF5wzmdVZh0fUWZbAz6/DaXxjTuZKl jNnnQePShI3P7wRdPlgv9s9I3CU/p+gUl2MjLKlRhqgk1ztGut8/Ej+Up6Vj1vOFB3Tp JJ9UxI9ovnVuOHJOTHtWoU80J8IRmdgy8XhGQIzrd2HG9UncGUqCEEMUms9Sa211pXhD ojUPprdT/Bp3i20Fkw/6eM9yLZIf10AFYJUkyFagy8vjwjITOO2vaIXO55uV2HMo5KUt kUEMWmykpP8jHc7gxfRggsDP3SbcgKKM1qnb8YGwv3j1u0hIInwuBQXOOJx0CTEQqUr/ QHfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785031197; x=1785635997; 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:content-type; bh=DsHLlh0udDqVC+emmPBCCltHi5t5SZsNobdjX3Jo96c=; b=UHX588PBnOIWoflYWZ+I9PnvOLDRHBG2oqByqWxgtg2IgbV20e5qmzXvDpGJyQSWbx SQj8DRSLM633dUb1BsnJxR1IUwc4ZV3y6j/suXPV87t6Fn/yzCbFhZWBlytftcSnCTxg 1Z1bLP9j7oWTtTOw2feVkdfPZmVkwcZxfpfM7pq6RLr9VYFfXXBL33Ekv1W0+zqvyNJ1 aREWbq5C1bXtVVbMpoZUlMeN7cT1gTOGO1GBkhydSouJLbb0M4O1JX6BfF/pGkT6sjcM a5QlMZZMA2qYMZ9eKnbQUPS/s0fY72sFAWO2shrtjLR4Gaqe3d+UGH3kT9lJpl4ODwBQ l3nA== X-Forwarded-Encrypted: i=1; AHgh+RouwygzZTagXy0w4c0sbrpaoqQ0PdPR2V85PW2HyNZo10XxOPeLxE0u43ZqbTA/FuHRj+yr7PPOaBFCMqg=@vger.kernel.org X-Gm-Message-State: AOJu0Yz4JOieIS0i+e5s6xs6Fo5ghq8nRtuleEP7+/TAhPfjYwCgqCpS 0/wTNF0nl6pqkD8t9qbcXBPHA+dZ/GBEPvoXwI5KPziFmiV99WAptUh7 X-Gm-Gg: AR+sD13/kzzSBTnmlhB4VSFeJB9sN4xB5O/WICKyn0/YUIY6RpjySdkMKhUTR/0iOD+ lFQ3PkiC8Q2zq7xRAztAxqjMVfC8XXGrEyDlTyeN9Yk2lFaWda2veijK0WUkyoJhluCQKsIZTyC zq8HWYpsTCUcr8SZBjfsJdN1xvp0AhJRPsoqd4FfkDrU6wuOE2zHklZd542xMk42wCv9OPWTmp5 IeUn1K57Nif93nRQHru/rA5R4ZlK/+OhPr/9Fzvlu2wPhrJ+8RSajsuL/2nlDHo45zg7iGUXD/2 dko7wraWZ8LeFr9APDhDiZKEltUikZmoLLbF8FlX6n3i7uakZSBgsgY0msJOvZ4c670foKunqgy A3Eq9ZmM+b50fokC/s+JMRXqA+HN0AylmmPqx67sPBG8uWlknueSoDWqho/NxZJSn103ap+iYa4 DPrKTR2eadBJP27c6W6/g2+EmmyTn6Dcn2d8RLf/XWw5DKkk6F+lJUJGYfqZ91ZXyZbld6GAaG7 DN9o0kivJGAynlULYg7DXdyslp0akn+meirqMhhtdU/ X-Received: by 2002:a05:6830:314d:b0:7e9:cf5d:b7c3 with SMTP id 46e09a7af769-7ee78db7dd2mr3701023a34.23.1785031196730; Sat, 25 Jul 2026 18:59:56 -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-7ee29e0ec5bsm9335656a34.10.2026.07.25.18.59.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jul 2026 18:59:56 -0700 (PDT) From: Russ Fellows To: miklos@szeredi.hu Cc: amir73il@gmail.com, fuse-devel@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Russ Fellows Subject: [PATCH v4 1/2] fuse: preserve FOPEN_PARALLEL_DIRECT_WRITES for passthrough opens Date: Sun, 26 Jul 2026 01:59:54 +0000 Message-ID: <20260726015955.319132-2-russ.fellows@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260726015955.319132-1-russ.fellows@gmail.com> References: <20260616231325.16788-1-russ.fellows@gmail.com> <20260726015955.319132-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-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_CACHED() to test for cached (page-cache) iomode -- neither FOPEN_DIRECT_IO nor FOPEN_PASSTHROUGH set -- and use it to guard the FOPEN_PARALLEL_DIRECT_WRITES stripping. Passthrough and direct-IO opens both bypass the page cache, so both are now eligible to enable parallel direct writes. While here, simplify fuse_file_io_open(): drop the early return for the pure direct-IO case and dispatch the caching open through the same FOPEN_IOMODE_CACHED() test, so a pure direct-IO open simply performs no iomode setup instead of returning early. This is a prerequisite for passthrough write parallelism; without it the shared-lock path in the subsequent patch never activates. Suggested-by: Amir Goldstein Signed-off-by: Russ Fellows --- fs/fuse/iomode.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/fs/fuse/iomode.c b/fs/fuse/iomode.c index 3728933..937d9e6 100644 --- a/fs/fuse/iomode.c +++ b/fs/fuse/iomode.c @@ -192,12 +192,18 @@ static int fuse_file_passthrough_open(struct inode *inode, struct file *file) return err; } +/* Fuse uses page cache if no passthrough nor direct_io open specified */ +#define FOPEN_IOMODE(oflags) \ + ((oflags) & (FOPEN_DIRECT_IO | FOPEN_PASSTHROUGH)) +#define FOPEN_IOMODE_CACHED(oflags) \ + (FOPEN_IOMODE(oflags) == 0) + /* Request access to submit new io to inode via open file */ int fuse_file_io_open(struct file *file, struct inode *inode) { struct fuse_file *ff = file->private_data; struct fuse_inode *fi = get_fuse_inode(inode); - int err; + int err = 0; /* * io modes are not relevant with DAX and with server that does not @@ -216,25 +222,20 @@ int fuse_file_io_open(struct file *file, struct inode *inode) /* * FOPEN_PARALLEL_DIRECT_WRITES requires FOPEN_DIRECT_IO. + * 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. */ - if (!(ff->open_flags & FOPEN_DIRECT_IO)) + if (FOPEN_IOMODE_CACHED(ff->open_flags)) ff->open_flags &= ~FOPEN_PARALLEL_DIRECT_WRITES; /* * First passthrough file open denies caching inode io mode. * First caching file open enters caching inode io mode. - * - * 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. */ - if ((ff->open_flags & FOPEN_DIRECT_IO) && - !(ff->open_flags & FOPEN_PASSTHROUGH)) - return 0; - if (ff->open_flags & FOPEN_PASSTHROUGH) err = fuse_file_passthrough_open(inode, file); - else + else if (FOPEN_IOMODE_CACHED(ff->open_flags)) err = fuse_file_cached_io_open(inode, ff); if (err) goto fail; -- 2.51.0