ext4 crypto: simplify interfaces to directory entry insert functions

A number of functions include ext4_add_dx_entry, make_indexed_dir,
etc. are being passed a dentry even though the only thing they use is
the containing parent.  We can shrink the code size slightly by making
this replacement.  This will also be useful in cases where we don't
have a dentry as the argument to the directory entry insert functions.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
Theodore Ts'o 2016-01-08 16:00:31 -05:00
parent db7730e309
commit 56a04915df
3 changed files with 11 additions and 17 deletions

View File

@ -3004,8 +3004,7 @@ extern int ext4_da_write_inline_data_end(struct inode *inode, loff_t pos,
struct page *page); struct page *page);
extern int ext4_try_add_inline_entry(handle_t *handle, extern int ext4_try_add_inline_entry(handle_t *handle,
struct ext4_filename *fname, struct ext4_filename *fname,
struct dentry *dentry, struct inode *dir, struct inode *inode);
struct inode *inode);
extern int ext4_try_create_inline_dir(handle_t *handle, extern int ext4_try_create_inline_dir(handle_t *handle,
struct inode *parent, struct inode *parent,
struct inode *inode); struct inode *inode);

View File

@ -995,12 +995,11 @@ void ext4_show_inline_dir(struct inode *dir, struct buffer_head *bh,
*/ */
static int ext4_add_dirent_to_inline(handle_t *handle, static int ext4_add_dirent_to_inline(handle_t *handle,
struct ext4_filename *fname, struct ext4_filename *fname,
struct dentry *dentry, struct inode *dir,
struct inode *inode, struct inode *inode,
struct ext4_iloc *iloc, struct ext4_iloc *iloc,
void *inline_start, int inline_size) void *inline_start, int inline_size)
{ {
struct inode *dir = d_inode(dentry->d_parent);
int err; int err;
struct ext4_dir_entry_2 *de; struct ext4_dir_entry_2 *de;
@ -1245,12 +1244,11 @@ out:
* the new created block. * the new created block.
*/ */
int ext4_try_add_inline_entry(handle_t *handle, struct ext4_filename *fname, int ext4_try_add_inline_entry(handle_t *handle, struct ext4_filename *fname,
struct dentry *dentry, struct inode *inode) struct inode *dir, struct inode *inode)
{ {
int ret, inline_size; int ret, inline_size;
void *inline_start; void *inline_start;
struct ext4_iloc iloc; struct ext4_iloc iloc;
struct inode *dir = d_inode(dentry->d_parent);
ret = ext4_get_inode_loc(dir, &iloc); ret = ext4_get_inode_loc(dir, &iloc);
if (ret) if (ret)
@ -1264,7 +1262,7 @@ int ext4_try_add_inline_entry(handle_t *handle, struct ext4_filename *fname,
EXT4_INLINE_DOTDOT_SIZE; EXT4_INLINE_DOTDOT_SIZE;
inline_size = EXT4_MIN_INLINE_DATA_SIZE - EXT4_INLINE_DOTDOT_SIZE; inline_size = EXT4_MIN_INLINE_DATA_SIZE - EXT4_INLINE_DOTDOT_SIZE;
ret = ext4_add_dirent_to_inline(handle, fname, dentry, inode, &iloc, ret = ext4_add_dirent_to_inline(handle, fname, dir, inode, &iloc,
inline_start, inline_size); inline_start, inline_size);
if (ret != -ENOSPC) if (ret != -ENOSPC)
goto out; goto out;
@ -1285,7 +1283,7 @@ int ext4_try_add_inline_entry(handle_t *handle, struct ext4_filename *fname,
if (inline_size) { if (inline_size) {
inline_start = ext4_get_inline_xattr_pos(dir, &iloc); inline_start = ext4_get_inline_xattr_pos(dir, &iloc);
ret = ext4_add_dirent_to_inline(handle, fname, dentry, ret = ext4_add_dirent_to_inline(handle, fname, dir,
inode, &iloc, inline_start, inode, &iloc, inline_start,
inline_size); inline_size);

View File

@ -273,7 +273,7 @@ static struct buffer_head * ext4_dx_find_entry(struct inode *dir,
struct ext4_filename *fname, struct ext4_filename *fname,
struct ext4_dir_entry_2 **res_dir); struct ext4_dir_entry_2 **res_dir);
static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname, static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname,
struct dentry *dentry, struct inode *inode); struct inode *dir, struct inode *inode);
/* checksumming functions */ /* checksumming functions */
void initialize_dirent_tail(struct ext4_dir_entry_tail *t, void initialize_dirent_tail(struct ext4_dir_entry_tail *t,
@ -1928,10 +1928,9 @@ static int add_dirent_to_buf(handle_t *handle, struct ext4_filename *fname,
* directory, and adds the dentry to the indexed directory. * directory, and adds the dentry to the indexed directory.
*/ */
static int make_indexed_dir(handle_t *handle, struct ext4_filename *fname, static int make_indexed_dir(handle_t *handle, struct ext4_filename *fname,
struct dentry *dentry, struct inode *dir,
struct inode *inode, struct buffer_head *bh) struct inode *inode, struct buffer_head *bh)
{ {
struct inode *dir = d_inode(dentry->d_parent);
struct buffer_head *bh2; struct buffer_head *bh2;
struct dx_root *root; struct dx_root *root;
struct dx_frame frames[2], *frame; struct dx_frame frames[2], *frame;
@ -2086,8 +2085,7 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
return retval; return retval;
if (ext4_has_inline_data(dir)) { if (ext4_has_inline_data(dir)) {
retval = ext4_try_add_inline_entry(handle, &fname, retval = ext4_try_add_inline_entry(handle, &fname, dir, inode);
dentry, inode);
if (retval < 0) if (retval < 0)
goto out; goto out;
if (retval == 1) { if (retval == 1) {
@ -2097,7 +2095,7 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
} }
if (is_dx(dir)) { if (is_dx(dir)) {
retval = ext4_dx_add_entry(handle, &fname, dentry, inode); retval = ext4_dx_add_entry(handle, &fname, dir, inode);
if (!retval || (retval != ERR_BAD_DX_DIR)) if (!retval || (retval != ERR_BAD_DX_DIR))
goto out; goto out;
ext4_clear_inode_flag(dir, EXT4_INODE_INDEX); ext4_clear_inode_flag(dir, EXT4_INODE_INDEX);
@ -2119,7 +2117,7 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
if (blocks == 1 && !dx_fallback && if (blocks == 1 && !dx_fallback &&
ext4_has_feature_dir_index(sb)) { ext4_has_feature_dir_index(sb)) {
retval = make_indexed_dir(handle, &fname, dentry, retval = make_indexed_dir(handle, &fname, dir,
inode, bh); inode, bh);
bh = NULL; /* make_indexed_dir releases bh */ bh = NULL; /* make_indexed_dir releases bh */
goto out; goto out;
@ -2154,12 +2152,11 @@ out:
* Returns 0 for success, or a negative error value * Returns 0 for success, or a negative error value
*/ */
static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname, static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname,
struct dentry *dentry, struct inode *inode) struct inode *dir, struct inode *inode)
{ {
struct dx_frame frames[2], *frame; struct dx_frame frames[2], *frame;
struct dx_entry *entries, *at; struct dx_entry *entries, *at;
struct buffer_head *bh; struct buffer_head *bh;
struct inode *dir = d_inode(dentry->d_parent);
struct super_block *sb = dir->i_sb; struct super_block *sb = dir->i_sb;
struct ext4_dir_entry_2 *de; struct ext4_dir_entry_2 *de;
int err; int err;