Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: aliyun/ossfs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.80.7
Choose a base ref
...
head repository: aliyun/ossfs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Jul 25, 2023

  1. Copy the full SHA
    a7b6a4d View commit details
  2. Copy the full SHA
    eced51b View commit details
  3. Copy the full SHA
    45708b3 View commit details
  4. Copy the full SHA
    3d3f111 View commit details
  5. Copy the full SHA
    4f49b41 View commit details
  6. Copy the full SHA
    5e50345 View commit details
  7. Copy the full SHA
    9cef6c4 View commit details
  8. Copy the full SHA
    c7d31b3 View commit details
  9. Copy the full SHA
    404cf5f View commit details
  10. Fixed a bug could not change the mode while the file was opened.

    Fixed segmentation fault caused by file write failure.
    huiguangjun committed Jul 25, 2023
    Copy the full SHA
    fc4801f View commit details
  11. Copy the full SHA
    d46c251 View commit details
  12. Copy the full SHA
    21258aa View commit details
  13. Copy the full SHA
    c7f6495 View commit details
  14. Copy the full SHA
    8d6562d View commit details
  15. update readme

    huiguangjun committed Jul 25, 2023
    Copy the full SHA
    5b53d28 View commit details
  16. Copy the full SHA
    d5b5d63 View commit details
  17. Copy the full SHA
    e4d5708 View commit details
  18. Copy the full SHA
    4838ab9 View commit details
  19. update readme

    huiguangjun committed Jul 25, 2023
    Copy the full SHA
    a1fbf9e View commit details
  20. update ChangeLog

    huiguangjun committed Jul 25, 2023
    Copy the full SHA
    60bb9c1 View commit details
  21. Copy the full SHA
    07cca4c View commit details

Commits on Jul 26, 2023

  1. update help content.

    huiguangjun committed Jul 26, 2023
    Copy the full SHA
    8f9c0ba View commit details

Commits on Jul 27, 2023

  1. update bench.

    huiguangjun committed Jul 27, 2023
    Copy the full SHA
    d19e097 View commit details
  2. add bench test data.

    huiguangjun committed Jul 27, 2023
    Copy the full SHA
    5a5df6e View commit details
  3. Release 1.91.1

    huiguangjun committed Jul 27, 2023
    Copy the full SHA
    fff31f0 View commit details

Commits on Aug 22, 2023

  1. Copy the full SHA
    ee2c8ce View commit details

Commits on Aug 23, 2023

  1. Fix some typo.

    huiguangjun committed Aug 23, 2023
    Copy the full SHA
    621569a View commit details
  2. update build script.

    huiguangjun committed Aug 23, 2023
    Copy the full SHA
    2d2d062 View commit details

Commits on Oct 12, 2023

  1. update build script.

    huiguangjun committed Oct 12, 2023
    Copy the full SHA
    dd4ee86 View commit details

Commits on Oct 20, 2023

  1. Copy the full SHA
    b2b38eb View commit details

Commits on Feb 29, 2024

  1. add new options to support reading files directly. (#163)

    * port threadpool from s3fs.
    
    * add new options to support  reading files directly without using local disk.
    chenwk96 authored Feb 29, 2024
    Copy the full SHA
    1beb8c0 View commit details

Commits on Mar 5, 2024

  1. update build scripts.

    chenwk96 committed Mar 5, 2024
    Copy the full SHA
    23e7fd8 View commit details
  2. Copy the full SHA
    a788d27 View commit details

Commits on Mar 8, 2024

  1. Copy the full SHA
    c9744bb View commit details

Commits on May 13, 2024

  1. update change log. (#165)

    chenwk96 authored May 13, 2024
    Copy the full SHA
    fd2a30c View commit details

Commits on Jun 5, 2024

  1. Copy the full SHA
    961da9f View commit details
  2. add debug log for type conflict.

    chenwk96 authored and FangQianan committed Jun 5, 2024
    Copy the full SHA
    b7d14e9 View commit details
  3. support cleaning file cache ahead when file reading && direct read fr…

    …om oss when no space.
    chenwk96 authored and FangQianan committed Jun 5, 2024
    Copy the full SHA
    25dc29c View commit details
  4. Copy the full SHA
    be7b241 View commit details
  5. Convert BodyData to std::string.

    chenwk96 authored and FangQianan committed Jun 5, 2024
    Copy the full SHA
    a183c7f View commit details
  6. Copy the full SHA
    f273187 View commit details
  7. 1. add an option: direct_read_backward_chunks to specify the num of c…

    …hunks to be saved on the backward direction; 2. add mixed_direct_read_mode
    FangQianan committed Jun 5, 2024
    Copy the full SHA
    7e5b2c9 View commit details
  8. update changeLog for v1.91.3.

    chenwk96 authored and FangQianan committed Jun 5, 2024
    Copy the full SHA
    f56615e View commit details

Commits on Jun 6, 2024

  1. Copy the full SHA
    44077bb View commit details

Commits on Sep 24, 2024

  1. release v1.91.4

    fangqianan.fqa authored and FangQianan committed Sep 24, 2024
    Copy the full SHA
    63c35bb View commit details

Commits on Sep 26, 2024

  1. Copy the full SHA
    eb95599 View commit details

Commits on Dec 25, 2024

  1. release 1.91.5

    FangQianan committed Dec 25, 2024
    Copy the full SHA
    16edb35 View commit details
  2. Merge pull request #173 from aliyun/release_1.91.5

    release 1.91.5
    FangQianan authored Dec 25, 2024
    Copy the full SHA
    5ebbc2b View commit details

Commits on Mar 26, 2025

  1. release 1.91.6

    FangQianan committed Mar 26, 2025
    Copy the full SHA
    460ffb6 View commit details
  2. Merge pull request #174 from aliyun/release_1.91.6

    release 1.91.6
    FangQianan authored Mar 26, 2025
    Copy the full SHA
    cd4a877 View commit details
Showing with 36,471 additions and 15,633 deletions.
  1. +42 −0 .clang-tidy
  2. +32 −0 .gitattributes
  3. +110 −29 .gitignore
  4. +0 −23 .travis.yml
  5. +5 −1 AUTHORS
  6. +89 −0 COMPILATION.md
  7. +751 −274 ChangeLog
  8. +1 −1 INSTALL
  9. +51 −5 Makefile.am
  10. +65 −35 README-CN.md
  11. +79 −61 README.md
  12. +17 −11 autogen.sh
  13. +44 −0 bench/Dockerfile
  14. +12 −0 bench/README.md
  15. +11 −0 bench/bench.data
  16. +100 −0 bench/bench.goofys
  17. +100 −0 bench/bench.ossfs
  18. +100 −0 bench/bench.ossfs+readdir-optimize
  19. BIN bench/bench.png
  20. +100 −0 bench/bench.s3fs
  21. +450 −0 bench/bench.sh
  22. +94 −0 bench/bench_format.py
  23. +67 −0 bench/bench_graph.gnuplot
  24. +71 −0 bench/bench_graph3.gnuplot
  25. +75 −0 bench/bench_graph_all.gnuplot
  26. +72 −0 bench/bench_graph_cached.gnuplot
  27. +20 −0 bench/format_bench.sh
  28. +15 −0 bench/format_bench3.sh
  29. +16 −0 bench/format_bench_all.sh
  30. +30 −0 bench/gen_small.py
  31. +110 −0 bench/riofs.conf.xml
  32. +147 −0 bench/run_bench.sh
  33. +376 −285 configure.ac
  34. +1 −2 doc/Makefile.am
  35. +0 −259 doc/man/ossfs.1
  36. +469 −0 doc/man/ossfs.1.in
  37. +473 −369 scripts/build-pkg.py
  38. +12 −0 scripts/docker-file/alinux/2/Dockerfile
  39. +11 −0 scripts/docker-file/alinux/3/Dockerfile
  40. +1 −0 scripts/docker-file/anolisos/7.x/Dockerfile
  41. +4 −1 scripts/docker-file/anolisos/8.x/Dockerfile
  42. +4 −1 scripts/docker-file/centos/7.x/Dockerfile
  43. +4 −1 scripts/docker-file/centos/8.x/Dockerfile
  44. +1 −0 scripts/docker-file/ubuntu/14.04/Dockerfile
  45. +6 −1 scripts/docker-file/ubuntu/16.04/Dockerfile
  46. +6 −1 scripts/docker-file/ubuntu/18.04/Dockerfile
  47. +6 −1 scripts/docker-file/ubuntu/20.04/Dockerfile
  48. +10 −0 scripts/docker-file/ubuntu/22.04/Dockerfile
  49. +45 −0 scripts/ossfs-coverage-centos7.sh
  50. +88 −9 src/Makefile.am
  51. +278 −0 src/addhead.cpp
  52. +75 −0 src/addhead.h
  53. +80 −0 src/autolock.cpp
  54. +60 −0 src/autolock.h
  55. +815 −345 src/cache.cpp
  56. +168 −94 src/cache.h
  57. +30 −120 src/common.h
  58. +37 −57 src/common_auth.cpp
  59. +3,961 −3,616 src/curl.cpp
  60. +357 −469 src/curl.h
  61. +127 −0 src/curl_handlerpool.cpp
  62. +64 −0 src/curl_handlerpool.h
  63. +368 −0 src/curl_multi.cpp
  64. +79 −0 src/curl_multi.h
  65. +457 −0 src/curl_util.cpp
  66. +63 −0 src/curl_util.h
  67. +297 −0 src/direct_reader.cpp
  68. +128 −0 src/direct_reader.h
  69. +890 −2,189 src/fdcache.cpp
  70. +80 −206 src/fdcache.h
  71. +165 −0 src/fdcache_auto.cpp
  72. +68 −0 src/fdcache_auto.h
  73. +2,331 −0 src/fdcache_entity.cpp
  74. +159 −0 src/fdcache_entity.h
  75. +443 −0 src/fdcache_fdinfo.cpp
  76. +98 −0 src/fdcache_fdinfo.h
  77. +1,009 −0 src/fdcache_page.cpp
  78. +136 −0 src/fdcache_page.h
  79. +134 −0 src/fdcache_pseudofd.cpp
  80. +65 −0 src/fdcache_pseudofd.h
  81. +281 −0 src/fdcache_stat.cpp
  82. +64 −0 src/fdcache_stat.h
  83. +284 −0 src/fdcache_untreated.cpp
  84. +73 −0 src/fdcache_untreated.h
  85. +250 −304 src/gnutls_auth.cpp
  86. +77 −0 src/memorypool.cpp
  87. +35 −0 src/memorypool.h
  88. +419 −0 src/metaheader.cpp
  89. +72 −0 src/metaheader.h
  90. +159 −0 src/mpu_util.cpp
  91. +64 −0 src/mpu_util.h
  92. +139 −0 src/mvnode.cpp
  93. +53 −0 src/mvnode.h
  94. +147 −176 src/nss_auth.cpp
  95. +295 −218 src/openssl_auth.cpp
  96. +106 −0 src/psemaphore.h
  97. +4,392 −4,167 src/s3fs.cpp
  98. +44 −48 src/s3fs.h
  99. +16 −16 src/s3fs_auth.h
  100. +1,347 −0 src/s3fs_cred.cpp
  101. +164 −0 src/s3fs_cred.h
  102. +145 −0 src/s3fs_extcred.h
  103. +52 −0 src/s3fs_global.cpp
  104. +613 −0 src/s3fs_help.cpp
  105. +41 −0 src/s3fs_help.h
  106. +318 −0 src/s3fs_logger.cpp
  107. +240 −0 src/s3fs_logger.h
  108. +278 −1,097 src/s3fs_util.cpp
  109. +21 −104 src/s3fs_util.h
  110. +607 −0 src/s3fs_xml.cpp
  111. +57 −0 src/s3fs_xml.h
  112. +325 −0 src/s3objlist.cpp
  113. +83 −0 src/s3objlist.h
  114. +271 −0 src/sighandlers.cpp
  115. +73 −0 src/sighandlers.h
  116. +539 −282 src/string_util.cpp
  117. +84 −28 src/string_util.h
  118. +302 −0 src/test_curl_util.cpp
  119. BIN src/test_mempool
  120. +197 −0 src/test_mempool.cpp
  121. +82 −0 src/test_page_list.cpp
  122. +234 −47 src/test_string_util.cpp
  123. +82 −14 src/test_util.h
  124. +286 −0 src/threadpoolman.cpp
  125. +105 −0 src/threadpoolman.h
  126. +332 −0 src/types.h
  127. +27 −7 test/Makefile.am
  128. +4 −0 test/aws_cli_config
  129. +2 −0 test/chaos-http-proxy.conf
  130. +135 −0 test/direct_read_test.cc
  131. +143 −0 test/filter-suite-log.sh
  132. +336 −15 test/integration-test-common.sh
  133. +2,801 −374 test/integration-test-main.sh
  134. +51 −0 test/junk_data.c
  135. +80 −52 test/mergedir.sh
  136. +111 −0 test/mix_direct_read_test.cc
  137. +0 −7 test/require-root.sh
  138. +66 −0 test/run_tests_using_sanitizers.sh
  139. +4 −2 test/s3proxy.conf
  140. +30 −19 test/sample_ahbe.conf
  141. +86 −63 test/sample_delcache.sh
  142. +102 −75 test/small-integration-test.sh
  143. +0 −28 test/stat_cache_test.py
  144. +394 −0 test/test-utils.sh
  145. +17 −0 test/test_policies/policy.json
  146. +60 −0 test/test_policies/policy_noaccess_prefix.json
  147. +236 −0 test/test_policy_mount.sh
  148. +171 −0 test/testlib.cpp
  149. +86 −6 test/ut_test.py
  150. +266 −0 test/write_multiblock.cc
  151. +0 −18 test/write_multiple_offsets.py
42 changes: 42 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Checks: '
-*,
bugprone-*,
-bugprone-branch-clone,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-macro-parentheses,
-bugprone-narrowing-conversions,
-bugprone-unhandled-self-assignment,
google-*,
-google-build-using-namespace,
-google-readability-casting,
-google-readability-function-size,
-google-readability-todo,
-google-runtime-int,
-google-runtime-references,
misc-*,
-misc-no-recursion,
-misc-redundant-expression,
-misc-unused-parameters,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-deprecated-headers,
-modernize-loop-convert,
-modernize-return-braced-init-list,
-modernize-use-auto,
-modernize-use-nullptr,
-modernize-use-trailing-return-type,
-modernize-use-using,
performance-*,
-performance-no-int-to-ptr,
portability-*,
readability-*,
-readability-else-after-return,
-readability-function-cognitive-complexity,
-readability-function-size,
-readability-implicit-bool-conversion,
-readability-inconsistent-declaration-parameter-name,
-readability-isolate-declaration,
-readability-magic-numbers,
-readability-named-parameter,
-readability-simplify-boolean-expr'
32 changes: 32 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# ossfs - FUSE-based file system backed by Alibaba Cloud OSS
#
# Copyright(C) 2007 Randy Rizun <rrizun@gmail.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#

* text eol=lf

*.png binary

#
# Local variables:
# tab-width: 4
# c-basic-offset: 4
# End:
# vim600: noet sw=4 ts=4 fdm=marker
# vim<600: noet sw=4 ts=4
#
139 changes: 110 additions & 29 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,30 +1,111 @@
#
# ossfs - FUSE-based file system backed by Alibaba Cloud OSS
#
# Copyright(C) 2007 Randy Rizun <rrizun@gmail.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#

#
# Compiled Object files
#
*.slo
*.lo
*.o
/Makefile
/Makefile.in
/aclocal.m4
/autom4te.cache/
/config.guess
/config.log
/config.status
/config.sub
/stamp-h1
/config.h
/config.h.in
/configure
/depcomp
/test-driver
/compile
/doc/Makefile
/doc/Makefile.in
/install-sh
/missing
/src/.deps/
/src/Makefile
/src/Makefile.in
/src/s3fs
/src/test_*
/test/.deps/
/test/Makefile
/test/Makefile.in
/test/*.log
/default_commit_hash
*.Po
*.Plo

#
# autotools/automake
#
aclocal.m4
autom4te.cache
autoscan.log
config.guess
config.h
config.h.in
config.h.in~
config.log
config.status
config.sub
configure
configure.scan
depcomp
install-sh
libtool
ltmain.sh
m4
m4/*
missing
stamp-h1
Makefile
Makefile.in
test-driver
compile
missing

#
# man page
#
doc/man/ossfs.1

#
# object directories
#
.deps
.libs
*/.deps
*/.deps/*
*/.libs
*/.libs/*

#
# each directories
#
*.log
*.trs
default_commit_hash
src/ossfs
src/test_curl_util
src/test_page_list
src/test_string_util
src/test_mempool
test/chaos-http-proxy-*
test/junk_data
test/s3proxy-*
test/write_multiblock
test/direct_read_test
test/install_ossutil.sh
test/mix_direct_read_test
#
# Windows ports
#
*.dll
*.exe
fuse.pc
WinFsp/
bin/

.vscode/
dist
configure~
#
# Local variables:
# tab-width: 4
# c-basic-offset: 4
# End:
# vim600: noet sw=4 ts=4 fdm=marker
# vim<600: noet sw=4 ts=4
#
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

6 changes: 5 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
1. Randy Rizun <rrizun@gmail.com>

Wrote from scratch the initial version of S3FS.
Wrote from scratch the initial version of OSSFS.

2. Dan Moore <mooredan@suncup.net>

@@ -17,3 +17,7 @@ Bugfixes, performance and other improvements.
5. Takeshi Nakatani <ggtakec@gmail.com>

Bugfixes, performance and other improvements.

6. Andrew Gaul <gaul@gaul.org>

Bugfixes, performance and other improvements.
89 changes: 89 additions & 0 deletions COMPILATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Compilation from source code

These are generic instructions should work on almost any GNU/Linux, macOS, BSD, or similar.

If you want specific instructions for some distributions, check the [wiki](https://https://github.com/aliyun/ossfs/wiki/install).

Keep in mind using the pre-built packages when available.

1. Ensure your system satisfies build and runtime dependencies for:

* fuse >= 2.8.4
* automake
* gcc-c++
* make
* libcurl
* libxml2
* openssl
* mime.types (the package providing depends on the OS)
* ossfs tries to detect `/etc/mime.types` as default regardless of the OS
* Else ossfs tries to detect `/etc/apache2/mime.types` if OS is macOS
* ossfs exits with an error if these files are not exist
* Alternatively, you can set mime.types file path with `mime` option without detecting these default files
* pkg-config (or your OS equivalent)

2. Then compile from master via the following commands:

```
git clone https://github.com/aliyun/ossfs.git
cd ossfs
./autogen.sh
./configure
make
sudo make install
```

## Compilation on Windows (using MSYS2)

On Windows, use [MSYS2](https://www.msys2.org/) to compile for itself.

1. Install [WinFsp](https://github.com/billziss-gh/winfsp) to your machine.
2. Install dependencies onto MSYS2:

```sh
pacman -S git autoconf automake gcc make pkg-config libopenssl-devel libcurl-devel libxml2-devel libzstd-devel
```

3. Clone this repository, then change directory into the cloned one.
4. Copy WinFsp files to the directory:

```sh
cp -r "/c/Program Files (x86)/WinFsp" "./WinFsp"
```

5. Write `fuse.pc` to resolve the package correctly:

```sh
cat > ./fuse.pc << 'EOS'
arch=x64
prefix=${pcfiledir}/WinFsp
incdir=${prefix}/inc/fuse
implib=${prefix}/bin/winfsp-${arch}.dll
Name: fuse
Description: WinFsp FUSE compatible API
Version: 2.8.4
URL: http://www.secfs.net/winfsp/
Libs: "${implib}"
Cflags: -I"${incdir}"
EOS
```
6. Compile using the command line:
```sh
./autogen.sh
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(pwd)" ./configure
make
```
7. Copy binary files to distribute at one place:
```sh
mkdir ./bin
cp ./src/ossfs.exe ./bin/
cp ./WinFsp/bin/winfsp-x64.dll ./bin/
cp /usr/bin/msys-*.dll ./bin/
```
8. Distribute these files.
1,025 changes: 751 additions & 274 deletions ChangeLog

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion INSTALL
Original file line number Diff line number Diff line change
@@ -124,7 +124,7 @@ architecture at a time in the source code directory. After you have
installed the package for one architecture, use `make distclean' before
reconfiguring for another architecture.

On MacOS X 10.5 and later systems, you can create libraries and
On macOS 10.5 and later systems, you can create libraries and
executables that work on multiple system types--known as "fat" or
"universal" binaries--by specifying multiple `-arch' options to the
compiler but only a single `-arch' option to the preprocessor. Like
56 changes: 51 additions & 5 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
######################################################################
# s3fs - FUSE-based file system backed by Aliyun OSS
# ossfs - FUSE-based file system backed by Alibaba Cloud OSS
#
# Copyright 2007-2008 Randy Rizun <rrizun@gmail.com>
#
@@ -17,6 +17,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
######################################################################

SUBDIRS=src test doc

EXTRA_DIST=doc default_commit_hash
@@ -28,12 +29,57 @@ dist-hook:
release : dist ../utils/release.sh
../utils/release.sh $(DIST_ARCHIVES)

.PHONY: cppcheck shellcheck

cppcheck:
cppcheck --quiet --error-exitcode=1 \
--inline-suppr \
--std=c++11 \
--xml \
-D HAVE_ATTR_XATTR_H \
-D HAVE_SYS_EXTATTR_H \
-D HAVE_MALLOC_TRIM \
-U CURLE_PEER_FAILED_VERIFICATION \
--enable=all \
-U ENOATTR \
--enable=warning,style,information,missingInclude \
--suppress=missingIncludeSystem \
--suppress=unsignedLessThanZero \
--suppress=unusedFunction \
--suppress=variableScope \
--suppress=unmatchedSuppression \
src/ test/

#
# ShellCheck
#
SHELLCHECK_CMD = shellcheck
SHELLCHECK_SH_OPT = --shell=sh
SHELLCHECK_BASH_OPT = --shell=bash

# [NOTE]
# To control error warnings as a whole, specify the "SC<number>" with the following variables.
#
SHELLCHECK_COMMON_IGN = --exclude=SC1091
SHELLCHECK_CUSTOM_IGN = --exclude=SC1091

shellcheck:
@if type shellcheck > /dev/null 2>&1; then \
echo "* ShellCheck version"; \
$(SHELLCHECK_CMD) --version; \
echo ""; \
echo "* Check all sh files with ShellCheck"; \
LC_ALL=C.UTF-8 $(SHELLCHECK_CMD) $(SHELLCHECK_SH_OPT) $(SHELLCHECK_COMMON_IGN) $$(grep '#![[:space:]]*/bin/sh' $$(find . -type f -name \*.sh) | sed -e 's|^\(.*\):#\!.*$$|\1|g') || exit 1; \
echo "-> No error was detected."; \
echo ""; \
echo "* Check all bash files with ShellCheck"; \
LC_ALL=C.UTF-8 $(SHELLCHECK_CMD) $(SHELLCHECK_BASH_OPT) $(SHELLCHECK_COMMON_IGN) $$(grep '#![[:space:]]*/bin/bash' $$(find . -type f -name \*.sh) | sed -e 's|^\(.*\):#\!.*$$|\1|g') || exit 1; \
echo "-> No error was detected."; \
else \
echo "* ShellCheck is not installed, so skip this."; \
fi

#
# Local variables:
# tab-width: 4
# c-basic-offset: 4
# End:
# vim600: expandtab sw=4 ts= fdm=marker
# vim<600: expandtab sw=4 ts=4
#
100 changes: 65 additions & 35 deletions README-CN.md
Original file line number Diff line number Diff line change
@@ -14,19 +14,30 @@ ossfs 能让您在Linux/Mac OS X 系统中把Aliyun OSS bucket 挂载到本地

ossfs 基于s3fs 构建,具有s3fs 的全部功能。主要功能包括:

* 支持POSIX 文件系统的大部分功能,包括文件读写,目录,链接操作,权限,
uid/gid,以及扩展属性(extended attributes)
* 通过OSS 的multipart 功能上传大文件。
* MD5 校验保证数据完整性。
* 支持POSIX 文件系统的大部分功能,包括文件读写,目录,链接操作,权限,uid/gid,以及扩展属性(extended attributes)
* 支持随机写和追加写
* 大文件通过分片方式(multi-part api)上传
* 重名名通过拷贝(single-part copy/multi-part copy)接口
* 可选择开启服务端加密
* 支持MD5校验保证数据完整性
* 使用内存缓存元数据
* 依赖本地文件作为缓存

除了以上功能, ossfs 还具备自己的特性.
* 默认使用single-part拷贝以提升大文件的重名性能
* 可选符号链接信息保存在对象的元数据里
* 可选开启目录读取优化模式,该模式下会忽略如下文件信息,atime/ctime, uid/gid 和 permissions
* 可选开启直读模式,该模式下,读取文件时,数据下载到内存而非磁盘,再从内存中读取,从而提升顺序读性能

### 安装

#### 预编译的安装包

我们为常见的linux发行版制作了安装包:

- Ubuntu-14.04
- CentOS-7.0/6.5/5.11
- Ubuntu-14.04 or later
- CentOS-7.0 or later
- Anolis-7 or later

请从[版本发布页面][releases]选择对应的安装包下载安装,建议选择最新版本。

@@ -38,16 +49,16 @@ sudo apt-get install gdebi-core
sudo gdebi your_ossfs_package
```

- 对于CentOS6.5及以上,安装命令为:
- 对于CentOS,安装命令为:

```
sudo yum localinstall your_ossfs_package
```

- 对于CentOS5,安装命令为:
- 对于Anolis,安装命令为:

```
sudo yum localinstall your_ossfs_package --nogpgcheck
sudo yum localinstall your_ossfs_package
```

#### 源码安装
@@ -79,21 +90,50 @@ make
sudo make install
```

其它平台,请参阅[编译说明](COMPILATION.md)

### 运行

设置bucket name, access key/id信息,将其存放在/etc/passwd-ossfs 文件中,
注意这个文件的权限必须正确设置,建议设为640。如果不使用默认的文件路径,文件权限建议设置为600。
ossfs的密钥文件的默认路径如下:
* 用户主目录中 `.passwd-ossfs` 文件 ( 例如 `${HOME}/.passwd-ossfs`)
* 系统路径文件 `/etc/passwd-ossfs`

设置bucket name, access key/id信息,将其存放在`${HOME}/.passwd-ossfs` 文件中,并设置成仅限所有者的权限,即600。
如果密钥文件路径为`/etc/passwd-ossfs`, 可以设置成640


```
echo my-bucket:my-access-key-id:my-access-key-secret > /etc/passwd-ossfs
chmod 640 /etc/passwd-ossfs
echo my-access-key-id:my-access-key-secret > ${HOME}/.passwd-ossfs
chmod 600 ${HOME}/.passwd-ossfs
```

将oss bucket mount到指定目录
`my-bucket` 挂载到指定目录`/path/to/mountpoint`

```
ossfs my-bucket my-mount-point -ourl=my-oss-endpoint
ossfs my-bucket /path/to/mountpoint -ourl=my-oss-endpoint
```

如果您在使用ossfs的过程中遇到错误,可以开启调试日志:

```
ossfs my-bucket /path/to/mountpoint -ourl=my-oss-endpoint -o dbglevel=info -f -o curldbg
```

您可以在`/etc/fstab`加入以下命令,在开机自动挂载目录:

```
my-bucket /path/to/mountpoint fuse.ossfs _netdev,allow_other,url=my-oss-endpoint 0 0
```

注意一: 您需要将密钥等信息写入`/etc/passwd-ossfs`文件里, 并将文件权限修改为640

```
echo my-access-key-id:my-access-key-secret > /etc/passwd-ossfs
chmod 600 /etc/passwd-ossfs
```

注意二:您可能还需要确保`netfs`服务已经启动

#### 示例

`my-bucket`这个bucket挂载到`/tmp/ossfs`目录下,AccessKeyId是`faint`
@@ -121,12 +161,10 @@ fusermount -u /tmp/ossfs # non-root user

ossfs my-bucket /tmp/ossfs -ourl=http://oss-cn-hangzhou-internal.aliyuncs.com

- 在linux系统中,[updatedb][updatedb]会定期地扫描文件系统,如果不想
ossfs的挂载目录被扫描,可参考[FAQ][FAQ-updatedb]设置跳过挂载目录
- 如果你没有使用[eCryptFs][ecryptfs]等需要[XATTR][xattr]的文件系统,可
以通过添加`-o noxattr`参数来提升性能
- ossfs允许用户指定多组bucket/access_key_id/access_key_secret信息。当
有多组信息,写入passwd-ossfs的信息格式为:
- 在linux系统中,[updatedb][updatedb]会定期地扫描文件系统,
如果不想ossfs的挂载目录被扫描,可参考[FAQ][FAQ-updatedb]设置跳过挂载目录
- ossfs允许用户指定多组bucket/access_key_id/access_key_secret信息。
当有多组信息,写入passwd-ossfs的信息格式为:

bucket1:access_key_id1:access_key_secret1
bucket2:access_key_id2:access_key_secret2
@@ -161,22 +199,14 @@ fusermount -u /tmp/ossfs # non-root user

ossfs提供的功能和性能和本地文件系统相比,具有一些局限性。具体包括:

* 随机或者追加写文件会导致整个文件的重写。
* 元数据操作,例如list directory,性能较差,因为需要远程访问oss服务器。
* 文件/文件夹的rename操作不是原子的。
* 多个客户端挂载同一个oss bucket时,依赖用户自行协调各个客户端的行为。例如避免多个客户端写同一个文件等等。
* 不支持hard link。
* 随机或者追加写文件会导致整个文件的重写
* 元数据操作,例如list directory,性能较差,因为需要远程访问oss服务器
* 文件/文件夹的rename操作不是原子的
* 多个客户端挂载同一个oss bucket时,依赖用户自行协调各个客户端的行为。例如避免多个客户端写同一个文件等等
* 不支持hard link
* 仅检测本地修改,而不检测其他客户端或工具的外部修改
* 不适合用在高并发读/写的场景,这样会让系统的load升高

### 参与开发

0. 开发流程参考:https://github.com/rockuw/oss-sdk-status#development-oss-members-only
1. 提交代码后,确保travis CI是PASS的
2. 每发布一个新的版本:
- 运行`scripts/build-pkg.py`生成相应的安装包
-[Release页面][releases]发布一个版本
- 将生成的安装包上传到相应的Release下面

### 常见问题

[FAQ](https://github.com/aliyun/ossfs/wiki/FAQ)
140 changes: 79 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
@@ -7,26 +7,35 @@

## Introduction

The OSSFS enables you to mount Alibaba Cloud OSS buckets to a local file in Linux/Mac OS X systems.
The ossfs enables you to mount Alibaba Cloud OSS buckets to a local file in Linux, macOS, and FreeBSD systems.
In the system, you can conveniently operate on objects in OSS while using the local file system to maintain data sharing.

## Features

The OSSFS is built based on S3FS and has all the features of S3FS. Main features:
The ossfs is built based on s3fs and has all the features of s3fs. Main features:

* Support a majority of the POSIX file system features, including file read/write, directory, link operation, permission,
uid/gid, and extended attributes).
* Support upload of large files through the OSS multipart feature.
* Support MD5 verification to ensure data integrity.
* large subset of POSIX including reading/writing files, directories, symlinks, mode, uid/gid, and extended attributes
* allows random writes and appends
* large files via multi-part upload
* renames via server-side copy
* optional server-side encryption
* data integrity via MD5 hashes
* in-memory metadata caching
* local disk data caching

## Install OSSFS
In addition to the above features, ossfs also has its own features.
* renames via server-side single-part copy to improve large files renaming performance
* optional saves the symbolic link target in object user metadata
* optional improve readdir perfermance by ignoring metadata-atime/ctime, uid/gid, and permissions
* optional improve sequential-read performance by downloading file data to and reading from the memory instead of the disk

### Precompiled installer

We have prepared an installer package for common Linux releases:

- Ubuntu-14.04
- CentOS-7.0/6.5/5.11
- Ubuntu-14.04 or later
- CentOS-7.0 or later
- Anolis-7 or later

Please select the corresponding installer on the [Version Releases Page][Releases] to download and install the tool. The latest version is recommended.

@@ -38,16 +47,16 @@ sudo apt-get install gdebi-core
sudo gdebi your_ossfs_package
```

- For CentOS6.5 or above, the installation command is:
- For CentOS, the installation command is:

```
sudo yum localinstall your_ossfs_package
```

- For CentOS5, the installation command is:
- For Anolis, the installation command is:

```
sudo yum localinstall your_ossfs_package --nogpgcheck
sudo yum localinstall your_ossfs_package
```

### Install by source code
@@ -79,29 +88,58 @@ make
sudo make install
```

Otherwise consult the [compilation instructions](COMPILATION.md).

## Run OSSFS

Set the bucket name, access key/ID information and save the information to the "/etc/passwd-ossfs" object.
Note: The ACL of this object must be set correctly, and 640 is recommended. 600 is recommended if the password file is not the default path.
The default location for the ossfs password file can be created:

* using a `.passwd-ossfs` file in the users home directory (i.e. `${HOME}/.passwd-ossfs`)
* using the system-wide `/etc/passwd-ossfs` file

Enter your credentials in a file `${HOME}/.passwd-ossfs` and set
owner-only permissions:

```
echo my-access-key-id:my-access-key-secret > ${HOME}/.passwd-ossfs
chmod 600 ${HOME}/.passwd-ossfs
```

Run ossfs with an existing bucket `my-bucket` and directory `/path/to/mountpoint`:

```
ossfs my-bucket /path/to/mountpoint -ourl=my-oss-endpoint
```

If you encounter any errors, enable debug output:

```
ossfs my-bucket /path/to/mountpoint -ourl=my-oss-endpoint -o dbglevel=info -f -o curldbg
```

You can also mount on boot by entering the following line to `/etc/fstab`:

```
echo my-bucket:my-access-key-id:my-access-key-secret > /etc/passwd-ossfs
chmod 640 /etc/passwd-ossfs
my-bucket /path/to/mountpoint fuse.ossfs _netdev,allow_other,url=my-oss-endpoint 0 0
```

Mount the OSS bucket to the specified directory.
Note: You may also want to create the global credential file first

```
ossfs my-bucket my-mount-point -ourl=my-oss-endpoint
echo my-access-key-id:my-access-key-secret > /etc/passwd-ossfs
chmod 600 /etc/passwd-ossfs
```

Note2: You may also need to make sure `netfs` service is start on boot

### Example

Mount the 'my-bucket' bucket to the '/tmp/ossfs' directory and the AccessKeyId is 'faint',
the AccessKeySecret is '123', and the OSS endpoint is 'http://oss-cn-hangzhou.aliyuncs.com'.

```
echo my-bucket:faint:123 > /etc/passwd-ossfs
chmod 640 /etc/passwd-ossfs
echo faint:123 > /etc/passwd-ossfs
chmod 600 /etc/passwd-ossfs
mkdir /tmp/ossfs
ossfs my-bucket /tmp/ossfs -ourl=http://oss-cn-hangzhou.aliyuncs.com
```
@@ -116,28 +154,26 @@ fusermount -u /tmp/ossfs # non-root user
### Common settings

- You can use 'ossfs --version' to view the current version and 'ossfs -h' to view available parameters.
- If you are using OSSFS on an Alibaba Cloud ECS instance, you can use the intranet domain name to **save traffic charges** and
- If you are using ossfs on an Alibaba Cloud ECS instance, you can use the intranet domain name to **save traffic charges** and
**improve speed**:

ossfs my-bucket /tmp/ossfs -ourl=http://oss-cn-hangzhou-internal.aliyuncs.com

- In a Linux system, [updatedb][updatedb] will scan the file system on a regular basis. If you do not want the
OSSFS-mounted directory to be scanned, refer to [FAQ][FAQ-updatedb] to configure skipping the mounted directory.
- If [eCryptFs][ecryptfs] or other systems that require [XATTR][xattr] are not used, you can improve performance by
adding the '-o noxattr' parameter.
- The OSSFS allows you to specify multiple sets of bucket/access_key_id/access_key_secret information. When
ossfs-mounted directory to be scanned, refer to [FAQ][FAQ-updatedb] to configure skipping the mounted directory.
- The ossfs allows you to specify multiple sets of bucket/access_key_id/access_key_secret information. When
multiple sets of information are in place, the format of the information written to passwd-ossfs is:

bucket1:access_key_id1:access_key_secret1
bucket2:access_key_id2:access_key_secret2

- The [Supervisor][Supervisor] is recommended in a production environment to start and monitor the OSSFS process. For usage
- The [Supervisor][Supervisor] is recommended in a production environment to start and monitor the ossfs process. For usage
see [FAQ][faq-supervisor].

### Advanced settings

- You can add the '-f -d' parameters to run the OSSFS in the foreground and output the debug log.
- You can use the '-o kernel_cache' parameter to enable the OSSFS to use the page cache of the file system.
- You can add the '-f -d' parameters to run the ossfs in the foreground and output the debug log.
- You can use the '-o kernel_cache' parameter to enable the ossfs to use the page cache of the file system.
If you have multiple servers mounted to the same bucket and require strong consistency, **do not** use this
option.

@@ -151,40 +187,33 @@ Do not panic in case of errors. Troubleshoot the problem following the steps bel
grep 's3fs' /var/log/syslog
grep 'ossfs' /var/log/syslog

3. Retry OSSFS mounting and open the debug log:
3. Retry ossfs mounting and open the debug log:

ossfs ... -o dbglevel=debug -f -d > /tmp/fs.log 2>&1

Repeat the operation and save the '/tmp/fs.log' to check or send the file to me.

## Restrictions

Compared with local file systems, OSSFS has some restrictions in provided functionality and performance. Specifically speaking:
## Limitations

* Random or append writes to files may lead to rewrite of the entire file.
* Metadata operations, such as list directory perform poorly because of the remote access to the OSS server.
* The rename operations on files/folders are not atomic.
* When multiple clients are mounted to the same OSS bucket, you have to coordinate actions of various clients on your own. For example, keep multiple clients from writing data to the same file.
* Hard link is not supported.
* The tool is not suitable for scenarios with highly concurrent reads/writes as it will increase the system load.
Generally OSS cannot offer the same performance or semantics as a local file system. More specifically:

## Get involved in development
* random writes or appends to files require rewriting the entire object, optimized with multi-part upload copy
* metadata operations such as listing directories have poor performance due to network latency
* no atomic renames of files or directories
* no coordination between multiple clients mounting the same bucket
* no hard links
* inotify detects only local modifications, not external ones by other clients or tools
* not suitable for scenarios with highly concurrent reads/writes as it will increase the system load

0. For the development procedure, refer to: https://github.com/rockuw/oss-sdk-status#development-oss-members-only.
1. After the code is submitted, ensure the travis CI is in the PASS status.
2. Every time a new version is released:
- Run 'scripts/build-pkg.py' to generate the corresponding installer package.
- Release a version on the [Release Page][releases].
- Upload the generated installer package to the corresponding Release directory.

## FAQs
## Frequently Asked Questions

[FAQ](https://github.com/aliyun/ossfs/wiki/FAQ-EN)
* [FAQ](https://github.com/aliyun/ossfs/wiki/FAQ-EN)

### Related
## Related

* [OSSFS Wiki](https://github.com/aliyun/ossfs/wiki)
* [S3FS](https://github.com/s3fs-fuse/s3fs-fuse)- Mount the s3 bucket to the local file system through the fuse interface.
* [ossfs Wiki](https://github.com/aliyun/ossfs/wiki)
* [s3fs](https://github.com/s3fs-fuse/s3fs-fuse)- Mount the s3 bucket to the local file system through the fuse interface.

## Contact us

@@ -197,16 +226,5 @@ Compared with local file systems, OSSFS has some restrictions in provided functi

Copyright (C) 2010 Randy Rizun <rrizun@gmail.com>

Copyright (C) 2015 Haoran Yang <yangzhuodog1982@gmail.com>

Licensed under the GNU GPL version 2


[releases]: https://github.com/aliyun/ossfs/releases
[updatedb]: http://linux.die.net/man/8/updatedb
[faq-updatedb]: https://github.com/aliyun/ossfs/wiki/FAQ
[ecryptfs]: http://ecryptfs.org/
[xattr]: http://man7.org/linux/man-pages/man7/xattr.7.html
[supervisor]: http://supervisord.org/
[faq-supervisor]: https://github.com/aliyun/ossfs/wiki/FAQ#18

28 changes: 17 additions & 11 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#! /bin/sh

# This file is part of S3FS.
#!/bin/sh
#
# This file is part of OSSFS.
#
# Copyright 2009, 2010 Free Software Foundation, Inc.
#
# S3FS is free software: you can redistribute it and/or modify
# OSSFS is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# S3FS is distributed in the hope that it will be useful, but
# OSSFS is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
@@ -22,14 +22,12 @@
echo "--- Make commit hash file -------"

SHORTHASH="unknown"
type git > /dev/null 2>&1
if [ $? -eq 0 -a -d .git ]; then
RESULT=`git rev-parse --short HEAD`
if [ $? -eq 0 ]; then
SHORTHASH=${RESULT}
if command -v git > /dev/null 2>&1 && test -d .git; then
if RESULT=$(git rev-parse --short HEAD); then
SHORTHASH="${RESULT}"
fi
fi
echo ${SHORTHASH} > default_commit_hash
echo "${SHORTHASH}" > default_commit_hash

echo "--- Finished commit hash file ---"

@@ -44,3 +42,11 @@ echo "--- Finished autotools ----------"

exit 0

#
# Local variables:
# tab-width: 4
# c-basic-offset: 4
# End:
# vim600: expandtab sw=4 ts= fdm=marker
# vim<600: expandtab sw=4 ts=4
#
44 changes: 44 additions & 0 deletions bench/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM ubuntu:18.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get -y install --no-install-recommends \
# build s3fs,ossfs dependencies \
automake autotools-dev fuse g++ git libcurl4-gnutls-dev libfuse-dev \
libssl-dev libxml2-dev make pkg-config \
# for running benchmark \
curl python-setuptools python-pip gnuplot-nox imagemagick awscli \
# finally, clean up to make image smaller \
&& apt-get clean
# bench graph generation
RUN pip install numpy

# bench mdtest


WORKDIR /tmp

# build s3fs
RUN git clone --depth 1 https://github.com/s3fs-fuse/s3fs-fuse.git && \
cd s3fs-fuse && ./autogen.sh && ./configure && make -j8 > /dev/null && make install && \
cd .. && rm -Rf s3fs-fuse

# get prebuild bin
RUN curl -SL https://github.com/kahing/goofys/releases/latest/download/goofys -o /usr/local/bin/goofys && \
chmod +x /usr/local/bin/goofys

#get ossfs
RUN git clone --depth 1 https://github.com/aliyun/ossfs.git && \
cd ossfs && ./autogen.sh && ./configure && make -j8 > /dev/null && make install && \
cp -rf ./bench /root/bench && \
cd .. && rm -Rf ossfs

# build mdtest
# Install MPI & HDF5
#./mdtest -d ~/ya/mdtest -b 6 -I 8 -z 4
RUN apt-get install -y openmpi-bin libopenmpi-dev && \
apt-get install -y hdf5-tools libhdf5-openmpi-dev
RUN git clone --depth 1 https://github.com/hpc/ior.git && \
cd ior && ./bootstrap && ./configure && make > /dev/null && make install && \
cd .. && rm -Rf ior

ENTRYPOINT ["/root/bench/run_bench.sh"]
12 changes: 12 additions & 0 deletions bench/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Benchmark

## Goofys tests

These tests are run with `./run_bench.sh` in this directory. They're rather simple but the results are also included for completeness:

![benchmark results](bench.png?raw=true "Benchmark Results")

The test was run on an ECS ecs.s6-c1m2.xlarge 4CPU 8GiB in cn-shenzhen connected to a bucket in oss-cn-shenzhen. Units are seconds.
Using `-ostat_cache_expire=1` for s3fs(version 1.91)and ossfs.
Using `--stat-cache-ttl 1s --type-cache-ttl 1s` for goofys.
Using `-ostat_cache_expire=1 -oreaddir_optimize` for ossfs+readdir-optimize.
11 changes: 11 additions & 0 deletions bench/bench.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#operation,time
Create 100 files 10.105 9.368 11.014 10.528444444444444 9.822 11.384 5.3599000000000006 4.81 5.838 10.331500000000002 9.901 10.858
Create 100 files (parallel) 4.991444444444444 4.673 5.391 5.6676 5.233 6.307 0.9472000000000002 0.787 1.129 5.365777777777777 4.932 6.43
Unlink 100 files 2.6174 2.395 2.916 2.6270000000000002 2.359 3.103 2.6775555555555552 2.429 2.914 2.6721999999999997 2.456 3.031
Unlink 100 files (parallel) 3.1605 2.638 3.673 3.404 2.987 3.914 2.9871111111111115 2.798 3.312 3.2489000000000003 2.83 3.624
ls with 1000 files 0.5623333333333335 0.537 0.602 0.6181111111111111 0.575 0.719 0.16188888888888886 0.156 0.171 0.15644444444444447 0.147 0.167
`find' with 1000 dirs/files 2.4784444444444444 2.234 2.75 2.417 2.034 2.843 0.16866666666666666 0.155 0.189 0.933 0.728 1.421
Write 1GB 7.706333333333333 7.538 7.889 9.87788888888889 9.73 10.15 4.532399999999999 4.399 4.699 7.7941111111111105 7.517 8.097
Read 1GB 7.132777777777777 6.783 7.666 7.741 7.077 8.273 3.493 3.407 3.606 7.284333333333334 6.785 7.985
Rename 1GB 0.147 0.13 0.168 18.197400000000002 16.813 19.796 0.10677777777777778 0.096 0.131 0.1551111111111111 0.134 0.186
Time to 1st byte 0.3184 0.24 0.395 0.34288888888888885 0.197 0.464 0.025333333333333333 0.021 0.033 0.2822222222222222 0.223 0.357
100 changes: 100 additions & 0 deletions bench/bench.goofys
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
create_files 5.239
rm_files 2.674
create_files 5.838
rm_files 2.703
create_files 4.810
rm_files 2.735
create_files 5.200
rm_files 3.419
create_files 5.447
rm_files 2.762
create_files 5.380
rm_files 2.743
create_files 5.189
rm_files 2.429
create_files 5.199
rm_files 2.561
create_files 5.660
rm_files 2.577
create_files 5.637
rm_files 2.914
create_files_parallel 1.129
rm_files_parallel 2.965
create_files_parallel 0.904
rm_files_parallel 2.817
create_files_parallel 0.787
rm_files_parallel 3.312
create_files_parallel 0.853
rm_files_parallel 3.027
create_files_parallel 0.987
rm_files_parallel 2.843
create_files_parallel 1.017
rm_files_parallel 3.925
create_files_parallel 1.016
rm_files_parallel 3.101
create_files_parallel 0.855
rm_files_parallel 2.798
create_files_parallel 1.012
rm_files_parallel 3.044
create_files_parallel 0.912
rm_files_parallel 2.977
write_md5 4.631
read_md5 3.453
read_first_byte 0.028
rename_large_file 0.098
write_md5 4.699
read_md5 3.407
read_first_byte 0.026
rename_large_file 0.116
write_md5 4.399
read_md5 3.523
read_first_byte 0.023
rename_large_file 0.108
write_md5 4.540
read_md5 3.532
read_first_byte 0.037
rename_large_file 0.097
write_md5 4.645
read_md5 3.606
read_first_byte 0.023
rename_large_file 0.110
write_md5 4.417
read_md5 3.316
read_first_byte 0.024
rename_large_file 0.184
write_md5 4.439
read_md5 3.468
read_first_byte 0.033
rename_large_file 0.098
write_md5 4.552
read_md5 3.460
read_first_byte 0.025
rename_large_file 0.131
write_md5 4.599
read_md5 3.480
read_first_byte 0.025
rename_large_file 0.107
write_md5 4.403
read_md5 3.508
read_first_byte 0.021
rename_large_file 0.096
ls_files 0.158
ls_files 0.161
ls_files 0.157
ls_files 0.178
ls_files 0.162
ls_files 0.171
ls_files 0.156
ls_files 0.166
ls_files 0.164
ls_files 0.162
find_files 0.128
find_files 0.166
find_files 0.155
find_files 0.189
find_files 0.169
find_files 0.166
find_files 0.171
find_files 0.160
find_files 0.158
find_files 0.184
100 changes: 100 additions & 0 deletions bench/bench.ossfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
create_files 11.014
rm_files 2.395
create_files 9.940
rm_files 2.916
create_files 9.605
rm_files 2.800
create_files 10.720
rm_files 2.662
create_files 10.233
rm_files 2.456
create_files 9.911
rm_files 2.420
create_files 9.581
rm_files 2.496
create_files 10.468
rm_files 2.705
create_files 10.210
rm_files 2.651
create_files 9.368
rm_files 2.673
create_files_parallel 4.787
rm_files_parallel 3.096
create_files_parallel 4.673
rm_files_parallel 2.835
create_files_parallel 4.830
rm_files_parallel 2.638
create_files_parallel 5.391
rm_files_parallel 3.489
create_files_parallel 5.237
rm_files_parallel 3.286
create_files_parallel 4.910
rm_files_parallel 3.673
create_files_parallel 4.933
rm_files_parallel 2.946
create_files_parallel 4.946
rm_files_parallel 3.509
create_files_parallel 5.706
rm_files_parallel 2.770
create_files_parallel 5.216
rm_files_parallel 3.363
write_md5 8.180
read_md5 8.440
read_first_byte 0.366
rename_large_file 0.195
write_md5 7.729
read_md5 7.642
read_first_byte 0.325
rename_large_file 0.157
write_md5 7.784
read_md5 7.089
read_first_byte 0.324
rename_large_file 0.142
write_md5 7.889
read_md5 7.666
read_first_byte 0.395
rename_large_file 0.139
write_md5 7.576
read_md5 6.822
read_first_byte 0.240
rename_large_file 0.159
write_md5 7.839
read_md5 7.054
read_first_byte 0.339
rename_large_file 0.130
write_md5 7.601
read_md5 6.783
read_first_byte 0.268
rename_large_file 0.142
write_md5 7.538
read_md5 6.823
read_first_byte 0.370
rename_large_file 0.153
write_md5 7.588
read_md5 7.164
read_first_byte 0.284
rename_large_file 0.133
write_md5 7.813
read_md5 7.152
read_first_byte 0.273
rename_large_file 0.168
ls_files 0.602
ls_files 0.560
ls_files 0.537
ls_files 0.576
ls_files 1.198
ls_files 0.577
ls_files 0.543
ls_files 0.559
ls_files 0.561
ls_files 0.546
find_files 2.297
find_files 2.357
find_files 2.437
find_files 2.322
find_files 1.910
find_files 2.750
find_files 2.601
find_files 2.234
find_files 2.624
find_files 2.684
100 changes: 100 additions & 0 deletions bench/bench.ossfs+readdir-optimize
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
create_files 10.686
rm_files 2.635
create_files 10.500
rm_files 2.643
create_files 10.076
rm_files 2.541
create_files 10.444
rm_files 2.680
create_files 9.901
rm_files 2.529
create_files 10.153
rm_files 2.627
create_files 9.952
rm_files 2.456
create_files 10.575
rm_files 3.005
create_files 10.858
rm_files 3.031
create_files 10.170
rm_files 2.575
create_files_parallel 6.430
rm_files_parallel 3.352
create_files_parallel 5.005
rm_files_parallel 3.624
create_files_parallel 5.397
rm_files_parallel 3.041
create_files_parallel 5.342
rm_files_parallel 3.195
create_files_parallel 5.238
rm_files_parallel 3.042
create_files_parallel 5.346
rm_files_parallel 3.474
create_files_parallel 4.932
rm_files_parallel 2.830
create_files_parallel 6.643
rm_files_parallel 3.283
create_files_parallel 5.062
rm_files_parallel 3.523
create_files_parallel 5.540
rm_files_parallel 3.125
write_md5 7.817
read_md5 6.785
read_first_byte 0.234
rename_large_file 0.152
write_md5 7.709
read_md5 7.068
read_first_byte 0.511
rename_large_file 0.156
write_md5 7.772
read_md5 7.146
read_first_byte 0.257
rename_large_file 0.134
write_md5 7.950
read_md5 7.985
read_first_byte 0.246
rename_large_file 0.154
write_md5 7.818
read_md5 7.241
read_first_byte 0.352
rename_large_file 0.144
write_md5 8.465
read_md5 7.396
read_first_byte 0.357
rename_large_file 0.199
write_md5 8.097
read_md5 7.488
read_first_byte 0.344
rename_large_file 0.154
write_md5 7.517
read_md5 6.925
read_first_byte 0.247
rename_large_file 0.143
write_md5 7.846
read_md5 7.525
read_first_byte 0.223
rename_large_file 0.173
write_md5 7.621
read_md5 8.635
read_first_byte 0.280
rename_large_file 0.186
ls_files 0.149
ls_files 0.147
ls_files 0.167
ls_files 0.153
ls_files 0.167
ls_files 0.159
ls_files 0.151
ls_files 0.156
ls_files 0.159
ls_files 0.200
find_files 0.929
find_files 0.990
find_files 0.987
find_files 1.421
find_files 0.837
find_files 1.475
find_files 0.886
find_files 0.728
find_files 0.810
find_files 0.809
Binary file added bench/bench.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 100 additions & 0 deletions bench/bench.s3fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
create_files 10.078
rm_files 2.518
create_files 10.303
rm_files 2.542
create_files 11.064
rm_files 2.359
create_files 11.384
rm_files 2.587
create_files 9.822
rm_files 2.406
create_files 11.815
rm_files 3.103
create_files 10.567
rm_files 2.747
create_files 10.655
rm_files 2.936
create_files 10.562
rm_files 2.445
create_files 10.321
rm_files 3.516
create_files_parallel 6.125
rm_files_parallel 3.388
create_files_parallel 6.036
rm_files_parallel 2.987
create_files_parallel 5.537
rm_files_parallel 3.221
create_files_parallel 5.233
rm_files_parallel 3.303
create_files_parallel 5.558
rm_files_parallel 3.530
create_files_parallel 5.353
rm_files_parallel 3.513
create_files_parallel 5.843
rm_files_parallel 3.520
create_files_parallel 5.361
rm_files_parallel 3.914
create_files_parallel 6.307
rm_files_parallel 3.587
create_files_parallel 5.323
rm_files_parallel 3.077
write_md5 9.747
read_md5 7.816
read_first_byte 0.307
rename_large_file 18.878
write_md5 9.760
read_md5 7.297
read_first_byte 0.252
rename_large_file 16.813
write_md5 9.814
read_md5 8.980
read_first_byte 0.360
rename_large_file 18.313
write_md5 9.979
read_md5 8.182
read_first_byte 0.464
rename_large_file 19.627
write_md5 9.740
read_md5 7.467
read_first_byte 0.197
rename_large_file 17.196
write_md5 9.730
read_md5 8.273
read_first_byte 0.352
rename_large_file 17.827
write_md5 9.901
read_md5 7.077
read_first_byte 0.596
rename_large_file 19.796
write_md5 10.080
read_md5 8.181
read_first_byte 0.374
rename_large_file 17.655
write_md5 10.150
read_md5 7.965
read_first_byte 0.350
rename_large_file 18.745
write_md5 9.418
read_md5 7.411
read_first_byte 0.430
rename_large_file 17.124
ls_files 0.719
ls_files 0.651
ls_files 0.584
ls_files 0.626
ls_files 0.638
ls_files 0.593
ls_files 0.597
ls_files 0.580
ls_files 1.221
ls_files 0.575
find_files 2.034
find_files 3.171
find_files 2.511
find_files 2.449
find_files 2.386
find_files 2.368
find_files 2.320
find_files 2.232
find_files 2.610
find_files 2.843
450 changes: 450 additions & 0 deletions bench/bench.sh

Large diffs are not rendered by default.

94 changes: 94 additions & 0 deletions bench/bench_format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/usr/bin/python

import numpy
import sys

def filter_outliers(numbers, mean, std):
if len(numbers) == 1:
return numbers
return list(filter(lambda x: abs(x - mean) < 2 * std, numbers))

op_str = {
'create_files' : 'Create 100 files',
'create_files_parallel' : 'Create 100 files (parallel)',
'rm_files' : 'Unlink 100 files',
'rm_files_parallel' : 'Unlink 100 files (parallel)',
'ls_files' : 'ls with 1000 files',
'find_files' : "`find' with 1000 dirs/files",
'write_md5' : 'Write 1GB',
'read_first_byte' : 'Time to 1st byte',
'read_md5' : 'Read 1GB',
'rename_large_file' : 'Rename 1GB',
}

outputOrder = [
'create_files',
'create_files_parallel',
'rm_files',
'rm_files_parallel',
'ls_files',
'find_files',
'write_md5',
'read_md5',
'rename_large_file',
'read_first_byte',
]

f = sys.argv[1]
data = open(f).readlines()
#print 'operation | goofys | s3fs | speedup'
#print '----------| ------ | ------ | -------'

table = [{}, {}]
has_data = {}

print('#operation,time')
for l in data:
dataset = l.strip().split('\t')
while len(table) < len(dataset):
table.append({})
for d in range(0, len(dataset)):
op, num = dataset[d].split(' ')
if not op in table[d]:
table[d][op] = []
table[d][op] += [float(num)]
has_data[op] = True

for c in outputOrder:
if c in has_data:
sys.stdout.write(op_str[c])
for d in table:
mean = numpy.mean(d[c])
err = numpy.std(d[c])
x = filter_outliers(d[c], mean, err)
sys.stdout.write("\t%s\t%s\t%s" % (numpy.mean(x), numpy.min(x), numpy.max(x)))
print("")

# op = op_str[nums[0]]

# for i in range(1, len(nums)):

# x = map(lambda x: float(x), nums[1].strip().split(' '))
# y = map(lambda x: float(x), nums[2].strip().split(' '))
# mean_x = numpy.mean(x)
# err_x = numpy.std(x)
# mean_y = numpy.mean(y)
# err_y = numpy.std(y)
# fixed_x = fixed_y = ""

# x2 = filter_outliers(x, mean_x, err_x)
# y2 = filter_outliers(y, mean_y, err_y)
# if x != x2:
# fixed_x = "*" * abs(len(x) - len(x2))
# mean_x = numpy.mean(x2)
# err_x = numpy.std(x2)
# if y != y2:
# fixed_y = "*" * abs(len(y) - len(y2))
# mean_y = numpy.mean(y2)
# err_y = numpy.std(y2)

# print "%s, %s, %s, %s", op, mean_x, mean_x - err_x, mean_x + err_x
# # u_x = uncertainties.ufloat(mean_x, err_x)
# # u_y = uncertainties.ufloat(mean_y, err_y)
# # delta = u_y/u_x
# # print "%s | %s%s | %s%s | %sx" % (op, u_x, fixed_x, u_y, fixed_y, delta)
67 changes: 67 additions & 0 deletions bench/bench_graph.gnuplot
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/gnuplot

reset
#fontsize = 12
set terminal pngcairo crop size 1000,640
set output ARG2
#set key at graph 0.24, 0.8 horizontal samplen 0.1

set key at graph 0.0, 0.8 horizontal samplen 0.1

set style data histogram
set style histogram errorbars gap 2 lw 1
set style fill solid 1.00 border 0
set boxwidth 0.8
set xtic rotate
unset ytics
set y2tics rotate by 90

#set yrange [0:100];

set y2label 'Time (seconds)' offset -2.5
set xlabel ' '
set size 1, 1

set label 1 ARG3 at graph -0.55, 0.8 left rotate by 90
set label 2 ARG4 at graph -0.15, 0.8 left rotate by 90

set lmargin at screen 0.1

set datafile separator "\t"

set multiplot #layout 1,3
set bmargin at screen 0.4
#set size 1, 1

set origin 0.0,0.1
set size 0.31,0.8
set xrange [5.5:7.8]

plot ARG1 using 2:3:4 title " ", \
'' using 5:6:7 title " ", \
'' using 0:(0):xticlabel(1) w l title ''

set key off
unset label 1
unset label 2
unset label 3
set lmargin

set origin 0.255,0.1
set size 0.5,0.8
set xrange [-1:5.8]

plot ARG1 using 2:3:4 title " ", \
'' using 5:6:7 title " ", \
'' using 0:(0):xticlabel(1) w l title ''

set origin 0.7,0.1
set size 0.175,0.8
set xrange [7.5:8.7]
#set yrange [0:4.0]

plot ARG1 using 2:3:4 title " ", \
'' using 5:6:7 title " ", \
'' using 0:(0):xticlabel(1) w l title ''

unset multiplot
71 changes: 71 additions & 0 deletions bench/bench_graph3.gnuplot
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/gnuplot

reset
#fontsize = 12
set terminal pngcairo crop size 1000,640
set output ARG2
#set key at graph 0.24, 0.8 horizontal samplen 0.1

set key at graph -0.1, 0.75 horizontal samplen 0.1

set style data histogram
set style histogram errorbars gap 2 lw 1
set style fill solid 1.00 border 0
set boxwidth 0.8
set xtic rotate
unset ytics
set y2tics rotate by 90

#set yrange [0:100];

set y2label 'Time (seconds)' offset -2.5
set xlabel ' '
set size 1, 1

#set label 1 ARG3 at graph -0.4, 0.8 left rotate by 90
#set label 2 ARG4 at graph -0.2, 0.8 left rotate by 90
#set label 3 ARG5 at graph 0, 0.8 left rotate by 90

set lmargin at screen 0.1

set datafile separator "\t"

set multiplot #layout 1,3
set bmargin at screen 0.4
#set size 1, 1

set origin 0.0,0.1
set size 0.31,0.8
set xrange [5.5:7.8]

plot ARG1 using 2:3:4 title ARG3, \
'' using 5:6:7 title ARG4, \
'' using 8:9:10 title ARG5, \
'' using 0:(0):xticlabel(1) w l title ''

set key off
unset label 1
unset label 2
unset label 3
set lmargin

set origin 0.255,0.1
set size 0.5,0.8
set xrange [-0.5:5.5]

plot ARG1 using 2:3:4 title ARG3, \
'' using 5:6:7 title ARG4, \
'' using 8:9:10 title ARG5, \
'' using 0:(0):xticlabel(1) w l title ''

set origin 0.7,0.1
set size 0.175,0.8
set xrange [7.5:8.7]
#set yrange [0:4.0]

plot ARG1 using 2:3:4 title ARG3, \
'' using 5:6:7 title ARG4, \
'' using 8:9:10 title ARG5, \
'' using 0:(0):xticlabel(1) w l title ''

unset multiplot
75 changes: 75 additions & 0 deletions bench/bench_graph_all.gnuplot
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/gnuplot

reset
#fontsize = 12
set terminal pngcairo crop size 1600,1000
set output ARG2
#set key at graph 0.24, 0.8 horizontal samplen 0.1

set key at graph 0.0, 0.8 horizontal samplen 0.1

set style data histogram
set style histogram errorbars gap 2 lw 1
set style fill solid 1.00 border 0
set boxwidth 0.8
set xtic rotate
unset ytics
set y2tics rotate by 90

#set yrange [0:100];

set y2label 'Time (seconds)' offset -2.5
set xlabel ' '
set size 1, 1

set label 1 ARG3 at graph -0.48, 0.8 left rotate by 90
set label 2 ARG4 at graph -0.34, 0.8 left rotate by 90
set label 3 ARG5 at graph -0.20, 0.8 left rotate by 90
set label 4 ARG6 at graph -0.06, 0.8 left rotate by 90

set lmargin at screen 0.1

set datafile separator "\t"

set multiplot #layout 1,3
set bmargin at screen 0.4
#set size 1, 1

set origin 0.0,0.1
set size 0.34,0.8
set xrange [5.5:8.5]

plot ARG1 using 2:3:4 title " ", \
'' using 5:6:7 title " ", \
'' using 8:9:10 title " ", \
'' using 11:12:13 title " ", \
'' using 0:(0):xticlabel(1) w l title ''

set key off
unset label 1
unset label 2
unset label 3
unset label 4
set lmargin

set origin 0.330,0.1
set size 0.5,0.8
set xrange [-0.5:5.5]

plot ARG1 using 2:3:4 title " ", \
'' using 5:6:7 title " ", \
'' using 8:9:10 title " ", \
'' using 11:12:13 title " ", \
'' using 0:(0):xticlabel(1) w l title ''

set origin 0.80,0.1
set size 0.16,0.8
set xrange [8.5:9.5]

plot ARG1 using 2:3:4 title " ", \
'' using 5:6:7 title " ", \
'' using 8:9:10 title " ", \
'' using 11:12:13 title " ", \
'' using 0:(0):xticlabel(1) w l title ''

unset multiplot
72 changes: 72 additions & 0 deletions bench/bench_graph_cached.gnuplot
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/gnuplot

reset
#fontsize = 12
set terminal pngcairo crop size 1000,640
set output "bench/bench.png"

#set key at graph 0.24, 0.8 horizontal samplen 0.1

set key at graph 0.0, 0.8 horizontal samplen 0.1

set style data histogram
set style histogram errorbars gap 2 lw 1
set style fill solid 1.00 border 0
set boxwidth 0.8
set xtic rotate
unset ytics
set y2tics rotate by 90

#set yrange [0:100];

set y2label 'Time (seconds)' offset -2.5
set xlabel ' '
set size 1, 1

set label 1 'goofys' at graph -0.75, 0.8 left rotate by 90
set label 2 's3fs' at graph -0.45, 0.8 left rotate by 90
set label 3 'riofs' at graph -0.13, 0.8 left rotate by 90

set lmargin at screen 0.1

set datafile separator "\t"

set multiplot #layout 1,3
set bmargin at screen 0.4
#set size 1, 1

set origin 0.0,0.1
set size 0.3,0.8
set xrange [-0.5:0.8]

plot 'bench/bench.data' using 2:3:4 title " ", \
'' using 5:6:7 title " ", \
'' using 8:9:10 title " ", \
'' using 0:(0):xticlabel(1) w l title ''

set key off
unset label 1
unset label 2
unset label 3
set lmargin

set origin 0.3,0.1
set size 0.2,0.8
set xrange [0.5:1.8]

plot 'bench/bench.data' using 2:3:4 title " ", \
'' using 5:6:7 title " ", \
'' using 8:9:10 title " ", \
'' using 0:(0):xticlabel(1) w l title ''

set origin 0.5,0.1
set size 0.2,0.8
set xrange [1.5:2.8]
set yrange [0:0.1]

plot 'bench/bench.data' using 2:3:4 title " ", \
'' using 5:6:7 title " ", \
'' using 8:9:10 title " ", \
'' using 0:(0):xticlabel(1) w l title ''

unset multiplot
20 changes: 20 additions & 0 deletions bench/format_bench.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -e

PROG1=$1
PROG2=$2

if [ -z "$PROG1" -o -z "$PROG2" ]; then
echo "USAGE: ./format_bench.sh PROG1 PROG2"
echo "For example, ./format_bench.sh geesefs goofys"
exit
fi

python3 ./bench_format.py <(paste bench.$PROG1 bench.$PROG2) > bench.data

OUT=bench_"$PROG1"_"$PROG2".png

gnuplot -c bench_graph.gnuplot bench.data "$OUT" "$PROG1" "$PROG2"

convert -rotate 90 "$OUT" "$OUT"
15 changes: 15 additions & 0 deletions bench/format_bench3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e

PROG1=ossfs
PROG2=goofys
PROG3=s3fs

python3 ./bench_format.py <(paste bench.$PROG1 bench.$PROG2 bench.$PROG3) > bench.data

OUT=bench3.png

gnuplot -c bench_graph3.gnuplot bench.data "$OUT" "$PROG1" "$PROG2" "$PROG3"

convert -rotate 90 "$OUT" "$OUT"
16 changes: 16 additions & 0 deletions bench/format_bench_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -e

PROG1=ossfs
PROG2=s3fs
PROG3=goofys
PROG4=ossfs+readdir-optimize

python3 ./bench_format.py <(paste bench.$PROG1 bench.$PROG2 bench.$PROG3 bench.$PROG4) > bench_all.data

OUT=bench_all.png

gnuplot -c bench_graph_all.gnuplot bench_all.data "$OUT" "$PROG1" "$PROG2" "$PROG3" "$PROG4"

convert -rotate 90 "$OUT" "$OUT"
30 changes: 30 additions & 0 deletions bench/gen_small.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/python3

import sys, os, random

if len(sys.argv) < 2:
print("USAGE: python3 gen_small.py DIR [COUNT] [MAX_SIZE]")
print("Creates COUNT files under DIR, sharded over 1024 2-level deep subdirectories")
print("Files will be 0.5 KB - MAX_SIZE KB, skewed to smaller sizes")
print("Default COUNT and MAX_SIZE are 6400 and 300 KB")
exit(1)
d = sys.argv[1]+'/'
if len(sys.argv) > 2:
n = int(sys.argv[2])
else:
n = 6400
if len(sys.argv) > 3:
maxsize = int(sys.argv[3])*1000
else:
maxsize = 300000

# N small files, 0.5-maxsize kb in size, 1/10 on average, sharded across 1024 dirs
for i in range(n):
size = 512+int((random.random()**10)*maxsize)
os.makedirs(d+str(i%32)+'/'+str(int(i/32)%32), 0o777, True)
f = open(d+str(i%32)+'/'+str(int(i/32)%32)+'/'+str(i), 'wb')
f.write(os.urandom(size))
f.close()

# fsync
os.fsync(os.open(d, os.O_RDONLY))
110 changes: 110 additions & 0 deletions bench/riofs.conf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<app>
<foreground type="boolean">True</foreground>
</app>

<log>
<!-- use syslog for error messages -->
<use_syslog type="boolean">False</use_syslog>
<use_color type="boolean">False</use_color>

<!-- log level - LOG_err = 0, LOG_msg = 1, LOG_debug = 2 -->
<level type="int">0</level>
</log>

<pool>
<!-- number of concurrent connections for each type of operation -->
<writers type="int">2</writers>
<readers type="int">2</readers>

<!-- number of concurrent connections for "other" operations,
such as directory listing, object deleting, etc -->
<operations type="int">4</operations>

<!-- max requests in pool queue -->
<max_requests_per_pool type="uint">100</max_requests_per_pool>
</pool>

<s3>
<!-- S3 endpoint, can be set to bucket's region to avoid initial redirect
See http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region for options. -->
<endpoint type="string">${ENDPOINT}</endpoint>

<!-- The maximum number of keys returned in the response body. -->
<keys_per_request type="uint">1000</keys_per_request>

<!-- part size for upload / download files (5mb is the minimal value) -->
<part_size type="uint">5242880</part_size>

<!-- compatibility with s3fs: send HEAD request to S3 if file size is 0 to check if it's a directory
Greatly increases directory access time. Consider to disable this option. -->
<check_empty_files type="boolean">False</check_empty_files>

<!-- Storage class to use for storing the object.
Valid Values: STANDARD | REDUCED_REDUNDANCY
Please read S3 documentation before changing this value ! -->
<storage_type type="string">STANDARD</storage_type>

<!-- Use either environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY or configuration file.
Uncomment these 2 lines and replace ### strings with your data: -->
<!--
<access_key_id type="string">### AWS Access Key ID ###</access_key_id>
<secret_access_key type="string">### AWS Secret Access Key ###</secret_access_key>
-->
</s3>

<connection>
<!-- timeout value for HTTP requests (seconds) -->
<timeout type="int">-1</timeout>

<!-- number of retries, before giving up (-1 for infinite loop) -->
<retries type="int">-1</retries>

<!-- maximum redirects per HTTP request -->
<max_redirects type="int">20</max_redirects>

<!-- maximum retries per HTTP request -->
<max_retries type="int">20</max_retries>
</connection>

<filesystem>
<!-- set uid / gid of the owners of filesystem, -1 to use the current uid / gid of the calling process. -->
<uid type="int">-1</uid>
<gid type="int">-1</gid>
<!-- set default mode for all files and directories, -1 to use the default value -->
<dir_mode type="int">-1</dir_mode>
<file_mode type="int">-1</file_mode>

<!-- time to keep directory cache (seconds) -->
<dir_cache_max_time type="uint">1</dir_cache_max_time>

<!-- time to keep file attributes cache (seconds) -->
<file_cache_max_time type="uint">1</file_cache_max_time>

<!-- set True to enable calculating MD5 sum of file content, increases CPU load -->
<md5_enabled type="boolean">False</md5_enabled>

<!-- set True to enable objects caching -->
<cache_enabled type="boolean">True</cache_enabled>

<!-- directory for storing cache objects -->
<cache_dir type="string">/tmp/cache</cache_dir>

<!-- maximum size of cache directory (1Gb) -->
<cache_dir_max_size type="uint">10737418240</cache_dir_max_size>

<!-- maximum time of cached object, 10 min -->
<cache_object_ttl type="uint">600</cache_object_ttl>
</filesystem>

<statistics>
<!-- set True to enable statistics server, disabled by default. -->
<enabled type="boolean">False</enabled>

<!-- set host to bind server to, or 0.0.0.0 to bind on all available interfaces -->
<host type="string">127.0.0.1</host>
<port type="int">8011</port>

<!-- URI path -->
<stats_path type="string">/stats</stats_path>
<history_size type="uint">1000</history_size>
</statistics>
147 changes: 147 additions & 0 deletions bench/run_bench.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#!/bin/bash

set -o errexit
set -o nounset
set -o pipefail

: ${BUCKET:="oss-bucket-ossfs-bench"}
: ${GOOFYS_BUCKET:="$BUCKET"}
: ${FAST:="false"}
: ${CACHE:="false"}
: ${ENDPOINT:="http://oss-cn-shenzhen-internal.aliyuncs.com/"}
: ${OSS_ACCESS_KEY_ID:=""}
: ${OSS_SECRET_ACCESS_KEY:=""}
: ${PROG:="ossfs"}

if [ $# = 1 ]; then
t=$1
else
t=
fi

dir=$(dirname $0)

rm -rf bench-mnt
mkdir -p bench-mnt

OSSFS_CACHE="-ouse_cache=/tmp/cache"
GOOFYS_CACHE="--cache /tmp/cache -o allow_other"

if [ "$CACHE" == "false" ]; then
OSSFS_CACHE=""
GOOFYS_CACHE=""
fi

OSSFS_ENDPOINT="-ourl=$ENDPOINT"
GOOFYS_ENDPOINT="--endpoint $ENDPOINT --subdomain"

#credential
if test "${OSS_ACCESS_KEY_ID}" != ""; then
echo "${OSS_ACCESS_KEY_ID}:${OSS_ACCESS_KEY_SECRET}" > /etc/passwd-ossfs
chmod 0400 /etc/passwd-ossfs
echo "${OSS_ACCESS_KEY_ID}:${OSS_ACCESS_KEY_SECRET}" > /etc/passwd-s3fs
chmod 0400 /etc/passwd-s3fs
AWS_ACCESS_KEY_ID="${OSS_ACCESS_KEY_ID}"
AWS_SECRET_ACCESS_KEY="${OSS_ACCESS_KEY_SECRET}"
export AWS_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY
fi

export BUCKET
export ENDPOINT

S3FS="s3fs -f -ostat_cache_expire=1 ${OSSFS_CACHE} ${OSSFS_ENDPOINT} $BUCKET bench-mnt"
OSSFS="ossfs -f -ostat_cache_expire=1 ${OSSFS_CACHE} ${OSSFS_ENDPOINT} $BUCKET bench-mnt"
GOOFYS="goofys -f --stat-cache-ttl 1s --type-cache-ttl 1s ${GOOFYS_CACHE} ${GOOFYS_ENDPOINT} ${GOOFYS_BUCKET} bench-mnt"

iter=10
if [ "$FAST" != "false" ]; then
iter=1
fi

function cleanup {
$GOOFYS >/dev/null &
PID=$!

sleep 5

for f in $dir/bench.goofys $dir/bench.s3fs $dir/bench.ossfs $dir/bench.ossfs+readdir-optimize $dir/bench.data $dir/bench.png; do
if [ -e $f ]; then
cp $f bench-mnt/
fi
done

kill $PID
fusermount -u bench-mnt || true
sleep 1
rmdir bench-mnt
}
trap cleanup EXIT

for fs in s3fs ossfs ossfs+readdir-optimize goofys; do
if [ "$fs" == "-" ]; then
continue
fi

if mountpoint -q bench-mnt; then
echo "bench-mnt is still mounted"
exit 1
fi

case $fs in
s3fs)
FS=$S3FS
CREATE_FS=$FS
;;
goofys)
FS=$GOOFYS
CREATE_FS=$FS
;;
ossfs)
FS=$OSSFS
CREATE_FS=$FS
;;
ossfs+readdir-optimize)
FS="${OSSFS} -oreaddir_optimize"
CREATE_FS=$FS
;;
esac

if [ -e $dir/bench.$fs ]; then
rm $dir/bench.$fs
fi

if [ "$t" = "" ]; then
for tt in create create_parallel io; do
$dir/bench.sh "$FS" bench-mnt $tt |& tee -a $dir/bench.$fs
$dir/bench.sh "$FS" bench-mnt cleanup |& tee -a $dir/bench.$fs
done

$dir/bench.sh "$CREATE_FS" bench-mnt ls_create

for i in $(seq 1 $iter); do
$dir/bench.sh "$FS" bench-mnt ls_ls |& tee -a $dir/bench.$fs
done

$dir/bench.sh "$FS" bench-mnt ls_rm

$dir/bench.sh "$CREATE_FS" bench-mnt find_create |& tee -a $dir/bench.$fs
$dir/bench.sh "$FS" bench-mnt find_find |& tee -a $dir/bench.$fs
$dir/bench.sh "$FS" bench-mnt cleanup |& tee -a $dir/bench.$fs
else
if [ "$t" = "find" ]; then
$dir/bench.sh "$CREATE_FS" bench-mnt find_create |& tee -a $dir/bench.$fs
$dir/bench.sh "$FS" bench-mnt find_find |& tee -a $dir/bench.$fs
$dir/bench.sh "$FS" bench-mnt cleanup |& tee -a $dir/bench.$fs
elif [ "$t" = "cleanup" ]; then
$dir/bench.sh "$FS" bench-mnt cleanup |& tee -a $dir/bench.$fs
else
$dir/bench.sh "$FS" bench-mnt $t |& tee $dir/bench.$fs
fi
fi
done

$dir/bench_format.py <(paste $dir/bench.ossfs $dir/bench.s3fs $dir/bench.goofys $dir/bench.ossfs+readdir-optimize) > $dir/bench.data
gnuplot -c $dir/bench_graph_all.gnuplot $dir/bench.data $dir/bench.png ossfs s3fs goofys ossfs+readdir-optimize
convert -rotate 90 $dir/bench.png $dir/bench.png

661 changes: 376 additions & 285 deletions configure.ac

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions doc/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
######################################################################
# ossfs - FUSE-based file system backed by Aliyun OSS
# ossfs - FUSE-based file system backed by Alibaba Cloud OSS
#
# Copyright 2007-2008 Randy Rizun <rrizun@gmail.com>
# Copyright 2015 Haoran Yang <yangzhuodog1982@gmail.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
259 changes: 0 additions & 259 deletions doc/man/ossfs.1

This file was deleted.

469 changes: 469 additions & 0 deletions doc/man/ossfs.1.in

Large diffs are not rendered by default.

842 changes: 473 additions & 369 deletions scripts/build-pkg.py

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions scripts/docker-file/alinux/2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM alibaba-cloud-linux-2-registry.cn-hangzhou.cr.aliyuncs.com/alinux2/alinux2:latest


RUN yum update upgrade -y \
&& yum install -y gcc gcc-c++ make cmake curl rpm-build\
&& yum install -y automake gcc-c++ git libcurl-devel libxml2-devel fuse-devel openssl-devel \
&& curl -SL "https://cache.ruby-china.com/pub/ruby/ruby-2.6.5.tar.gz" -o /opt/ruby-2.6.5.tar.gz\
&& cd /opt/ && tar zxvf ruby-2.6.5.tar.gz && cd ruby-2.6.5 \
&& ./configure && make -j10 && make install \
&& gem sources -a http://mirrors.aliyun.com/rubygems/ -r https://rubygems.org/ \
&& gem install dotenv -v 2.8.1 \
&& gem install fpm
11 changes: 11 additions & 0 deletions scripts/docker-file/alinux/3/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM alibaba-cloud-linux-3-registry.cn-hangzhou.cr.aliyuncs.com/alinux3/alinux3:latest

RUN yum update -y
RUN yum install -y gcc gcc-c++ make cmake curl rpm-build
RUN yum install -y automake gcc-c++ git libcurl-devel libxml2-devel fuse-devel openssl-devel \
&& curl -SL "https://cache.ruby-china.com/pub/ruby/ruby-2.6.5.tar.gz" -o /opt/ruby-2.6.5.tar.gz\
&& cd /opt/ && tar zxvf ruby-2.6.5.tar.gz && cd ruby-2.6.5 \
&& ./configure && make -j10 && make install \
&& gem sources -a http://mirrors.aliyun.com/rubygems/ -r https://rubygems.org/ \
&& gem install dotenv -v 2.8.1 \
&& gem install fpm
1 change: 1 addition & 0 deletions scripts/docker-file/anolisos/7.x/Dockerfile
Original file line number Diff line number Diff line change
@@ -8,4 +8,5 @@ RUN yum update upgrade -y \
&& cd /opt/ && tar zxvf ruby-2.6.5.tar.gz && cd ruby-2.6.5 \
&& ./configure && make -j10 && make install \
&& gem sources -a http://mirrors.aliyun.com/rubygems/ -r https://rubygems.org/ \
&& gem install dotenv -v 2.8.1 \
&& gem install fpm
5 changes: 4 additions & 1 deletion scripts/docker-file/anolisos/8.x/Dockerfile
Original file line number Diff line number Diff line change
@@ -4,6 +4,9 @@ FROM openanolis/anolisos:8.6
RUN yum update -y \
&& yum install -y gcc gcc-c++ make cmake curl rpm-build\
&& yum install -y automake gcc-c++ git libcurl-devel libxml2-devel fuse-devel openssl-devel \
&& yum install -y ruby\
&& curl -SL "https://cache.ruby-china.com/pub/ruby/ruby-2.6.5.tar.gz" -o /opt/ruby-2.6.5.tar.gz\
&& cd /opt/ && tar zxvf ruby-2.6.5.tar.gz && cd ruby-2.6.5 \
&& ./configure && make -j10 && make install \
&& gem sources -a http://mirrors.aliyun.com/rubygems/ -r https://rubygems.org/ \
&& gem install dotenv -v 2.8.1 \
&& gem install fpm
5 changes: 4 additions & 1 deletion scripts/docker-file/centos/7.x/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
FROM centos:centos7

RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
RUN yum update upgrade -y \
&& yum install -y gcc gcc-c++ make cmake curl rpm-build\
&& yum install -y gcc gcc-c++ make cmake curl rpm-build \
&& yum install -y automake gcc-c++ git libcurl-devel libxml2-devel fuse-devel openssl-devel \
&& curl -SL "https://cache.ruby-china.com/pub/ruby/ruby-2.6.5.tar.gz" -o /opt/ruby-2.6.5.tar.gz\
&& cd /opt/ && tar zxvf ruby-2.6.5.tar.gz && cd ruby-2.6.5 \
&& ./configure && make -j10 && make install \
&& gem sources -a http://mirrors.aliyun.com/rubygems/ -r https://rubygems.org/ \
&& gem install dotenv -v 2.8.1 \
&& gem install fpm
5 changes: 4 additions & 1 deletion scripts/docker-file/centos/8.x/Dockerfile
Original file line number Diff line number Diff line change
@@ -7,6 +7,9 @@ RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|
RUN yum update -y \
&& yum install -y gcc gcc-c++ make cmake curl rpm-build\
&& yum install -y automake gcc-c++ git libcurl-devel libxml2-devel fuse-devel openssl-devel \
&& yum install -y ruby \
&& curl -SL "https://cache.ruby-china.com/pub/ruby/ruby-2.6.5.tar.gz" -o /opt/ruby-2.6.5.tar.gz\
&& cd /opt/ && tar zxvf ruby-2.6.5.tar.gz && cd ruby-2.6.5 \
&& ./configure && make -j10 && make install \
&& gem sources -a http://mirrors.aliyun.com/rubygems/ -r https://rubygems.org/ \
&& gem install dotenv -v 2.8.1 \
&& gem install fpm
1 change: 1 addition & 0 deletions scripts/docker-file/ubuntu/14.04/Dockerfile
Original file line number Diff line number Diff line change
@@ -7,4 +7,5 @@ RUN apt-get update \
&& cd /opt/ && tar zxvf ruby-2.6.5.tar.gz && cd ruby-2.6.5 \
&& ./configure && make -j10 && make install \
&& gem sources -a http://mirrors.aliyun.com/rubygems/ -r https://rubygems.org/ \
&& gem install dotenv -v 2.8.1 \
&& gem install fpm
7 changes: 6 additions & 1 deletion scripts/docker-file/ubuntu/16.04/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
FROM ubuntu:16.04

RUN apt-get update \
&& apt-get install -y software-properties-common

RUN add-apt-repository ppa:brightbox/ruby-ng \
&& apt-get update \
&& apt-get install -y automake autotools-dev g++ git libcurl4-gnutls-dev curl\
&& apt-get install -y libfuse-dev libssl-dev libxml2-dev make pkg-config \
&& apt-get install -y ruby \
&& apt-get install -y ruby2.6 ruby2.6-dev \
&& gem sources -a http://mirrors.aliyun.com/rubygems/ -r https://rubygems.org/ \
&& gem install dotenv -v 2.8.1 \
&& gem install fpm
7 changes: 6 additions & 1 deletion scripts/docker-file/ubuntu/18.04/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
FROM ubuntu:18.04

RUN apt-get update \
&& apt-get install -y software-properties-common

RUN add-apt-repository ppa:brightbox/ruby-ng \
&& apt-get update \
&& apt-get install -y automake autotools-dev g++ git libcurl4-gnutls-dev curl\
&& apt-get install -y libfuse-dev libssl-dev libxml2-dev make pkg-config \
&& apt-get install -y ruby \
&& apt-get install -y ruby2.6 ruby2.6-dev \
&& gem sources -a http://mirrors.aliyun.com/rubygems/ -r https://rubygems.org/ \
&& gem install dotenv -v 2.8.1 \
&& gem install fpm
7 changes: 6 additions & 1 deletion scripts/docker-file/ubuntu/20.04/Dockerfile
Original file line number Diff line number Diff line change
@@ -3,8 +3,13 @@ FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
&& apt-get install -y software-properties-common

RUN add-apt-repository ppa:brightbox/ruby-ng \
&& apt-get update \
&& apt-get install -y automake autotools-dev g++ git libcurl4-gnutls-dev curl\
&& apt-get install -y libfuse-dev libssl-dev libxml2-dev make pkg-config \
&& apt-get install -y ruby \
&& apt-get install -y ruby2.6 ruby2.6-dev \
&& gem sources -a http://mirrors.aliyun.com/rubygems/ -r https://rubygems.org/ \
&& gem install dotenv -v 2.8.1 \
&& gem install fpm
10 changes: 10 additions & 0 deletions scripts/docker-file/ubuntu/22.04/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
&& apt-get install -y automake autotools-dev g++ git libcurl4-gnutls-dev curl\
&& apt-get install -y libfuse-dev libssl-dev libxml2-dev make pkg-config \
&& apt-get install -y ruby \
&& gem sources -a http://mirrors.aliyun.com/rubygems/ -r https://rubygems.org/ \
&& gem install fpm
45 changes: 45 additions & 0 deletions scripts/ossfs-coverage-centos7.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

# Usage:
# step 1: echo "AK:SK" > /root/.passwd-ossfs
# step 2: sh ossfs-coverage-centos7.sh bucket-name url

buildossfs() {
cd $OSSFS_SOURCE_DIR
make clean
./autogen.sh
./configure CXXFLAGS="-g -O2 --coverage -fprofile-arcs -ftest-coverage"
make -j4
}

BUCKET=$1
URL=$2
OSSFS_SOURCE_DIR=$PWD

echo $OSSFS_SOURCE_DIR

echo "Install dependencies..."
yum install -y curl python-setuptools python-pip awscli mailcap attr
yum install -y lcov

echo "Build OSSFS..."
buildossfs

echo "execute the tests"
cd ${OSSFS_SOURCE_DIR}/test
chmod +x *.sh
chmod +x *.py

rm -rf ${OSSFS_SOURCE_DIR}/coverage_html && mkdir ${OSSFS_SOURCE_DIR}/coverage_html

DBGLEVEL=debug ALL_TESTS=1 OSSFS_CREDENTIALS_FILE=/root/.passwd-ossfs TEST_BUCKET_1=${BUCKET} S3PROXY_BINARY="" OSS_URL=${URL} ./small-integration-test.sh

${OSSFS_SOURCE_DIR}/src/test_page_list
${OSSFS_SOURCE_DIR}/src/test_curl_util
${OSSFS_SOURCE_DIR}/src/test_string_util
${OSSFS_SOURCE_DIR}/src/test_mempool

gcovr -r ${OSSFS_SOURCE_DIR}/src --html-details -o ${OSSFS_SOURCE_DIR}/coverage_html/coverage.html



97 changes: 88 additions & 9 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
######################################################################
# s3fs - FUSE-based file system backed by Aliyun OSS
# ossfs - FUSE-based file system backed by Alibaba Cloud OSS
#
# Copyright 2007-2008 Randy Rizun <rrizun@gmail.com>
#
@@ -21,24 +21,103 @@ bin_PROGRAMS=ossfs

AM_CPPFLAGS = $(DEPS_CFLAGS)
if USE_GNUTLS_NETTLE
AM_CPPFLAGS += -DUSE_GNUTLS_NETTLE
AM_CPPFLAGS += -DUSE_GNUTLS_NETTLE
endif
if USE_SSL_OPENSSL_30
AM_CPPFLAGS += -DUSE_OPENSSL_30
endif

ossfs_SOURCES = s3fs.cpp s3fs.h curl.cpp curl.h cache.cpp cache.h string_util.cpp string_util.h s3fs_util.cpp s3fs_util.h fdcache.cpp fdcache.h common_auth.cpp s3fs_auth.h common.h
ossfs_SOURCES = \
s3fs.cpp \
s3fs_global.cpp \
s3fs_help.cpp \
s3fs_logger.cpp \
s3fs_xml.cpp \
metaheader.cpp \
mpu_util.cpp \
mvnode.cpp \
curl.cpp \
curl_handlerpool.cpp \
curl_multi.cpp \
curl_util.cpp \
s3objlist.cpp \
cache.cpp \
string_util.cpp \
s3fs_cred.cpp \
s3fs_util.cpp \
fdcache.cpp \
fdcache_entity.cpp \
fdcache_page.cpp \
fdcache_stat.cpp \
fdcache_auto.cpp \
fdcache_fdinfo.cpp \
fdcache_pseudofd.cpp \
fdcache_untreated.cpp \
addhead.cpp \
sighandlers.cpp \
autolock.cpp \
common_auth.cpp \
threadpoolman.cpp \
direct_reader.cpp \
memorypool.cpp
if USE_SSL_OPENSSL
ossfs_SOURCES += openssl_auth.cpp
ossfs_SOURCES += openssl_auth.cpp
endif
if USE_SSL_GNUTLS
ossfs_SOURCES += gnutls_auth.cpp
ossfs_SOURCES += gnutls_auth.cpp
endif
if USE_SSL_NSS
ossfs_SOURCES += nss_auth.cpp
ossfs_SOURCES += nss_auth.cpp
endif

ossfs_LDADD = $(DEPS_LIBS)

noinst_PROGRAMS = test_string_util
noinst_PROGRAMS = \
test_curl_util \
test_page_list \
test_string_util \
test_mempool

test_curl_util_SOURCES = common_auth.cpp curl_util.cpp string_util.cpp test_curl_util.cpp s3fs_global.cpp s3fs_logger.cpp
if USE_SSL_OPENSSL
test_curl_util_SOURCES += openssl_auth.cpp
endif
if USE_SSL_GNUTLS
test_curl_util_SOURCES += gnutls_auth.cpp
endif
if USE_SSL_NSS
test_curl_util_SOURCES += nss_auth.cpp
endif

test_string_util_SOURCES = string_util.cpp test_string_util.cpp test_util.h
test_curl_util_LDADD = $(DEPS_LIBS)

TESTS = test_string_util
test_page_list_SOURCES = \
fdcache_page.cpp \
s3fs_global.cpp \
s3fs_logger.cpp \
string_util.cpp \
test_page_list.cpp

test_string_util_SOURCES = string_util.cpp test_string_util.cpp s3fs_logger.cpp

test_mempool_SOURCES = memorypool.cpp test_mempool.cpp s3fs_logger.cpp s3fs_global.cpp string_util.cpp
test_mempool_LDFLAGS = -pthread
test_mempool_LDADD = $(DEPS_LIBS)

TESTS = \
test_curl_util \
test_page_list \
test_string_util \
test_mempool

clang-tidy:
clang-tidy $(ossfs_SOURCES) -- $(DEPS_CFLAGS) $(CPPFLAGS)

#
# Local variables:
# tab-width: 4
# c-basic-offset: 4
# End:
# vim600: expandtab sw=4 ts= fdm=marker
# vim<600: expandtab sw=4 ts=4
#
278 changes: 278 additions & 0 deletions src/addhead.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
/*
* ossfs - FUSE-based file system backed by Alibaba Cloud OSS
*
* Copyright(C) 2007 Randy Rizun <rrizun@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <fstream>

#include "common.h"
#include "s3fs.h"
#include "addhead.h"
#include "curl_util.h"

//-------------------------------------------------------------------
// Symbols
//-------------------------------------------------------------------
#define ADD_HEAD_REGEX "reg:"

//-------------------------------------------------------------------
// Class AdditionalHeader
//-------------------------------------------------------------------
AdditionalHeader AdditionalHeader::singleton;

//-------------------------------------------------------------------
// Class AdditionalHeader method
//-------------------------------------------------------------------
AdditionalHeader::AdditionalHeader()
{
if(this == AdditionalHeader::get()){
is_enable = false;
}else{
abort();
}
}

AdditionalHeader::~AdditionalHeader()
{
if(this == AdditionalHeader::get()){
Unload();
}else{
abort();
}
}

bool AdditionalHeader::Load(const char* file)
{
if(!file){
S3FS_PRN_WARN("file is NULL.");
return false;
}
Unload();

std::ifstream AH(file);
if(!AH.good()){
S3FS_PRN_WARN("Could not open file(%s).", file);
return false;
}

// read file
std::string line;
ADDHEAD *paddhead;
while(getline(AH, line)){
if(line.empty()){
continue;
}
if('#' == line[0]){
continue;
}
// load a line
std::istringstream ss(line);
std::string key; // suffix(key)
std::string head; // additional HTTP header
std::string value; // header value
if(0 == isblank(line[0])){
ss >> key;
}
if(ss){
ss >> head;
if(ss && static_cast<size_t>(ss.tellg()) < line.size()){
value = line.substr(static_cast<int>(ss.tellg()) + 1);
}
}

// check it
if(head.empty()){
if(key.empty()){
continue;
}
S3FS_PRN_ERR("file format error: %s key(suffix) is no HTTP header value.", key.c_str());
Unload();
return false;
}

paddhead = new ADDHEAD;
if(0 == strncasecmp(key.c_str(), ADD_HEAD_REGEX, strlen(ADD_HEAD_REGEX))){
// regex
if(key.size() <= strlen(ADD_HEAD_REGEX)){
S3FS_PRN_ERR("file format error: %s key(suffix) does not have key std::string.", key.c_str());
delete paddhead;
continue;
}
key.erase(0, strlen(ADD_HEAD_REGEX));

// compile
regex_t* preg = new regex_t;
int result;
if(0 != (result = regcomp(preg, key.c_str(), REG_EXTENDED | REG_NOSUB))){ // we do not need matching info
char errbuf[256];
regerror(result, preg, errbuf, sizeof(errbuf));
S3FS_PRN_ERR("failed to compile regex from %s key by %s.", key.c_str(), errbuf);
delete preg;
delete paddhead;
continue;
}

// set
paddhead->pregex = preg;
paddhead->basestring = key;
paddhead->headkey = head;
paddhead->headvalue = value;

}else{
// not regex, directly comparing
paddhead->pregex = NULL;
paddhead->basestring = key;
paddhead->headkey = head;
paddhead->headvalue = value;
}

// add list
addheadlist.push_back(paddhead);

// set flag
if(!is_enable){
is_enable = true;
}
}
return true;
}

void AdditionalHeader::Unload()
{
is_enable = false;

for(addheadlist_t::iterator iter = addheadlist.begin(); iter != addheadlist.end(); ++iter){
ADDHEAD *paddhead = *iter;
if(paddhead){
if(paddhead->pregex){
regfree(paddhead->pregex);
delete paddhead->pregex;
}
delete paddhead;
}
}
addheadlist.clear();
}

bool AdditionalHeader::AddHeader(headers_t& meta, const char* path) const
{
if(!is_enable){
return true;
}
if(!path){
S3FS_PRN_WARN("path is NULL.");
return false;
}

size_t pathlength = strlen(path);

// loop
//
// [NOTE]
// Because to allow duplicate key, and then scanning the entire table.
//
for(addheadlist_t::const_iterator iter = addheadlist.begin(); iter != addheadlist.end(); ++iter){
const ADDHEAD *paddhead = *iter;
if(!paddhead){
continue;
}

if(paddhead->pregex){
// regex
regmatch_t match; // not use
if(0 == regexec(paddhead->pregex, path, 1, &match, 0)){
// match -> adding header
meta[paddhead->headkey] = paddhead->headvalue;
}
}else{
// directly comparing
if(paddhead->basestring.length() < pathlength){
if(paddhead->basestring.empty() || 0 == strcmp(&path[pathlength - paddhead->basestring.length()], paddhead->basestring.c_str())){
// match -> adding header
meta[paddhead->headkey] = paddhead->headvalue;
}
}
}
}
return true;
}

struct curl_slist* AdditionalHeader::AddHeader(struct curl_slist* list, const char* path) const
{
headers_t meta;

if(!AddHeader(meta, path)){
return list;
}
for(headers_t::iterator iter = meta.begin(); iter != meta.end(); ++iter){
// Adding header
list = curl_slist_sort_insert(list, iter->first.c_str(), iter->second.c_str());
}
meta.clear();
S3FS_MALLOCTRIM(0);
return list;
}

bool AdditionalHeader::Dump() const
{
if(!S3fsLog::IsS3fsLogDbg()){
return true;
}

std::ostringstream ssdbg;
int cnt = 1;

ssdbg << "Additional Header list[" << addheadlist.size() << "] = {" << std::endl;

for(addheadlist_t::const_iterator iter = addheadlist.begin(); iter != addheadlist.end(); ++iter, ++cnt){
const ADDHEAD *paddhead = *iter;

ssdbg << " [" << cnt << "] = {" << std::endl;

if(paddhead){
if(paddhead->pregex){
ssdbg << " type\t\t--->\tregex" << std::endl;
}else{
ssdbg << " type\t\t--->\tsuffix matching" << std::endl;
}
ssdbg << " base std::string\t--->\t" << paddhead->basestring << std::endl;
ssdbg << " add header\t--->\t" << paddhead->headkey << ": " << paddhead->headvalue << std::endl;
}
ssdbg << " }" << std::endl;
}


ssdbg << "}" << std::endl;

// print all
S3FS_PRN_DBG("%s", ssdbg.str().c_str());

return true;
}

/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: expandtab sw=4 ts=4 fdm=marker
* vim<600: expandtab sw=4 ts=4
*/
75 changes: 75 additions & 0 deletions src/addhead.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* ossfs - FUSE-based file system backed by Alibaba Cloud OSS
*
* Copyright(C) 2007 Randy Rizun <rrizun@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef S3FS_ADDHEAD_H_
#define S3FS_ADDHEAD_H_

#include <regex.h>

#include "metaheader.h"

//----------------------------------------------
// Structure / Typedef
//----------------------------------------------
typedef struct add_header{
regex_t* pregex; // not NULL means using regex, NULL means comparing suffix directly.
std::string basestring;
std::string headkey;
std::string headvalue;
}ADDHEAD;

typedef std::vector<ADDHEAD *> addheadlist_t;

//----------------------------------------------
// Class AdditionalHeader
//----------------------------------------------
class AdditionalHeader
{
private:
static AdditionalHeader singleton;
bool is_enable;
addheadlist_t addheadlist;

protected:
AdditionalHeader();
~AdditionalHeader();

public:
// Reference singleton
static AdditionalHeader* get() { return &singleton; }

bool Load(const char* file);
void Unload();

bool AddHeader(headers_t& meta, const char* path) const;
struct curl_slist* AddHeader(struct curl_slist* list, const char* path) const;
bool Dump() const;
};

#endif // S3FS_ADDHEAD_H_

/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: expandtab sw=4 ts=4 fdm=marker
* vim<600: expandtab sw=4 ts=4
*/
80 changes: 80 additions & 0 deletions src/autolock.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* ossfs - FUSE-based file system backed by Alibaba Cloud OSS
*
* Copyright(C) 2007 Takeshi Nakatani <ggtakec.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include <cstdio>
#include <cstdlib>
#include <cerrno>

#include "common.h"
#include "s3fs.h"
#include "autolock.h"

//-------------------------------------------------------------------
// Class AutoLock
//-------------------------------------------------------------------
AutoLock::AutoLock(pthread_mutex_t* pmutex, Type type) : auto_mutex(pmutex)
{
if (type == ALREADY_LOCKED) {
is_lock_acquired = false;
} else if (type == NO_WAIT) {
int result = pthread_mutex_trylock(auto_mutex);
if(result == 0){
is_lock_acquired = true;
}else if(result == EBUSY){
is_lock_acquired = false;
}else{
S3FS_PRN_CRIT("pthread_mutex_trylock returned: %d", result);
abort();
}
} else {
int result = pthread_mutex_lock(auto_mutex);
if(result == 0){
is_lock_acquired = true;
}else{
S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", result);
abort();
}
}
}

bool AutoLock::isLockAcquired() const
{
return is_lock_acquired;
}

AutoLock::~AutoLock()
{
if (is_lock_acquired) {
int result = pthread_mutex_unlock(auto_mutex);
if(result != 0){
S3FS_PRN_CRIT("pthread_mutex_unlock returned: %d", result);
abort();
}
}
}

/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: expandtab sw=4 ts=4 fdm=marker
* vim<600: expandtab sw=4 ts=4
*/
60 changes: 60 additions & 0 deletions src/autolock.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* ossfs - FUSE-based file system backed by Alibaba Cloud OSS
*
* Copyright(C) 2007 Randy Rizun <rrizun@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef S3FS_AUTOLOCK_H_
#define S3FS_AUTOLOCK_H_

#include <pthread.h>

//-------------------------------------------------------------------
// AutoLock Class
//-------------------------------------------------------------------
class AutoLock
{
public:
enum Type {
NO_WAIT = 1,
ALREADY_LOCKED = 2,
NONE = 0
};

private:
pthread_mutex_t* const auto_mutex;
bool is_lock_acquired;

private:
AutoLock(const AutoLock&);

public:
explicit AutoLock(pthread_mutex_t* pmutex, Type type = NONE);
~AutoLock();
bool isLockAcquired() const;
};

#endif // S3FS_AUTOLOCK_H_

/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: expandtab sw=4 ts=4 fdm=marker
* vim<600: expandtab sw=4 ts=4
*/
Loading