Commit graph

67 commits

Author SHA1 Message Date
Fabian 497f618cab Merge branch 'wasm' into master 2021-01-03 02:07:20 -06:00
Fabian ac9d248c85 9p stats: Show file in progress after parallel operation finishes 2020-12-31 19:14:34 -06:00
Fabian cd3f48c0a3 Simplify recursive state handling (don't require get_state for set_state) 2020-12-31 19:14:32 -06:00
Fabian d5c9b29942 Upgrade jshint 2020-12-31 19:14:29 -06:00
Ernest Wong 04d2b72248 9p: Simplify read - OpenInode is not asynchronous 2020-08-30 19:37:15 -05:00
Fabian 639ec0019b Commit a temporary workaround 2020-08-30 19:37:15 -05:00
Fabian b83ed1b7c1 Minor 2020-08-30 19:29:54 -05:00
Fabian dd929f52c5 9p: Add create event, add file name to the read event 2020-08-30 19:29:54 -05:00
Ernest Wong 595d6dca55 Filesystem: Refactor inodedata accesses to async methods
The "// jshint ignore:line" comments are pretty messy, so squint your eyes.
They're systematically placed, so we can regex it out when jshint's
new version finally arrives.

Using async/await instead of callbacks due to callback hell, and it also
helps minimising the diff)
2020-08-30 19:29:54 -05:00
Ernest Wong adc035368f Filesystem: Log lock types as readable strings 2020-08-30 19:29:54 -05:00
Ernest Wong 401b814f93 Filesystem: Store infinite lock lengths
Having both lock.length and lock.get_length() giving different values is
confusing.
2020-08-30 19:29:54 -05:00
Ernest Wong 267083e897 Filesystem: Implement POSIX record locks 2020-08-30 19:29:54 -05:00
Ernest Wong 66cf97e0a7 Filesystem: Tidy comments, clarify nlinks special case. 2020-08-30 19:29:54 -05:00
Ernest Wong c3739fc22a 9p: Disable filename tracking by default 2020-08-30 19:29:54 -05:00
Ernest Wong 1a7dc59f07 9p: Track filename during RENAMEAT 2020-08-30 19:29:54 -05:00
Ernest Wong 0d885e5e8c 9p: put dbg_name into state and document its limitations 2020-08-30 19:29:54 -05:00
Ernest Wong 8f4fcfa6f7 9p: return correct error code for link and unlink 2020-08-30 19:29:54 -05:00
Ernest Wong 5b456b64cb 9p: don't rely on inode.name for debug messages 2020-08-30 19:29:54 -05:00
Ernest Wong d1519d4509 Filesystem: hard links, replace linked lists with Map.
Unfortunately, I didn't split this into multiple commits:

- Keeping track of nlinks is now all done by link_under_dir and
unlink_from_dir methods.

- Inodes are no longer associated with a name.

- Directory structure is now represented using a Map<name to idx>, so
the directory inode fully owns the directory entries instead a linked
list scattered across many inodes.

- The parameter order for FS#Link and FS#link_under_dir has been
modified to be consistent with 9p's: (dirid, fid, name)

- Allowed the movement of hardlinked files between filesystems
"vertically", as long as the target inode is reachable within the
filesystem and subfilesystems without ever having to traverse to the
parent filesystem.

- The methods FS#copy_inode and FS#divert does not put the filesystem in
an invalid state: FS#copy_inode does not modify inode.nlinks nor
inode.direntries, and FS#divert makes sure to delete the original nlinks
and direntries after it has been copied over to a new inode.

- Added extra assertions in FS#link_under_dir and FS#unlink_from_dir

- Forwarders should not be deleted upon unlink: the files are still
accessible.

- Non-root non-directory forwarders can now be linked under
non-forwarder directories for extra freedom for hardlinks. Now, the rule
for linking is: never link under a forwarder, and never link a directory
more than once.

Some tests and some 9p debug code is broken because they rely on
inode.name which no longer exists nor makes sense to exist.

Will fix in next commit.
2020-08-30 19:29:54 -05:00
Ernest Wong 6c55912a59 Fail early if unlink of destination failed for fs.Rename 2020-08-30 19:29:53 -05:00
Ernest Wong 7aa42c3418 Identify type of failure for fs.Unlink using -errno convention 2020-08-30 19:29:53 -05:00
Ernest Wong fa3a961628 Handle unexpected error codes from filesystem 2020-08-30 19:29:53 -05:00
Ernest Wong e683e812fd Mount only onto non-existent paths, existent parent
If mountpoint already exists, then we're silently making its children
inaccessible which may not be what we expected/intended.

Create a new forwarder inode upon mounting.
2020-08-30 19:29:53 -05:00
Ernest Wong 3fe75a9130 Identify type of failure for fs.Rename using -errno convention 2020-08-30 19:29:53 -05:00
Ernest Wong 9e592dbd84 Decouple 9p and starter from fs's internal structure
Part of changes to support fs mounting on the host side.
Inode attributes are generally left untouched as field accesses.
2020-08-30 19:29:53 -05:00
Ernest Wong 8f0bba4b1f Fix hang during setxattr: send error instead of ignore write 2020-08-30 19:29:53 -05:00
Ernest Wong ba8ab574b5 9P: Don't write xattr data into actual file contents
Wait for proper xattr support.
2020-08-30 19:29:53 -05:00
Ernest Wong 65f7b68185 Remove trailing spaces in lib/* 2020-08-30 19:29:13 -05:00
Fabian 74f2756e08 Filesystem: Mark written files as dirty 2020-08-30 19:29:13 -05:00
Ernest Wong bda133ba49 JSHint the lib directory 2020-08-30 19:29:13 -05:00
Ernest Wong e5fe9d278b 9P readdir should return whole number of dir-entries
See issue #43
2020-08-30 19:29:13 -05:00
Ernest Wong 5778076c2b 9P read(dir) handle case when offset exceeds available
Previously:
(1) The number of bytes to read (aka count) is readjusted to become negative.
Driver reports bogus count value.
(2) However, when sending the data through virtio, the payload buffer was
incorrectly subarrayed with the negative end-offset, so wrong data was
still sent through.

Now:
(1) 9P read(dir) now clamps the count value to non-negative numbers.
(2) Add asserts for negative replybuffersize and payloadsize as those
should not happen in the first place.
2020-08-30 19:27:07 -05:00
Ernest Wong 9d4b5cff2f Virtio 9p flush after every reply - replies can be async
Previous intention: virtqueue.flush_replies was to be called after all
current pending requests have been processed.
Previous implementation: flush_replies was called at the end of the
notify handler, assuming that all replies are pushed by then.

However, some replies are pushed asynchronously sometime after the
notify handler finishes, so the guest OS never gets interrupted for
that reply and the guest OS will appear stuck.
2020-08-30 19:27:07 -05:00
Ernest Wong 87974d765b Turn vars into consts and lets, remove unused variables
Might as well make things consistent.
Found unused variables in the process.
2020-08-30 19:27:07 -05:00
Ernest Wong b4556b2adb Virtio tidyup
- Use array.includes over .indexOf for existence checking.
- Immediate object returns.
- Correct commenting for non JSDoc comments.
- Improve assert messages for failures.
- Move generic reusable code into lib.js
2020-08-30 19:27:07 -05:00
Ernest Wong 597d635c8f Tidy 9p + ensure tagname gets state-restored value 2020-08-30 19:27:07 -05:00
Ernest Wong 309175f23d Virtio handle batched and suppressed requests 2020-08-30 19:27:07 -05:00
Ernest Wong 8f6393f3f9 VirtIO and VirtIO 9P fix state restore 2020-08-30 19:27:07 -05:00
Ernest Wong 553c95af6e Fix 9p device-specific config field widths
VirtIO upgrade progress:
the debian driver now responds with
ACKNOWLEDGE DRIVER FEATURES_OK DRIVER_OK
2020-08-30 19:27:07 -05:00
Ernest Wong f39e7bf58a Update 9p to use new virtio interface 2020-08-30 19:27:07 -05:00
Ernest Wong 0c3c53150e Implement virtqueue operations + other fixes
Implement queue push, pop and flush
Implement get/set_next_blob.
 - Old interface used to use GetByte
 - Later, GetByte was replaced with code that copies all data into a
single contiguous buffer so buffer bounds don't need to be checked for
every GetByte call.
 - get_next_blob allows data to be copied directly into a destination buffer
(e.g. in lib/filesystem.js) without first copying into an intermediate
buffer.

Fix handling of 64bit fields.
Fix device status handling.
2020-08-30 19:27:07 -05:00
Ernest Wong 590ae36343 VirtIO notify asserts - take notify_off into account 2020-08-30 19:27:07 -05:00
Ernest Wong 49221d015f Flip virtio<->device relationship and begin upgrade
If multiple devices need its own virtio interface, it's cleaner for
each device to contain its own virtio than for a single virtio to manage
multiple devices.

Replaced original virtio v0.9 header in BAR0 with several virtio v1.0
PCI capabilities.

Began abstracting virtqueues.
2020-08-30 19:27:07 -05:00
Fabian ad4dd48754 Implement number of links nlinks
via jor1k/454784af39c51bbf409eeb7d10d504835431f679
2020-08-30 19:27:02 -05:00
Fabian 34cb4335db Don't use variable from outer scope 2020-08-30 19:27:02 -05:00
Fabian 35148ec662 Use .set(.subarray) instead of manual loop 2020-08-30 19:27:02 -05:00
Fabian d29aad93ba Optimise 9p.ReceiveRequest by replacing GetByte with buffers
This optimises kernel-to-virtio-device calls, in particular applicable
to 9p file writes
2020-08-30 19:27:02 -05:00
Fabian d31b424a37 Also keep filesystem changes in state image 2020-08-30 19:27:02 -05:00
Luca Invernizzi 9a7eeffa3b 9P filesystem allows to set custom atime and mtime 2020-07-21 20:10:13 -05:00
copy 5eb5389e52 Port filesystem changes from jor1k
454784a  Count links in directory
43cf658  Finish fixing (c|a|m)time updating in MergeFile
2018-02-14 16:34:54 -06:00