summaryrefslogtreecommitdiff
path: root/fs/crypto/crypto.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2018-05-01 01:51:47 +0300
committerTheodore Ts'o <tytso@mit.edu>2018-05-20 23:21:05 +0300
commit544d08fde258b4da72b6cfbe2d7172c86ce9860d (patch)
tree56d013a89974bd62e3ca974e090f495808edc64a /fs/crypto/crypto.c
parent11b8818ec09d577567f59fc1b32cfa56c756fe89 (diff)
downloadlinux-544d08fde258b4da72b6cfbe2d7172c86ce9860d.tar.xz
fscrypt: use a common logging function
Use a common function for fscrypt warning and error messages so that all the messages are consistently ratelimited, include the "fscrypt:" prefix, and include the filesystem name if applicable. Also fix up a few of the log messages to be more descriptive. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/crypto/crypto.c')
-rw-r--r--fs/crypto/crypto.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c
index f46191b6b3ed..243a269e6c5f 100644
--- a/fs/crypto/crypto.c
+++ b/fs/crypto/crypto.c
@@ -174,9 +174,10 @@ int fscrypt_do_page_crypto(const struct inode *inode, fscrypt_direction_t rw,
res = crypto_wait_req(crypto_skcipher_encrypt(req), &wait);
skcipher_request_free(req);
if (res) {
- printk_ratelimited(KERN_ERR
- "%s: crypto_skcipher_encrypt() returned %d\n",
- __func__, res);
+ fscrypt_err(inode->i_sb,
+ "%scryption failed for inode %lu, block %llu: %d",
+ (rw == FS_DECRYPT ? "de" : "en"),
+ inode->i_ino, lblk_num, res);
return res;
}
return 0;
@@ -416,6 +417,27 @@ fail:
return res;
}
+void fscrypt_msg(struct super_block *sb, const char *level,
+ const char *fmt, ...)
+{
+ static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL,
+ DEFAULT_RATELIMIT_BURST);
+ struct va_format vaf;
+ va_list args;
+
+ if (!__ratelimit(&rs))
+ return;
+
+ va_start(args, fmt);
+ vaf.fmt = fmt;
+ vaf.va = &args;
+ if (sb)
+ printk("%sfscrypt (%s): %pV\n", level, sb->s_id, &vaf);
+ else
+ printk("%sfscrypt: %pV\n", level, &vaf);
+ va_end(args);
+}
+
/**
* fscrypt_init() - Set up for fs encryption.
*/