Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1833523rwd; Tue, 13 Jun 2023 15:10:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5RX4CFdBz4+NZNXr751knyGpNrmDnjW8Xv67mjdggD4hGXqPBVtKbTZeiQzy4YKR6oUHN9 X-Received: by 2002:a05:6808:8c:b0:39a:bbd4:bab with SMTP id s12-20020a056808008c00b0039abbd40babmr9105020oic.31.1686694207384; Tue, 13 Jun 2023 15:10:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686694207; cv=none; d=google.com; s=arc-20160816; b=hc+NBNDkynmsyOqFKAZDvTXKraF3vlYwIZrILahXNLux5DKkJzMvDIS1SflmSxLrSC w/W5p7L4QgoGnribY1Ho1qlIZpOZz+YHpTcY5yJus+lwfF4IPYf8SoTcsRoGzaGNPPTS eKnYuo7fwYljJE5K66QpZNce7+8uqrDOPJ1hxSO3HkTgkW8hm0GScJesfg69Jz6J+e4r bFqUiaOfk5ymuNEgHA+n7X71hMVEa90SiN9EbpN8D9h9xr7ZmwUIr6To4efsygLqd2r/ +4u/pNl1qcssafWLxrFHqagwIpTOGGBfG7IoABieSh4DZk1X9NRM3ULsn9H1U5AsvNQD LBwA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s14-20020a17090a13ce00b0025c0f6c60efsi24171pjf.169.2023.06.13.15.09.53; Tue, 13 Jun 2023 15:10:07 -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 S232951AbjFMV4o (ORCPT + 99 others); Tue, 13 Jun 2023 17:56:44 -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-Type: text/plain; charset="us-ascii" Content-ID: <1193484.1686693279.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable 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 = Fix dio_bio_cleanup() to advance the head index into the list of pages pas= t 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=3Dudf export DISABLE_UDF_TEST=3D1 export TEST_DEV=3D/dev/lo1 export TEST_DIR=3D/xfstest.test export SCRATCH_DEV=3D/dev/lo0 export SCRATCH_MNT=3D/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@i= ntel.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 | 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 =3D sdio->tail; } = /*