Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Personal/pragyagandhi/sdk integration #1598

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
637 commits
Select commit Hold shift + click to select a range
81d5863
Add support for mknod
amulyan13 Sep 3, 2024
3f057c5
Cleaned up some code related to forget_seen.
Sep 4, 2024
79c7ed1
Add stat support for mknod
amulyan13 Sep 4, 2024
1384eee
Added some debug logs for noting when we return an inode to fuse.
Sep 4, 2024
534fc54
Added getx() for correctly retrieving extent left and right edges.
Sep 5, 2024
dfa05bd
Merge pull request #36 from linuxsmiths/amn/mknod
linuxsmiths Sep 5, 2024
534e5f9
Rfeactor in prep for making a library that has no fuse interfacing code.
Sep 7, 2024
059c130
Added ENABLE_NO_FUSE in prep for nofuse support
Sep 7, 2024
aa237e5
Forgot to add src/config.cpp earlier
Sep 7, 2024
5b64b14
SOme more refactoring for ENABLE_NO_FUSE.
Sep 8, 2024
c2dbe1c
Adding fuse compat definitions for nofuse mode.
Sep 8, 2024
44a384f
Refactor common FS handlers in a separate header file.
Sep 8, 2024
4b167aa
Some more nofuse refactoring.
Sep 8, 2024
b4a2fd8
Handle forget on unmount and fix rpc_api leak
Sep 9, 2024
ae7119e
online review
Sep 9, 2024
f74038f
fix for loop of erase
Sep 9, 2024
1397a6f
fix comments
Sep 9, 2024
5a0027a
fix spaces
Sep 9, 2024
194cc2e
fix spaces
Sep 9, 2024
8bd4673
Merge pull request #37 from linuxsmiths/personal/shushukl/ForgetOnUnm…
linuxsmiths Sep 9, 2024
fd01e1d
fix non paranoid build
Sep 10, 2024
874d7dc
Merge pull request #39 from linuxsmiths/personal/shushukl/fixNonParan…
shubham808 Sep 10, 2024
0a0e23d
Fixing bugs identified by Nitin during kernel build
Sep 10, 2024
e95741f
Assign filecache/dircache handle and rastate under inode lock
Sep 11, 2024
ada647c
flush_task and write_task were being interchangeably used, fixed it
Sep 12, 2024
322ce99
Added flush_cache_and_wait() in prep for future change to cause flush…
Sep 12, 2024
f4b9612
getattr must first cause dirty file data to be sync'ed
Sep 12, 2024
e4888d8
Add missing release() in flush_cache_and_wait()
Sep 12, 2024
ce9028d
Added file cache stats
Sep 12, 2024
8c6da39
Pass the right uid/gid on create
amulyan13 Sep 9, 2024
cd0b8f3
Honor ctx->umask
amulyan13 Sep 13, 2024
9fc5fe7
Add uid, gid and umask to create, mknod mkdir tasks
amulyan13 Sep 13, 2024
f8ad777
Address comment
amulyan13 Sep 13, 2024
902e4ab
fix uid gid
amulyan13 Sep 13, 2024
ecf4f71
Merge pull request #38 from linuxsmiths/amn/ctx
linuxsmiths Sep 13, 2024
dfc5ba7
1st cut nofuse code - this supports basic stat/read
Sep 13, 2024
3c62688
added some changes to handle the newly added fuse_ctx struct in nofus…
Sep 13, 2024
0b839ca
Fixed and issue with resolving dirs deeper than depth 1
Sep 13, 2024
0e3fb21
Added dup/dup2 for nofuse.
Sep 14, 2024
35900a4
Turn off asan with nofuse as they both don't go well together
Sep 14, 2024
2c9d29d
Fix some release warnings.
Sep 14, 2024
280e749
Don't call intercepted functions during cleanup
Sep 14, 2024
de91d20
Initial changes for IOV.
nitin-deamon Aug 24, 2024
e5b028e
Removed unnecessary code.
nitin-deamon Sep 2, 2024
cdee1f5
Rebase the change.
nitin-deamon Sep 2, 2024
a0b41b3
Fix the rebase.
nitin-deamon Sep 13, 2024
b7a732c
Nitpiks
nitin-deamon Sep 13, 2024
51ceccd
Changed the approach.
nitin-deamon Sep 13, 2024
ebc7bde
Refactoring.
nitin-deamon Sep 14, 2024
96b3509
Merge pull request #34 from linuxsmiths/personal/nitinsingla/write-io…
linuxsmiths Sep 14, 2024
7ab1985
Made copy_to_cache() nfs_inode member and simplified the interface.
Sep 15, 2024
a39f718
Add max_dirty_extent_bytes() and get_bytes_to_flush() to bytes_chunk_…
Sep 15, 2024
5badb84
Fix checks for seq and random flushing.
Sep 15, 2024
160ef0a
Refactor to use bc_iovec in place of write_iov_context.
Sep 16, 2024
b2fcdc0
Changes after audit/review.
Sep 16, 2024
1a5a142
Merge pull request #42 from linuxsmiths/personal/linuxsmiths/audit_af…
nitin-deamon Sep 16, 2024
e964e01
added an assert
Sep 16, 2024
60b502e
Add error injection framework.
Sep 16, 2024
fa44e72
Added a note about file-backed caches.
Sep 16, 2024
54b6a0f
added more comments
Sep 16, 2024
055e344
Add fsstat support
amulyan13 Sep 13, 2024
2ba3b48
Added some useful application/readahead stats.
Sep 17, 2024
b4aa755
Add uid/git ctx to symlink
amulyan13 Sep 13, 2024
48e7bde
Fixed an unused variable warning in release builds.
Sep 17, 2024
049da09
Addressing comments
amulyan13 Sep 17, 2024
74d0402
Add assert for RPC_TASK_MAGIC
amulyan13 Sep 17, 2024
a0bfb1d
Merge pull request #41 from linuxsmiths/amn/fsstat
linuxsmiths Sep 17, 2024
645488f
Avoid dup call to api_task_info::release() to avoid double free of va…
Sep 17, 2024
aa73d42
Adding jukebox error injection for all RPCs.
Sep 17, 2024
117eb8e
Added forget_seen_usecs instrumentation to catch the assert failure d…
Sep 17, 2024
d9d586f
Update inode->attr when reusing old inodes.
Sep 18, 2024
53fb3a4
ASAN bug fix
Sep 18, 2024
508b3a1
Fixing forget_seen assert failure.
Sep 18, 2024
343dd3e
Added some missing jukebox injections.
Sep 18, 2024
77f59f1
Drop inode ref held by lookup_sync().
Sep 18, 2024
1ac2ac9
Added some logs to catch an elusive assert
Sep 18, 2024
d13efd2
decref() should purge dnlc cache too for directories.
Sep 19, 2024
09811b3
Plug a race where readdirectory_cache::clear() may not delete the ino…
Sep 19, 2024
279c1d5
handle bad cookie using partial read method
Sep 19, 2024
2680a2d
Add RMW support
Sep 19, 2024
fbc07a4
log fix
Sep 19, 2024
c1c9249
handle 4096 bytes symlinks
Sep 19, 2024
281d5ce
Don't set readahead beyond eof.
Sep 19, 2024
ace3657
Updated some comments
Sep 20, 2024
603eb6a
File cache stats must be after RPC stats, and some log updates
Sep 20, 2024
7218587
Remove is_empty and add is_whole
Sep 21, 2024
781879e
Serve getattr fuse request from cache if not expired.
Sep 21, 2024
f3ecc50
Refactor some code to use attr_cache_expired()
Sep 22, 2024
4aa44ff
Force flags to 0 in rename
Sep 22, 2024
4149a04
hreview comments
Sep 23, 2024
31fe72a
add logs
Sep 23, 2024
310752d
force_update_attr*() must update received attributes only if they are…
Sep 23, 2024
212e8e7
Merge pull request #44 from linuxsmiths/personal/shushukl/HandleBadCo…
linuxsmiths Sep 23, 2024
75ecefe
Audit after Shubham's badcookie change.
Sep 24, 2024
a1fc730
add bad cookie pressure point
Sep 24, 2024
511b715
make pp macro
Sep 24, 2024
144a214
Merge pull request #46 from linuxsmiths/personal/shushukl/badcookiePP
linuxsmiths Sep 24, 2024
ab575b6
Audit after Shubham's change
Sep 24, 2024
07ba2ea
fix one bug wrt eof handling
Sep 24, 2024
792cf24
fixed a typo
Sep 24, 2024
67e6e01
Add lookup cacheing
Sep 24, 2024
baae7e7
Don't inject jukebox for non-idempotent requests.
Sep 25, 2024
3db1cdc
Missed few
Sep 25, 2024
8c9c833
Pick latest attributes from nfs_inode instead of the attributes saved…
Sep 25, 2024
f86c371
Turn off lookup cache and update inode's attr only if newer.
Sep 26, 2024
65e60ef
Unify dnlc cache with readdir cache.
Sep 26, 2024
ce08853
Add instrumentation to catch one failing assert
Sep 26, 2024
c821cd8
Add paranoid assert to verify dnlc addition.
Sep 26, 2024
8e19b89
Add support for adding dnlc entry on lookup
Sep 26, 2024
485af94
Added dnlc_add
Sep 27, 2024
0733de0
use std::string as key instead of char *
Sep 27, 2024
7884802
Minor bug fix.
Sep 27, 2024
6129280
Drop dircachecnt ref grabbed by lookup() inside dnlc_add()
Sep 27, 2024
d3da841
Added -ve lookup from readdir cache.
Sep 27, 2024
b07de1a
Update "confirmed" readdir cache status for existing directories too
Sep 28, 2024
49292d3
Populate file-info in create response
Sep 28, 2024
29eb78e
Clear confirmed when dircache is purged.
Sep 28, 2024
65c718d
Make confirmed_msecs atomic
Sep 28, 2024
d35f2da
Converted purging logs to debug
Sep 28, 2024
0cdb1a0
Made some more logs debug
Sep 28, 2024
2628820
some more debug logs
Sep 28, 2024
e5967a7
Handle postop attr in rename callback
Sep 29, 2024
74c1aaa
Added opencnt for dirs too
Sep 29, 2024
1b3d754
non-debug build break fix
Sep 29, 2024
5b9d5d2
Fix warnings reported by cppcheck
Sep 29, 2024
1f25a12
Removed some warnings dies to Wextra
Sep 29, 2024
e6d44b7
Allow AZNFSC_INJECT_ERROR_PERCENT to be set to 0 to turn off error in…
Sep 30, 2024
49c54a4
Added ENABLE_DEBUG define in debug mode
Sep 30, 2024
ca255d9
Adde caller's file:line information to get_nfs_inode() logs
Sep 30, 2024
13014a8
nit: add new line after LOC_FMT for consistency
Sep 30, 2024
c1a8f0d
Remove assert that was forcing non-zero pp probability
Sep 30, 2024
f9ed418
log source file and line number from logs in debug builds
Sep 30, 2024
2267547
Increase inode->opencnt before responding to fuse in reply_create()
Sep 30, 2024
d9c351f
Fixed some clang warnings.
Oct 1, 2024
1826745
Make directory entry a shared ptr
amulyan13 Oct 1, 2024
8f02f55
Merge pull request #49 from linuxsmiths/amn/dir_entries_shared_ptr
linuxsmiths Oct 2, 2024
f9ce733
Audit after Amulya's shared_ptr change.
Oct 2, 2024
cd28383
put_nfs_inode_nolock() must check dircachecnt before lookupcnt
Oct 2, 2024
8787947
Off-by-1 fix for access_range
Oct 3, 2024
34adfde
Added a log to describe an assert
Oct 3, 2024
fd61836
Added an assert to help catch one issue observed
Oct 3, 2024
453aa2b
Add note for UPDATE_INODE_ATTR() why it can fail with postop attr ass…
Oct 3, 2024
f7d54d8
Grab parent dir inode ref for silly renamed file
Oct 4, 2024
0e7f784
Forgot to push this file
Oct 4, 2024
9099f65
Add handling of preop attributes.
Oct 4, 2024
cd38dca
Some comments updated.
Oct 4, 2024
291f718
Minor changes post audit of the preop attr change.
Oct 4, 2024
ed95281
Don't use UPDATE_INODE_WCC() for create/remove calls
Oct 5, 2024
0629223
Added a config for choosing the desired consistency
Oct 5, 2024
534a30d
Demote a readdir cache to lookuponly when a file/dir is created or de…
Oct 5, 2024
a103de2
Added some comments after audit.
Oct 5, 2024
8853aba
Added config cache.attr.user.enable for controlling userspace attribu…
Oct 5, 2024
9460a03
We must set st.f_namemax in statfs o/p else pathconf doesn't return n…
Oct 5, 2024
72ed353
Set statfs blocksize correctly
Oct 5, 2024
8c87a47
Force allow_other,default_permissions mount options to hide fuse'ism
Oct 6, 2024
e2b3e33
Inline write when under memory pressure
Oct 6, 2024
1acea06
Introduce do_inline_write
Oct 6, 2024
979365c
Added stats for inline writes.
Oct 6, 2024
c9d2cfc
Improved logging.
Oct 6, 2024
d11f666
Remove target file from dnlc during rename
Oct 6, 2024
4f91a65
In solowriter mode read cna return 0/eof for offsets greater than fil…
Oct 7, 2024
6ed00c6
Disable attributes_follow assert as we hit it because of the PP on th…
Oct 7, 2024
e131322
Statfs fix after the block size was updated - forgot to update the de…
Oct 7, 2024
de5f450
Fail write and read, if beyind max file size supported.
Oct 7, 2024
ed5442e
Add instrumentation to catch an elusive bug
Oct 7, 2024
8914cfa
consistency names update for better clarity
Oct 8, 2024
f19b3d3
Remove wait-for-update logic
Oct 9, 2024
a6784cd
Inject copy_to_cache() failures more often.
Oct 10, 2024
7fe6475
copy_to_cache() must release the membuf before returning EAGAIN.
Oct 10, 2024
cc644a8
Introduce random delay in file_cache::scan()
Oct 10, 2024
a88157b
Updated a comment.
Oct 10, 2024
6d0ca83
Inject error for not marking membuf uptodate on read completion
Oct 10, 2024
64f6b3d
Relax some asserts as we can now drop inuse count before the lock.
Oct 10, 2024
35374a1
Downgrading log to debug from warn, as it was being hit many times.
Oct 11, 2024
2489259
TSAN fix
Oct 11, 2024
6300cc8
Missed in prev commit
Oct 12, 2024
5bbfbcc
Sync'ed the latest commit
Oct 12, 2024
3665f7e
TSAN fix
Oct 12, 2024
a8d7f55
TSAN fix
Oct 12, 2024
3ea6596
TSAN fix
Oct 12, 2024
7c17bbb
TSAN fix in libnfs
Oct 12, 2024
4b7afbc
TSAN fix
Oct 12, 2024
2662755
Enforce max rsize as per wsize
Oct 12, 2024
22c10ad
Error log if inode with 0 refs is present in inode_map on shutdown
Oct 12, 2024
6a3d4ab
TSAN fix
Oct 13, 2024
dac3fbf
TSAN fix
Oct 13, 2024
0f944af
Added file type in come logs in the decref() path
Oct 13, 2024
40b904a
TSAN fixes
Oct 13, 2024
428be4a
Don't add PP delay for every call to scan() and set_locked().
Oct 13, 2024
e39e71f
Improved some logging.
Oct 13, 2024
c9702a8
shutdown() must make sure next_it is protected against removal due to…
Oct 13, 2024
f52a10c
Move nfs_client::shutdown() from nfs_client.h to nfs_client.cpp
Oct 13, 2024
e3f3da7
Add PP logs when delaying scan() and set_locked()
Oct 13, 2024
974d9f4
Update attr_timeout_timestamp if update_nolock() finds attributes hav…
Oct 14, 2024
8a79375
Disable locking temporarily.
Oct 14, 2024
f27f500
Added a TODO for handling create response w/o a filehandle.
Oct 14, 2024
6973302
Mark readdir cache lookuponly when dnlc_add() is called irrespective …
Oct 15, 2024
7faa2ee
Refactor lookup_dircache(), readdirplus_callback(), readdir_callback(…
Oct 16, 2024
44d6b7e
Lock name refactoring
Oct 16, 2024
7372093
More debug logs.
Oct 16, 2024
aa66a87
log fix
Oct 16, 2024
76588ff
Better logging and a bug fix where we were not releasing dircachecnt …
Oct 16, 2024
020e486
Make directory_entry const where not needed.
Oct 16, 2024
27b365b
Improved log
Oct 16, 2024
f2d2b82
Refined some asserts for dircachecnt
Oct 17, 2024
d30694f
Typo fix
Oct 17, 2024
466508c
Add assert if setattr doesn't get postop attributes from server.
Oct 18, 2024
87f57a6
Make sure inode is correctly removed from inode_map in case when we f…
Oct 19, 2024
f635123
Disable PP that fals getdents() with EINVAL.
Oct 19, 2024
b547864
LOOKUP response received for a Type (2) entry should not update it in…
Oct 20, 2024
691a9b1
Typo
Oct 20, 2024
b15cf73
Log tid of the libnfs thread processing requests for a given mount.
Oct 20, 2024
adb4e23
log typo
Oct 20, 2024
06a6ad5
Only hold inode_map_lock while accessing the inode_map.
Oct 20, 2024
1d5023b
Made fh and crc members of nfs_inode readonly.
Oct 20, 2024
93433d6
add Linux tid to rpc_context
Oct 20, 2024
642be32
Audit locking.
Oct 21, 2024
d3524bb
Make filecache_handle private and change all accesses to get_filecach…
Oct 21, 2024
0db968b
made dircache_handle private
Oct 22, 2024
0e1f74a
Checkin debris from last time.
Oct 22, 2024
e8a8379
Comment some fuse feature flags introduced in 3.15
Oct 22, 2024
390bfec
audit and cleanup of locks
Oct 22, 2024
26b9963
Add has_cache()
Oct 22, 2024
e4ffc1f
More refactoring.
Oct 23, 2024
5a2d9b8
typo fix
Oct 23, 2024
6646083
Audit before cherry pick
Oct 23, 2024
a5e118f
fix empty string being logged
Oct 23, 2024
34a1f4e
readdirectory_cache::dnlc_add() should drop readdircache_lock_2 befor…
Oct 24, 2024
6c168f1
Access inode->attr under inode lock.
Oct 24, 2024
28936a8
Some tsan fixes.
Oct 24, 2024
d33e762
bytes_chunk_cache::inline_prune must skip locked bytes
Oct 25, 2024
6f83d9a
Populate missing filehandle for create/mkdir/mknod
Oct 16, 2024
1c922f7
Add logs
Oct 16, 2024
470822f
Make getattr call if setattr fails to get postop
Oct 24, 2024
c49631a
Handle negative case
Oct 24, 2024
4b6b97e
Add PP
Oct 24, 2024
baa40bd
Fix issues
Oct 24, 2024
0a5cdf7
Add proxy tasks for lookup and getattr
Oct 25, 2024
0b773f4
eventfd change
Oct 25, 2024
3649077
Reduce poll timeout now that we have eventfd based notification.
Oct 25, 2024
9bcbf8e
Merge pull request #51 from linuxsmiths/amn/createfhlookup
linuxsmiths Oct 26, 2024
d7c94f8
Audit after Amulya's proxy lookup PR merge.
Oct 26, 2024
f37d7dd
Reinstate init_lookup() call that got misses out in prev merge
Oct 26, 2024
0a5798c
Reset proxy_optype on task create
Oct 26, 2024
c5a05e2
Introduce alloc_rpc_task_reserved() to be called from libnfs callback…
Oct 26, 2024
3d1d84a
Fix eventfd notify for pdu requeue.
Oct 26, 2024
f4a9546
SHutdown client and transport after cleanign up fuse structures.
Oct 26, 2024
0377c96
Initial version with known data races which we want to suppress.
Oct 27, 2024
80f54e4
Added a note about a TSAN warning on unmount.
Oct 27, 2024
e7c3943
Updated
pragyagandhi Dec 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[submodule "nfs/extern/libnfs"]
path = nfs/extern/libnfs
url = https://github.com/linuxsmiths/libnfs
[submodule "nfs/extern/yaml-cpp"]
path = nfs/extern/yaml-cpp
url = https://github.com/jbeder/yaml-cpp.git
[submodule "nfs/extern/spdlog"]
path = nfs/extern/spdlog
url = https://github.com/gabime/spdlog.git
[submodule "nfs/extern/vcpkg"]
path = nfs/extern/vcpkg
url = https://github.com/microsoft/vcpkg.git
29 changes: 29 additions & 0 deletions nfs/CMake/Findfuse3.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Findfuse3
# Finds fuse3 includes and library
#
# Result variables:
# fuse3_FOUND - fuse3 library was found
# fuse3_INCLUDE_DIR - fuse3 include directory
# fuse3_LIBRARY - Library needed to use fuse3

# check if already in cache, be silent
if (fuse3_INCLUDE_DIR AND fuse3_LIBRARY)
set(fuse3_FIND_QUIETLY TRUE)
endif()

# find includes
find_path(fuse3_INCLUDE_DIR fuse3/fuse.h
/usr/local/include
/usr/include)

# find lib
find_library(fuse3_LIBRARY
NAMES fuse3 libfuse3
PATHS /lib64 /lib /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib /usr/lib/x86_64-linux-gnu)

include("FindPackageHandleStandardArgs")
find_package_handle_standard_args(fuse3 DEFAULT_MSG
fuse3_INCLUDE_DIR
fuse3_LIBRARY)

mark_as_advanced(fuse3_INCLUDE_DIR fuse3_LIBRARY)
29 changes: 29 additions & 0 deletions nfs/CMake/Findtcmalloc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Findtcmalloc
# Finds tcmalloc includes and library
#
# Result variables:
# tcmalloc_FOUND - tcmalloc library was found
# tcmalloc_INCLUDE_DIR - tcmalloc include directory
# tcmalloc_LIBRARY - Library needed to use tcmalloc

# check if already in cache, be silent
if (tcmalloc_INCLUDE_DIR AND tcmalloc_LIBRARY)
set(tcmalloc_FIND_QUIETLY TRUE)
endif()

# find includes
find_path(tcmalloc_INCLUDE_DIR gperftools/tcmalloc.h
/usr/local/include
/usr/include)

# find lib
find_library(tcmalloc_LIBRARY
NAMES tcmalloc libtcmalloc
PATHS /lib64 /lib /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib /usr/lib/x86_64-linux-gnu)

include("FindPackageHandleStandardArgs")
find_package_handle_standard_args(tcmalloc DEFAULT_MSG
tcmalloc_INCLUDE_DIR
tcmalloc_LIBRARY)

mark_as_advanced(tcmalloc_INCLUDE_DIR tcmalloc_LIBRARY)
275 changes: 275 additions & 0 deletions nfs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
cmake_minimum_required(VERSION 3.7)

project(aznfsclient
DESCRIPTION "FUSE driver for mounting Blob NFS shares"
LANGUAGES CXX
VERSION 0.1.0)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

#
# Add options here.
#
option(ENABLE_TESTS "Build and run test programs" OFF)
option(ENABLE_NO_FUSE "Build nofuse shared library" OFF)
option(ENABLE_DOCUMENTATION "Build Documentation" OFF)
option(ENABLE_PARANOID "Enable paranoid checking in the code" ON)
option(ENABLE_NON_AZURE_NFS "Enable support for general NFS servers" ON)
option(ENABLE_CHATTY "Enable super verbose logs" OFF)
option(ENABLE_TCMALLOC "Use tcmalloc for malloc/free/new/delete" ON)

#
# Enable paranoid checks only in debug builds.
# Disable asan for nofuse as it doesn't work well with that.
#
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DENABLE_DEBUG)
if(ENABLE_PARANOID)
add_definitions(-DENABLE_PARANOID)
endif()
if(NOT ENABLE_NO_FUSE)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif()
endif()

#
# Enable shard library for all components when building nofuse shared lib.
#
if(ENABLE_NO_FUSE)
set(BUILD_SHARED_LIBS ON CACHE INTERNAL "Build shared libs" FORCE)
set(YAML_BUILD_SHARED_LIBS ON CACHE INTERNAL "Build yaml-cpp shared library" FORCE)
set(SPDLOG_BUILD_SHARED ON CACHE INTERNAL "Build spdlog shared library" FORCE)
add_definitions(-DENABLE_NO_FUSE)
else()
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Build shared libs" FORCE)
set(YAML_BUILD_SHARED_LIBS OFF CACHE INTERNAL "Build yaml-cpp shared library" FORCE)
set(SPDLOG_BUILD_SHARED OFF CACHE INTERNAL "Build spdlog shared library" FORCE)
endif()

if(ENABLE_NON_AZURE_NFS)
add_definitions(-DENABLE_NON_AZURE_NFS)
endif()

if(ENABLE_CHATTY)
add_definitions(-DENABLE_CHATTY)
endif()

set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for binaries")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})

#
# We add the following submodule(s), update them as needed, before starting.
# git submodule add https://github.com/linuxsmiths/libnfs extern/libnfs
# git submodule add https://github.com/jbeder/yaml-cpp.git extern/yaml-cpp
# git submodule add https://github.com/gabime/spdlog.git extern/spdlog
#
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/../.git")
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()

if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/libnfs/CMakeLists.txt")
message(FATAL_ERROR "The libnfs submodule was not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()

if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/yaml-cpp/CMakeLists.txt")
message(FATAL_ERROR "The yaml-cpp submodule was not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()

if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/spdlog/CMakeLists.txt")
message(FATAL_ERROR "The spdlog submodule was not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()

if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/vcpkg/bootstrap-vcpkg.sh")
message(FATAL_ERROR "The vcpkg submodule was not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()

find_package(azure-identity-cpp CONFIG REQUIRED)
find_package(azure-storage-blobs-cpp CONFIG REQUIRED)

#
# Find fuse3 and if not found try to install.
#
if(NOT ENABLE_NO_FUSE)
find_package(fuse3 QUIET)
if(NOT fuse3_FOUND)
message(STATUS "fuse3 not found, trying to install libfuse3-dev!")
execute_process(COMMAND sudo apt install -y libfuse3-dev
RESULT_VARIABLE fuse3_INSTALL_RESULT)
if(NOT fuse3_INSTALL_RESULT EQUAL "0")
message(FATAL_ERROR "apt install libfuse3-dev failed with ${fuse3_INSTALL_RESULT}, try installing libfuse3-dev manually and then run cmake again")
else()
# Call once more to ensure above install completed fine and also
# will set fuse3_INCLUDE_DIR and fuse3_LIBRARY variables.
find_package(fuse3 REQUIRED)
endif()
else()
message(STATUS "Using fuse3 lib ${fuse3_LIBRARY}")
message(STATUS "Using fuse3 include dir ${fuse3_INCLUDE_DIR}")
endif()
endif()

#
# We need GnuTLS for secure libnfs transport.
#
find_package(GnuTLS "3.4.6" QUIET)
if(NOT GNUTLS_FOUND)
message(STATUS "GnuTLS not found, trying to install gnutls-dev!")
execute_process(COMMAND sudo apt install -y gnutls-dev
RESULT_VARIABLE GNUTLS_INSTALL_RESULT)
if(NOT GNUTLS_INSTALL_RESULT EQUAL "0")
message(FATAL_ERROR "apt install gnutls-dev failed with ${GNUTLS_INSTALL_RESULT}, try installing gnutls-dev manually and then run cmake again")
else()
find_package(GnuTLS "3.4.6" REQUIRED)
endif()
endif()

#
# Find tcmalloc and if not found try to install.
#
if(ENABLE_TCMALLOC)
find_package(tcmalloc QUIET)
if(NOT tcmalloc_FOUND)
message(STATUS "tcmalloc not found, trying to install libgoogle-perftools-dev!")
execute_process(COMMAND sudo apt install -y libgoogle-perftools-dev
RESULT_VARIABLE tcmalloc_INSTALL_RESULT)
if(NOT tcmalloc_INSTALL_RESULT EQUAL "0")
message(FATAL_ERROR "apt install libgoogle-perftools-dev failed with ${tcmalloc_INSTALL_RESULT}, try installing libgoogle-perftools-dev manually and then run cmake again")
else()
# Call once more to ensure above install completed fine and also
# will set tcmalloc_INCLUDE_DIR and tcmalloc_LIBRARY variables.
find_package(tcmalloc REQUIRED)
endif()
else()
message(STATUS "Using tcmalloc lib ${tcmalloc_LIBRARY}")
message(STATUS "Using tcmalloc include dir ${tcmalloc_INCLUDE_DIR}")
endif()
endif()

#
# Install zlib for crc32.
#
find_package(ZLIB QUIET)
if(NOT ZLIB_FOUND)
message(STATUS "zlib not found, trying to install zlib1g-dev!")
execute_process(COMMAND sudo apt install -y zlib1g-dev
RESULT_VARIABLE ZLIB_INSTALL_RESULT)
if(NOT ZLIB_INSTALL_RESULT EQUAL "0")
message(FATAL_ERROR "apt install zlib1g-dev failed with ${ZLIB_INSTALL_RESULT}, try installing zlib1g-dev manually and then run cmake again")
else()
# Call once more to ensure above install completed fine and also
# will set ZLIB_INCLUDE_DIR and ZLIB_LIBRARY variables.
find_package(ZLIB REQUIRED)
endif()
else()
message(STATUS "Using zlib lib ${ZLIB_LIBRARIES}")
message(STATUS "Using zlib include dir ${ZLIB_INCLUDE_DIRS}")
endif()

#
# Find jsoncpp and if not found try to install.
#
find_package(jsoncpp QUIET)
if(NOT jsoncpp_FOUND)
message(STATUS "jsoncpp not found, trying to install libjsoncpp-dev!")
execute_process(COMMAND sudo apt-get install libjsoncpp-dev
RESULT_VARIABLE jsoncpp_INSTALL_RESULT)
if(NOT jsoncpp_INSTALL_RESULT EQUAL "0")
message(FATAL_ERROR "apt-get install libjsoncpp-dev failed with ${jsoncpp_INSTALL_RESULT}, try installing libjsoncpp-dev manually")
# Call once more to ensure above install completed fine and also
# will set jsoncpp_INCLUDE_DIR and jsoncpp_LIBRARY variables.
find_package(jsoncpp REQUIRED)
endif()
else()
message(STATUS "Using jsoncpp lib ${jsoncpp_LIBRARY}")
message(STATUS "Using jsoncpp include dir ${jsoncpp_INCLUDE_DIR}")
endif()

# Build libnfs (with multithreading enabled).
set(ENABLE_MULTITHREADING ON)
set(ENABLE_EXAMPLES ON)
add_subdirectory(extern/libnfs)
add_subdirectory(extern/yaml-cpp)

# Build static library for spdlog.
add_subdirectory(extern/spdlog)

configure_file(inc/aznfsc_config.h.in inc/aznfsc_config.h)

set(sources
src/config.cpp
src/util.cpp
src/log.cpp
src/nfs_client.cpp
src/rpc_transport.cpp
src/rpc_task.cpp
src/rpc_readdir.cpp
src/connection.cpp
src/nfs_inode.cpp
src/file_cache.cpp
src/readahead.cpp
src/rpc_stats.cpp)

if(ENABLE_NO_FUSE)
# libaznfsclient.so.
set(sources ${sources} src/nofuse.cpp)
add_library(${CMAKE_PROJECT_NAME} SHARED
${sources})
else()
# aznfsclient executable.
set(sources ${sources} src/main.cpp)
add_executable(${CMAKE_PROJECT_NAME}
${sources})
endif()

# All include directories.
target_include_directories(${CMAKE_PROJECT_NAME}
PRIVATE "${PROJECT_SOURCE_DIR}/inc"
PRIVATE "${PROJECT_BINARY_DIR}/inc"
PRIVATE "${ZLIB_INCLUDE_DIRS}"
PRIVATE "${PROJECT_SOURCE_DIR}/extern/libnfs/nfs"
PRIVATE "${PROJECT_SOURCE_DIR}/extern/libnfs/include"
PRIVATE "${PROJECT_SOURCE_DIR}/extern/libnfs/include/nfsc"
PRIVATE "${PROJECT_SOURCE_DIR}/extern/libnfs/mount"
PRIVATE "${PROJECT_SOURCE_DIR}/extern/spdlog/include")

if(NOT ENABLE_NO_FUSE)
target_include_directories(${CMAKE_PROJECT_NAME}
PRIVATE "${fuse3_INCLUDE_DIR}")
target_link_libraries(${CMAKE_PROJECT_NAME}
${fuse3_LIBRARY}
jsoncpp_lib
Azure::azure-identity Azure::azure-storage-blobs)
endif()

target_compile_options(${CMAKE_PROJECT_NAME}
PRIVATE -Wall
PRIVATE -Wextra -Wno-unused-parameter
PRIVATE -Werror
)

# All libraries.
target_link_libraries(${CMAKE_PROJECT_NAME}
${ZLIB_LIBRARIES}
pthread
nfs
yaml-cpp
spdlog)

if(ENABLE_TCMALLOC)
target_link_libraries(${CMAKE_PROJECT_NAME}
${tcmalloc_LIBRARY})
endif()

install(TARGETS ${CMAKE_PROJECT_NAME})
37 changes: 37 additions & 0 deletions nfs/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Building
========
- mkdir build && cd build
- cmake -DCMAKE_BUILD_TYPE=Debug ..
- make

# If you want to support non-Azure NFS server add the following to cmake.
- -DENABLE_NON_AZURE_NFS=ON ..

# For enabling AZLogVerbose()
- -DENABLE_CHATTY=ON ..

# For using TCMalloc
- -DENABLE_TCMALLOC=ON ..

# For disabling paranoid checks.
- -DENABLE_PARANOID=OFF

# For building nofuse shared library.
- -DENABLE_NO_FUSE=ON

Running
=======
Copy sample-config.yaml as path/to/your/config.yaml and edit it according
to your requirement. Then run as

#./aznfsclient --config-file=path/to/your/config.yaml /mnt/your/path -d

-d option indicates debug run which would mean:
* It'll run in the foreground.
* Debug logs will be enabled.

If you don't want debug logs but still want to run in the foreground, use -f
#./aznfsclient --config-file=path/to/your/config.yaml /mnt/your/path -f

else, if you want to run in the background, use
#./aznfsclient --config-file=path/to/your/config.yaml /mnt/your/path
10 changes: 10 additions & 0 deletions nfs/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

export VCPKG_ROOT=/home/pragya/azure-storage-fuse/nfs/extern/vcpkg
mkdir -p build && cd build
#cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_TCMALLOC=OFF ..
#cmake -DCMAKE_BUILD_TYPE=Release ..
#cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_NO_FUSE=ON ..
cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_TCMALLOC=OFF -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake ..
cmake --build .
make
1 change: 1 addition & 0 deletions nfs/extern/libnfs
Submodule libnfs added at 88ea39
Loading
Loading