Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3761739pxk; Tue, 29 Sep 2020 05:46:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTVuVtbBEuMuAYbHul6FkxUtR/aB2jElwxpqgwyAucUAFraDCEnrHe5m1+hmD1vq5DB83c X-Received: by 2002:a17:906:4685:: with SMTP id a5mr3668514ejr.446.1601383582256; Tue, 29 Sep 2020 05:46:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601383582; cv=none; d=google.com; s=arc-20160816; b=IzMQ2d+3ou2m0VyD5X3QkojuXvwxy7GJgUjL4WwX7FucVL3KOqJCk5Yy3trJL6sNiA Q9xG8LmtojgvQjBDCixP1hlzDRWVoyiaq73WXE4aHrmeEWz+DeoQ8I0ntqWRMYrzIqLT l72ExfjBw0PFXAaa8nCaPjzMQd/ijPNiWjvzz01wAKkXmdAqL/8/RSADmCCIveSrwxJ+ n95Fo8zszrloy0U/Ig8/J3aIHtSUT0Xk0KPnzVi56ipgZU81v/ywGp4K5wABe+zFx1Ii zCAVzqamdglc39xeCfa7wczt42MopVE+OyYDoaZx2Y7swhZhpHarmB75gWiAyd5Wc6IM 1ibQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3Zy06oRgcIcAQqe4Oh9nWNgW5XxynFsjn7qUS76GnM0=; b=MJ5xcMQg1zsFlHcYvN4kM+nmBjWoD1xv2miAZkp+2KEWtOJiin6Ff05BInyVbzpE+J ac4YdGl++Q2pSmaPio8MGVnx1q+IevqMx8RiJQERT5k0b7sUw+2/PxY2LtsQXtfX5zpz nu+A56nH/JILyl6fQxEoYnAT4DLt77TNaIEQavXy92NEwCW6KLPWPPPBPnRep5fUQUww a+hc5amUZ5RijSsgPyuyVURnHoTjj39k2B0K4NB9zKDXLJHrH6V8FBBb2TdxU3cmaMxd BzAu4/IUZPFq7y/Q0M2cH2cvXioHV9F9N8r+OEiNnqvcrXjykG0sRUl+i8L/m4zEVl6q fhuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=FFQTzNV9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w11si2521630ejy.632.2020.09.29.05.45.59; Tue, 29 Sep 2020 05:46:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=FFQTzNV9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732226AbgI2MnZ (ORCPT + 99 others); Tue, 29 Sep 2020 08:43:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731252AbgI2MnH (ORCPT ); Tue, 29 Sep 2020 08:43:07 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D443C061755 for ; Tue, 29 Sep 2020 05:43:07 -0700 (PDT) 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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