From: Christoph Hellwig <hch@lst.de>
To: Matthew Wilcox <willy@infradead.org>
Cc: Jens Axboe <axboe@kernel.dk>, Xiubo Li <xiubli@redhat.com>,
Ilya Dryomov <idryomov@gmail.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
"Theodore Ts'o" <tytso@mit.edu>, Jaegeuk Kim <jaegeuk@kernel.org>,
Chao Yu <chao@kernel.org>, Miklos Szeredi <miklos@szeredi.hu>,
Andreas Gruenbacher <agruenba@redhat.com>,
"Darrick J. Wong" <djwong@kernel.org>,
Trond Myklebust <trond.myklebust@hammerspace.com>,
Anna Schumaker <anna@kernel.org>,
Damien Le Moal <dlemoal@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
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 [thread overview]
Message-ID: <20230519093521.133226-4-hch@lst.de> (raw)
In-Reply-To: <20230519093521.133226-1-hch@lst.de>
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 <hch@lst.de>
---
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 <linux/pagevec.h>
#include <linux/uio.h>
#include <linux/mman.h>
-#include <linux/backing-dev.h>
#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;
--
2.39.2
next prev parent reply other threads:[~2023-05-19 9:35 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-19 9:35 cleanup the filemap / direct I/O interaction Christoph Hellwig
2023-05-19 9:35 ` [PATCH 01/13] iomap: update ki_pos a little later in iomap_dio_complete Christoph Hellwig
2023-05-21 23:40 ` Damien Le Moal
2023-07-06 0:18 ` [f2fs-dev] " patchwork-bot+f2fs
2023-05-19 9:35 ` [PATCH 02/13] filemap: update ki_pos in generic_perform_write Christoph Hellwig
2023-05-21 23:42 ` Damien Le Moal
2023-05-22 2:20 ` Xiubo Li
2023-05-19 9:35 ` Christoph Hellwig [this message]
2023-05-21 23:44 ` [PATCH 03/13] filemap: assign current->backing_dev_info " Damien Le Moal
2023-05-22 2:22 ` Xiubo Li
2023-05-19 9:35 ` [PATCH 04/13] filemap: add a kiocb_write_and_wait helper Christoph Hellwig
2023-05-21 23:46 ` Damien Le Moal
2023-05-19 9:35 ` [PATCH 05/13] filemap: add a kiocb_invalidate_pages helper Christoph Hellwig
2023-05-21 23:51 ` Damien Le Moal
2023-05-19 9:35 ` [PATCH 06/13] filemap: add a kiocb_invalidate_post_write helper Christoph Hellwig
2023-05-21 23:56 ` Damien Le Moal
2023-05-23 16:01 ` Christoph Hellwig
2023-05-19 9:35 ` [PATCH 07/13] iomap: update ki_pos in iomap_file_buffered_write Christoph Hellwig
2023-05-22 0:01 ` Damien Le Moal
2023-05-23 16:02 ` Christoph Hellwig
2023-05-19 9:35 ` [PATCH 08/13] iomap: assign current->backing_dev_info " Christoph Hellwig
2023-05-22 0:05 ` Damien Le Moal
2023-05-23 1:06 ` Darrick J. Wong
2023-05-23 3:30 ` Matthew Wilcox
2023-05-23 16:02 ` Christoph Hellwig
2023-05-19 9:35 ` [PATCH 09/13] iomap: use kiocb_write_and_wait and kiocb_invalidate_pages Christoph Hellwig
2023-05-22 0:07 ` Damien Le Moal
2023-05-19 9:35 ` [PATCH 10/13] fs: factor out a direct_write_fallback helper Christoph Hellwig
2023-05-22 0:16 ` Damien Le Moal
2023-05-22 14:19 ` Miklos Szeredi
2023-05-23 16:03 ` Christoph Hellwig
2023-05-19 9:35 ` [PATCH 11/13] fuse: update ki_pos in fuse_perform_write Christoph Hellwig
2023-05-22 0:18 ` Damien Le Moal
2023-05-19 9:35 ` [PATCH 12/13] fuse: drop redundant arguments to fuse_perform_write Christoph Hellwig
2023-05-22 0:19 ` Damien Le Moal
2023-05-19 9:35 ` [PATCH 13/13] fuse: use direct_write_fallback Christoph Hellwig
2023-05-22 0:20 ` Damien Le Moal
2023-05-23 1:12 ` cleanup the filemap / direct I/O interaction Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230519093521.133226-4-hch@lst.de \
--to=hch@lst.de \
--cc=agruenba@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=anna@kernel.org \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=ceph-devel@vger.kernel.org \
--cc=chao@kernel.org \
--cc=cluster-devel@redhat.com \
--cc=djwong@kernel.org \
--cc=dlemoal@kernel.org \
--cc=idryomov@gmail.com \
--cc=jaegeuk@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=trond.myklebust@hammerspace.com \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
--cc=xiubli@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox