Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3877712rwb; Tue, 8 Nov 2022 09:19:40 -0800 (PST) X-Google-Smtp-Source: AMsMyM59EHwOsXunw4tIFlDmGzamx/P5x+fInc/SJKycaXlSzxbHdDgacKmla1XrStoq+sk+RQ6Q X-Received: by 2002:a17:902:c20c:b0:186:b3d0:f77 with SMTP id 12-20020a170902c20c00b00186b3d00f77mr56043452pll.26.1667927980481; Tue, 08 Nov 2022 09:19:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667927980; cv=none; d=google.com; s=arc-20160816; b=uJpQq2+rIczs6TDRp7jqRrg4VeLqy89NqS3Zf92PQxh7/lSr9BqnoOoD+YD3caaQlH ll1BezhAiK0p53cPDGmhmu+9KdY7bmeWxe4DiDpDd4+8bHOVsnxgZ96W/y6pWDdnnzzt HAFcRmEnMG7fzuF80+lpD7LM92528G8T6bwAInoooTWIzBKX8rjGjHqLJUW6v/l4vsou o2rz6p3bbgnLThs86lEXk3z1SJ74Qdgq7wMW56IJjzMe2YekGaWSxWUgFdnYfSVr1+ay Rc6H9GGjAPsxSu1I4P2tqndH9bFVrQtSkYoZsWCPPW6Bi8nNpf57sqG+cHYXYgBucacE Dkiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-id:mime-version:subject :cc:to:references:in-reply-to:from:organization:dkim-signature; bh=+7O/cdVA9cRWQClu+6yWqTBX+v+ngyo9UGXM4aHQHz0=; b=U+u6S7Gwkv2x4cCutuQSiMzR5VQz3x3tgkFQPlh5iP+qpsIX2i0i11WPcjSN0kTRfG yAxRFy6O8roIkrp0hNmAyoxsKT7RDK6aGyTKOTuhSl1E+d4KspDc4GtrQoJONTQ8MxgE HLl/miBRy4eDm9KpHsScbS5gxRSM7BlQwZSCrduFYNT189PyREJIVrJSJtbrCsNDwb0X kLve6JfyGy54l71T5h8qphTqRbR940SkUbpI5MiR13BssP7C852nb/nik60w9rwrOSEb btTDgvbHVuglHBFTFi5Gxg5VAKNevsFKLUTrroJDLwY4h8hXWVAuKoezxRMDOi7DqugK ZeBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WRspdi+q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j185-20020a638bc2000000b004430face459si14602666pge.95.2022.11.08.09.19.28; Tue, 08 Nov 2022 09:19:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WRspdi+q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234297AbiKHQAU (ORCPT + 91 others); Tue, 8 Nov 2022 11:00:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234486AbiKHQAK (ORCPT ); Tue, 8 Nov 2022 11:00:10 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8220B58BE3 for ; Tue, 8 Nov 2022 07:59:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667923154; 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: in-reply-to:in-reply-to:references:references; bh=+7O/cdVA9cRWQClu+6yWqTBX+v+ngyo9UGXM4aHQHz0=; b=WRspdi+qJKU0UK5jvbBOPsKSuUEZc8xeiH4/YoLH9KtpRkcYFD2SqG6Yetfrg8lwN+MYnh n+LzcIM04ck1Nz7KFoKnGp5nCBAJtSL265xy8NhUQkKweiZdVg1jRLPlEvOQhD6ul5zrtK Vug3ds7yFWO1KeIQOIN1I+RQ3fflcng= 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-641-ilJCerraMtCxfVDjkarK6A-1; Tue, 08 Nov 2022 10:59:11 -0500 X-MC-Unique: ilJCerraMtCxfVDjkarK6A-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 09905811E81; Tue, 8 Nov 2022 15:59:11 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.37.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 492082166B29; Tue, 8 Nov 2022 15:59:09 +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: <084d78a4-6052-f2ec-72f2-af9c4979f5dc@linux.alibaba.com> References: <084d78a4-6052-f2ec-72f2-af9c4979f5dc@linux.alibaba.com> <166757987929.950645.12595273010425381286.stgit@warthog.procyon.org.uk> <166757988611.950645.7626959069846893164.stgit@warthog.procyon.org.uk> To: JeffleXu Cc: dhowells@redhat.com, willy@infradead.org, Jeff Layton , linux-cachefs@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] netfs: Fix dodgy maths MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2363339.1667923148.1@warthog.procyon.org.uk> Date: Tue, 08 Nov 2022 15:59:08 +0000 Message-ID: <2363340.1667923148@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org JeffleXu wrote: > > Fix the dodgy maths in netfs_rreq_unlock_folios(). start_page could be > > inside the folio, in which case the calculation of pgpos will be come up > > with a negative number (though for the moment rreq->start is rounded down > > earlier and folios would have to get merged whilst locked) > > Hi, the patch itself seems fine. Just some questions about the scenario. > > 1. "start_page could be inside the folio" Is that because > .expand_readahead() called from netfs_readahead()? Since otherwise, > req-start is always aligned to the folio boundary. At the moment, rreq->start is always coincident with the start of the first folio in the collection because we always read whole folios - however, it might be best to assume that this might not always hold true if it's simple to fix the maths to get rid of the assumption. > 2. If start_page is indeed inside the folio, then only the trailing part > of the first folio can be covered by the request, and this folio will be > marked with uptodate, though the beginning part of the folio may have > not been read from the cache. Is that expected? Or correct me if I'm wrong. For the moment there's no scenario where this arises; I think we need to wait until we have a scenario and then see how we'll need to juggle the flags. David