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 X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56B0FC433DF for ; Wed, 14 Oct 2020 03:04:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B437C22201 for ; Wed, 14 Oct 2020 03:04:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="KjYOvQja" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B437C22201 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 77BF46B0071; Tue, 13 Oct 2020 23:04:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E8276B0068; Tue, 13 Oct 2020 23:04:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0DB856B0070; Tue, 13 Oct 2020 23:04:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0055.hostedemail.com [216.40.44.55]) by kanga.kvack.org (Postfix) with ESMTP id B0EC26B006E for ; Tue, 13 Oct 2020 23:04:03 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4FA141EF1 for ; Wed, 14 Oct 2020 03:04:03 +0000 (UTC) X-FDA: 77369036766.13.move42_610c86027208 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 2E2A418140B67 for ; Wed, 14 Oct 2020 03:04:03 +0000 (UTC) X-HE-Tag: move42_610c86027208 X-Filterd-Recvd-Size: 3100 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Wed, 14 Oct 2020 03:04:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Fzh51vQNpYK9qDtm8DdSGaGA15CKG5lqyy79LzIykwE=; b=KjYOvQja/Iwuct+ojBrauVcVFx AxDAnkywo8nFPa+UzyHzrFSK8cpK50zKIJo5mc2Lkn4uXOfdssASd7f2vK5QZ2A2Em9jS6AH0C5FC q4eA7p84qUjFnY6ez4a9CO6Ao3Obj7lPz31pHvQxpsSXd38W2AuQW6RysUkD1xOLviU4QgPO/v0vy QVyWPtDCp2/Zp9sWQ9r7gUosW/VBQnfn4kpninNnAGchfyQPqgy1H5sGp/ZGoBvExla98nY1tCq8U AJjTXeo+/HXc9pH26lwtrVUh2cB7McLvU5g8jdj3ciXceDJrtncqAn8Jbh1STKhZta/UmTXamuMlL Uwi7ZsHA==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSX55-0005i8-Lw; Wed, 14 Oct 2020 03:03:59 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 02/14] fs: Make page_mkwrite_check_truncate thp-aware Date: Wed, 14 Oct 2020 04:03:45 +0100 Message-Id: <20201014030357.21898-3-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201014030357.21898-1-willy@infradead.org> References: <20201014030357.21898-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: If the page is compound, check the last index in the page and return the appropriate size. Change the return type to ssize_t in case we ever support pages larger than 2GB. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagemap.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 7dc6bf713d27..5083a0efafa8 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -983,22 +983,22 @@ static inline unsigned long dir_pages(struct inode = *inode) * @page: the page to check * @inode: the inode to check the page against * - * Returns the number of bytes in the page up to EOF, + * Return: The number of bytes in the page up to EOF, * or -EFAULT if the page was truncated. */ -static inline int page_mkwrite_check_truncate(struct page *page, +static inline ssize_t page_mkwrite_check_truncate(struct page *page, struct inode *inode) { loff_t size =3D i_size_read(inode); pgoff_t index =3D size >> PAGE_SHIFT; - int offset =3D offset_in_page(size); + unsigned long offset =3D offset_in_thp(page, size); =20 if (page->mapping !=3D inode->i_mapping) return -EFAULT; =20 /* page is wholly inside EOF */ - if (page->index < index) - return PAGE_SIZE; + if (page->index + thp_nr_pages(page) - 1 < index) + return thp_size(page); /* page is wholly past EOF */ if (page->index > index || !offset) return -EFAULT; --=20 2.28.0