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=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 52B63C4741F for ; Tue, 29 Sep 2020 12:43:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5C63021D43 for ; Tue, 29 Sep 2020 12:43:01 +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="FFQTzNV9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C63021D43 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 5606C6B0062; Tue, 29 Sep 2020 08:43:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 510956B0068; Tue, 29 Sep 2020 08:43:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3FEC66B006C; Tue, 29 Sep 2020 08:43:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0035.hostedemail.com [216.40.44.35]) by kanga.kvack.org (Postfix) with ESMTP id 26FCE6B0062 for ; Tue, 29 Sep 2020 08:43:00 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B9443180AD802 for ; Tue, 29 Sep 2020 12:42:59 +0000 (UTC) X-FDA: 77316063678.22.plant39_0007e9d2718a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 8A2D618038E60 for ; Tue, 29 Sep 2020 12:42:59 +0000 (UTC) X-HE-Tag: plant39_0007e9d2718a X-Filterd-Recvd-Size: 4408 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Tue, 29 Sep 2020 12:42:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=3Zy06oRgcIcAQqe4Oh9nWNgW5XxynFsjn7qUS76GnM0=; b=FFQTzNV9FLJWoPmNhxe5yL1W+Q tDkiItvKjFTET2X9o+OiiUO/NvmheEO+m5yLMVhFHhfebG1nbpZ6X034hcT2/wVo1ixij5+dxwvqN s71s/67K+KnNkPIMUFTHdqAqiLkInwtvZZJpDTQog6HZvYypcOTmFUhLiGTrvDrh0Fw76AJufwe3e pmSQqEclL6qF3fKcedWFu7/rp3eyIsS4U57xPU1gR+juL/YY7uhq1XdJ8eNJYa4pMfeROaFN21sl+ yJhcF8jHc7L0EdAqlkZPerM0uMCm4mi20gNAIwsil3v7pjo9XW5wTSGFKP7OZD2O56GV6HX1Qk+oL oqYOxVPA==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNEy4-00066L-2U; Tue, 29 Sep 2020 12:42:52 +0000 Date: Tue, 29 Sep 2020 13:42:51 +0100 From: Matthew Wilcox To: Jan Kara Cc: linux-mm@kvack.org, Andrew Morton , Hugh Dickins , William Kucharski , Johannes Weiner , Yang Shi , Dave Chinner , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 04/12] mm/filemap: Add mapping_seek_hole_data Message-ID: <20200929124251.GB20115@casper.infradead.org> References: <20200914130042.11442-1-willy@infradead.org> <20200914130042.11442-5-willy@infradead.org> <20200929084653.GC10896@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200929084653.GC10896@quack2.suse.cz> 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: On Tue, Sep 29, 2020 at 10:46:53AM +0200, Jan Kara wrote: > On Mon 14-09-20 14:00:34, Matthew Wilcox (Oracle) wrote: > > Rewrite shmem_seek_hole_data() and move it to filemap.c. > > > > + rcu_read_lock(); > > + while ((page = xas_find_get_entry(&xas, max, XA_PRESENT))) { > > + loff_t pos = xas.xa_index * PAGE_SIZE; > > OK, but for ordinary filesystems this could be problematic because of > exceptional entries? For ordinary filesystems, I have this queued up on top: http://git.infradead.org/users/willy/pagecache.git/commitdiff/02c740b215bab901f95a560759b3bd906648da08 which handles exceptional entries. It treats shadow/swap/DAX entries the same -- there's definitely data there, it's just not in a struct page right now. > Also for shmem you've dropped the PageUptodate check which I'm not sure is > safe? That was unintentional. I did run xfstests against this patch (just did it again ... it passes), so I suspect it doesn't create a !Uptodate page. I'll see if I can enhance the existing xfstests to catch this case. The patch I link to above also doesn't handle !Uptodate pages on shmem filesystems the same way that the current code does. So ... on top of this patch, I propose doing this: @@ -2416,6 +2416,14 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_ite r *iter) } EXPORT_SYMBOL(generic_file_read_iter); +static inline loff_t page_seek_hole_data(struct page *page, + loff_t start, loff_t end, bool seek_data) +{ + if (xa_is_value(page) || PageUptodate(page)) + return seek_data ? start : end; + return seek_data ? end : start; +} + static inline unsigned int seek_page_size(struct xa_state *xas, struct page *page) { @@ -2463,10 +2471,10 @@ loff_t mapping_seek_hole_data(struct address_space *mapping, loff_t start, start = pos; } - if (seek_data) + pos += seek_page_size(&xas, page); + start = page_seek_hole_data(page, start, pos, seek_data); + if (start < pos) goto unlock; - - start = pos + seek_page_size(&xas, page); } rcu_read_unlock(); ... and then rebasing the other patch on top of this works out nicely. Here's the result: http://git.infradead.org/users/willy/pagecache.git/commitdiff/9eb3f496b7cdcdcae83026e861e148f46921c367 http://git.infradead.org/users/willy/pagecache.git/commitdiff/7d93274088f0872d849a906d783dc260bee106b9