From patchwork Fri May 19 09:35:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13248019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1F34C77B75 for ; Fri, 19 May 2023 09:35:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A963A900003; Fri, 19 May 2023 05:35:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A4577900004; Fri, 19 May 2023 05:35:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 90D6A900003; Fri, 19 May 2023 05:35:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 63AA3900004 for ; Fri, 19 May 2023 05:35:53 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2EABD1208C2 for ; Fri, 19 May 2023 09:35:53 +0000 (UTC) X-FDA: 80806497786.23.EE05121 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf07.hostedemail.com (Postfix) with ESMTP id 0C0C340013 for ; Fri, 19 May 2023 09:35:50 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=M6Kzmetz; dmarc=none; spf=none (imf07.hostedemail.com: domain of BATV+aecf67361b95543ec79f+7208+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aecf67361b95543ec79f+7208+infradead.org+hch@bombadil.srs.infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684488951; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6ol1bWODvCYTDT1JUgKKn9Fh7sNo8e9dyRg15aWfO9s=; b=Xcogsi4X1cLJPyjJQ7J5TZkUc4b0Evvl8t08JWKdgS4AL1kDEUJrI9YD4TLR7Xw9l8JZCI cDULZQq0HD1Etw/i/o2NCxXXwtS8oEqZQBI+bzWWNgW+xzURGgmi8fMaUO+JNs/Hq7L2ZH 1ZwFRO15Yeg1aZFQmoUEcOAyctcuNrI= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=M6Kzmetz; dmarc=none; spf=none (imf07.hostedemail.com: domain of BATV+aecf67361b95543ec79f+7208+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aecf67361b95543ec79f+7208+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684488951; a=rsa-sha256; cv=none; b=n2SYzSvd7c45C4NAY4abtncpg0EhtI0VeQpZLJB4HbIyuNgtjE2Gskc2j9eqdWEVolPLR9 b9Nbp/bzzRANb9tgZB0o+gVaGKA76LqwXqS9iR1cg3vTQ4Dj2Psf/tAnyjoHYgli9FlpzM n1Xhw5L/N2IVP3WdzLPbLvITN/ejPo4= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=6ol1bWODvCYTDT1JUgKKn9Fh7sNo8e9dyRg15aWfO9s=; b=M6KzmetzkAeuS/VLc0Lh9JjJju Ru7ZWS27kADd2VtwycBozYnipzuMCirIKKvprX9mPjk8FvigFdIjN4M/xtUGuo008+0WHzo3WfJO3 EWdbDmUJHxpyHqFvevzzdoF8sY4ioA/FmCmhyHPkTSVBFbLUMUzg40a4nDIY0CgVciRjpOyZAAYL6 xkhg/yyrk3LagyAARJhct/1trEUwML73oIOqKl2Q1BZS5BLz1DLbgF0IsqLaC9nklXzoY22/+vvE8 6CgJvHjCSdFdTeTp+UnCpdHK3HMDcG/2uwD5g8SjDrtquin8RrPGVFwqC+Dwf8e+kLQB4xAFRANP0 98GWXd4g==; Received: from [2001:4bb8:188:3dd5:e8d0:68bb:e5be:210a] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1pzwWL-00FjdO-2V; Fri, 19 May 2023 09:35:34 +0000 From: Christoph Hellwig To: Matthew Wilcox Cc: Jens Axboe , Xiubo Li , Ilya Dryomov , Alexander Viro , Christian Brauner , "Theodore Ts'o" , Jaegeuk Kim , Chao Yu , Miklos Szeredi , Andreas Gruenbacher , "Darrick J. Wong" , 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, linux-f2fs-devel@lists.sourceforge.net (open list:F2FS FILE SYSTEM), cluster-devel@redhat.com, linux-xfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 03/13] filemap: assign current->backing_dev_info in generic_perform_write Date: Fri, 19 May 2023 11:35:11 +0200 Message-Id: <20230519093521.133226-4-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230519093521.133226-1-hch@lst.de> References: <20230519093521.133226-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0C0C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SDRj8tp50stf3+EX5qijpmEgB8WmltWH2RMBqbH9xTzBomK6c+pdqctXpNwKxqY9qFNDhEwMtr4S3OYC1gFkQzNNFr+xE3FWtNI2STYSSlRdWwdf4UDaeZjmMc0OcVU+Abr9e3rN881YU/z/9IU4VhO0EUhXG5wUMkmhC7jmko0Npbr9c8ySQKjyE+ufOrY0kPUceG3u7Jz3k4/+FuJ5Tc2utLaFhEDXPFIe7r94JVlA3h7CXayKfoX448Yh/cpuecNY/Fzau9ViWrfKqd05CTlBpb8xsTJiDu0aZ0uJ5wT+A75MfNfAI6y7LgMRDN75iW9mHjJuuzNQYvCOkha/2HcFDp/TdSVhTnu+jAb8UJrHoWPmKBzW/sFCZftjxGSqLKvHrQ6vcuFlkNk6zyKoaLKGOGkFJ3V5F4BkJrsL/w1V2OGCX0N7LjYuxjyL4lhNk3w7BD/dxCpaBFLKiZ0Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Move the assignment to current->backing_dev_info from the callers into generic_perform_write to reduce boiler plate code and reduce the scope to just around the page dirtying loop. Signed-off-by: Christoph Hellwig Reviewed-by: Damien Le Moal Reviewed-by: Xiubo Li --- fs/ceph/file.c | 4 ---- fs/ext4/file.c | 3 --- fs/f2fs/file.c | 2 -- fs/nfs/file.c | 5 +---- mm/filemap.c | 2 ++ 5 files changed, 3 insertions(+), 13 deletions(-) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index feeb9882ef635a..767f4dfe7def64 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -1791,9 +1791,6 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from) else ceph_start_io_write(inode); - /* We can write back this queue in page reclaim */ - current->backing_dev_info = inode_to_bdi(inode); - if (iocb->ki_flags & IOCB_APPEND) { err = ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE, false); if (err < 0) @@ -1938,7 +1935,6 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from) ceph_end_io_write(inode); out_unlocked: ceph_free_cap_flush(prealloc_cf); - current->backing_dev_info = NULL; return written ? written : err; } diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 50824831d31def..3cb83a3e2e4a2a 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -29,7 +29,6 @@ #include #include #include -#include #include "ext4.h" #include "ext4_jbd2.h" #include "xattr.h" @@ -285,9 +284,7 @@ static ssize_t ext4_buffered_write_iter(struct kiocb *iocb, if (ret <= 0) goto out; - current->backing_dev_info = inode_to_bdi(inode); ret = generic_perform_write(iocb, from); - current->backing_dev_info = NULL; out: inode_unlock(inode); diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 9e3855e43a7a63..7134fe8bd008cb 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -4517,9 +4517,7 @@ static ssize_t f2fs_buffered_write_iter(struct kiocb *iocb, if (iocb->ki_flags & IOCB_NOWAIT) return -EOPNOTSUPP; - current->backing_dev_info = inode_to_bdi(inode); ret = generic_perform_write(iocb, from); - current->backing_dev_info = NULL; if (ret > 0) { f2fs_update_iostat(F2FS_I_SB(inode), inode, diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 3cc87ae8473356..e8bb4c48a3210a 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -648,11 +648,8 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from) since = filemap_sample_wb_err(file->f_mapping); nfs_start_io_write(inode); result = generic_write_checks(iocb, from); - if (result > 0) { - current->backing_dev_info = inode_to_bdi(inode); + if (result > 0) result = generic_perform_write(iocb, from); - current->backing_dev_info = NULL; - } nfs_end_io_write(inode); if (result <= 0) goto out; diff --git a/mm/filemap.c b/mm/filemap.c index 4d0ec2fa1c7070..bf693ad1da1ece 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3892,6 +3892,7 @@ ssize_t generic_perform_write(struct kiocb *iocb, struct iov_iter *i) long status = 0; ssize_t written = 0; + current->backing_dev_info = inode_to_bdi(mapping->host); do { struct page *page; unsigned long offset; /* Offset into pagecache page */ @@ -3956,6 +3957,7 @@ ssize_t generic_perform_write(struct kiocb *iocb, struct iov_iter *i) balance_dirty_pages_ratelimited(mapping); } while (iov_iter_count(i)); + current->backing_dev_info = NULL; if (!written) return status;