All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: fuse-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org
Subject: per-inode locks in FUSE (kernel vs userspace)
Date: Fri, 3 Dec 2021 00:05:34 +0000	[thread overview]
Message-ID: <20211203000534.M766663@dcvr> (raw)

Hi all, I'm working on a new multi-threaded FS using the
libfuse3 fuse_lowlevel.h API.  It looks to me like the kernel
already performs the necessary locking on a per-inode basis to
save me some work in userspace.

In particular, I originally thought I'd need pthreads mutexes on
a per-inode (fuse_ino_t) basis to protect userspace data
structures between the .setattr (truncate), .fsync, and
.write_buf userspace callbacks.

However upon reading the kernel, I can see fuse_fsync,
fuse_{cache,direct}_write_iter in fs/fuse/file.c all use
inode_lock.  do_truncate also uses inode_lock in fs/open.c.

So it's look like implementing extra locking in userspace would
do nothing useful in my case, right?

Thanks.

             reply	other threads:[~2021-12-03  0:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-03  0:05 Eric Wong [this message]
2021-12-06 22:28 ` per-inode locks in FUSE (kernel vs userspace) Vivek Goyal
2021-12-07  8:38   ` Miklos Szeredi
2021-12-07 13:48     ` Vivek Goyal
2021-12-07 14:07       ` Miklos Szeredi

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=20211203000534.M766663@dcvr \
    --to=normalperson@yhbt.net \
    --cc=fuse-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.