History log of /fuchsia/zircon/system/ulib/fs/pseudo-dir.cpp
Revision Date Author Comments
# 11a637e8 12-Sep-2018 Sean Klein <smklein@google.com>

[fs][fidl] Replaced filesystem ioctls with FIDL.

This patch allows "ioctl" to be removed from the
C++ VFS Vnode interface.

IOCTL_VFS_MOUNT_FS -> Mount()
IOCTL_VFS_UNMOUNT_FS -> Unmount()
IOCTL_VFS_UNMOUNT_NODE -> UnmounteNode()
IOCTL_VFS_QUERY_FS -> QueryFilesystem()
IOCTL_VFS_MOUNT_MKDIR_FS -> MountAndCreate()
IOCTL_VFS_GET_DEVICE_PATH -> GetDevicePath()
IOCTL_VFS_WATCH_DIR -> WatchDir()

Test: fs-management / fs / blobfs / fvm tests, df manually

Change-Id: Iefe8ec251ca6b8f4e4578ceb61bae6dff7a59e3d


# 007799dd 18-Sep-2018 Ankur Mittal <anmittal@google.com>

[fs] Fix PseudoDir readdir

Readdir was returning ZX_ERR_* when there were more entries than supplied
buffer. Change it to ZX_OK as it is not a error to have pagination.

TEST=fs-vnode-test

Change-Id: Ifcb24578b3fccd69f513eb6b90289c1c27117435


# 155019a5 11-Sep-2018 Sean Klein <smklein@google.com>

[io][fidl] Update io.fidl to comply with the FIDL style guide

As documented:
https://fuchsia.googlesource.com/docs/+/master/development/api/fidl.md

- Constants must be named in ALL_CAPS_SNAKE_CASE.
- Enum members must be named in ALL_CAPS_SNAKE_CASE.

Test: CQ

Change-Id: I643e0aec420c3c61753fad15a03a79f6f4fa9d52


# 7f36f25d 23-Aug-2018 Sean Klein <smklein@google.com>

[fdio][fidl] Use unaligned dirents for readdir, add ino

Test: fs-tests
ZX-2502 #done

Change-Id: I93e932a629f25c7da9f9a1a06e022d907ada47ed


# 47c23a87 17-Jul-2018 Christopher R. Johnson <crjohns@google.com>

[fs] Optimize PseudoDir using a WAVL tree.

PseudoDir stores directory entries in a linked list. Insertions to the
list are O(1), but locating an element by name (for opening or removal)
is O(n). Additionally, Readdir may need to checkpoint its progress and
continue, but it must start from the beginning of the list each time. In
the worst case this is O(n^2).

This change replaces the storage for PseudoDir with two WAVL trees, one
sorted by name and the other by ID. Insertions/Lookups/Removals are now
O(lg n). Readdir may still need to restart O(n) times, so Readdir is now
O(n lg n).

This changed the benchmarks as follows:

PseudoDir/Create 33.24%
PseudoDir/RemoveAdd/1 38.44%
PseudoDir/RemoveAdd/8 114.99%
PseudoDir/RemoveAdd/64 11.94%
PseudoDir/RemoveAdd/512 -75.92%
PseudoDir/RemoveAdd/4k -95.53%
PseudoDir/RemoveAdd/16k -98.76%
PseudoDir/Readdir/1/1024 2.87%
PseudoDir/Readdir/8/1024 -4.76%
PseudoDir/Readdir/64/1024 -72.69%
PseudoDir/Readdir/512/1024 -95.63%
PseudoDir/Readdir/4k/1024 -99.66%
PseudoDir/Readdir/16k/1024 -99.87%
PseudoDir/Readdir/1/4k 2.97%
PseudoDir/Readdir/8/4k -5.73%
PseudoDir/Readdir/64/4k -72.71%
PseudoDir/Readdir/512/4k -95.60%
PseudoDir/Readdir/4k/4k -99.67%
PseudoDir/Readdir/16k/4k -99.92%
PseudoDir/Readdir/1/32k 6.65%
PseudoDir/Readdir/8/32k -5.22%
PseudoDir/Readdir/64/32k -72.60%
PseudoDir/Readdir/512/32k -95.56%
PseudoDir/Readdir/4k/32k -99.65%
PseudoDir/Readdir/16k/32k -99.88%
PseudoDir/Readdir/1/64k 2.12%
PseudoDir/Readdir/8/64k -5.35%
PseudoDir/Readdir/64/64k -72.47%
PseudoDir/Readdir/512/64k -95.53%
PseudoDir/Readdir/4k/64k -99.66%
PseudoDir/Readdir/16k/64k -99.87%

The additional overhead outweighs the gains for only tens of entries for
removal and addition. For hundreds or thousands of entries, the
optimized version is far better.

This has a small overhead for small Readdir executions, but it rapidly
outperforms the original implementation on larger directories.

See the bug for detailed benchmark run information.

TEST=zircon$ runtests -t fs-vnode-test; fuchsia$ run zircon_benchmarks \
--benchmark_filter=Pseudo

ZX-2374: #done

Change-Id: I0e41c560e50ac7cf50d6fd9aaddf0d2d20306b04


# d07a82c2 07-May-2018 Ankur Mittal <anmittal@google.com>

[fs] Add IsEmpty function to PseudoDir

Change-Id: I03ba8c2e61b6a4d6bf32607218f7927555fa18e5


# 20460b5f 06-Nov-2017 Sean Klein <smklein@google.com>

[fs] Use the Fuchsia-defined open flags

Re-lands 2aff2cba029cf0f7e98e6d19f6dc7a663c318227

This change uses the Fuchsia-defined flags on the wire
as well as on filesystem servers. Clients interacting
with filesystems through the POSIX compatibility layer
can continue using POSIX open flags; they will be translated
by the RIO layers client-side.

ZX-1359 #comment In Progress

Change-Id: I4972c024547a0daa2146831e49e34d3ef905d4b4


# c830a868 14-Nov-2017 Sean Klein <smklein@google.com>

Revert "[fs] Use the Fuchsia-defined open flags"

This reverts commit 2aff2cba029cf0f7e98e6d19f6dc7a663c318227.

Reason for revert: Fuchsia uses upstream Rust, which doesn't pull these constants from our C library, but their own. I'll need to wait a few days for us to update upstream Rust before we can make progress here.

Original change's description:
> [fs] Use the Fuchsia-defined open flags
>
> This change uses the Fuchsia-defined flags on the wire
> as well as on filesystem servers. Clients interacting
> with filesystems through the POSIX compatibility layer
> can continue using POSIX open flags; they will be translated
> by the RIO layers client-side.
>
> ZX-1359 #comment In Progress
>
> Change-Id: I27dfdea2024183d5d59daa1ed7d8886d89d503d0

TBR=kulakowski@google.com,smklein@google.com,swetland@google.com,mcgrathr@google.com,planders@google.com

Change-Id: If93c2da36f92ea28ed013a61c01c6ec521da26cc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true


# 2aff2cba 06-Nov-2017 Sean Klein <smklein@google.com>

[fs] Use the Fuchsia-defined open flags

This change uses the Fuchsia-defined flags on the wire
as well as on filesystem servers. Clients interacting
with filesystems through the POSIX compatibility layer
can continue using POSIX open flags; they will be translated
by the RIO layers client-side.

ZX-1359 #comment In Progress

Change-Id: I27dfdea2024183d5d59daa1ed7d8886d89d503d0


# 697f0cdf 27-Oct-2017 Jeff Brown <jeffbrown@google.com>

[fs][pseudo-dir] Prefer fbl::StringPiece for entry removal.

When adding an entry, it's handy to use an fbl::String since we need
to retain it on the heap. When removing an entry, this isn't necessary
since we're only comparing the content so we can use fbl::StringPiece.

Change-Id: Ia5cb34983c9cfad8b1c3b801723f7b464ff4563f


# c0ffb134 15-Oct-2017 Sean Klein <smklein@google.com>

[fs] Make readdir return actual size as output parameter

One of many commits trying to reduce the overloaded use of
"zx_status_t".

ZX-1189 #done

Change-Id: I8b393b2d5440abfc7646223cab9f9c94115538a4


# 34eacd46 28-Jul-2017 Jeff Brown <jeffbrown@google.com>

[libfs] Define pseudo-dir and pseudo-file vnode types.

Pseudo-dir is appropriate for publishing directories with a small
number of nodes which the client cannot modify.

Pseudo-file is appropriate for publishing dynamic properties.
It is available in buffered and unbuffered flavors.

Change-Id: I11d927c3d7d50ccc725a91377aaacfc1209dce1b