Details
-
Bug
-
Resolution: Unresolved
-
Medium
-
None
-
None
-
None
-
3
-
9223372036854775807
Description
DIO encrypted file corruption during migration (lfs migrate). The encrypt path in osc_brw_prep_request() writes cp_page_index into page_folio(page)->index, then osc_encrypt_pagecache_blocks() reads it back via folio_index_page(). For DIO pages that are part of compound pages (order > 0), folio_index_page() adds folio_page_idx() to the base index, producing a wrong AES-XTS tweak. The decrypt path correctly uses cp_page_index directly.
Compound pages can appear for DIO allocations on any kernel – reproduced on RHEL 9.6 and SLES 15.6 (not just newer kernels).
Fix: pass cp_page_index explicitly to osc_encrypt_pagecache_blocks() for DIO, mirroring the decrypt path which already uses cp_page_index directly. Eliminates the fragile round-trip through folio->index.
Root cause analysis from Sebastien Buisson's debug patch (review.whamcloud.com/65041) traces:
- Encrypt: page_index_in_folio=1, folio->index set to 2 by prep, folio_index_page() returns 2+1=3, lblk=3
- Decrypt: cp_page_index=2, lblk=2
- Mismatch: encrypt lblk=3 != decrypt lblk=2 -> corruption
Related: LU-17916 (folio-order-aware code), LU-19895 (large folio allocation option)