* [f2fs-dev] [PATCH] f2fs: fix to use per-inode maxbytes and cleanup
@ 2024-07-18 9:36 ` Zhiguo Niu
0 siblings, 0 replies; 6+ messages in thread
From: Zhiguo Niu @ 2024-07-18 9:36 UTC (permalink / raw)
To: jaegeuk, chao
Cc: ke.wang, linux-kernel, linux-f2fs-devel, zhiguo.niu, Hao_hao.Wang
This is a supplement to commit 6d1451bf7f84 ("f2fs: fix to use per-inode maxbytes")
for some missed cases, also cleanup redundant code in f2fs_llseek.
Cc: Chengguang Xu <cgxu519@mykernel.net>
Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
---
fs/f2fs/data.c | 2 +-
fs/f2fs/file.c | 7 ++-----
fs/f2fs/verity.c | 5 +++--
3 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 6457e5b..1d41d99 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2064,7 +2064,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
static inline loff_t f2fs_readpage_limit(struct inode *inode)
{
if (IS_ENABLED(CONFIG_FS_VERITY) && IS_VERITY(inode))
- return inode->i_sb->s_maxbytes;
+ return max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
return i_size_read(inode);
}
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index effbaa6..e6411d5 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -431,7 +431,7 @@ static bool __found_offset(struct address_space *mapping,
static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
{
struct inode *inode = file->f_mapping->host;
- loff_t maxbytes = inode->i_sb->s_maxbytes;
+ loff_t maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
struct dnode_of_data dn;
pgoff_t pgofs, end_offset;
loff_t data_ofs = offset;
@@ -513,10 +513,7 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
static loff_t f2fs_llseek(struct file *file, loff_t offset, int whence)
{
struct inode *inode = file->f_mapping->host;
- loff_t maxbytes = inode->i_sb->s_maxbytes;
-
- if (f2fs_compressed_file(inode))
- maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
+ loff_t maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
switch (whence) {
case SEEK_SET:
diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c
index f7bb0c5..7fc787c 100644
--- a/fs/f2fs/verity.c
+++ b/fs/f2fs/verity.c
@@ -74,7 +74,7 @@ static int pagecache_write(struct inode *inode, const void *buf, size_t count,
struct address_space *mapping = inode->i_mapping;
const struct address_space_operations *aops = mapping->a_ops;
- if (pos + count > inode->i_sb->s_maxbytes)
+ if (pos + count > (max_file_blocks(inode) << F2FS_BLKSIZE_BITS))
return -EFBIG;
while (count) {
@@ -237,7 +237,8 @@ static int f2fs_get_verity_descriptor(struct inode *inode, void *buf,
pos = le64_to_cpu(dloc.pos);
/* Get the descriptor */
- if (pos + size < pos || pos + size > inode->i_sb->s_maxbytes ||
+ if (pos + size < pos ||
+ pos + size > (max_file_blocks(inode) << F2FS_BLKSIZE_BITS) ||
pos < f2fs_verity_metadata_pos(inode) || size > INT_MAX) {
f2fs_warn(F2FS_I_SB(inode), "invalid verity xattr");
f2fs_handle_error(F2FS_I_SB(inode),
--
1.9.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] f2fs: fix to use per-inode maxbytes and cleanup
@ 2024-07-18 9:36 ` Zhiguo Niu
0 siblings, 0 replies; 6+ messages in thread
From: Zhiguo Niu @ 2024-07-18 9:36 UTC (permalink / raw)
To: jaegeuk, chao
Cc: linux-f2fs-devel, linux-kernel, niuzhiguo84, zhiguo.niu, ke.wang,
Hao_hao.Wang
This is a supplement to commit 6d1451bf7f84 ("f2fs: fix to use per-inode maxbytes")
for some missed cases, also cleanup redundant code in f2fs_llseek.
Cc: Chengguang Xu <cgxu519@mykernel.net>
Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
---
fs/f2fs/data.c | 2 +-
fs/f2fs/file.c | 7 ++-----
fs/f2fs/verity.c | 5 +++--
3 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 6457e5b..1d41d99 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2064,7 +2064,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
static inline loff_t f2fs_readpage_limit(struct inode *inode)
{
if (IS_ENABLED(CONFIG_FS_VERITY) && IS_VERITY(inode))
- return inode->i_sb->s_maxbytes;
+ return max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
return i_size_read(inode);
}
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index effbaa6..e6411d5 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -431,7 +431,7 @@ static bool __found_offset(struct address_space *mapping,
static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
{
struct inode *inode = file->f_mapping->host;
- loff_t maxbytes = inode->i_sb->s_maxbytes;
+ loff_t maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
struct dnode_of_data dn;
pgoff_t pgofs, end_offset;
loff_t data_ofs = offset;
@@ -513,10 +513,7 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
static loff_t f2fs_llseek(struct file *file, loff_t offset, int whence)
{
struct inode *inode = file->f_mapping->host;
- loff_t maxbytes = inode->i_sb->s_maxbytes;
-
- if (f2fs_compressed_file(inode))
- maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
+ loff_t maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
switch (whence) {
case SEEK_SET:
diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c
index f7bb0c5..7fc787c 100644
--- a/fs/f2fs/verity.c
+++ b/fs/f2fs/verity.c
@@ -74,7 +74,7 @@ static int pagecache_write(struct inode *inode, const void *buf, size_t count,
struct address_space *mapping = inode->i_mapping;
const struct address_space_operations *aops = mapping->a_ops;
- if (pos + count > inode->i_sb->s_maxbytes)
+ if (pos + count > (max_file_blocks(inode) << F2FS_BLKSIZE_BITS))
return -EFBIG;
while (count) {
@@ -237,7 +237,8 @@ static int f2fs_get_verity_descriptor(struct inode *inode, void *buf,
pos = le64_to_cpu(dloc.pos);
/* Get the descriptor */
- if (pos + size < pos || pos + size > inode->i_sb->s_maxbytes ||
+ if (pos + size < pos ||
+ pos + size > (max_file_blocks(inode) << F2FS_BLKSIZE_BITS) ||
pos < f2fs_verity_metadata_pos(inode) || size > INT_MAX) {
f2fs_warn(F2FS_I_SB(inode), "invalid verity xattr");
f2fs_handle_error(F2FS_I_SB(inode),
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: fix to use per-inode maxbytes and cleanup
2024-07-18 9:36 ` Zhiguo Niu
@ 2024-07-22 1:41 ` Chao Yu
-1 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2024-07-22 1:41 UTC (permalink / raw)
To: Zhiguo Niu, jaegeuk; +Cc: Hao_hao.Wang, ke.wang, linux-kernel, linux-f2fs-devel
On 2024/7/18 17:36, Zhiguo Niu wrote:
> This is a supplement to commit 6d1451bf7f84 ("f2fs: fix to use per-inode maxbytes")
> for some missed cases, also cleanup redundant code in f2fs_llseek.
>
> Cc: Chengguang Xu <cgxu519@mykernel.net>
> Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] f2fs: fix to use per-inode maxbytes and cleanup
@ 2024-07-22 1:41 ` Chao Yu
0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2024-07-22 1:41 UTC (permalink / raw)
To: Zhiguo Niu, jaegeuk
Cc: linux-f2fs-devel, linux-kernel, niuzhiguo84, ke.wang,
Hao_hao.Wang
On 2024/7/18 17:36, Zhiguo Niu wrote:
> This is a supplement to commit 6d1451bf7f84 ("f2fs: fix to use per-inode maxbytes")
> for some missed cases, also cleanup redundant code in f2fs_llseek.
>
> Cc: Chengguang Xu <cgxu519@mykernel.net>
> Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: fix to use per-inode maxbytes and cleanup
2024-07-18 9:36 ` Zhiguo Niu
@ 2024-07-25 16:53 ` Jaegeuk Kim
-1 siblings, 0 replies; 6+ messages in thread
From: Jaegeuk Kim @ 2024-07-25 16:53 UTC (permalink / raw)
To: Zhiguo Niu; +Cc: ke.wang, linux-kernel, linux-f2fs-devel, Hao_hao.Wang
On 07/18, Zhiguo Niu wrote:
> This is a supplement to commit 6d1451bf7f84 ("f2fs: fix to use per-inode maxbytes")
> for some missed cases, also cleanup redundant code in f2fs_llseek.
>
> Cc: Chengguang Xu <cgxu519@mykernel.net>
> Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
> ---
> fs/f2fs/data.c | 2 +-
> fs/f2fs/file.c | 7 ++-----
> fs/f2fs/verity.c | 5 +++--
> 3 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 6457e5b..1d41d99 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -2064,7 +2064,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
> static inline loff_t f2fs_readpage_limit(struct inode *inode)
> {
> if (IS_ENABLED(CONFIG_FS_VERITY) && IS_VERITY(inode))
> - return inode->i_sb->s_maxbytes;
> + return max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
F2FS_BLK_TO_BYTES(max_file_blocks(inode))?
>
> return i_size_read(inode);
> }
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index effbaa6..e6411d5 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -431,7 +431,7 @@ static bool __found_offset(struct address_space *mapping,
> static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
> {
> struct inode *inode = file->f_mapping->host;
> - loff_t maxbytes = inode->i_sb->s_maxbytes;
> + loff_t maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
> struct dnode_of_data dn;
> pgoff_t pgofs, end_offset;
> loff_t data_ofs = offset;
> @@ -513,10 +513,7 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
> static loff_t f2fs_llseek(struct file *file, loff_t offset, int whence)
> {
> struct inode *inode = file->f_mapping->host;
> - loff_t maxbytes = inode->i_sb->s_maxbytes;
> -
> - if (f2fs_compressed_file(inode))
> - maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
> + loff_t maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
>
> switch (whence) {
> case SEEK_SET:
> diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c
> index f7bb0c5..7fc787c 100644
> --- a/fs/f2fs/verity.c
> +++ b/fs/f2fs/verity.c
> @@ -74,7 +74,7 @@ static int pagecache_write(struct inode *inode, const void *buf, size_t count,
> struct address_space *mapping = inode->i_mapping;
> const struct address_space_operations *aops = mapping->a_ops;
>
> - if (pos + count > inode->i_sb->s_maxbytes)
> + if (pos + count > (max_file_blocks(inode) << F2FS_BLKSIZE_BITS))
> return -EFBIG;
>
> while (count) {
> @@ -237,7 +237,8 @@ static int f2fs_get_verity_descriptor(struct inode *inode, void *buf,
> pos = le64_to_cpu(dloc.pos);
>
> /* Get the descriptor */
> - if (pos + size < pos || pos + size > inode->i_sb->s_maxbytes ||
> + if (pos + size < pos ||
> + pos + size > (max_file_blocks(inode) << F2FS_BLKSIZE_BITS) ||
> pos < f2fs_verity_metadata_pos(inode) || size > INT_MAX) {
> f2fs_warn(F2FS_I_SB(inode), "invalid verity xattr");
> f2fs_handle_error(F2FS_I_SB(inode),
> --
> 1.9.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] f2fs: fix to use per-inode maxbytes and cleanup
@ 2024-07-25 16:53 ` Jaegeuk Kim
0 siblings, 0 replies; 6+ messages in thread
From: Jaegeuk Kim @ 2024-07-25 16:53 UTC (permalink / raw)
To: Zhiguo Niu
Cc: chao, linux-f2fs-devel, linux-kernel, niuzhiguo84, ke.wang,
Hao_hao.Wang
On 07/18, Zhiguo Niu wrote:
> This is a supplement to commit 6d1451bf7f84 ("f2fs: fix to use per-inode maxbytes")
> for some missed cases, also cleanup redundant code in f2fs_llseek.
>
> Cc: Chengguang Xu <cgxu519@mykernel.net>
> Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
> ---
> fs/f2fs/data.c | 2 +-
> fs/f2fs/file.c | 7 ++-----
> fs/f2fs/verity.c | 5 +++--
> 3 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 6457e5b..1d41d99 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -2064,7 +2064,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
> static inline loff_t f2fs_readpage_limit(struct inode *inode)
> {
> if (IS_ENABLED(CONFIG_FS_VERITY) && IS_VERITY(inode))
> - return inode->i_sb->s_maxbytes;
> + return max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
F2FS_BLK_TO_BYTES(max_file_blocks(inode))?
>
> return i_size_read(inode);
> }
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index effbaa6..e6411d5 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -431,7 +431,7 @@ static bool __found_offset(struct address_space *mapping,
> static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
> {
> struct inode *inode = file->f_mapping->host;
> - loff_t maxbytes = inode->i_sb->s_maxbytes;
> + loff_t maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
> struct dnode_of_data dn;
> pgoff_t pgofs, end_offset;
> loff_t data_ofs = offset;
> @@ -513,10 +513,7 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
> static loff_t f2fs_llseek(struct file *file, loff_t offset, int whence)
> {
> struct inode *inode = file->f_mapping->host;
> - loff_t maxbytes = inode->i_sb->s_maxbytes;
> -
> - if (f2fs_compressed_file(inode))
> - maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
> + loff_t maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
>
> switch (whence) {
> case SEEK_SET:
> diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c
> index f7bb0c5..7fc787c 100644
> --- a/fs/f2fs/verity.c
> +++ b/fs/f2fs/verity.c
> @@ -74,7 +74,7 @@ static int pagecache_write(struct inode *inode, const void *buf, size_t count,
> struct address_space *mapping = inode->i_mapping;
> const struct address_space_operations *aops = mapping->a_ops;
>
> - if (pos + count > inode->i_sb->s_maxbytes)
> + if (pos + count > (max_file_blocks(inode) << F2FS_BLKSIZE_BITS))
> return -EFBIG;
>
> while (count) {
> @@ -237,7 +237,8 @@ static int f2fs_get_verity_descriptor(struct inode *inode, void *buf,
> pos = le64_to_cpu(dloc.pos);
>
> /* Get the descriptor */
> - if (pos + size < pos || pos + size > inode->i_sb->s_maxbytes ||
> + if (pos + size < pos ||
> + pos + size > (max_file_blocks(inode) << F2FS_BLKSIZE_BITS) ||
> pos < f2fs_verity_metadata_pos(inode) || size > INT_MAX) {
> f2fs_warn(F2FS_I_SB(inode), "invalid verity xattr");
> f2fs_handle_error(F2FS_I_SB(inode),
> --
> 1.9.1
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-07-25 16:53 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-18 9:36 [f2fs-dev] [PATCH] f2fs: fix to use per-inode maxbytes and cleanup Zhiguo Niu
2024-07-18 9:36 ` Zhiguo Niu
2024-07-22 1:41 ` [f2fs-dev] " Chao Yu
2024-07-22 1:41 ` Chao Yu
2024-07-25 16:53 ` [f2fs-dev] " Jaegeuk Kim
2024-07-25 16:53 ` Jaegeuk Kim
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.