Commit bab79b04 authored by Tahsin Erdogan's avatar Tahsin Erdogan Committed by Theodore Ts'o

ext4: change ext4_xattr_inode_iget() signature

In general, kernel functions indicate success/failure through their return
values. This function returns the status as an output parameter and reserves
the return value for the inode. Make it follow the general convention.
Signed-off-by: default avatarTahsin Erdogan <tahsin@google.com>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 0eefb107
...@@ -312,40 +312,47 @@ ext4_xattr_inode_read(struct inode *ea_inode, void *buf, size_t *size) ...@@ -312,40 +312,47 @@ ext4_xattr_inode_read(struct inode *ea_inode, void *buf, size_t *size)
return 0; return 0;
} }
struct inode *ext4_xattr_inode_iget(struct inode *parent, unsigned long ea_ino, int *err) static int ext4_xattr_inode_iget(struct inode *parent, unsigned long ea_ino,
struct inode **ea_inode)
{ {
struct inode *ea_inode = NULL; struct inode *inode;
int err;
ea_inode = ext4_iget(parent->i_sb, ea_ino); inode = ext4_iget(parent->i_sb, ea_ino);
if (IS_ERR(ea_inode) || is_bad_inode(ea_inode)) { if (IS_ERR(inode)) {
int rc = IS_ERR(ea_inode) ? PTR_ERR(ea_inode) : 0; err = PTR_ERR(inode);
ext4_error(parent->i_sb, "error while reading EA inode %lu " ext4_error(parent->i_sb, "error while reading EA inode %lu "
"/ %d %d", ea_ino, rc, is_bad_inode(ea_inode)); "err=%d", ea_ino, err);
*err = rc != 0 ? rc : -EIO; return err;
return NULL; }
if (is_bad_inode(inode)) {
ext4_error(parent->i_sb, "error while reading EA inode %lu "
"is_bad_inode", ea_ino);
err = -EIO;
goto error;
} }
if (EXT4_XATTR_INODE_GET_PARENT(ea_inode) != parent->i_ino || if (EXT4_XATTR_INODE_GET_PARENT(inode) != parent->i_ino ||
ea_inode->i_generation != parent->i_generation) { inode->i_generation != parent->i_generation) {
ext4_error(parent->i_sb, "Backpointer from EA inode %lu " ext4_error(parent->i_sb, "Backpointer from EA inode %lu "
"to parent invalid.", ea_ino); "to parent is invalid.", ea_ino);
*err = -EINVAL; err = -EINVAL;
goto error; goto error;
} }
if (!(EXT4_I(ea_inode)->i_flags & EXT4_EA_INODE_FL)) { if (!(EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL)) {
ext4_error(parent->i_sb, "EA inode %lu does not have " ext4_error(parent->i_sb, "EA inode %lu does not have "
"EXT4_EA_INODE_FL flag set.\n", ea_ino); "EXT4_EA_INODE_FL flag set.\n", ea_ino);
*err = -EINVAL; err = -EINVAL;
goto error; goto error;
} }
*err = 0; *ea_inode = inode;
return ea_inode; return 0;
error: error:
iput(ea_inode); iput(inode);
return NULL; return err;
} }
/* /*
...@@ -355,17 +362,17 @@ static int ...@@ -355,17 +362,17 @@ static int
ext4_xattr_inode_get(struct inode *inode, unsigned long ea_ino, void *buffer, ext4_xattr_inode_get(struct inode *inode, unsigned long ea_ino, void *buffer,
size_t *size) size_t *size)
{ {
struct inode *ea_inode = NULL; struct inode *ea_inode;
int err; int ret;
ea_inode = ext4_xattr_inode_iget(inode, ea_ino, &err); ret = ext4_xattr_inode_iget(inode, ea_ino, &ea_inode);
if (err) if (ret)
return err; return ret;
err = ext4_xattr_inode_read(ea_inode, buffer, size); ret = ext4_xattr_inode_read(ea_inode, buffer, size);
iput(ea_inode); iput(ea_inode);
return err; return ret;
} }
static int static int
...@@ -866,7 +873,7 @@ int ext4_xattr_inode_unlink(struct inode *inode, unsigned long ea_ino) ...@@ -866,7 +873,7 @@ int ext4_xattr_inode_unlink(struct inode *inode, unsigned long ea_ino)
struct inode *ea_inode = NULL; struct inode *ea_inode = NULL;
int err; int err;
ea_inode = ext4_xattr_inode_iget(inode, ea_ino, &err); err = ext4_xattr_inode_iget(inode, ea_ino, &ea_inode);
if (err) if (err)
return err; return err;
...@@ -1946,7 +1953,7 @@ static int ...@@ -1946,7 +1953,7 @@ static int
ext4_xattr_inode_orphan_add(handle_t *handle, struct inode *inode, ext4_xattr_inode_orphan_add(handle_t *handle, struct inode *inode,
int credits, struct ext4_xattr_ino_array *lea_ino_array) int credits, struct ext4_xattr_ino_array *lea_ino_array)
{ {
struct inode *ea_inode = NULL; struct inode *ea_inode;
int idx = 0, error = 0; int idx = 0, error = 0;
if (lea_ino_array == NULL) if (lea_ino_array == NULL)
...@@ -1965,8 +1972,8 @@ ext4_xattr_inode_orphan_add(handle_t *handle, struct inode *inode, ...@@ -1965,8 +1972,8 @@ ext4_xattr_inode_orphan_add(handle_t *handle, struct inode *inode,
return error; return error;
} }
} }
ea_inode = ext4_xattr_inode_iget(inode, error = ext4_xattr_inode_iget(inode,
lea_ino_array->xia_inodes[idx], &error); lea_ino_array->xia_inodes[idx], &ea_inode);
if (error) if (error)
continue; continue;
inode_lock(ea_inode); inode_lock(ea_inode);
...@@ -2083,7 +2090,7 @@ void ...@@ -2083,7 +2090,7 @@ void
ext4_xattr_inode_array_free(struct inode *inode, ext4_xattr_inode_array_free(struct inode *inode,
struct ext4_xattr_ino_array *lea_ino_array) struct ext4_xattr_ino_array *lea_ino_array)
{ {
struct inode *ea_inode = NULL; struct inode *ea_inode;
int idx = 0; int idx = 0;
int err; int err;
...@@ -2091,8 +2098,8 @@ ext4_xattr_inode_array_free(struct inode *inode, ...@@ -2091,8 +2098,8 @@ ext4_xattr_inode_array_free(struct inode *inode,
return; return;
for (; idx < lea_ino_array->xia_count; ++idx) { for (; idx < lea_ino_array->xia_count; ++idx) {
ea_inode = ext4_xattr_inode_iget(inode, err = ext4_xattr_inode_iget(inode,
lea_ino_array->xia_inodes[idx], &err); lea_ino_array->xia_inodes[idx], &ea_inode);
if (err) if (err)
continue; continue;
/* for inode's i_count get from ext4_xattr_delete_inode */ /* for inode's i_count get from ext4_xattr_delete_inode */
......
...@@ -161,8 +161,6 @@ extern int ext4_xattr_get(struct inode *, int, const char *, void *, size_t); ...@@ -161,8 +161,6 @@ extern int ext4_xattr_get(struct inode *, int, const char *, void *, size_t);
extern int ext4_xattr_set(struct inode *, int, const char *, const void *, size_t, int); extern int ext4_xattr_set(struct inode *, int, const char *, const void *, size_t, int);
extern int ext4_xattr_set_handle(handle_t *, struct inode *, int, const char *, const void *, size_t, int); extern int ext4_xattr_set_handle(handle_t *, struct inode *, int, const char *, const void *, size_t, int);
extern struct inode *ext4_xattr_inode_iget(struct inode *parent, unsigned long ea_ino,
int *err);
extern int ext4_xattr_inode_unlink(struct inode *inode, unsigned long ea_ino); extern int ext4_xattr_inode_unlink(struct inode *inode, unsigned long ea_ino);
extern int ext4_xattr_delete_inode(handle_t *handle, struct inode *inode, extern int ext4_xattr_delete_inode(handle_t *handle, struct inode *inode,
struct ext4_xattr_ino_array **array); struct ext4_xattr_ino_array **array);
......
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