f2fs: refactor read path to allow multiple postprocessing steps
authorEric Biggers <ebiggers@google.com>
Wed, 18 Apr 2018 18:09:48 +0000 (11:09 -0700)
committerJaegeuk Kim <jaegeuk@google.com>
Sat, 21 Apr 2018 05:34:05 +0000 (22:34 -0700)
commitc6e638ae452cc27fca4894022c2a3e53772cee2d
treee86d5c7755528d0552a4ba1ae89398c887cf7713
parent61760b0be333584661bb029f0d071dc9baa1d84a
f2fs: refactor read path to allow multiple postprocessing steps

Cherry-pick from origin/upstream-f2fs-stable-linux-4.14.y:
  e1f299357c3e ("f2fs: refactor read path to allow multiple postprocessing steps")

Currently f2fs's ->readpage() and ->readpages() assume that either the
data undergoes no postprocessing, or decryption only.  But with
fs-verity, there will be an additional authenticity verification step,
and it may be needed either by itself, or combined with decryption.

To support this, store a 'struct bio_post_read_ctx' in ->bi_private
which contains a work struct, a bitmask of postprocessing steps that are
enabled, and an indicator of the current step.  The bio completion
routine, if there was no I/O error, enqueues the first postprocessing
step.  When that completes, it continues to the next step.  Pages that
fail any postprocessing step have PageError set.  Once all steps have
completed, pages without PageError set are set Uptodate, and all pages
are unlocked.

Also replace f2fs_encrypted_file() with a new function
f2fs_post_read_required() in places like direct I/O and garbage
collection that really should be testing whether the file needs special
I/O processing, not whether it is encrypted specifically.

This may also be useful for other future f2fs features such as
compression.

Change-Id: I8178e0fa7ae0171e5894b32a692cc8b1fb45a149
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/data.c
fs/f2fs/f2fs.h
fs/f2fs/file.c
fs/f2fs/gc.c
fs/f2fs/inline.c
fs/f2fs/super.c