Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796406128; b=UEbYUm1jkiJBzOhoRLKr1H1b51HGS4QM0lc79eKBriciARVbQazMQrQE6vZ4WcOrjlRT hhAJJCDfbjpcCLesOjp2wXFXm9v/FzUKonDuK4GRUZMDx/cBvfeJ+eBTC6Q28t/MZXpYs kjlTnCVJW1AsOu9LaDuyHfmTd0GOIbo8BlXO9eUQ9BzU7JyvIj6uz5tOEMbuJruqw6Ovc dzhc1dXGVwBf+lG4OxvBgOrUHPf3R6Z1QIBq9h+BA4AI9c/jNFkHzuKqFnZEpmR4sVlUM osN+ItRkkGH7AIZzprWOoDPlee+JAn1wiK8mIpiRUVSELYNm0t+tGYTvZi/bmfStTag== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796406128; 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=lD00AUZcXkU23QZ6ZFEievVgDsgzVLXgwRweB29cubI=; b=Wc6D4fDHu7wYeg4sIbO+XYkRSSZhhxYqs4jGOeoDlckDJXZ93FVfqu9nl+D+XAG6k3W7 Ru1QoKfY5luhZym1GzwCUsnjzk23QwTwDKdw6eqZBiB9RDI2xeH8Pz6hQ9A3dCU4yVW7T 0LqvfXYimwcAHM04LCFqjbh0JyzROFgNL3V9biLw3XovlEERf5tfWqcVD+WgIba8wR9Tv h8TGP+p9PrQVGkDm5yZzQXdPiqQmBNHTAGgWMdg14g31P+N8lMmL/d4MGMV+f8QeVxuSN N/AJL9KvOgXABBLaPqFTWJzwYCA/vRv6gNPxtCND2WzloBpAu26Z7pcgLJoZ/Has7og== 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=SP0C6JoL; arc=none smtp.remote-ip=209.85.161.48 Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.48]) (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 536AD606A334 for ; Fri, 4 Dec 2026 17:42:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 536AD606A334 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=SP0C6JoL Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-703be215729so497662eaf.1 for ; Fri, 04 Dec 2026 09:42:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hammerspace.com; s=google; t=1796406127; x=1797010927; 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=lD00AUZcXkU23QZ6ZFEievVgDsgzVLXgwRweB29cubI=; b=SP0C6JoLEtqkkAQYJGeRDoCiM9uOEJcFT4rjGl0G7QUXJXaoVWY6q2/q87fiPy8vNx 6RXqYjJVNazBTiMcc9gDOyjw4iaWUP2ig/lHboS7xVoeIVQk8ZPrFL5ObJWMajs52ece Ptqvd0MGL75mfSzhC9CZJvR2KsAWfoQ7Fhd7VkBLDQz71OMBcUwW/3NraB8uDzmxKp+b Yq87Eeo+jQVx6c6YnGgTkH5hRles59Racy43vGNJw3+IAkVF2cmxoE/NwGSSFzTdPENT sKuWQLSrpmeZtFIJyfrPZlcZjSGPBPpJl8T9wJuvHmpQ8XRkHV7u6vxW/G9Tw49mRLRz iPdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796406127; x=1797010927; 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=lD00AUZcXkU23QZ6ZFEievVgDsgzVLXgwRweB29cubI=; b=M4SJdmf0BomKW996DF1yDBpu/ErlnWoP4fxVACtH1gJ6j5TZS5hSWoerIgudThIxsd UIpYqDLkFoMkQ+EVVcyLMXUMeSvmWic3wAUdoiEBm9Wp4u+Z0mjBuk4lYVippOFVrlXu aM81Lj5FZd72FUnyEQHSsU4lHkY/EWgqNzX1+1rLywy/yrtFO0r0VmaBpgZj7rtiK60z 7Aj+xi2s1/ZrhKA88Dnra0pjtAgKsg9X57wHhakJ5LItHIy4ydcriE2tQ4UcIx/hCv4q Z9p/kGTAbQA3GSz/nE7nHKXQU2+rK8LOzdCYXJ8GAuBrJ8qA+4cv5LnZI1TSqXCECtg+ 6kbQ== X-Forwarded-Encrypted: i=1; AL+hErG9SqXdFb4gjawas22kWTVTQrpWxF8EvVuQGFuSx0t9SMD9qf9KGu9OikBUfMjrjnbc2P1Lz1jAbWA=@vger.kernel.org X-Gm-Message-State: APuU4Z8oyroGryWFpG9fGgNzd+eAIZ5B+AUu1wu88A2gur74fbnIWspq dvshxBAbwv7TJeQcps04Wzc9dEJb/n8T0X+BPzmzb4ruyv9112xmV77PuALeYaGbU6nvQwMFeRs TyUac X-Gm-Gg: AZFdTZclzwzwmqbOkx3+slFZg2hhAJ3V02BcBO9mqw2xkw+aI9BjywU1qFjea63cT+Z tF9WrhjobcqUHcnz8M2ivIbWhSvEmRGDMEbiM3jSHXX4QE2XXMHdMpgw2sJwwDvc/5xG4brt3Pw V8L+o7WcGtK09hCfMAoLOir4OCE3WwXWOiGt73aeIVfmMMTXOIPqS1N3yUpVW5xcMWPTtFsE7eb 2qzsw26LRRSReKbXtT6J3ds4VBjmBrIZV/5btfoCgM5fE4pHcCjY6z7XcYSWZY/YvVYX6z82eTu dEL84M6nOgb3Fc32bTAS8R3t0eKDyOHjCqnmAuV2ESjZWdwp4i4/4QjFLv+xwSzfFRU91jkPmoc uN8uE8uvvYvzHA7pN92aKsEdQvBlKm+3UveXKfoNVt00Uby4M7ByDhPYkR8yiBUh4zUSkh3FTTe QGmV/8B/7CWRePNf/OxPhJ7yrOHbSkdcEvwX9IBMP7ZAWg5PkpLkpXA+jECLT4gQQZ2rVeaisHN OMEbIWxbCQlc1773yDKDy7rfFd+qwUm6BNi/MiabMRkXv2iO7X6Xf544UUFR7HcO2Zv0BNShVfU jLZHnZiITwMMLG2O5xP9oZ6WFWo6Od9TOuHrTvkLrkfom8k9JPOAIHEFkjDivOabZRVxFDDNZU/ 771PELjvV3wE34Oi25g== X-Received: by 2002:a05:6820:5086:b0:71a:ecfc:4438 with SMTP id 006d021491bc7-71bf2038cb1mr2256128eaf.24.1796406126968; Fri, 04 Dec 2026 09:42:06 -0800 (PST) Received: from bcodding.csb.hammerspace.com ([66.97.168.37]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-71bef0cd34asm3035398eaf.3.2026.12.04.09.42.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 09:42:06 -0800 (PST) From: Benjamin Coddington To: Trond Myklebust , Anna Schumaker , Mike Snitzer Cc: Olga Kornievskaia , linux-nfs@vger.kernel.org Subject: [PATCH v5 01/12] NFS: resend O_DIRECT write requests that error cleanup gets with -EAGAIN Date: Fri, 4 Dec 2026 12:41:52 -0500 Message-ID: <800dceb7f4876ff11c2424da73bc05fc1ce95b58.1796405840.git.bcodding@hammerspace.com> 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 layout driver's pg_init can fail a descriptor with -EAGAIN while it still holds queued requests; flexfiles does this when the mirror count changes. nfs_pageio_error_cleanup() hands those requests to error_cleanup, and for O_DIRECT writes nfs_write_sync_pgio_error() just unlocks and releases them. nfs_direct_write_schedule_iovec() treats -EAGAIN as soft and defers only the request it was adding, so the queued requests, already counted in requested_bytes, are never written and no error is reported. Pass the descriptor's nfs_direct_req to error_cleanup. On -EAGAIN, put the O_DIRECT write requests on the commit list and set NFS_ODIRECT_RESCHED_WRITES so the write completion resends them. Move that code out of nfs_direct_write_reschedule_io() into nfs_direct_write_requeue() and use it in both places. This also changes the other -EAGAIN cleanups of O_DIRECT write requests: the requests queued in nfs_direct_write_reschedule()'s descriptor, a mirror copy cleaned up by nfs_pageio_cleanup_request(), and the pages left over when nfs_pageio_resend() fails with -EAGAIN are all requeued rather than released. Fixes: 954998b60caa ("NFS: Fix error handling for O_DIRECT write scheduling") Cc: stable@vger.kernel.org # v6.6+ Signed-off-by: Benjamin Coddington --- fs/nfs/direct.c | 48 +++++++++++++++++++++++++---------------- fs/nfs/pagelist.c | 7 +++--- fs/nfs/read.c | 3 ++- fs/nfs/write.c | 5 +++-- include/linux/nfs_xdr.h | 3 ++- 5 files changed, 41 insertions(+), 25 deletions(-) diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index a3c6e8f4ea06..c771bb1b0730 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -330,7 +330,8 @@ static void nfs_direct_read_completion(struct nfs_pgio_header *hdr) hdr->release(hdr); } -static void nfs_read_sync_pgio_error(struct list_head *head, int error) +static void nfs_read_sync_pgio_error(struct list_head *head, int error, + struct nfs_direct_req *dreq) { nfs_release_request_list(head); } @@ -818,39 +819,50 @@ static void nfs_direct_write_completion(struct nfs_pgio_header *hdr) hdr->release(hdr); } -static void nfs_write_sync_pgio_error(struct list_head *head, int error) +static void nfs_direct_write_requeue(struct nfs_direct_req *dreq, + struct list_head *head) { + struct nfs_commit_info cinfo; struct nfs_page *req; + nfs_init_cinfo_from_dreq(&cinfo, dreq); + spin_lock(&dreq->lock); + if (dreq->error == 0) + dreq->flags = NFS_ODIRECT_RESCHED_WRITES; + spin_unlock(&dreq->lock); while (!list_empty(head)) { req = nfs_list_entry(head->next); nfs_list_remove_request(req); - nfs_unlock_and_release_request(req); + nfs_unlock_request(req); + nfs_mark_request_commit(req, NULL, &cinfo, 0); } } -static void nfs_direct_write_reschedule_io(struct nfs_pgio_header *hdr) +static void nfs_write_sync_pgio_error(struct list_head *head, int error, + struct nfs_direct_req *dreq) { - struct nfs_direct_req *dreq = hdr->dreq; struct nfs_page *req; - struct nfs_commit_info cinfo; - - trace_nfs_direct_write_reschedule_io(dreq); - nfs_init_cinfo_from_dreq(&cinfo, dreq); - spin_lock(&dreq->lock); - if (dreq->error == 0) - dreq->flags = NFS_ODIRECT_RESCHED_WRITES; - set_bit(NFS_IOHDR_REDO, &hdr->flags); - spin_unlock(&dreq->lock); - while (!list_empty(&hdr->pages)) { - req = nfs_list_entry(hdr->pages.next); + /* -EAGAIN: requests already counted by the caller must be resent */ + if (error == -EAGAIN) { + nfs_direct_write_requeue(dreq, head); + return; + } + while (!list_empty(head)) { + req = nfs_list_entry(head->next); nfs_list_remove_request(req); - nfs_unlock_request(req); - nfs_mark_request_commit(req, NULL, &cinfo, 0); + nfs_unlock_and_release_request(req); } } +static void nfs_direct_write_reschedule_io(struct nfs_pgio_header *hdr) +{ + trace_nfs_direct_write_reschedule_io(hdr->dreq); + + set_bit(NFS_IOHDR_REDO, &hdr->flags); + nfs_direct_write_requeue(hdr->dreq, &hdr->pages); +} + static const struct nfs_pgio_completion_ops nfs_direct_write_completion_ops = { .error_cleanup = nfs_write_sync_pgio_error, .init_hdr = nfs_direct_pgio_init, diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index c76c32a33be5..0bb18acaf872 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c @@ -1209,7 +1209,8 @@ nfs_pageio_cleanup_request(struct nfs_pageio_descriptor *desc, LIST_HEAD(head); nfs_list_move_request(req, &head); - desc->pg_completion_ops->error_cleanup(&head, desc->pg_error); + desc->pg_completion_ops->error_cleanup(&head, desc->pg_error, + desc->pg_dreq); } /** @@ -1340,7 +1341,7 @@ static void nfs_pageio_error_cleanup(struct nfs_pageio_descriptor *desc) for (midx = 0; midx < desc->pg_mirror_count; midx++) { mirror = nfs_pgio_get_mirror(desc, midx); desc->pg_completion_ops->error_cleanup(&mirror->pg_list, - desc->pg_error); + desc->pg_error, desc->pg_dreq); } } @@ -1443,7 +1444,7 @@ int nfs_pageio_resend(struct nfs_pageio_descriptor *desc, nfs_pageio_complete(desc); if (!list_empty(&pages)) { int err = desc->pg_error < 0 ? desc->pg_error : -EIO; - hdr->completion_ops->error_cleanup(&pages, err); + hdr->completion_ops->error_cleanup(&pages, err, hdr->dreq); nfs_set_pgio_error(hdr, err, hdr->io_start); return err; } diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 1fdca07761f6..ad9e948f4cb1 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c @@ -220,7 +220,8 @@ static void nfs_initiate_read(struct nfs_pgio_header *hdr, } static void -nfs_async_read_error(struct list_head *head, int error) +nfs_async_read_error(struct list_head *head, int error, + struct nfs_direct_req *dreq) { struct nfs_page *req; diff --git a/fs/nfs/write.c b/fs/nfs/write.c index af8735d0d67f..7967487e026c 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -1378,7 +1378,8 @@ static void nfs_redirty_request(struct nfs_page *req) nfs_release_request(req); } -static void nfs_async_write_error(struct list_head *head, int error) +static void nfs_async_write_error(struct list_head *head, int error, + struct nfs_direct_req *dreq) { struct nfs_page *req; @@ -1394,7 +1395,7 @@ static void nfs_async_write_error(struct list_head *head, int error) static void nfs_async_write_reschedule_io(struct nfs_pgio_header *hdr) { - nfs_async_write_error(&hdr->pages, 0); + nfs_async_write_error(&hdr->pages, 0, NULL); } static const struct nfs_pgio_completion_ops nfs_async_write_completion_ops = { diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index c0e29b4dfa62..fce0e773bd7b 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1742,7 +1742,8 @@ struct nfs_commit_data { }; struct nfs_pgio_completion_ops { - void (*error_cleanup)(struct list_head *head, int); + void (*error_cleanup)(struct list_head *head, int error, + struct nfs_direct_req *dreq); void (*init_hdr)(struct nfs_pgio_header *hdr); void (*completion)(struct nfs_pgio_header *hdr); void (*reschedule_io)(struct nfs_pgio_header *hdr); -- 2.53.0