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=-10.5 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 52B42C433DB for ; Tue, 9 Feb 2021 14:29:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A54AD64E56 for ; Tue, 9 Feb 2021 14:29:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A54AD64E56 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E59366B0071; Tue, 9 Feb 2021 09:29:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DE0EB6B0072; Tue, 9 Feb 2021 09:29:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA8EC6B0073; Tue, 9 Feb 2021 09:29:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0216.hostedemail.com [216.40.44.216]) by kanga.kvack.org (Postfix) with ESMTP id B24866B0071 for ; Tue, 9 Feb 2021 09:29:40 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7B73F180268B6 for ; Tue, 9 Feb 2021 14:29:40 +0000 (UTC) X-FDA: 77798962920.14.range82_2f0eca827608 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id 4F4A9182299BB for ; Tue, 9 Feb 2021 14:29:40 +0000 (UTC) X-HE-Tag: range82_2f0eca827608 X-Filterd-Recvd-Size: 4829 Received: from mail-io1-f43.google.com (mail-io1-f43.google.com [209.85.166.43]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Tue, 9 Feb 2021 14:29:39 +0000 (UTC) Received: by mail-io1-f43.google.com with SMTP id n201so18890920iod.12 for ; Tue, 09 Feb 2021 06:29:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=sR8Y5r3hBaqi7OfyrOKfoKntN+cJHKvefPND1Fw72qs=; b=Xmsw9t81sF7zEdoNNbMsU6rqedj1RxMf9mcipV//PWNWxig3fn3xRl9ZGIeGGOnnGX Boh54R+8O+7qvyy9btRg54MNOmu+D8TRD1muXASban1wc5YNR0LxyLI6bj+Vc31h8M03 IbUNoZmyk6qoh2CbqqmVGQZBckW9uc5gPyfqJZQp0G45Gfcr6jtNUrq4IyCCo9YPeWNq SdJ/u7jFjajPV04J5QXW4JPZdK1GKo56wIgUOIO2nLmvV/ZHgzwrybBnVZO24oss0rK+ B5oi6SEnXZVOmx4ifTo0hTMEH7UMB6xw83Dan05fNjE05nOC++APeB1TGYu9yKWZMMwe 5gRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=sR8Y5r3hBaqi7OfyrOKfoKntN+cJHKvefPND1Fw72qs=; b=YiHl9Yb0gRYnYqz4fVG1+tD1+dFMoESwbcq47ezk0pRpBdp9D7XV42pjg0fuQRm1ot s9o6Fw7zjuzGixnvxB8dObkNHbQ2SYi4XYgSoE2DW6HGIZBQg3uDlEh6wcyRShwelnvN aCgUYjIgCiVDCfAD+Pr4N6DduelcEGuOeduwIBvaiM3Y3X9iEbhsvNsC0uHJWPRDCITj 0jlawKG7K4FO272l+0wV1GXpiWR6Om5GQRlV6rLLf25d2j0QG633APLYWTS1H9tc3gxX 2JSRvxOOK4yRxEN/Imx0Wowz+rmQKk2rahlYXaDtvDj73Be9ke//KEZC5N04hJ32SzqG xRpQ== X-Gm-Message-State: AOAM533TZ4pefEZAsxmZL5zttDztWbFPFgoDvhpyvm6U8KvXhIe8pu4m 4x2wlmJ5I/oLfAgO5ishJuwFlg== X-Google-Smtp-Source: ABdhPJx10WZDpqwBaXShrmjbhnFlTKZO7snwFdVsANnFEeNvaYn8UtAwvKhWqiF60oh87N98gP9y4Q== X-Received: by 2002:a5e:c74a:: with SMTP id g10mr3350295iop.129.1612880978696; Tue, 09 Feb 2021 06:29:38 -0800 (PST) Received: from [192.168.1.30] ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id h12sm10678522ilj.52.2021.02.09.06.29.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Feb 2021 06:29:38 -0800 (PST) Subject: Re: [PATCH 3/3] iomap: use filemap_range_needs_writeback() for O_DIRECT reads To: Christoph Hellwig Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org References: <20210209023008.76263-1-axboe@kernel.dk> <20210209023008.76263-4-axboe@kernel.dk> <20210209075119.GC1696555@infradead.org> From: Jens Axboe Message-ID: <9fb1a43c-3d5f-be43-952e-b0462ed47b4c@kernel.dk> Date: Tue, 9 Feb 2021 07:29:37 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210209075119.GC1696555@infradead.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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 2/9/21 12:51 AM, Christoph Hellwig wrote: > On Mon, Feb 08, 2021 at 07:30:08PM -0700, Jens Axboe wrote: >> + if (iocb->ki_flags & IOCB_NOWAIT) { >> + if (filemap_range_needs_writeback(mapping, pos, end)) { >> + ret = -EAGAIN; >> + goto out_free_dio; >> + } >> + flags |= IOMAP_NOWAIT; >> + } >> if (iter_is_iovec(iter)) >> dio->flags |= IOMAP_DIO_DIRTY; >> } else { >> + if (iocb->ki_flags & IOCB_NOWAIT) { >> + if (filemap_range_has_page(mapping, pos, end)) { >> + ret = -EAGAIN; >> + goto out_free_dio; >> + } >> + flags |= IOMAP_NOWAIT; >> + } >> + >> flags |= IOMAP_WRITE; >> dio->flags |= IOMAP_DIO_WRITE; >> >> @@ -478,14 +493,6 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, >> dio->flags |= IOMAP_DIO_WRITE_FUA; >> } >> >> - if (iocb->ki_flags & IOCB_NOWAIT) { >> - if (filemap_range_has_page(mapping, pos, end)) { >> - ret = -EAGAIN; >> - goto out_free_dio; >> - } >> - flags |= IOMAP_NOWAIT; >> - } > > looking at this I really hate the scheme with the potential racyness > and duplicated page looksups. Me too > Why can't we pass a nonblock flag to filemap_write_and_wait_range > and invalidate_inode_pages2_range that makes them return -EAGAIN > when they would block to clean this whole mess up? We could, but that's a _lot_ of surgery. I'd rather live with the slight race for now instead of teaching writepages, page laundering, etc about IOCB_NOWAIT. I do think that's a worthy long term goal, but we dio read situation is bad enough that it warrants a quicker fix. -- Jens Axboe