From patchwork Tue Jun 13 21:54:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13279240 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 F0A34EB64DA for ; Tue, 13 Jun 2023 21:55:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A76B8E0005; Tue, 13 Jun 2023 17:55:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 657AC8E0002; Tue, 13 Jun 2023 17:55:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 547688E0005; Tue, 13 Jun 2023 17:55:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 433A98E0002 for ; Tue, 13 Jun 2023 17:55:10 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2050B1C827F for ; Tue, 13 Jun 2023 21:55:10 +0000 (UTC) X-FDA: 80899080780.28.EE789D7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 614B3180015 for ; Tue, 13 Jun 2023 21:55:06 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HGt+JmBh; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686693306; 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=1PjQMG6Yu1qBPrMj044V/Nk+rlr/96uKkoV0wYpuazQ=; b=pDKXCgXlsv6GBulfWvFXAxYCcwQjwWilNPM3I8uWzwxLqUCdDqIjdWDNOVU6eLPrJxcg+K e4FH3a2G4nhhjaz3EiNem+Gcq4jqHmzRkQbVhRFI8uSdW714jXgFzooWknStht/+LCW4DA Viu9G2bJkb0yJbX97qqtuRUaqljpayM= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HGt+JmBh; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686693306; a=rsa-sha256; cv=none; b=m7/PtlI9Qb3f6fdCcPI0UOYBsTOaTiJ3f6+98wdULb8O2zDUjUwZ13gx1/AiX4pTvc2C4y dujB5wm8Er76l79wZW4OUp0BKFpPFLKc6LKu4ilcTPcdDrA5zP2h78KCqs+SEXNysTY4kn 8NRK5i8NlZZTRcpJoG6evHP0ftMqgS8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686693305; 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=1PjQMG6Yu1qBPrMj044V/Nk+rlr/96uKkoV0wYpuazQ=; b=HGt+JmBhmmBAaQJETxi7dPA1iwMREEIlVzKvx6FITpm8FwNcjyAS0HCOMZXXkKYfBwTS02 Vhe+4YceEwfymaiFl5XiRL1K8GIqPacibPF9ux6UfzzjojP0seRDR1CXbJ0aZCh0RU65yY YLjFPgzRzyxItxdbIghpJmAeXYeLips= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-39-3wnroJiJOTC1wvpPs_598w-1; Tue, 13 Jun 2023 17:54:57 -0400 X-MC-Unique: 3wnroJiJOTC1wvpPs_598w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8A1BE3C0CEF0; Tue, 13 Jun 2023 21:54:42 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id D29182166B25; Tue, 13 Jun 2023 21:54:39 +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_cleanup() to advance the head index MIME-Version: 1.0 Content-ID: <1193484.1686693279.1@warthog.procyon.org.uk> Date: Tue, 13 Jun 2023 22:54:39 +0100 Message-ID: <1193485.1686693279@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspam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kcBa4IGt+VKvV9+b/DpPLlI/RihjR05+LL7j/qbQiwVd36YZNeg+1ef+OHA4GSOgdjlrVHN6wZoPH108zgmF66c/9CUPwiIIRgGALw8AMWe0QYglI042vqYlBFUzgyxPIn6ii8DK6UMQ/+/vOyhCh3gqcwAIlRobFZG0ClQxD4qMj7UIK8OYRbdhMFSKe9g43JZ49Ey/RKB1o1/AkLzyBneGveDo7ts/TDpG85nUwpGAk37FVsK9S/3UNBWootOmrpEv9xDG0SfcW+TaKrPaavvJpyKl07i8IfpqIv+LiHkz3Tcp+V8Ft55JBYfoo/NoI31uzxvzszpNdBjdAEK9DY5gq9zruRP1yf5dHXEoJYfkCuY5EYcOTfZKxTPQMkmK0K2jzsDF3nyU1FE1oM6/nwQg4WXh3NBvOF8bZ7MpizH4fKgCAOSlAFYyoAnMBCemC9+ufuZu+VvFKjOprUHwash2pQrnARa7JxUgWJQNgHuYumjljIrEPL29mEofV8MOvpYu3bP1AJPtbzQDl1VX16B1nD7jd/iyVSq5ULzB1uf/pnkbNpN3pvjNvZZDDeXVHW83PzSPHnrTG4hknlrp5IjXM/FG756u+G7dL6FqyJo/R/WvzF+Et7adv4/umAg0U7y9Zg/CLUTL2ExUp5sX1DAWNQVMvmUZAAH+fkt/SLaruLze5b4rkvGg== 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_cleanup() to advance the head index into the list of pages past the pages it has released, as __blockdev_direct_IO() will call it twice if do_direct_IO() fails. The issue was causing: WARNING: CPU: 6 PID: 2220 at mm/gup.c:76 try_get_folio This can be triggered by setting up a clean pair of UDF filesystems on loopback devices and running the generic/451 xfstest with them as the scratch and test partitions. Something like the following: fallocate /mnt2/udf_scratch -l 1G fallocate /mnt2/udf_test -l 1G mknod /dev/lo0 b 7 0 mknod /dev/lo1 b 7 1 losetup lo0 /mnt2/udf_scratch losetup lo1 /mnt2/udf_test mkfs -t udf /dev/lo0 mkfs -t udf /dev/lo1 cd xfstests ./check generic/451 with xfstests configured by putting the following into local.config: export FSTYP=udf export DISABLE_UDF_TEST=1 export TEST_DEV=/dev/lo1 export TEST_DIR=/xfstest.test export SCRATCH_DEV=/dev/lo0 export SCRATCH_MNT=/xfstest.scratch 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 --- fs/direct-io.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/direct-io.c b/fs/direct-io.c index 0643f1bb4b59..2ceb378b93c0 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -459,6 +459,7 @@ static inline void dio_cleanup(struct dio *dio, struct dio_submit *sdio) if (dio->is_pinned) unpin_user_pages(dio->pages + sdio->head, sdio->tail - sdio->head); + sdio->head = sdio->tail; } /*