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: 107578 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp846937vqr; Tue, 13 Jun 2023 14:59:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5fCxgF6niWpYNJEwkUvTozFqWgZjmv+7PqH+bFoWdt4wZ44yfBhqLPOUQ6PXhchvnCDMq9 X-Received: by 2002:a17:906:6a08:b0:978:adec:4ad1 with SMTP id qw8-20020a1709066a0800b00978adec4ad1mr13581480ejc.32.1686693584716; Tue, 13 Jun 2023 14:59:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686693584; cv=none; d=google.com; s=arc-20160816; b=DdQyWZfKzXyV38QqbetTWVUIAYwT5LQ9IJh0HlJXe+JRfJDssb0FPBaifmFrbEr7hJ ygpxRqHtiBouA23ll/KUBGUpsSgg0enDH2ZypR2FlXU6u1Eqep6mGlf1q9cCQSb1xy/S JqVrP0UOMvTHWOTdHOBNiDMYXsTTyJE0igrJfLlWGFVbnJh1OMSHtEBLBmgJN8LtjWEc beuFawjr78twD5oXexcUtHYdh5rw8H1+/cfb5vof2ttEaFTRqMtSl6Tek1Y5tBqtak3z O6L2xT99wg8f2i5kTyJ7h3RGZr/E4D9EJtSL5mQB+T/8ScDslRR3zqvstsTxsP4RBnoK kMkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-transfer-encoding :content-id:mime-version:subject:cc:to:from:organization :dkim-signature; bh=1PjQMG6Yu1qBPrMj044V/Nk+rlr/96uKkoV0wYpuazQ=; b=RI5dwW43tqLyOlJISwa4jTahMxkRJCF2k/IoTIUDohQexTSe7yHiQEgdIr3B+GtiQQ Fad+nu8EKlJR1k7lPYmL9DqWNMxdFyAN2hTCASJDfNzFEYEsUrQqVadxOBp31rpgvbFu SWPUik8rba+7B6RMeQMNNL1wTVBlJLCs6ZLF91FFRpovQkvsHzEwoQIRLGiCBIL4ihJA Jv0DJTtskxtlkmQww07XxkkW8dyAGCOzdQqhyMZqXETmrOQjJkDlPwZgyJTm5tAFVZGo 1WSnBhjci99DuR+qvtFZyrJ48JZW3LUkt9pKL/MS8OBuVGQ8dI5+3vHbGKVaKsjtdUIg 4eKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HGt+JmBh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l14-20020a170906414e00b0094effaaa050si6968063ejk.50.2023.06.13.14.59.19; Tue, 13 Jun 2023 14:59:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HGt+JmBh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233925AbjFMV4p (ORCPT + 99 others); Tue, 13 Jun 2023 17:56:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234073AbjFMV4K (ORCPT ); Tue, 13 Jun 2023 17:56:10 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DA6B1FDB for ; Tue, 13 Jun 2023 14:55:06 -0700 (PDT) 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768626412403119172?= X-GMAIL-MSGID: =?utf-8?q?1768626412403119172?= 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; } /*