From: Jan Kara <jack@suse.cz>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Jens Axboe <axboe@kernel.dk>, Miklos Szeredi <miklos@szeredi.hu>,
David Howells <dhowells@redhat.com>,
Al Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v3 3/7] fs: create kiocb_{start,end}_write() helpers
Date: Thu, 17 Aug 2023 16:47:32 +0200 [thread overview]
Message-ID: <20230817144732.dyeu6e6c5a2m63fg@quack3> (raw)
In-Reply-To: <20230817141337.1025891-4-amir73il@gmail.com>
On Thu 17-08-23 17:13:33, Amir Goldstein wrote:
> aio, io_uring, cachefiles and overlayfs, all open code an ugly variant
> of file_{start,end}_write() to silence lockdep warnings.
>
> Create helpers for this lockdep dance so we can use the helpers in all
> the callers.
>
> Suggested-by: Jan Kara <jack@suse.cz>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> include/linux/fs.h | 36 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 36 insertions(+)
>
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index ced388aff51f..2548048a6e6c 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2579,6 +2579,42 @@ static inline void file_end_write(struct file *file)
> sb_end_write(file_inode(file)->i_sb);
> }
>
> +/**
> + * kiocb_start_write - get write access to a superblock for async file io
> + * @iocb: the io context we want to submit the write with
> + *
> + * This is a variant of sb_start_write() for async io submission.
> + * Should be matched with a call to kiocb_end_write().
> + */
> +static inline void kiocb_start_write(struct kiocb *iocb)
> +{
> + struct inode *inode = file_inode(iocb->ki_filp);
> +
> + sb_start_write(inode->i_sb);
> + /*
> + * Fool lockdep by telling it the lock got released so that it
> + * doesn't complain about the held lock when we return to userspace.
> + */
> + __sb_writers_release(inode->i_sb, SB_FREEZE_WRITE);
> +}
> +
> +/**
> + * kiocb_end_write - drop write access to a superblock after async file io
> + * @iocb: the io context we sumbitted the write with
> + *
> + * Should be matched with a call to kiocb_start_write().
> + */
> +static inline void kiocb_end_write(struct kiocb *iocb)
> +{
> + struct inode *inode = file_inode(iocb->ki_filp);
> +
> + /*
> + * Tell lockdep we inherited freeze protection from submission thread.
> + */
> + __sb_writers_acquired(inode->i_sb, SB_FREEZE_WRITE);
> + sb_end_write(inode->i_sb);
> +}
> +
> /*
> * This is used for regular files where some users -- especially the
> * currently executed binary in a process, previously handled via
> --
> 2.34.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2023-08-17 14:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-17 14:13 [PATCH v3 0/7] kiocb_{start,end}_write() helpers Amir Goldstein
2023-08-17 14:13 ` [PATCH v3 1/7] io_uring: rename kiocb_end_write() local helper Amir Goldstein
2023-08-17 14:46 ` Jan Kara
2023-08-17 14:13 ` [PATCH v3 2/7] fs: add kerneldoc to file_{start,end}_write() helpers Amir Goldstein
2023-08-17 14:46 ` Jan Kara
2023-08-17 14:13 ` [PATCH v3 3/7] fs: create kiocb_{start,end}_write() helpers Amir Goldstein
2023-08-17 14:47 ` Jan Kara [this message]
2023-08-17 14:13 ` [PATCH v3 4/7] io_uring: use " Amir Goldstein
2023-08-21 12:27 ` Jan Kara
2023-08-17 14:13 ` [PATCH v3 5/7] aio: " Amir Goldstein
2023-08-17 14:48 ` Jan Kara
2023-08-17 14:13 ` [PATCH v3 6/7] ovl: " Amir Goldstein
2023-08-17 14:49 ` Jan Kara
2023-08-17 14:13 ` [PATCH v3 7/7] cachefiles: " Amir Goldstein
2023-08-17 14:50 ` Jan Kara
2023-08-17 14:56 ` [PATCH v3 0/7] " Christian Brauner
2023-08-21 11:35 ` Amir Goldstein
2023-08-21 12:27 ` Jan Kara
2023-08-21 15:30 ` Christian Brauner
2023-08-21 16:37 ` Jens Axboe
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=20230817144732.dyeu6e6c5a2m63fg@quack3 \
--to=jack@suse.cz \
--cc=amir73il@gmail.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=dhowells@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--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