From: Ming Lei <ming.lei@redhat.com>
To: 胡焜 <huk23@m.fudan.edu.cn>
Cc: linux-block <linux-block@vger.kernel.org>,
"Christoph Hellwig" <hch@infradead.org>,
覃佳基 <jjtan24@m.fudan.edu.cn>
Subject: Re: [PATCH] loop: move vfs_fsync() out of loop_update_dio()
Date: Tue, 18 Mar 2025 09:07:11 +0800 [thread overview]
Message-ID: <Z9jHP7lFB5jVZELN@fedora> (raw)
In-Reply-To: <tencent_569A521D2FECE6C55D795124@qq.com>
On Mon, Mar 17, 2025 at 04:52:16PM +0800, 胡焜 wrote:
> > drivers/block/loop.c | 12 ++++++------
> > 1 file changed, 6 insertions(+), 6 deletions(-)
>
> > diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> > index 1ec7417c7f00..be7e20064427 100644
> > --- a/drivers/block/loop.c
> > +++ b/drivers/block/loop.c
> > @@ -205,8 +205,6 @@ static bool lo_can_use_dio(struct loop_device *lo)
> > */
> > static inline void loop_update_dio(struct loop_device *lo)
> > {
> > - bool dio_in_use = lo->lo_flags & LO_FLAGS_DIRECT_IO;
> > -
> > lockdep_assert_held(&lo->lo_mutex);
> > WARN_ON_ONCE(lo->lo_state == Lo_bound &&
> > lo->lo_queue->mq_freeze_depth == 0);
> > @@ -215,10 +213,6 @@ static inline void loop_update_dio(struct loop_device *lo)
> > lo->lo_flags |= LO_FLAGS_DIRECT_IO;
> > if ((lo->lo_flags & LO_FLAGS_DIRECT_IO) && !lo_can_use_dio(lo))
> > lo->lo_flags &= ~LO_FLAGS_DIRECT_IO;
> > -
> > - /* flush dirty pages before starting to issue direct I/O */
> > - if ((lo->lo_flags & LO_FLAGS_DIRECT_IO) && !dio_in_use)
> > - vfs_fsync(lo->lo_backing_file, 0);
> > }
> >
> > /**
> > @@ -621,6 +615,9 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
> > if (get_loop_size(lo, file) != get_loop_size(lo, old_file))
> > goto out_err;
>
> > + /* may work in dio, so flush page cache for avoiding race */
> > + vfs_fsync(file, 0);
> > +
> > /* and ... switch */
> > disk_force_media_change(lo->lo_disk);
> > blk_mq_freeze_queue(lo->lo_queue);
> > @@ -1098,6 +1095,9 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode,
> > if (error)
> > goto out_unlock;
>
> > + /* may work in dio, so flush page cache for avoiding race */
> > + vfs_fsync(file, 0);
> > +
> > loop_update_dio(lo);
> > loop_sysfs_init(lo);
> >
> > --
> > 2.44.0
>
>
> Hello Ming,
>
> I would like to double check that this fix doesn't seem to have been merged into the main thread, will this version still be merged into mainline kernel tree?
The V2 has been sent out after updating comment, please verify if it fixes your issue:
https://lore.kernel.org/linux-block/20250318010318.3861682-1-ming.lei@redhat.com/
If yes, feel free to provide one tested-by for moving on.
Thanks,
Ming
next prev parent reply other threads:[~2025-03-18 1:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-13 12:06 [PATCH] loop: move vfs_fsync() out of loop_update_dio() Ming Lei
2025-01-13 13:50 ` Christoph Hellwig
2025-01-13 15:04 ` Ming Lei
2025-01-15 6:59 ` Christoph Hellwig
2025-03-17 8:52 ` 胡焜
2025-03-18 1:07 ` Ming Lei [this message]
2025-04-09 5:49 ` [PATCH] " 胡焜
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=Z9jHP7lFB5jVZELN@fedora \
--to=ming.lei@redhat.com \
--cc=hch@infradead.org \
--cc=huk23@m.fudan.edu.cn \
--cc=jjtan24@m.fudan.edu.cn \
--cc=linux-block@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;
as well as URLs for NNTP newsgroup(s).