Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp36873rwb; Tue, 8 Nov 2022 21:56:13 -0800 (PST) X-Google-Smtp-Source: AMsMyM4N0+SMtHQOQMya5NQJIRWQQBtt12jUHYvyUF7/ENh5NtXwPwm/FrSF2eddTh1kwWCqTXrW X-Received: by 2002:a17:906:899d:b0:7ad:cf09:96be with SMTP id gg29-20020a170906899d00b007adcf0996bemr49736024ejc.221.1667973373142; Tue, 08 Nov 2022 21:56:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667973373; cv=none; d=google.com; s=arc-20160816; b=Haef0TSyWOKycEnoJ/uVqHfVnbHkYD1QKAAgjGk36g7pTYOl+EEr+bisnmoyEtAwGH f7oMoJh2emoZJ7NRDeo7XCpLLaOdjsucOOveF37XcuFdaVDka/7MHc59vEjsGwI04NW7 UlAz90E4AfQ5whzB2CjJlg0jwJdHtV1KwkDY/3rLwDTXDQFQp6lbSrjVEHSRCaz96amH kaT3kDsKDIFsahQLrD+JVpKPSf97x1M2EhWZSOMUvlsDoJJVHQzhnLwJkPcSGuWGXwKO 5sW20UX7DLP187WuJeJedqPjttzgmay5sAlWGOnVUiSwsRepUMtfpMT31/iOkctzDJNG pdFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=Lyq4z/RJL6q1U44UMTVS/q1uDLXTGiMukARXY22hkOs=; b=ESFS9RjTRMFIWPXkUo2Cyk6fD049UUAAGPzG10BJxE/85ss8Wfi8cUI53aPL2ii4Tt Z+5iIuVaIcX+afNMP4iJPcrrFXmqUl35WduMWAn6xain6TzkrBvUubuu4D2LVeKYIHfE zkAI/xCgx8q/hR1f0Hwwuuz1eXIhxRX7SB7d3t7pgZ5MSrdYNXb43e/8w0PJ3LJUde3l +WRtBP8+qne0b5h68Bfyj90Ujn7NZBXPs2ytQoBtRqoLGwBEk9bHwnTQ8niccwmlzsl9 qg+6paU4OdITf6/fRfIuxcuJA3C38b1fNKDcwdc9MjcIeFF5rcRQ6t/TCx8fR3OaPkjr 27sg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rv14-20020a17090710ce00b007ad9f041c3bsi10795516ejb.27.2022.11.08.21.55.42; Tue, 08 Nov 2022 21:56:13 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229698AbiKIFfd (ORCPT + 93 others); Wed, 9 Nov 2022 00:35:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229452AbiKIFfc (ORCPT ); Wed, 9 Nov 2022 00:35:32 -0500 Received: from out199-9.us.a.mail.aliyun.com (out199-9.us.a.mail.aliyun.com [47.90.199.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A25B91DDE9; Tue, 8 Nov 2022 21:35:30 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VUMLLG8_1667972125; Received: from 30.221.129.114(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VUMLLG8_1667972125) by smtp.aliyun-inc.com; Wed, 09 Nov 2022 13:35:26 +0800 Message-ID: Date: Wed, 9 Nov 2022 13:35:25 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [Linux-cachefs] [PATCH v2 2/2] netfs: Fix dodgy maths Content-Language: en-US To: David Howells , willy@infradead.org Cc: linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com, Jeff Layton , linux-kernel@vger.kernel.org References: <166757987929.950645.12595273010425381286.stgit@warthog.procyon.org.uk> <166757988611.950645.7626959069846893164.stgit@warthog.procyon.org.uk> From: JeffleXu In-Reply-To: <166757988611.950645.7626959069846893164.stgit@warthog.procyon.org.uk> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham 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 On 11/5/22 12:38 AM, David Howells 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) > > Alter how this works to just frame the tracking in terms of absolute file > positions, rather than offsets from the start of the I/O request. This > simplifies the maths and makes it easier to follow. > > Fix the issue by using folio_pos() and folio_size() to calculate the end > position of the page. > > Fixes: 3d3c95046742 ("netfs: Provide readahead and readpage netfs helpers") > Reported-by: Matthew Wilcox > Signed-off-by: David Howells > cc: Jeff Layton > cc: linux-cachefs@redhat.com > cc: linux-fsdevel@vger.kernel.org > Link: https://lore.kernel.org/r/Y2SJw7w1IsIik3nb@casper.infradead.org/ Reviewed-by: Jingbo Xu -- Thanks, Jingbo