diff options
author | Eric Biggers <ebiggers@google.com> | 2022-08-15 16:50:51 -0700 |
---|---|---|
committer | Eric Biggers <ebiggers@google.com> | 2022-09-06 15:15:56 -0700 |
commit | 14db0b3c7b837f4edeb7c1794290c2f345c7f627 (patch) | |
tree | 910d1d1587b9e30030ba477777d42cacf1fac462 /fs/crypto | |
parent | 272ac1500372183ffd54b0c9f43f52afc482e610 (diff) | |
download | linux-rpi-14db0b3c7b837f4edeb7c1794290c2f345c7f627.tar.gz linux-rpi-14db0b3c7b837f4edeb7c1794290c2f345c7f627.tar.bz2 linux-rpi-14db0b3c7b837f4edeb7c1794290c2f345c7f627.zip |
fscrypt: stop using PG_error to track error status
As a step towards freeing the PG_error flag for other uses, change ext4
and f2fs to stop using PG_error to track decryption errors. Instead, if
a decryption error occurs, just mark the whole bio as failed. The
coarser granularity isn't really a problem since it isn't any worse than
what the block layer provides, and errors from a multi-page readahead
aren't reported to applications unless a single-page read fails too.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Chao Yu <chao@kernel.org> # for f2fs part
Link: https://lore.kernel.org/r/20220815235052.86545-2-ebiggers@kernel.org
Diffstat (limited to 'fs/crypto')
-rw-r--r-- | fs/crypto/bio.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/fs/crypto/bio.c b/fs/crypto/bio.c index 2217fe5ece6f..1b4403136d05 100644 --- a/fs/crypto/bio.c +++ b/fs/crypto/bio.c @@ -25,21 +25,25 @@ * then this function isn't applicable. This function may sleep, so it must be * called from a workqueue rather than from the bio's bi_end_io callback. * - * This function sets PG_error on any pages that contain any blocks that failed - * to be decrypted. The filesystem must not mark such pages uptodate. + * Return: %true on success; %false on failure. On failure, bio->bi_status is + * also set to an error status. */ -void fscrypt_decrypt_bio(struct bio *bio) +bool fscrypt_decrypt_bio(struct bio *bio) { struct bio_vec *bv; struct bvec_iter_all iter_all; bio_for_each_segment_all(bv, bio, iter_all) { struct page *page = bv->bv_page; - int ret = fscrypt_decrypt_pagecache_blocks(page, bv->bv_len, + int err = fscrypt_decrypt_pagecache_blocks(page, bv->bv_len, bv->bv_offset); - if (ret) - SetPageError(page); + + if (err) { + bio->bi_status = errno_to_blk_status(err); + return false; + } } + return true; } EXPORT_SYMBOL(fscrypt_decrypt_bio); |