fuse: caches documentation and testing
Subsystems (3)
v5 cover fuse: caches documentation and testing
Hi!
Following this email, I'm sending v5 of this patchset. Here's what changed since v4 (mostly from Amir's review):
- Included suggested changes to the document
- Moved back 'struct fuse_common_ctx' into tests FIXTURE
- Fixed a few typos in the tests comments
- Added missing SPDX-License-Identifier tag to fuse_common.h
- Added an initial stab on the dentries cache (hence not adding Amir's 'Reviewed-by' tag in the first patch)
Luis Henriques (8):
Documentation: fuse: add document on caches being used by FUSE selftests/fuse: convert fusectl test to fuse3 selftests/fuse: check that fusectlfs is mounted selftests/fuse: factor-out test fixture setup/teardown selftests/fuse: use dynamically allocated memory to store ACLs selftests/fuse: add some extra ACL caching tests selftests/fuse: add fuse symlink caching test selftests/fuse: add fuse readdir caching test
.../filesystems/fuse/fuse-caches.rst | 198 ++++++++++++ Documentation/filesystems/fuse/index.rst | 1 + .../selftests/filesystems/fuse/.gitignore | 3 + .../selftests/filesystems/fuse/Makefile | 28 +- .../filesystems/fuse/fuse_acl_cache_test.c | 299 ++++++++++++++---- .../selftests/filesystems/fuse/fuse_common.c | 58 ++++ .../selftests/filesystems/fuse/fuse_common.h | 33 ++ .../selftests/filesystems/fuse/fuse_mnt.c | 17 +- .../fuse/fuse_readdir_cache_test.c | 273 ++++++++++++++++ .../fuse/fuse_symlink_cache_test.c | 162 ++++++++++ .../selftests/filesystems/fuse/fusectl_test.c | 9 +- 11 files changed, 998 insertions(+), 83 deletions(-) create mode 100644 Documentation/filesystems/fuse/fuse-caches.rst create mode 100644 tools/testing/selftests/filesystems/fuse/fuse_common.c create mode 100644 tools/testing/selftests/filesystems/fuse/fuse_common.h create mode 100644 tools/testing/selftests/filesystems/fuse/fuse_readdir_cache_test.c create mode 100644 tools/testing/selftests/filesystems/fuse/fuse_symlink_cache_test.c
RFC PATCH v5 1/8 Documentation: fuse: add document on caches being used by FUSE
This new file aims at documenting the caches that are used by FUSE. At the moment only symlink, attributes, ACLs and readdir caches are described.
--- .../filesystems/fuse/fuse-caches.rst | 198 ++++++++++++++++++ Documentation/filesystems/fuse/index.rst | 1 + 2 files changed, 199 insertions(+) create mode 100644 Documentation/filesystems/fuse/fuse-caches.rst
Documentation/filesystems/fuse/fuse-caches.rst new file +198 -0
@@ -0,0 +1,198 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=========== +FUSE Caches +=========== + +Introduction +============ + +This document summarises the different types of caches used in FUSE. For each +cache type, it documents the rules to insert data into it. It also documents the +rules for validating and invalidating data in the cache. + +symlink caching +=============== + +Whenever there's a link resolution request for a FUSE filesystem, the VFS will +call into ``fuse_get_link()``, the ``->get_link()`` inode operation. This +function will then send a ``FUSE_READLINK`` request to the user-space FUSE +server. + +The server can ask the kernel to cache all link resolutions by setting the +``FUSE_CACHE_SYMLINKS`` flag during the ``FUSE_INIT`` negotiation. If this flag +is set, when the VFS calls into the ``->get_link()`` operation, FUSE will +immediately call ``__page_get_link()``. The first time this is done for a +specific inode, it will result in sending the ``FUSE_READLINK`` request to +user-space. But the result returned from this request will then be added into +the page-cache. The next time this link needs to be resolved, it will use the +link resolution already cached, and will only fallback to user-space if the +folio isn't up-to-date. + +Attributes caching +================== + +Inode attributes may be obtained from user-space by different FUSE operations. +For example, ``FUSE_LOOKUP``, ``FUSE_GETATTR``, and also several other +operations that create file system objects (e.g. ``FUSE_MKDIR``). These +attributes obtained from user-space are cached by the kernel. They have, +however, a timeout associated and once it expires, they are invalidated. The +next time the attributes are needed, a request (``FUSE_GETATTR``) will be sent +to the FUSE server. + +The ``FUSE_GETATTR`` request can be sent to user-space in three different +scenarios: + +#. if the attributes for the inode aren't yet available in the kernel; +#. if they are not valid any more (timed-out, or have been invalidated), or +#. if there is an explicit request for forcing the request to be sent (for + example, by using the ``AT_STATX_FORCE_SYNC`` flag in ``statx``). + +Regarding the attributes invalidation, they may happen in several occasions. For +example, upon a user-space request for invalidation, through +``FUSE_NOTIFY_INVAL_INODE``, ``FUSE_NOTIFY_INVAL_ENTRY``, or +``FUSE_NOTIFY_DELETE`` requests. + +FUSE uses fine-grained invalidation masks rather than invalidating all +attributes at once. The principle is that each operation only invalidates the +specific attributes that the operation could have changed on the server. The +masks used are: + +- ``STATX_ATIME`` - after reads and readlink, since the server may update access + time +- ``STATX_CTIME`` - after xattr changes (including ACL set/remove) and rename +- ``STATX_BLOCKS`` - after a successful flush with writeback cache, since the + server's block count may differ from the local one +- ``FUSE_STATX_MODIFY`` (``STATX_MTIME | STATX_CTIME | STATX_BLOCKS``) - after + writeback completion (without writeback cache), since the server may have + updated modification metadata +- ``FUSE_STATX_MODSIZE`` (``FUSE_STATX_MODIFY | STATX_SIZE``) - after writes, + truncate-on-open, and fallocate, since the server's size and modification + metadata may have changed +- ``FUSE_STATX_MODDIR`` (``FUSE_STATX_MODSIZE | STATX_NLINK``) - after directory + modifications (create, unlink, mkdir, rmdir, rename), since the server may + have updated the directory's size, timestamps, and link count +- ``STATX_BASIC_STATS`` - as a full invalidation, used for server-initiated + invalidation (``FUSE_NOTIFY_INVAL_INODE``), interrupted setattr, and + interrupted link + +The full set of invalidation points can be found by searching for +``fuse_invalidate_attr_mask()`` in the FUSE source. + +ACL caching +=========== + +FUSE has allowed the usage of POSIX Access Control Lists (ACLs) for a long time, +as they can be set and accessed simply as extended attributes. However, it was +only with the introduction of the ``FUSE_POSIX_ACL`` flag that ACLs started to +be fully supported. Without this flag being set during the ``FUSE_INIT`` +negotiation, ACLs can still be set, but the VFS won't use them for performing +permission checks - that would be the user-space server's responsibility. + +Without setting ``FUSE_POSIX_ACL``, ACLs will not be cached by the kernel. In +this case, new inodes ``i_acl`` and ``i_default_acl`` fields will be set to +``ACL_DONT_CACHE``. + +If the ``FUSE_POSIX_ACL`` flag is set, when an inode ACL is accessed VFS will +first check if it's already cached. If it is not, FUSE ``->get_acl()`` operation +(``fuse_get_acl()``) is called, which will eventually send a user-space request. +Future accesses to this inode ACL will use the cached data. + +Setting an ACL in an inode will also result in sending a request to the FUSE +server for setting it. But this operation won't immediately cache the ACL -- it +will only be cached after it is accessed again and requested from user-space. + +ACLs will be removed from the cache in the following situations: + +- When setting an ACL in an inode (and the ``FUSE_POSIX_ACL`` flag is set), + previously cached ACLs for this inode will be invalidated. +- When invalidating an inode through the ``FUSE_NOTIFY_INVAL_INODE`` operation. +- After setting an inode attribute (i.e. operation ``FUSE_SETATTR`` is sent to + user-space), the user-space server may have also updated the ACLs. Thus, any + cached ACLs for this inode are also invalidated. +- Whenever attributes are refreshed from the server. For example, when + revalidating a dentry (``->d_revalidate()``), or when updating a dentry while + processing a ``FUSE_READDIRPLUS``. +- In general, when there is the need to send a ``FUSE_STATX`` or + ``FUSE_GETATTR`` to user-space (e.g. when attributes expired). + +readdir caching +=============== + +When opening a directory a ``FUSE_OPENDIR`` will be sent to the FUSE server, and +server will be responsible for setting the open flags related with caching, +namely ``FOPEN_KEEP_CACHE`` and ``FOPEN_CACHE_DIR``. + +``FOPEN_CACHE_DIR`` determines if readdir results of this open will be cached +and if readdir cache will be used to return readdir results during the current +open. If ``FOPEN_KEEP_CACHE`` is set, any readdir cache from previous opens is +preserved when the directory is opened. Otherwise, the old readdir cache is +invalidated on open. + +The readdir cache will also expire and reset if the inode's ``mtime`` or +``iversion`` don't match the cached values, or if the FUSE connection ``epoch`` +doesn't match the cache ``epoch``. + +dentry caching +============== + +FUSE keeps track of all its file systems dentries in a set of rbtrees. These +trees will keep the dentries sorted by their expiry time, so that it is easy to +quickly invalidate expired dentries. + +This set of rbtrees is protected through hashed locks to reduce contention while +doing trees traversal. + +When FUSE is initialised, an array of ``struct dentry_bucket`` is initialised +with a predefined (``FUSE_HASH_SIZE``) number of elements. Each element of this +array (``dentry_hash``) holds an rbtree (initially empty) of dentries. Every +time a new dentry is created it will be added to one of the elements of this +array's rbtree, where it will be sorted by its expiry time (``timeout``). The +selection of the array element where a dentry is inserted is done through the +``hash_ptr()`` hash function. + +A dentry expiry time will be set to a valid value (provided by the FUSE server) +in several occasions: + +- When a new file system object is created (e.g. ``FUSE_CREATE``, + ``FUSE_MKDIR``, etc). +- When a lookup is sucessfully performed. +- When a dentry is sucessfully revalidated (``->d_revalidate()``). + +A dentry expiry time can be set to 0, indicating that it is stale. This means +that a ``FUSE_LOOKUP`` will be sent to user-space then next time it needs to be +looked up. It can be set to 0 in several occasions: + +- When the user-space FUSE server explicitly requests a dentry to be invalidated + (``FUSE_NOTIFY_INVAL_ENTRY``). +- When a file system object is being deleted (e.g. ``FUSE_UNLINK``) or renamed. +- When a filesystem object is being created and fails with ``-EEXIST``. +- When a lookup fails with ``-ENOENT``. + +Cleaning up expired dentries can happen in different ways. One scenario is when +the VFS requests a revalidation. If the timeout value is 0 (expired), a new +lookup is sent to user-space. If this lookup results in ``-ENOENT``, the dentry +is invalidated. If the lookup is successful, the dentry is re-validated and the +expiry time will be updated. (There's a special case where the lookup is +successful but the nodeid returned is different from the expected one; in this +case a ``FUSE_FORGET`` needs to be sent to user-space and the dentry is +invalidated.) + +Another way of cleaning-up expired dentries is through a mechanism that can be +enabled through the ``inval_wq`` FUSE module parameter. Setting this parameter +to a value >= 5 will create a workqueue that will periodically walk through all +the dentries rbtrees in the ``dentry_hash`` array and invalidate those dentries +that have already expired. Once all the rbtrees have been checked, the workqueue +reschedules itself to run again after ``inval_wq`` seconds. By default, this +workqueue is disabled (``inval_wq`` is set to 0). + +There is yet another mechanism that allows to clean all the cached dentries for +a mounted file system, which is by incrementing the 'epoch' +(``FUSE_NOTIFY_INC_EPOCH``). Each FUSE connection will have its epoch value set +when it is created, and every new dentry have its ``->d_time`` set to the +current connection epoch value. By incrementing the connection epoch value, all +dentries that go through ``->d_revalidate()`` will be automatically invalidated +because their ``->d_time`` is be smaller than the connection epoch. If +``inval_wq`` is set, the workqueue to invalidate the dentries will be triggered +immediately after the epoch is incremented. +
Documentation/filesystems/fuse/index.rst +1 -0
@@ -12,4 +12,5 @@ FUSE (Filesystem in Userspace) Technical Documentation fuse-io fuse-io-uring fuse-passthrough + fuse-caches uapi/fuse-uapi-io-uring
RFC PATCH v5 2/8 selftests/fuse: convert fusectl test to fuse3
In reply to Luis HenriquesSince it is probably not worth adding new fuse kselftests based on fuse2, it is a good idea to convert the single existing test to fuse3. The conversion is trivial, as it only requires some changes to function signatures (the gettattr and truncate fuse operations), and to the filler() helper.
--- .../selftests/filesystems/fuse/Makefile | 20 +++++++------------ .../selftests/filesystems/fuse/fuse_mnt.c | 17 +++++++++------- 2 files changed, 17 insertions(+), 20 deletions(-)
tools/testing/selftests/filesystems/fuse/Makefile +7 -13
@@ -4,31 +4,25 @@ CFLAGS += -Wall -O2 -g $(KHDR_INCLUDES) TEST_GEN_PROGS := fusectl_test TEST_GEN_PROGS += write_extend_eof_test -TEST_GEN_FILES := fuse_mnt - -# fuse_acl_cache_test requires libfuse3; add it only when the library is present. -ACL_CFLAGS := $(shell pkg-config fuse3 --cflags 2>/dev/null) -ACL_LDLIBS := $(shell pkg-config fuse3 --libs 2>/dev/null) -ifneq ($(ACL_CFLAGS),) TEST_GEN_PROGS += fuse_acl_cache_test -endif +TEST_GEN_FILES := fuse_mnt include ../../lib.mk $(OUTPUT)/write_extend_eof_test: LDLIBS += -lpthread -VAR_CFLAGS := $(shell pkg-config fuse --cflags 2>/dev/null) +VAR_CFLAGS := $(shell pkg-config fuse3 --cflags 2>/dev/null) ifeq ($(VAR_CFLAGS),) -VAR_CFLAGS := -D_FILE_OFFSET_BITS=64 -I/usr/include/fuse +VAR_CFLAGS := -D_FILE_OFFSET_BITS=64 -I/usr/include/fuse3 endif -VAR_LDLIBS := $(shell pkg-config fuse --libs 2>/dev/null) +VAR_LDLIBS := $(shell pkg-config fuse3 --libs 2>/dev/null) ifeq ($(VAR_LDLIBS),) -VAR_LDLIBS := -lfuse -pthread +VAR_LDLIBS := -lfuse3 -pthread endif $(OUTPUT)/fuse_mnt: CFLAGS += $(VAR_CFLAGS) $(OUTPUT)/fuse_mnt: LDLIBS += $(VAR_LDLIBS) -$(OUTPUT)/fuse_acl_cache_test: CFLAGS += $(ACL_CFLAGS) -$(OUTPUT)/fuse_acl_cache_test: LDLIBS += $(ACL_LDLIBS) +$(OUTPUT)/fuse_acl_cache_test: CFLAGS += $(VAR_CFLAGS) +$(OUTPUT)/fuse_acl_cache_test: LDLIBS += $(VAR_LDLIBS)
tools/testing/selftests/filesystems/fuse/fuse_mnt.c +10 -7
@@ -4,7 +4,7 @@* Creates a simple FUSE filesystem with a single read-write file (/test) */ -#define FUSE_USE_VERSION 26 +#define FUSE_USE_VERSION 31#include <fuse.h> #include <stdio.h>
@@ -20,7 +20,8 @@ static char *content;static size_t content_size =0 ;static const char test_path[] ="/test" ; -static int test_getattr (const char *path,struct stat *st) +static int test_getattr (const char *path,struct stat *st, +struct fuse_file_info *fi) {memset (st,0 ,sizeof (*st));
@@ -41,14 +42,15 @@ static int test_getattr(const char *path, struct stat *st) }static int test_readdir (const char *path,void *buf,fuse_fill_dir_t filler, -off_t offset,struct fuse_file_info *fi) +off_t offset,struct fuse_file_info *fi, +enum fuse_readdir_flags flags) {if (strcmp (path,"/" ))return -ENOENT ; -filler (buf,"." ,NULL ,0 ); -filler (buf,".." ,NULL ,0 ); -filler (buf, test_path +1 ,NULL ,0 ); +filler (buf,"." ,NULL ,0 ,FUSE_FILL_DIR_DEFAULTS ); +filler (buf,".." ,NULL ,0 ,FUSE_FILL_DIR_DEFAULTS ); +filler (buf, test_path +1 ,NULL ,0 ,FUSE_FILL_DIR_DEFAULTS );return 0 ; }
@@ -107,7 +109,8 @@ static int test_write(const char *path, const char *buf, size_t size,return size; } -static int test_truncate (const char *path,off_t size) +static int test_truncate (const char *path,off_t size, +struct fuse_file_info *fi) {if (strcmp (path, test_path) !=0 )return -ENOENT ;
RFC PATCH v5 3/8 selftests/fuse: check that fusectlfs is mounted
In reply to Luis HenriquesThe control filesystem for FUSE needs to be mounted for the fusectl_test to be successfully run. Skip the test is that is not the case.
--- tools/testing/selftests/filesystems/fuse/fusectl_test.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
tools/testing/selftests/filesystems/fuse/fusectl_test.c +8 -1
@@ -106,8 +106,15 @@ TEST_F(fusectl, abort)char path_buf[PATH_MAX ];int abort_fd, test_fd, ret; -sprintf (path_buf,"/sys/fs/fuse/connections/%d/abort" , self->connection); +snprintf (path_buf,PATH_MAX ,"%s/%d" ,FUSECTL_MOUNTPOINT , + self->connection); +if (access (path_buf,F_OK ) !=0 ) +SKIP (return, +"fusectl doesn't seem to be mounted: %s" , +strerror (errno)); +snprintf (path_buf,PATH_MAX ,"%s/%d/abort" ,FUSECTL_MOUNTPOINT , + self->connection);ASSERT_EQ (0 ,access (path_buf,F_OK )); abort_fd =open (path_buf,O_WRONLY );
RFC PATCH v5 4/8 selftests/fuse: factor-out test fixture setup/teardown
In reply to Luis HenriquesIn order to reduce new tests setup/teardown code duplication, factor-out these functions from the existing acl_cache test into a new fuse_common.c file that can be reused in other tests.
While there, also move some of the FIXTURE members into a fuse_common_ctx structure that can be passed into setup/teardown instead of passing them by reference.
--- .../selftests/filesystems/fuse/Makefile | 8 ++- .../filesystems/fuse/fuse_acl_cache_test.c | 70 ++++--------------- .../selftests/filesystems/fuse/fuse_common.c | 58 +++++++++++++++ .../selftests/filesystems/fuse/fuse_common.h | 33 +++++++++ 4 files changed, 110 insertions(+), 59 deletions(-) create mode 100644 tools/testing/selftests/filesystems/fuse/fuse_common.c create mode 100644 tools/testing/selftests/filesystems/fuse/fuse_common.h
tools/testing/selftests/filesystems/fuse/Makefile +6 -2
@@ -21,8 +21,12 @@ ifeq ($(VAR_LDLIBS),) VAR_LDLIBS := -lfuse3 -pthread endif +CFLAGS += $(VAR_CFLAGS) +LDLIBS += $(VAR_LDLIBS) + $(OUTPUT)/fuse_mnt: CFLAGS += $(VAR_CFLAGS) $(OUTPUT)/fuse_mnt: LDLIBS += $(VAR_LDLIBS) -$(OUTPUT)/fuse_acl_cache_test: CFLAGS += $(VAR_CFLAGS) -$(OUTPUT)/fuse_acl_cache_test: LDLIBS += $(VAR_LDLIBS) +$(OUTPUT)/fuse_acl_cache_test: fuse_common.c fuse_acl_cache_test.c + +EXTRA_CLEAN := fuse_common.o
tools/testing/selftests/filesystems/fuse/fuse_acl_cache_test.c +13 -57
105 lines not on this page · raw message
tools/testing/selftests/filesystems/fuse/fuse_common.c new file +58 -0
58 lines not on this page · raw message
tools/testing/selftests/filesystems/fuse/fuse_common.h new file +33 -0
@@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __SELFTEST_FUSE_COMMON_H__ +#define __SELFTEST_FUSE_COMMON_H__ + +#define _GNU_SOURCE +#include <errno.h> +#include <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <limits.h> + +#define FUSE_USE_VERSION 31 +#include <fuse_lowlevel.h> + +#define MAX_ERR_MSG 256 + +#define MOUNTPOINT_TEMPLATE "/tmp/fuse_test_XXXXXX" +#define MOUNTPOINT_SZ 64 + +struct fuse_common_ctx { +struct fuse_session *se; +char mountpoint[MOUNTPOINT_SZ ]; +pthread_t thread; +}; + +int fs_setup (const struct fuse_lowlevel_ops *fs_ops, +struct fuse_common_ctx *ctx,char *err); +void fs_teardown (struct fuse_common_ctx *ctx); + +#endif /* __SELFTEST_FUSE_COMMON_H__ */
RFC PATCH v5 5/8 selftests/fuse: use dynamically allocated memory to store ACLs
In reply to Luis HenriquesInstead of directly using static arrays for the ACL value, allocate memory for storing it. This will make it easier to implement ACL tests that also set the xattr dynamically.
--- .../filesystems/fuse/fuse_acl_cache_test.c | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-)
tools/testing/selftests/filesystems/fuse/fuse_acl_cache_test.c +27 -5
@@ -80,7 +80,7 @@ static const uint8_t acl_b[] = {struct daemon_state {pthread_mutex_t lock; -const uint8_t *acl; +uint8_t *acl;size_t acl_size;int getxattr_count; };
@@ -142,15 +142,26 @@ static void fs_getattr(fuse_req_t req, fuse_ino_t ino,static void fs_getxattr (fuse_req_t req,fuse_ino_t ino,const char *name,size_t size) { +uint8_t *acl =NULL ; +size_t acl_size; +if (ino !=FILE_INO ||strcmp (name,"system.posix_acl_access" ) !=0 ) {fuse_reply_err (req,ENODATA );return ; } +if (size) { + acl =malloc (size); +if (!acl) { +fuse_reply_err (req,ENOMEM ); +return ; + } + }pthread_mutex_lock (&g_ds.lock); -const uint8_t *acl = g_ds.acl; -size_t acl_size = g_ds.acl_size; + acl_size = g_ds.acl_size; +if (acl && (size >= acl_size)) +memcpy (acl, g_ds.acl, acl_size); g_ds.getxattr_count++;pthread_mutex_unlock (&g_ds.lock);
@@ -160,6 +171,8 @@ static void fs_getxattr(fuse_req_t req, fuse_ino_t ino, const char *name,fuse_reply_err (req,ERANGE ); else fuse_reply_buf(req, (const char *)acl, acl_size); + +free (acl); }static const struct fuse_lowlevel_ops fs_ops = {
@@ -180,8 +193,10 @@ FIXTURE_SETUP(acl_cache)char err[MAX_ERR_MSG ];pthread_mutex_lock (&g_ds.lock); - g_ds.acl = acl_a; g_ds.acl_size =sizeof (acl_a); + g_ds.acl =malloc (g_ds.acl_size); +ASSERT_NE (g_ds.acl,NULL ); +memcpy (g_ds.acl, acl_a, g_ds.acl_size); g_ds.getxattr_count =0 ;pthread_mutex_unlock (&g_ds.lock);
@@ -195,6 +210,7 @@ FIXTURE_SETUP(acl_cache)FIXTURE_TEARDOWN (acl_cache) {fs_teardown (&self->ctx); +free (g_ds.acl); }static int do_force_statx (const char *path)
@@ -210,6 +226,7 @@ TEST_F(acl_cache, stale_after_force_sync)char buf[512 ];ssize_t sz;int count; +uint8_t *acl;/* * Step 1: two getxattr calls before any statx(FORCE_SYNC).
@@ -270,8 +287,13 @@ TEST_F(acl_cache, stale_after_force_sync)* !fc->posix_acl mounts (it skips forget_all_cached_acls in that case). * On a fixed kernel the ACL was never cached, so this is moot. */ + acl =malloc (sizeof (acl_b)); +ASSERT_NE (acl,NULL ); +memcpy (acl, acl_b,sizeof (acl_b)); +pthread_mutex_lock (&g_ds.lock); - g_ds.acl = acl_b; +free (g_ds.acl); + g_ds.acl = acl; g_ds.acl_size =sizeof (acl_b);pthread_mutex_unlock (&g_ds.lock);TH_LOG ("step 4: daemon switched to ACL_B (%zu bytes)" ,sizeof (acl_b));
RFC PATCH v5 6/8 selftests/fuse: add some extra ACL caching tests
In reply to Luis HenriquesThis adds some extra tests to ACL caching:
- Verify that reading ACLs results in the expected number of requests being sent user-space, depending on whether cache is enabled or disabled
- Verify caching behaviour on some caching invalidation scenarios
While there, add test binary to .gitignore.
--- .../selftests/filesystems/fuse/.gitignore | 1 + .../filesystems/fuse/fuse_acl_cache_test.c | 201 +++++++++++++++++- 2 files changed, 200 insertions(+), 2 deletions(-)
tools/testing/selftests/filesystems/fuse/.gitignore +1 -0
@@ -2,3 +2,4 @@ fuse_mnt fusectl_test write_extend_eof_test +fuse_acl_cache_test
tools/testing/selftests/filesystems/fuse/fuse_acl_cache_test.c +199 -2
258 lines not on this page · raw message
RFC PATCH v5 7/8 selftests/fuse: add fuse symlink caching test
In reply to Luis HenriquesThis patch adds a simple test that allows to verify that, when resolving a symlink, user-space is called only the first time when caching is enabled or, if caching is disabled, every time the symlink resolution is requested.
--- .../selftests/filesystems/fuse/.gitignore | 1 + .../selftests/filesystems/fuse/Makefile | 2 + .../fuse/fuse_symlink_cache_test.c | 162 ++++++++++++++++++ 3 files changed, 165 insertions(+) create mode 100644 tools/testing/selftests/filesystems/fuse/fuse_symlink_cache_test.c
tools/testing/selftests/filesystems/fuse/.gitignore +1 -0
@@ -3,3 +3,4 @@ fuse_mnt fusectl_test write_extend_eof_test fuse_acl_cache_test +fuse_symlink_cache_test
tools/testing/selftests/filesystems/fuse/Makefile +2 -0
@@ -5,6 +5,7 @@ CFLAGS += -Wall -O2 -g $(KHDR_INCLUDES) TEST_GEN_PROGS := fusectl_test TEST_GEN_PROGS += write_extend_eof_test TEST_GEN_PROGS += fuse_acl_cache_test +TEST_GEN_PROGS += fuse_symlink_cache_test TEST_GEN_FILES := fuse_mnt include ../../lib.mk
@@ -28,5 +29,6 @@ $(OUTPUT)/fuse_mnt: CFLAGS += $(VAR_CFLAGS) $(OUTPUT)/fuse_mnt: LDLIBS += $(VAR_LDLIBS) $(OUTPUT)/fuse_acl_cache_test: fuse_common.c fuse_acl_cache_test.c +$(OUTPUT)/fuse_symlink_cache_test: fuse_common.c fuse_symlink_cache_test.c EXTRA_CLEAN := fuse_common.o
tools/testing/selftests/filesystems/fuse/fuse_symlink_cache_test.c new file +162 -0
162 lines not on this page · raw message
RFC PATCH v5 8/8 selftests/fuse: add fuse readdir caching test
In reply to Luis HenriquesThis new test will check the caching behaviour using combinations of two opendir flags: FOPEN_KEEP_CACHE and FOPEN_CACHE_DIR.
--- .../selftests/filesystems/fuse/.gitignore | 1 + .../selftests/filesystems/fuse/Makefile | 2 + .../fuse/fuse_readdir_cache_test.c | 273 ++++++++++++++++++ 3 files changed, 276 insertions(+) create mode 100644 tools/testing/selftests/filesystems/fuse/fuse_readdir_cache_test.c
tools/testing/selftests/filesystems/fuse/.gitignore +1 -0
@@ -4,3 +4,4 @@ fusectl_test write_extend_eof_test fuse_acl_cache_test fuse_symlink_cache_test +fuse_readdir_cache_test
tools/testing/selftests/filesystems/fuse/Makefile +2 -0
@@ -6,6 +6,7 @@ TEST_GEN_PROGS := fusectl_test TEST_GEN_PROGS += write_extend_eof_test TEST_GEN_PROGS += fuse_acl_cache_test TEST_GEN_PROGS += fuse_symlink_cache_test +TEST_GEN_PROGS += fuse_readdir_cache_test TEST_GEN_FILES := fuse_mnt include ../../lib.mk
@@ -30,5 +31,6 @@ $(OUTPUT)/fuse_mnt: LDLIBS += $(VAR_LDLIBS) $(OUTPUT)/fuse_acl_cache_test: fuse_common.c fuse_acl_cache_test.c $(OUTPUT)/fuse_symlink_cache_test: fuse_common.c fuse_symlink_cache_test.c +$(OUTPUT)/fuse_readdir_cache_test: fuse_common.c fuse_readdir_cache_test.c EXTRA_CLEAN := fuse_common.o
tools/testing/selftests/filesystems/fuse/fuse_readdir_cache_test.c new file +273 -0
273 lines not on this page · raw message
Quoted 6 lines · Luis Henriques
Hi!
Following this email, I'm sending v5 of this patchset. Here's what changed since v4 (mostly from Amir's review):
Quoted 6 lines
- Included suggested changes to the document
- Moved back 'structfuse_common_ctx' into tests FIXTURE
- Fixed a few typos in the tests comments
- Added missing SPDX-License-Identifier tag tofuse_common.h
- Added an initial stab on the dentries cache (hence not adding Amir's 'Reviewed-by' tag in the first patch)
Applied, thanks.
Miklos