• Bob Peterson's avatar
    gfs2: Only set PageChecked if we have a transaction · 6302d6f4
    Bob Peterson authored
    With jdata writes, we frequently got into situations where gfs2 deadlocked
    because of this calling sequence:
    
    gfs2_ail1_start
       gfs2_ail1_flush - for every tr on the sd_ail1_list:
          gfs2_ail1_start_one - for every bd on the tr's tr_ail1_list:
             generic_writepages
    	    write_cache_pages passing __writepage()
    	       calls clear_page_dirty_for_io which calls set_page_dirty:
    	          which calls jdata_set_page_dirty which sets PageChecked.
    	       __writepage() calls
    	          mapping->a_ops->writepage AKA gfs2_jdata_writepage
    
    However, gfs2_jdata_writepage checks if PageChecked is set, and if so, it
    ignores the write and redirties the page. The problem is that write_cache_pages
    calls clear_page_dirty_for_io, which often calls set_page_dirty(). See comments
    in page-writeback.c starting with "Yes, Virginia". If it's jdata,
    set_page_dirty will call jdata_set_page_dirty which will set PageChecked.
    That causes a conflict because it makes it look like the page has been
    redirtied by another writer, in which case we need to skip writing it and
    redirty the page. That ends up in a deadlock because it isn't a "real" writer
    and nothing will ever clear PageChecked.
    
    If we do have a real writer, it will have started a transaction. So this
    patch checks if a transaction is in use, and if not, it skips setting
    PageChecked. That way, the page will be dirtied, cleaned, and written
    appropriately.
    Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
    Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
    6302d6f4
aops.c 20.5 KB