diff options
author | Justus Winter <justus@gnupg.org> | 2016-05-22 19:35:10 +0200 |
---|---|---|
committer | Justus Winter <justus@gnupg.org> | 2016-08-07 23:28:45 +0200 |
commit | 0e3a795af98b6441d0a9928036e140978511e272 (patch) | |
tree | 801984832811a5f7bb24c847e07b5b47900e9737 /ext2fs | |
parent | ceae83bd25aadee094ec9d3a95cf27510cea2037 (diff) |
libpager: provide 'pager_create_alloc'
Add a variant to 'pager_create' that allocates memory for the user
hook next to the pager data increasing locality.
* console/pager.c (pager_clear_user_data): Fix type of 'idx', do not
free 'upi'.
(user_pager_create): Use the new function.
* doc/hurd.texi: Document new function.
* ext2fs/pager.c (pager_clear_user_data): Don't free 'upi'.
(diskfs_get_filemap): Use the new function.
* fatfs/pager.c (pager_clear_user_data): Don't free 'upi'.
(diskfs_get_filemap): Use the new function.
* isofs/pager.c (pager_clear_user_data): Don't free 'upi'.
(diskfs_get_filemap): Use the new function.
* libpager/pager-create.c (_pager_create): New generic allocation
function.
(pager_create): Use the new generic function.
(pager_create_alloc): New function.
* libpager/pager.h (pager_create_alloc): New prototype.
Diffstat (limited to 'ext2fs')
-rw-r--r-- | ext2fs/pager.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/ext2fs/pager.c b/ext2fs/pager.c index 485f69cd..456b582c 100644 --- a/ext2fs/pager.c +++ b/ext2fs/pager.c @@ -822,8 +822,6 @@ pager_clear_user_data (struct user_pager_info *upi) diskfs_nrele_light (upi->node); } - - free (upi); } /* This will be called when the ports library wants to drop weak references. @@ -1316,23 +1314,22 @@ diskfs_get_filemap (struct node *node, vm_prot_t prot) } else { - struct user_pager_info *upi = - malloc (sizeof (struct user_pager_info)); - upi->type = FILE_DATA; - upi->node = node; - upi->max_prot = prot; - diskfs_nref_light (node); - diskfs_node_disknode (node)->pager = - pager_create (upi, file_pager_bucket, MAY_CACHE, - MEMORY_OBJECT_COPY_DELAY, 0); - if (diskfs_node_disknode (node)->pager == 0) + struct user_pager_info *upi; + pager = pager_create_alloc (sizeof *upi, file_pager_bucket, + MAY_CACHE, MEMORY_OBJECT_COPY_DELAY, 0); + if (pager == NULL) { - diskfs_nrele_light (node); - free (upi); pthread_spin_unlock (&node_to_page_lock); return MACH_PORT_NULL; } + upi = pager_get_upi (pager); + upi->type = FILE_DATA; + upi->node = node; + upi->max_prot = prot; + diskfs_nref_light (node); + diskfs_node_disknode (node)->pager = pager; + /* A weak reference for being part of the node. */ ports_port_ref_weak (diskfs_node_disknode (node)->pager); |