public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
To: Jan Kara <jack@suse.cz>, Ted Tso <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org,
	Gao Xiang <hsiangkao@linux.alibaba.com>,
	Dave Chinner <david@fromorbit.com>, Jan Kara <jack@suse.cz>,
	stable@vger.kernel.org
Subject: Re: [PATCH v3] ext4: Properly sync file size update after O_SYNC direct IO
Date: Fri, 13 Oct 2023 23:33:56 +0530	[thread overview]
Message-ID: <87edhyielv.fsf@doe.com> (raw)
In-Reply-To: <20231013121350.26872-1-jack@suse.cz>

Jan Kara <jack@suse.cz> writes:

> Gao Xiang has reported that on ext4 O_SYNC direct IO does not properly
> sync file size update and thus if we crash at unfortunate moment, the
> file can have smaller size although O_SYNC IO has reported successful
> completion. The problem happens because update of on-disk inode size is
> handled in ext4_dio_write_iter() *after* iomap_dio_rw() (and thus
> dio_complete() in particular) has returned and generic_file_sync() gets
> called by dio_complete(). Fix the problem by handling on-disk inode size
> update directly in our ->end_io completion handler.
>
> References: https://lore.kernel.org/all/02d18236-26ef-09b0-90ad-030c4fe3ee20@linux.alibaba.com
> Reported-by: Gao Xiang <hsiangkao@linux.alibaba.com>
> CC: stable@vger.kernel.org
> Fixes: 378f32bab371 ("ext4: introduce direct I/O write using iomap infrastructure")
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
>  fs/ext4/file.c | 153 +++++++++++++++++++++----------------------------
>  1 file changed, 65 insertions(+), 88 deletions(-)
>
> Changes since v2:
> * Added more comments explaining the code flow
> * Added WARN_ON_ONCE to verify extending IO is handled synchronously
>
> Changes since v1:
> * Rebased on top of Linus' tree (instead of a tree with iomap cleanup)
> * Made ext4_dio_write_end_io() always return number of written bytes on
>   success for consistency

Thanks for addressing it. It's always better to have a consistent return
value wherever possible.

> * Added Fixes tag

Looks good to me. Please feel free to add - 

Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>

  reply	other threads:[~2023-10-13 18:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-13 12:13 [PATCH v3] ext4: Properly sync file size update after O_SYNC direct IO Jan Kara
2023-10-13 18:03 ` Ritesh Harjani [this message]
2023-10-23  0:55 ` Theodore Ts'o

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=87edhyielv.fsf@doe.com \
    --to=ritesh.list@gmail.com \
    --cc=david@fromorbit.com \
    --cc=hsiangkao@linux.alibaba.com \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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