Skip to content
  • Chao Yu's avatar
    f2fs crypto: fix incorrect positioning for GCing encrypted data page · 4356e48e
    Chao Yu authored
    
    
    For now, flow of GCing an encrypted data page:
    1) try to grab meta page in meta inode's mapping with index of old block
    address of that data page
    2) load data of ciphertext into meta page
    3) allocate new block address
    4) write the meta page into new block address
    5) update block address pointer in direct node page.
    
    Other reader/writer will use f2fs_wait_on_encrypted_page_writeback to
    check and wait on GCed encrypted data cached in meta page writebacked
    in order to avoid inconsistence among data page cache, meta page cache
    and data on-disk when updating.
    
    However, we will use new block address updated in step 5) as an index to
    lookup meta page in inner bio buffer. That would be wrong, and we will
    never find the GCing meta page, since we use the old block address as
    index of that page in step 1).
    
    This patch fixes the issue by adjust the order of step 1) and step 3),
    and in step 1) grab page with index generated in step 3).
    
    Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
    Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
    4356e48e