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: Tahsin Erdogan <tahsin@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 53698f8..f16a908 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -312,40 +312,47 @@
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);
- if (IS_ERR(ea_inode) || is_bad_inode(ea_inode)) {
- int rc = IS_ERR(ea_inode) ? PTR_ERR(ea_inode) : 0;
+ inode = ext4_iget(parent->i_sb, ea_ino);
+ if (IS_ERR(inode)) {
+ err = PTR_ERR(inode);
ext4_error(parent->i_sb, "error while reading EA inode %lu "
- "/ %d %d", ea_ino, rc, is_bad_inode(ea_inode));
- *err = rc != 0 ? rc : -EIO;
- return NULL;
+ "err=%d", ea_ino, err);
+ return err;
}
- if (EXT4_XATTR_INODE_GET_PARENT(ea_inode) != parent->i_ino ||
- ea_inode->i_generation != parent->i_generation) {
- ext4_error(parent->i_sb, "Backpointer from EA inode %lu "
- "to parent invalid.", ea_ino);
- *err = -EINVAL;
+ 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_I(ea_inode)->i_flags & EXT4_EA_INODE_FL)) {
+ if (EXT4_XATTR_INODE_GET_PARENT(inode) != parent->i_ino ||
+ inode->i_generation != parent->i_generation) {
+ ext4_error(parent->i_sb, "Backpointer from EA inode %lu "
+ "to parent is invalid.", ea_ino);
+ err = -EINVAL;
+ goto error;
+ }
+
+ if (!(EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL)) {
ext4_error(parent->i_sb, "EA inode %lu does not have "
"EXT4_EA_INODE_FL flag set.\n", ea_ino);
- *err = -EINVAL;
+ err = -EINVAL;
goto error;
}
- *err = 0;
- return ea_inode;
-
+ *ea_inode = inode;
+ return 0;
error:
- iput(ea_inode);
- return NULL;
+ iput(inode);
+ return err;
}
/*
@@ -355,17 +362,17 @@
ext4_xattr_inode_get(struct inode *inode, unsigned long ea_ino, void *buffer,
size_t *size)
{
- struct inode *ea_inode = NULL;
- int err;
+ struct inode *ea_inode;
+ int ret;
- ea_inode = ext4_xattr_inode_iget(inode, ea_ino, &err);
- if (err)
- return err;
+ ret = ext4_xattr_inode_iget(inode, ea_ino, &ea_inode);
+ if (ret)
+ return ret;
- err = ext4_xattr_inode_read(ea_inode, buffer, size);
+ ret = ext4_xattr_inode_read(ea_inode, buffer, size);
iput(ea_inode);
- return err;
+ return ret;
}
static int
@@ -866,7 +873,7 @@
struct inode *ea_inode = NULL;
int err;
- ea_inode = ext4_xattr_inode_iget(inode, ea_ino, &err);
+ err = ext4_xattr_inode_iget(inode, ea_ino, &ea_inode);
if (err)
return err;
@@ -1946,7 +1953,7 @@
ext4_xattr_inode_orphan_add(handle_t *handle, struct inode *inode,
int credits, struct ext4_xattr_ino_array *lea_ino_array)
{
- struct inode *ea_inode = NULL;
+ struct inode *ea_inode;
int idx = 0, error = 0;
if (lea_ino_array == NULL)
@@ -1965,8 +1972,8 @@
return error;
}
}
- ea_inode = ext4_xattr_inode_iget(inode,
- lea_ino_array->xia_inodes[idx], &error);
+ error = ext4_xattr_inode_iget(inode,
+ lea_ino_array->xia_inodes[idx], &ea_inode);
if (error)
continue;
inode_lock(ea_inode);
@@ -2083,7 +2090,7 @@
ext4_xattr_inode_array_free(struct inode *inode,
struct ext4_xattr_ino_array *lea_ino_array)
{
- struct inode *ea_inode = NULL;
+ struct inode *ea_inode;
int idx = 0;
int err;
@@ -2091,8 +2098,8 @@
return;
for (; idx < lea_ino_array->xia_count; ++idx) {
- ea_inode = ext4_xattr_inode_iget(inode,
- lea_ino_array->xia_inodes[idx], &err);
+ err = ext4_xattr_inode_iget(inode,
+ lea_ino_array->xia_inodes[idx], &ea_inode);
if (err)
continue;
/* for inode's i_count get from ext4_xattr_delete_inode */