mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
NFS: Create a new nfs_alloc_fattr_with_label() function
For creating fattrs with the label field already allocated for us. I also update nfs_free_fattr() to free the label in the end. Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
This commit is contained in:
parent
d4a95a7e5a
commit
d755ad8dc7
4 changed files with 36 additions and 20 deletions
|
@ -80,18 +80,15 @@ int nfs_get_root(struct super_block *s, struct fs_context *fc)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* get the actual root for this mount */
|
/* get the actual root for this mount */
|
||||||
fsinfo.fattr = nfs_alloc_fattr();
|
fsinfo.fattr = nfs_alloc_fattr_with_label(server);
|
||||||
if (fsinfo.fattr == NULL)
|
if (fsinfo.fattr == NULL)
|
||||||
goto out_name;
|
goto out_name;
|
||||||
|
|
||||||
fsinfo.fattr->label = nfs4_label_alloc(server, GFP_KERNEL);
|
|
||||||
if (IS_ERR(fsinfo.fattr->label))
|
|
||||||
goto out_fattr;
|
|
||||||
error = server->nfs_client->rpc_ops->getroot(server, ctx->mntfh, &fsinfo);
|
error = server->nfs_client->rpc_ops->getroot(server, ctx->mntfh, &fsinfo);
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
dprintk("nfs_get_root: getattr error = %d\n", -error);
|
dprintk("nfs_get_root: getattr error = %d\n", -error);
|
||||||
nfs_errorf(fc, "NFS: Couldn't getattr on root");
|
nfs_errorf(fc, "NFS: Couldn't getattr on root");
|
||||||
goto out_label;
|
goto out_fattr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inode = nfs_fhget(s, ctx->mntfh, fsinfo.fattr, NULL);
|
inode = nfs_fhget(s, ctx->mntfh, fsinfo.fattr, NULL);
|
||||||
|
@ -99,12 +96,12 @@ int nfs_get_root(struct super_block *s, struct fs_context *fc)
|
||||||
dprintk("nfs_get_root: get root inode failed\n");
|
dprintk("nfs_get_root: get root inode failed\n");
|
||||||
error = PTR_ERR(inode);
|
error = PTR_ERR(inode);
|
||||||
nfs_errorf(fc, "NFS: Couldn't get root inode");
|
nfs_errorf(fc, "NFS: Couldn't get root inode");
|
||||||
goto out_label;
|
goto out_fattr;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = nfs_superblock_set_dummy_root(s, inode);
|
error = nfs_superblock_set_dummy_root(s, inode);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
goto out_label;
|
goto out_fattr;
|
||||||
|
|
||||||
/* root dentries normally start off anonymous and get spliced in later
|
/* root dentries normally start off anonymous and get spliced in later
|
||||||
* if the dentry tree reaches them; however if the dentry already
|
* if the dentry tree reaches them; however if the dentry already
|
||||||
|
@ -115,7 +112,7 @@ int nfs_get_root(struct super_block *s, struct fs_context *fc)
|
||||||
dprintk("nfs_get_root: get root dentry failed\n");
|
dprintk("nfs_get_root: get root dentry failed\n");
|
||||||
error = PTR_ERR(root);
|
error = PTR_ERR(root);
|
||||||
nfs_errorf(fc, "NFS: Couldn't get root dentry");
|
nfs_errorf(fc, "NFS: Couldn't get root dentry");
|
||||||
goto out_label;
|
goto out_fattr;
|
||||||
}
|
}
|
||||||
|
|
||||||
security_d_instantiate(root, inode);
|
security_d_instantiate(root, inode);
|
||||||
|
@ -154,8 +151,6 @@ int nfs_get_root(struct super_block *s, struct fs_context *fc)
|
||||||
nfs_setsecurity(inode, fsinfo.fattr, fsinfo.fattr->label);
|
nfs_setsecurity(inode, fsinfo.fattr, fsinfo.fattr->label);
|
||||||
error = 0;
|
error = 0;
|
||||||
|
|
||||||
out_label:
|
|
||||||
nfs4_label_free(fsinfo.fattr->label);
|
|
||||||
out_fattr:
|
out_fattr:
|
||||||
nfs_free_fattr(fsinfo.fattr);
|
nfs_free_fattr(fsinfo.fattr);
|
||||||
out_name:
|
out_name:
|
||||||
|
@ -165,5 +160,5 @@ out:
|
||||||
error_splat_root:
|
error_splat_root:
|
||||||
dput(fc->root);
|
dput(fc->root);
|
||||||
fc->root = NULL;
|
fc->root = NULL;
|
||||||
goto out_label;
|
goto out_fattr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1606,6 +1606,23 @@ struct nfs_fattr *nfs_alloc_fattr(void)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(nfs_alloc_fattr);
|
EXPORT_SYMBOL_GPL(nfs_alloc_fattr);
|
||||||
|
|
||||||
|
struct nfs_fattr *nfs_alloc_fattr_with_label(struct nfs_server *server)
|
||||||
|
{
|
||||||
|
struct nfs_fattr *fattr = nfs_alloc_fattr();
|
||||||
|
|
||||||
|
if (!fattr)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
fattr->label = nfs4_label_alloc(server, GFP_NOFS);
|
||||||
|
if (IS_ERR(fattr->label)) {
|
||||||
|
kfree(fattr);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fattr;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(nfs_alloc_fattr_with_label);
|
||||||
|
|
||||||
struct nfs_fh *nfs_alloc_fhandle(void)
|
struct nfs_fh *nfs_alloc_fhandle(void)
|
||||||
{
|
{
|
||||||
struct nfs_fh *fh;
|
struct nfs_fh *fh;
|
||||||
|
|
|
@ -342,14 +342,6 @@ nfs4_label_copy(struct nfs4_label *dst, struct nfs4_label *src)
|
||||||
|
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
static inline void nfs4_label_free(struct nfs4_label *label)
|
|
||||||
{
|
|
||||||
if (label) {
|
|
||||||
kfree(label->label);
|
|
||||||
kfree(label);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void nfs_zap_label_cache_locked(struct nfs_inode *nfsi)
|
static inline void nfs_zap_label_cache_locked(struct nfs_inode *nfsi)
|
||||||
{
|
{
|
||||||
|
@ -358,7 +350,6 @@ static inline void nfs_zap_label_cache_locked(struct nfs_inode *nfsi)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static inline struct nfs4_label *nfs4_label_alloc(struct nfs_server *server, gfp_t flags) { return NULL; }
|
static inline struct nfs4_label *nfs4_label_alloc(struct nfs_server *server, gfp_t flags) { return NULL; }
|
||||||
static inline void nfs4_label_free(void *label) {}
|
|
||||||
static inline void nfs_zap_label_cache_locked(struct nfs_inode *nfsi)
|
static inline void nfs_zap_label_cache_locked(struct nfs_inode *nfsi)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -426,9 +426,22 @@ extern void nfs_fattr_set_barrier(struct nfs_fattr *fattr);
|
||||||
extern unsigned long nfs_inc_attr_generation_counter(void);
|
extern unsigned long nfs_inc_attr_generation_counter(void);
|
||||||
|
|
||||||
extern struct nfs_fattr *nfs_alloc_fattr(void);
|
extern struct nfs_fattr *nfs_alloc_fattr(void);
|
||||||
|
extern struct nfs_fattr *nfs_alloc_fattr_with_label(struct nfs_server *server);
|
||||||
|
|
||||||
|
static inline void nfs4_label_free(struct nfs4_label *label)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_NFS_V4_SECURITY_LABEL
|
||||||
|
if (label) {
|
||||||
|
kfree(label->label);
|
||||||
|
kfree(label);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static inline void nfs_free_fattr(const struct nfs_fattr *fattr)
|
static inline void nfs_free_fattr(const struct nfs_fattr *fattr)
|
||||||
{
|
{
|
||||||
|
if (fattr)
|
||||||
|
nfs4_label_free(fattr->label);
|
||||||
kfree(fattr);
|
kfree(fattr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue