aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/idmap.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2012-02-07 14:59:05 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-02-15 00:19:50 -0500
commitd073e9b541e1ac3f52d72c3a153855d9a9ee3278 (patch)
tree4719e9b10b9df0416523577d5008045198ad8633 /fs/nfs/idmap.c
parent7ced286e0ade171af89d32c22b1590e1ca480542 (diff)
NFSv4: Reduce the footprint of the idmapper
Instead of pre-allocating the storage for all the strings, we can significantly reduce the size of that table by doing the allocation when we do the downcall. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> Reviewed-by: Jeff Layton <jlayton@redhat.com>
Diffstat (limited to 'fs/nfs/idmap.c')
-rw-r--r--fs/nfs/idmap.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c
index 5a5566fa1619..fff79481218c 100644
--- a/fs/nfs/idmap.c
+++ b/fs/nfs/idmap.c
@@ -362,7 +362,7 @@ struct idmap_hashent {
362 unsigned long ih_expires; 362 unsigned long ih_expires;
363 __u32 ih_id; 363 __u32 ih_id;
364 size_t ih_namelen; 364 size_t ih_namelen;
365 char ih_name[IDMAP_NAMESZ]; 365 const char *ih_name;
366}; 366};
367 367
368struct idmap_hashtable { 368struct idmap_hashtable {
@@ -482,12 +482,17 @@ void
482nfs_idmap_delete(struct nfs_client *clp) 482nfs_idmap_delete(struct nfs_client *clp)
483{ 483{
484 struct idmap *idmap = clp->cl_idmap; 484 struct idmap *idmap = clp->cl_idmap;
485 int i;
485 486
486 if (!idmap) 487 if (!idmap)
487 return; 488 return;
488 nfs_idmap_unregister(clp, idmap->idmap_pipe); 489 nfs_idmap_unregister(clp, idmap->idmap_pipe);
489 rpc_destroy_pipe_data(idmap->idmap_pipe); 490 rpc_destroy_pipe_data(idmap->idmap_pipe);
490 clp->cl_idmap = NULL; 491 clp->cl_idmap = NULL;
492 for (i = 0; i < ARRAY_SIZE(idmap->idmap_user_hash.h_entries); i++)
493 kfree(idmap->idmap_user_hash.h_entries[i].ih_name);
494 for (i = 0; i < ARRAY_SIZE(idmap->idmap_group_hash.h_entries); i++)
495 kfree(idmap->idmap_group_hash.h_entries[i].ih_name);
491 kfree(idmap); 496 kfree(idmap);
492} 497}
493 498
@@ -634,9 +639,14 @@ static void
634idmap_update_entry(struct idmap_hashent *he, const char *name, 639idmap_update_entry(struct idmap_hashent *he, const char *name,
635 size_t namelen, __u32 id) 640 size_t namelen, __u32 id)
636{ 641{
642 char *str = kmalloc(namelen + 1, GFP_KERNEL);
643 if (str == NULL)
644 return;
645 kfree(he->ih_name);
637 he->ih_id = id; 646 he->ih_id = id;
638 memcpy(he->ih_name, name, namelen); 647 memcpy(str, name, namelen);
639 he->ih_name[namelen] = '\0'; 648 str[namelen] = '\0';
649 he->ih_name = str;
640 he->ih_namelen = namelen; 650 he->ih_namelen = namelen;
641 he->ih_expires = jiffies + nfs_idmap_cache_timeout; 651 he->ih_expires = jiffies + nfs_idmap_cache_timeout;
642} 652}