Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6188341rwl; Wed, 22 Mar 2023 07:35:39 -0700 (PDT) X-Google-Smtp-Source: AK7set9stveLtfx3R3W3ChxQ6DkL71ArrnVPCGTvgRvJPyrOiowGyESfhYyj9HtSDrIShgNvlOCH X-Received: by 2002:a17:906:2344:b0:931:bc4a:ce08 with SMTP id m4-20020a170906234400b00931bc4ace08mr7591883eja.36.1679495739207; Wed, 22 Mar 2023 07:35:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679495739; cv=none; d=google.com; s=arc-20160816; b=K/qMqmpJxZMuCghX3sw14YaidU70/X1hN3D0OM0W+dl1S+d+56ZdaXl1ECdySFQmAr RmAu4FSP1LdAzZ1NhQXHu46osGY2PjZp/T+IF1qNaIDR6Ks3BuYAAoIK3QD4ZqVktFoj zmgqt5CMB/yDXqvpcMNEXSpctkve8/HdVPp+VZlzdbTn/cyC2OyeE3tgK8ZTcJouueon JWObDq95jIayPdey3Xjlk/a79J7bJNyaVc1GfMT9WRo1LWtxtpTP1Pc+uo0IM4jL64hY oHEpId0K2wnjFqElslrao5sD+KxxiBUt8yBewU2zHmQ3EPPeEHsWsExjcrpIFgVhIM0S SHOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3I8+EPoj9s30M6BN+/MyaicBmCloUwGfehVdB0NlrWY=; b=Yo3MwNP4YIsbdDdznKiKVLysWXGwFmbupc9KDCGx9SQLzI8x0BUfJePk2mGTsNRDWD Crdc5DMxm4mIdRjLVelFZzWu7fQtroFpwh8Sg0FvPxlyaUeen0VKAiPDVJz51WDoK5He YnfFEAIP3TuWiXtogU2tnt4S6Y1kEEhQ9ArYtMghN4Lg0gN6yUVuH5Pcb0/vPADJFPgd ODQp5/TQTxnGZWswWBs6YVeIgdOeIXWzeNZmPnv51W6uM9NvPNjzMESmKAb78fTE0jt3 97T6PuDq628yCTKcNNIK7bkEHdfU7lmXu92wvw3uVI69hbWD1RCaBFlGj+fYJVhfmGEN i5wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ZJGeiZAp; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gt42-20020a1709072daa00b0093525a7ec36si2123329ejc.106.2023.03.22.07.35.15; Wed, 22 Mar 2023 07:35:39 -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=@infradead.org header.s=casper.20170209 header.b=ZJGeiZAp; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231181AbjCVOUI (ORCPT + 99 others); Wed, 22 Mar 2023 10:20:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231522AbjCVOTa (ORCPT ); Wed, 22 Mar 2023 10:19:30 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A7FA64B19; Wed, 22 Mar 2023 07:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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; bh=3I8+EPoj9s30M6BN+/MyaicBmCloUwGfehVdB0NlrWY=; b=ZJGeiZApYD0ixCPvU2hO6qnVJ4 6hWhoXL2A5VSGpA/HCIUwp17RyNbGB6HwspMKQJPNDDh20N6hrOT4ozwKMOIDvzXcfPIOJMsyrkjM Wt3MkZhdFVmqHdJ1lWxT4eXdCx110KJnbOyzl/iPxY+bn6XLfmHsjea6m1l7KLD8f7dY4YSKeAek+ umzj/t7YDT4ethQO/0993oVhI/sJvKfiV78LOHHrY6cakTRl21XfDTdT4E8DXsRynHOO+boyXDbX4 Mw0WKEvPgsFeoFkI87C2PhNCXHmae9LHyCnHR6r3HoUft2dxDNv/BZgb6iE5h3T4igDN8xhR2ML9O rV2aBaYQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pezIz-0034XG-FS; Wed, 22 Mar 2023 14:19:09 +0000 Date: Wed, 22 Mar 2023 14:19:09 +0000 From: Matthew Wilcox To: Pankaj Raghav Cc: senozhatsky@chromium.org, viro@zeniv.linux.org.uk, axboe@kernel.dk, brauner@kernel.org, akpm@linux-foundation.org, minchan@kernel.org, hubcap@omnibond.com, martin@omnibond.com, mcgrof@kernel.org, devel@lists.orangefs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, gost.dev@samsung.com Subject: Re: [RFC v2 4/5] mpage: use folios in bio end_io handler Message-ID: References: <20230322135013.197076-1-p.raghav@samsung.com> <20230322135013.197076-5-p.raghav@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230322135013.197076-5-p.raghav@samsung.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE, URIBL_BLOCKED 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 On Wed, Mar 22, 2023 at 02:50:12PM +0100, Pankaj Raghav wrote: > static void mpage_write_end_io(struct bio *bio) > { > - struct bio_vec *bv; > - struct bvec_iter_all iter_all; > + struct folio_iter fi; > + int err = blk_status_to_errno(bio->bi_status); > > - bio_for_each_segment_all(bv, bio, iter_all) { > - struct page *page = bv->bv_page; > - page_endio(page, REQ_OP_WRITE, > - blk_status_to_errno(bio->bi_status)); > + bio_for_each_folio_all(fi, bio) { > + struct folio *folio = fi.folio; > + > + if (err) { > + struct address_space *mapping; > + > + folio_set_error(folio); > + mapping = folio_mapping(folio); > + if (mapping) > + mapping_set_error(mapping, err); The folio is known to belong to this mapping and can't be truncated while under writeback. So it's safe to do: folio_set_error(folio); mapping_set_error(folio->mapping, err); I'm not even sure I'd bother to pull folio out of the fi. bio_for_each_folio_all(fi, bio) { if (err) { folio_set_error(fi.folio); mapping_set_error(fi.folio->mapping, err); } folio_end_writeback(fi.folio); }