aboutsummaryrefslogtreecommitdiff
path: root/ext2fs
Commit message (Collapse)AuthorAgeFilesLines
* ext2fs: Disable an expensive checkSamuel Thibault2021-08-121-0/+4
| | | | | | disk_cache_block_is_ref calls hurd_ihash_find which is very expensive, so better disable the checks from record_global_poke and record_indir_poke unless building a debugging version.
* ext2fs: clear inline dataSamuel Thibault2021-08-111-0/+13
| | | | | When truncating a node with inline data, it's safer to really frob the inline data, to make sure ext2fs does not wrongly interprete it as block numbers.
* ext2fs: Fix block allocation on symlink->translator conversionSamuel Thibault2021-08-111-18/+19
| | | | | In diskfs_set_translator we need to truncate the existing node before allocating the block for the translator.
* ext2fs: clear data when setting a translator on a symlinkSamuel Thibault2021-08-111-0/+18
| | | | | | | e2fsck does not like seeing both blocks for the symlink and for the translation entry. This fixes the disappearance of /dev/urandom.
* ext2fs: Fix getting filemap for forcing delayed copiesSamuel Thibault2021-08-101-1/+1
| | | | The delayed copy actually needs write access.
* ext2fs: Update to upstream Hurd-reserved xattr index for "gnu.*".Jan (janneke) Nieuwenhuizen2020-05-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3980bd3b406addb327d858aebd19e229ea340b9a This supports setting (and reading) of passive trasnlators from GNU/Linux, e.g. dd if=/dev/zero of=file bs=1k count=1000 losetup /dev/loop0 file mke2fs -t ext2 -o hurd -O ext_attr /dev/loop0 mount -t ext2 -o x-xattr-translator-records /dev/loop0 /mnt mkdir -p /mnt/servers/socket touch /mnt/servers/socket/1 setfattr --name=gnu.translator --value='"/hurd/pflocal\0"' /mnt/servers/socket/1 getfattr --name=gnu.translator /mnt/servers/socket/1 # file: 1 gnu.translator="/hurd/pflocal" * ext2fs/xattr.c (xattr_prefixes): For "gnu.*", use index for the Hurd (10).
* Fix build with -fno-commonSamuel Thibault2020-03-312-22/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which will be the default in gcc-10. * acpi/acpifs.h (fs, acpifs_maptime): Add extern qualifier. * boot/private.h (verbose): Likewise. * eth-multiplexer/netfs_impl.h (multiplexer_maptime): Likewise. * eth-multiplexer/vdev.h (port_bucket, vdev_portclass): Likewise. * exec/priv.h (port_bucket, execboot_portclass): Likewise. * ext2fs/ext2fs.h (sblock, sblock_dirty, block_size, log2_block_size, log2_dev_blocks_per_fs_block, log2_stat_blocks_per_fs_block, zeroblock, frag_size, frags_per_block, inodes_per_block, itb_per_group, db_per_group, desc_per_block, addr_per_block, groups_count, node_to_page_lock, generation_lock, next_generation, group_desc_image, global_pokel, modified_global_blocks, use_xattr_translator_records): Likewise. * hostmux/hostmux.h (hostmux_maptime): Likewise. * isofs/isofs.h (host_name, mounted_on, disk_image, disk_image_len, logical_block_size, sblock): Likewise. * libdiskfs/diskfs.h (diskfs_shortcut_symlink, diskfs_shortcut_chrdev, diskfs_shortcut_blkdev, diskfs_shortcut_fifo, diskfs_shortcut_ifsock, diskfs_create_symlink_hook, diskfs_read_symlink_hook): Likewise. * libnetfs/callbacks.h (_netfs_translator_callback1, _netfs_translator_callback2): Likewise. * libnetfs/priv.h (netfs_mtime): Likewise. * libpager/priv.h (_pager_class): Likewise. * libtrivfs/trivfs.h (trivfs_check_access_hook, trivfs_check_open_hook, trivfs_open_hook, trivfs_protid_create_hook, trivfs_peropen_create_hook, trivfs_protid_destroy_hook, trivfs_peropen_destroy_hook, trivfs_getroot_hook): Likewise. * lwip/lwip-hurd.h (lwip_bucket, socketport_class, addrport_class, shutdown_notify_class, lwip_protid_portclasses, lwip_cntl_portclasses, lwip_bootstrap_portclass, fsys_identity, lwipcntl, lwip_owner, lwip_group): Likewise. * lwip/port/include/netif/hurdtunif.h (tunnel_cntlclass, tunnel_class): Likewise. * nfs/nfs.h (main_udp_socket, hostname, mapped_time): Likewise. * nfsd/nfsd.h (mapped_time, authserver): Likewise. * pci-arbiter/pcifs.h (fs, pcifs_maptime): Likewise. * pci-arbiter/startup.h (pci_shutdown_notify_class, arrange_shutdown_notification): Likewise. * pfinet/pfinet.h (pfinet_bucket, addrport_class, socketport_class, fsys_identity, pfinetctl, pfinet_owner, pfinet_group): Likewise. * pflocal/sserver.h (sock_port_bucket): Likewise. * proc/proc.h (authserver, self_proc, init_proc, startup_proc, proc_bucket, proc_class, generic_port_class, exc_class, generic_port, kernel_proc, global_lock): Likewise. * term/term.h (termstate, termflags, global_lock, carrier_alert, select_alert, pty_select_alert, term_bucket, tty_cntl_class, tty_class, cttyid_class, pty_class, pty_cntl_class, termctl, ptyctl, inputq, rawq, outputq, remote_input_mode, external_processing, term_owner, term_group, term_mode, bottom): Likewise. * usermux/usermux.h (usermux_maptime): Likewise. * utils/msgids.h (msgid_argp): Likewise. * libdiskfs/priv.h (_diskfs_mtime): Remove definition. * lwip/options.h (lwip_argp): Add prototype. * mach-defpager/priv.h (partitions): Name structure. (all_partitions): Add extern qualifier. * acpi/main.c (acpifs_maptime, fs): New variables. * exec/main.c (port_bucket, execboot_portclass): Likewise. * ext2fs/ext2fs.c (sblock, sblock_dirty, block_size, log2_block_size, log2_dev_blocks_per_fs_block, log2_stat_blocks_per_fs_block, frag_size, frags_per_block, inodes_per_block, itb_per_group, db_per_group, desc_per_block, addr_per_block, groups_count, next_generation, group_desc_image, global_pokel, use_xattr_translator_records): Likewise. * isofs/main.c (host_name, mounted_on, logical_block_size, sblock): Likewise. * libpager/pager-create.c (_pager_class): Likewise. * lwip/port/netif/hurdtunif.c (tunnel_cntlclass, tunnel_class): Likewise. * mach-defpager/default_pager.c (all_partitions): Likewise. * nfs/main.c (main_udp_socket, hostname, mapped_time): Likewise. * nfsd/main.c (mapped_time, authserver): Likewise. * pci-arbiter/main.c (fs, pcifs_maptime): Likewise. * pci-arbiter/startup.c (*pci_shutdown_notify_class): Likewise. * pfinet/main.c (pfinetctl, pfinet_owner, pfinet_group, pfinet_bucket, addrport_class, socketport_class, fsys_identity): Likewise. * proc/main.c (authserver, self_proc, init_proc, startup_proc, proc_bucket, proc_class, generic_port_class, exc_class, generic_port, kernel_proc, global_lock): Likewise. * term/main.c (termstate, termflags, global_lock, carrier_alert, select_alert, pty_select_alert, term_bucket, tty_cntl_class, tty_class, cttyid_class, pty_class, pty_cntl_class, termctl, ptyctl, outputq, remote_input_mode, external_processing, term_owner, term_group, term_mode, bottom): Likewise. * usermux/usermux.c (usermux_mapped_time): Rename to usermux_maptime. * lwip/main.c: Include "options.h". (lwip_argp, netif_list): Remove declarations. (lwip_bucket, socketport_class, addrport_class, shutdown_notify_class, lwip_cntl_portclasses, lwip_bootstrap_portclass, lwip_owner, lwip_group, fsys_identity, lwipcntl): New variables. * eth-multiplexer/multiplexer.c (multiplexer_maptime): Add variable. * hostmux/hostmux.c (hostmux_mapped_time): Rename variable to hostmux_maptime * libdiskfs/extra-version.c: Rename file to... * libdiskfs/priv.c: ... new file. (diskfs_shortcut_symlink, diskfs_shortcut_chrdev, diskfs_shortcut_blkdev, diskfs_shortcut_fifo, diskfs_shortcut_ifsock, diskfs_create_symlink_hook, diskfs_read_symlink_hook): Add weak variables. * libdiskfs/Makefile (OTHERSRCS): Replace extra-version.c with priv.c. * libtrivfs/priv.c: New file. * libtrivfs/Makefile (OTHERSRCS): Add priv.c * libcons/extra-version.c: Rename file to... * libcons/priv.c: ... new file. * libcons/Makefile (SRCS): Replace extra-version.c with priv.c. Fix build with #
* ext2fs: Fix fast symlinks created by linuxDamien Zammit2019-11-241-5/+1
| | | | | | | | linux seems to allocate 8 blocks for any fast symlink. * ext2fs/inode.c (write_symlink): Do not assert that st_blocks is 0. (read_symlink): Return EINVAL when node->dn_stat.st_size >= MAX_INODE_SYMLINK, not when node->dn_stat.st_blocks != 0.
* Use the data_t type defined in hurd_types.h.Flavio Cruz2019-09-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * boot/boot.c: Replace char* with data_t. * console-client/trans.c: Likewise. * exec/exec.c: Likewise. * ext2fs/storeinfo.c: Likewise. * fatfs/inode.c: Likewise. * fatfs/main.c: Likewise. * isofs/inode.c: Likewise. * libdiskfs/boot-start.c: Likewise. * libdiskfs/dir-readdir.c: Likewise. * libdiskfs/file-exec.c: Likewise. * libdiskfs/file-get-fs-opts.c: Likewise. * libdiskfs/file-get-trans.c: Likewise. * libdiskfs/file-getfh.c: Likewise. * libdiskfs/file-set-trans.c: Likewise. * libdiskfs/fsys-forward.c: Likewise. * libdiskfs/fsys-getfile.c: Likewise. * libdiskfs/fsys-options.c: Likewise. * libdiskfs/io-read.c: Likewise. * libdiskfs/io-write.c: Likewise. * libnetfs/dir-readdir.c: Likewise. * libnetfs/file-exec.c: Likewise. * libnetfs/file-get-fs-options.c: Likewise. * libnetfs/file-get-storage-info.c: Likewise. * libnetfs/file-get-translator.c: Likewise. * libnetfs/file-set-translator.c: Likewise. * libnetfs/fsstubs.c: Likewise. * libnetfs/fsys-get-options.c: Likewise. * libnetfs/fsys-set-options.c: Likewise. * libnetfs/fsysstubs.c: Likewise. * libnetfs/io-read.c: Likewise. * libnetfs/io-write.c: Likewise. * libtrivfs/dir-readdir.c: Likewise. * libtrivfs/file-get-fs-options.c: Likewise. * libtrivfs/file-get-storage-info.c: Likewise. * libtrivfs/file-get-trans.c: Likewise. * libtrivfs/file-getfh.c: Likewise. * libtrivfs/file-set-trans.c: Likewise. * libtrivfs/fsys-forward.c: Likewise. * libtrivfs/fsys-get-options.c: Likewise. * libtrivfs/fsys-set-options.c: Likewise. * libtrivfs/fsys-stubs.c: Likewise. * libtrivfs/io-read.c: Likewise. * libtrivfs/io-write.c: Likewise. * pfinet/io-ops.c: Likewise. * pfinet/pfinet-ops.c: Likewise. * pfinet/socket-ops.c: Likewise. * pfinet/tunnel.c: Likewise. * pflocal/io.c: Likewise. * pflocal/pf.c: Likewise. * pflocal/socket.c: Likewise. * proc/info.c: Likewise. * startup/startup.c: Likewise. * storeio/io.c: Likewise. * term/users.c: Likewise. * tmpfs/node.c: Likewise. * trans/crash.c: Likewise. * trans/fakeroot.c: Likewise. * trans/fifo.c: Likewise. * trans/firmlink.c: Likewise. * trans/hello-mt.c: Likewise. * trans/hello.c: Likewise. * trans/mtab.c: Likewise. * trans/new-fifo.c: Likewise. * trans/null.c: Likewise. * trans/proxy-defpager.c: Likewise. * trans/streamio.c: Likewise.
* ext2fs: Improve inlining.Justus Winter2017-08-241-2/+26
| | | | | * ext2fs/ext2fs.h: Add missing declarations needed when inlining is disabled.
* ext2fs: Fix warning.Justus Winter2017-08-101-1/+1
| | | | * ext2fs/xattr.c (ext2_set_xattr): Initialize 'block'.
* Use our own variant of 'assert' and 'assert_perror'.Justus Winter2017-08-0511-85/+85
| | | | | Our variants print stack traces on failures. This will make locating errors much easier.
* Fix typo.Maksym Planeta2017-08-051-1/+1
| | | | * ext2fs/truncate.c (force_delayed_copies): Fix typo.
* ext2fs: Reduce verbosity of missing xattr support on the FSSamuel Thibault2017-06-091-1/+1
| | | | | * ext2fs/xattr.c (ext2_free_xattr_block): Only warn about missing ext2fs support in debugging mode.
* ext2fs: Reduce verbosity of missing xattr support on the FSSamuel Thibault2017-05-071-2/+2
| | | | | * ext2fs/xattr.c (ext2_list_xattr, ext2_get_xattr): Only warn about missing ext2fs support in debugging mode.
* ext2fs: downgrade warnings about old translator records to debug messagesRichard Braun2017-01-081-2/+2
| | | | | | ext2fs/inode.c (diskfs_set_translator): Replace call to ext2_warning with ext2_debug. (diskfs_get_translator): Likewise.
* ext2fs: fix extended attribute retrievalRichard Braun2017-01-061-2/+1
| | | | | * ext2fs/xattr.c (ext2_get_xattr): Reset buffer size before each call to xattr_entry_get.
* ext2fs: minor cleanupRichard Braun2017-01-062-7/+7
| | | | | | | | | | | | | Fix some typos, types, add a few checks against integer overflows. ext2fs/inode.c (diskfs_user_read_node): Initialize datalen to 0. (diskfs_set_translator): Fix typo. (diskfs_get_translator): Change datalen type to size_t. * ext2fs/xattr.c (xattr_entry_get): Change type of block parameter to void *. (xattr_entry_create): Guard against integer overflows. (xattr_entry_replace): Likewise. (ext2_set_xattr): Fix typo.
* ext2fs: fix block referenceRichard Braun2017-01-061-5/+4
| | | | | ext2fs/xattr.c (ext2_get_xattr): Keep the inode reference until the block reference is done.
* ext2fs: Fix potential block leak.Justus Winter2017-01-061-0/+4
| | | | | | * ext2fs/xattr.c (ext2_set_xattr): We allocate a block, but only register it as the inodes acl block on success. Make sure to deallocate the block otherwise.
* ext2fs: Fix block allocation.Justus Winter2017-01-061-1/+1
| | | | | * ext2fs/xattr.c (ext2_set_xattr): Check returned block number before mapping it.
* ext2fs: Require users to opt-in for xattr-based translator records.Justus Winter2017-01-063-2/+28
| | | | | | | | | | * ext2fs/ext2fs.c (use_xattr_translator_records): New variable. (X_XATTR_TRANSLATOR_RECORDS): New macro. (options): New option '--x-xattr-translator-records'. (parse_opt): Handle new option. * ext2fs/ext2fs.h (use_xattr_translator_records): New declaration. * ext2fs/inode.c (diskfs_set_translator): Use new variable. (diskfs_get_translator): Likewise.
* ext2fs: Do not read translator record on Linux filesystems.Justus Winter2017-01-061-4/+0
| | | | | | | * ext2fs/inode.c (diskfs_user_read_node): Do not read translator record on filesystems using Linux on-disk format. We pondered to use this to introduce the feature, implementing it merely for Linux filesystem.
* ext2fs: Fix block leak in xattr code.Justus Winter2017-01-061-0/+8
| | | | | | * ext2fs/xattr.c (ext2_set_xattr): Avoid allocating and leaking a block if the caller tries to delete an extended attribute from a node that has no extended attribute in the first place.
* ext2fs: Use correct type for sizes.Justus Winter2017-01-062-22/+22
| | | | | | | * ext2fs/ext2fs.h (ext2_{list,get,set}_xattr): Use 'size_t'. * ext2fs/xattr.c (xattr_entry_{list,get,create): Use 'size_t' where appropriate. (ext2_{list,get,set}_xattr): Likewise.
* ext2fs: Fix typo.Justus Winter2017-01-061-1/+1
|
* ext2fs: Use xattr to store passive translatorShengyu Zhang2017-01-061-63/+161
| | | | | | | * ext2fs/inode.c (diskfs_set_translator): Use xattr to store passive translator if xattr is supported by filesystem. (diskfs_get_translator): Read value of xattr key "gnu.translator" if it exists. (diskfs_user_read_node): Set translator flag on reading.
* ext2fs: Add support for xattrShengyu Zhang2017-01-066-2/+970
| | | | | | | | | * ext2fs/Makefile (SRCS): Add xattr.c. * ext2fs/ext2_fs.h: Define EXT2_FEATURE_COMPAT_EXT_ATTR. * ext2fs/ext2fs.h: Add xattr functions. * ext2fs/ialloc.c (diskfs_free_node): Free xattr block. * ext2fs/xattr.c: xattr implement. * ext2fs/xattr.h: Likewise.
* ext2fs: Use more POSIXish error codeSamuel Thibault2016-11-201-0/+2
| | | | | * ext2fs/dir.c (diskfs_direnter_hard): On missing room to extend directory, return ENOSPC.
* ext2fs: Do not talk about crashing on ENOSPCSamuel Thibault2016-11-201-1/+1
| | | | | * ext2fs/pager.c (pager_unlock_page): Do not say that ext2fs will crash because of ENOSPC.
* ext2fs: Fix crash on ENOSPC while extending a directorySamuel Thibault2016-11-201-0/+8
| | | | | * ext2fs/dir.c (diskfs_direnter_hard): Call hurd_safe_memset on directory extension before using it, to actually reserve room.
* Add missing spinlock initializersSamuel Thibault2016-11-012-2/+5
| | | | | | | | | | Thanks Agustina Arzille for the report * ext2fs/ext2fs.h (global_lock, modified_global_blocks_lock): Declare extern * ext2fs/ext2fs.c (global_lock, modified_global_blocks_lock): Define and initialize to PTHREAD_SPINLOCK_INITIALIZER. * libtreefs/xinl.c (treefs_node_refcnt_lock): Likewise.
* ext2fs: Poison pointers into dereferenced cache pages.Justus Winter2016-10-093-6/+10
| | | | | | | | | * ext2fs/ext2fs.h (disk_cache_block_deref): Replace with a macro that NULLs the given pointer. (dino_deref): Likewise. * ext2fs/pager.c (disk_cache_block_deref): Rename. * ext2fs/pokel.c (pokel_add): Adapt. (pokel_exec): Likewise.
* ext2fs: Rename parameter.Justus Winter2016-10-081-3/+3
| | | | | * ext2fs/ext2fs.h (sync_global_pointer): Rename 'bptr' so that it doesn't collide with the macro 'bptr'.
* ext2fs: Disable option to specify alternate superblock.Justus Winter2016-10-031-0/+9
| | | | | | * ext2fs/ext2fs.c (options): Disable '--sblock', this has never been implemented. (parse_opt): Likewise.
* libpager: provide 'pager_create_alloc'Justus Winter2016-08-071-14/+11
| | | | | | | | | | | | | | | | | | | | | 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.
* ext2fs: fix pager use-after-freeJustus Winter2016-05-221-11/+20
| | | | | | | | | | | | | Previously, pagers had no reference for being part of a node, only for having a send right made for them. Hence we sometimes saw use-after-free errors if the kernel did give up that send right, typically while deleting files. Keep a weak reference as long as the pager is referenced by a node. * ext2fs/pager.c (pager_clear_user_data): Assert that 'pager' has been NULLed. (pager_dropweak): Drop the weak reference and NULL 'pager'. (diskfs_get_filemap): Simplify. Acquire a weak reference.
* Fix supporting >4GiB files in ext2fsSamuel Thibault2016-04-262-7/+14
| | | | | | | | | | * ext2fs/inode.c (diskfs_user_read_node): When sizeof(off_t) >= 8, add di->i_size_high as high-64bit part to st->st_size. Drop setting unused info->i_high_size. (write_node): When sizeof(off_t) >= 8, write high-64bit part of st->st_size to di->i_size_high. * ext2fs/ext2_fs_i.h (ext2_inode_info): Remove i_high_size field. * pfinet/linux-src/include/linux/ext2_fs_i.h (ext2_inode_info): Likewise.
* ext2fs: Fix off-by-oneSamuel Thibault2016-03-181-1/+1
| | | | | * ext2fs/pager.c (disk_cache_init): Do not add disk_cache_info[disk_cache_blocks] to disk_cache_info_free.
* ext2fs: Fix adding blocks to free blocks cacheSamuel Thibault2016-03-151-1/+8
| | | | | | | | | * ext2fs/pager.c (disk_cache_info_free_push): Add prototype. (disk_pager_notify_evict): When dropping DC_INCORE flag, if the block becomes free (no reference and no DC_DONT_REUSE flags), call disk_cache_info_free_push. (disk_cache_block_deref): Only call disk_cache_info_free_push if the flags of the block do not contain DC_DONT_REUSE flags.
* Drop OTHERLIBS and use LDLIBS exclusivelyFlavio Cruz2015-12-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When cross-compiling, OTHERLIBS magically turns -lpthread into the path to the host libpthread.so file, resulting in build issues. LDLIBS does not suffer from this problem and it seems that is already being used in other Makefiles. This patch removes OTHERLIBS entirely from the build system. * Makeconf: Remove references to OTHERLIBS * auth/Makefile: Replace OTHERLIBS with LDLIBS. * boot/Makefile: Likewise. * console/Makefile: Likewise. * exec/Makefile: Likewise. * ext2fs/Makefile: Likewise. * fatfs/Makefile: Likewise. * ftpfs/Makefile: Likewise. * hostmux/Makefile: Likewise. * isofs/Makefile: Likewise. * libhurd-slab/Makefile: Likewise. * nfs/Makefile: Likewise. * nfsd/Makefile: Likewise. * pfinet/Makefile: Likewise. * proc/Makefile: Likewise. * procfs/Makefile: Likewise. * random/Makefile: Likewise. * storeio/Makefile: Likewise. * term/Makefile: Likewise. * tmpfs/Makefile: Likewise. * usermux/Makefile: Likewise.
* fix compiler warnings in hurd/ext2fsFlavio Cruz2015-12-297-21/+21
| | | | | | | | | | | | ext2fs: Fix compiler warnings. * ext2fs/balloc.c: Use unsigned char instead of char. * ext2fs/bitmap.c Use unsigned char for bitmaps. * ext2fs/dir.c: Fix format. * ext2fs/ext2fs.h: Use unsigned char for bitmaps. * ext2fs/ialloc.c: Use unsigned char for bitmaps. Fix format string in ext2_warning. * ext2fs/pager.c: Fix format string in ext2_warning and ext2_error.
* ext2fs: keep list of reusable disk cache entriesJustus Winter2015-11-292-31/+53
| | | | | | | | | | | | This avoids a linear scan through the cache. * ext2fs/ext2fs.h (struct disk_cache_info): New field 'next'. * ext2fs/pager.c (disk_cache_hint): Drop. (disk_cache_info_free, disk_cache_info_free_lock): New variables. (disk_cache_info_free_pop, disk_cache_info_free_push): New functions. (disk_cache_init): Adjust slightly. (disk_cache_block_ref): Use new functions. (disk_cache_block_deref): Likewise.
* ext2fs: disable block cache debugging by defaultJustus Winter2015-11-292-5/+5
| | | | | * ext2fs/ext2fs.h: Disable block cache debugging by default. * ext2fs/pager.c: Likewise.
* ext2fs: improve the block cacheJustus Winter2015-11-291-4/+6
| | | | | | * ext2fs/pager.c (disk_cache_block_ref): Improve the cache by using the new lookup and insertion functions that return and use a location pointer.
* Remove unused variablesJustus Winter2015-11-061-2/+0
| | | | | | | * console/pager.c (user_pager_init): Remove unused variables. * ext2fs/pager.c (create_disk_pager): Likewise. * fatfs/pager.c (create_fat_pager): Likewise. * storeio/pager.c (init_dev_paging): Likewise.
* Fix race condition in ext2fs when remountingJames Clarke2015-09-063-2/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On some systems, ext2fs.static would regularly hang at startup, as a race condition meant it would process paging requests while remounting. To fix this, libpager has been altered to allow inhibiting and resuming its worker threads, and ext2fs uses this to inhibit paging while remounting. * console/pager.c (pager_requests): New variable. (user_pager_init): Updated call to pager_start_workers to use new pager_requests variable. * daemons/runsystem.sh: Removed artificial delay working around the race condition. * ext2fs/ext2fs.c (diskfs_reload_global_state): Call new inhibit_ext2_pager and resume_ext2_pager functions, and leave sblock as non-NULL so it will be munmapped. * ext2fs/ext2fs.h (inhibit_ext2_pager,resume_ext2_pager): New functions. * ext2fs/pager.c (file_pager_requests): New variable. (create_disk_pager): Updated call to pager_start_workers to use new file_pager_requests variable. (inhibit_ext2_pager,resume_ext2_pager): New functions. * fatfs/fatfs.h (inhibit_fat_pager,resume_fat_pager): New functions. * fatfs/pager.c (file_pager_requests): New variable. (create_fat_pager): Updated call to pager_start_workers to use new file_pager_requests variable. (inhibit_fat_pager,resume_fat_pager): New functions. * libdiskfs/disk-pager.c (diskfs_disk_pager_requests): New variable. (diskfs_start_disk_pager): Updated call to pager_start_workers to use new diskfs_disk_pager_requests variable. * libdiskfs/diskfs-pager.h (diskfs_disk_pager_requests): New variable. * libpager/demuxer.c (struct pager_requests): Renamed struct requests to struct pager_requests. Replaced queue with queue_in and queue_out pointers. Added inhibit_wakeup field. (pager_demuxer): Updated to use new queue_in/queue_out pointers. Only wake up workers if not inhibited. (worker_func): Updated to use new queue_in/queue_out pointers. Final worker thread to sleep notifies the inhibit_wakeup condition variable. (pager_start_workers): Added out parameter for the requests instance. Allocate heap space shared by both queues. Initialise new inhibit_wakeup condition. (pager_inhibit_workers,pager_resume_workers): New functions. * libpager/pager.h (struct pager_requests): Public forward definition. (pager_start_workers): Added out parameter for the requests instance. (pager_inhibit_workers,pager_resume_workers): New functions. * libpager/queue.h (queue_empty): New function. * storeio/pager.c (pager_requests): New variable. (init_dev_paging): Updated call to pager_start_workers to use new pager_requests variable.
* ext2fs: provide unconditional debug macroJustus Winter2015-08-151-1/+3
| | | | | | * ext2fs/ext2fs.h (ext2_debug_): New macro that unconditionally prints the given message. (ext2_debug): Use the new macro.
* ext2fs: improve ext2fs debuggingJustus Winter2015-08-151-3/+2
| | | | | * ext2fs/ext2fs.h (ext2_debug): Print to stderr. (printf): Drop declaration.
* libdiskfs: implement a node cacheJustus Winter2015-04-174-226/+28
| | | | | | | | | | | | | | | | | | | | | Previously, all users of libdiskfs implemented a node cache on their own. Move the node cache from ext2fs into libdiskfs. We preserve the previous API by marking all functions that we pull from ext2fs as weak, so that users like tmpfs can still implement their own node cache. * ext2fs/dir.c (diskfs_lookup_hard): Adjust accordingly. * ext2fs/ext2fs.c (main): Don't call `inode_init'. * ext2fs/ext2fs.h (struct disknode): Drop `hnext', `hprevp'. * ext2fs/inode.c: Move the node cache into diskfs. (diskfs_user_make_node): New function. (diskfs_try_dropping_softrefs): Rename to `diskfs_user_try_dropping_softrefs'. (read_node): Rename to `diskfs_user_read_node'. Also move a chunk of code dealing with generations from `diskfs_cached_lookup' here. * libdiskfs/Makefile (OTHERSRCS): Add `node-cache.c'. * libdiskfs/diskfs.h (struct node): Add `hnext', `hprevp'. Amend existing comments, add forward declarations. * libdiskfs/node-cache.c: New file.