-#if 0
-/*
- * this was needed for catching correct calling place of ll_intent_alloc() with
- * missed ll_intent_free() causing memory leak. --umka
- */
-#define ll_intent_alloc(it) \
- ({ \
- int err; \
- OBD_SLAB_ALLOC((it)->d.fs_data, ll_intent_slab, SLAB_KERNEL, \
- sizeof(struct lustre_intent_data)); \
- if (!(it)->d.fs_data) { \
- err = -ENOMEM; \
- } else { \
- err = 0; \
- } \
- (it)->it_op_release = ll_intent_release; \
- err; \
- })
-
-#define ll_intent_free(it) \
- do { \
- if ((it)->d.fs_data) { \
- OBD_SLAB_FREE((it)->d.fs_data, ll_intent_slab, \
- sizeof(struct lustre_intent_data)); \
- (it)->d.fs_data = NULL; \
- } \
- } while (0)
-#endif
+struct crypto_helper_ops {
+ int (*init_it_key)(struct inode *inode, struct lookup_intent *it);
+ int (*create_key)(struct inode *dir, mode_t mode, void **key,
+ int* key_size);
+ int (*get_mac)(struct inode *inode, struct iattr *iattr, void*value,
+ int size, void **key, int* key_size);
+ int (*decrypt_key)(struct inode *inode, struct lookup_intent *it);
+ int (*init_inode_key)(struct inode *inode, void *md_key);
+ int (*destroy_key)(struct inode *inode);
+};
+
+/*llite crypto ops for crypto api*/
+struct ll_crypto_info {
+ struct obd_export *ll_gt_exp;
+ struct list_head ll_cops_list;
+ struct crypto_helper_ops *ll_cops;
+ int ll_c_flags;
+};
+#define ll_page2key(page) ((ll_i2info(page->mapping->host))->lli_key_info)
+static inline struct ll_crypto_info* ll_s2crpi(struct super_block *sb)
+{
+ return (struct ll_crypto_info*)ll_s2sbi(sb)->ll_crypto_info;
+}
+static inline struct ll_crypto_info* ll_i2crpi(struct inode *inode)
+{
+ return (struct ll_crypto_info*)ll_i2sbi(inode)->ll_crypto_info;
+}
+
+static inline struct crypto_helper_ops* ll_i2crpops(struct inode *inode)
+{
+ return ll_i2crpi(inode)->ll_cops;
+}
+
+static inline struct crypto_helper_ops* ll_s2crpops(struct super_block *sb)
+{
+ return ll_s2crpi(sb)->ll_cops;
+}
+
+static inline struct obd_export *ll_s2gsexp(struct super_block *sb)
+{
+ struct ll_crypto_info *llci = ll_s2crpi(sb);
+ if (llci)
+ return llci->ll_gt_exp;
+ return NULL;
+}
+static inline struct obd_export *ll_i2gsexp(struct inode *inode)
+{
+ return ll_s2gsexp(inode->i_sb);
+}
+
+static inline
+int ll_crypto_init_it_key(struct inode *inode, struct lookup_intent *it)
+{
+ struct ll_crypto_info *lci = ll_i2crpi(inode);
+ if (lci) {
+ struct crypto_helper_ops *ops = lci->ll_cops;;
+ if (ops && ops->init_it_key)
+ return ops->init_it_key(inode, it);
+ }
+ return 0;
+}
+
+static inline
+int ll_crypto_create_key(struct inode *inode, mode_t mode, void **key,
+ int* key_size)
+{
+ struct ll_crypto_info *lci = ll_i2crpi(inode);
+ if (lci) {
+ struct crypto_helper_ops *ops = lci->ll_cops;;
+ if (ops && ops->create_key)
+ return ops->create_key(inode, mode, key, key_size);
+ }
+ return 0;
+}
+
+static inline
+int ll_crypto_get_mac(struct inode *inode, struct iattr *attr, void *acl,
+ int acl_size, void **mac, int *mac_size)
+{
+ struct ll_crypto_info *lci = ll_i2crpi(inode);
+ if (lci) {
+ struct crypto_helper_ops *ops = lci->ll_cops;
+ if (ops && ops->get_mac)
+ return ops->get_mac(inode, attr, acl, acl_size,
+ mac, mac_size);
+ }
+ return 0;
+}
+
+static inline
+int ll_crypto_decrypt_key(struct inode *inode, struct lookup_intent *it)
+{
+ struct ll_crypto_info *lci = ll_i2crpi(inode);
+ if (lci) {
+ struct crypto_helper_ops *ops = lci->ll_cops;
+ if (ops && ops->decrypt_key)
+ return ops->decrypt_key(inode, it);
+ }
+ return 0;
+}
+
+static inline
+int ll_crypto_init_inode_key(struct inode *inode, void *md_key)
+{
+ struct ll_crypto_info *lci = ll_i2crpi(inode);
+ if (lci) {
+ struct crypto_helper_ops *ops = lci->ll_cops;
+ if (ops && ops->init_inode_key)
+ return ops->init_inode_key(inode, md_key);
+ }
+ return 0;
+}
+
+static inline
+int ll_crypto_destroy_inode_key(struct inode *inode)
+{
+ struct ll_crypto_info *lci = ll_i2crpi(inode);
+ if (lci) {
+ struct crypto_helper_ops *ops = lci->ll_cops;
+ if (ops && ops->destroy_key)
+ return ops->destroy_key(inode);
+ }
+ return 0;
+}