From patchwork Mon Jun 12 20:24:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13277268 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AF09C7EE2E for ; Mon, 12 Jun 2023 20:24:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D9A58E0002; Mon, 12 Jun 2023 16:24:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 560656B0075; Mon, 12 Jun 2023 16:24:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 400408E0002; Mon, 12 Jun 2023 16:24:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 27A456B0074 for ; Mon, 12 Jun 2023 16:24:45 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id EF2F4A0327 for ; Mon, 12 Jun 2023 20:24:44 +0000 (UTC) X-FDA: 80895224088.05.4871748 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 32A22140021 for ; Mon, 12 Jun 2023 20:24:42 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XbGvS7DF; spf=pass (imf23.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686601482; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=S42fl/HoNEU97xotwFSAjJfWCsSnH9zjSpzpvH3McME=; b=JItXEsLuwKwzDAREXq4OiPfpp0162l7fkXfqJo9nxI8NMQ/RJkzi4SlHoFN1CO2sR/lohA +H3xv6YBh+zzn7rK+iBqmIEFTs616NCPPCsGEUwOSctq4XRZaTe/MDXmILsIB6IOZeLp++ TFajQiHcYPkNJONtGrQ6xYR+0TL+U3g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686601482; a=rsa-sha256; cv=none; b=vSB91wPVxpGOFkAySE8VACXUgGrod9cidkXniOYTD9ZwThhn+CUJztwHFzOboM13X3H1Z+ nKhsL2UHMILGWVKK8+I5Ie3TJAFYUvSVrvywG7dItxiDc62p16qQD7kNnsYze40cOMSbCa 3+gwJKsr/ucUMUhKlfFISv11NVreaEs= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XbGvS7DF; spf=pass (imf23.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686601481; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=S42fl/HoNEU97xotwFSAjJfWCsSnH9zjSpzpvH3McME=; b=XbGvS7DFB81vZcz9I4UhVIyY1v6qVH0rgmyNhMTUl/OQdwuz7bbfJsjLYoNnOV7hyiN4zy M9GIMSoybOrhMHsNzDtyv9Vb05sSRx5vBvXLacRWAJjJYVxdkrXYgiZ4Qd2+Aebx8XmNIe TJ/kuwTUdTAFCS9qEQkLS43tfiZefFw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-139-xzVXP3XYOhqICv2yzeVXDA-1; Mon, 12 Jun 2023 16:24:38 -0400 X-MC-Unique: xzVXP3XYOhqICv2yzeVXDA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 230618037AA; Mon, 12 Jun 2023 20:24:37 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id A51B12956; Mon, 12 Jun 2023 20:24:34 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells To: Jens Axboe , David Hildenbrand , kernel test robot cc: dhowells@redhat.com, Christoph Hellwig , Andrew Morton , Al Viro , Matthew Wilcox , Jan Kara , Jeff Layton , Jason Gunthorpe , Logan Gunthorpe , Hillf Danton , Christian Brauner , Lorenzo Stoakes , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-mm@kvack.org, oe-lkp@lists.linux.dev, lkp@intel.com, linux-kernel@vger.kernel.org Subject: [PATCH v2] block: Fix dio_bio_alloc() to set BIO_PAGE_PINNED MIME-Version: 1.0 Content-ID: <545462.1686601473.1@warthog.procyon.org.uk> Date: Mon, 12 Jun 2023 21:24:33 +0100 Message-ID: <545463.1686601473@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Stat-Signature: ccym8ffp6841oa5agczmir4isfk93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xsj0AR2o9Z42vtHQ8g6MH2FPlzdsnSsMT+cE3ZqzLvWcR7KVVsrlP4jw9wabfHAONM6c+oIvJbNyO1CuE1Av2g09MNSfoZ4red+ZudkxQonwGn9sDAjJfqSNdE0apJAW+8v7MykyqOwgs1Yu7RYH6RFObl4aw9lffdBitmb6lSvVBYDzkrZcPqy5TMG1b1fsWhThsMPNj/e+XmOQmvNA56ckIVbmSmcPSwpKO0tSoHpB9RuRSi8jw0NdpCbOHsDGLLovt19xgTlQSX886LFfuNc2bi4/cTI3+FXDJ9fSURJNoWQGnu0nlf0TCfTh6K6O8q6FDhiM+PRkClOaJaewMrN3lOZ952MlN5FeN9fseN+fzNCV8O7dSpCy9DA4TF6sIcoGoGN48HSYQ4rBHPMxdJQEs7KdDzWjCG9Z8DMGzNgyKMhqKxn0JCdHKRmBgXXqII2G8cIIV7Kfdd4Fskw2yxy4J0gA9rMcFazz6pYxwFJ2T1uE9rYMju+SjpaF+VoI4J3pOOoeDdyUuJahvtcJ+fNUrM25+7KqJNM39Cg+Hx337/pMYglZd4sZtfPXFhZnFyZyit9Fx2OTOpxFHe1m/ba+P8ymp64lJLnDi0KSeatI1GZ4AlyeG/WqJAACiKw1+urmA6V0QrpnzCFregX/bsw1Sc0zDeUAsLt7nTg== 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: Fix dio_bio_alloc() to set BIO_PAGE_PINNED, not BIO_PAGE_REFFED, so that the bio code unpins the pinned pages rather than putting a ref on them. The issue was causing: WARNING: CPU: 6 PID: 2220 at mm/gup.c:76 try_get_folio This can be caused by creating a file on a loopback UDF filesystem, opening it O_DIRECT and making two writes to it from the same source buffer. Fixes: 1ccf164ec866 ("block: Use iov_iter_extract_pages() and page pinning in direct-io.c") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202306120931.a9606b88-oliver.sang@intel.com Signed-off-by: David Howells cc: Christoph Hellwig cc: David Hildenbrand cc: Andrew Morton cc: Jens Axboe cc: Al Viro cc: Matthew Wilcox cc: Jan Kara cc: Jeff Layton cc: Jason Gunthorpe cc: Logan Gunthorpe cc: Hillf Danton cc: Christian Brauner cc: Linus Torvalds cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-kernel@vger.kernel.org cc: linux-mm@kvack.org Reviewed-by: Christoph Hellwig Reviewed-by: David Hildenbrand --- Notes: ver #2) - Remove comment on requiring references for all pages. fs/direct-io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/direct-io.c b/fs/direct-io.c index 14049204cac8..5d4c5be0fb41 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -414,8 +414,8 @@ dio_bio_alloc(struct dio *dio, struct dio_submit *sdio, bio->bi_end_io = dio_bio_end_aio; else bio->bi_end_io = dio_bio_end_io; - /* for now require references for all pages */ - bio_set_flag(bio, BIO_PAGE_REFFED); + if (dio->need_unpin) + bio_set_flag(bio, BIO_PAGE_PINNED); sdio->bio = bio; sdio->logical_offset_in_bio = sdio->cur_page_fs_offset; }