ocfs2-devel.oss.oracle.com archive mirror
 help / color / mirror / Atom feed
From: Junxiao Bi <junxiao.bi@oracle.com>
To: ocfs2-devel@oss.oracle.com
Subject: Re: [Ocfs2-devel] [PATCH 1/2] ocfs2: fix zero out valid data
Date: Mon, 19 Jul 2021 09:27:47 -0700	[thread overview]
Message-ID: <4aa9b048-2480-55a7-876c-f02b472cd8e4@oracle.com> (raw)
In-Reply-To: <20210713211306.50593-1-junxiao.bi@oracle.com>

Anybody help review this?

Thanks,

Junxiao.

On 7/13/21 2:13 PM, Junxiao Bi wrote:
> If append-dio feature is enabled, direct-io write and fallocate could run
> in parallel to extend file size, fallocate used "orig_isize" to record
> i_size before taking "ip_alloc_sem", when ocfs2_zeroout_partial_cluster()
> zeroout EOF blocks, i_size maybe already extended by ocfs2_dio_end_io_write(),
> that will cause valid data zeroed out.
>
> Fixes: 1733438b1d06 ("ocfs2: fix data corruption by fallocate")
> Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
> Cc: <stable@vger.kernel.org>
> ---
>   fs/ocfs2/file.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
> index 775657943057..53bb46ce3cbb 100644
> --- a/fs/ocfs2/file.c
> +++ b/fs/ocfs2/file.c
> @@ -1935,7 +1935,6 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
>   		goto out_inode_unlock;
>   	}
>   
> -	orig_isize = i_size_read(inode);
>   	switch (sr->l_whence) {
>   	case 0: /*SEEK_SET*/
>   		break;
> @@ -1943,7 +1942,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
>   		sr->l_start += f_pos;
>   		break;
>   	case 2: /*SEEK_END*/
> -		sr->l_start += orig_isize;
> +		sr->l_start += i_size_read(inode);
>   		break;
>   	default:
>   		ret = -EINVAL;
> @@ -1998,6 +1997,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
>   		ret = -EINVAL;
>   	}
>   
> +	orig_isize = i_size_read(inode);
>   	/* zeroout eof blocks in the cluster. */
>   	if (!ret && change_size && orig_isize < size) {
>   		ret = ocfs2_zeroout_partial_cluster(inode, orig_isize,

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

  parent reply	other threads:[~2021-07-19 16:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-13 21:13 Junxiao Bi
2021-07-13 21:13 ` [Ocfs2-devel] [PATCH 2/2] ocfs2: issue zeroout to EOF blocks Junxiao Bi
2021-07-21  3:32   ` Joseph Qi
2021-07-19 16:27 ` Junxiao Bi [this message]
2021-07-21  1:54 ` [Ocfs2-devel] [PATCH 1/2] ocfs2: fix zero out valid data Joseph Qi

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=4aa9b048-2480-55a7-876c-f02b472cd8e4@oracle.com \
    --to=junxiao.bi@oracle.com \
    --cc=ocfs2-devel@oss.oracle.com \
    --subject='Re: [Ocfs2-devel] [PATCH 1/2] ocfs2: fix zero out valid data' \
    /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

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).