Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1052969ybl; Sat, 18 Jan 2020 17:36:20 -0800 (PST) X-Google-Smtp-Source: APXvYqxBMqkue1BKT8x2b6gj44wygBZd8sS/o/LwiQBYEmRl7atHgpEuj+TPqNV+Dr7QapF9VjDt X-Received: by 2002:a9d:7b51:: with SMTP id f17mr11227202oto.302.1579397779744; Sat, 18 Jan 2020 17:36:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579397779; cv=none; d=google.com; s=arc-20160816; b=dOmWQES9t+g+dIs/7f3IgqXZ9NAExKyVUX0+3F4aYFDwEQnzZGZdFX9Hexjm28SHIv EQQW5cac9CB0DexFfMeg4++sJXbKzfLDRnPF0LZqclFnHzgnUIp+3GBw+cx8l1t4fser co2z5eJ4xlB+q0BMuFixvihH4ltrBOIJ46cEhUZ73uGEVXIf1uG3R00RC87ptd1q/Hov uYP/Bz1yQEryD8YcJZ/zqVvIwm9K0ZqT1j9TBNoqBsbbVdjEaINvoS6Ips0wE4YCtAcy CpwY5ydcrwDQRW7P0HNxsF5neRp4Dt0qC8ld++t+AsRllzsvON1Fo6AygUf8AcZClzcM ssCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=OuxCsRq18JIL07Y/pkDyIB3bgXWuEi8FkOXHFfqZyQI=; b=zNGru4rdTixedOinp6iDBTXJx91Q2ClgGFKCMhYuIuBL3f48OhUuEWVvMHE/zjvJkR oygMWeAQTfE35vWMGmiOfYUmbmx/pYDDrF9BI7Y4HlWxaYR0bSPMGodGrUGSIaE5e9s6 ms9Y/D+aM566tsRihxoDfhtTv7U7yeFBhFa43COVD4N00L/u/WWyFfYnMsdhHSqvmM5e Hvre4g+DzkwuVtPJewhfyaKrdD0dnZfXkjodRVR6pyqa0Hx8+gPzZmiI+treohHVm8vL 5/tw24i7t501UnZxSsre2Jq8y0acaOiK2EOgFTrwoWjvFLG3oN+kscF7VcTvR17IKMUN ehew== ARC-Authentication-Results: i=1; mx.google.com; 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 l7si9178283otn.123.2020.01.18.17.36.08; Sat, 18 Jan 2020 17:36:19 -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; 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 S1728792AbgASBep (ORCPT + 99 others); Sat, 18 Jan 2020 20:34:45 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:9652 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728689AbgASBep (ORCPT ); Sat, 18 Jan 2020 20:34:45 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id AF8274ADDE76E45BC65C; Sun, 19 Jan 2020 09:34:42 +0800 (CST) Received: from [127.0.0.1] (10.173.220.96) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.439.0; Sun, 19 Jan 2020 09:34:33 +0800 Subject: Re: [RFC] iomap: fix race between readahead and direct write To: Matthew Wilcox CC: , , , , , , , References: <20200116063601.39201-1-yukuai3@huawei.com> <20200118230826.GA5583@bombadil.infradead.org> From: "yukuai (C)" Message-ID: Date: Sun, 19 Jan 2020 09:34:32 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20200118230826.GA5583@bombadil.infradead.org> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.173.220.96] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(). Thanks! Yu Kuai