diff options
author | Maksym Planeta <mcsim.planeta@gmail.com> | 2012-10-07 15:46:05 +0300 |
---|---|---|
committer | Maksym Planeta <mcsim.planeta@gmail.com> | 2012-10-28 12:33:36 +0100 |
commit | e0f9439bea0bc986c2fb008519a4c010fc8a5ae5 (patch) | |
tree | 7ca9bca4bd6b7f2f97f3764734a4d74499a71f11 /ext2fs/truncate.c | |
parent | 4e0c82cb1ff18f7cb97eacc39aa29abdeecd5599 (diff) |
Make ext2fs work with partitions bigger than 2Gb.
This commit is port of large store patch from debian repository.
Additionally this patch was changed to use new libpager interface.
The main idea behind this patch is to use special disk cache up to 2Gb size
instead of mapping the whole partition. This cache is used to map only those
pages of partitions that are used at the moment or were used recently. This
allows to map only up to 2Gb of memory, although partition could be much
bigger.
This commit does not bring support for large files, only for partitions!
* ext2fs/balloc.c (ext2_free_blocks): Function changed to access disk blocks
in a new way.
(ext2_new_block): Likewise.
(ext2_count_free_blocks): Likewise.
(ext2_check_blocks_bitmap): Likewise.
* ext2fs/ext2fs.c (main): As now not the whole image is being mapped, but
there is disk cache is being used, appropriately were changed some names of
functions and variables.
(diskfs_reload_global_state): Likewise.
* ext2fs/ext2fs.h (DISK_CACHE_BLOCKS): New macro. Sets size of disk cache.
(DC_INCORE, DC_UNTOUCHED, DC_FIXED, DC_DONT_REUSE, DC_NO_BLOCK): New macros,
used for keeping status of block in disk cache.
(DISK_CACHE_LAST_READ_XOR) [NDEBUG]: New macro for debugging purposes.
(struct disk_cache_info): Structure that keeps information about block in
disk cache.
(bptr_index): New macro for converting address in memory to index of block
in disk cache.
(boffs_ptr): Macro has been converted to function to take into account
presence of disk cache.
(bptr_offs): Likewise.
(dino -> dino_ref): Function has been renamed and changed to take into
account presence of disk cache.
(dino_deref): New function that releases dinode.
(record_global_poke): Function changed to access disk blocks in a new way.
(sync_global_ptr): Likewise.
(record_indir_poke): Likewise.
(sync_global): Add debugging macro.
* ext2fs/getblk.c (ext2_alloc_block): Function changed to access disk block
in a new way.
(block_getblk): Likewise.
* ext2fs/hyper.c (get_hypermetadata): Function has been changed because,
to read sblock on its own.
(map_hypermetadata): New function that sets sblock and group_desc_image as
pointers in disk cache.
(diskfs_set_hypermetadata): Increase reference count in disk cache for
sblock, when it is poked.
(diskfs_readonly_changed): Update function to use disk cache.
* ext2fs/ialloc.c (diskfs_free_node): Function changed to access disk blocks
in a new way.
(ext2_alloc_inode): Likewise.
(ext2_count_free_inodes): Likewise.
(ext2_check_inodes_bitmap): Likewise.
* ext2fs/inode.c (diskfs_cached_lookup): Use disk cache instead of disk
image.
(read_node): Function changed to access disk blocks using interface. Also
debugging macro has been added.
(write_node): Likewise.
(diskfs_set_translator): Function changed to access disk blocks using
interface.
(diskfs_set_translator): Likewise.
* ext2fs/pager.c (disk_image): Obsolete variable removed.
(STAT_ADD): New macro.
(FREE_PAGE_BUFS): Remove obsolete macro.
(get_page_buf -> get_buf): Function renamed and changed to return buffer of
asked size.
(free_page_buf -> free_buf): Function renamed and changed.
(file_pager_read_page -> file_pager_read): Function renamed and changed to
process several pages at once.
(file_pager_write_page -> file_pager_write): Likewise.
(disk_pager_read_page -> disk_pager_read): Likewise.
(disk_pager_write_page -> disk_pager_write): Likewise.
(pending_blocks_write): Function has been changed.
(ext2_pager_notify_evict): New function.
(pager_read_page -> ext2_read_pages): Function has been renamed and changed
to support new libpager interface.
(pager_write_page -> ext2_write_pages): Likewise.
(pager_unlock_page -> ext2_unlock_pages): Likewise.
(pager_report_extent -> ext2_report_extent): Likewise.
(pager_clear_user_data -> ext2_clear_user_data): Likewise.
(pager_dropweak): Remove obsolete function.
(ext2_ops): New variable.
(disk_cache): Likewise.
(disk_cache_size): Likewise.
(disk_cache_blocks): Likewise.
(disk_cache_bptr): Likewise.
(disk_cache_info): Likewise.
(disk_cache_hint): Likewise.
(disk_cache_lock): Likewise.
(disk_cache_reassociation): Likewise.
(disk_cache_init): New function.
(disk_cache_return_unused): Likewise.
(disk_cache_block_ref_no_block): Likewise.
(disk_cache_block_is_cached): Likewise.
(disk_cache_block_ref): Likewise.
(disk_cache_block_ref_hint_no_block): Likewise.
(disk_cache_block_ref_ptr): Likewise.
(disk_cache_block_deref): Likewise.
(disk_cache_block_is_ref): Likewise.
(create_disk_pager): Function has been changed to support both new
interfaces of libpager and disk cache.
(diskfs_get_filemap): Function has been changed to support new interface of
libpager.
* ext2fs/pokel.c (pokel_add): Function changed to take into account new way
of working with disk blocks.
(__pokel_exec): Likewise.
* ext2fs/truncate.c (trunc_indirect): Function changed to take into account
both new way of working with disk blocks and changes in libpager.
(force_delayed_copies): Function changed to support new libpager interface.
Diffstat (limited to 'ext2fs/truncate.c')
-rw-r--r-- | ext2fs/truncate.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/ext2fs/truncate.c b/ext2fs/truncate.c index 077225b0..ab9c78fa 100644 --- a/ext2fs/truncate.c +++ b/ext2fs/truncate.c @@ -124,7 +124,7 @@ trunc_indirect (struct node *node, block_t end, { unsigned index; int modified = 0, all_freed = 1; - block_t *ind_bh = (block_t *)bptr (*p); + block_t *ind_bh = (block_t *)disk_cache_block_ref (*p); unsigned first = end < offset ? 0 : end - offset; for (index = first; index < addr_per_block; index++) @@ -139,11 +139,18 @@ trunc_indirect (struct node *node, block_t end, if (first == 0 && all_freed) { - pager_flush_some (diskfs_disk_pager, boffs (*p), block_size, 1); + if (block_size >= vm_page_size) + pager_flush_some (diskfs_disk_pager, + ((bptr_index (ind_bh) << log2_block_size) + / vm_page_size), + block_size / vm_page_size, 1); free_block_run_free_ptr (fbr, p); + disk_cache_block_deref (ind_bh); } else if (modified) record_indir_poke (node, ind_bh); + else + disk_cache_block_deref (ind_bh); } } @@ -241,8 +248,10 @@ force_delayed_copies (struct node *node, off_t length) /* XXX should cope with errors from diskfs_get_filemap */ poke_pages (obj, round_page (length), round_page (node->allocsize)); mach_port_deallocate (mach_task_self (), obj); - pager_flush_some (pager, round_page(length), - node->allocsize - length, 1); + pager_flush_some (pager, round_page(length) / vm_page_size, + round_page (node->allocsize - + round_page (length)) / vm_page_size, + 1); } ports_port_deref (pager); |