summaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2022-12-07 12:27:10 +0100
committerTheodore Ts'o <tytso@mit.edu>2022-12-08 21:49:25 -0500
commit29bc9cea0e13dc8043c249f5f232b9e0c441ae24 (patch)
tree4c1a78490f8b0a3520e6b2068503ee78e64f0a59 /fs/ext4
parent15648d599cd1c15cc678039dcab65599276fe407 (diff)
downloadlinux-29bc9cea0e13dc8043c249f5f232b9e0c441ae24.tar.bz2
ext4: move percpu_rwsem protection into ext4_writepages()
Move protection by percpu_rwsem from ext4_do_writepages() to ext4_writepages(). We will not want to grab this protection during transaction commits as that would be prone to deadlocks and the protection is not needed. Move the shutdown state checking as well since we want to be able to complete commit while the shutdown is in progress. Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20221207112722.22220-7-jack@suse.cz Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/inode.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index a023cca4b6f6..3aa01a9d4664 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2727,10 +2727,6 @@ static int ext4_do_writepages(struct mpage_da_data *mpd)
struct blk_plug plug;
bool give_up_on_write = false;
- if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
- return -EIO;
-
- percpu_down_read(&sbi->s_writepages_rwsem);
trace_ext4_writepages(inode, wbc);
/*
@@ -2940,20 +2936,28 @@ unplug:
out_writepages:
trace_ext4_writepages_result(inode, wbc, ret,
nr_to_write - wbc->nr_to_write);
- percpu_up_read(&sbi->s_writepages_rwsem);
return ret;
}
static int ext4_writepages(struct address_space *mapping,
struct writeback_control *wbc)
{
+ struct super_block *sb = mapping->host->i_sb;
struct mpage_da_data mpd = {
.inode = mapping->host,
.wbc = wbc,
.can_map = 1,
};
+ int ret;
+
+ if (unlikely(ext4_forced_shutdown(EXT4_SB(sb))))
+ return -EIO;
- return ext4_do_writepages(&mpd);
+ percpu_down_read(&EXT4_SB(sb)->s_writepages_rwsem);
+ ret = ext4_do_writepages(&mpd);
+ percpu_up_read(&EXT4_SB(sb)->s_writepages_rwsem);
+
+ return ret;
}
static int ext4_dax_writepages(struct address_space *mapping,