[f2fs] Fix incorrect directory operations

In fs_test,
- For TestDirectoryReaddirRmAll of DirectoryTest,
    since results of readdir are not ordered by creation sequence in f2fs,
    check whether each readdir result is correct in an alternative way.

In f2fs,
- Use correct i_mode in GetProtocols.
- Check must_be_dir conditions in Rename and Unlink.
- Exclude ".." from results of Readdir.
- Set correct return value from Readdir.
- Add missing initialization for member variables of vnode.
- Check whether dir is unlinked before create or rename inside the dir.

Test: fx test directory-tests unlink-tests dot-dot-tests

Prerequisite: FUCHSIA_DIR$ patch -p1 < \
third_party/f2fs/patches/0003-f2fs-Handle-unordered-readdir-for-f2fs-in-TestDirect.patch

Change-Id: I72454f3dec3e8bd4c838a03234141a3c4da7c1ba
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/f2fs/+/536507
Reviewed-by: Brett Wilson <brettw@google.com>
4 files changed
tree: 58f317f6d1f5d692b9ba64a079ac708eab8adc6c
  1. patches/
  2. test_files/
  3. third_party/
  4. tools/
  5. AUTHORS
  6. bcache.cc
  7. bcache.h
  8. BUILD.gn
  9. checkpoint.cc
  10. CONTRIBUTING.md
  11. data.cc
  12. dir.cc
  13. dir.h
  14. dir_hash.cc
  15. f2fs.cc
  16. f2fs.h
  17. f2fs_internal.h
  18. f2fs_layout.h
  19. f2fs_lib.h
  20. f2fs_types.h
  21. file.cc
  22. file.h
  23. LICENSE
  24. mkfs.cc
  25. mkfs.h
  26. namei.cc
  27. node.cc
  28. node.h
  29. PATENTS
  30. README.md
  31. recovery.cc
  32. segment.cc
  33. segment.h
  34. super.cc
  35. vnode.cc
  36. vnode.h
README.md

What is F2FS?

F2FS is the most commonly used log-structured file system in Linux. It supports flash-friendly features such as adaptive logging, multi-head logging, fsync acceleration, and node address translation. For more information see: https://www.usenix.org/conference/fast15/technical-sessions/presentation/lee

Major Release

1st release (Apr-06-2021)

  • Features: mkfs, mount/umount, read, write, rmdir, mkdir, rename, fsync, lseek, link, unlink
  • Remarks
  • Fuchsia base code ; Thu Mar 11 08:53:24 2021 Prashanth Swaminathan,76a08ad1474 [speak] Migrate to new component templates
  • There is no cache. Every request is handled as a synchronous operation.
  • fsync() triggers checkpointing
  • lock granularity: file operation
  • LFS is used for block allocation by default, and IPU is forced when the number of free sections is below 50%.
  • no background/foreground gc
  • disable the roll-forward recovery
  • 6 active logs
  • disable the ext-identify feature
  • block allocation: LFS, IPU
  • fsck do nothing, but it returns true
  • no discard

2nd release (May-28-2021)

  • Features: truncate, ssr, fsync, recovery
  • Remarks
  • Fuchsia base code ; Thu May 20 07:25:45 2021 Yilong Li, 02c0dfff0fdb
  • support the roll-forward recovery and file level fsync()
  • block allocation: LFS, IPU, SSR
  • truncate

3rd release (June-25-2021)

  • Features: fsck, mount option, mkfs option
  • Remarts
  • fsck (base: bbf6e62)
  • support the ext-identify feature
  • support discard

4th release (July-30-2021 ~)

  • Testability
  • Features: buffered IO, gc (if writable PagedVfs is available)
  • Remarks
  • background/foreground gc
  • caching node/meta blocks
  • read ahead
  • Page level locking
  • buffered IO
  • mmap
  • IPU can be disabled.
  • support fvm
  • xattr

How to build

$ fx set core.x64 --with-base //bundles:tools --with-base //bundles:tests --with-base third_party/f2fs $ fx emu -N --headless (see third_party/f2fs/test_files/README.md for test)