Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3661839rwd; Mon, 22 May 2023 18:17:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7etNz0D80/ItWkdII5yyRspzhyrP0WQJhXkRIBtu82Z8MhECTD5qRe/iy5cPOunjoRaNzC X-Received: by 2002:a05:6a00:1389:b0:623:8592:75c4 with SMTP id t9-20020a056a00138900b00623859275c4mr18879793pfg.29.1684804654192; Mon, 22 May 2023 18:17:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684804654; cv=none; d=google.com; s=arc-20160816; b=rrTtSbJdPxtfhw8vLi19aIuBHuvFdn5ieZ7ZhzgIlQnj4emq1ddROAUdAE6iNGLcFf fhRQm3vcZZ7UpLn71eatHwzOCbz+OCRWFfd3Lrvil8PPoHyHDe9H8eBruFFOg2EtIB+V Dqr7HKt/JgsXxWfA8rmi0ZllRLd0WJEb7thv5z+/qqcUe+l95j1SC77uujS5d2UKBeZp LwwEPE73DWyf1vmXL3zAF2ADZWH2woDYSAjmwnlAvH+ZWI/9l0mE0Yw0WUB6g8ko1FH9 hCWH6liKrNF1ZvUIVPhOBf7lsso+p1j0/bv20y6Y+TrGYiXIJwuon0hOLOKOZtEj0tQJ bp9g== 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=2ej59/T/mMH9enC8u09fLhXt1y6kmoqAgjeImlgOrUg=; b=yqpvGTN6KynawWIbaMEXB2W8nIl1OKVc0f+1sSccabX7BfrZ2jfJaEg/hGWigYQx7H RRUFLEDu1y52mUkuUySvZlmqrmmrAMs0PMhkVKeqY37c6/S3Jn63JFGUOyuGplAg02RY D+Itrg3gzcRmn8WUmgByd8xF7FwlOToiEcbnnjd9Rh7LHoOEUxtDpThKgG9S0tUR8S55 q75phMs+wUjWDHHdPYVfLg7rOPRp3BlEHzNOXOshfa8pM+u/ruKVZJY2b47HID0uo7Wc /nCHwY9A7qCBj2qmfgGP1ZLrZDJRocuwradJFEEqchA2CeP5VfviRFIp754sT1J1Y8WU hbww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B7HpXX0w; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v8-20020a63bf08000000b0050be915cebcsi5476307pgf.878.2023.05.22.18.17.15; Mon, 22 May 2023 18:17:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=@kernel.org header.s=k20201202 header.b=B7HpXX0w; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229992AbjEWBGm (ORCPT + 99 others); Mon, 22 May 2023 21:06:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235317AbjEWBGa (ORCPT ); Mon, 22 May 2023 21:06:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A0EF97; Mon, 22 May 2023 18:06:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9AF6862D60; Tue, 23 May 2023 01:06:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5A8CC433EF; Tue, 23 May 2023 01:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684803988; bh=h4E1J1AKDKMVuSfgh/Fow3jhm+kdCps73if0IpfmP5M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=B7HpXX0w8KazRHI9JNKr78xlTtBd/1Nh3mIbBpnJMweSFzrOqUOt7vzqrdBkuR6da VpRkQ0B9OD3Lv3dmDJT2f5qM2ZiJ/Kyn1Lq2WhZw69nlhNmf+f3buLVFiU8DbZvv7F UZtgkITdSnN+xy5B/gLJIpuTpnarir62FwLnGDW1sBWKc+tVEtQAX97dY0y9SoCq5l zRaQqJlwCLVdQFoTj4OZUDBxuXLoYm1YXms74/n+fosCJ8AqmV5X1QCSlaFFWigY5U 89PsbK7iFzdJ2y1/246qlBtpGb/jm+WXxujyUQIlwqewLNfDNz7C/tJF/7+ceO+zUq U9+tx48Oj/N1Q== Date: Mon, 22 May 2023 18:06:27 -0700 From: "Darrick J. Wong" To: Christoph Hellwig Cc: Matthew Wilcox , Jens Axboe , Xiubo Li , Ilya Dryomov , Alexander Viro , Christian Brauner , Theodore Ts'o , Jaegeuk Kim , Chao Yu , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Damien Le Moal , Andrew Morton , linux-block@vger.kernel.org, ceph-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, "open list:F2FS FILE SYSTEM" , cluster-devel@redhat.com, linux-xfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 08/13] iomap: assign current->backing_dev_info in iomap_file_buffered_write Message-ID: <20230523010627.GD11598@frogsfrogsfrogs> References: <20230519093521.133226-1-hch@lst.de> <20230519093521.133226-9-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230519093521.133226-9-hch@lst.de> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,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: X-Mailing-List: linux-ext4@vger.kernel.org On Fri, May 19, 2023 at 11:35:16AM +0200, Christoph Hellwig wrote: > Move the assignment to current->backing_dev_info from the callers into > iomap_file_buffered_write to reduce boiler plate code and reduce the > scope to just around the page dirtying loop. > > Note that zonefs was missing this assignment before. I'm still wondering (a) what the hell current->backing_dev_info is for, and (b) if we need it around the iomap_unshare operation. $ git grep current..backing_dev_info fs/btrfs/file.c:1148: current->backing_dev_info = inode_to_bdi(inode); fs/btrfs/file.c:1169: current->backing_dev_info = NULL; fs/btrfs/file.c:1692: current->backing_dev_info = NULL; fs/ceph/file.c:1795: current->backing_dev_info = inode_to_bdi(inode); fs/ceph/file.c:1943: current->backing_dev_info = NULL; fs/ext4/file.c:288: current->backing_dev_info = inode_to_bdi(inode); fs/ext4/file.c:290: current->backing_dev_info = NULL; fs/f2fs/file.c:4520: current->backing_dev_info = inode_to_bdi(inode); fs/f2fs/file.c:4522: current->backing_dev_info = NULL; fs/fuse/file.c:1366: current->backing_dev_info = inode_to_bdi(inode); fs/fuse/file.c:1412: current->backing_dev_info = NULL; fs/gfs2/file.c:1044: current->backing_dev_info = inode_to_bdi(inode); fs/gfs2/file.c:1048: current->backing_dev_info = NULL; fs/nfs/file.c:652: current->backing_dev_info = inode_to_bdi(inode); fs/nfs/file.c:654: current->backing_dev_info = NULL; fs/ntfs/file.c:1914: current->backing_dev_info = inode_to_bdi(vi); fs/ntfs/file.c:1918: current->backing_dev_info = NULL; fs/ntfs3/file.c:823: current->backing_dev_info = inode_to_bdi(inode); fs/ntfs3/file.c:996: current->backing_dev_info = NULL; fs/xfs/xfs_file.c:721: current->backing_dev_info = inode_to_bdi(inode); fs/xfs/xfs_file.c:756: current->backing_dev_info = NULL; mm/filemap.c:3995: current->backing_dev_info = inode_to_bdi(inode); mm/filemap.c:4056: current->backing_dev_info = NULL; AFAICT nobody uses it at all? Unless there's some bizarre user that isn't extracting it from @current? Oh, hey, new question (c) isn't this set incorrectly for xfs realtime files? --D > Signed-off-by: Christoph Hellwig > --- > fs/gfs2/file.c | 3 --- > fs/iomap/buffered-io.c | 3 +++ > fs/xfs/xfs_file.c | 5 ----- > 3 files changed, 3 insertions(+), 8 deletions(-) > > diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c > index 499ef174dec138..261897fcfbc495 100644 > --- a/fs/gfs2/file.c > +++ b/fs/gfs2/file.c > @@ -25,7 +25,6 @@ > #include > #include > #include > -#include > #include > > #include "gfs2.h" > @@ -1041,11 +1040,9 @@ static ssize_t gfs2_file_buffered_write(struct kiocb *iocb, > goto out_unlock; > } > > - current->backing_dev_info = inode_to_bdi(inode); > pagefault_disable(); > ret = iomap_file_buffered_write(iocb, from, &gfs2_iomap_ops); > pagefault_enable(); > - current->backing_dev_info = NULL; > if (ret > 0) > written += ret; > > diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c > index 550525a525c45c..b2779bd1f10611 100644 > --- a/fs/iomap/buffered-io.c > +++ b/fs/iomap/buffered-io.c > @@ -3,6 +3,7 @@ > * Copyright (C) 2010 Red Hat, Inc. > * Copyright (C) 2016-2019 Christoph Hellwig. > */ > +#include > #include > #include > #include > @@ -869,8 +870,10 @@ iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *i, > if (iocb->ki_flags & IOCB_NOWAIT) > iter.flags |= IOMAP_NOWAIT; > > + current->backing_dev_info = inode_to_bdi(iter.inode); > while ((ret = iomap_iter(&iter, ops)) > 0) > iter.processed = iomap_write_iter(&iter, i); > + current->backing_dev_info = NULL; > > if (unlikely(ret < 0)) > return ret; > diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c > index bfba10e0b0f3c2..98d763cc3b114c 100644 > --- a/fs/xfs/xfs_file.c > +++ b/fs/xfs/xfs_file.c > @@ -27,7 +27,6 @@ > > #include > #include > -#include > #include > #include > #include > @@ -717,9 +716,6 @@ xfs_file_buffered_write( > if (ret) > goto out; > > - /* We can write back this queue in page reclaim */ > - current->backing_dev_info = inode_to_bdi(inode); > - > trace_xfs_file_buffered_write(iocb, from); > ret = iomap_file_buffered_write(iocb, from, > &xfs_buffered_write_iomap_ops); > @@ -751,7 +747,6 @@ xfs_file_buffered_write( > goto write_retry; > } > > - current->backing_dev_info = NULL; > out: > if (iolock) > xfs_iunlock(ip, iolock); > -- > 2.39.2 >