From: Christoph Hellwig <hch@lst.de>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-xfs@vger.kernel.org, david@fromorbit.com, hch@lst.de,
fdmanana@kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 2/2] vfs: separate __sb_start_write into blocking and non-blocking helpers
Date: Fri, 6 Nov 2020 08:48:29 +0100 [thread overview]
Message-ID: <20201106074829.GB31133@lst.de> (raw)
In-Reply-To: <160463583438.1669281.14783057013328963357.stgit@magnolia>
On Thu, Nov 05, 2020 at 08:10:34PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> Break this function into two helpers so that it's obvious that the
> trylock versions return a value that must be checked, and the blocking
> versions don't require that. While we're at it, clean up the return
> type mismatch.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> fs/aio.c | 2 +-
> fs/io_uring.c | 3 +--
> fs/super.c | 18 ++++++++++++------
> include/linux/fs.h | 21 +++++++++++----------
> 4 files changed, 25 insertions(+), 19 deletions(-)
>
>
> diff --git a/fs/aio.c b/fs/aio.c
> index c45c20d87538..04bb4bac327f 100644
> --- a/fs/aio.c
> +++ b/fs/aio.c
> @@ -1572,7 +1572,7 @@ static int aio_write(struct kiocb *req, const struct iocb *iocb,
> * we return to userspace.
> */
> if (S_ISREG(file_inode(file)->i_mode)) {
> - __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, true);
> + __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE);
This should use sb_start_write()
> if (req->flags & REQ_F_ISREG) {
> - __sb_start_write(file_inode(req->file)->i_sb,
> - SB_FREEZE_WRITE, true);
> + __sb_start_write(file_inode(req->file)->i_sb, SB_FREEZE_WRITE);
Same.
> +void __sb_start_write(struct super_block *sb, int level)
> {
> + percpu_down_read(sb->s_writers.rw_sem + level - 1);
> }
> EXPORT_SYMBOL(__sb_start_write);
>
> +/*
> + * This is an internal function, please use sb_start_{write,pagefault,intwrite}
> + * instead.
> + */
> +bool __sb_start_write_trylock(struct super_block *sb, int level)
> +{
> + return percpu_down_read_trylock(sb->s_writers.rw_sem + level - 1);
> +}
> +EXPORT_SYMBOL_GPL(__sb_start_write_trylock);
I think these can be inline in the headers, or even be merged into
the few callers.
> @@ -2756,14 +2757,14 @@ static inline void file_start_write(struct file *file)
> {
> if (!S_ISREG(file_inode(file)->i_mode))
> return;
> - __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, true);
> + __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE);
This should use sb_start_write.
> }
>
> static inline bool file_start_write_trylock(struct file *file)
> {
> if (!S_ISREG(file_inode(file)->i_mode))
> return true;
> - return __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, false);
> + return __sb_start_write_trylock(file_inode(file)->i_sb, SB_FREEZE_WRITE);
And this one sb_start_write_trylock.
prev parent reply other threads:[~2020-11-06 7:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-06 4:10 [PATCH 0/2] vfs: remove lockdep fs freeze weirdness Darrick J. Wong
2020-11-06 4:10 ` [PATCH 1/2] vfs: remove lockdep bogosity in __sb_start_write Darrick J. Wong
2020-11-06 7:45 ` Christoph Hellwig
2020-11-10 11:31 ` Jan Kara
2020-11-06 4:10 ` [PATCH 2/2] vfs: separate __sb_start_write into blocking and non-blocking helpers Darrick J. Wong
2020-11-06 7:48 ` Christoph Hellwig [this message]
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=20201106074829.GB31133@lst.de \
--to=hch@lst.de \
--cc=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=fdmanana@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox