mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
[PATCH] new helper: d_obtain_alias
The calling conventions of d_alloc_anon are rather unfortunate for all users, and it's name is not very descriptive either. Add d_obtain_alias as a new exported helper that drops the inode reference in the failure case, too and allows to pass-through NULL pointers and inodes to allow for tail-calls in the export operations. Incidentally this helper already existed as a private function in libfs.c as exportfs_d_alloc so kill that one and switch the callers to d_obtain_alias. Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Al Viro <[email protected]>
This commit is contained in:
parent
3a8cff4f02
commit
4ea3ada295
3 changed files with 38 additions and 24 deletions
26
fs/libfs.c
26
fs/libfs.c
|
|
@ -732,28 +732,6 @@ out:
|
|||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is what d_alloc_anon should have been. Once the exportfs
|
||||
* argument transition has been finished I will update d_alloc_anon
|
||||
* to this prototype and this wrapper will go away. --hch
|
||||
*/
|
||||
static struct dentry *exportfs_d_alloc(struct inode *inode)
|
||||
{
|
||||
struct dentry *dentry;
|
||||
|
||||
if (!inode)
|
||||
return NULL;
|
||||
if (IS_ERR(inode))
|
||||
return ERR_PTR(PTR_ERR(inode));
|
||||
|
||||
dentry = d_alloc_anon(inode);
|
||||
if (!dentry) {
|
||||
iput(inode);
|
||||
dentry = ERR_PTR(-ENOMEM);
|
||||
}
|
||||
return dentry;
|
||||
}
|
||||
|
||||
/**
|
||||
* generic_fh_to_dentry - generic helper for the fh_to_dentry export operation
|
||||
* @sb: filesystem to do the file handle conversion on
|
||||
|
|
@ -782,7 +760,7 @@ struct dentry *generic_fh_to_dentry(struct super_block *sb, struct fid *fid,
|
|||
break;
|
||||
}
|
||||
|
||||
return exportfs_d_alloc(inode);
|
||||
return d_obtain_alias(inode);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(generic_fh_to_dentry);
|
||||
|
||||
|
|
@ -815,7 +793,7 @@ struct dentry *generic_fh_to_parent(struct super_block *sb, struct fid *fid,
|
|||
break;
|
||||
}
|
||||
|
||||
return exportfs_d_alloc(inode);
|
||||
return d_obtain_alias(inode);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(generic_fh_to_parent);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue