|
@@ -26,6 +26,8 @@
|
|
|
|
|
|
#define FF_LAYOUT_POLL_RETRY_MAX (15*HZ)
|
|
|
|
|
|
+static struct group_info *ff_zero_group;
|
|
|
+
|
|
|
static struct pnfs_layout_hdr *
|
|
|
ff_layout_alloc_layout_hdr(struct inode *inode, gfp_t gfp_flags)
|
|
|
{
|
|
@@ -407,8 +409,9 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh,
|
|
|
struct nfs4_ff_layout_mirror *mirror;
|
|
|
struct nfs4_deviceid devid;
|
|
|
struct nfs4_deviceid_node *idnode;
|
|
|
- u32 ds_count;
|
|
|
- u32 fh_count;
|
|
|
+ struct auth_cred acred = { .group_info = ff_zero_group };
|
|
|
+ struct rpc_cred *cred;
|
|
|
+ u32 ds_count, fh_count, id;
|
|
|
int j;
|
|
|
|
|
|
rc = -EIO;
|
|
@@ -484,24 +487,39 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh,
|
|
|
fls->mirror_array[i]->fh_versions_cnt = fh_count;
|
|
|
|
|
|
/* user */
|
|
|
- rc = decode_name(&stream, &fls->mirror_array[i]->uid);
|
|
|
+ rc = decode_name(&stream, &id);
|
|
|
if (rc)
|
|
|
goto out_err_free;
|
|
|
|
|
|
+ acred.uid = make_kuid(&init_user_ns, id);
|
|
|
+
|
|
|
/* group */
|
|
|
- rc = decode_name(&stream, &fls->mirror_array[i]->gid);
|
|
|
+ rc = decode_name(&stream, &id);
|
|
|
if (rc)
|
|
|
goto out_err_free;
|
|
|
|
|
|
+ acred.gid = make_kgid(&init_user_ns, id);
|
|
|
+
|
|
|
+ /* find the cred for it */
|
|
|
+ cred = rpc_lookup_generic_cred(&acred, 0, gfp_flags);
|
|
|
+ if (IS_ERR(cred)) {
|
|
|
+ rc = PTR_ERR(cred);
|
|
|
+ goto out_err_free;
|
|
|
+ }
|
|
|
+
|
|
|
+ rcu_assign_pointer(fls->mirror_array[i]->cred, cred);
|
|
|
+
|
|
|
mirror = ff_layout_add_mirror(lh, fls->mirror_array[i]);
|
|
|
if (mirror != fls->mirror_array[i]) {
|
|
|
+ /* swap cred ptrs so free_mirror will clean up old */
|
|
|
+ fls->mirror_array[i]->cred = xchg(&mirror->cred, cred);
|
|
|
ff_layout_free_mirror(fls->mirror_array[i]);
|
|
|
fls->mirror_array[i] = mirror;
|
|
|
}
|
|
|
|
|
|
- dprintk("%s: uid %d gid %d\n", __func__,
|
|
|
- fls->mirror_array[i]->uid,
|
|
|
- fls->mirror_array[i]->gid);
|
|
|
+ dprintk("%s: uid %u gid %u\n", __func__,
|
|
|
+ from_kuid(&init_user_ns, acred.uid),
|
|
|
+ from_kgid(&init_user_ns, acred.gid));
|
|
|
}
|
|
|
|
|
|
p = xdr_inline_decode(&stream, 4);
|
|
@@ -2226,6 +2244,11 @@ static int __init nfs4flexfilelayout_init(void)
|
|
|
{
|
|
|
printk(KERN_INFO "%s: NFSv4 Flexfile Layout Driver Registering...\n",
|
|
|
__func__);
|
|
|
+ if (!ff_zero_group) {
|
|
|
+ ff_zero_group = groups_alloc(0);
|
|
|
+ if (!ff_zero_group)
|
|
|
+ return -ENOMEM;
|
|
|
+ }
|
|
|
return pnfs_register_layoutdriver(&flexfilelayout_type);
|
|
|
}
|
|
|
|
|
@@ -2234,6 +2257,10 @@ static void __exit nfs4flexfilelayout_exit(void)
|
|
|
printk(KERN_INFO "%s: NFSv4 Flexfile Layout Driver Unregistering...\n",
|
|
|
__func__);
|
|
|
pnfs_unregister_layoutdriver(&flexfilelayout_type);
|
|
|
+ if (ff_zero_group) {
|
|
|
+ put_group_info(ff_zero_group);
|
|
|
+ ff_zero_group = NULL;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
MODULE_ALIAS("nfs-layouttype4-4");
|