From: Vivek Goyal <vgoyal@redhat.com>
To: Eric Wong <normalperson@yhbt.net>
Cc: fuse-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org
Subject: Re: per-inode locks in FUSE (kernel vs userspace)
Date: Mon, 6 Dec 2021 17:28:35 -0500 [thread overview]
Message-ID: <Ya6OkznJxzAFe8fT@redhat.com> (raw)
In-Reply-To: <20211203000534.M766663@dcvr>
On Fri, Dec 03, 2021 at 12:05:34AM +0000, Eric Wong wrote:
> 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?
I guess it probably is a good idea to implement proper locking
in multi-threaded fs and not rely on what kind of locking
kernel is doing. If kernel locking changes down the line, your
implementation will be broken.
Vivek
next prev parent reply other threads:[~2021-12-06 22:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-03 0:05 per-inode locks in FUSE (kernel vs userspace) Eric Wong
2021-12-06 22:28 ` Vivek Goyal [this message]
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=Ya6OkznJxzAFe8fT@redhat.com \
--to=vgoyal@redhat.com \
--cc=fuse-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=normalperson@yhbt.net \
/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;
as well as URLs for NNTP newsgroup(s).