Whamcloud - gitweb
LU-15608 sec: fix DIO for encrypted files 64/46664/6
authorSebastien Buisson <sbuisson@ddn.com>
Tue, 1 Mar 2022 16:26:09 +0000 (17:26 +0100)
committerOleg Drokin <green@whamcloud.com>
Thu, 17 Mar 2022 07:08:06 +0000 (07:08 +0000)
commit966ca46e4aa2eb39c70e49648ffe6fcaaf475536
tree67e4f91263ba8682108418800df1dbf4cff17994
parent1dbcbd70f87b7390998cd3b1fa546ece9d2a493e
LU-15608 sec: fix DIO for encrypted files

With Direct IO, we do not have proper page cache pages. So we need to
retrieve by ourselves the page mapping and the page index of the page
to be encrypted/decrypted.

For the index, we need to use the offset of the page within the file,
and not the object.
So we rename cl_page's cp_osc_index to cp_page_index for that purpose.
cp_osc_index is redundant with osc_async_page's oap_obj_off and only
used by osc_index(), so we also adapt this function.
cp_page_index is initialized in cl_page_alloc(), and accessed in
the OSC layer where the llcrypt primitives are called.

For the mapping, problem is page->mapping is not set to NULL on page
allocation, so it cannot safely be used to see if a page is a direct
I/O page.
Use cl_page for direct I/O and page->mapping for buffered
I/O.  (clpage->cp_inode is only set for direct I/O and
cannot easily be always set.)
Without this, we sometimes get panics when page2inode is
used in the OSC layer.  (Note the remaining use in dom is
safe because ll_dom_readpage is a page cache helper and
will never see DIO pages.)

Fixes: a71e0dd7f7 ("LU-14306 sec: get rid of bad rss-counter state messages")
Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Change-Id: Icb53a4e45463b8d3febc2e6212b39dc25719d866
Reviewed-on: https://review.whamcloud.com/46664
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/cl_object.h
lustre/include/lustre_osc.h
lustre/include/obd.h
lustre/llite/file.c
lustre/obdclass/cl_page.c
lustre/osc/osc_page.c
lustre/osc/osc_request.c
lustre/tests/sanity-sec.sh