Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1057746ybl; Sat, 18 Jan 2020 17:44:25 -0800 (PST) X-Google-Smtp-Source: APXvYqw7rrXpHyl18W9u7KrOeLZtPpylvboM6OcTL/8GHgCLyuodvkyD+xTOuUX2u8+gZYZlkP7J X-Received: by 2002:a9d:6e82:: with SMTP id a2mr11118692otr.336.1579398265391; Sat, 18 Jan 2020 17:44:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579398265; cv=none; d=google.com; s=arc-20160816; b=nsaHkm9iC9V9DI4kdf37ByCEfljVtPAjprLl0kXmYRvC8uRe6TTrxT0UAT4GnMV/gY 2ufDu7oZpHSug6BcthN/7oH+mglPcHUwPYjyuNWdfvkLKsfzSFykJKqcFq0CkFPZqzj8 jgN9UJcNcSNx/o5TeQcPg1Ze6U7m4OIfpK3rpA2OO6Fld/g27QhrjrVf8OUE2oHeIF1/ A7fYlIjEUXQv6/HNUIHUqNCi6WXpKsrhGMLRT0dS4Zho9QOxYX0QqHsTIncr8TP9UByv SOSVanMegnkBr41LW7hA1Z/ho3oj+xZbyu3Om4HcWwcFEgKrMdo5ajR4VmHBYcDrAufA hC8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=GacFmTwPDNSrAHS3oEX1cOtDzMsn4hpcGoZQBj+oge8=; b=P57dgo+YKME3iwmRK+FNmoOLgDlZc9qV9DKQsiKYxLkplYXVp2fRVcTyvxnz2eaVID OmJ4u7GYnd1fsQa+lsotEqpERLGEdiESS7JCaSOOfRUsZQK1t7qSKRCEqiQ858cdf+cN Mwp6Ab30nsGyZ4/848NVMSE0rv9EDzDF/Oup86bMvXAc04GXEABfJLpBA97ukb5ybmTr lRbu/3XKtb/Pr1PSWoBVchWIuy/4gjnSODRmyX7w7TcM+3jL5g4BxZ/PZrf6e9TyIWYi Khn6Bfu6ukW/w6FAgTOWqjhkUpwpPLiapociSpLRGRpn7g+1dc4gw8oKDhvD9VGO21P0 umPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=pSvbAnIf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w19si11313144oih.201.2020.01.18.17.44.13; Sat, 18 Jan 2020 17:44:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=pSvbAnIf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727766AbgASBnW (ORCPT + 99 others); Sat, 18 Jan 2020 20:43:22 -0500 Received: from [198.137.202.133] ([198.137.202.133]:55144 "EHLO bombadil.infradead.org" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1727106AbgASBnV (ORCPT ); Sat, 18 Jan 2020 20:43:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=GacFmTwPDNSrAHS3oEX1cOtDzMsn4hpcGoZQBj+oge8=; b=pSvbAnIfeaU8NhiNePru6z203 2b75/Sh4GoqRdexOHid3yVIFzRIf7ePbj9Iy43BhVmksspkhqiBi9Iw9qF0+/rFAieHnMzowwXkRQ YjfJGFRjBb9CKkseEkmnH3O2HE22DQUsjfWK7+bFq5xvuV8npFCHZtcSx2Xm476KM3ADF1VTPotPG kf2UK30o680R5XrbvuvlgeO0bz4b9gQmYSpCpaUsDapugo4HWQ1YKN5BBeU7iwvNB7xYXPWzJvHSC Siofg7N/OlykrLD9gGeABxvUChhn0pbbsFnQ2Sw0S4acilxY/W7VM9RW1eSYxh9rkwdY6YUaJEZnB gnX74Buzg==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1iszbR-0002Jg-E3; Sun, 19 Jan 2020 01:42:13 +0000 Date: Sat, 18 Jan 2020 17:42:13 -0800 From: Matthew Wilcox To: "yukuai (C)" Cc: hch@infradead.org, darrick.wong@oracle.com, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, houtao1@huawei.com, zhengbin13@huawei.com, yi.zhang@huawei.com Subject: Re: [RFC] iomap: fix race between readahead and direct write Message-ID: <20200119014213.GA16943@bombadil.infradead.org> References: <20200116063601.39201-1-yukuai3@huawei.com> <20200118230826.GA5583@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 19, 2020 at 09:34:32AM +0800, yukuai (C) wrote: > > > On 2020/1/19 7:08, Matthew Wilcox wrote: > > It's worth noting that my patch series from earlier this week to > > redesign the readahead API will fix this problem. Direct write will block > > on the locked pages in the page cache. > > Thank you for your response! > > In this case, direct write finish while page do not exist in the page > cache. This is the fundamental condition of the race, because readahead > won't allocate page if page exist in page cache. > > By the way, in the current logic, if page exist in page cache, direct > write need to hold lock for page in invalidate_inode_pages2_range(). Did you read my patch series? The current code allocates pages, but does not put them in the page cache until after iomap is called. My patch series changes that to put the pages in the page cache as soon as they're allocated, and before iomap is called.