linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peng Tao <bergwolf@gmail.com>
To: Xie Yongji <xieyongji@bytedance.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH] fuse: Fix deadlock on open(O_TRUNC)
Date: Mon, 16 Aug 2021 10:35:15 +0800	[thread overview]
Message-ID: <CA+a=Yy674ff4r-cVQ_QLyt0D1vh_6OdSeGXCPgNGHQ303mRV0Q@mail.gmail.com> (raw)
In-Reply-To: <20210813093155.45-1-xieyongji@bytedance.com>

On Fri, Aug 13, 2021 at 5:57 PM Xie Yongji <xieyongji@bytedance.com> wrote:
>
> The invalidate_inode_pages2() might be called with FUSE_NOWRITE
> set in fuse_finish_open(), which can lead to deadlock in
> fuse_launder_page().
>
> To fix it, this tries to delay calling invalidate_inode_pages2()
> until FUSE_NOWRITE is removed.
>
> Fixes: e4648309b85a ("fuse: truncate pending writes on O_TRUNC")
> Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
> ---
>  fs/fuse/dir.c    |  2 +-
>  fs/fuse/file.c   | 19 +++++++++++++++----
>  fs/fuse/fuse_i.h |  2 +-
>  3 files changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index eade6f965b2e..d919c3e89cb0 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -548,7 +548,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry,
>                 fuse_sync_release(fi, ff, flags);
>         } else {
>                 file->private_data = ff;
> -               fuse_finish_open(inode, file);
> +               fuse_finish_open(inode, file, false);
>         }
>         return err;
>
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index 97f860cfc195..035af9c88eaf 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -193,12 +193,12 @@ static void fuse_link_write_file(struct file *file)
>         spin_unlock(&fi->lock);
>  }
>
> -void fuse_finish_open(struct inode *inode, struct file *file)
> +void fuse_finish_open(struct inode *inode, struct file *file, bool no_write)
>  {
>         struct fuse_file *ff = file->private_data;
>         struct fuse_conn *fc = get_fuse_conn(inode);
>
> -       if (!(ff->open_flags & FOPEN_KEEP_CACHE))
> +       if (!(ff->open_flags & FOPEN_KEEP_CACHE) && !no_write)
>                 invalidate_inode_pages2(inode->i_mapping);
It would break !FOPEN_KEEP_CACHE semantics, right? Fuse server asks
the kernel not to keep cache across open but kernel still keeps it?

Cheers,
Tao
-- 
Into Sth. Rich & Strange

  reply	other threads:[~2021-08-16  2:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13  9:31 [PATCH] fuse: Fix deadlock on open(O_TRUNC) Xie Yongji
2021-08-16  2:35 ` Peng Tao [this message]
2021-08-16  5:35   ` Yongji Xie
2021-08-16 12:39 ` Miklos Szeredi
2021-08-16 13:16   ` Yongji Xie
2021-12-14 14:26   ` Luís Henriques
2021-12-14 15:19     ` Miklos Szeredi
2021-12-14 15:35       ` Luís 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='CA+a=Yy674ff4r-cVQ_QLyt0D1vh_6OdSeGXCPgNGHQ303mRV0Q@mail.gmail.com' \
    --to=bergwolf@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=xieyongji@bytedance.com \
    /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).