Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4822331rdb; Fri, 15 Sep 2023 13:26:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5OKwKlDddg/6U+2k49CLlk4qmdNHnwHXkrbl2qksGH5v7z+NPBgLe8qQKlj1ZMki7zwnf X-Received: by 2002:a17:90a:31c9:b0:25e:d727:6fb4 with SMTP id j9-20020a17090a31c900b0025ed7276fb4mr2558732pjf.2.1694809601107; Fri, 15 Sep 2023 13:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694809601; cv=none; d=google.com; s=arc-20160816; b=WG+fLYGVeVWMzAsVAYnzRuSKzpxBlpEIpqaWH3+J7fnmg0NxdFU1Xum/3fi4RDiFmt urBHwd5g/F1GIc+hZ0CxyPTRQ4niYBFoEHfp3Asjj2sZnGi+VIHXIwDKbICQjhjNKe9A inYSsaNRrBxx6u8QQHWGwEeGVYQ64Ymido4SwRg/VQDZEETBWx4sMnKbZHypnrT9GxLG C7hoSHUpEYaVrkuEFdYePWBzV5ISJtn8DYCWhKCkoqVlyKVvV7UbQgLcYD25H0OP36mF qJMKfctspFltF2U7Uwu15jxTTRM//7USBh/t4vsgzOVPvprnMyf3sWVYLxot70cZKzjM uG3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SzrHPPmJTKjWfDrn3YXBgU9n1TNPo/kiGOZujmxfC3o=; fh=kl+S4GAUWD1kOeoqBopscteh2mu3DZslcHc01dOJ6TI=; b=ougTyAZbfYampqMryMt8hKLcg2PqE2jS7e0vwCfZkSeOUTZFXtrB1eDxT4glXWdzgX obMEZcrcRp0TX5I1hz7o2uHYl7VW7vDieRdPpDxe5l7pcqPmVoRalaulqC+OADOuNaeV ljHS3iyZhTfqA9FtbOOcUh2wkdxqnyM7AaRPkEKW1cfS8GVcH7dH7pdkFrD5aDmQxMzk Ins2X2sEa+qn9m+yb17IuRGhrFfp+TnEIgd49y708sODJNPS3Yyv0yA/60MpgVMtAO9q ddnW8S+7GeuHSrx2wljAUYj9eYE5M7RwAsun/PbIuwMKtpLn7S9TngAmjLcaXLLbZ4n6 7YJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pankajraghav.com header.s=MBO0001 header.b=zv1eBTD7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id k8-20020a17090a9d8800b00274077b3ff1si5890031pjp.54.2023.09.15.13.26.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 13:26:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@pankajraghav.com header.s=MBO0001 header.b=zv1eBTD7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 8C44D8053CDA; Fri, 15 Sep 2023 11:43:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236814AbjIOSml (ORCPT + 99 others); Fri, 15 Sep 2023 14:42:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237022AbjIOSm1 (ORCPT ); Fri, 15 Sep 2023 14:42:27 -0400 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99CB63A84; Fri, 15 Sep 2023 11:40:57 -0700 (PDT) Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4RnNJS3W0Xz9sbL; Fri, 15 Sep 2023 20:39:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803160; 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=SzrHPPmJTKjWfDrn3YXBgU9n1TNPo/kiGOZujmxfC3o=; b=zv1eBTD7DSyKB/ZHl4zr3fiwfusUpLKbzkWEafjVoKUx2xfMK7rklsQPPIp19HKeoo3l8c FWeg/koAWMOCS5X6e/FiZsa8S/OteBDH7E1VOVQjIAhxRZxG2855TiW8pZ388XhUkviYq2 bUYv3/X5vM3Wi4vWfiFfR93e4/3fPoNylQkICflCDoirfo2ziNslgUpmYPd0h1VRhy/zgi U9QpS/GtWY71h/CXkrwsXNlNbS9TdIZ8rep7TVuhIWNrq3bhlA9o+chV8bjGafiMcWHOQs lIMWb0XukJXAYtVaua7Mngo8ueNlG8zrZT38tUYnIZNdtKRF4sPJFkbVEB/wNA== From: Pankaj Raghav To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: p.raghav@samsung.com, david@fromorbit.com, da.gomez@samsung.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, willy@infradead.org, djwong@kernel.org, linux-mm@kvack.org, chandan.babu@oracle.com, mcgrof@kernel.org, gost.dev@samsung.com Subject: [RFC 10/23] filemap: align the index to mapping_min_order in filemap_get_pages() Date: Fri, 15 Sep 2023 20:38:35 +0200 Message-Id: <20230915183848.1018717-11-kernel@pankajraghav.com> In-Reply-To: <20230915183848.1018717-1-kernel@pankajraghav.com> References: <20230915183848.1018717-1-kernel@pankajraghav.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 15 Sep 2023 11:43:05 -0700 (PDT) From: Luis Chamberlain Align the index to the mapping_min_order number of pages in filemap_get_pages(). Signed-off-by: Luis Chamberlain --- generic/451 triggers a crash in this path for bs = 16k. mm/filemap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index e4d46f79e95d..8a4bbddcf575 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2558,14 +2558,17 @@ static int filemap_get_pages(struct kiocb *iocb, size_t count, { struct file *filp = iocb->ki_filp; struct address_space *mapping = filp->f_mapping; + unsigned int min_order = mapping_min_folio_order(mapping); + unsigned int nrpages = 1UL << min_order; struct file_ra_state *ra = &filp->f_ra; - pgoff_t index = iocb->ki_pos >> PAGE_SHIFT; + pgoff_t index = round_down(iocb->ki_pos >> PAGE_SHIFT, nrpages); pgoff_t last_index; struct folio *folio; int err = 0; /* "last_index" is the index of the page beyond the end of the read */ last_index = DIV_ROUND_UP(iocb->ki_pos + count, PAGE_SIZE); + last_index = round_up(last_index, nrpages); retry: if (fatal_signal_pending(current)) return -EINTR; @@ -2581,8 +2584,7 @@ static int filemap_get_pages(struct kiocb *iocb, size_t count, if (!folio_batch_count(fbatch)) { if (iocb->ki_flags & (IOCB_NOWAIT | IOCB_WAITQ)) return -EAGAIN; - err = filemap_create_folio(filp, mapping, - iocb->ki_pos >> PAGE_SHIFT, fbatch); + err = filemap_create_folio(filp, mapping, index, fbatch); if (err == AOP_TRUNCATED_PAGE) goto retry; return err; -- 2.40.1