Whamcloud - gitweb
LU-19098 hsm: don't print progname twice with lhsmtool
[fs/lustre-release.git] / libcfs / include / libcfs / crypto / llcrypt.h
index 5df68c4..997bee7 100644 (file)
@@ -1,4 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+
 /*
  * llcrypt.h: declarations for per-file encryption
  *
  * Written by Michael Halcrow, 2015.
  * Modified by Jaegeuk Kim, 2015.
  */
+
 /*
  * Linux commit 219d54332a09
  * tags/v5.4
  */
+
 #ifndef _LINUX_LLCRYPT_H
 #define _LINUX_LLCRYPT_H
 
 
 #define LL_CRYPTO_BLOCK_SIZE           16
 
+/* Extracts the second-to-last ciphertext block; see explanation below */
+#define LLCRYPT_FNAME_DIGEST(name, len)                                \
+       ((name) + round_down((len) - LL_CRYPTO_BLOCK_SIZE - 1,  \
+                            LL_CRYPTO_BLOCK_SIZE))
+
 struct llcrypt_ctx;
 struct llcrypt_info;
 
@@ -53,6 +61,8 @@ struct llcrypt_name {
 
 /* Maximum value for the third parameter of llcrypt_operations.set_context(). */
 #define LLCRYPT_SET_CONTEXT_MAX_SIZE   40
+#define LLCRYPT_DIGESTED_CHAR_OLD      '_'
+#define LLCRYPT_DIGESTED_CHAR          '+'
 
 #ifdef CONFIG_LL_ENCRYPTION
 /*
@@ -121,16 +131,26 @@ extern struct page *llcrypt_encrypt_pagecache_blocks(struct page *page,
                                                     unsigned int len,
                                                     unsigned int offs,
                                                     gfp_t gfp_flags);
-extern int llcrypt_encrypt_block_inplace(const struct inode *inode,
-                                        struct page *page, unsigned int len,
-                                        unsigned int offs, u64 lblk_num,
-                                        gfp_t gfp_flags);
+extern int llcrypt_encrypt_block(const struct inode *inode, struct page *src,
+                        struct page *dst, unsigned int len,
+                        unsigned int offs, u64 lblk_num, gfp_t gfp_flags);
 
 extern int llcrypt_decrypt_pagecache_blocks(struct page *page, unsigned int len,
                                            unsigned int offs);
-extern int llcrypt_decrypt_block_inplace(const struct inode *inode,
-                                        struct page *page, unsigned int len,
-                                        unsigned int offs, u64 lblk_num);
+
+extern int llcrypt_decrypt_block(const struct inode *inode, struct page *src,
+                        struct page *dst, unsigned int len,
+                        unsigned int offs, u64 lblk_num, gfp_t gfp_flags);
+
+static inline int llcrypt_decrypt_block_inplace(const struct inode *inode,
+                                               struct page *page,
+                                               unsigned int len,
+                                               unsigned int offs,
+                                               u64 lblk_num)
+{
+       return llcrypt_decrypt_block(inode, page, page, len, offs, lblk_num,
+                                    GFP_NOFS);
+}
 
 static inline bool llcrypt_is_bounce_page(struct page *page)
 {
@@ -153,7 +173,7 @@ extern int llcrypt_inherit_context(struct inode *, struct inode *,
                                        void *, bool);
 extern bool llcrypt_policy_has_filename_enc(struct inode *inode);
 /* keyring.c */
-extern void llcrypt_sb_free(struct super_block *sb);
+extern void llcrypt_sb_free(struct lustre_sb_info *lsi);
 extern int llcrypt_ioctl_add_key(struct file *filp, void __user *arg);
 extern int llcrypt_ioctl_remove_key(struct file *filp, void __user *arg);
 extern int llcrypt_ioctl_remove_key_all_users(struct file *filp,
@@ -182,12 +202,6 @@ extern int llcrypt_fname_disk_to_usr(struct inode *, u32, u32,
                        const struct llcrypt_str *, struct llcrypt_str *);
 
 #define LLCRYPT_FNAME_MAX_UNDIGESTED_SIZE      32
-
-/* Extracts the second-to-last ciphertext block; see explanation below */
-#define LLCRYPT_FNAME_DIGEST(name, len)        \
-       ((name) + round_down((len) - LL_CRYPTO_BLOCK_SIZE - 1, \
-                            LL_CRYPTO_BLOCK_SIZE))
-
 #define LLCRYPT_FNAME_DIGEST_SIZE      LL_CRYPTO_BLOCK_SIZE
 
 /**
@@ -255,13 +269,6 @@ static inline bool llcrypt_match_name(const struct llcrypt_name *fname,
        return !memcmp(de_name, fname->disk_name.name, fname->disk_name.len);
 }
 
-/* bio.c */
-extern void llcrypt_decrypt_bio(struct bio *);
-extern void llcrypt_enqueue_decrypt_bio(struct llcrypt_ctx *ctx,
-                                       struct bio *bio);
-extern int llcrypt_zeroout_range(const struct inode *, pgoff_t, sector_t,
-                                unsigned int);
-
 /* hooks.c */
 extern int llcrypt_file_open(struct inode *inode, struct file *filp);
 extern int __llcrypt_prepare_link(struct inode *inode, struct inode *dir,
@@ -336,11 +343,10 @@ static inline struct page *llcrypt_encrypt_pagecache_blocks(struct page *page,
        return ERR_PTR(-EOPNOTSUPP);
 }
 
-static inline int llcrypt_encrypt_block_inplace(const struct inode *inode,
-                                               struct page *page,
-                                               unsigned int len,
-                                               unsigned int offs, u64 lblk_num,
-                                               gfp_t gfp_flags)
+static inline int llcrypt_encrypt_block(const struct inode *inode,
+                                       struct page *src, struct page *dst,
+                                       unsigned int len, unsigned int offs,
+                                       u64 lblk_num, gfp_t gfp_flags)
 {
        return -EOPNOTSUPP;
 }
@@ -352,6 +358,14 @@ static inline int llcrypt_decrypt_pagecache_blocks(struct page *page,
        return -EOPNOTSUPP;
 }
 
+static inline int llcrypt_decrypt_block(const struct inode *inode,
+                                       struct page *src, struct page *dst,
+                                       unsigned int len, unsigned int offs,
+                                       u64 lblk_num, gfp_t gfp_flags)
+{
+       return -EOPNOTSUPP;
+}
+
 static inline int llcrypt_decrypt_block_inplace(const struct inode *inode,
                                                struct page *page,
                                                unsigned int len,
@@ -411,7 +425,7 @@ static inline bool llcrypt_policy_has_filename_enc(struct inode *inode)
 }
 
 /* keyring.c */
-static inline void llcrypt_sb_free(struct super_block *sb)
+static inline void llcrypt_sb_free(struct lustre_sb_info *lsi)
 {
 }
 
@@ -506,22 +520,6 @@ static inline bool llcrypt_match_name(const struct llcrypt_name *fname,
        return !memcmp(de_name, fname->disk_name.name, fname->disk_name.len);
 }
 
-/* bio.c */
-static inline void llcrypt_decrypt_bio(struct bio *bio)
-{
-}
-
-static inline void llcrypt_enqueue_decrypt_bio(struct llcrypt_ctx *ctx,
-                                              struct bio *bio)
-{
-}
-
-static inline int llcrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
-                                       sector_t pblk, unsigned int len)
-{
-       return -EOPNOTSUPP;
-}
-
 /* hooks.c */
 
 static inline int llcrypt_file_open(struct inode *inode, struct file *filp)