From mboxrd@z Thu Jan 1 00:00:00 1970 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 2FB54C61DA3 for ; Fri, 24 Feb 2023 15:13:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C79D46B0074; Fri, 24 Feb 2023 10:13:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C26646B0075; Fri, 24 Feb 2023 10:13:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEE606B0078; Fri, 24 Feb 2023 10:13:15 -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 9BE486B0074 for ; Fri, 24 Feb 2023 10:13:15 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 78087C0203 for ; Fri, 24 Feb 2023 15:13:15 +0000 (UTC) X-FDA: 80502528750.25.0716995 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 65B2540029 for ; Fri, 24 Feb 2023 15:13:13 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YwjMdEoc; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.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=1677251593; 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=GQh9PzREi1aKG+cvDq/BudsqXqu0IrqPEQVrEk5VEng=; b=XEru9rBcUAsRLzMsT9w33d522ITlyqBhNB0fshQF7QtrONqpr8JeCZMUVOzRLsnVzyA2z5 EO6YkXplI0lcB65MYhJNJgn18M6cyBr6k88nVaa2Y/goxfIEHQjPXSD9UvvEcTwP9LSg0c 2vvgzIjJudbimVq5lnqohr3ilY+Bjy4= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YwjMdEoc; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.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=1677251593; a=rsa-sha256; cv=none; b=oHv71S+jsCk99kbYzjckwqoa+E2pNe99ihJopH1W1kzXZfnHoqXqHbiUtorPH6yQ9BHFrV 2DNp9eiCoXTO5jKg9vxTrBGr+I8eY1VUSyQvOIwUpJ1xSI+SoqgDEt+a8mkfEFP+MJPmb7 ifbSQUZEZOE/gPP1H08es7DQemUeNt0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251592; 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=GQh9PzREi1aKG+cvDq/BudsqXqu0IrqPEQVrEk5VEng=; b=YwjMdEocuACtOXvfhU9cBHZBKDhOOCR5AeI/t/VvwyXg6Pj8ukYQH3N3dGmhbKFeyc83rT dKIJlaHvpD7C5Kx2wdOXDUkbZIaiUADbhRQ/4m3xFSdf0mX1fcqY9ABMhJ+vGsxaZ68SxD tUT2b7dGRcJHRIorJouFwS4m8/bxMig= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-656-ZGuU11x2PtyBMDfxKc7VNQ-1; Fri, 24 Feb 2023 10:13:09 -0500 X-MC-Unique: ZGuU11x2PtyBMDfxKc7VNQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9C9F6800B23; Fri, 24 Feb 2023 15:13:08 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id CBAC7492B12; Fri, 24 Feb 2023 15:13:06 +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: <2213409.1677249075@warthog.procyon.org.uk> References: <2213409.1677249075@warthog.procyon.org.uk> <2134430.1677240738@warthog.procyon.org.uk> <2009825.1677229488@warthog.procyon.org.uk> <20230220135225.91b0f28344c01d5306c31230@linux-foundation.org> To: Linus Torvalds , Steve French Cc: dhowells@redhat.com, Vishal Moola , Andrew Morton , Jan Kara , Paulo Alcantara , Matthew Wilcox , Huang Ying , Baolin Wang , Xin Hao , linux-mm@kvack.org, mm-commits@vger.kernel.org, linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC][PATCH] cifs: Improve use of filemap_get_folios_tag() MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2244150.1677251586.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Fri, 24 Feb 2023 15:13:06 +0000 Message-ID: <2244151.1677251586@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspamd-Queue-Id: 65B2540029 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: 1iz8yeidsuw3d7gz7mmnm9thkr5mkmjc X-HE-Tag: 1677251593-418718 X-HE-Meta: U2FsdGVkX19Ai+75WtGdabji6bg1oUf6Ne/7hzNzAzoKUnx55+ENj8yyLrexW+49n/xSYxEzv3lMBVD6dXxgZks8E+FK42YscINyvVysddaITXjKebkZRVdpTEAAcQwMWHwd5g4b1YIbmNyZ7DLsMhKLRoUQmsuGa4AwsjjDRdFEosEopY36erTZnMCmCjdlIw4SM5mCCtif7zsbxUkMgs19snZZRKQ/sXRJ+nzVbCxiRvLtlVm3vEU2vb35itPlp+FT95dP2ExSBz2BHonMWPPYAwHbITr/69qvv69QleTM/ETSHdtjm7Vb5qhcLiipUkrcASZ3fA7hZl7AtHBp6FOHfB6djoZm+tD3w6swfX/Blmh2vq7ZiYxyiTFovXRPZuQrqHPpUz7auAcM5g+9E9819ePQCaX5Q56vNr62vLLAdsIzJ3dsMDwNevRfg4egUcgzHPeNtHybKUry3ddTyWD4khe6Mw8ERzhSUxlQvhAfhL+9UV36leVG7PUBGmQ34XRNcel/+2MS/hivfx1DtoX7FFY8Sf40cSILyioopzn/aTItuV/RetjIj7MJpykzXjnUkb9ETY1ihSoQMYVU+RujuqmpjLoctTbH0Sx2gKtXTa9kHQURGcOTRhK5JlLNRddrdukZfwKycCkiKB8swZ9UthzDNxhQ6g862a3Xc6RVGbk1+SRr9Oe3fFDU+AtClr2lP5SyoaAFJBtHSMtq9DVbKFEd7XACU6KdkoLTMv7/qRRnqb67jK1ryEQUXWVL2gi2LeZoVyyYQAOsmnKMEU4OCN3FaZfYqVAIhe3gvvrSBP792xrMQpAj+uEJb17Ssb7LTlsjqvk9NPBDoOqD0ZoUHyMT6DuVWzpqgln5+IAj7jX76mrgw1+DcyLIOxwBZR+x636cc9rtEQHCorKW0dY0DjPtFXLPmFx/IklrXh+b67w3DpNWSIoLWOpPLMvUQU+qlkAOuHAX6LGjq6i aEmfjTpN v67I7piHhitS9A+fobj/ZN5Y7khKPAIbSnynLxyHcNGw0vLrpW+oJ3Z5E7U4/3PpwbZ5b+9qzBFOsVzgnFVZ/V/KHZNSGvr+2pC6uoDZ45sICzDL4zt2itH34tyItsCriUcy6q2bPRy4sOQvbgbHQGwcX96tCqo64WMOD1vC+30m0adjnk9jSZIOWeHSatdoeliUD6Lta5zWzou2NVNu/QeQ8/ug4mTGSZNVzrnMh9fuapcTPDGy9TkPw7tVgjhRrUU2/OR4OEE3z1Z7jBVtsOEACdio+Q45DpO8GkR57hyal/TlzLPn3rFph5ZBoXWg9VoIq 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: [This additional to the "cifs: Fix cifs_writepages_region()" patch that I posted] The inefficiency derived from filemap_get_folios_tag() get a batch of contiguous folios in Vishal's change to afs that got copied into cifs can be reduced by skipping over those folios that have been passed by the star= t position rather than going through the process of locking, checking and trying to write them. A similar change would need to be made in afs, in addition to fixing the b= ugs there. There's also a fix in cifs_write_back_from_locked_folio() where it doesn't return the amount of data dispatched to the server as ->async_writev() jus= t returns 0 on success. Signed-off-by: David Howells --- diff --git a/fs/cifs/file.c b/fs/cifs/file.c index ebfcaae8c437..bae1a9709e32 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2839,6 +2839,7 @@ static ssize_t cifs_write_back_from_locked_folio(str= uct address_space *mapping, free_xid(xid); if (rc =3D=3D 0) { wbc->nr_to_write =3D count; + rc =3D len; } else if (is_retryable_error(rc)) { cifs_pages_write_redirty(inode, start, len); } else { @@ -2873,6 +2874,13 @@ static int cifs_writepages_region(struct address_sp= ace *mapping, for (int i =3D 0; i < nr; i++) { ssize_t ret; struct folio *folio =3D fbatch.folios[i]; + unsigned long long fstart; + + fstart =3D folio_pos(folio); /* May go backwards with THPs */ + if (fstart < start && + folio_size(folio) <=3D start - fstart) + continue; + start =3D fstart; = redo_folio: start =3D folio_pos(folio); /* May regress with THPs */