Commit b6c1d8fc authored by Michael Halcrow's avatar Michael Halcrow Committed by Linus Torvalds

eCryptfs: remove unused functions and kmem_cache

The switch to read_write.c routines and the persistent file make a number of
functions unnecessary.  This patch removes them.
Signed-off-by: default avatarMichael Halcrow <mhalcrow@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 035241d3
...@@ -353,119 +353,6 @@ static int encrypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat, ...@@ -353,119 +353,6 @@ static int encrypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
return rc; return rc;
} }
static void
ecryptfs_extent_to_lwr_pg_idx_and_offset(unsigned long *lower_page_idx,
int *byte_offset,
struct ecryptfs_crypt_stat *crypt_stat,
unsigned long extent_num)
{
unsigned long lower_extent_num;
int extents_occupied_by_headers_at_front;
int bytes_occupied_by_headers_at_front;
int extent_offset;
int extents_per_page;
bytes_occupied_by_headers_at_front =
(crypt_stat->extent_size
* crypt_stat->num_header_extents_at_front);
extents_occupied_by_headers_at_front =
( bytes_occupied_by_headers_at_front
/ crypt_stat->extent_size );
lower_extent_num = extents_occupied_by_headers_at_front + extent_num;
extents_per_page = PAGE_CACHE_SIZE / crypt_stat->extent_size;
(*lower_page_idx) = lower_extent_num / extents_per_page;
extent_offset = lower_extent_num % extents_per_page;
(*byte_offset) = extent_offset * crypt_stat->extent_size;
ecryptfs_printk(KERN_DEBUG, " * crypt_stat->extent_size = "
"[%d]\n", crypt_stat->extent_size);
ecryptfs_printk(KERN_DEBUG, " * crypt_stat->"
"num_header_extents_at_front = [%d]\n",
crypt_stat->num_header_extents_at_front);
ecryptfs_printk(KERN_DEBUG, " * extents_occupied_by_headers_at_"
"front = [%d]\n", extents_occupied_by_headers_at_front);
ecryptfs_printk(KERN_DEBUG, " * lower_extent_num = [0x%.16x]\n",
lower_extent_num);
ecryptfs_printk(KERN_DEBUG, " * extents_per_page = [%d]\n",
extents_per_page);
ecryptfs_printk(KERN_DEBUG, " * (*lower_page_idx) = [0x%.16x]\n",
(*lower_page_idx));
ecryptfs_printk(KERN_DEBUG, " * extent_offset = [%d]\n",
extent_offset);
ecryptfs_printk(KERN_DEBUG, " * (*byte_offset) = [%d]\n",
(*byte_offset));
}
static int ecryptfs_write_out_page(struct ecryptfs_page_crypt_context *ctx,
struct page *lower_page,
struct inode *lower_inode,
int byte_offset_in_page, int bytes_to_write)
{
int rc = 0;
if (ctx->mode == ECRYPTFS_PREPARE_COMMIT_MODE) {
rc = ecryptfs_commit_lower_page(lower_page, lower_inode,
ctx->param.lower_file,
byte_offset_in_page,
bytes_to_write);
if (rc) {
ecryptfs_printk(KERN_ERR, "Error calling lower "
"commit; rc = [%d]\n", rc);
goto out;
}
} else {
rc = ecryptfs_writepage_and_release_lower_page(lower_page,
lower_inode,
ctx->param.wbc);
if (rc) {
ecryptfs_printk(KERN_ERR, "Error calling lower "
"writepage(); rc = [%d]\n", rc);
goto out;
}
}
out:
return rc;
}
static int ecryptfs_read_in_page(struct ecryptfs_page_crypt_context *ctx,
struct page **lower_page,
struct inode *lower_inode,
unsigned long lower_page_idx,
int byte_offset_in_page)
{
int rc = 0;
if (ctx->mode == ECRYPTFS_PREPARE_COMMIT_MODE) {
/* TODO: Limit this to only the data extents that are
* needed */
rc = ecryptfs_get_lower_page(lower_page, lower_inode,
ctx->param.lower_file,
lower_page_idx,
byte_offset_in_page,
(PAGE_CACHE_SIZE
- byte_offset_in_page));
if (rc) {
ecryptfs_printk(
KERN_ERR, "Error attempting to grab, map, "
"and prepare_write lower page with index "
"[0x%.16x]; rc = [%d]\n", lower_page_idx, rc);
goto out;
}
} else {
*lower_page = grab_cache_page(lower_inode->i_mapping,
lower_page_idx);
if (!(*lower_page)) {
rc = -EINVAL;
ecryptfs_printk(
KERN_ERR, "Error attempting to grab and map "
"lower page with index [0x%.16x]; rc = [%d]\n",
lower_page_idx, rc);
goto out;
}
}
out:
return rc;
}
/** /**
* ecryptfs_lower_offset_for_extent * ecryptfs_lower_offset_for_extent
* *
...@@ -1306,43 +1193,6 @@ int ecryptfs_cipher_code_to_string(char *str, u16 cipher_code) ...@@ -1306,43 +1193,6 @@ int ecryptfs_cipher_code_to_string(char *str, u16 cipher_code)
return rc; return rc;
} }
/**
* ecryptfs_read_header_region
* @data: The virtual address to write header region data into
* @dentry: The lower dentry
* @mnt: The lower VFS mount
*
* Returns zero on success; non-zero otherwise
*/
static int ecryptfs_read_header_region(char *data, struct dentry *dentry,
struct vfsmount *mnt)
{
struct file *lower_file;
mm_segment_t oldfs;
int rc;
rc = ecryptfs_open_lower_file(&lower_file, dentry, mnt, O_RDONLY);
if (rc) {
printk(KERN_ERR
"Error opening lower_file to read header region\n");
goto out;
}
lower_file->f_pos = 0;
oldfs = get_fs();
set_fs(get_ds());
rc = lower_file->f_op->read(lower_file, (char __user *)data,
ECRYPTFS_DEFAULT_EXTENT_SIZE, &lower_file->f_pos);
set_fs(oldfs);
rc = ecryptfs_close_lower_file(lower_file);
if (rc) {
printk(KERN_ERR "Error closing lower_file\n");
goto out;
}
rc = 0;
out:
return rc;
}
int ecryptfs_read_and_validate_header_region(char *data, int ecryptfs_read_and_validate_header_region(char *data,
struct inode *ecryptfs_inode) struct inode *ecryptfs_inode)
{ {
......
...@@ -552,22 +552,7 @@ void ecryptfs_destroy_crypt_stat(struct ecryptfs_crypt_stat *crypt_stat); ...@@ -552,22 +552,7 @@ void ecryptfs_destroy_crypt_stat(struct ecryptfs_crypt_stat *crypt_stat);
void ecryptfs_destroy_mount_crypt_stat( void ecryptfs_destroy_mount_crypt_stat(
struct ecryptfs_mount_crypt_stat *mount_crypt_stat); struct ecryptfs_mount_crypt_stat *mount_crypt_stat);
int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat); int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat);
int ecryptfs_write_inode_size_to_metadata(struct inode *ecryptefs_inode); int ecryptfs_write_inode_size_to_metadata(struct inode *ecryptfs_inode);
int ecryptfs_get_lower_page(struct page **lower_page, struct inode *lower_inode,
struct file *lower_file,
unsigned long lower_page_index, int byte_offset,
int region_bytes);
int
ecryptfs_commit_lower_page(struct page *lower_page, struct inode *lower_inode,
struct file *lower_file, int byte_offset,
int region_size);
int ecryptfs_copy_page_to_lower(struct page *page, struct inode *lower_inode,
struct file *lower_file);
int ecryptfs_do_readpage(struct file *file, struct page *page,
pgoff_t lower_page_index);
int ecryptfs_writepage_and_release_lower_page(struct page *lower_page,
struct inode *lower_inode,
struct writeback_control *wbc);
int ecryptfs_encrypt_page(struct page *page); int ecryptfs_encrypt_page(struct page *page);
int ecryptfs_decrypt_page(struct page *page); int ecryptfs_decrypt_page(struct page *page);
int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry); int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry);
...@@ -591,10 +576,6 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length); ...@@ -591,10 +576,6 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length);
int ecryptfs_inode_test(struct inode *inode, void *candidate_lower_inode); int ecryptfs_inode_test(struct inode *inode, void *candidate_lower_inode);
int ecryptfs_inode_set(struct inode *inode, void *lower_inode); int ecryptfs_inode_set(struct inode *inode, void *lower_inode);
void ecryptfs_init_inode(struct inode *inode, struct inode *lower_inode); void ecryptfs_init_inode(struct inode *inode, struct inode *lower_inode);
int ecryptfs_open_lower_file(struct file **lower_file,
struct dentry *lower_dentry,
struct vfsmount *lower_mnt, int flags);
int ecryptfs_close_lower_file(struct file *lower_file);
ssize_t ecryptfs_getxattr(struct dentry *dentry, const char *name, void *value, ssize_t ecryptfs_getxattr(struct dentry *dentry, const char *name, void *value,
size_t size); size_t size);
ssize_t ssize_t
......
...@@ -141,34 +141,6 @@ static int ecryptfs_readdir(struct file *file, void *dirent, filldir_t filldir) ...@@ -141,34 +141,6 @@ static int ecryptfs_readdir(struct file *file, void *dirent, filldir_t filldir)
struct kmem_cache *ecryptfs_file_info_cache; struct kmem_cache *ecryptfs_file_info_cache;
int ecryptfs_open_lower_file(struct file **lower_file,
struct dentry *lower_dentry,
struct vfsmount *lower_mnt, int flags)
{
int rc = 0;
flags |= O_LARGEFILE;
dget(lower_dentry);
mntget(lower_mnt);
*lower_file = dentry_open(lower_dentry, lower_mnt, flags);
if (IS_ERR(*lower_file)) {
printk(KERN_ERR "Error opening lower file for lower_dentry "
"[0x%p], lower_mnt [0x%p], and flags [0x%x]\n",
lower_dentry, lower_mnt, flags);
rc = PTR_ERR(*lower_file);
*lower_file = NULL;
goto out;
}
out:
return rc;
}
int ecryptfs_close_lower_file(struct file *lower_file)
{
fput(lower_file);
return 0;
}
/** /**
* ecryptfs_open * ecryptfs_open
* @inode: inode speciying file to open * @inode: inode speciying file to open
......
...@@ -670,11 +670,6 @@ static struct ecryptfs_cache_info { ...@@ -670,11 +670,6 @@ static struct ecryptfs_cache_info {
.name = "ecryptfs_xattr_cache", .name = "ecryptfs_xattr_cache",
.size = PAGE_CACHE_SIZE, .size = PAGE_CACHE_SIZE,
}, },
{
.cache = &ecryptfs_lower_page_cache,
.name = "ecryptfs_lower_page_cache",
.size = PAGE_CACHE_SIZE,
},
{ {
.cache = &ecryptfs_key_record_cache, .cache = &ecryptfs_key_record_cache,
.name = "ecryptfs_key_record_cache", .name = "ecryptfs_key_record_cache",
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment