From patchwork Fri Dec 13 13:50:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13907057 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 771A8E7717D for ; Fri, 13 Dec 2024 13:50:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE12F6B0083; Fri, 13 Dec 2024 08:50:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A69636B0085; Fri, 13 Dec 2024 08:50:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8BC7C6B0088; Fri, 13 Dec 2024 08:50:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 6B3EA6B0083 for ; Fri, 13 Dec 2024 08:50:38 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id DD335AF533 for ; Fri, 13 Dec 2024 13:50:37 +0000 (UTC) X-FDA: 82890070368.05.BC3B036 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id D675718000A for ; Fri, 13 Dec 2024 13:50:32 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=J9u0NfwY; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734097824; 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=zFfHFGyfFLnfH39ds9xcldOHx5zC/fcdWITNBPuGcyY=; b=OfhPdIM++YTP8R7sc0vERSCjNj9r0bzGGPIdIdYLntB+J78jgcX4mowxq3nR8gbhfB4d54 PBA4ihyNmLzpNFdCvWcFqDY7XsxAOpl0OIARN/7icVdRFQW85a2lgYUC+eUHvIsIFCWXgc RWB+uBXfxlkskSgWEZk9Zw/ZRbjpdQ0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734097824; a=rsa-sha256; cv=none; b=AZ48WHGZv2UNuBkDTyKa4TgR7gAZdYNlg+lP3e+/SrHubCHa1TSlXXnx+ff6VDLDgakfgk kSxWb5lRD8hd6At4tVM1EOO+qf0l44l8bt4ad/ON1ph+J3Lx2N/PO7a0Wnt+qAxPWlhlvK IuQfYtVsn1OqBJyUgDwn5bhaeA6Ws1w= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=J9u0NfwY; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734097835; 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=zFfHFGyfFLnfH39ds9xcldOHx5zC/fcdWITNBPuGcyY=; b=J9u0NfwYyQzfdcCDiRMwWHEYIxKLB6ONi2wv5iLjX6STtFiyFQH8j1PgmPDIiGVlO7kEM9 Xb9/7R7B23QyfQQX7y+vDaQmKBvbVtwkffIkNBqpHqb9dr/W2MZjrG+KRz9wIE37so2eiD hDLF4oDZs/N7Sz+nWrMhOxPm86qAcDI= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-166-qo9Op8B1MvuELGCTRl92nA-1; Fri, 13 Dec 2024 08:50:33 -0500 X-MC-Unique: qo9Op8B1MvuELGCTRl92nA-1 X-Mimecast-MFC-AGG-ID: qo9Op8B1MvuELGCTRl92nA Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A073919560A6; Fri, 13 Dec 2024 13:50:30 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.48]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BB0A9195394B; Fri, 13 Dec 2024 13:50:23 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Max Kellermann , Ilya Dryomov , Xiubo Li , Trond Myklebust , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, 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, linux-kernel@vger.kernel.org, Masahiro Yamada , Marc Dionne Subject: [PATCH 01/10] kheaders: Ignore silly-rename files Date: Fri, 13 Dec 2024 13:50:01 +0000 Message-ID: <20241213135013.2964079-2-dhowells@redhat.com> In-Reply-To: <20241213135013.2964079-1-dhowells@redhat.com> References: <20241213135013.2964079-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Stat-Signature: wo5swzt1mg1i1rj7hcn1zs91w88gx4yr X-Rspamd-Queue-Id: D675718000A X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1734097832-196856 X-HE-Meta: U2FsdGVkX18tIgANXv0uMFIsJutIMcHydkV7jZtfnXQZ/1EE5m0OwML9sy5FLgDNOqaltnBtjL3aIHFbmFfz+wecszShbPvm8stcPcsfFKfbPJRSA1MAV8C5s8bOD78fWanOpxZlCQed5x/rdTeqZYraq1YHoxdYSqTTKSsib4Yl1Ay9mCDAo1V5IvgHENHOY1kG+JuwODuHRiVNuL6Cbcghe0fwLGtHeCCnGN7wMN47wP9oTSNrw0bFqlDlh2Vv75HcQT3TpwpzPafqlZC2vW6lzC4TyCEboFiA9zjy+FEvkEswefHexJrVT7P1hKEs0y2L6IngmRhccS/oC91XJewNhCjXJggyU8Hhd8ywdND4mry45KVyO8snRoapOREaoNfMqPiF6BEKqTSrqd2yiFpRCCpUDBhXsSqE0JOSbU2PesduZF2BQY8ujLV2ooJYsrMzObfLHPjgSyDu7kVIYPvq8rnOpC8Y4fo57quuydb77hfnAAGqAYqRnwDB3jslMjHEhqjo8T7YC6NvN7TyuDO0LqWyBItnqJPWtUD3OZVjSFo6YPLC5rTHXL7yJLCbnwilTHJgF6nVLP/sr8Q4y1dPRSTarvgzoOrFUrHYDzPOKofHhCHqhWokv9bceLTvxpRTFH07Pt2s9Zp3wssTjN2zEEvq1xI4GfAH0StkgzewZjfp6p7FonLxo43HtxeeL9vx+DRo+zhBZ87cqb+wcIA7tfKPLZomhm4F+ax2B95xPPIm9uf0+UmrHU8fkMNafTdDcUqypSTOzbEsANnISTJuvavEAGty4n2D/bqBoK/qGzQpoVvQH4Djcv1m6gWiH1BPWSAWYn0T/R3swnFs8jjTP3OkdXpF3JTmFZTPLJay6f2nUTJY6DFNijheI25UylKkbhN5Thkbu9x/2KW/P5eAlII93+oBwt2clshF3485O/8NELtnPOG6pNFne0Jio7KF1wZpalzzRw0+qLU FVnzJ8lv z+bhkLC4VuE9kO5URe+16Km4cCNLMQ1C8HSrMHi0avjMan8URRGdJxwByd2iYA9RPs8bxkwuPbgGkeIS27eZFr1sLPv3wIgH8vuU0thhucdjLnhkNS7kLZOCLRiqJSLfui4MYhXNYHNXJYCe3TkOBzAgHlXwTuA+4YbgySUSDA+nW3abwLOgyaxwDDwff8xd1w1RrCDfRmSD/xnj+/j+ihUP3//CICuH0hKy3Srj18yu0XVc8bsweibt+gpUmfd8CwUXYa+IR5KbibqTzrcuwOE24hr6IsR5h1FJxylE8pCbxky6PEHByuasbcLL8NntHFyC3/HQi4OpK/ndgFBEn9OhR4rC46lWB76fC6vX14FFxSZs3N9uc+fwG0UUlLlcxHv0yQXtaJ852F9r7WpxTbEA65JjVkjOqmhn9OERI8MkP8bnoPytE3NV7hXJ1GX4+ePrEPCZoFM90mKk8PNnRvG9/tA== 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: Tell tar to ignore silly-rename files (".__afs*" and ".nfs*") when building the header archive. These occur when a file that is open is unlinked locally, but hasn't yet been closed. Such files are visible to the user via the getdents() syscall and so programs may want to do things with them. During the kernel build, such files may be made during the processing of header files and the cleanup may get deferred by fput() which may result in tar seeing these files when it reads the directory, but they may have disappeared by the time it tries to open them, causing tar to fail with an error. Further, we don't want to include them in the tarball if they still exist. With CONFIG_HEADERS_INSTALL=y, something like the following may be seen: find: './kernel/.tmp_cpio_dir/include/dt-bindings/reset/.__afs2080': No such file or directory tar: ./include/linux/greybus/.__afs3C95: File removed before we read it The find warning doesn't seem to cause a problem. Fix this by telling tar when called from in gen_kheaders.sh to exclude such files. This only affects afs and nfs; cifs uses the Windows Hidden attribute to prevent the file from being seen. Signed-off-by: David Howells cc: Masahiro Yamada cc: Marc Dionne cc: linux-afs@lists.infradead.org cc: linux-nfs@vger.kernel.org cc: linux-kernel@vger.kernel.org --- kernel/gen_kheaders.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/gen_kheaders.sh b/kernel/gen_kheaders.sh index 383fd43ac612..7e1340da5aca 100755 --- a/kernel/gen_kheaders.sh +++ b/kernel/gen_kheaders.sh @@ -89,6 +89,7 @@ find $cpio_dir -type f -print0 | # Create archive and try to normalize metadata for reproducibility. tar "${KBUILD_BUILD_TIMESTAMP:+--mtime=$KBUILD_BUILD_TIMESTAMP}" \ + --exclude=".__afs*" --exclude=".nfs*" \ --owner=0 --group=0 --sort=name --numeric-owner --mode=u=rw,go=r,a+X \ -I $XZ -cf $tarfile -C $cpio_dir/ . > /dev/null From patchwork Fri Dec 13 13:50:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13907058 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 5788FE77180 for ; Fri, 13 Dec 2024 13:50:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E88F16B0088; Fri, 13 Dec 2024 08:50:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E12446B0089; Fri, 13 Dec 2024 08:50:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C8C436B008A; Fri, 13 Dec 2024 08:50:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A38836B0088 for ; Fri, 13 Dec 2024 08:50:46 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 69FCC1C7D9A for ; Fri, 13 Dec 2024 13:50:46 +0000 (UTC) X-FDA: 82890070242.27.1C8EDB8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf20.hostedemail.com (Postfix) with ESMTP id B3AE61C0002 for ; Fri, 13 Dec 2024 13:50:17 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Rgc7YuW9; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1734097827; 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=XyqR/WjDCwAE5X+NDEcLa5xYMEUn9QBuN0OBrTmThCY=; b=lrVK27iwhbwqhCg8tHiW0/9bp7gvWZKO2YRMZm2rSLiifBRQ3InIxyB4QhcgRJ3OwgC0od EZcefx5Mv8H38wd3RpmC2zKzyYvnst823m+fJHmHH1R9H5VIVrxwGraoqyaqrnieugT3i1 6jvDVeyuOaVvRqu4DxCEqpBQZLqX04E= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Rgc7YuW9; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734097827; a=rsa-sha256; cv=none; b=76OAQGMMs7efUsjYvjBF/qX66x+ScnRbjvupoEMC51yhA3S3HcyvVaBCtM3u8qRurv27uA XTFl/syNQbyfzaTsEZiotLqRv1qwfStHoEgZa3xkFd6oHO2RM2/ef5TjcwtS3PihfVsrJy mZQJ/fNRkYrFuRp6E44q8m6/cXTswA0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734097844; 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=XyqR/WjDCwAE5X+NDEcLa5xYMEUn9QBuN0OBrTmThCY=; b=Rgc7YuW9JNB//oZMuTVw7KwzVTQrGrFlf9xWClLXtH5PrC6i37r51AuCNiUccM8+YojxA1 iZHWFr4uTngWfXMm3tVmDEqXaUT5J6pvAczXHANEGNkBKEXobgGWN+70yBuWdsJu93tP2Z ynrBp9dzQoLOkh5pDU7KAJzVH/YF3vg= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-73--YEkMWSgNkChCQp0_JqhQQ-1; Fri, 13 Dec 2024 08:50:40 -0500 X-MC-Unique: -YEkMWSgNkChCQp0_JqhQQ-1 X-Mimecast-MFC-AGG-ID: -YEkMWSgNkChCQp0_JqhQQ Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7662919560AF; Fri, 13 Dec 2024 13:50:37 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.48]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1BF2F1956089; Fri, 13 Dec 2024 13:50:31 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Max Kellermann , Ilya Dryomov , Xiubo Li , Trond Myklebust , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, 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, linux-kernel@vger.kernel.org, Shyam Prasad N , Steve French , Paulo Alcantara Subject: [PATCH 02/10] netfs: Fix non-contiguous donation between completed reads Date: Fri, 13 Dec 2024 13:50:02 +0000 Message-ID: <20241213135013.2964079-3-dhowells@redhat.com> In-Reply-To: <20241213135013.2964079-1-dhowells@redhat.com> References: <20241213135013.2964079-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Server: rspam05 X-Stat-Signature: og6e5aefzddpbg1omtd8m3xw77ecikdb X-Rspamd-Queue-Id: B3AE61C0002 X-Rspam-User: X-HE-Tag: 1734097817-261570 X-HE-Meta: U2FsdGVkX18Nt/OycgGZ4AQL3l9VIcp/GXKkFWaSF1LE5ODtU3Yo68QUSHTzX+o8nVrhZiMc6efMvF//jMeS/c4z1s9PHSK30X1cwp6bvs27PriV18+6zIsQsVUpnraHTOSvbRDdVWlTNQhNIKZJwl9O/b2bLzQRfKWipq8HjQupbiVktLgJGiqibQbX8RFQe1eUVU+9I/gHyta9CV3euZOaEqmpwJiyqm4L9yXvtTs/7Z7eSZtnjrI+/q86eLW7Q/c3OAbNr8lJXIHdeQKgeZqgHlYhEzwLTB/tAaz+w9SBdI57Q+R6k2J8KoYMFMDB1a5pGsYCnza7GwXm0Chby8scErWSQYpr2cBiCp2S8Sm0hVguGHZjgZFkmUAoFKB1o0ZwDce15/HxATbJ4QZL2rQl6GXVr3Bdgtwj0o26tygUFl1irs6fFMMuXUY5RgVDtLnAGb4d2h/k1ppCKYPg3ow88bCsrFpGEbnX11OqfZTNrnxnR+gIjjH0i6QMqjhxQ13OMX91KrmMpnDNsGiFi/KDAehfJydITwq2znqSwvfuCNw55wxuBtA5QPc5gS2kkA62AjSqwNlXybzYLTqe68EFHYKDR6v0l3/q+jrV+dyUkN7T2qFLAtB0uqJkdNOklkyA8NDuWgI2a84dUJyV6SQ540D0LQp0bybFL3UfY1wu4jckxErSQnsXXaps2GbexmfA9VX+NYT1w8iYVfYRGrdTqEXrPIVGTtI4Ex1e+irtDY2fh7k+NnY05JKqY3OcVkuquW+0ypwL69uNMqDKjX4vkF60vwCxIOoEW8IQuWGf3uoAj52PTC0PQrSTS1dOlx+O39x03i7BCnRr/vLAbPSYMCJTjljtiV1ETYl/x2Xcmu7onewX5kCVEIR0098eE4q9SON6zvpbjLPMKiUKzms7yLGDslAQVaDiDTOZUBj2hwZuRvoRGimIBVZZU7i0RGDYFYXogkj5FC2qe91 WCr6oby3 K420PZN97s6+eTrqd9PVCwFBxNzWxN+uwhqCGw3G40vQ3H/abmcfewNrCcumHW7nmJrsuYdMF/7w/T8GVPwYbPlv4a+MZE2aaQ6Pmw7GPML/uVa55HBtydbuwxihIQx1/a601cAac5Ldr2yfdrKy+0uLqu53S46cNLY1MpzMZL0B47n+i2ZCG+RFBc2pLVNTP9kHC51oI0oyQ2MSFiVSPzVsWH6RHTJVkwzG6IdB+vvAxbQ5v9jHy3pXqtsV/fOw0ps5wAvIw2Sv0ialwS97PEXRxf+8SKSptvasoyruwF0JYarUor6Oebo/5SqtZzUspzhl3ZXNiARim2qsXdsgj89jPprsZtGWQXUwWAkihwfcNJJsv7tfy7SRAkGP62AEnu2Mh8WrGNTJo08Qyb5k77irD3wTXn7cBN20Zps7MiZInmcQoCKBzCDbQWUUFkdaOwoaD4x4Iz015r4pKks/bazBlW39IPLPnY0oxfRFiVKk7UJ5gHARq2e+lLLg9EIG+y6S2oQkk9CxDd74lVsNONlDyteZrXfyjnIW/X8K3mIXaXaU= 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: When a read subrequest finishes, if it doesn't have sufficient coverage to complete the folio(s) covering either side of it, it will donate the excess coverage to the adjacent subrequests on either side, offloading responsibility for unlocking the folio(s) covered to them. Now, preference is given to donating down to a lower file offset over donating up because that check is done first - but there's no check that the lower subreq is actually contiguous, and so we can end up donating incorrectly. The scenario seen[1] is that an 8MiB readahead request spanning four 2MiB folios is split into eight 1MiB subreqs (numbered 1 through 8). These terminate in the order 1,6,2,5,3,7,4,8. What happens is: - 1 donates to 2 - 6 donates to 5 - 2 completes, unlocking the first folio (with 1). - 5 completes, unlocking the third folio (with 6). - 3 donates to 4 - 7 donates to 4 incorrectly - 4 completes, unlocking the second folio (with 3), but can't use the excess from 7. - 8 donates to 4, also incorrectly. Fix this by preventing downward donation if the subreqs are not contiguous (in the example above, 7 donates to 4 across the gap left by 5 and 6). Reported-by: Shyam Prasad N Closes: https://lore.kernel.org/r/CANT5p=qBwjBm-D8soFVVtswGEfmMtQXVW83=TNfUtvyHeFQZBA@mail.gmail.com/ Signed-off-by: David Howells cc: Steve French cc: Paulo Alcantara cc: Jeff Layton cc: linux-cifs@vger.kernel.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org Link: https://lore.kernel.org/r/526707.1733224486@warthog.procyon.org.uk/ [1] --- fs/netfs/read_collect.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/netfs/read_collect.c b/fs/netfs/read_collect.c index 3cbb289535a8..b415e3972336 100644 --- a/fs/netfs/read_collect.c +++ b/fs/netfs/read_collect.c @@ -247,16 +247,17 @@ static bool netfs_consume_read_data(struct netfs_io_subrequest *subreq, bool was /* Deal with the trickiest case: that this subreq is in the middle of a * folio, not touching either edge, but finishes first. In such a - * case, we donate to the previous subreq, if there is one, so that the - * donation is only handled when that completes - and remove this - * subreq from the list. + * case, we donate to the previous subreq, if there is one and if it is + * contiguous, so that the donation is only handled when that completes + * - and remove this subreq from the list. * * If the previous subreq finished first, we will have acquired their * donation and should be able to unlock folios and/or donate nextwards. */ if (!subreq->consumed && !prev_donated && - !list_is_first(&subreq->rreq_link, &rreq->subrequests)) { + !list_is_first(&subreq->rreq_link, &rreq->subrequests) && + subreq->start == prev->start + prev->len) { prev = list_prev_entry(subreq, rreq_link); WRITE_ONCE(prev->next_donated, prev->next_donated + subreq->len); subreq->start += subreq->len; From patchwork Fri Dec 13 13:50:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13907059 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 8B805E77180 for ; Fri, 13 Dec 2024 13:50:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 253966B008A; Fri, 13 Dec 2024 08:50:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1DDEA6B008C; Fri, 13 Dec 2024 08:50:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07DF06B0092; Fri, 13 Dec 2024 08:50:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id CF4F76B008A for ; Fri, 13 Dec 2024 08:50:52 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 778A342030 for ; Fri, 13 Dec 2024 13:50:52 +0000 (UTC) X-FDA: 82890070368.03.F7ADC36 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 4C2A140019 for ; Fri, 13 Dec 2024 13:50:27 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hod7ZKFr; spf=pass (imf11.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=1734097833; 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=EP45p+cLd1dDJ3/M9yBe/6nHDozsGhktItpu1CrIpGQ=; b=0TOjW2dioJWviFnool9E6oAVl7yQaoduWhMQteEo6R9Fn5/dOwpfq3zAQxtPc9kzOqOb22 XguWWzHKOwcbH8ooyPtcdUq2ZLMsC29DLyV5e/geDZp+WmIkh4joXg2ZHjVMTmPEokKg9R 605IHXV16l7v2kPXPbFYG6MRwmfr9lU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734097833; a=rsa-sha256; cv=none; b=FmkLg4cPkW8iDPo/47yaRpEmsGR35kLTwa2B1LSIv1+mmA4GtGfe8SksqSGK+KoHfhfIBZ T6eE1qRK8/aUD6TwionmSCB/4hTXztXJH+zeJOs0sZhcMinxZOpCjRkDP8uAb0+IwSs0LA jFzDVZL1BATn7e7Nfq2mZ/ljPrP1ifM= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hod7ZKFr; spf=pass (imf11.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=1734097850; 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=EP45p+cLd1dDJ3/M9yBe/6nHDozsGhktItpu1CrIpGQ=; b=hod7ZKFrsZ9CGVnJhIxiZSSz5OLer/7C1glbHR+jJt6RAK1ax/UYGpqN8w2X3IGfD0WAI0 4f2SPA7lgqHNa3vP4wK1Mj/zyGjsVPyIa3DcGRTZCqfRqCHAFYsoktQsj4rKFPKM1PaWvQ StGpB8BKpGw3oHZJK1k/Jl6/EAno6N8= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-638-UcRIgQcnN_-cN26AjAuVpA-1; Fri, 13 Dec 2024 08:50:46 -0500 X-MC-Unique: UcRIgQcnN_-cN26AjAuVpA-1 X-Mimecast-MFC-AGG-ID: UcRIgQcnN_-cN26AjAuVpA Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 96F4C1955F28; Fri, 13 Dec 2024 13:50:43 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.48]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C692F1956052; Fri, 13 Dec 2024 13:50:38 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Max Kellermann , Ilya Dryomov , Xiubo Li , Trond Myklebust , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, 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, linux-kernel@vger.kernel.org, syzbot+404b4b745080b6210c6c@syzkaller.appspotmail.com, Dmitry Antipov Subject: [PATCH 03/10] netfs: Fix enomem handling in buffered reads Date: Fri, 13 Dec 2024 13:50:03 +0000 Message-ID: <20241213135013.2964079-4-dhowells@redhat.com> In-Reply-To: <20241213135013.2964079-1-dhowells@redhat.com> References: <20241213135013.2964079-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 4C2A140019 X-Stat-Signature: r74cb4b4jns9of4tsyk8hmqs4gk3s1be X-Rspam-User: X-HE-Tag: 1734097827-977368 X-HE-Meta: U2FsdGVkX1/Vf4Z6SVuvmRMKmzvO8bWUvanpVEBeDUq8hLoMoeMY0w673iEev4UmlosIVELmvGDkeRuc2vCfQRGpS07uCu7N7EwkyQdmMmQ15ibg+oobGstdrWSPeDjgnhscta2QNSw1L1N+tVd+C8rluecoE0tFetGu0Kz4on5bGjqrE5r46X0JPw9R2aoSF9lA7tzJOT9SyVI0GNdlQcnpkSVi5QrM88vaygWwwA7DS03Ag6mlGNlA2f2lBhg1cBkJ4VTrJpyJ6jjZEnoeTuPCmlLRYA92f9039O9wR6ISr5O/6ArYr6ywV9RLByaW5IgI26Lp0tzQGK7hwYps/Dbkl4b1XZgADh9Byks2yQpBaDOcBdRU0yR0AT/tUDubBo5hZRBP9dGs4mxYAl3TXz66xkS45GC+z92xy40Pv8EUheeOkmmxxgNrFthaWLrutaz0RmbfDJRuDr3SCI8Yi3koezG0Yck41Sr7mOeOejb97REWSXhv+/kefUyv6AAAfcDCN+cFyHNXNSotnZozudIlkar7lT/tBMxE8LVMh67Q1uebGImcxza7kSVS0a0JqYSBo9t5WKbmaLTYovwQCfdLiEmRUNC1sgqwKxHg709+dQ2HUrBFu5A/0epNu75Jd2YZM5REue8Yl+Cxh0HJVf7I5KyCyFr6z6S51lUN50c2h2EFMgyX6GdbVlKJaOMKzegnCj2m6pywKU5hs8pEvxLx56f2TffQTf+fbTYeRDgMU1q1gi2VkUphwAohJHrsC4oZoqgE4HCdj1p6YGSOHSeiSCpPvaSVcx+2z3MCV4GxanNCu5G5LEku5ryzS4leIwX1JGyOwo6+MNSJzN7VSUn9hbualxSsSwmXfLID+ntibnxE83zmwToBKRP9NHSCPt7nMnaaNsZL6G6HoAyfZ3ssdOHOOUWKGlJX3eg68nkv+ajtIHja4THliMGg3LAw5S+WA/EQkDrSRotrRUy UwD3C1zj VqYFCLUvJX1dMB06Zv/Kn803+0cOel6GVjmjT44kebOCmmhogu0XMKAD2EiYYClzL+V2Hz6n5BhHKm1IQTD1/AomA/vg7dKQ61M//p9pp5DG9je+6lgWdnS2sJThEbLFrlIzbK1wrgYRkxy0JGNB2EJ9mq4FmGKOowhkGbUXlv2hWVt8Gi6+C7N8y8Uaofb4T/sQYxB5CF6j4zZYRWwGod28IO8KqSSrI5KzuP9OUV2Csz2JuCihmtqGLHx1oWdTvg+cKHMHv5g8yS2ko6i2mf+mThir1DRrHSYFNRBtIe6ax/SS5gVKRw0wfQP1KttDBV+J9h+x+hHi6MbqZbiHbBSMUGvpgSUjbxE8VncjhwVWlKs67u0uHvCJakdnXgVAz80tOHeqh4RossBGdeF4Oltdg0WsRwwTxPVwPVrk65ZTDeIKvdqQXWH+9aXfplDLJ+C+IfONtOYoXRMVa1//mA031ys5nWhjkMswnkw0w/mtyyl2Fd/GcSiXH0ixx1ziBsV3RtS66A55csGbLkjFHPXvU5M+KlXOWWBu9bjMC9MK+r+jHW7PlEGE8X4ZfVIdC0NIWEfWUFAfYlV/EL+Rn88n7W6am1X+Agc/+TS0VQv96l9RIF0IQTpf6/4RtWfGYNH+ULPZ6LzVtNh9+IdNtiJOJZ9RYd700RxCMcbn6R2cK99aw9lEqWyg/k9NlNF/Whh7A 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: If netfs_read_to_pagecache() gets an error from either ->prepare_read() or from netfs_prepare_read_iterator(), it needs to decrement ->nr_outstanding, cancel the subrequest and break out of the issuing loop. Currently, it only does this for two of the cases, but there are two more that aren't handled. Fix this by moving the handling to a common place and jumping to it from all four places. This is in preference to inserting a wrapper around netfs_prepare_read_iterator() as proposed by Dmitry Antipov[1]. Link: https://lore.kernel.org/r/20241202093943.227786-1-dmantipov@yandex.ru/ [1] Fixes: ee4cdf7ba857 ("netfs: Speed up buffered reading") Reported-by: syzbot+404b4b745080b6210c6c@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=404b4b745080b6210c6c Signed-off-by: David Howells cc: Dmitry Antipov cc: Jeff Layton cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org --- fs/netfs/buffered_read.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c index 7ac34550c403..4dc9b8286355 100644 --- a/fs/netfs/buffered_read.c +++ b/fs/netfs/buffered_read.c @@ -275,22 +275,14 @@ static void netfs_read_to_pagecache(struct netfs_io_request *rreq) netfs_stat(&netfs_n_rh_download); if (rreq->netfs_ops->prepare_read) { ret = rreq->netfs_ops->prepare_read(subreq); - if (ret < 0) { - atomic_dec(&rreq->nr_outstanding); - netfs_put_subrequest(subreq, false, - netfs_sreq_trace_put_cancel); - break; - } + if (ret < 0) + goto prep_failed; trace_netfs_sreq(subreq, netfs_sreq_trace_prepare); } slice = netfs_prepare_read_iterator(subreq); - if (slice < 0) { - atomic_dec(&rreq->nr_outstanding); - netfs_put_subrequest(subreq, false, netfs_sreq_trace_put_cancel); - ret = slice; - break; - } + if (slice < 0) + goto prep_iter_failed; rreq->netfs_ops->issue_read(subreq); goto done; @@ -302,6 +294,8 @@ static void netfs_read_to_pagecache(struct netfs_io_request *rreq) trace_netfs_sreq(subreq, netfs_sreq_trace_submit); netfs_stat(&netfs_n_rh_zero); slice = netfs_prepare_read_iterator(subreq); + if (slice < 0) + goto prep_iter_failed; __set_bit(NETFS_SREQ_CLEAR_TAIL, &subreq->flags); netfs_read_subreq_terminated(subreq, 0, false); goto done; @@ -310,6 +304,8 @@ static void netfs_read_to_pagecache(struct netfs_io_request *rreq) if (source == NETFS_READ_FROM_CACHE) { trace_netfs_sreq(subreq, netfs_sreq_trace_submit); slice = netfs_prepare_read_iterator(subreq); + if (slice < 0) + goto prep_iter_failed; netfs_read_cache_to_pagecache(rreq, subreq); goto done; } @@ -318,6 +314,14 @@ static void netfs_read_to_pagecache(struct netfs_io_request *rreq) WARN_ON_ONCE(1); break; + prep_iter_failed: + ret = slice; + prep_failed: + subreq->error = ret; + atomic_dec(&rreq->nr_outstanding); + netfs_put_subrequest(subreq, false, netfs_sreq_trace_put_cancel); + break; + done: size -= slice; start += slice; From patchwork Fri Dec 13 13:50:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13907060 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 87FABE7717D for ; Fri, 13 Dec 2024 13:50:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 206156B0092; Fri, 13 Dec 2024 08:50:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B6A26B0093; Fri, 13 Dec 2024 08:50:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 030CA6B0095; Fri, 13 Dec 2024 08:50:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D5BF16B0092 for ; Fri, 13 Dec 2024 08:50:58 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 695F5160E0C for ; Fri, 13 Dec 2024 13:50:58 +0000 (UTC) X-FDA: 82890070620.19.07A6A51 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 5B3522000B for ; Fri, 13 Dec 2024 13:50:31 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=N7L+xOIG; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734097832; a=rsa-sha256; cv=none; b=UnKWbqBAv8K5Tc3te8B4fHoVYDBl2+kujxs+DPaQ5cD9i6pFqh/paxACD+kLCWdSwddshu PP/TCSY7P/bkO9F6eYOIcFREPuCpF3vNwdEB6W/4lplaf6x5WHal5+xBS01FEETluGSX8e b8eHBZA8/hhPevdso8h80c1GqNemqVo= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=N7L+xOIG; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734097832; 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=5M1ENZFbO/mNMn248U1qss6F8q2hwKZC+45ijoUGNaQ=; b=1cHUBx2O9pVFlXX6oyHDW+L0G6p7AWwWRQfzKPa92uLwuqdszgJvRhBUMZq/6FTlSzoqD6 /j7o1IW/Nua65QaoIQ/QwmBeJs1ZfNmr/CJPqR/j/H3YxagLo4n4SqFd1WZRVQK+kHrQto qmraysvajXR8dz7jDI0kubzbrwMvxd4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734097856; 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=5M1ENZFbO/mNMn248U1qss6F8q2hwKZC+45ijoUGNaQ=; b=N7L+xOIGH6ysdQd2KxR6lkiNo5uPiOh3+urZJUvItES5v3fQj/vjDAcMk65AgupWn0NI/Q 0X4wOlXh5Y0/H4q/nv/p+Uh869DFAedja0jeKJNEHQrozOycl6e0BwNaZ7EXbDg5nBfA+E Xojz8pUQkCYgbRma8Mcp9EoxpawHsEc= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-492-komwBIjYNoKdH0VnGk57oA-1; Fri, 13 Dec 2024 08:50:52 -0500 X-MC-Unique: komwBIjYNoKdH0VnGk57oA-1 X-Mimecast-MFC-AGG-ID: komwBIjYNoKdH0VnGk57oA Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D61E71956056; Fri, 13 Dec 2024 13:50:49 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.48]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EC2561956052; Fri, 13 Dec 2024 13:50:44 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Max Kellermann , Ilya Dryomov , Xiubo Li , Trond Myklebust , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, 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, linux-kernel@vger.kernel.org, Anna Schumaker , Dave Wysochanski Subject: [PATCH 04/10] nfs: Fix oops in nfs_netfs_init_request() when copying to cache Date: Fri, 13 Dec 2024 13:50:04 +0000 Message-ID: <20241213135013.2964079-5-dhowells@redhat.com> In-Reply-To: <20241213135013.2964079-1-dhowells@redhat.com> References: <20241213135013.2964079-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 5B3522000B X-Stat-Signature: 11381gcwzod9jgp9qmxfst8neuczq5g9 X-Rspam-User: X-HE-Tag: 1734097831-327727 X-HE-Meta: U2FsdGVkX1+jkHDcez8pYSOtn4DmFChcn730pjgBowzw7JyHB0tKwAzLdNCI0JNUTw2KUldWxDp6DLjwqomSNsSm7Lt94/cgSGl66ej2oxLD2gXbKfHAcU89j5tIwLL3C1m/jiIrZdE27e8qn1duDkmVcaMcl+HnPX/+kRQ2f22p5SbvtXLUWffZRzCpBOAidzDaogbkM+jdm8Rs+xD3gmgBbk7/G1RCDM8Wh8s9q3GL0YiApTiU60kUACmNmOGcA3+6bSpsRB1hC4I8zV/y/FT2Bl9jjoUqzPcnlPQTt87A8xP9md/S+xYX+ND0slbX275hIJgTfspZVTL4rUlMIqwf0YdgQvZ9b+te77srxU5mJtZtoHpIdnUiKVrmBbLZ7R7GhtbRf+DoCROCgZe+rJJyY8tpPG3bpQK+2jondLBksNeBXgsIrflOP4tsiiz+hrJibwuNioXJE6oEqMG5PwbQflVM8T8HrquvYR2S+CwLr+b0Gg20UgzP3xN10jyH/ETmxUf5EivfeJmvqKENsiCPg0x8mhwW7snGIdlCzrRwGtZ2cmilHlFatX5BUEwZlR7IB6dlGOkzQ+0+AJl03BIV8/OnNcFRbfXQtQkqbvlcMYz/cYOEyQyKDvISfQtt10BfOYz8yPHM1HMfXujOhNjDoB3imGh9cLyjKSQHNW1kNwCNu9e8DCL6ezmhAj0OmmZBQlAp/BdEPPIBeY+Tv+lVUD207NRe1mDmfKgk6B9h4k2Is3vc9KSOBz4xCmTqwbTAX4034EicNUL+bty/OkNOpBEtj1/9O0YljOnkssVGK1ZCFLiCSbZGQwteOCi1l534TfazHd7hLgTM2yWyh1ulLVPEI6ZrFjKk2M82pKTtzFExguN28Stak3n8WPkJyT+kP8plt3i5ay75oSB9a80nfMhnWV7GywBTyMraZlUQ1Sw6uWHrDLpmbkWBSlHXubSKGXYoAx7dUBXI/nN x5RV964W Fh28R+bsmOeJI28V0mXFzGPGDFbiUt4dA4tQhpcfNVM3KkkHLs4Kgdo9VhbXSKWqe7ONZtP8A3xsnZED0HOwR/eieFfzfci+KtaoyDqIREKz2982CQLyDvMI52aI5b6/0h50MkFdXysWVWFeZ7/ExZbVX7oxHt23WAhSzIkXnSCW/meZVbX54zbprOPynpBaZhlnrVRQ09hSPNsChpI4Z0V5chRPxXKH4A/eKt+m9vlp0IHiuJEDwFfvzt/q6ifl+/nZXl1AD5QrPfyg7j/YupsGLATJVs3pCfRjRJalXub/wkUWcTQc1maPlcW7MOMDigxs8/Ccz68+xLm51Zl13HvnFMmx3fPJeCMnk01FS/8pF64xprFFPB4Gi3XUVbxeJa8bL7kVKlhilf21sB3Iyvppm6aNYO9UZzMLrmGIY9LMBnJKIfcMZyVLMqa2/awkvURR+CyyRjQkvsdHAutGJ6VlpH8/wWTCtZ1UJ1yaMGkTsdKQqfJf3DrDW5N7aQDFXBbgt 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: When netfslib wants to copy some data that has just been read on behalf of nfs, it creates a new write request and calls nfs_netfs_init_request() to initialise it, but with a NULL file pointer. This causes nfs_file_open_context() to oops - however, we don't actually need the nfs context as we're only going to write to the cache. Fix this by just returning if we aren't given a file pointer and emit a warning if the request was for something other than copy-to-cache. Further, fix nfs_netfs_free_request() so that it doesn't try to free the context if the pointer is NULL. Fixes: ee4cdf7ba857 ("netfs: Speed up buffered reading") Reported-by: Max Kellermann Closes: https://lore.kernel.org/r/CAKPOu+9DyMbKLhyJb7aMLDTb=Fh0T8Teb9sjuf_pze+XWT1VaQ@mail.gmail.com/ Signed-off-by: David Howells cc: Trond Myklebust cc: Anna Schumaker cc: Dave Wysochanski cc: Jeff Layton cc: linux-nfs@vger.kernel.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org --- fs/nfs/fscache.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/nfs/fscache.c b/fs/nfs/fscache.c index 810269ee0a50..d49e4ce27999 100644 --- a/fs/nfs/fscache.c +++ b/fs/nfs/fscache.c @@ -263,6 +263,12 @@ int nfs_netfs_readahead(struct readahead_control *ractl) static atomic_t nfs_netfs_debug_id; static int nfs_netfs_init_request(struct netfs_io_request *rreq, struct file *file) { + if (!file) { + if (WARN_ON_ONCE(rreq->origin != NETFS_PGPRIV2_COPY_TO_CACHE)) + return -EIO; + return 0; + } + rreq->netfs_priv = get_nfs_open_context(nfs_file_open_context(file)); rreq->debug_id = atomic_inc_return(&nfs_netfs_debug_id); /* [DEPRECATED] Use PG_private_2 to mark folio being written to the cache. */ @@ -274,7 +280,8 @@ static int nfs_netfs_init_request(struct netfs_io_request *rreq, struct file *fi static void nfs_netfs_free_request(struct netfs_io_request *rreq) { - put_nfs_open_context(rreq->netfs_priv); + if (rreq->netfs_priv) + put_nfs_open_context(rreq->netfs_priv); } static struct nfs_netfs_io_data *nfs_netfs_alloc(struct netfs_io_subrequest *sreq) From patchwork Fri Dec 13 13:50:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13907061 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 36535E7717F for ; Fri, 13 Dec 2024 13:51:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF1B26B0095; Fri, 13 Dec 2024 08:51:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BA1376B0096; Fri, 13 Dec 2024 08:51:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A430B6B0098; Fri, 13 Dec 2024 08:51:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 86BB66B0095 for ; Fri, 13 Dec 2024 08:51:06 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 04F63140F46 for ; Fri, 13 Dec 2024 13:51:05 +0000 (UTC) X-FDA: 82890071040.27.3DACDDA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 2D876160009 for ; Fri, 13 Dec 2024 13:50:46 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JcRstcy+; spf=pass (imf08.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=1734097852; 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=PgqF6qS7NlWWtrfijPJ59f4qec6LLBa+L5U7UdJSTDg=; b=L7GfTS1Bx3IWrHyt3NoxgR7UDaeszCH5wNt5hId9VlxHkDOFrIsjInApkId6yD+dxYqMKw CRWGxN0paPEUG++m/ZNOMuAjO7b+8f1G+1X+465hqhBeFUM0NvbB5d1Biwu5jti95Y30F3 /zAxDn/Mz5kaXLkKxr9FtAvuuQ07jSU= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JcRstcy+; spf=pass (imf08.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734097852; a=rsa-sha256; cv=none; b=ANdqrWoX0yRwXia1Z78rgBFik/brCUuWQPxfclFhbR/uhlYJuIqDLh7RXmMsuHetYStEF3 ZRJqaDeLeMSJAvl0JNRHxKO52ADGiRjCkzq8FKXHvbrXQaCcBiX0lgzGhl8HtkqSBhOMUZ E7G/oSeCHA/2FA8m8a8qC6+c9YJO24A= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734097863; 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=PgqF6qS7NlWWtrfijPJ59f4qec6LLBa+L5U7UdJSTDg=; b=JcRstcy+VCNxqmVKzfis+b1DzdeNB1Gi5Es4W1U0wCY5NQXUpHEnVUumgKNG8BMRrKr5bw 2xniJS12sRPyqh/rev13K+4+gGYslCE66AYlg1Fo6Z5Y20wwaGurmPcyLP33EV3VTP1kKh RY3o6ttNu9Fqm4NXfXd5l0q4FNwL5fY= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-144-5qCQLS_NOjiuU8cdRRSGCw-1; Fri, 13 Dec 2024 08:50:58 -0500 X-MC-Unique: 5qCQLS_NOjiuU8cdRRSGCw-1 X-Mimecast-MFC-AGG-ID: 5qCQLS_NOjiuU8cdRRSGCw Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8DA8F1955F54; Fri, 13 Dec 2024 13:50:55 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.48]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 51D89195605A; Fri, 13 Dec 2024 13:50:50 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Max Kellermann , Ilya Dryomov , Xiubo Li , Trond Myklebust , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, 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, linux-kernel@vger.kernel.org Subject: [PATCH 05/10] cachefiles: Parse the "secctx" immediately Date: Fri, 13 Dec 2024 13:50:05 +0000 Message-ID: <20241213135013.2964079-6-dhowells@redhat.com> In-Reply-To: <20241213135013.2964079-1-dhowells@redhat.com> References: <20241213135013.2964079-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Rspamd-Queue-Id: 2D876160009 X-Stat-Signature: 81xoxca9yn4k4ofujwkieydc7y1qtbyn X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1734097846-292073 X-HE-Meta: U2FsdGVkX19XFLbonnDcOm2xzHrVCTfEGUctb3mUZ75hIxsXdC8Pfv/h9ud5XG9Py9kKeHHX/34pOZdk8REMIOpcudqdaiG81QA8KyqkM8KFJsgljU6lWKCy+hmSHWSAaaY2Rg8g3/oE343tGUc+Cz9UYYqtcr1z0DBM7OtR3foYcJRWOaTWRIcTAFrDyd0MMfmrZnG2rzlFAMHv6D+P8ASCUWmN6K0CUWdzTt/DVD/DzP3PY6VXcEyYckyGZXXJau5UXK1MN2xWLhkfqe3VoRhYgN/3zQ4fm+pqzTAZzh2qPr2/dxjR0WeNCMUQS1kstVkXPQT7WSCoqqgZdu8MfavPqAdtoqe6zSIfb8BoKEZZxFdt+zLaXthc3jiANE6PTrGk4RRK/d6AK87hl8WiEAqbwnseKgSE7SGv+AXycH7r2ZuYT2+X4P3QV+8FY1p4B8fiW5dSX9aFt8M7GtYVh1CfvAv1ixgBeNE8xp8QObkTooEwnbzUonC9ZLYJ5q15YaC4jfZipIGsmCNJ0DKqYc+VTpm08dNDU1JoHYoge8n1BoWnS2CNFgcTJf/E70G9JJpYoI2QrTkzA3eg7FAb59h5Mv1tOT8+1gLbvQ5vm1zunN9Ej12Tf5WpN32B1T30V3xONiHlwZOQfSbwzAeo0sEnDvDZZCW6IZaE+t6txxLUOHroS6lGXa3JNIGgKNXLor/Ksi7zdJA23Diq+GG8nHM0l+SGDPplocQ8qAX3WdoBpWiWrTTwocLvxNXUt2Bal8pYJzgMA2rFpr2w67IsV4JsN2pNzlxefRB/iZ3m2hyKTTMcKfn22pl7m608gETRp6ESBtYMwRe4KxUeDA3oCwt2YbOiN2KVS4q20rmTKowEwQZf2fVZBov2qBClzQ1B2cp7LSuEDpgJDVAZE8k++CnwVg9tkLVem2gC7BzVcj6YZ2jRxOcQ+J2Yn/k4vWgzJPX7UoaeD2GefTo64ph nFUdsakK ctkga+8uC7AUHBdSlDQaZyt+b6Jh5kpHIJP4LYAuMcR9KHgOaiCfliG+2o30DQazCn3Ea4EwmPBmzs9kSHyQ7FaI7KQnlY7kahgQpAh7zRGS/drOspFULhoPQeewR1hCMRWlquB2pUt4j3AnOCKb2VW9wbfYmGBRsaK3L84I/T50Z+SJd5jUvjEl4fQDsCod3g6TtZXObyit2ZCI9/BoAfsDGWDb+tVnzZRNjPE2vAdklPc+tCy43BPQWqgEZhNX6OXwGC9YDE/vXbmRHdMdEHSzkFPtu4MBSTTtCLwT+0skvse8h2y4ptvjbd5tozfvyzGfOI3txDb4aAGPihAxd64Xtz0sRp9eXVoX18IeasN8oYnVdbJQZenP7FEP9g0/o/elVlUkgJTjJGT1qfugvIVReMw== 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: From: Max Kellermann Instead of storing an opaque string, call security_secctx_to_secid() right in the "secctx" command handler and store only the numeric "secid". This eliminates an unnecessary string allocation and allows the daemon to receive errors when writing the "secctx" command instead of postponing the error to the "bind" command handler. For example, if the kernel was built without `CONFIG_SECURITY`, "bind" will return `EOPNOTSUPP`, but the daemon doesn't know why. With this patch, the "secctx" will instead return `EOPNOTSUPP` which is the right context for this error. This patch adds a boolean flag `have_secid` because I'm not sure if we can safely assume that zero is the special secid value for "not set". This appears to be true for SELinux, Smack and AppArmor, but since this attribute is not documented, I'm unable to derive a stable guarantee for that. Signed-off-by: Max Kellermann Signed-off-by: David Howells Link: https://lore.kernel.org/r/20241209141554.638708-1-max.kellermann@ionos.com/ --- fs/cachefiles/daemon.c | 14 +++++++------- fs/cachefiles/internal.h | 3 ++- fs/cachefiles/security.c | 6 +++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c index 89b11336a836..1806bff8e59b 100644 --- a/fs/cachefiles/daemon.c +++ b/fs/cachefiles/daemon.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -576,7 +577,7 @@ static int cachefiles_daemon_dir(struct cachefiles_cache *cache, char *args) */ static int cachefiles_daemon_secctx(struct cachefiles_cache *cache, char *args) { - char *secctx; + int err; _enter(",%s", args); @@ -585,16 +586,16 @@ static int cachefiles_daemon_secctx(struct cachefiles_cache *cache, char *args) return -EINVAL; } - if (cache->secctx) { + if (cache->have_secid) { pr_err("Second security context specified\n"); return -EINVAL; } - secctx = kstrdup(args, GFP_KERNEL); - if (!secctx) - return -ENOMEM; + err = security_secctx_to_secid(args, strlen(args), &cache->secid); + if (err) + return err; - cache->secctx = secctx; + cache->have_secid = true; return 0; } @@ -820,7 +821,6 @@ static void cachefiles_daemon_unbind(struct cachefiles_cache *cache) put_cred(cache->cache_cred); kfree(cache->rootdirname); - kfree(cache->secctx); kfree(cache->tag); _leave(""); diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h index 7b99bd98de75..38c236e38cef 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h @@ -122,7 +122,6 @@ struct cachefiles_cache { #define CACHEFILES_STATE_CHANGED 3 /* T if state changed (poll trigger) */ #define CACHEFILES_ONDEMAND_MODE 4 /* T if in on-demand read mode */ char *rootdirname; /* name of cache root directory */ - char *secctx; /* LSM security context */ char *tag; /* cache binding tag */ refcount_t unbind_pincount;/* refcount to do daemon unbind */ struct xarray reqs; /* xarray of pending on-demand requests */ @@ -130,6 +129,8 @@ struct cachefiles_cache { struct xarray ondemand_ids; /* xarray for ondemand_id allocation */ u32 ondemand_id_next; u32 msg_id_next; + u32 secid; /* LSM security id */ + bool have_secid; /* whether "secid" was set */ }; static inline bool cachefiles_in_ondemand_mode(struct cachefiles_cache *cache) diff --git a/fs/cachefiles/security.c b/fs/cachefiles/security.c index fe777164f1d8..fc6611886b3b 100644 --- a/fs/cachefiles/security.c +++ b/fs/cachefiles/security.c @@ -18,7 +18,7 @@ int cachefiles_get_security_ID(struct cachefiles_cache *cache) struct cred *new; int ret; - _enter("{%s}", cache->secctx); + _enter("{%u}", cache->have_secid ? cache->secid : 0); new = prepare_kernel_cred(current); if (!new) { @@ -26,8 +26,8 @@ int cachefiles_get_security_ID(struct cachefiles_cache *cache) goto error; } - if (cache->secctx) { - ret = set_security_override_from_ctx(new, cache->secctx); + if (cache->have_secid) { + ret = set_security_override(new, cache->secid); if (ret < 0) { put_cred(new); pr_err("Security denies permission to nominate security context: error %d\n", From patchwork Fri Dec 13 13:50:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13907062 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 28492E77182 for ; Fri, 13 Dec 2024 13:51:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BA31C6B0098; Fri, 13 Dec 2024 08:51:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B540B6B0099; Fri, 13 Dec 2024 08:51:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F3AF6B009A; Fri, 13 Dec 2024 08:51:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7DAD56B0098 for ; Fri, 13 Dec 2024 08:51:12 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id EE222C0F3E for ; Fri, 13 Dec 2024 13:51:11 +0000 (UTC) X-FDA: 82890071796.05.771AE85 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 426CE100003 for ; Fri, 13 Dec 2024 13:50:21 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Opmb7oMZ; spf=pass (imf05.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734097846; a=rsa-sha256; cv=none; b=8Ux7aeOFVW6RSI3/5nESV8sgmUkhBwDqkOcTdjN+ht6LZIf369HGyxrzSidAxp0yK4eIcO MWvQOic7kklFl7Kb1l0v1HBH4w89rxDY7MuAlwrSaEBfgG/pKbVmlTFHa881VhQqJeqVjo 64nOn78ddA+/gTfQzlhUKFa6x3gEWqE= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Opmb7oMZ; spf=pass (imf05.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=1734097846; 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=dahqI5gLkGfD05TuY+PqQn3pxJDwXGZGfLY3MOFYgVE=; b=h4Dq91EocbmKttRiFIm+ZRx42xRkn2CnLj7QodMhiPoQgCR1YcVVPh75ynFWnU3uEgvbWF bCQO98s77q68a/9Xm4E8fgurkdibdNTYEA8vQFRHwxADfzExRZmrkzQNcrF449MSLAvbnp deDhrHISeASBMtDD76Ymb0yvS06pO2k= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734097869; 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=dahqI5gLkGfD05TuY+PqQn3pxJDwXGZGfLY3MOFYgVE=; b=Opmb7oMZAhU19zFew4Q9s26TEEmklbZ5TZuYFqxDphnYwpLHeZXyUlUyScVyHcke6r3zbL VHWOeS36i2WmfsHH/Bx0ky0XZ28jnIWBIa4wJbLZ0+IUMlhvv0Xlq2eIkTeHfKiJc9gm0D u8KznsG5+25p0n4DvHaG3V2MMw6MUYk= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-692-NQm--YxLM0SK64NOpZx29g-1; Fri, 13 Dec 2024 08:51:06 -0500 X-MC-Unique: NQm--YxLM0SK64NOpZx29g-1 X-Mimecast-MFC-AGG-ID: NQm--YxLM0SK64NOpZx29g Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2E4CD19560B5; Fri, 13 Dec 2024 13:51:02 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.48]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 058071955F40; Fri, 13 Dec 2024 13:50:56 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Max Kellermann , Ilya Dryomov , Xiubo Li , Trond Myklebust , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, 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, linux-kernel@vger.kernel.org, Zilin Guan , Akira Yokosawa Subject: [PATCH 06/10] netfs: Remove redundant use of smp_rmb() Date: Fri, 13 Dec 2024 13:50:06 +0000 Message-ID: <20241213135013.2964079-7-dhowells@redhat.com> In-Reply-To: <20241213135013.2964079-1-dhowells@redhat.com> References: <20241213135013.2964079-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Rspamd-Queue-Id: 426CE100003 X-Stat-Signature: 11p6wfffgfhihi5my38opcmoudyft9hc X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1734097821-480289 X-HE-Meta: U2FsdGVkX1+wWEhwoJTJDhHNrAzMRAIfgnYZy1VeoU8rYCnjdONjZzWg/ZvFvQVhdV1k65o6hvxI1eaRykdIHG6Zs9EnBJ8DlAEFmj36UTfyZ9lXJRE+TJU1fkfXhnuNq367zkMXUL943BojUC1ruoj/NGtbOmO0e9ggFmxqa/57/H5YoZssyMWxQtYDSsmFnc69NLrzHDhTJkwV5BFRJj/7GCwh6xYXc4TfxF4pQxO6lgd08PBBuXNNTBYLlu5tfGeJGaF9Bo0dSROmJIcsslbYfJll1Yj79t/tD75hxxMoseqe6gFIFd6IbVnRXCqtGq2vqOOBv/MJQ8cOFXrWDCxLwL7KsCyjIgGwbd1LxJ3mL6C3dcxuSe51GQ+lsaSAlqkRU00cr4EzCrKT6eP/P2LCa8JmlbpWsuhlMNufB5qElciH4FVaBn6wvcoK9Pw5JujaGHeOBOyNtLAoEAsc1VWP7+56v3wfL6poY1gUKbCnMufwnkivFl1iWk6IFDGNjjgOC9C5p4XNiT5bwTBgwkXASclCJqgQrUYtIALXgItc6bWHn5dlmmrrPRVJBArf4FX2YJqCrcUJitHKH3f3K9CTX+vUCxpIPJCMpXQsd4Fn/7a97pSW/NXf6wtZ65caN5beKJ1yie/CJf/RxWGEE8IWTqIQSjKDYRUB1zqyS6tK3RdVmhsAHprhzNJqjVlDSMCWOCGaYVmfhHRnbKwGV31pOXU3FWnhzWK5+cPhf3fscUPgUUyZ9Y4H3VZFM2ImGLsM98EWKshyKRds0fLnDtkLaS+lzmOTjlt6UtjV20IrqpWzkttRgpF+HK/mz56DsksitjsFdYVMpcdfkC/SKd4gbQ9+bvlC8txaPN/tOnd/RsXPtJ0cFoNBqJh4NgvT40AAvj9UbF11gEpSAZ5fZssT5iNd7vJBvWrj+2Qs28tvIgtatUcreU8hajnZOrNtglWWsUgwli8n/rpp+hr rt1P3GS3 nooEvX5Yh0PyFESfeE+v+tNjl4ZaCgqDw3uxCtmrN2KbQO/oFSefZ4ws+CrxPJFw2EE2bzlW6Lnft2UZ4rnskkxFDglvcUeySJOzwenlvxfxt85Npxh/GVDGH/yEPtjgOFHYtUhEuuZVS86+T/tE7Yvr4MhMlL/udPx27WZPrhdAwj+naGJ9W9Lx9VsB2JesS7RkwA7hwdCG8DBDiXDjL2+ET00azZs9FFBUeE6CLEKZTQ+L426Iu/8sFdRRJ8t0PUpaJmibupept4HTS9N0ELW9kLxqcWKa4aJ6BMvzLEv71jvrYqonpiNoPpkJFaWLIgFIhZ9IMzhvkfSmVqA1ZwXCaDFlzWKdX9wQlmSaGwTn5T8dBjoq6y/xd69usTkCDagVpHeZGPzqnywfpjwBBndyX6au1Gphen+6FRcn1s3rcWoyq2CL1sYGRL04ZeBT4g1H7 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: From: Zilin Guan The function netfs_unbuffered_write_iter_locked() in fs/netfs/direct_write.c contains an unnecessary smp_rmb() call after wait_on_bit(). Since wait_on_bit() already incorporates a memory barrier that ensures the flag update is visible before the function returns, the smp_rmb() provides no additional benefit and incurs unnecessary overhead. This patch removes the redundant barrier to simplify and optimize the code. Signed-off-by: Zilin Guan Signed-off-by: David Howells cc: Akira Yokosawa cc: Jeff Layton cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org Link: https://lore.kernel.org/r/20241207021952.2978530-1-zilin@seu.edu.cn/ Reviewed-by: Akira Yokosawa --- fs/netfs/direct_write.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/netfs/direct_write.c b/fs/netfs/direct_write.c index 88f2adfab75e..173e8b5e6a93 100644 --- a/fs/netfs/direct_write.c +++ b/fs/netfs/direct_write.c @@ -104,7 +104,6 @@ ssize_t netfs_unbuffered_write_iter_locked(struct kiocb *iocb, struct iov_iter * trace_netfs_rreq(wreq, netfs_rreq_trace_wait_ip); wait_on_bit(&wreq->flags, NETFS_RREQ_IN_PROGRESS, TASK_UNINTERRUPTIBLE); - smp_rmb(); /* Read error/transferred after RIP flag */ ret = wreq->error; if (ret == 0) { ret = wreq->transferred; From patchwork Fri Dec 13 13:50:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13907063 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 8BDA7E7717F for ; Fri, 13 Dec 2024 13:51:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1DEC56B009A; Fri, 13 Dec 2024 08:51:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 18FF06B009B; Fri, 13 Dec 2024 08:51:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 030936B009C; Fri, 13 Dec 2024 08:51:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D507C6B009A for ; Fri, 13 Dec 2024 08:51:18 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 86113C0EE0 for ; Fri, 13 Dec 2024 13:51:18 +0000 (UTC) X-FDA: 82890072132.16.799390A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 9A224C001B for ; Fri, 13 Dec 2024 13:51:05 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KDpay3Wf; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734097852; a=rsa-sha256; cv=none; b=mRO1WXPNLHUarw1aSRzWfT99FXWKbtT7UrQv5MVqoegsfMmoz45JJml5Y9USQWJO+i40qx sVVl2RhawB2YJ2luho4dav8ILteKsopHUeQmDajllvJWFb31+5N9akaVRrSvevypfpPpzN svJDx8OL+VtpY3Z6QXMbGYBagBu54EI= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KDpay3Wf; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734097852; 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=Iv9WM7D/h/d7OTq2M7QoeqOwEbcTnPmdrMlMHFXuPOU=; b=7pblcs438wSnTLI2OkeW5bDUd2NjHaUbl/UWshgkmAR1iOtYRhAdCQc0u+ia02ubsfRGha M5u7N4Rs8J/O5LZ6zcXBXJ/+Cw5SxJDyt1j4UKkF99XWLODkUYwvsh2Ttv3L8jIu2uQA40 tOpNWBYbpVJM6i7cja8AFo/zWkE5ras= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734097876; 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=Iv9WM7D/h/d7OTq2M7QoeqOwEbcTnPmdrMlMHFXuPOU=; b=KDpay3Wf9N1bk21dHvAPJJ+WN/h/WJHQThySi0mDDrxZdRfdNE6a/odtPsJduKZ3MwCaKb Q2Oi6yV4wxZYq1beavzcYWz9g19KrCnM3Gh/lyn3UpVrBlxBhOCenzVFn4m3zgTZMRB9/q G+rquVcYZns3CxIjhE0NcllkA3SxaV0= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-649-Z0u6tnJ2N66YU4thKkuufg-1; Fri, 13 Dec 2024 08:51:11 -0500 X-MC-Unique: Z0u6tnJ2N66YU4thKkuufg-1 X-Mimecast-MFC-AGG-ID: Z0u6tnJ2N66YU4thKkuufg Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4184F1956089; Fri, 13 Dec 2024 13:51:08 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.48]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9E5001956086; Fri, 13 Dec 2024 13:51:03 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Max Kellermann , Ilya Dryomov , Xiubo Li , Trond Myklebust , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, 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, linux-kernel@vger.kernel.org, Zilin Guan , Akira Yokosawa Subject: [PATCH 07/10] netfs: Fix missing barriers by using clear_and_wake_up_bit() Date: Fri, 13 Dec 2024 13:50:07 +0000 Message-ID: <20241213135013.2964079-8-dhowells@redhat.com> In-Reply-To: <20241213135013.2964079-1-dhowells@redhat.com> References: <20241213135013.2964079-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Stat-Signature: tumyzsayytopbkowfuec1ndekbgpmng9 X-Rspam-User: X-Rspamd-Queue-Id: 9A224C001B X-Rspamd-Server: rspam08 X-HE-Tag: 1734097865-333958 X-HE-Meta: U2FsdGVkX19RJKPM4RbhYYqDJhnRu74H5QL1QYOWc4ziVlOmTU6ZkBAtqMajF1PT5GMC8ZhM/Hpnms6Crz3uQxcHZaI8e7xWsNPJ1tP9T51RHBHTPP0oL4YAyRoTpJ+XqfdKKe8PAJTFfqw4BEgF8pJ41IBjAf1i69yY26bB34NqGKXuKIVtgHSFlTJINS0PhLjdC0UDl+qX88moeILX5rIeN2e/WfUtU/wg18284r/pU2CMyk+xHxGdO44IJoyamZsccMM80eNQ7JoCdYBZYlx6aYGagEQQYZT4lo/ThpxkeGHvbUQkrjpAmpg/vzT0YwUYOdGOu2585FkSkXqP8UbZp5RcAQuLN9XHra9SW7YY8h/GFBrhRnVSDb30IfaHwskLgH/zljOR3dAUifDky3wJ2CHzde3GztOC0Qh9UK0PxWE15wiZl59Y+eIi7wfuzXzK+mjvI3O/LAN8VusL+UAh0yYCqq1BEilrxfpd6CoUhYoyvDweOF1q0OaZZv/0474h3Tv6aZ7raA/rfgNSdUUT0nRHbduobRGOzClKidacsuZ4jS3/Sio9H6rdvl5bbKmMmFEodawlWDlbTAQxACj+iLQf7KyGEnQAFNI6ev6HQ+jR+7gAED+M81LQVvRaFo+h7oEhcFuvlBiwCfJUVc1uofsihNH2z9k2KtdnVspQcyLLxvshas7L47tzm1CUGDaEOnb9Nv2pDiWFrih8yLAeUhoafwfaql7qOR21ta/5J0dTlyXFETL6wWREOvMqU0o/jmngIAdAQNsI5hR5iT/VTpn5YyJFw3sE+t7EwlBJGzqoigTfTjYV+Z+miQ0DeBYuLYixv+s3/02SIKxIyOWuRMN4XbNEzPagyi/RX1f0g/Q1jasrO4HX0t4oh/Yr2N0Jy+bSdCj6jCB5r+xoPwgHapsAOIUDQwNk1ldRNBqSl781N7pCUEsgHOTEVltLPYg1vwtsh+82lGUVvaX R5lCWAZq PgoVfdAI2Ln7UcymvaTF/6qRBvY/l45WUAEYCBl5ULOB94pKT/10BbBA4NYQwhLl5dgKxBM504bvfLMeipVjiQRzzGVHzyHd606Jxp4u7kf9DmgzsFP0qiwY6JVJfKE9h6YOUinC5SsN7VTU+59ecP6dZ+z56Zt8xjBj6EmbQMAjIZQFn/nTfNzFHTqkpe2x6MASbx8YbExMEMixz/srzcFLIzAW4X2hLVbHy+t11ZV2BKowVqrGPAnNKd4wUTEiUFzlLxVx1SL3oLqAv6y45FA+Nvb4/uAEYpb1MQ4O346n2dy7KC82rYjGQjnZhP3OXVpLrEIEN0a5AnaNdifvi2twSX62CP529alNo4tdo/n2uGm7BR6liR6N9BRjxzZqlmZCKh/1iCywTCcxyixAhAZAEhG5i9bdVosxPL/iFc+AIMTtFWKoxb5F+0yFDzVT72Pw7 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: Use clear_and_wake_up_bit() rather than something like: clear_bit_unlock(NETFS_RREQ_IN_PROGRESS, &rreq->flags); wake_up_bit(&rreq->flags, NETFS_RREQ_IN_PROGRESS); as there needs to be a barrier inserted between which is present in clear_and_wake_up_bit(). Fixes: 288ace2f57c9 ("netfs: New writeback implementation") Fixes: ee4cdf7ba857 ("netfs: Speed up buffered reading") Signed-off-by: David Howells cc: Zilin Guan cc: Akira Yokosawa cc: Jeff Layton cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org Reviewed-by: Akira Yokosawa --- fs/netfs/read_collect.c | 3 +-- fs/netfs/write_collect.c | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/fs/netfs/read_collect.c b/fs/netfs/read_collect.c index b415e3972336..46ce3b7adf07 100644 --- a/fs/netfs/read_collect.c +++ b/fs/netfs/read_collect.c @@ -379,8 +379,7 @@ static void netfs_rreq_assess(struct netfs_io_request *rreq) task_io_account_read(rreq->transferred); trace_netfs_rreq(rreq, netfs_rreq_trace_wake_ip); - clear_bit_unlock(NETFS_RREQ_IN_PROGRESS, &rreq->flags); - wake_up_bit(&rreq->flags, NETFS_RREQ_IN_PROGRESS); + clear_and_wake_up_bit(NETFS_RREQ_IN_PROGRESS, &rreq->flags); trace_netfs_rreq(rreq, netfs_rreq_trace_done); netfs_clear_subrequests(rreq, false); diff --git a/fs/netfs/write_collect.c b/fs/netfs/write_collect.c index 1d438be2e1b4..82290c92ba7a 100644 --- a/fs/netfs/write_collect.c +++ b/fs/netfs/write_collect.c @@ -501,8 +501,7 @@ static void netfs_collect_write_results(struct netfs_io_request *wreq) goto need_retry; if ((notes & MADE_PROGRESS) && test_bit(NETFS_RREQ_PAUSE, &wreq->flags)) { trace_netfs_rreq(wreq, netfs_rreq_trace_unpause); - clear_bit_unlock(NETFS_RREQ_PAUSE, &wreq->flags); - wake_up_bit(&wreq->flags, NETFS_RREQ_PAUSE); + clear_and_wake_up_bit(NETFS_RREQ_PAUSE, &wreq->flags); } if (notes & NEED_REASSESS) { @@ -605,8 +604,7 @@ void netfs_write_collection_worker(struct work_struct *work) _debug("finished"); trace_netfs_rreq(wreq, netfs_rreq_trace_wake_ip); - clear_bit_unlock(NETFS_RREQ_IN_PROGRESS, &wreq->flags); - wake_up_bit(&wreq->flags, NETFS_RREQ_IN_PROGRESS); + clear_and_wake_up_bit(NETFS_RREQ_IN_PROGRESS, &wreq->flags); if (wreq->iocb) { size_t written = min(wreq->transferred, wreq->len); @@ -714,8 +712,7 @@ void netfs_write_subrequest_terminated(void *_op, ssize_t transferred_or_error, trace_netfs_sreq(subreq, netfs_sreq_trace_terminated); - clear_bit_unlock(NETFS_SREQ_IN_PROGRESS, &subreq->flags); - wake_up_bit(&subreq->flags, NETFS_SREQ_IN_PROGRESS); + clear_and_wake_up_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags); /* If we are at the head of the queue, wake up the collector, * transferring a ref to it if we were the ones to do so. From patchwork Fri Dec 13 13:50:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13907064 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 2FE0FE7717D for ; Fri, 13 Dec 2024 13:51:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B57BD6B009C; Fri, 13 Dec 2024 08:51:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ADF156B009D; Fri, 13 Dec 2024 08:51:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 958DB6B009E; Fri, 13 Dec 2024 08:51:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6F1FD6B009C for ; Fri, 13 Dec 2024 08:51:24 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 372391A083A for ; Fri, 13 Dec 2024 13:51:24 +0000 (UTC) X-FDA: 82890071712.01.5814D03 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 75AF4C0010 for ; Fri, 13 Dec 2024 13:50:53 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=D9b5Wy1w; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734097870; a=rsa-sha256; cv=none; b=hz8wE0Ezf198duLnU3Gy1SKtR7f0+Y4Mi7NYifnZiKAFB84K0CGcVvCMtsbRHqZ+2I7NKw PcRhSLXj0zmpxAn28xNOUjudDB5vYPb6DONtVG8iI1tuwRinDpWak9clkxT0XxBuoiPEX5 XXqrpQpNmj5HmUuEiv6MKxHieNkJr9M= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=D9b5Wy1w; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734097870; 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=KjPETwBK7bWpM5YaAhKCzBXjAnc9nY6CVWmIFTOZIoE=; b=zct16WNnsdDhoNAs/kyALOuuY0c0Cq32zhnt1Bn92we0cHv+TMeVBkg34ibloJIP/nv71H xpOi9GyaoQEUMxmMd1zwYwg1w4yPUJM4G0tqgAFJXH1Nl9bCXrmOo1Hr5507OdjzBLpGkX NzgiLOKKzj/ENzO1jITMlDzyeLB5UjI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734097881; 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=KjPETwBK7bWpM5YaAhKCzBXjAnc9nY6CVWmIFTOZIoE=; b=D9b5Wy1wXnzm5iUPaUdwjON7lpF7JqjlkKhJ063nkr1uo/nVUpV6tlJQYiM0pp0hRGvjcC bE1+svwZBbJiK3brvz6WXrhEumbz4GjrV1ajw3bqbsJ1U5SR9zEvs18YOKEpL5O/A6JB7f DWD0X2pqTKklz5gEdBlnX15yw4rsqQg= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-39-NT_RY7GvPRmiuXhKw1jMLw-1; Fri, 13 Dec 2024 08:51:18 -0500 X-MC-Unique: NT_RY7GvPRmiuXhKw1jMLw-1 X-Mimecast-MFC-AGG-ID: NT_RY7GvPRmiuXhKw1jMLw Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F191719560BC; Fri, 13 Dec 2024 13:51:14 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.48]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B296F30044C1; Fri, 13 Dec 2024 13:51:09 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Max Kellermann , Ilya Dryomov , Xiubo Li , Trond Myklebust , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, 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, linux-kernel@vger.kernel.org, Lizhi Xu , Dominique Martinet Subject: [PATCH 08/10] netfs: Work around recursion by abandoning retry if nothing read Date: Fri, 13 Dec 2024 13:50:08 +0000 Message-ID: <20241213135013.2964079-9-dhowells@redhat.com> In-Reply-To: <20241213135013.2964079-1-dhowells@redhat.com> References: <20241213135013.2964079-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 75AF4C0010 X-Stat-Signature: 9i47gjwd9jh5ogbcg683fqk3fn9yab35 X-HE-Tag: 1734097853-980661 X-HE-Meta: U2FsdGVkX19HKIwCspgscRCzOCFRbdrC15NiR8m2su9mNa15p6U0TNDlua7eI6HmcNY29nyEPk61dpflDixq7ende1RqUK3m+/1xDoJLjiXQL3T3wz1r5zwiD8WX22LcOOmwmlnP+AcRekncwESWvR3aKs2xwOwngQTobbGpZ00AjzTuoCNilxF6SmgSSzrUrQpLGtj5isnePdxN0ap3GJv9kQ76y2OqVA1evMZJwbrL9DsF9EKvID/yL/PEQDN7Po5Mls3KxEoELJhjLBrtQmsIUxvSIM9TkhVuczPp9435g+bnyuZF8OfpCYXHHLEnw7EqxuOfe2sgO0jc2nhLpRa+fHwPa6S2rx3d3O7TisbPhvyuij8CYY2aqRZRvwDA4EE0q4lKA/io79ubj1KZgRwTXEAT7YceYk3JGWWVRi21cDKfU9bRHAnVEz2qTP5X6yJS5G3W2H4jOh9D69X6kiBp6F0cd3pHoyvoVk2lnz/eTRKpT9fpr/EO9ctQf9d+1TwP416+i2DhfabY1TMGO9r162bkrCkhtY0l5gDJoF9nuyHLYsM1/hOBpS4543ONjZ47lHjrbme6pHsjqz60O5yJgntGzAetHI0Od+LEhGyBorI5QR1KMJ4eVTgD2wcsMESZTPhiZpHq2JYShusk5sC7Rn58l7cExWV6APREZlBE+6CRPeHozpsq+7fYZSuMrLGZJVXcQ7wtpxq+GQ2R0EgrXsUA5/wziER+7vS8++tURGjgiADDv1ETaRYzDfj+nf5TtEcncYFpQVyMiyFC5oLVVxYNqdn/aHv+RCXWlcL80D62YO0gqb35m4+omcltGGf8+FtUXxh5F72NSR7qNCXIVv7xz1Dz0XmJ/xckNnvruwr4+bTwKerz6Q6sChBrZNYdrkWVe2wqY/JQzSyuhy2TNAx7dyj220r8f75POxH7fUdZI0yjal4xJ8o1LMVdYy5hSOQV+vVSbWuKA8m C5oTYDaF Kb3/VfjmoW79ObfhVRq/22jaoBIFzZjnliEM0USoQEui00CCM7O5HjT+WmiLE1bCH0nXWc/zbpg3L6MC0kzkjRs8QCoiq0zXHs5U57NtXHJllKTb8bwY6MsGE3vZeB8xiuFD3AcNZSZ2M2JMnHU2eTqn3GcsCNiBN0zqUE4VsXjoRt2sE243gBdfNjAPwrgT2wxwKlmPidWTJAYQBIAa8xcwMI4ZwDefovHiL+RYDkz6lVZXHNXnLXCk7PpAbtbgyNRXjmeea/G2ccyJarOjnZS6CCRDV4BqSkCoKK9X/Mi4Ykpae4gZZLoK7Z6tzDJBkOyE3Yr3bx4yvX+Tn6/lRcZy1GCetzgfF5aqSHoVlhl7ORKujWtz+OFuWQdajFARznkGBx0vh0X233VirOEoOr7xKydGc6Fyfp2wi62aOtPds9TVQo47QWR5EEzzPkFr8yKsYbfckv07HilwvzxjcWkn9yaK5pK3RYTfi1435pYdTjUpPbmDTDnG19TOIoraO8brKlJhSbTtbsL8h8xSvjLOrlw== 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: syzkaller reported recursion with a loop of three calls (netfs_rreq_assess, netfs_retry_reads and netfs_rreq_terminated) hitting the limit of the stack during an unbuffered or direct I/O read. There are a number of issues: (1) There is no limit on the number of retries. (2) A subrequest is supposed to be abandoned if it does not transfer anything (NETFS_SREQ_NO_PROGRESS), but that isn't checked under all circumstances. (3) The actual root cause, which is this: if (atomic_dec_and_test(&rreq->nr_outstanding)) netfs_rreq_terminated(rreq, ...); When we do a retry, we bump the rreq->nr_outstanding counter to prevent the final cleanup phase running before we've finished dispatching the retries. The problem is if we hit 0, we have to do the cleanup phase - but we're in the cleanup phase and end up repeating the retry cycle, hence the recursion. Work around the problem by limiting the number of retries. This is based on Lizhi Xu's patch[1], and makes the following changes: (1) Replace NETFS_SREQ_NO_PROGRESS with NETFS_SREQ_MADE_PROGRESS and make the filesystem set it if it managed to read or write at least one byte of data. Clear this bit before issuing a subrequest. (2) Add a ->retry_count member to the subrequest and increment it any time we do a retry. (3) Remove the NETFS_SREQ_RETRYING flag as it is superfluous with ->retry_count. If the latter is non-zero, we're doing a retry. (4) Abandon a subrequest if retry_count is non-zero and we made no progress. (5) Use ->retry_count in both the write-side and the read-size. [?] Question: Should I set a hard limit on retry_count in both read and write? Say it hits 50, we always abandon it. The problem is that these changes only mitigate the issue. As long as it made at least one byte of progress, the recursion is still an issue. This patch mitigates the problem, but does not fix the underlying cause. I have patches that will do that, but it's an intrusive fix that's currently pending for the next merge window. The oops generated by KASAN looks something like: BUG: TASK stack guard page was hit at ffffc9000482ff48 (stack is ffffc90004830000..ffffc90004838000) Oops: stack guard page: 0000 [#1] PREEMPT SMP KASAN NOPTI ... RIP: 0010:mark_lock+0x25/0xc60 kernel/locking/lockdep.c:4686 ... mark_usage kernel/locking/lockdep.c:4646 [inline] __lock_acquire+0x906/0x3ce0 kernel/locking/lockdep.c:5156 lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5825 local_lock_acquire include/linux/local_lock_internal.h:29 [inline] ___slab_alloc+0x123/0x1880 mm/slub.c:3695 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3908 __slab_alloc_node mm/slub.c:3961 [inline] slab_alloc_node mm/slub.c:4122 [inline] kmem_cache_alloc_noprof+0x2a7/0x2f0 mm/slub.c:4141 radix_tree_node_alloc.constprop.0+0x1e8/0x350 lib/radix-tree.c:253 idr_get_free+0x528/0xa40 lib/radix-tree.c:1506 idr_alloc_u32+0x191/0x2f0 lib/idr.c:46 idr_alloc+0xc1/0x130 lib/idr.c:87 p9_tag_alloc+0x394/0x870 net/9p/client.c:321 p9_client_prepare_req+0x19f/0x4d0 net/9p/client.c:644 p9_client_zc_rpc.constprop.0+0x105/0x880 net/9p/client.c:793 p9_client_read_once+0x443/0x820 net/9p/client.c:1570 p9_client_read+0x13f/0x1b0 net/9p/client.c:1534 v9fs_issue_read+0x115/0x310 fs/9p/vfs_addr.c:74 netfs_retry_read_subrequests fs/netfs/read_retry.c:60 [inline] netfs_retry_reads+0x153a/0x1d00 fs/netfs/read_retry.c:232 netfs_rreq_assess+0x5d3/0x870 fs/netfs/read_collect.c:371 netfs_rreq_terminated+0xe5/0x110 fs/netfs/read_collect.c:407 netfs_retry_reads+0x155e/0x1d00 fs/netfs/read_retry.c:235 netfs_rreq_assess+0x5d3/0x870 fs/netfs/read_collect.c:371 netfs_rreq_terminated+0xe5/0x110 fs/netfs/read_collect.c:407 netfs_retry_reads+0x155e/0x1d00 fs/netfs/read_retry.c:235 netfs_rreq_assess+0x5d3/0x870 fs/netfs/read_collect.c:371 ... netfs_rreq_terminated+0xe5/0x110 fs/netfs/read_collect.c:407 netfs_retry_reads+0x155e/0x1d00 fs/netfs/read_retry.c:235 netfs_rreq_assess+0x5d3/0x870 fs/netfs/read_collect.c:371 netfs_rreq_terminated+0xe5/0x110 fs/netfs/read_collect.c:407 netfs_retry_reads+0x155e/0x1d00 fs/netfs/read_retry.c:235 netfs_rreq_assess+0x5d3/0x870 fs/netfs/read_collect.c:371 netfs_rreq_terminated+0xe5/0x110 fs/netfs/read_collect.c:407 netfs_dispatch_unbuffered_reads fs/netfs/direct_read.c:103 [inline] netfs_unbuffered_read fs/netfs/direct_read.c:127 [inline] netfs_unbuffered_read_iter_locked+0x12f6/0x19b0 fs/netfs/direct_read.c:221 netfs_unbuffered_read_iter+0xc5/0x100 fs/netfs/direct_read.c:256 v9fs_file_read_iter+0xbf/0x100 fs/9p/vfs_file.c:361 do_iter_readv_writev+0x614/0x7f0 fs/read_write.c:832 vfs_readv+0x4cf/0x890 fs/read_write.c:1025 do_preadv fs/read_write.c:1142 [inline] __do_sys_preadv fs/read_write.c:1192 [inline] __se_sys_preadv fs/read_write.c:1187 [inline] __x64_sys_preadv+0x22d/0x310 fs/read_write.c:1187 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 Fixes: ee4cdf7ba857 ("netfs: Speed up buffered reading") Closes: https://syzkaller.appspot.com/bug?extid=1fc6f64c40a9d143cfb6 Signed-off-by: David Howells Suggested-by: Lizhi Xu cc: Dominique Martinet cc: Jeff Layton cc: v9fs@lists.linux.dev cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org Link: https://lore.kernel.org/r/20241108034020.3695718-1-lizhi.xu@windriver.com/ [1] --- fs/9p/vfs_addr.c | 6 +++++- fs/afs/write.c | 5 ++++- fs/netfs/read_collect.c | 15 +++++++++------ fs/netfs/read_retry.c | 6 ++++-- fs/netfs/write_collect.c | 5 ++--- fs/netfs/write_issue.c | 2 ++ fs/smb/client/cifssmb.c | 13 +++++++++---- fs/smb/client/smb2pdu.c | 9 ++++++--- include/linux/netfs.h | 6 +++--- 9 files changed, 44 insertions(+), 23 deletions(-) diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c index 819c75233235..3bc9ce6c575e 100644 --- a/fs/9p/vfs_addr.c +++ b/fs/9p/vfs_addr.c @@ -57,6 +57,8 @@ static void v9fs_issue_write(struct netfs_io_subrequest *subreq) int err, len; len = p9_client_write(fid, subreq->start, &subreq->io_iter, &err); + if (len > 0) + __set_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags); netfs_write_subrequest_terminated(subreq, len ?: err, false); } @@ -80,8 +82,10 @@ static void v9fs_issue_read(struct netfs_io_subrequest *subreq) if (pos + total >= i_size_read(rreq->inode)) __set_bit(NETFS_SREQ_HIT_EOF, &subreq->flags); - if (!err) + if (!err) { subreq->transferred += total; + __set_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags); + } netfs_read_subreq_terminated(subreq, err, false); } diff --git a/fs/afs/write.c b/fs/afs/write.c index 34107b55f834..ccb6aa8027c5 100644 --- a/fs/afs/write.c +++ b/fs/afs/write.c @@ -122,7 +122,7 @@ static void afs_issue_write_worker(struct work_struct *work) if (subreq->debug_index == 3) return netfs_write_subrequest_terminated(subreq, -ENOANO, false); - if (!test_bit(NETFS_SREQ_RETRYING, &subreq->flags)) { + if (!subreq->retry_count) { set_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags); return netfs_write_subrequest_terminated(subreq, -EAGAIN, false); } @@ -149,6 +149,9 @@ static void afs_issue_write_worker(struct work_struct *work) afs_wait_for_operation(op); ret = afs_put_operation(op); switch (ret) { + case 0: + __set_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags); + break; case -EACCES: case -EPERM: case -ENOKEY: diff --git a/fs/netfs/read_collect.c b/fs/netfs/read_collect.c index 46ce3b7adf07..47ed3a5044e2 100644 --- a/fs/netfs/read_collect.c +++ b/fs/netfs/read_collect.c @@ -438,7 +438,7 @@ void netfs_read_subreq_progress(struct netfs_io_subrequest *subreq, rreq->origin == NETFS_READPAGE || rreq->origin == NETFS_READ_FOR_WRITE)) { netfs_consume_read_data(subreq, was_async); - __clear_bit(NETFS_SREQ_NO_PROGRESS, &subreq->flags); + __set_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags); } } EXPORT_SYMBOL(netfs_read_subreq_progress); @@ -497,7 +497,7 @@ void netfs_read_subreq_terminated(struct netfs_io_subrequest *subreq, rreq->origin == NETFS_READPAGE || rreq->origin == NETFS_READ_FOR_WRITE)) { netfs_consume_read_data(subreq, was_async); - __clear_bit(NETFS_SREQ_NO_PROGRESS, &subreq->flags); + __set_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags); } rreq->transferred += subreq->transferred; } @@ -511,10 +511,13 @@ void netfs_read_subreq_terminated(struct netfs_io_subrequest *subreq, } else { trace_netfs_sreq(subreq, netfs_sreq_trace_short); if (subreq->transferred > subreq->consumed) { - __set_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags); - __clear_bit(NETFS_SREQ_NO_PROGRESS, &subreq->flags); - set_bit(NETFS_RREQ_NEED_RETRY, &rreq->flags); - } else if (!__test_and_set_bit(NETFS_SREQ_NO_PROGRESS, &subreq->flags)) { + /* If we didn't read new data, abandon retry. */ + if (subreq->retry_count && + test_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags)) { + __set_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags); + set_bit(NETFS_RREQ_NEED_RETRY, &rreq->flags); + } + } else if (test_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags)) { __set_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags); set_bit(NETFS_RREQ_NEED_RETRY, &rreq->flags); } else { diff --git a/fs/netfs/read_retry.c b/fs/netfs/read_retry.c index 0350592ea804..0e72e9226fc8 100644 --- a/fs/netfs/read_retry.c +++ b/fs/netfs/read_retry.c @@ -56,6 +56,8 @@ static void netfs_retry_read_subrequests(struct netfs_io_request *rreq) if (test_bit(NETFS_SREQ_FAILED, &subreq->flags)) break; if (__test_and_clear_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags)) { + __clear_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags); + subreq->retry_count++; netfs_reset_iter(subreq); netfs_reissue_read(rreq, subreq); } @@ -137,7 +139,8 @@ static void netfs_retry_read_subrequests(struct netfs_io_request *rreq) stream0->sreq_max_len = subreq->len; __clear_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags); - __set_bit(NETFS_SREQ_RETRYING, &subreq->flags); + __clear_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags); + subreq->retry_count++; spin_lock_bh(&rreq->lock); list_add_tail(&subreq->rreq_link, &rreq->subrequests); @@ -213,7 +216,6 @@ static void netfs_retry_read_subrequests(struct netfs_io_request *rreq) subreq->error = -ENOMEM; __clear_bit(NETFS_SREQ_FAILED, &subreq->flags); __clear_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags); - __clear_bit(NETFS_SREQ_RETRYING, &subreq->flags); } spin_lock_bh(&rreq->lock); list_splice_tail_init(&queue, &rreq->subrequests); diff --git a/fs/netfs/write_collect.c b/fs/netfs/write_collect.c index 82290c92ba7a..ca3a11ed9b54 100644 --- a/fs/netfs/write_collect.c +++ b/fs/netfs/write_collect.c @@ -179,7 +179,6 @@ static void netfs_retry_write_stream(struct netfs_io_request *wreq, struct iov_iter source = subreq->io_iter; iov_iter_revert(&source, subreq->len - source.count); - __set_bit(NETFS_SREQ_RETRYING, &subreq->flags); netfs_get_subrequest(subreq, netfs_sreq_trace_get_resubmit); netfs_reissue_write(stream, subreq, &source); } @@ -234,7 +233,7 @@ static void netfs_retry_write_stream(struct netfs_io_request *wreq, /* Renegotiate max_len (wsize) */ trace_netfs_sreq(subreq, netfs_sreq_trace_retry); __clear_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags); - __set_bit(NETFS_SREQ_RETRYING, &subreq->flags); + subreq->retry_count++; stream->prepare_write(subreq); part = min(len, stream->sreq_max_len); @@ -279,7 +278,7 @@ static void netfs_retry_write_stream(struct netfs_io_request *wreq, subreq->start = start; subreq->debug_index = atomic_inc_return(&wreq->subreq_counter); subreq->stream_nr = to->stream_nr; - __set_bit(NETFS_SREQ_RETRYING, &subreq->flags); + subreq->retry_count = 1; trace_netfs_sreq_ref(wreq->debug_id, subreq->debug_index, refcount_read(&subreq->ref), diff --git a/fs/netfs/write_issue.c b/fs/netfs/write_issue.c index bf6d507578e5..ff0e82505a0b 100644 --- a/fs/netfs/write_issue.c +++ b/fs/netfs/write_issue.c @@ -244,6 +244,8 @@ void netfs_reissue_write(struct netfs_io_stream *stream, iov_iter_advance(source, size); iov_iter_truncate(&subreq->io_iter, size); + subreq->retry_count++; + __clear_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags); __set_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags); netfs_do_issue_write(stream, subreq); } diff --git a/fs/smb/client/cifssmb.c b/fs/smb/client/cifssmb.c index bd42a419458e..6cb1e81993f8 100644 --- a/fs/smb/client/cifssmb.c +++ b/fs/smb/client/cifssmb.c @@ -1319,14 +1319,16 @@ cifs_readv_callback(struct mid_q_entry *mid) } if (rdata->result == -ENODATA) { - __set_bit(NETFS_SREQ_HIT_EOF, &rdata->subreq.flags); rdata->result = 0; + __set_bit(NETFS_SREQ_HIT_EOF, &rdata->subreq.flags); } else { size_t trans = rdata->subreq.transferred + rdata->got_bytes; if (trans < rdata->subreq.len && rdata->subreq.start + trans == ictx->remote_i_size) { - __set_bit(NETFS_SREQ_HIT_EOF, &rdata->subreq.flags); rdata->result = 0; + __set_bit(NETFS_SREQ_HIT_EOF, &rdata->subreq.flags); + } else if (rdata->got_bytes > 0) { + __set_bit(NETFS_SREQ_MADE_PROGRESS, &rdata->subreq.flags); } } @@ -1670,10 +1672,13 @@ cifs_writev_callback(struct mid_q_entry *mid) if (written > wdata->subreq.len) written &= 0xFFFF; - if (written < wdata->subreq.len) + if (written < wdata->subreq.len) { result = -ENOSPC; - else + } else { result = written; + if (written > 0) + __set_bit(NETFS_SREQ_MADE_PROGRESS, &wdata->subreq.flags); + } break; case MID_REQUEST_SUBMITTED: case MID_RETRY_NEEDED: diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c index 010eae9d6c47..458b53d1f9cb 100644 --- a/fs/smb/client/smb2pdu.c +++ b/fs/smb/client/smb2pdu.c @@ -4615,6 +4615,7 @@ smb2_readv_callback(struct mid_q_entry *mid) __set_bit(NETFS_SREQ_HIT_EOF, &rdata->subreq.flags); rdata->result = 0; } + __set_bit(NETFS_SREQ_MADE_PROGRESS, &rdata->subreq.flags); } trace_smb3_rw_credits(rreq_debug_id, subreq_debug_index, rdata->credits.value, server->credits, server->in_flight, @@ -4840,10 +4841,12 @@ smb2_writev_callback(struct mid_q_entry *mid) if (written > wdata->subreq.len) written &= 0xFFFF; - if (written < wdata->subreq.len) + if (written < wdata->subreq.len) { wdata->result = -ENOSPC; - else + } else if (written > 0) { wdata->subreq.len = written; + __set_bit(NETFS_SREQ_MADE_PROGRESS, &wdata->subreq.flags); + } break; case MID_REQUEST_SUBMITTED: case MID_RETRY_NEEDED: @@ -5012,7 +5015,7 @@ smb2_async_writev(struct cifs_io_subrequest *wdata) } #endif - if (test_bit(NETFS_SREQ_RETRYING, &wdata->subreq.flags)) + if (wdata->subreq.retry_count > 0) smb2_set_replay(server, &rqst); cifs_dbg(FYI, "async write at %llu %u bytes iter=%zx\n", diff --git a/include/linux/netfs.h b/include/linux/netfs.h index 5eaceef41e6c..4083d77e3f39 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -185,6 +185,7 @@ struct netfs_io_subrequest { short error; /* 0 or error that occurred */ unsigned short debug_index; /* Index in list (for debugging output) */ unsigned int nr_segs; /* Number of segs in io_iter */ + u8 retry_count; /* The number of retries (0 on initial pass) */ enum netfs_io_source source; /* Where to read from/write to */ unsigned char stream_nr; /* I/O stream this belongs to */ unsigned char curr_folioq_slot; /* Folio currently being read */ @@ -194,14 +195,13 @@ struct netfs_io_subrequest { #define NETFS_SREQ_COPY_TO_CACHE 0 /* Set if should copy the data to the cache */ #define NETFS_SREQ_CLEAR_TAIL 1 /* Set if the rest of the read should be cleared */ #define NETFS_SREQ_SEEK_DATA_READ 3 /* Set if ->read() should SEEK_DATA first */ -#define NETFS_SREQ_NO_PROGRESS 4 /* Set if we didn't manage to read any data */ +#define NETFS_SREQ_MADE_PROGRESS 4 /* Set if we transferred at least some data */ #define NETFS_SREQ_ONDEMAND 5 /* Set if it's from on-demand read mode */ #define NETFS_SREQ_BOUNDARY 6 /* Set if ends on hard boundary (eg. ceph object) */ #define NETFS_SREQ_HIT_EOF 7 /* Set if short due to EOF */ #define NETFS_SREQ_IN_PROGRESS 8 /* Unlocked when the subrequest completes */ #define NETFS_SREQ_NEED_RETRY 9 /* Set if the filesystem requests a retry */ -#define NETFS_SREQ_RETRYING 10 /* Set if we're retrying */ -#define NETFS_SREQ_FAILED 11 /* Set if the subreq failed unretryably */ +#define NETFS_SREQ_FAILED 10 /* Set if the subreq failed unretryably */ }; enum netfs_io_origin { From patchwork Fri Dec 13 13:50: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: 13907065 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 60C1DE7717F for ; Fri, 13 Dec 2024 13:51:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E8A836B009E; Fri, 13 Dec 2024 08:51:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E398B6B009F; Fri, 13 Dec 2024 08:51:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D01A56B00A0; Fri, 13 Dec 2024 08:51:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id AFC746B009E for ; Fri, 13 Dec 2024 08:51:31 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 76425120E9D for ; Fri, 13 Dec 2024 13:51:31 +0000 (UTC) X-FDA: 82890072006.08.08D92F9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf05.hostedemail.com (Postfix) with ESMTP id C82F010001D for ; Fri, 13 Dec 2024 13:50:40 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hZhWmtxF; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734097865; a=rsa-sha256; cv=none; b=Lmvqz77WSNn004xdHxVKp7K7KBvEgyO1RP4M0VmRx56opIU05o+bqClAv6qQQVFZmsggmS ROIKyRaBWgwerednH+HuB6ojFOGWwHiWhpa7Uc+7s8Iuc46FEF6qRCIr7/l+vANG6Rg/WY sxiSUfH2aCIHd5HlI3IYDXQo7EL4J1k= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hZhWmtxF; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734097865; 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=uxmqCJdKFxLw/y1tKF8ZCDzW6SWRkgRIhZKChhoKrx8=; b=shgW/KVU958S3jxfMiBD+ecoQPr9bK2eJeJrfVDq0+5McPuvHAvTjZGaDqw+8Y2naQ97VS SUowocxAe/bkoYyFUfEAIA5LePTvoWt2FwWJSggUHWdbBKSeEYBjyT8MF0ceiTwBqJoANl 2wdJNtyQzOTvdPdgHKW38/KGYODRYXQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734097889; 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=uxmqCJdKFxLw/y1tKF8ZCDzW6SWRkgRIhZKChhoKrx8=; b=hZhWmtxFvkwy4PGSwgaZns361J3sfMRa04hpPapFvdcg2XHpEiE1A5m8foCDlzI+ipWFX8 25pe3vva/EVyjzdp20BOAlYBnQP9wgAe++pvdPdM+zbkPFA8djBGiKzh1vLr5GmadeQ6AZ UBmMyQTqhER5AkPKcb3Bej1pcykUugM= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-497-dpcO627eMBu77q5ky2OXKQ-1; Fri, 13 Dec 2024 08:51:23 -0500 X-MC-Unique: dpcO627eMBu77q5ky2OXKQ-1 X-Mimecast-MFC-AGG-ID: dpcO627eMBu77q5ky2OXKQ Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6AFF11955E95; Fri, 13 Dec 2024 13:51:21 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.48]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 643061956086; Fri, 13 Dec 2024 13:51:16 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Max Kellermann , Ilya Dryomov , Xiubo Li , Trond Myklebust , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, 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, linux-kernel@vger.kernel.org Subject: [PATCH 09/10] netfs: Fix ceph copy to cache on write-begin Date: Fri, 13 Dec 2024 13:50:09 +0000 Message-ID: <20241213135013.2964079-10-dhowells@redhat.com> In-Reply-To: <20241213135013.2964079-1-dhowells@redhat.com> References: <20241213135013.2964079-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C82F010001D X-Stat-Signature: 871jzgd4wyn14fxt37ewndubc7zewybw X-Rspam-User: X-HE-Tag: 1734097840-767248 X-HE-Meta: U2FsdGVkX1/8E+0MjW+SyYTX5kc2dgQ6AmaMM6R1/8D/LfxHPJUsWh3WFeJo0TTJ/pY0/SW/jv2W0NA6wmuraeaKcHe/kcxk7uczcUXC1FXCcDMrXfCbR/AZ5n28H7c0MGslVJM1wvKDR82x9rF5j+6CFgVmR3MTCns6J30yTCafaLr0AfNVRckofNIdOs9EaPAuIjnz7iUovGCdvZGsvqS730/EK9M8XbeJdL9Sq1/r4Z5xtwrEIPqA03r20b71QTv46QNR5QsO3aNf/W6Kng1eiyjAdeyT1S24d9M6J4nEMw5WBTpTvU3GjTBPMLk8F2neZbhC1J8+Kvj79+e/g8wVdOwRljhlH1jFz1BI4uBQjPelIUy79mgg+runX9RRuypLHqIxguZuyQ+/2GPe0GZ1F9ZHZoFsf0C5x3wlG5piHgFN4xp2/+iAMIVCL502xSWO+hiBX7QpdU/SYzQ/Mh/Hkg4LqQHyQkEKGP8XMSeRfGLyxBb1+Bi5Gt6k1FtKoIYLNA/tfexDb5OR2SiHh/VdEc1OY+PrEQPRN/1LDbsTcJaCn9ZtnBw7ESkC5WqKYHHcbyDv+3hRlPE/ypoFhLQoRv0ZgE1OyV8pWxx1gqfxMdUIIU5WO9aKwviJjFbHQIOOww3mEjy2AkiYGPA5+YVX2gz3ejh9xVu4m4jIzQ3MqHNnuZzED+BY/yaVW95GTuFi+f6YdK/6h/Z8MEJp5RozcHsA8Xwb7bqDTWTAf6ENNXMdosBqoDQK2b17Bax88Km5eTVBm6KqIoRyYvUfDgqqZk9Wxgb+QQTiuF0orsfwfer5XRTIC+PF7Jh5juWCfPd4nPDjsAvLruRhV9har86O7aPVXenZueTJhwteMY5BDrBI59HxUthkn2vKjJOxEtMWDfC/jcuhhtTV8BJNmqWVTVvLFOnSUh2bCoFiDE87uBeEQsGa1AVSeKProDpI8xmakomoMqXUWKPcI6K vdD81OYf u5OIsKv5562dEU8qHyU6fNYypDnSaM44my68i6a1SzEQnw9ALM2SeQFmnNobfOM6YUyYctYFLxcWdeY2gwuZm2fehJTxzfdX6G2J04qSMYASqNIu2ChZ5nfj5r4rU4q5BQJ4Sfv9t74oGsgfdpXacxRAmHETPA76SZV+Hes1pElxOeJlcBUpuZLSVk+vm429YpfETCah189q5hhc8c6A8YnTxiCg97ftpaWeB4bHs2Z3aHT+qoDNCSvPC6hUpR7qU1dfz3uc06Ycdu5YnyUMqCq2kgTta1xHJuy2Qg98jvVd1dzztDBcfNaJOsP3/2vIjJ3hxxsZWB/pJq8FmpQYZ0oDjUUWBE+ppg7RRFajan3/TDNTmXIKioh5cJfitFDWrnd/ZLb3nHI55sr5DBGBW3wlbkFLtJqu0FnpPd8McYVGl3wfiqxlCdyDlEw== 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: At the end of netfs_unlock_read_folio() in which folios are marked appropriately for copying to the cache (either with by being marked dirty and having their private data set or by having PG_private_2 set) and then unlocked, the folio_queue struct has the entry pointing to the folio cleared. This presents a problem for netfs_pgpriv2_write_to_the_cache(), which is used to write folios marked with PG_private_2 to the cache as it expects to be able to trawl the folio_queue list thereafter to find the relevant folios, leading to a hang. Fix this by not clearing the folio_queue entry if we're going to do the deprecated copy-to-cache. The clearance will be done instead as the folios are written to the cache. This can be reproduced by starting cachefiles, mounting a ceph filesystem with "-o fsc" and writing to it. Fixes: 796a4049640b ("netfs: In readahead, put the folio refs as soon extracted") Reported-by: Max Kellermann Closes: https://lore.kernel.org/r/CAKPOu+_4m80thNy5_fvROoxBm689YtA0dZ-=gcmkzwYSY4syqw@mail.gmail.com/ Signed-off-by: David Howells cc: Jeff Layton cc: Ilya Dryomov cc: Xiubo Li cc: netfs@lists.linux.dev cc: ceph-devel@vger.kernel.org cc: linux-fsdevel@vger.kernel.org --- fs/netfs/read_collect.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/netfs/read_collect.c b/fs/netfs/read_collect.c index 47ed3a5044e2..e8624f5c7fcc 100644 --- a/fs/netfs/read_collect.c +++ b/fs/netfs/read_collect.c @@ -62,10 +62,14 @@ static void netfs_unlock_read_folio(struct netfs_io_subrequest *subreq, } else { trace_netfs_folio(folio, netfs_folio_trace_read_done); } + + folioq_clear(folioq, slot); } else { // TODO: Use of PG_private_2 is deprecated. if (test_bit(NETFS_SREQ_COPY_TO_CACHE, &subreq->flags)) netfs_pgpriv2_mark_copy_to_cache(subreq, rreq, folioq, slot); + else + folioq_clear(folioq, slot); } if (!test_bit(NETFS_RREQ_DONT_UNLOCK_FOLIOS, &rreq->flags)) { @@ -77,8 +81,6 @@ static void netfs_unlock_read_folio(struct netfs_io_subrequest *subreq, folio_unlock(folio); } } - - folioq_clear(folioq, slot); } /* From patchwork Fri Dec 13 13:50:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13907066 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 33FBCE7717D for ; Fri, 13 Dec 2024 13:51:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B55166B00A0; Fri, 13 Dec 2024 08:51:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B05786B00A1; Fri, 13 Dec 2024 08:51:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A6D66B00A2; Fri, 13 Dec 2024 08:51:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 7BA416B00A0 for ; Fri, 13 Dec 2024 08:51:38 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 37CD1A0F35 for ; Fri, 13 Dec 2024 13:51:38 +0000 (UTC) X-FDA: 82890071628.20.95298F1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 41E1F180012 for ; Fri, 13 Dec 2024 13:51:18 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=N6ljuulX; spf=pass (imf06.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1734097869; 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=L1v5Uahl/uBNImxZaUKZS5taSNKrtxd0nK3bDl+BkV8=; b=QT5/Of3Op1UMA5jf8LYbKdAUhj+H5nQrLPZg69iu1Cumqe9tk/tcEdkTZ8CDnS4svLl3b/ l5D/sh5JPO+GKz8oTShWPWzLYuyNQ9hMoIVPonWYZGnatgXbpXk0mqxPLE5d0xY4uSQNee M9SPfLPEtHmB5siLz9ldBYEzTnwycZ8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734097869; a=rsa-sha256; cv=none; b=3PBmrX9dV/rMPxMnuJWAgNhEbyAwN2JPTl1ZMVsMwOYsgq7Rs5g7ACpFERgLxh25LV8bMu Bgk1leR17Hd2B60yoSCG55FZ31TgDuSbNt/Oo4tSDnmmQy5N2iRj30nwLEh+g4owQjxOum HLIOMFCnYVdDyKArntnzaqb2f9yhWqA= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=N6ljuulX; spf=pass (imf06.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1734097895; 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=L1v5Uahl/uBNImxZaUKZS5taSNKrtxd0nK3bDl+BkV8=; b=N6ljuulXK6aMhComeTOlsB/uqIdX5mSytwcMrpV2/WJtikll6J8EIJVMhue0ql6IBJ8cTP JVKR0g38hGNp7XwheTeGzzSekjbqej+o+66PBB6l3eiby+cEBFdxbOvdPLGXllDiPMHOM5 hAcMctQ9wu/IsDye0CxoyoayaEu/IAE= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-473-iuxIXFenMlSlR7jWS7DojA-1; Fri, 13 Dec 2024 08:51:30 -0500 X-MC-Unique: iuxIXFenMlSlR7jWS7DojA-1 X-Mimecast-MFC-AGG-ID: iuxIXFenMlSlR7jWS7DojA Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 059B41955F08; Fri, 13 Dec 2024 13:51:28 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.48]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 056F31956086; Fri, 13 Dec 2024 13:51:22 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Max Kellermann , Ilya Dryomov , Xiubo Li , Trond Myklebust , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, 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, linux-kernel@vger.kernel.org Subject: [PATCH 10/10] netfs: Fix the (non-)cancellation of copy when cache is temporarily disabled Date: Fri, 13 Dec 2024 13:50:10 +0000 Message-ID: <20241213135013.2964079-11-dhowells@redhat.com> In-Reply-To: <20241213135013.2964079-1-dhowells@redhat.com> References: <20241213135013.2964079-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Queue-Id: 41E1F180012 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: 7sm5u6kerups9urjx5azbzq1qep6bqcu X-HE-Tag: 1734097878-436310 X-HE-Meta: U2FsdGVkX19RA8CipwdZ6L/DWCxVT17kT5KzUlcmlswyNP3goPNXwb3nmwlNureYtB0Tl2nD9RYfak7UKJVvufZKvHUF/hXtqBmVH0YYVfHI6sgBKi+GG6p1LFZ/ABzcnMehmVVvYUWgVpj72oCVpi7JB82EB60lwimDi9EfifOjYIfzeQbPfVE2Mv0TqTyOGg9gYLu+6T4SOb2MJAvnWiDORuG/mA13V3jhqjGeCYaWsqfxkpxB+QqKqUhWH4MwU5l8HyDmMEJOrCXkZiITLghzj+lr3Xbcx6QTLYzWFgDUiDml6bpQTcJo9OPqocLTDgFj4BSkWe9DbQ0WfmUFRaB4ZYh9Egyfc369mkXDAybtQypq/pFM0r2tHpwW9yAUoGjgh7CGt6b3iEoRtb28kCLllwGIvOV+nkCqdRzM6i5zPEPFLCWJc3e+7IjL95YkQIaF+JSqG0CA5xivEaoH19eMEihEU/prFUsVxGwSGa2LxnP4hCd/Zb+PSKBD/4ocge3vINLfrhPWxQ1dQOs7pbOuL1SQhLtLHqgfkTWCay1TeFFNhlp9aA8neqfV4U0SQoa5LM4igmB8sXA+b3jkIzvQHAkSIMU0D4a0uJFxirkR/Nbtrkf13lSYgr+D4EJzgTe0AiLBOtpYfntyoIES74idVmcx/5WB7+/c9tauSxALhTzqBZrtqkhmtK7ZqBQhuMg/+GFJLUx99hW+ZQ+HRfm5g1pPuG+bZzOGux5btgo8pLdo7UAs4uG98Kh1JBW71+gZEMBuyOGpHFjoXt3hxlLXFmUgeHwgf9b1hKBP5mH3iC9zotuF/+SpY7oiD71OF9ftlKlcLWJzQNi7ahcUANV9UlRbPFI/O1uZ1laMhG/vCdmQYZ1W4NRSikiVT9fM76N3XpRy/5xEDvc5fgdzKsmMeJoiz67U+XYjGHj+Pk1P394lhmNLmvyVlMLxMRh+iXfLp8AeNiBpWgxhM2B i7Xtj4fW Tk/iEYtWzrZ0/jRdLB15K8PMuW9fgGB7DZ5xm9+rlSxPEssXxqgNCHuPkRdWtnPTR0n+8G9Rg0ESeQyAdt99GBnB8w7QV4KnIoqxNgjVd9RIow/ykkmhv3wAJIfKhqeekvg1nYN3HQke/9uTL5/13nBFLevhIaobIeKEC4H8phaTa8DTpaNnf1XiFbBiOMaGBn++VkOaDDKFfoOi7NISDa7fIxpoeYHLGwPggIK59d6qZE2ZX9cyr49hAfoLB5TnRExP5q1Kou3WzRCnTE/5EfRe+2B74P+V4VAsDK2hNuWsWjlzhqbL3AeYjNZ7rRKp9xXRB8GAExwz4dNMj5JT8Bv86bLDtLqIPT9xhAgv7/iisD4arMh2k7UBRgXbgFaQDANKh0ytZldCYZI9Iqw8FsIcxYMEOmP05bHgtFTCG+x6jw7iRYRX/II/PIg== 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: When the caching for a cookie is temporarily disabled (e.g. due to a DIO write on that file), future copying to the cache for that file is disabled until all fds open on that file are closed. However, if netfslib is using the deprecated PG_private_2 method (such as is currently used by ceph), and decides it wants to copy to the cache, netfs_advance_write() will just bail at the first check seeing that the cache stream is unavailable, and indicate that it dealt with all the content. This means that we have no subrequests to provide notifications to drive the state machine or even to pin the request and the request just gets discarded, leaving the folios with PG_private_2 set. Fix this by jumping directly to cancel the request if the cache is not available. That way, we don't remove mark3 from the folio_queue list and netfs_pgpriv2_cancel() will clean up the folios. This was found by running the generic/013 xfstest against ceph with an active cache and the "-o fsc" option passed to ceph. That would usually hang Fixes: ee4cdf7ba857 ("netfs: Speed up buffered reading") Reported-by: Max Kellermann Closes: https://lore.kernel.org/r/CAKPOu+_4m80thNy5_fvROoxBm689YtA0dZ-=gcmkzwYSY4syqw@mail.gmail.com/ Signed-off-by: David Howells cc: Jeff Layton cc: Ilya Dryomov cc: Xiubo Li cc: netfs@lists.linux.dev cc: ceph-devel@vger.kernel.org cc: linux-fsdevel@vger.kernel.org --- fs/netfs/read_pgpriv2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/netfs/read_pgpriv2.c b/fs/netfs/read_pgpriv2.c index ba5af89d37fa..54d5004fec18 100644 --- a/fs/netfs/read_pgpriv2.c +++ b/fs/netfs/read_pgpriv2.c @@ -170,6 +170,10 @@ void netfs_pgpriv2_write_to_the_cache(struct netfs_io_request *rreq) trace_netfs_write(wreq, netfs_write_trace_copy_to_cache); netfs_stat(&netfs_n_wh_copy_to_cache); + if (!wreq->io_streams[1].avail) { + netfs_put_request(wreq, false, netfs_rreq_trace_put_return); + goto couldnt_start; + } for (;;) { error = netfs_pgpriv2_copy_folio(wreq, folio); From patchwork Mon Dec 16 20:34:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13910303 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 3F010E7717F for ; Mon, 16 Dec 2024 20:35:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ABA0B6B00A8; Mon, 16 Dec 2024 15:35:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A6B336B00A9; Mon, 16 Dec 2024 15:35:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9317E6B00AA; Mon, 16 Dec 2024 15:35:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 74A2D6B00A8 for ; Mon, 16 Dec 2024 15:35:01 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id F302A120EDB for ; Mon, 16 Dec 2024 20:35:00 +0000 (UTC) X-FDA: 82901975520.26.289EB2B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 1A60D180003 for ; Mon, 16 Dec 2024 20:34:37 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=B+XNgytB; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734381271; a=rsa-sha256; cv=none; b=1QUL4ycrEr9fvL/5UN+VtawFcJ79LuE1lS/9mRPa+8/i+QY/2lI4vpgvfP/aIlML27WT3v HfH/oXyUDh6EqffvZqr7dv763ccaLv+CF8MeyDkORSeZP7nAxzCQDcDEPzrDaMLowAhDF1 qXkq2lFgCQfVk1kQATevmAU1TjBni80= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=B+XNgytB; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734381271; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3uel8b3F42MjWx1FV4MNqrLkM5e1s0/oyCwTXY7gJWI=; b=4tc03ITVmPnmhbIpoc7xDKuuMsu4DgZteHFZaiyp8kq+YnLcpll/x2pXBK3SgmlHutaHKw BrD0oe3B93konCPh8vnKiUvEJ2wxOoN8T2264WdV/v+fZ1hG7yNr0cyHx6PMitW/tyuGZn 6DVGnuYwRLOWCimmWH9ugy+fdsVGVkQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734381298; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3uel8b3F42MjWx1FV4MNqrLkM5e1s0/oyCwTXY7gJWI=; b=B+XNgytB3gVcf1snhXo3wgvoyFWNGYnopas4t1JaW+Mt7WvNkHF3SAI7Y0GmuYzKTBew6c 90anPQNnqc1ofrb3TFUS1GxIqEbtxTO7DayjBptP8kYtnAGiSJhS1rqMyPGcP/CHZYxGC1 BQ6EIIqJ4Sgcc+N21O9S8SQuqHxW1nE= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-130-PLpJV9waPvq0rsK0CpjcQA-1; Mon, 16 Dec 2024 15:34:55 -0500 X-MC-Unique: PLpJV9waPvq0rsK0CpjcQA-1 X-Mimecast-MFC-AGG-ID: PLpJV9waPvq0rsK0CpjcQA Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B245219560A3; Mon, 16 Dec 2024 20:34:51 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.48]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6A88819560A2; Mon, 16 Dec 2024 20:34:46 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20241213135013.2964079-1-dhowells@redhat.com> References: <20241213135013.2964079-1-dhowells@redhat.com> To: Christian Brauner Cc: dhowells@redhat.com, Max Kellermann , Ilya Dryomov , Xiubo Li , Trond Myklebust , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, 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, linux-kernel@vger.kernel.org Subject: [PATCH 11/10] netfs: Fix is-caching check in read-retry MIME-Version: 1.0 Content-ID: <3752047.1734381285.1@warthog.procyon.org.uk> Date: Mon, 16 Dec 2024 20:34:45 +0000 Message-ID: <3752048.1734381285@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 1A60D180003 X-Stat-Signature: wyn5y4dy3j7tzdx9nbanaxajc15sq69m X-Rspam-User: X-HE-Tag: 1734381277-384789 X-HE-Meta: U2FsdGVkX18Gl29nBFYylUKtlaxeXT4Pu8w8ggQ0Ou13TkhI0LDR7sxkcPNxonQ5Mbo5IO0KBpFbh4vJ8bn7yuUc8xi35vVHEf4ZrfZA+NPkM/Yw7MRiQr+XxK6wAnf+keLChUNYdxLud0fxm318ufCBY32klzcMoguHJHKKWaulxA8QsYaEMb4NScE5iZg/Ia8lO8TOjlSFivqW+xLIbIlHM+EDI90oH5lNq9gt0dhp+rFas/AQgeg4cPKHbR6fJJ4j4twX0EZMcw4dXNrj2aRAu4qEwFKfZFDqTfY1geOmlQ5qzY09JjreCEl3l3rxV0jKIALsUYC7vRx472BAQz4GbqGsXIBqzZ8U1nG5BDjusztyoFYoBAhHUEcmQOAGXtA/tex0xUX5ky1ttcPEczrf2EL94SEsa+KeIM/LIEFyKmY4so2P532QBTEtFItoHOUbrQ12wC2QyupP687g1zoGXscSUJ3VnRNXJaglxwjZ/3CJ/IVlD1CeF5O9DgKm24/uQid3/ne6Mc98nkRsVX95vU9Ohqiij46u27XWGH29muBSf7fWgOaadDFt8nVuUCive4fwZtA0V1ChwcMZEE6ImTXKNv/Xv/L7WY+mI1fDl2CGKTlwNAn44FLbq8GyDVwKbDITpml5UrIVlw8dLKofd+ivqEF0QsiSatQMAbWNpkoFefRH40AKVAZEjaRET+8JLe8pDbEUNuMR7acLC4+X+mMrF76yHlU/AQMNvasAJHRTHW8kcXx6RaLa5FxutKZQ5wbY5Do/0assCKSODFFq9fA+HeOnfHNyXBiGb5qUNs7RRaSykJLmWVKR/9pPqRdM8EnaeyTwch5IqciSrBpzeA/+pYoQ02uCh7opQSnL6waFMiL/Mzc1v/ZoaG38iC5hqJN99AI6hMBWm8vIcI7YhpJTlqLWFa/XlaXKPEg01JBTqx+/YolMMIswAwaBn/92Z2l50Ye9USf3kdY qUP2JEgu 77SdhL/Q2+jbrH/Fr/tmMZRFaIsEroZ54h806N6FdhiS4ceIXEwjS/No4SQ//zVxfhpsMcqYAYj2vzs1e0MMUTAUkxUv35jn42/8zng7Xv8kb9DjfaI36tiL8k9EJNP22pwUdabST1gaIKDx6kB/Y8fckYZ8gmZ+6dMwxdVws74x5REMn2YHACLKBF5SqlUYenCr/YzYwN0zz5ImIXsCK5w+IHj9y1TXm/EN2N/b38cOkNZ7qVHmun+DYaN+17Gr6bPu0qJ+7/M2ULo5Qe2rLwIpmbsCeWPIXfLbyYNnNFupuuSSfRvU25pc5Fv6Nrlglya56ntM/DvG6z2xy+/2G/TFhZbJDbs6nYfyD 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: netfs: Fix is-caching check in read-retry The read-retry code checks the NETFS_RREQ_COPY_TO_CACHE flag to determine if there might be failed reads from the cache that need turning into reads from the server, with the intention of skipping the complicated part if it can. The code that set the flag, however, got lost during the read-side rewrite. Fix the check to see if the cache_resources are valid instead. The flag can then be removed. Fixes: ee4cdf7ba857 ("netfs: Speed up buffered reading") Signed-off-by: David Howells cc: Jeff Layton cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org --- fs/netfs/read_retry.c | 2 +- include/linux/netfs.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/netfs/read_retry.c b/fs/netfs/read_retry.c index 0e72e9226fc8..21b4a54e545e 100644 --- a/fs/netfs/read_retry.c +++ b/fs/netfs/read_retry.c @@ -49,7 +49,7 @@ static void netfs_retry_read_subrequests(struct netfs_io_request *rreq) * up to the first permanently failed one. */ if (!rreq->netfs_ops->prepare_read && - !test_bit(NETFS_RREQ_COPY_TO_CACHE, &rreq->flags)) { + !rreq->cache_resources.ops) { struct netfs_io_subrequest *subreq; list_for_each_entry(subreq, &rreq->subrequests, rreq_link) { diff --git a/include/linux/netfs.h b/include/linux/netfs.h index 4083d77e3f39..ecdd5ced16a8 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -269,7 +269,6 @@ struct netfs_io_request { size_t prev_donated; /* Fallback for subreq->prev_donated */ refcount_t ref; unsigned long flags; -#define NETFS_RREQ_COPY_TO_CACHE 1 /* Need to write to the cache */ #define NETFS_RREQ_NO_UNLOCK_FOLIO 2 /* Don't unlock no_unlock_folio on completion */ #define NETFS_RREQ_DONT_UNLOCK_FOLIOS 3 /* Don't unlock the folios on completion */ #define NETFS_RREQ_FAILED 4 /* The request failed */