From: Jeff Layton <jlayton@redhat.com>
To: Miklos Szeredi <miklos@szeredi.hu>, Al Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org,
Miklos Szeredi <mszeredi@redhat.com>,
Trond Myklebust <trond.myklebust@hammerspace.com>
Subject: Re: [RFC] fl_owner_t and use of filp_close() in nfs4_free_lock_stateid()
Date: Tue, 11 Oct 2022 16:45:43 -0400 [thread overview]
Message-ID: <5a5a92423c8bac5b275c213ed1ce3fa59cafda4f.camel@redhat.com> (raw)
In-Reply-To: <CAJfpegsgtke1X7FGpMSgTGdDsOxU7kqPqf2JbOAnqgMj0XFoSQ@mail.gmail.com>
On Tue, 2022-10-11 at 21:02 +0200, Miklos Szeredi wrote:
> On Tue, 11 Oct 2022 at 20:04, Al Viro <viro@zeniv.linux.org.uk> wrote:
>
> > Another interesting question is about FUSE ->flush() - how is the
> > server supposed to use the value it gets from
> > inarg.lock_owner = fuse_lock_owner_id(fm->fc, id);
> > in fuse_flush()? Note that e.g. async write might be followed by
> > close() before the completion. Moreover, it's possible to start
> > async write and do unshare(CLONE_FILES); if the descriptor table
> > used to be shared and all other threads exit after our unshare,
> > it's possible to get
> > async write begins, fuse_send_write() called with current->files as owner
> > flush happens, with current->files as id
> > what used to be current->files gets freed and memory reused
> > async write completes
> >
> > Miklos, could you give some braindump on that?
>
> The lock_owner in flush is supposed to be used for remote posix lock
> release [1]. I don't like posix lock semantics the least bit, and in
> hindsight it would have been better to just not try to support remote
> posix locks (nfs doesn't, so why would anyone care for it in fuse?)
> Anyway, it's probably too late to get rid of this wart now.
>
The NFS client maintains lock records in the local VFS. When a file is
closed, the VFS issues a whole file unlock. You're probably getting
bitten by this in locks_remove_posix:
ctx = smp_load_acquire(&inode->i_flctx);
if (!ctx || list_empty(&ctx->flc_posix))
return;
Because FUSE doesn't set any locks in the local kernel, that final
unlock never occurs.
There are a couple of options here: You could have FUSE start setting
local lock records, or you could look at pushing the above check down
into the individual ->lock ops.
> The lock_owner field in read/write/setattr was added for mandatory
> locking [2]. Now that support for mandatory locking has been removed
> this is dead code, I guess. Will clean up in fuse as well.
>
That sounds like a good plan.
>
> [1] v2.6.18: 7142125937e1 ("[PATCH] fuse: add POSIX file locking support")
> [2] v2.6.24: f33321141b27 ("fuse: add support for mandatory locking")
>
next prev parent reply other threads:[~2022-10-11 20:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-11 18:03 [RFC] fl_owner_t and use of filp_close() in nfs4_free_lock_stateid() Al Viro
2022-10-11 19:02 ` Miklos Szeredi
2022-10-11 20:45 ` Jeff Layton [this message]
2022-10-12 7:08 ` 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=5a5a92423c8bac5b275c213ed1ce3fa59cafda4f.camel@redhat.com \
--to=jlayton@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=mszeredi@redhat.com \
--cc=trond.myklebust@hammerspace.com \
--cc=viro@zeniv.linux.org.uk \
/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).