f2fs: add a max block count for f2fs_map_blocks
PATCH 1/1 f2fs: add a max block count for f2fs_map_blocks
This patch adds a max block count for f2fs_map_blocks
--- fs/f2fs/data.c | 4 ++++ fs/f2fs/f2fs.h | 3 +++ 2 files changed, 7 insertions(+)
fs/f2fs/data.c +4 -0
@@ -578,6 +578,10 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, map->m_len =0 ; map->m_flags =0 ; +/* We can handle the block number less than F2FS_MAX_BLOCKS */ +if (unlikely (map->m_lblk >=F2FS_MAX_BLOCKS )) +return -EUCLEAN ; +/* it only supports block size == page size */ pgofs = (pgoff_t )map->m_lblk;
fs/f2fs/f2fs.h +3 -0
@@ -331,6 +331,9 @@ enum {#define F2FS_LINK_MAX 0xffffffff/* maximum link count per file */ + +#define F2FS_MAX_BLOCKS 0x3F015AFF/* maximum block count per file */ +#define MAX_DIR_RA_PAGES 4/* maximum ra pages of dir */ /* vector size for gang look-up from extent cache that consists of radix tree */
Signature · 4 lines
1.9.1 ------------------------------------------------------------------------------
Hi,
Quoted 8 lines
-----Original Message-----
From: Yunlei He [mailto:[email protected]]
Sent: Friday, December 25, 2015 4:48 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Yunlei He; Xue Liu
Subject: [PATCH] f2fs: add a max block count forf2fs_map_blocksThis patch adds a max block count for
f2fs_map_blocks
Maximum file size should be limited by sb->s_maxbytes which was inited in max_file_size(), so logical block index should not exceed the value calculated with maxbytes, why would we limit logical block index with another value?
Thanks,
Quoted 38 lines
Signed-off-by Yunlei He <[email protected]>Signed-off-by Xue Liu <[email protected]>--- fs/f2fs/data.c | 4 ++++ fs/f2fs/f2fs.h | 3 +++ 2 files changed, 7 insertions(+)fs/f2fs/data.c +4
-0@@ -578,6 +578,10 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, map->m_len =0 ; map->m_flags =0 ; +/* We can handle the block number less than F2FS_MAX_BLOCKS */ +if (unlikely (map->m_lblk >=F2FS_MAX_BLOCKS )) +return -EUCLEAN ; +/* it only supports block size == page size */ pgofs = (pgoff_t )map->m_lblk;fs/f2fs/f2fs.h +3
-1@@ -331,6 +331,9 @@ enum {#define F2FS_LINK_MAX 0xffffffff/* maximum link count per file */ + +#define F2FS_MAX_BLOCKS 0x3F015AFF/* maximum block count per file */ +#define MAX_DIR_RA_PAGES 4/* maximum ra pages of dir */ /* vector size for gang look-up from extent cache that consists of radix tree */ --
Quoted 1 line
1.9.1
------------------------------------------------------------------------------
Quoted 9 lines · Chao Yu
Hi,
Quoted 7 lines
-----Original Message-----
From: Yunlei He [mailto:[email protected]]
Sent: Friday, December 25, 2015 4:48 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Yunlei He; Xue Liu
Subject: [PATCH] f2fs: add a max block count forf2fs_map_blocks
Quoted 9 lines
Quoted 1 line
This patch adds a max block count for
f2fs_map_blocksMaximum file size should be limited by
sb->s_maxbyteswhich was inited inmax_file_size(), so logical block index should not exceed the value calculated with maxbytes, why would we limit logical block index with another value?Thanks,
Hi,
Trinity test program will send a block number as parameter into ioctl_fibmap, which will be used in get_node_path(), when the block number large than f2fs max blocks, it will trigger kernel bug. So we judge the block number in f2fs_map_blocks(), which reference ext4:
file: fs/ext4/inode.c
function: ext4_map_blocks()
/* We can handle the block number less than EXT_MAX_BLOCKS */
if (unlikely(map->m_lblk >= EXT_MAX_BLOCKS))
return -EFSCORRUPTED;Quoted 36 lines
Quoted 36 lines
Signed-off-by Yunlei He <[email protected]>Signed-off-by Xue Liu <[email protected]>--- fs/f2fs/data.c | 4 ++++ fs/f2fs/f2fs.h | 3 +++ 2 files changed, 7 insertions(+)fs/f2fs/data.c +4
-0@@ -578,6 +578,10 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, map->m_len =0 ; map->m_flags =0 ; +/* We can handle the block number less than F2FS_MAX_BLOCKS */ +if (unlikely (map->m_lblk >=F2FS_MAX_BLOCKS )) +return -EUCLEAN ; +/* it only supports block size == page size */ pgofs = (pgoff_t )map->m_lblk;fs/f2fs/f2fs.h +3
-0@@ -331,6 +331,9 @@ enum {#define F2FS_LINK_MAX 0xffffffff/* maximum link count per file */ + +#define F2FS_MAX_BLOCKS 0x3F015AFF/* maximum block count per file */ +#define MAX_DIR_RA_PAGES 4/* maximum ra pages of dir */
Quoted 8 lines
Quoted 3 lines
fs/f2fs/f2fs.h +0
-1/* vector size for gang look-up from extent cache that consists of radix tree */ --1.9.1
.
------------------------------------------------------------------------------
Chao Yu
maintainerHi,
Quoted 17 lines · liuxue
Quoted 16 lines · Chao Yu
Hi,
Quoted 8 lines
-----Original Message-----
From: Yunlei He [mailto:[email protected]]
Sent: Friday, December 25, 2015 4:48 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Yunlei He; Xue Liu
Subject: [PATCH] f2fs: add a max block count forf2fs_map_blocksThis patch adds a max block count for
f2fs_map_blocksMaximum file size should be limited by
sb->s_maxbyteswhich was inited inmax_file_size(), so logical block index should not exceed the value calculated with maxbytes, why would we limit logical block index with another value?
Quoted 7 lines
Quoted 2 lines
Thanks,
Hi,
Trinity test program will send a block number as parameter intoioctl_fibmap, which will be used inget_node_path(), when the block number large than f2fs max blocks, it will trigger kernel bug. So we judge the block number inf2fs_map_blocks(), which reference ext4:
Thanks for the explanation, and this makes sense to me, it's better to add above message in commit log.
Quoted 17 lines
file:
fs/ext4/inode.c
function:ext4_map_blocks()/* We can handle the block number less than EXT_MAX_BLOCKS */ if (unlikely(map->m_lblk >= EXT_MAX_BLOCKS)) return -EFSCORRUPTED;Quoted 8 lines
Quoted 8 lines
Signed-off-by Yunlei He <[email protected]>Signed-off-by Xue Liu <[email protected]>--- fs/f2fs/data.c | 4 ++++ fs/f2fs/f2fs.h | 3 +++ 2 files changed, 7 insertions(+)
Quoted 5 lines
Quoted 5 lines
fs/f2fs/data.c int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
Quoted 5 lines
fs/f2fs/data.c +0
-0@@ -578,6 +578,10 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
As you mentioned, this bug will only be triggered in bmap, so how about checking upper boundary in get_data_block_bmap? Since we could remain bug_on in get_node_path for other call paths to check whether this is a bug of VFS or not.
Quoted 6 lines
Quoted 6 lines
fs/f2fs/data.c int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, · line 583
Quoted 6 lines
fs/f2fs/data.c +3
-0map->m_len =0 ; map->m_flags =0 ; +/* We can handle the block number less than F2FS_MAX_BLOCKS */ +if (unlikely (map->m_lblk >=F2FS_MAX_BLOCKS )) +return -EUCLEAN ;
EFBIG ?
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
fs/f2fs/data.c +1
-0+/* it only supports block size == page size */ pgofs = (pgoff_t )map->m_lblk;fs/f2fs/f2fs.h +0
-0@@ -331,6 +331,9 @@ enum {
Quoted 4 lines
Quoted 4 lines
fs/f2fs/f2fs.h enum { · line 335
Quoted 4 lines
fs/f2fs/f2fs.h +2
-0#define F2FS_LINK_MAX 0xffffffff/* maximum link count per file */ + +#define F2FS_MAX_BLOCKS 0x3F015AFF/* maximum block count per file */
Can you introduce F2FS_MAX_BLOCKS with calculation detail of constant '0x3F015AFF', moreover need to exclude reserved space for inline xattr.
Thanks,
Quoted 14 lines
Quoted 10 lines
Quoted 6 lines
fs/f2fs/f2fs.h +1
-1+#define MAX_DIR_RA_PAGES 4/* maximum ra pages of dir */ /* vector size for gang look-up from extent cache that consists of radix tree */ --1.9.1
.
Quoted 6 lines
------------------------------------------------------------------------------
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
------------------------------------------------------------------------------
Quoted 48 lines · Chao Yu
Hi,
Quoted 17 lines · liuxue
Quoted 16 lines · Chao Yu
Hi,
Quoted 8 lines
-----Original Message-----
From: Yunlei He [mailto:[email protected]]
Sent: Friday, December 25, 2015 4:48 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Yunlei He; Xue Liu
Subject: [PATCH] f2fs: add a max block count forf2fs_map_blocksThis patch adds a max block count for
f2fs_map_blocksMaximum file size should be limited by
sb->s_maxbyteswhich was inited inmax_file_size(), so logical block index should not exceed the value calculated with maxbytes, why would we limit logical block index with another value?Quoted 7 lines
Quoted 2 lines
Thanks,
Hi,
Trinity test program will send a block number as parameter intoioctl_fibmap, which will be used inget_node_path(), when the block number large than f2fs max blocks, it will trigger kernel bug. So we judge the block number inf2fs_map_blocks(), which reference ext4:Thanks for the explanation, and this makes sense to me, it's better to add above message in commit log.
Quoted 17 lines
file:
fs/ext4/inode.c
function:ext4_map_blocks()/* We can handle the block number less than EXT_MAX_BLOCKS */ if (unlikely(map->m_lblk >= EXT_MAX_BLOCKS)) return -EFSCORRUPTED;Quoted 8 lines
Quoted 8 lines
Signed-off-by Yunlei He <[email protected]>Signed-off-by Xue Liu <[email protected]>--- fs/f2fs/data.c | 4 ++++ fs/f2fs/f2fs.h | 3 +++ 2 files changed, 7 insertions(+)
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines
fs/f2fs/data.c int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
Quoted 5 lines
fs/f2fs/data.c +0
-0@@ -578,6 +578,10 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,As you mentioned, this bug will only be triggered in bmap, so how about checking upper boundary in
get_data_block_bmap? Since we could remainbug_oninget_node_pathfor other call paths to check whether this is a bug of VFS or not.
yeah, change here maybe influence dio and fiemap.
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
fs/f2fs/data.c int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, · line 583
Quoted 6 lines
fs/f2fs/data.c +3
-0map->m_len =0 ; map->m_flags =0 ; +/* We can handle the block number less than F2FS_MAX_BLOCKS */ +if (unlikely (map->m_lblk >=F2FS_MAX_BLOCKS )) +return -EUCLEAN ;EFBIG ?
yeah, EFBIG is better.
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
fs/f2fs/data.c +1
-0+/* it only supports block size == page size */ pgofs = (pgoff_t )map->m_lblk;fs/f2fs/f2fs.h +0
-0@@ -331,6 +331,9 @@ enum {#define F2FS_LINK_MAX 0xffffffff/* maximum link count per file */
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
fs/f2fs/f2fs.h enum { · line 335
Quoted 2 lines
fs/f2fs/f2fs.h +2
-0+ +#define F2FS_MAX_BLOCKS 0x3F015AFF/* maximum block count per file */ Can you introduce
F2FS_MAX_BLOCKSwith calculation detail of constant '0x3F015AFF', moreover need to exclude reserved space for inline xattr.Thanks,
I will send version v2 use max_file_size() function.
Thanks,
Quoted 15 lines
Quoted 15 lines
Quoted 11 lines
Quoted 7 lines
fs/f2fs/f2fs.h +1
-1+#define MAX_DIR_RA_PAGES 4/* maximum ra pages of dir */ /* vector size for gang look-up from extent cache that consists of radix tree */ --1.9.1
.
Quoted 9 lines
Quoted 6 lines
------------------------------------------------------------------------------
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel.
------------------------------------------------------------------------------