Skip to content
  1. Apr 15, 2023
    • Jan Kara's avatar
      ext4: Drop special handling of journalled data from ext4_sync_file() · e360c6ed
      Jan Kara authored
      
      
      Now that ext4_writepages() make sure all pages with journalled data are
      stable on disk, we don't need special handling of journalled data in
      ext4_sync_file().
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20230329154950.19720-6-jack@suse.cz
      
      
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      e360c6ed
    • Jan Kara's avatar
      ext4: Commit transaction before writing back pages in data=journal mode · 1f1a55f0
      Jan Kara authored
      
      
      When journalling data we currently just walk over pages, journal those
      that are marked for delayed dirtying (only pinned pages dirtied behing
      our back these days) and checkpoint other dirty pages. Because some
      pages may be part of running transaction the result is that after
      filemap_write_and_wait() we are not guaranteed pages are stable on disk.
      Thus places that want to flush current pagecache content need to jump
      through hoops to make sure journalled data is not lost. This is
      manageable in cases completely controlled by ext4 (such as extent
      shifting operations or inode eviction) but it gets ugly for stuff like
      fsverity. Furthermore it is rather error prone as people often do not
      realize journalled data needs special handling.
      
      So change ext4_writepages() to commit transaction with inode's data
      before going through the writeback loop in WB_SYNC_ALL mode. As a result
      filemap_write_and_wait() is now really getting pages to stable storage
      and makes pagecache pages safe to reclaim. Consequently we can remove
      the special handling of journalled data from several places in follow up
      patches.
      
      Note that this will make fsync(2) for journalled data more expensive as
      we will end up not only committing the transaction we need but also
      checkpointing the data (which we may have previously skipped if the data
      was part of the running transaction). If we really cared, we would need
      to introduce special VFS function for writing out & invalidating page
      cache for a range, use ->launder_page callback to perform checkpointing,
      and use it from all the places that need this functionality. But at this
      point I'm not convinced the complexity is worth it.
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20230329154950.19720-5-jack@suse.cz
      
      
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      1f1a55f0
    • Jan Kara's avatar
      ext4: Clear dirty bit from pages without data to write · 5e1bdea6
      Jan Kara authored
      
      
      With journalled data it can happen that checkpointing code will write
      out page contents without clearing the page dirty bit. The logic in
      ext4_page_nomap_can_writeout() then results in us never calling
      mpage_submit_page() and thus clearing the dirty bit. Drop the
      optimization with ext4_page_nomap_can_writeout() and just always call to
      mpage_submit_page(). ext4_bio_write_page() knows when to redirty the
      page and the additional clearing & setting of page dirty bit for ordered
      mode writeout is not that expensive to jump through the hoops for it.
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20230329154950.19720-4-jack@suse.cz
      
      
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      5e1bdea6
    • Jan Kara's avatar
      ext4: Keep pages with journalled data dirty · 265e72ef
      Jan Kara authored
      
      
      Currently we clear page dirty bit when we checkpoint some buffers from a
      page with journalled data or when we perform delayed dirtying of a page
      in ext4_writepages(). In a quest to simplify handling of journalled data
      we want to keep page dirty as long as it has either buffers to
      checkpoint or journalled dirty data. So make sure to keep page dirty in
      ext4_writepages() if it still has journalled data attached to it.
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20230329154950.19720-3-jack@suse.cz
      
      
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      265e72ef
    • Jan Kara's avatar
      ext4: Mark pages with journalled data dirty · d84c9ebd
      Jan Kara authored
      
      
      Currently pages with journalled data written by write(2) or modified by
      block zeroing during truncate(2) are not marked as dirty. They are
      dirtied only once the transaction commits. This however makes writeback
      code think inode has no pages to write and so ext4_writepages() is not
      called to make pages with journalled data persistent. Mark pages with
      journalled data dirty (similarly as it happens for writes through mmap)
      so that writeback code knows about them and ext4_writepages() can do
      what it needs to to the inode.
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20230329154950.19720-2-jack@suse.cz
      
      
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      d84c9ebd
    • Jan Kara's avatar
      jdb2: Don't refuse invalidation of already invalidated buffers · bd159398
      Jan Kara authored
      
      
      When invalidating buffers under the partial tail page,
      jbd2_journal_invalidate_folio() returns -EBUSY if the buffer is part of
      the committing transaction as we cannot safely modify buffer state.
      However if the buffer is already invalidated (due to previous
      invalidation attempts from ext4_wait_for_tail_page_commit()), there's
      nothing to do and there's no point in returning -EBUSY. This fixes
      occasional warnings from ext4_journalled_invalidate_folio() triggered by
      generic/051 fstest when blocksize < pagesize.
      
      Fixes: 53e87268 ("ext4: fix deadlock in journal_unmap_buffer()")
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20230329154950.19720-1-jack@suse.cz
      
      
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      bd159398
  2. Apr 07, 2023
  3. Apr 06, 2023