Message ID | 431929.1686588681@warthog.procyon.org.uk |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp18079vqr; Mon, 12 Jun 2023 10:18:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5fbwITA3TqMfHasRdZlnjUx5eWSu/Sccf1je+6Q8FlvNdq3F1GX2THoqK6UyY+bEwpYg0D X-Received: by 2002:a17:902:9b8c:b0:1b0:378e:2768 with SMTP id y12-20020a1709029b8c00b001b0378e2768mr5674591plp.7.1686590302455; Mon, 12 Jun 2023 10:18:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686590302; cv=none; d=google.com; s=arc-20160816; b=yxKVB6lh0CYlmirJml38ZCdqrk0CAUgf8SJYk8m5mj0LaJJLbik9cVQKqJkqGt+6mn uw+YY2MBkr+6hDJlAP312CuusftWZr9Z0UoXfxgjgM1n2zePsJzg/BIlLT9o1lXrqlLF nhLlAxxD17FlQPZ7HfDWoiRK39jojQaQUjeN5Xgp7srew3fEtPJ3j616MdrNDdkvWxjN ySgUXjHWxCbCyemA5HKBBneMC9UdwuhVDWrJpUvHNWgWjG3Z6zrPcDDtuVoWIJY8MA/8 ACJV8H7OOHvscWj3XQL/xclnQO9XnuW7FdgDmmeKBRsBQFTmCOY65cx7k9spvbLuxkqR FilQ== 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=KUdFKCdBRtXD70pPEw8UKzishmgLHxiTnsybrG/P/8Q=; b=FRuii4t7LaM+OZkibx8AX3UPy6XlyJOFkvWAS6UkFGNC3Fk02olNvhxgsVA/e/XvV3 gjK3LfIS9orr2/nHXbfXORHjln8m1fIswDSJkAtDscdu+/Wh7ndAhp4nuWk/imh1tiDP GRLeI8U1xg4jO52pC5bF6IkU36MY9vnuNXWqXdi/suPFwY0+QNkcV64iAoyDeBIS4PVP hI7xeI5aAwTuUIGguS2fDEriJAKjTZu7GTJVwD18X1D71HeyX2UKvAK+9Z2QXx5Iheop 53CdybmgJlv9b+73Ysg3w1j+xPYLftBWOWy7L2Ghq0o6hdBnAp4P13VNSRwvd7QTaVF/ O0KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LyT4Bx8H; 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 t5-20020a17090340c500b001a65688c863si7403001pld.56.2023.06.12.10.17.56; Mon, 12 Jun 2023 10:18:22 -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=LyT4Bx8H; 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 S237180AbjFLQwY (ORCPT <rfc822;rust.linux@gmail.com> + 99 others); Mon, 12 Jun 2023 12:52:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233617AbjFLQwR (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 12 Jun 2023 12:52:17 -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 AD300E6F for <linux-kernel@vger.kernel.org>; Mon, 12 Jun 2023 09:51:30 -0700 (PDT) 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 <dhowells@redhat.com> To: Jens Axboe <axboe@kernel.dk>, David Hildenbrand <david@redhat.com>, kernel test robot <oliver.sang@intel.com> cc: dhowells@redhat.com, Christoph Hellwig <hch@infradead.org>, Andrew Morton <akpm@linux-foundation.org>, Al Viro <viro@zeniv.linux.org.uk>, Matthew Wilcox <willy@infradead.org>, Jan Kara <jack@suse.cz>, Jeff Layton <jlayton@kernel.org>, Jason Gunthorpe <jgg@nvidia.com>, Logan Gunthorpe <logang@deltatee.com>, Hillf Danton <hdanton@sina.com>, Christian Brauner <brauner@kernel.org>, Lorenzo Stoakes <lstoakes@gmail.com>, 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-Type: text/plain; charset="us-ascii" Content-ID: <431928.1686588681.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable 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-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=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768518113192334131?= X-GMAIL-MSGID: =?utf-8?q?1768518113192334131?= |
Series |
block: Fix dio_bio_alloc() to set BIO_PAGE_PINNED
|
|
Commit Message
David Howells
June 12, 2023, 4:51 p.m. UTC
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 <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202306120931.a9606b88-oliver.sang@intel.com
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Christoph Hellwig <hch@infradead.org>
cc: David Hildenbrand <david@redhat.com>
cc: Andrew Morton <akpm@linux-foundation.org>
cc: Jens Axboe <axboe@kernel.dk>
cc: Al Viro <viro@zeniv.linux.org.uk>
cc: Matthew Wilcox <willy@infradead.org>
cc: Jan Kara <jack@suse.cz>
cc: Jeff Layton <jlayton@kernel.org>
cc: Jason Gunthorpe <jgg@nvidia.com>
cc: Logan Gunthorpe <logang@deltatee.com>
cc: Hillf Danton <hdanton@sina.com>
cc: Christian Brauner <brauner@kernel.org>
cc: Linus Torvalds <torvalds@linux-foundation.org>
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(-)
Comments
On 12.06.23 18:51, David Howells wrote: > > 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 <oliver.sang@intel.com> > Closes: https://lore.kernel.org/oe-lkp/202306120931.a9606b88-oliver.sang@intel.com > Signed-off-by: David Howells <dhowells@redhat.com> > cc: Christoph Hellwig <hch@infradead.org> > cc: David Hildenbrand <david@redhat.com> > cc: Andrew Morton <akpm@linux-foundation.org> > cc: Jens Axboe <axboe@kernel.dk> > cc: Al Viro <viro@zeniv.linux.org.uk> > cc: Matthew Wilcox <willy@infradead.org> > cc: Jan Kara <jack@suse.cz> > cc: Jeff Layton <jlayton@kernel.org> > cc: Jason Gunthorpe <jgg@nvidia.com> > cc: Logan Gunthorpe <logang@deltatee.com> > cc: Hillf Danton <hdanton@sina.com> > cc: Christian Brauner <brauner@kernel.org> > cc: Linus Torvalds <torvalds@linux-foundation.org> > 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 */ Does the comment still hold? > - 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; > } >
David Hildenbrand <david@redhat.com> wrote: > > /* for now require references for all pages */ > > Does the comment still hold? Actually, no. David
Okay, it isn't this. The problem appears to be that __blockdev_direct_IO() calls dio_cleanup() twice if do_direct_IO() fails. David
static inline void dio_cleanup(struct dio *dio, struct dio_submit *sdio) { - while (sdio->head < sdio->tail) - put_page(dio->pages[sdio->head++]); + if (dio->is_pinned) + unpin_user_pages(dio->pages + sdio->head, + sdio->tail - sdio->head); } /* Meh. It's obvious. Need to advance head. David
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; }