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=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 0FF76C433DF for ; Thu, 2 Jul 2020 18:07:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BE06D20870 for ; Thu, 2 Jul 2020 18:07:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="SAc0P6TZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BE06D20870 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0C4A38D0017; Thu, 2 Jul 2020 14:07:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 071808D000C; Thu, 2 Jul 2020 14:07:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA30E8D0017; Thu, 2 Jul 2020 14:07:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D6A7E8D000C for ; Thu, 2 Jul 2020 14:07:27 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 9CC70180AD802 for ; Thu, 2 Jul 2020 18:07:27 +0000 (UTC) X-FDA: 76993918134.03.verse92_170e88d26e8b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id DE2E5160B8 for ; Thu, 2 Jul 2020 18:06:37 +0000 (UTC) X-HE-Tag: verse92_170e88d26e8b X-Filterd-Recvd-Size: 4743 Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Thu, 2 Jul 2020 18:06:37 +0000 (UTC) Received: by mail-lf1-f68.google.com with SMTP id u25so16795034lfm.1 for ; Thu, 02 Jul 2020 11:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hXeahw42GKg9juA4uBvpVeENM2KNGrSYvX0lCAxHaNg=; b=SAc0P6TZQfW4FQsf2+lBD6w+OSrGuXoO/P2PmSMr9aJV7th8BuILaQ/KWCoOqTwRky Z+eIAa2Z4MCcV67tYB3E39MCwT1aVIIJBvvu6hNQ/ndKZHjjvkLbORwFnofChsGG7dJ/ +O1yGNrkWF0L9ihdnRiytVkIkOBqnPy0jQXsY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hXeahw42GKg9juA4uBvpVeENM2KNGrSYvX0lCAxHaNg=; b=dmnpKso/FcszrySxB35bytKO/+TKioaGo7d6yMyyMWKcHQDWmfURv8XhiRWDKUQ2Rq qC//K6rmwBD+GzsFIZNZhaMt9DAOAxKDTHMcN6ra6tjqsqDvVHx0UppYOO2sbq1Eh2i+ CPJMwHZ/Xub4OIMHp3o+SyBxlROd0z9IiDM6p6t2fHJr2w7OPUzSUVtRI8Waj2Qlk7ho Z3gXt22I1mDKn8zsN/g9xqv1yIq8XSjYEv1N9g0UWli9f+swNcOYoHS82cULavn+rrXe akQWuGqXTL2dPayuzJfMyugFCr0Dn/A0QFxQsZCWjamC3J0pAGB/iapNSPVPwBYMLWkY e4Iw== X-Gm-Message-State: AOAM531Q1O4371PzfFlUbZi4K+o67XuYfjNWOc+OQx7U7RSKlr++i4Hy z2Hr8Yoc6nFdXctadnhpUiB8IrEcTmU= X-Google-Smtp-Source: ABdhPJzeJ3tG47r4nDVGlaICxHKNnmyG3tH4VsnKLG7H4xVVu80OogtquKc5KstWJ6L789ZVexda5A== X-Received: by 2002:ac2:5093:: with SMTP id f19mr19341865lfm.10.1593713194438; Thu, 02 Jul 2020 11:06:34 -0700 (PDT) Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com. [209.85.208.181]) by smtp.gmail.com with ESMTPSA id l1sm3213758ljc.65.2020.07.02.11.06.33 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Jul 2020 11:06:33 -0700 (PDT) Received: by mail-lj1-f181.google.com with SMTP id q7so20150171ljm.1 for ; Thu, 02 Jul 2020 11:06:33 -0700 (PDT) X-Received: by 2002:a2e:999a:: with SMTP id w26mr11620388lji.371.1593713192759; Thu, 02 Jul 2020 11:06:32 -0700 (PDT) MIME-Version: 1.0 References: <20200702165120.1469875-1-agruenba@redhat.com> <20200702165120.1469875-3-agruenba@redhat.com> In-Reply-To: <20200702165120.1469875-3-agruenba@redhat.com> From: Linus Torvalds Date: Thu, 2 Jul 2020 11:06:16 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC 2/4] fs: Add IOCB_NOIO flag for generic_file_read_iter To: Andreas Gruenbacher Cc: Matthew Wilcox , Dave Chinner , linux-fsdevel , Linux-MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: DE2E5160B8 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 Thu, Jul 2, 2020 at 9:51 AM Andreas Gruenbacher wrote: > > Add an IOCB_NOIO flag that indicates to generic_file_read_iter that it > shouldn't trigger any filesystem I/O for the actual request or for > readahead. This allows to do tentative reads out of the page cache as > some filesystems allow, and to take the appropriate locks and retry the > reads only if the requested pages are not cached. This looks sane to me, except for this part: > if (!PageUptodate(page)) { > - if (iocb->ki_flags & IOCB_NOWAIT) { > + if (iocb->ki_flags & (IOCB_NOWAIT | IOCB_NOIO)) { > put_page(page); > goto would_block; > } This path doesn't actually initiate reads at all - it waits for existing reads to finish. So I think it should only check for IOCB_NOWAIT. Of course, if you want to avoid both new reads to be submitted _and_ avoid waiting for existing pending reads, you should just set both flags, and you get the semantics you want. So for your case, this may not make any difference. But if the issue is a deadlock where the code can block for IO, but not call back down to the filesystem for new IO (because it holds a lock that the filesystem might need) then this patch as-is is wrong, because it disallows even that case. Linus