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;
+
+ 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 "
+ "err=%d", ea_ino, err);
+ return 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;
+ if (is_bad_inode(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;
+ "is_bad_inode", ea_ino);
+ err = -EIO;
+ goto error;
}
- if (EXT4_XATTR_INODE_GET_PARENT(ea_inode) != parent->i_ino ||
- ea_inode->i_generation != parent->i_generation) {
+ 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 invalid.", ea_ino);
- *err = -EINVAL;
+ "to parent is invalid.", ea_ino);
+ err = -EINVAL;
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_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;
}
/*
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
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;
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)
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);
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;
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 */