From: Chao Yu <chao@kernel.org>
To: Daeho Jeong <daeho43@gmail.com>,
linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com
Cc: Daeho Jeong <daehojeong@google.com>
Subject: Re: [f2fs-dev] [PATCH] f2fs: use cow inode data when updating atomic write
Date: Fri, 21 Apr 2023 10:23:54 +0800 [thread overview]
Message-ID: <44ca783a-da8c-aec9-ac35-76acc5475cb9@kernel.org> (raw)
In-Reply-To: <20230418175206.3282328-1-daeho43@gmail.com>
On 2023/4/19 1:52, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@google.com>
>
> Need to use cow inode data content instead of the one in the original
> inode, when we try to write the already updated atomic write files.
>
Miss a fixes line?
Otherwise it looks good to me.
Thanks
> Signed-off-by: Daeho Jeong <daehojeong@google.com>
> ---
> fs/f2fs/data.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 8df225014304..7165b1202f53 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -3491,7 +3491,7 @@ static int __reserve_data_block(struct inode *inode, pgoff_t index,
>
> static int prepare_atomic_write_begin(struct f2fs_sb_info *sbi,
> struct page *page, loff_t pos, unsigned int len,
> - block_t *blk_addr, bool *node_changed)
> + block_t *blk_addr, bool *node_changed, bool *use_cow)
> {
> struct inode *inode = page->mapping->host;
> struct inode *cow_inode = F2FS_I(inode)->cow_inode;
> @@ -3505,10 +3505,12 @@ static int prepare_atomic_write_begin(struct f2fs_sb_info *sbi,
>
> /* Look for the block in COW inode first */
> err = __find_data_block(cow_inode, index, blk_addr);
> - if (err)
> + if (err) {
> return err;
> - else if (*blk_addr != NULL_ADDR)
> + } else if (*blk_addr != NULL_ADDR) {
> + *use_cow = true;
> return 0;
> + }
>
> if (is_inode_flag_set(inode, FI_ATOMIC_REPLACE))
> goto reserve_block;
> @@ -3538,6 +3540,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
> struct page *page = NULL;
> pgoff_t index = ((unsigned long long) pos) >> PAGE_SHIFT;
> bool need_balance = false;
> + bool use_cow = false;
> block_t blkaddr = NULL_ADDR;
> int err = 0;
>
> @@ -3597,7 +3600,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
>
> if (f2fs_is_atomic_file(inode))
> err = prepare_atomic_write_begin(sbi, page, pos, len,
> - &blkaddr, &need_balance);
> + &blkaddr, &need_balance, &use_cow);
> else
> err = prepare_write_begin(sbi, page, pos, len,
> &blkaddr, &need_balance);
> @@ -3637,7 +3640,9 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
> f2fs_handle_error(sbi, ERROR_INVALID_BLKADDR);
> goto fail;
> }
> - err = f2fs_submit_page_read(inode, page, blkaddr, 0, true);
> + err = f2fs_submit_page_read(use_cow ?
> + F2FS_I(inode)->cow_inode : inode, page,
> + blkaddr, 0, true);
> if (err)
> goto fail;
>
next prev parent reply other threads:[~2023-04-21 2:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-18 17:52 [PATCH] f2fs: use cow inode data when updating atomic write Daeho Jeong
2023-04-21 2:23 ` Chao Yu [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-04-24 15:43 Daeho Jeong
2023-04-24 15:47 ` [f2fs-dev] " Chao Yu
2023-04-24 18:10 ` patchwork-bot+f2fs
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=44ca783a-da8c-aec9-ac35-76acc5475cb9@kernel.org \
--to=chao@kernel.org \
--cc=daeho43@gmail.com \
--cc=daehojeong@google.com \
--cc=kernel-team@android.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@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