From patchwork Mon Jun 12 16:51:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13276966 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 E96F7C7EE2E for ; Mon, 12 Jun 2023 16:51:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 58D3A6B0074; Mon, 12 Jun 2023 12:51:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 516326B0075; Mon, 12 Jun 2023 12:51:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3DF818E0002; Mon, 12 Jun 2023 12:51:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 2FE8C6B0074 for ; Mon, 12 Jun 2023 12:51:34 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id AF51F402F8 for ; Mon, 12 Jun 2023 16:51:33 +0000 (UTC) X-FDA: 80894686866.04.19FF241 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf13.hostedemail.com (Postfix) with ESMTP id C7F8220015 for ; Mon, 12 Jun 2023 16:51:30 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LyT4Bx8H; spf=pass (imf13.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=1686588690; 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=KUdFKCdBRtXD70pPEw8UKzishmgLHxiTnsybrG/P/8Q=; b=AIZdN8/uo6FXbtjYPiBQL6ciZZw636r3SuJd8XQHomtYLtq/jozP8zER4vIYjcKqe1OqbL 6w/Slk0WXOv0Fhqy4nAXFwhQd87YbKYA2TkhqO1HRrEd3+MM49BHRhLBQEonK7igBvNyl6 XlOElmTYsATsb6V1BDL4dFKCDlGeA+A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686588690; a=rsa-sha256; cv=none; b=xR44E0OmHF7wFatqQhUKTPF4XWJuGXk2MbQO3yKV2n6zUCaiPz+qOQbp6Z2M9IEWKZJs8+ Ls6SxmZZG7qkT77t+RV3htCa+HSQ/hD4OQuNFH0aitaJYBsyuzRw38Nybot2KE4QmGmhuE 0kQo2UsSbNjR+iqfmmdOz2bI2qFPTS4= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LyT4Bx8H; spf=pass (imf13.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=1686588689; 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=KUdFKCdBRtXD70pPEw8UKzishmgLHxiTnsybrG/P/8Q=; b=LyT4Bx8HjK2zeDdlO3+4FRUOMjdfrRBwjYs687oYbXa02ne5vqikoz1fgLF4oosYfBbfK1 OYGj962QOQzLPe20JRFU1JzMoob4hEDkT7cafUEYLJiELX2oO30yMjN7Jqh9zwq5AGvDVn Ht2eq/4H7c2tv1t01MKIxGMNesnvef8= 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-557-3Bd9b2jJP1qS--WMQacq3A-1; Mon, 12 Jun 2023 12:51:25 -0400 X-MC-Unique: 3Bd9b2jJP1qS--WMQacq3A-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D2BFA85A5AA; Mon, 12 Jun 2023 16:51:24 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1088720234B3; Mon, 12 Jun 2023 16:51:21 +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] block: Fix dio_bio_alloc() to set BIO_PAGE_PINNED MIME-Version: 1.0 Content-ID: <431928.1686588681.1@warthog.procyon.org.uk> Date: Mon, 12 Jun 2023 17:51:21 +0100 Message-ID: <431929.1686588681@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Rspamd-Queue-Id: C7F8220015 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: gq9o7ds1swjqzd1xtfmeb7k6t6tohd1f X-HE-Tag: 1686588690-892353 X-HE-Meta: U2FsdGVkX183utoRSRhOTPPwh9yLM6jiYFVbFLe7GXc0SZtRsmpUzCXAU2y/B6AJixVS1NBBXW5mbztxaXrv4zBJ1ky3i32hhDSHRkeRYz7kMhopeN0qflkJoaJvZ3oNFYojGAAh2VfnYFmHy4/wNUrmokE/WzmiY/o70K/b7p4dXd469GYTdVnFKmkGB9A7i6QXiH6cFv7KqLE99M89a30M881mkm5wUsPqmRBK98Eg8e5i5fI0ARq3MR5Q+zJvydBfCPGKoJpKc33997j15nhcbzLQy+Ei+qS6RV/cU4skaleYRJhqWVo0bcaF4J5iyNkUv7vKMm2Or9WeiqCiOXY06qFpdnhjISlQFwYejc6lt044z8mXGs063MWO6FHbccqjHJUjM8SADePNQkhZFcwtK4aMiW0TtMgLly6xpi7nTvDoCw8+DPVvh1hNU41D2xy/nMnB3IACL+Y62oPQrJrmnr/1ogLafcwUW0YvVLokj81+yPESwZYbqVtz9cFYM+d2ftj7fLi8yYoEOz5r/GUZ7//7/VYGpjeOydqfu+x83esklPvwVTxgaS+DJZiR+sL9iZSdjhDd7EfIchbI72nBDumiORB9mYxB9RKMoawWKyCxQgSKlzmD4eLrs1mIgCh4QNnaD7mD5e0oEFJeB3MVNmbGCz8/q1CP9zVua7zbRXQ9fPgHIjuX+upp8adCH+ZXjB3JioxRqw8vqk8FvKAbYlXmvs/5bCUpWBMSqVjEaHRNHQPpfFke1o0HCYgtLgYV4BR3saloFkNVkrSyzCk+28hMfC4zi+78BvpObuE3wiAM+KHtTn11V1Gmh+njcBAWfaXQVdZg0c5InY9yIKjRqLglG8eLFbeH7YwY8M5M+gQyGv61eMkWB5GT7PtqfpGdpFHR+9PrD34rbhWyjG+hzwfcfKfE0DpaTifx8LS6uMaqgqBmtR47eqCUW7IVex7P9PnFZqT9o6jjry9 4zFJnarB 5/YvwiOML5OgKwMKz6H+EMtCiuCCeMMdDqTZv2O+1WgQtK7BOS8OJ/Sx5hujlT0tkkk9wC4+uan4NGSjqpZM+HTOvcz5DjhiRW/UHn3+SmSJcyJgLMI9wV5Zq/zEISWLn3vSkTJ8eRYyD0SILuK9MOsKOKyPVyZGjjbcLoLEcR3YKqyvRUii7Q/RGUrlIZ8gLdVXxpvrlrUteY8wpwVRxbx7GEe7sKLSXEPfaaGOEPw33nIoZR+cyaXikNrvuI15pFTDqWOSITKHcSnXvfF3+N8Iyzp3wL9cyll/KVZxfn2daFbM/VCAcQnEcpKr+A3b7ntABS05+aQF9FcK8gRzT5LBkJFeIaQxW8fE0sGwvjDukyApvWE/yC/V+YEZ8qBUnesBxJN0SofYYRRC11I9d/HL1ngm+DNUZPvATJdn/vb+hW32fOVxNwl0Dbs131H23mOdo0x6LxNOuusqz5gxWNw6pPClsk1CPw1mHBGlA1jJzfODO9BOaMKr4i0IClZb8kYxUPQXNzv6sAbkVNsq0meFVFry4iU8YUZE9QvjjmSG/piVuxG6V1eS+FSrCS9LdjiqiLMdasRoXLmXxUyalYOg80w1oAQ6YJKym7Hkao5GBjPdLnftAeAGMrvcsi8QCsLP/lm9x8RACcDVPwVk6sA6E4vLoG3zCIfnslh90aYeC6kMYTqbSu59rkw== 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 --- fs/direct-io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/direct-io.c b/fs/direct-io.c index 14049204cac8..04e810826ee8 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -415,7 +415,8 @@ dio_bio_alloc(struct dio *dio, struct dio_submit *sdio, 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; }