mm/filemap.c: rewrite mapping_needs_writeback in less fancy manner
authorKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
Mon, 23 Sep 2019 22:34:48 +0000 (15:34 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 24 Sep 2019 22:54:08 +0000 (15:54 -0700)
This actually checks that writeback is needed or in progress.

Link: http://lkml.kernel.org/r/156378817069.1087.1302816672037672488.stgit@buzz
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/filemap.c

index 82f3b9a3a9406626d9bc1de9ddff3516dcb764c2..d5462d706f76d76c0ddb269c4cfa3565265d2192 100644 (file)
@@ -618,10 +618,13 @@ int filemap_fdatawait_keep_errors(struct address_space *mapping)
 }
 EXPORT_SYMBOL(filemap_fdatawait_keep_errors);
 
+/* Returns true if writeback might be needed or already in progress. */
 static bool mapping_needs_writeback(struct address_space *mapping)
 {
-       return (!dax_mapping(mapping) && mapping->nrpages) ||
-           (dax_mapping(mapping) && mapping->nrexceptional);
+       if (dax_mapping(mapping))
+               return mapping->nrexceptional;
+
+       return mapping->nrpages;
 }
 
 int filemap_write_and_wait(struct address_space *mapping)