Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.169 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796306240; b=hv2pLKFynItyO0ttlyB0kpYapCD0KKdq+NcP0kB88o4dhtoKG3c1z0N1tyBH2Pd5BzEH ukDKQeSB+Axii2qg4IYgtrhf8JRHaWsvhQITuGF2cAeSAlycvmV/8zgiaMdk6to3FO735 RVbxZebvT1xCt3mO/ARAhCpzI41tT50CbhuvfJ5xLeC2itAck1pXhKHzZN/aFAuXCm/U+ gWSA8HOHrMKkOUzSzzjqHRf3FdKw7WR78OS+16XxJob8/wNgTTkwZs/Y5RlsWsYWe5APk eWg1TcQCKk2wN62rYsRIEfJeRVcTuVt1QanmL9GU+VqfDIKrqj4wzyPCK7d09lOyPDg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796306240; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=26dvfd3ZxWViSj0QVagiZsmOjT42AYFOw+hViZGxxfE=; b=ZpUOyV8rkSqnP5ZYRrd3NrecybkMaj6td3ttMdEVNa9tuRymWRXCqxaKDFbXEDKcHRcC WfHpOU0so0vJiSzMc01LCGvt2GwP2a/khY+DN/vRezxzWYjvRhMdRBILAnpLfBs01jKcn 3E/GrjV8t8HxShe1FEqI3qD6Ntgnmu2M263v81iB1fpTTWuCrC9YVzszJ0TTYLOBIBr5+ IgEKCHSUSM7eTEEA1ylKBZqYZtjAGchZ+jGqHoWDuPntHIekR78loWc9elPdeVl0ugXwV PyyJi+isQovTGmsNxX/ViXi6YZRmjcGPpYFAxDqbtOYnMSJcBXZj1FOtEyov5HexESA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=hammerspace.com; spf=pass smtp.mailfrom=hammerspace.com; dkim=pass header.d=hammerspace.com header.i=@hammerspace.com header.a=rsa-sha256 header.s=google header.b=L5oApYvW; arc=none smtp.remote-ip=209.85.167.169 Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.169]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD5F3606A338 for ; Thu, 3 Dec 2026 13:57:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AD5F3606A338 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=hammerspace.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hammerspace.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=hammerspace.com header.i=@hammerspace.com header.a=rsa-sha256 header.s=google header.b=L5oApYvW Received: by mail-oi1-f169.google.com with SMTP id 5614622812f47-4b28d9537bcso810540b6e.0 for ; Thu, 03 Dec 2026 05:57:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hammerspace.com; s=google; t=1796306239; x=1796911039; 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=26dvfd3ZxWViSj0QVagiZsmOjT42AYFOw+hViZGxxfE=; b=L5oApYvW/RTjxX50JggV4LS3xYg4WgGCpyn3B7pkozFqwZZ62sXcMDGnuphrno1cJi cO1szS2OdA+VUey2lyGen+7iA0H0IPQZz9t9TyjLGz/QAIn4QcImI7EAQKvk2TlHDJwC Mj5Narys6VW08pw1+0wsIF/ScQUkPfb8eFgdcDOh2D1Cn6JYSTJLZW1E4PusJmfVge9e Vcsa7lOJJ4uTcS7kQlpgpAKPVm+aYrGbzJvo21/X2nYUkhum7VKIgmemQs5nOwEilPGC tNqN8Cv70l0VdAotKL0M2/PHuoNayGTTdsfJtRx9i/rGtuLyl9ZLlTpOhTAWUxtVWlzN R6Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796306239; x=1796911039; 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=26dvfd3ZxWViSj0QVagiZsmOjT42AYFOw+hViZGxxfE=; b=v2f1v3HJtCuY8wcpR8ujQnj8cznJgkqCfTgSK0Gim4fzRFD/VCrFhz1EAhN2bI2TEt /mw+bZv4h3VL/zNwKXc9OimWjZ20V22pHt/acTEEICWfnv0eMyUEI4hnYhTZQfcwaGOE CJcNdGNfJX45i94F5NOtgAp7/yOCzJoMb5vUovVsLHG5BDjhHllRNCGvA06v0S569XNI pJdYndhUFVMf3sIWnk9xOn9MljpYwPgvlMzIwPd18a/cyj4ZXZEqe2/FX9TSCNmTHaHC HfW9+bxzUcW6mueMA2rM/cqsl8imv83YSh1V24H2pswJDa1NOkuV8h0IXzXVDNhv5FEx HEyA== X-Forwarded-Encrypted: i=1; AL+hErGEKxbjxqwkypT/M8795yP6lH5U50hxBn4/7pZrDl5AIb6c5t64W+PqUYKK5G3lfUpAQCZvGyuzJs4=@vger.kernel.org X-Gm-Message-State: APuU4Z9xgl9Zc8auLJZr0H0n9TWoL2klvgubT/e8AP7nUVZXNGLYOieE iP06T5yKZplYvdwmZLpCtG14dwL1nsDg41CYIwA1mC18LU/vG8IymY36GzC+8eVREB4= X-Gm-Gg: AZFdTZd65bmScpE2ZIDpaA87XP0+YhsYV5EdQ1z6IcRTLR1hzi2TzsV2eNBe79uLguC +fM17QL0MN4gn770amYKo365xEqCOA7N+WARfdVbfP4+zUG4VINyGieJT6+wfyC+9Gwrjcs4DsV 0Zx5yWoFZvPoyd1bl7WpP387rM/GZGLsKo4yn4cZrA6QGFxvTtXyB6LIINIZHo7BkcA/rNWeW8A ZFgcx99C8IXajRkWM0rTPjL9rHP3IvhB0BgXCpAQ2P+vDEkecmJuO+dnAVs/NF5VqTUcbEabKNy jTGzaCncwttFigm1+6P0Ll9jOK0RBpDDgUJTMw/hspTsURJjukzI+0eN0Ik2kFR72ZZD+C/s1Pk keY37UW3YBqWqfhWnsACgN/aUhChEiAvQQ7fm+mJkZUOMkpeTdGOOlG5SlatyHY0NZqNtYFoJ33 2pyGFY57kfDGopdnhPSIcAhrK56XBy49GzCv67kyuMiVuuAmm4c9NOmM6DPTA77mfpAaBeC+0Ew KbVOcw5AxojjBlvYg4XUrbqm1TSs+dgZP3cTxVISTNjEqYi5eW3acrtATd3D7FdJKgHBSn/bUv4 aHFZGtJYiBD2xaGWrsIzXsCI1bilvco8PcRPrSF9dQw0vcfIueTBWg9F5XhCrYpwWpAO08g8 X-Received: by 2002:a05:6808:4f52:b0:4b8:4703:db90 with SMTP id 5614622812f47-57f07c4f608mr1855249b6e.25.1796306238573; Thu, 03 Dec 2026 05:57:18 -0800 (PST) Received: from bcodding.csb.hammerspace.com ([66.97.168.37]) by smtp.gmail.com with ESMTPSA id 5614622812f47-57a350548ffsm30973955b6e.11.2026.12.03.05.57.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 05:57:18 -0800 (PST) From: Benjamin Coddington To: Trond Myklebust , Anna Schumaker , Mike Snitzer Cc: Olga Kornievskaia , linux-nfs@vger.kernel.org Subject: [PATCH v4 10/11] NFS: wait and resend a folio refused with -EAGAIN in nfs_wb_folio() Date: Thu, 3 Dec 2026 08:57:05 -0500 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Benjamin Coddington A pNFS layout driver can refuse a write with -EAGAIN so that it is resent. Flexfiles does so from ff_layout_pg_init_write() when the layout segment's mirror count no longer matches the descriptor's, and from ff_layout_pg_get_mirror_count_write() when there is no layout segment and the file's layouts carry FF_FLAGS_NO_IO_THRU_MDS. nfs_do_writepage() redirties the folio and returns the -EAGAIN. nfs_writepages() resends it, but nfs_wb_folio() returns it to its callers: nfs_updatepage(), nfs_flush_incompatible(), nfs_read_folio(), nfs_invalidate_folio() and nfs_launder_folio(). A read(2) or write(2) on a blocking file then fails with EAGAIN, for example when the folio is dirty while a layout is being recalled. Resend the folio from nfs_wb_folio(), and wait a second before every resend after the first. The caller holds the folio lock throughout. That used to be unsafe: writeback kept its layout segment in use while it waited for that folio, so a recall, and with it the layout this resend needs, could wait on the folio. A pageio descriptor no longer keeps its segment in use. A fatal signal ends the wait, and a softerr mount still gets the -EAGAIN, as it does from nfs_writepages(). nfs_migrate_folio() doesn't resend: it ignores the result and returns -EBUSY while the folio still has requests, and resending would hold up compaction. Fixes: 1d62e659c0bf ("NFSv4/flexfiles: honor FF_FLAGS_NO_IO_THRU_MDS in pg_get_mirror_count_write") Signed-off-by: Benjamin Coddington --- fs/nfs/write.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 7967487e026c..dd41e3bd88aa 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -2073,15 +2073,8 @@ int nfs_wb_folio_reclaim(struct inode *inode, struct folio *folio) return 0; } -/** - * nfs_wb_folio - Write back all requests on one page - * @inode: pointer to page - * @folio: pointer to folio - * - * Assumes that the folio has been locked by the caller, and will - * not unlock it. - */ -int nfs_wb_folio(struct inode *inode, struct folio *folio) +static int __nfs_wb_folio(struct inode *inode, struct folio *folio, + bool resend) { loff_t range_start = folio_pos(folio); size_t len = folio_size(folio); @@ -2091,6 +2084,7 @@ int nfs_wb_folio(struct inode *inode, struct folio *folio) .range_start = range_start, .range_end = range_start + len - 1, }; + bool resent = false; int ret; trace_nfs_writeback_folio(inode, range_start, len); @@ -2099,6 +2093,16 @@ int nfs_wb_folio(struct inode *inode, struct folio *folio) folio_wait_writeback(folio); if (folio_clear_dirty_for_io(folio)) { ret = nfs_writepage_locked(folio, &wbc); + if (ret == -EAGAIN && resend && + !(NFS_SERVER(inode)->flags & NFS_MOUNT_SOFTERR)) { + if (resent && schedule_timeout_killable(HZ) && + fatal_signal_pending(current)) { + ret = -ERESTARTSYS; + goto out_error; + } + resent = true; + continue; + } if (ret < 0) goto out_error; continue; @@ -2115,6 +2119,19 @@ int nfs_wb_folio(struct inode *inode, struct folio *folio) return ret; } +/** + * nfs_wb_folio - Write back all requests on one page + * @inode: pointer to page + * @folio: pointer to folio + * + * Assumes that the folio has been locked by the caller, and will + * not unlock it. + */ +int nfs_wb_folio(struct inode *inode, struct folio *folio) +{ + return __nfs_wb_folio(inode, folio, true); +} + #ifdef CONFIG_MIGRATION int nfs_migrate_folio(struct address_space *mapping, struct folio *dst, struct folio *src, enum migrate_mode mode) @@ -2129,7 +2146,7 @@ int nfs_migrate_folio(struct address_space *mapping, struct folio *dst, */ if (folio_test_private(src)) { if (mode == MIGRATE_SYNC) - nfs_wb_folio(src->mapping->host, src); + __nfs_wb_folio(src->mapping->host, src, false); if (folio_test_private(src)) return -EBUSY; } -- 2.53.0