Skip to content

Commit 7d41870

Browse files
lxbszidryomov
authored andcommitted
ceph: implement writeback livelock avoidance using page tagging
While the mapped IOs continue if we try to flush a file's buffer we can see that the fsync() won't complete until the IOs finish. This is analogous to Jan Kara's commit (f446daa mm: implement writeback livelock avoidance using page tagging), we will try to avoid livelocks of writeback when some steadily creates dirty pages in a mapping we are writing out. Signed-off-by: Xiubo Li <xiubli@redhat.com> Reviewed-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent 7a6c3a0 commit 7d41870

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

fs/ceph/addr.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,7 @@ static int ceph_writepages_start(struct address_space *mapping,
808808
bool should_loop, range_whole = false;
809809
bool done = false;
810810
bool caching = ceph_is_cache_enabled(inode);
811+
xa_mark_t tag;
811812

812813
if (wbc->sync_mode == WB_SYNC_NONE &&
813814
fsc->write_congested)
@@ -834,6 +835,11 @@ static int ceph_writepages_start(struct address_space *mapping,
834835
start_index = wbc->range_cyclic ? mapping->writeback_index : 0;
835836
index = start_index;
836837

838+
if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) {
839+
tag = PAGECACHE_TAG_TOWRITE;
840+
} else {
841+
tag = PAGECACHE_TAG_DIRTY;
842+
}
837843
retry:
838844
/* find oldest snap context with dirty data */
839845
snapc = get_oldest_context(inode, &ceph_wbc, NULL);
@@ -872,6 +878,9 @@ static int ceph_writepages_start(struct address_space *mapping,
872878
dout(" non-head snapc, range whole\n");
873879
}
874880

881+
if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
882+
tag_pages_for_writeback(mapping, index, end);
883+
875884
ceph_put_snap_context(last_snapc);
876885
last_snapc = snapc;
877886

@@ -888,7 +897,7 @@ static int ceph_writepages_start(struct address_space *mapping,
888897

889898
get_more_pages:
890899
nr_folios = filemap_get_folios_tag(mapping, &index,
891-
end, PAGECACHE_TAG_DIRTY, &fbatch);
900+
end, tag, &fbatch);
892901
dout("pagevec_lookup_range_tag got %d\n", nr_folios);
893902
if (!nr_folios && !locked_pages)
894903
break;

0 commit comments

Comments
 (0)