From: Wu Bo via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: linux-kernel@vger.kernel.org
Cc: Wu Bo <wubo.oduw@gmail.com>, Jaegeuk Kim <jaegeuk@kernel.org>,
Wu Bo <bo.wu@vivo.com>,
linux-f2fs-devel@lists.sourceforge.net
Subject: [f2fs-dev] [PATCH v2 12/13] f2fs: convert inline tails to avoid potential issues
Date: Tue, 10 Sep 2024 21:57:25 -0600 [thread overview]
Message-ID: <fbecda7cba8a51a8b685f6d3138a04a99b93e46d.1726024117.git.bo.wu@vivo.com> (raw)
In-Reply-To: <cover.1726024116.git.bo.wu@vivo.com>
Like the commit:
commit b3d208f96d6b ("f2fs: revisit inline_data to avoid data races and potential bugs")
Due to the limitations of inline data, there are many scenarios where
inline isn't supported well, such as move file range.
Therefore, in these scenarios, convert the inline tail file to a regular
file.
Signed-off-by: Wu Bo <bo.wu@vivo.com>
---
fs/f2fs/data.c | 4 ++++
fs/f2fs/file.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
fs/f2fs/verity.c | 4 ++++
3 files changed, 55 insertions(+)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index f52834c1cacd..a59758e1c878 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -4141,6 +4141,10 @@ static int f2fs_swap_activate(struct swap_info_struct *sis, struct file *file,
if (ret)
return ret;
+ ret = f2fs_convert_inline_tail(inode);
+ if (ret)
+ return ret;
+
if (!f2fs_disable_compressed_file(inode))
return -EINVAL;
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 64ea0bfc2e1e..3dcc5e363c13 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -84,6 +84,10 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)
if (err)
goto out;
+ err = f2fs_convert_inline_tail(inode);
+ if (err)
+ goto out;
+
#ifdef CONFIG_F2FS_FS_COMPRESSION
if (f2fs_compressed_file(inode)) {
int ret = f2fs_is_compressed_cluster(inode, page->index);
@@ -1070,6 +1074,12 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
return err;
}
+ if (attr->ia_size > MAX_INLINE_TAIL(inode)) {
+ err = f2fs_convert_inline_tail(inode);
+ if (err)
+ return err;
+ }
+
f2fs_down_write(&fi->i_gc_rwsem[WRITE]);
filemap_invalidate_lock(inode->i_mapping);
@@ -1191,6 +1201,10 @@ static int f2fs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
if (ret)
return ret;
+ ret = f2fs_convert_inline_tail(inode);
+ if (ret)
+ return ret;
+
pg_start = ((unsigned long long) offset) >> PAGE_SHIFT;
pg_end = ((unsigned long long) offset + len) >> PAGE_SHIFT;
@@ -1501,6 +1515,10 @@ static int f2fs_collapse_range(struct inode *inode, loff_t offset, loff_t len)
if (ret)
return ret;
+ ret = f2fs_convert_inline_tail(inode);
+ if (ret)
+ return ret;
+
/* write out all dirty pages from offset */
ret = filemap_write_and_wait_range(inode->i_mapping, offset, LLONG_MAX);
if (ret)
@@ -1591,6 +1609,10 @@ static int f2fs_zero_range(struct inode *inode, loff_t offset, loff_t len,
if (ret)
return ret;
+ ret = f2fs_convert_inline_tail(inode);
+ if (ret)
+ return ret;
+
ret = filemap_write_and_wait_range(mapping, offset, offset + len - 1);
if (ret)
return ret;
@@ -1705,6 +1727,10 @@ static int f2fs_insert_range(struct inode *inode, loff_t offset, loff_t len)
if (ret)
return ret;
+ ret = f2fs_convert_inline_tail(inode);
+ if (ret)
+ return ret;
+
f2fs_balance_fs(sbi, true);
filemap_invalidate_lock(mapping);
@@ -2010,6 +2036,9 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
} else {
/* try to convert inline_data to support compression */
int err = f2fs_convert_inline_inode(inode);
+ if (err)
+ return err;
+ err = f2fs_convert_inline_tail(inode);
if (err)
return err;
@@ -2172,6 +2201,10 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
if (ret)
goto out;
+ ret = f2fs_convert_inline_tail(inode);
+ if (ret)
+ goto out;
+
f2fs_down_write(&fi->i_gc_rwsem[WRITE]);
/*
@@ -2964,10 +2997,16 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
goto out_unlock;
ret = f2fs_convert_inline_inode(src);
+ if (ret)
+ goto out_unlock;
+ ret = f2fs_convert_inline_tail(src);
if (ret)
goto out_unlock;
ret = f2fs_convert_inline_inode(dst);
+ if (ret)
+ goto out_unlock;
+ ret = f2fs_convert_inline_tail(dst);
if (ret)
goto out_unlock;
@@ -3353,6 +3392,10 @@ static int f2fs_ioc_set_pin_file(struct file *filp, unsigned long arg)
if (ret)
goto out;
+ ret = f2fs_convert_inline_tail(inode);
+ if (ret)
+ goto out;
+
if (!f2fs_disable_compressed_file(inode)) {
ret = -EOPNOTSUPP;
goto out;
@@ -3998,6 +4041,10 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)
if (ret)
goto err;
+ ret = f2fs_convert_inline_tail(inode);
+ if (ret)
+ goto err;
+
f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
filemap_invalidate_lock(mapping);
diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c
index f7bb0c54502c..aaf3e754140a 100644
--- a/fs/f2fs/verity.c
+++ b/fs/f2fs/verity.c
@@ -139,6 +139,10 @@ static int f2fs_begin_enable_verity(struct file *filp)
if (err)
return err;
+ err = f2fs_convert_inline_tail(inode);
+ if (err)
+ return err;
+
set_inode_flag(inode, FI_VERITY_IN_PROGRESS);
return 0;
}
--
2.35.3
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2024-09-11 3:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-11 3:57 [f2fs-dev] [PATCH v2 00/13] f2fs: introduce inline tail Wu Bo via Linux-f2fs-devel
2024-09-11 3:57 ` [f2fs-dev] [PATCH v2 01/13] f2fs: add inline tail mount option Wu Bo via Linux-f2fs-devel
2024-09-11 3:57 ` [f2fs-dev] [PATCH v2 02/13] f2fs: add inline tail disk layout definition Wu Bo via Linux-f2fs-devel
2024-09-11 3:57 ` [f2fs-dev] [PATCH v2 03/13] f2fs: implement inline tail write & truncate Wu Bo via Linux-f2fs-devel
2024-09-11 3:57 ` [f2fs-dev] [PATCH v2 04/13] f2fs: implement inline tail read & fiemap Wu Bo via Linux-f2fs-devel
2024-09-11 3:57 ` [f2fs-dev] [PATCH v2 05/13] f2fs: set inline tail flag when create inode Wu Bo via Linux-f2fs-devel
2024-09-11 3:57 ` [f2fs-dev] [PATCH v2 06/13] f2fs: fix address info has been truncated Wu Bo via Linux-f2fs-devel
2024-09-11 3:57 ` [f2fs-dev] [PATCH v2 07/13] f2fs: support seek for inline tail Wu Bo via Linux-f2fs-devel
2024-09-11 3:57 ` [f2fs-dev] [PATCH v2 08/13] f2fs: convert inline tail when inode expand Wu Bo via Linux-f2fs-devel
2024-09-11 3:57 ` [f2fs-dev] [PATCH v2 09/13] f2fs: fix data loss during inline tail writing Wu Bo via Linux-f2fs-devel
2024-09-11 3:57 ` [f2fs-dev] [PATCH v2 10/13] f2fs: avoid inlining quota files Wu Bo via Linux-f2fs-devel
2024-09-11 3:57 ` [f2fs-dev] [PATCH v2 11/13] f2fs: fix inline tail data lost Wu Bo via Linux-f2fs-devel
2024-09-11 3:57 ` Wu Bo via Linux-f2fs-devel [this message]
2024-09-11 3:57 ` [f2fs-dev] [PATCH v2 13/13] f2fs: implement inline tail forward recovery Wu Bo via Linux-f2fs-devel
2024-09-13 7:24 ` kernel test robot
2024-09-12 7:14 ` [f2fs-dev] [PATCH v2 00/13] f2fs: introduce inline tail Chao Yu via Linux-f2fs-devel
2024-09-14 2:41 ` Wu Bo via Linux-f2fs-devel
2024-09-14 9:21 ` Wu Bo via Linux-f2fs-devel
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=fbecda7cba8a51a8b685f6d3138a04a99b93e46d.1726024117.git.bo.wu@vivo.com \
--to=linux-f2fs-devel@lists.sourceforge.net \
--cc=bo.wu@vivo.com \
--cc=jaegeuk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wubo.oduw@gmail.com \
/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).