fs/adfs: map: factor out map cleanup
We have several places which deal with releasing the map buffers and freeing the map array. Provide a helper for this. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
6092b6be30
commit
7b19526762
|
@ -147,6 +147,7 @@ int adfs_notify_change(struct dentry *dentry, struct iattr *attr);
|
||||||
int adfs_map_lookup(struct super_block *sb, u32 frag_id, unsigned int offset);
|
int adfs_map_lookup(struct super_block *sb, u32 frag_id, unsigned int offset);
|
||||||
void adfs_map_statfs(struct super_block *sb, struct kstatfs *buf);
|
void adfs_map_statfs(struct super_block *sb, struct kstatfs *buf);
|
||||||
struct adfs_discmap *adfs_read_map(struct super_block *sb, struct adfs_discrecord *dr);
|
struct adfs_discmap *adfs_read_map(struct super_block *sb, struct adfs_discrecord *dr);
|
||||||
|
void adfs_free_map(struct super_block *sb);
|
||||||
|
|
||||||
/* Misc */
|
/* Misc */
|
||||||
__printf(3, 4)
|
__printf(3, 4)
|
||||||
|
|
|
@ -421,3 +421,11 @@ error_free:
|
||||||
kfree(dm);
|
kfree(dm);
|
||||||
return ERR_PTR(-EIO);
|
return ERR_PTR(-EIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void adfs_free_map(struct super_block *sb)
|
||||||
|
{
|
||||||
|
struct adfs_sb_info *asb = ADFS_SB(sb);
|
||||||
|
|
||||||
|
adfs_map_relse(asb->s_map, asb->s_map_size);
|
||||||
|
kfree(asb->s_map);
|
||||||
|
}
|
||||||
|
|
|
@ -90,12 +90,9 @@ static int adfs_checkdiscrecord(struct adfs_discrecord *dr)
|
||||||
|
|
||||||
static void adfs_put_super(struct super_block *sb)
|
static void adfs_put_super(struct super_block *sb)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
struct adfs_sb_info *asb = ADFS_SB(sb);
|
struct adfs_sb_info *asb = ADFS_SB(sb);
|
||||||
|
|
||||||
for (i = 0; i < asb->s_map_size; i++)
|
adfs_free_map(sb);
|
||||||
brelse(asb->s_map[i].dm_bh);
|
|
||||||
kfree(asb->s_map);
|
|
||||||
kfree_rcu(asb, rcu);
|
kfree_rcu(asb, rcu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,10 +409,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
root = adfs_iget(sb, &root_obj);
|
root = adfs_iget(sb, &root_obj);
|
||||||
sb->s_root = d_make_root(root);
|
sb->s_root = d_make_root(root);
|
||||||
if (!sb->s_root) {
|
if (!sb->s_root) {
|
||||||
int i;
|
adfs_free_map(sb);
|
||||||
for (i = 0; i < asb->s_map_size; i++)
|
|
||||||
brelse(asb->s_map[i].dm_bh);
|
|
||||||
kfree(asb->s_map);
|
|
||||||
adfs_error(sb, "get root inode failed\n");
|
adfs_error(sb, "get root inode failed\n");
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
goto error;
|
goto error;
|
||||||
|
|
Loading…
Reference in New Issue