mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Luis Henriques <luis@igalia.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
	 Chen Linxuan <me@black-desk.cn>,
	Jonathan Corbet <corbet@lwn.net>,
	 Shuah Khan <skhan@linuxfoundation.org>,
	 fuse-devel@lists.linux.dev, linux-kernel@vger.kernel.org,
	 linux-kselftest@vger.kernel.org,
	 Matt Harvey <mharvey@jumptrading.com>,
	 kernel-dev@igalia.com
Subject: Re: [RFC PATCH v3 6/8] selftests/fuse: add some extra ACL caching tests
Date: Mon, 07 Sep 2026 11:48:31 +0100	[thread overview]
Message-ID: <87ld9dfibk.fsf@wotan.olymp> (raw)
In-Reply-To: <CAOQ4uxhF6qaAxLFt0UP8nBbZTWVVYf_Y7zgL8Lu9xEnJzg=GiA@mail.gmail.com> (Amir Goldstein's message of "Sat, 5 Sep 2026 14:38:24 +0200")

On Sat, Sep 05 2026, Amir Goldstein wrote:

> On Fri, Sep 4, 2026 at 12:38 PM Luis Henriques <luis@igalia.com> wrote:
>>
>> This 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.
>>
>> Signed-off-by: Luis Henriques <luis@igalia.com>
>> ---
>>  .../selftests/filesystems/fuse/.gitignore     |   1 +
>>  .../filesystems/fuse/fuse_acl_cache_test.c    | 179 ++++++++++++++++++
>>  2 files changed, 180 insertions(+)
>>
>> diff --git a/tools/testing/selftests/filesystems/fuse/.gitignore b/tools/testing/selftests/filesystems/fuse/.gitignore
>> index fb51603fe419..f7f3dd345a50 100644
>> --- a/tools/testing/selftests/filesystems/fuse/.gitignore
>> +++ b/tools/testing/selftests/filesystems/fuse/.gitignore
>> @@ -2,3 +2,4 @@
>>  fuse_mnt
>>  fusectl_test
>>  write_extend_eof_test
>> +fuse_acl_cache_test
>> diff --git a/tools/testing/selftests/filesystems/fuse/fuse_acl_cache_test.c b/tools/testing/selftests/filesystems/fuse/fuse_acl_cache_test.c
>> index c2d6658ff7de..9608a0adb967 100644
>> --- a/tools/testing/selftests/filesystems/fuse/fuse_acl_cache_test.c
>> +++ b/tools/testing/selftests/filesystems/fuse/fuse_acl_cache_test.c
>> @@ -83,6 +83,7 @@ struct daemon_state {
>>         uint8_t        *acl;
>>         size_t          acl_size;
>>         int             getxattr_count;
>> +       bool            cache;
>>  };
>>
>>  /*
>> @@ -91,9 +92,17 @@ struct daemon_state {
>>   */
>>  static struct daemon_state g_ds = {
>>         .lock = PTHREAD_MUTEX_INITIALIZER,
>> +       .cache = false,
>>  };
>>
>>  /* ---- FUSE lowlevel callbacks -------------------------------------------- */
>> +static void fs_init(void *userdata, struct fuse_conn_info *conn)
>> +{
>> +       pthread_mutex_lock(&g_ds.lock);
>> +       if (g_ds.cache)
>> +               fuse_set_feature_flag(conn, FUSE_CAP_POSIX_ACL);
>> +       pthread_mutex_unlock(&g_ds.lock);
>> +}
>>
>>  static void fs_lookup(fuse_req_t req, fuse_ino_t parent, const char *name)
>>  {
>> @@ -115,6 +124,8 @@ static void fs_lookup(fuse_req_t req, fuse_ino_t parent, const char *name)
>>         e.attr.st_ino     = FILE_INO;
>>         e.attr.st_mode    = S_IFREG | 0644;
>>         e.attr.st_nlink   = 1;
>> +       e.attr.st_uid = getuid();
>> +       e.attr.st_gid = getgid();
>>         fuse_reply_entry(req, &e);
>>  }
>>
>> @@ -175,10 +186,38 @@ static void fs_getxattr(fuse_req_t req, fuse_ino_t ino, const char *name,
>>         free(acl);
>>  }
>>
>> +static void fs_setxattr(fuse_req_t req, fuse_ino_t ino, const char *name,
>> +                           const char *value, size_t size, int flags)
>> +{
>> +       int ret = 0;
>> +       uint8_t *acl;
>> +
>> +       if (ino != FILE_INO)
>> +               ret = ENOENT;
>> +       else if (!strcmp(name, "system.posix_acl_access")) {
>> +               acl = malloc(size);
>> +               if (acl) {
>> +                       memcpy(acl, value, size);
>> +                       pthread_mutex_lock(&g_ds.lock);
>> +                       if (g_ds.acl)
>> +                               free(g_ds.acl);
>> +                       g_ds.acl = acl;
>> +                       g_ds.acl_size = size;
>> +                       pthread_mutex_unlock(&g_ds.lock);
>> +               } else
>> +                       ret = ENOMEM;
>> +       } else
>> +               ret = ENOTSUP;
>> +
>
> I am allergic to mismatching {} in if/else statements.

Ah! Ah! OK, I'll fix that.  (And I also admit I'm not consistent with
this, which probably means I'm not allergic :-) )

> I personally think that code will be cleaner with a goto error
> without all these multi nesting levels.

Sure, I'll refactor it accordingly.

Cheers,
-- 
Luís

  reply	other threads:[~2026-09-07 10:47 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04 10:39 [RFC PATCH v3 0/8] fuse: caches documentation and testing Luis Henriques
2026-09-04 10:39 ` [RFC PATCH v3 1/8] Documentation: fuse: add document on caches being used by FUSE Luis Henriques
2026-09-05 21:04   ` Amir Goldstein
2026-09-07 10:38     ` Luis Henriques
2026-09-04 10:39 ` [RFC PATCH v3 2/8] selftests/fuse: convert fusectl test to fuse3 Luis Henriques
2026-09-04 10:39 ` [RFC PATCH v3 3/8] selftests/fuse: check that fusectlfs is mounted Luis Henriques
2026-09-05 13:59   ` Amir Goldstein
2026-09-04 10:39 ` [RFC PATCH v3 4/8] selftests/fuse: factor-out test fixture setup/teardown Luis Henriques
2026-09-05 12:45   ` Amir Goldstein
2026-09-07 10:44     ` Luis Henriques
2026-09-07 11:38       ` Amir Goldstein
2026-09-04 10:39 ` [RFC PATCH v3 5/8] selftests/fuse: use dynamically allocated memory to store ACLs Luis Henriques
2026-09-05 14:00   ` Amir Goldstein
2026-09-04 10:39 ` [RFC PATCH v3 6/8] selftests/fuse: add some extra ACL caching tests Luis Henriques
2026-09-05 12:38   ` Amir Goldstein
2026-09-07 10:48     ` Luis Henriques [this message]
2026-09-04 10:39 ` [RFC PATCH v3 7/8] selftests/fuse: add fuse symlink caching test Luis Henriques
2026-09-05 12:32   ` Amir Goldstein
2026-09-07 10:58     ` Luis Henriques
2026-09-04 10:39 ` [RFC PATCH v3 8/8] selftests/fuse: add fuse readdir " Luis Henriques
2026-09-05 14:11   ` Amir Goldstein
2026-09-07 10:55     ` Luis Henriques

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ld9dfibk.fsf@wotan.olymp \
    --to=luis@igalia.com \
    --cc=amir73il@gmail.com \
    --cc=corbet@lwn.net \
    --cc=fuse-devel@lists.linux.dev \
    --cc=kernel-dev@igalia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=me@black-desk.cn \
    --cc=mharvey@jumptrading.com \
    --cc=miklos@szeredi.hu \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®