From patchwork Thu Mar 28 16:34:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13609086 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2511DCD1283 for ; Thu, 28 Mar 2024 16:38:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A1F336B00B9; Thu, 28 Mar 2024 12:38:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9CDDB6B00BB; Thu, 28 Mar 2024 12:38:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 847276B00BC; Thu, 28 Mar 2024 12:38:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 6272B6B00B9 for ; Thu, 28 Mar 2024 12:38:08 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 34CB9160E7A for ; Thu, 28 Mar 2024 16:38:08 +0000 (UTC) X-FDA: 81947005056.14.124A1B1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 83D4A80007 for ; Thu, 28 Mar 2024 16:38:06 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JAMszjV6; spf=pass (imf02.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711643886; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YXmc3YCo60jECje6D8F3mfZ1bN1Jr5ynl0cOwSqeZGY=; b=TGm+KRfUl4n1SZnYc6aZ8e/ytA6wegkWAqzGeo+7h3XgzuEHxsbI6GVTxzld4iVr8CRlL4 IH77IHlY+zMon7HFhSkcGxNC/V2SAsSoF8SfPPD9FClNqlA1SxpNu1XfYNKeG0dl9mAAou CK3ylTA6A6JjPjPEyjBMGx7s3wE0nCg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711643886; a=rsa-sha256; cv=none; b=vItHxiRXMjXMOwexiwUznOZ3rSSAIfFfZXWpymekrVCuZzNd50ReE7V3BW3AeuH2x155Mi iR9KEKcm6PYZ9NLhDjdQLNuGTX97DdNPddmk5hX2scdkepMTGkOVBIdAulC4ZuQ4E0HEO4 HyzcxBIDcUa8NibTQcXR6giRujFK9Vs= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JAMszjV6; spf=pass (imf02.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711643885; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YXmc3YCo60jECje6D8F3mfZ1bN1Jr5ynl0cOwSqeZGY=; b=JAMszjV6K50RZrG61gFMN2aTRF1QRiGpLE3jwjgrJaK2CNDUbHPVVPg3UEwDe4nyoxhPhi /v3RCNh8KfTt7UC57C8VMWcFjLqfX+iBY27jA31om4lq1CHU+5Yx8AgMRYOJi31oNE6BpX 0kWpBb/VBhOF8LMmy/YrNayIJun+348= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-252-8jp_rTaQOFW2Kmd5vBMnHA-1; Thu, 28 Mar 2024 12:38:02 -0400 X-MC-Unique: 8jp_rTaQOFW2Kmd5vBMnHA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5A18A88F2EC; Thu, 28 Mar 2024 16:38:01 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.146]) by smtp.corp.redhat.com (Postfix) with ESMTP id 72392492BD0; Thu, 28 Mar 2024 16:37:58 +0000 (UTC) From: David Howells To: Christian Brauner , Jeff Layton , Gao Xiang , Dominique Martinet Cc: David Howells , Matthew Wilcox , Steve French , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Eric Van Hensbergen , Ilya Dryomov , netfs@lists.linux.dev, linux-cachefs@redhat.com, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 17/26] netfs: Fix writethrough-mode error handling Date: Thu, 28 Mar 2024 16:34:09 +0000 Message-ID: <20240328163424.2781320-18-dhowells@redhat.com> In-Reply-To: <20240328163424.2781320-1-dhowells@redhat.com> References: <20240328163424.2781320-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Rspamd-Queue-Id: 83D4A80007 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ght9f7sn77xgxho3hr7mwjcpcxuhe8cy X-HE-Tag: 1711643886-900840 X-HE-Meta: U2FsdGVkX1/UGx5lJ/hcznSiS237DiLxyLULbZcSLwPz6B6bnt82O5Vb5K9MYMLAbxBMsKfKiYRoUSNGuoHFDBOEDxtMXn0SpOYLLS5dbcdv75NX7jmGgQsI5gSQR7wwJWoagaYJU4YkiPKsEZqZjcCUAZ4hrArUcjJGSymy/Ltbsb9iKOL5D+M/uolx2mpuybo1k6Cuye4680HwMM+QArKsmaK8x/zCCLMP+nfVUKTrDlQSmVQ7KPjCUqbqUUQib1zwuRjB/UFkDlsgcM3upaTPFaHJ+PplxCsT+AyUlaCF3HIF7806cYc5/4cZuUMKPXJlkxKTebGqjf3GljY1U28ll9YgDSNkWkFaaBAwxk8M9SXH9819kC/uJgfiqcoxNDi7UkK6fJYID4ioNu6Hb2bMAUjgB9mCz/Qzn6rUoNXMIww9meu0OCbNQSIdChz0FmdNl4O8OjZbTa5bev2g8knUoXYIpGs48TrZiuur91ALoN+JehROCKggE5C/aVxaAJY/V4I20A6m5bYNNL/uhTAYvaiGZrJZnV00rxNqiTvkw1ytjF5y2NkkIVeaIdM8NMKJY82r9EfAUC4yko1XzI7ffSevnnOLRYsk9sYw45SW0hvwFpjqSMKhWNiPi7AAdbD886+WWnum59mjwQouO/nn+k7YWA1VNLChXteS761yzZOxH20qmbbM/Rocue6JnjbiWloZurlBe+Itd+2Nkdu2KhIg1sXPEdxILbqQIhCSYCADHyBD4n27ncojl1BdDlqk0kdPQphMObEPUraGBbHiCclRzsDjEjALWwktzJYd6FCw5m1qioxftdZL8kxfsTG4Ph2qcgvPaqlSZfGXzp3vZ/USpLC56NSXsrsAqUtfsBAG77CW0emS0t5LqSnO+bkXe+Rq/kk63n4ESDfaLX74RvZIu/R/wRGYvaQ00dCn3IImmVFsy5rDMfnJ7w03aDuv8s08PVze5/eXDbO vnUGsSwr mpzucnXyGcFaljnPO7q68EVjq5W1FLKOGOXn2c8TBCxZDjnDiyqdNurerq4Cz8Ky2ttlt2oKTiA5RtO00T49K24+GkLX0FLcuf1SE4OgdUzoMjVfvYNvpgKnIIIizTX4T7syPPnMrho4hBWEc9VQ5iv5sT8syNejCoDHQ/OwOAOMqGPZlebbuadbJgXup0HJIPuW+Wm/p7OSK11wImIP8br3FTj0G6pvBxlwicTssOMfE4w8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Fix the error return in netfs_perform_write() acting in writethrough-mode to return any cached error in the case that netfs_end_writethrough() returns 0. Signed-off-by: David Howells cc: Jeff Layton cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org Reviewed-by: Jeff Layton --- fs/netfs/buffered_write.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c index 8e4a3fb287e3..db4ad158948b 100644 --- a/fs/netfs/buffered_write.c +++ b/fs/netfs/buffered_write.c @@ -188,7 +188,7 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter, enum netfs_how_to_modify howto; enum netfs_folio_trace trace; unsigned int bdp_flags = (iocb->ki_flags & IOCB_SYNC) ? 0: BDP_ASYNC; - ssize_t written = 0, ret; + ssize_t written = 0, ret, ret2; loff_t i_size, pos = iocb->ki_pos, from, to; size_t max_chunk = PAGE_SIZE << MAX_PAGECACHE_ORDER; bool maybe_trouble = false; @@ -409,10 +409,12 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter, out: if (unlikely(wreq)) { - ret = netfs_end_writethrough(wreq, iocb); + ret2 = netfs_end_writethrough(wreq, iocb); wbc_detach_inode(&wbc); - if (ret == -EIOCBQUEUED) - return ret; + if (ret2 == -EIOCBQUEUED) + return ret2; + if (ret == 0) + ret = ret2; } iocb->ki_pos += written;