Commit 2b358b4e authored by Frank Zago's avatar Frank Zago Committed by Greg Kroah-Hartman

staging/lustre/llite: optimize ll_fid2path()

The only parameter from userspace that matters is the length of the
buffer. We don't need to allocate then import the whole structure. By
importing only that length, we can save a memory allocation.

Add sparse annotations to that function.
Signed-off-by: default avatarfrank zago <fzago@cray.com>
Reviewed-on: http://review.whamcloud.com/11167
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5389Reviewed-by: default avatarJohn L. Hammond <john.hammond@intel.com>
Reviewed-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Signed-off-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b6ee56fe
......@@ -1702,37 +1702,35 @@ static int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap,
return rc;
}
int ll_fid2path(struct inode *inode, void *arg)
int ll_fid2path(struct inode *inode, void __user *arg)
{
struct obd_export *exp = ll_i2mdexp(inode);
struct getinfo_fid2path *gfout, *gfin;
int outsize, rc;
struct obd_export *exp = ll_i2mdexp(inode);
const struct getinfo_fid2path __user *gfin = arg;
struct getinfo_fid2path *gfout;
u32 pathlen;
size_t outsize;
int rc;
if (!capable(CFS_CAP_DAC_READ_SEARCH) &&
!(ll_i2sbi(inode)->ll_flags & LL_SBI_USER_FID2PATH))
return -EPERM;
/* Need to get the buflen */
OBD_ALLOC_PTR(gfin);
if (gfin == NULL)
return -ENOMEM;
if (copy_from_user(gfin, arg, sizeof(*gfin))) {
OBD_FREE_PTR(gfin);
/* Only need to get the buflen */
if (get_user(pathlen, &gfin->gf_pathlen))
return -EFAULT;
}
outsize = sizeof(*gfout) + gfin->gf_pathlen;
outsize = sizeof(*gfout) + pathlen;
OBD_ALLOC(gfout, outsize);
if (gfout == NULL) {
OBD_FREE_PTR(gfin);
if (gfout == NULL)
return -ENOMEM;
}
memcpy(gfout, gfin, sizeof(*gfout));
OBD_FREE_PTR(gfin);
if (copy_from_user(gfout, arg, sizeof(*gfout)))
GOTO(gf_free, rc = -EFAULT);
/* Call mdc_iocontrol */
rc = obd_iocontrol(OBD_IOC_FID2PATH, exp, outsize, gfout, NULL);
if (rc)
if (rc != 0)
GOTO(gf_free, rc);
if (copy_to_user(arg, gfout, outsize))
......
......@@ -775,7 +775,7 @@ int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp,
int *lmm_size, struct ptlrpc_request **request);
int ll_fsync(struct file *file, loff_t start, loff_t end, int data);
int ll_merge_lvb(const struct lu_env *env, struct inode *inode);
int ll_fid2path(struct inode *inode, void *arg);
int ll_fid2path(struct inode *inode, void __user *arg);
int ll_data_version(struct inode *inode, __u64 *data_version, int extent_lock);
int ll_hsm_release(struct inode *inode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment