Add fix to add-get_inode_usage-callback-to-transfer-multi-inode-charges
[ext4-patch-queue.git] / avoid-unnecesary-stalls-in-ext4_evict_inode
blob5c514ba2bda2fb17dda092f919f0503feefaf3eb
1 ext4: avoid unnecessary stalls in ext4_evict_inode()
3 From: Jan Kara <jack@suse.cz>
5 These days inode reclaim calls evict_inode() only when it has no pages
6 in the mapping.  In that case it is not necessary to wait for transaction
7 commit in ext4_evict_inode() as there can be no pages waiting to be
8 committed.  So avoid unnecessary transaction waiting in that case.
10 We still have to keep the check for the case where ext4_evict_inode()
11 gets called from other paths (e.g. umount) where inode still can have
12 some page cache pages.
14 Reported-by: Johannes Weiner <hannes@cmpxchg.org>
15 Signed-off-by: Jan Kara <jack@suse.cz>
16 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
17 ---
18  fs/ext4/inode.c | 3 ++-
19  1 file changed, 2 insertions(+), 1 deletion(-)
21 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
22 index 5834c4d76be8..3aef67ca18ac 100644
23 --- a/fs/ext4/inode.c
24 +++ b/fs/ext4/inode.c
25 @@ -213,7 +213,8 @@ void ext4_evict_inode(struct inode *inode)
26                  */
27                 if (inode->i_ino != EXT4_JOURNAL_INO &&
28                     ext4_should_journal_data(inode) &&
29 -                   (S_ISLNK(inode->i_mode) || S_ISREG(inode->i_mode))) {
30 +                   (S_ISLNK(inode->i_mode) || S_ISREG(inode->i_mode)) &&
31 +                   inode->i_data.nrpages) {
32                         journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
33                         tid_t commit_tid = EXT4_I(inode)->i_datasync_tid;
35 -- 
36 2.12.0