From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4932BC35671 for ; Sun, 23 Feb 2020 17:58:13 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1983720880; Sun, 23 Feb 2020 17:58:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.b="fMumaN0L"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="KqVRRKqo"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="PakxXawg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1983720880 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1j5vW8-0002PC-AX; Sun, 23 Feb 2020 17:58:12 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1j5vW6-0002Ow-NA for linux-f2fs-devel@lists.sourceforge.net; Sun, 23 Feb 2020 17:58:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=LL53eGqGjRhh2FS0FiyzWSm5OLgF8ml4hem9pzFTyEA=; b=fMumaN0L0b0m1h/CnDInWFNzts C8NB2nlYleSqTXSW3zCZC0r3EAZUxImWUKP6wDoXiKKBxE2ERbpq8ufwhe5VS9/eCcPxGzmwIJy9K PQ5pCWsrutX3KN1H6FCeScHgMBuifC8qVODgjvKyzewVx9Y4lnlSe+R77fQ5ulmGLGxM=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To :From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=LL53eGqGjRhh2FS0FiyzWSm5OLgF8ml4hem9pzFTyEA=; b=KqVRRKqoaEK4wpDliY2rv31irS Hpx5f4L1kUBEAkrK4FK5FM4H6yk0G853aENUtQr+TFZkHiHRXnr4SORpzthywe5wB3WfhpkRJNokx VpP0RH4z4ubGKb9GOct2fpSt7TsXbJUWxwIi9ei7c+tWeATC6c5ieltvRv1XAXhdT2Io=; Received: from userp2120.oracle.com ([156.151.31.85]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1j5vW4-00ERgv-NM for linux-f2fs-devel@lists.sourceforge.net; Sun, 23 Feb 2020 17:58:10 +0000 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01NHvWju073441; Sun, 23 Feb 2020 17:57:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=LL53eGqGjRhh2FS0FiyzWSm5OLgF8ml4hem9pzFTyEA=; b=PakxXawgs/LSVhmYsY1+zuFHltffRjwbw3lP6hwl72y2PLEa8jNl5Ujy9gt6xfZOb6Mz pZe861TUQ4w4vRL9H8BDN/Ft61yUxW8ZBT4mCp1Nsu1+ZVxqNgCaBMfkolgljQ/nzIEm VO3l937hvjq7rdJRQatg9AN9IDP9fTPQ6OaBJMyOSZbxjNXA0Pa3NCTlr7d5UixoLlJV YrAW+AhpE2AJpG3fsJITXVfY9m9jcm9agVJeDdzcJ59kdJlQYXV/vdxaxGBdHC43mQUa BqvSk6611lS95oLYQySLRzScVf7fgUh60vjQJvd694prMF7sLeHaJsUvpLosCClFBjqK OQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2yavxrbtp0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 Feb 2020 17:57:32 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01NHq2br019936; Sun, 23 Feb 2020 17:55:31 GMT Received: from pps.reinject (localhost [127.0.0.1]) by aserp3020.oracle.com with ESMTP id 2ybe3cnq93-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 23 Feb 2020 17:55:31 +0000 Received: from aserp3020.oracle.com (aserp3020.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 01NHtVwC036442; Sun, 23 Feb 2020 17:55:31 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2ybe3cnq8s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 Feb 2020 17:55:31 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 01NHtP55027269; Sun, 23 Feb 2020 17:55:25 GMT Received: from localhost (/10.159.228.17) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 09:55:25 -0800 Date: Sun, 23 Feb 2020 09:55:23 -0800 From: "Darrick J. Wong" To: Matthew Wilcox Message-ID: <20200223175523.GK9506@magnolia> References: <20200219210103.32400-1-willy@infradead.org> <20200219210103.32400-22-willy@infradead.org> <20200222004425.GG9506@magnolia> <20200222015435.GH24185@bombadil.infradead.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200222015435.GH24185@bombadil.infradead.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9540 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 suspectscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230148 X-Headers-End: 1j5vW4-00ERgv-NM Subject: Re: [f2fs-dev] [PATCH v7 21/24] iomap: Restructure iomap_readpages_actor X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, ocfs2-devel@oss.oracle.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-btrfs@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On Fri, Feb 21, 2020 at 05:54:35PM -0800, Matthew Wilcox wrote: > On Fri, Feb 21, 2020 at 04:44:25PM -0800, Darrick J. Wong wrote: > > On Wed, Feb 19, 2020 at 01:01:00PM -0800, Matthew Wilcox wrote: > > > From: "Matthew Wilcox (Oracle)" > > > > > > By putting the 'have we reached the end of the page' condition at the end > > > of the loop instead of the beginning, we can remove the 'submit the last > > > page' code from iomap_readpages(). Also check that iomap_readpage_actor() > > > didn't return 0, which would lead to an endless loop. > > > > > > Signed-off-by: Matthew Wilcox (Oracle) > > > --- > > > fs/iomap/buffered-io.c | 32 ++++++++++++++++++-------------- > > > 1 file changed, 18 insertions(+), 14 deletions(-) > > > > > > diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c > > > index cb3511eb152a..31899e6cb0f8 100644 > > > --- a/fs/iomap/buffered-io.c > > > +++ b/fs/iomap/buffered-io.c > > > @@ -400,15 +400,9 @@ iomap_readpages_actor(struct inode *inode, loff_t pos, loff_t length, > > > void *data, struct iomap *iomap, struct iomap *srcmap) > > > { > > > struct iomap_readpage_ctx *ctx = data; > > > - loff_t done, ret; > > > - > > > - for (done = 0; done < length; done += ret) { > > > - if (ctx->cur_page && offset_in_page(pos + done) == 0) { > > > - if (!ctx->cur_page_in_bio) > > > - unlock_page(ctx->cur_page); > > > - put_page(ctx->cur_page); > > > - ctx->cur_page = NULL; > > > - } > > > + loff_t ret, done = 0; > > > + > > > + while (done < length) { > > > if (!ctx->cur_page) { > > > ctx->cur_page = iomap_next_page(inode, ctx->pages, > > > pos, length, &done); > > > @@ -418,6 +412,20 @@ iomap_readpages_actor(struct inode *inode, loff_t pos, loff_t length, > > > } > > > ret = iomap_readpage_actor(inode, pos + done, length - done, > > > ctx, iomap, srcmap); > > > + done += ret; > > > + > > > + /* Keep working on a partial page */ > > > + if (ret && offset_in_page(pos + done)) > > > + continue; > > > + > > > + if (!ctx->cur_page_in_bio) > > > + unlock_page(ctx->cur_page); > > > + put_page(ctx->cur_page); > > > + ctx->cur_page = NULL; > > > + > > > + /* Don't loop forever if we made no progress */ > > > + if (WARN_ON(!ret)) > > > + break; > > > } > > > > > > return done; > > > @@ -451,11 +459,7 @@ iomap_readpages(struct address_space *mapping, struct list_head *pages, > > > done: > > > if (ctx.bio) > > > submit_bio(ctx.bio); > > > - if (ctx.cur_page) { > > > - if (!ctx.cur_page_in_bio) > > > - unlock_page(ctx.cur_page); > > > - put_page(ctx.cur_page); > > > - } > > > + BUG_ON(ctx.cur_page); > > > > Whoah, is the system totally unrecoverably hosed at this point? > > > > I get that this /shouldn't/ happen, but should we somehow end up with a > > page here, are we unable either to release it or even just leak it? I'd > > have thought a WARN_ON would be just fine here. > > If we do find a page here, we don't actually know what to do with it. > It might be (currently) locked, it might have the wrong refcount. > Whatever is going on, it's probably better that we stop everything right > here rather than allow things to go further and possibly present bad > data to the application. I mean, we could even be leaking the previous > contents of this page to userspace. Or maybe the future contents of a > page which shouldn't be in the page cache any more, but userspace gets > a mapping to it. > > I'm not enthusiastic about putting in some code here to try to handle > a "can't happen" case, since it's never going to be tested, and might > end up causing more problems than it tries to solve. Let's just stop. Seeing how Linus (and others like myself) are a bit allergic to BUG these days, could you add the first paragraph of the above justification as a comment adjacent to the BUG_ON(), please? :) --D _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel