AOSP: erofs-utils: pass a parameter to write tail end in block list
PATCH v2 1/2 AOSP: erofs-utils: pass a parameter to write tail end in block list
From: Yue Hu <[email protected]>
We can determine whether the tail block is the first one or not during the writing process. Therefore, instead of internally checking the block number for the tail block map, just simply pass the flag.
Also, add the missing sbi argument to macro erofs_blknr.
---
v2: change commit message a bit
include/erofs/block_list.h | 4 ++-- lib/block_list.c | 5 ++--- lib/inode.c | 9 +++++++-- 3 files changed, 11 insertions(+), 7 deletions(-)
include/erofs/block_list.h +2 -2
@@ -19,7 +19,7 @@ void erofs_droid_blocklist_fclose(void);void erofs_droid_blocklist_write (struct erofs_inode *inode,erofs_blk_t blk_start,erofs_blk_t nblocks);void erofs_droid_blocklist_write_tail_end (struct erofs_inode *inode, -erofs_blk_t blkaddr); +erofs_blk_t blkaddr,bool first_block);void erofs_droid_blocklist_write_extent (struct erofs_inode *inode,erofs_blk_t blk_start,erofs_blk_t nblocks,bool first_extent,bool last_extent);
@@ -28,7 +28,7 @@ static inline void erofs_droid_blocklist_write(struct erofs_inode *inode, erofs_blk_t blk_start, erofs_blk_t nblocks) {}static inline void erofs_droid_blocklist_write_tail_end (struct erofs_inode *inode, -erofs_blk_t blkaddr) {} +erofs_blk_t blkaddr,bool first_block) {} static inline void erofs_droid_blocklist_write_extent(struct erofs_inode *inode, erofs_blk_t blk_start, erofs_blk_t nblocks,
lib/block_list.c +2 -3
@@ -85,7 +85,7 @@ void erofs_droid_blocklist_write(struct erofs_inode *inode, }void erofs_droid_blocklist_write_tail_end (struct erofs_inode *inode, -erofs_blk_t blkaddr) +erofs_blk_t blkaddr,bool first_block) {if (!block_list_fp || !cfg.mount_point)return ;
@@ -94,8 +94,7 @@ void erofs_droid_blocklist_write_tail_end(struct erofs_inode *inode,if (S_ISDIR (inode->i_mode) ||S_ISLNK (inode->i_mode))return ; -/* XXX: another hack, which means it has been outputed before */ -if (erofs_blknr (inode->i_size)) { +if (!first_block) {if (blkaddr ==NULL_ADDR )fprintf (block_list_fp,"\n" );else
lib/inode.c +7 -2
@@ -734,12 +734,15 @@ static int erofs_write_tail_end(struct erofs_inode *inode) {struct erofs_sb_info *sbi = inode->sbi;struct erofs_buffer_head *bh, *ibh; +bool first_block; bh = inode->bh_data;if (!inode->idata_size) goto out; + first_block = !erofs_blknr (sbi, inode->i_size); +/* have enough room to inline data */ if (inode->bh_inline) { ibh = inode->bh_inline;
@@ -747,7 +750,8 @@ static int erofs_write_tail_end(struct erofs_inode *inode) ibh->fsprivate =erofs_igrab (inode); ibh->op = &erofs_write_inline_bhops; -erofs_droid_blocklist_write_tail_end (inode,NULL_ADDR ); +erofs_droid_blocklist_write_tail_end (inode,NULL_ADDR , + first_block); }else {int ret;erofs_off_t pos, zero_pos;
@@ -801,7 +805,8 @@ static int erofs_write_tail_end(struct erofs_inode *inode)free (inode->idata); inode->idata =NULL ; -erofs_droid_blocklist_write_tail_end (inode,erofs_blknr (sbi, pos)); +erofs_droid_blocklist_write_tail_end (inode,erofs_blknr (sbi, pos), + first_block); } out:/* now bh_data can drop directly */
Signature · 1 line
2.17.1
PATCH 2/2 AOSP: erofs-utils: add a variable to validate tail block map in block list
From: Yue Hu <[email protected]>
We write the block map directly before the tail, as this applies only to regular files. However, the tail block map does not follow the rule.
Therefore, introduce a variable to track whether the tail block is safe to write before its map if it exists rather than separately check the file type when mapping.
--- lib/block_list.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
lib/block_list.c +9 -7
@@ -12,6 +12,7 @@#include "erofs/print.h" static FILE *block_list_fp; +static bool regular_tail = false;int erofs_droid_blocklist_fopen (void ) {
@@ -77,22 +78,23 @@ void erofs_droid_blocklist_write_extent(struct erofs_inode *inode,void erofs_droid_blocklist_write (struct erofs_inode *inode,erofs_blk_t blk_start,erofs_blk_t nblocks) { -if (!block_list_fp || !cfg.mount_point || !nblocks) +if (!block_list_fp || !cfg.mount_point)return ; -blocklist_write (inode->i_srcpath, blk_start, nblocks, - true, !inode->idata_size); +if (nblocks) +blocklist_write (inode->i_srcpath, blk_start, nblocks, true, + !inode->idata_size); +if (inode->idata_size) + regular_tail = true; }void erofs_droid_blocklist_write_tail_end (struct erofs_inode *inode,erofs_blk_t blkaddr,bool first_block) { -if (!block_list_fp || !cfg.mount_point) +if (!block_list_fp || !cfg.mount_point || !regular_tail)return ; -/* XXX: a bit hacky.. may need a better approach */ -if (S_ISDIR (inode->i_mode) ||S_ISLNK (inode->i_mode)) -return ; + regular_tail = false;if (!first_block) {if (blkaddr ==NULL_ADDR )
Signature · 1 line
2.17.1
Quoted 7 lines · Yue Hu
From: Yue Hu <[email protected]>
We can determine whether the tail block is the first one or not during the writing process. Therefore, instead of internally checking the block number for the tail block map, just simply pass the flag.
Also, add the missing sbi argument to macro
erofs_blknr.
Could you submit a patch to fix this issue first?
Quoted 15 lines
Signed-off-by Yue Hu <[email protected]>---
v2: change commit message a bitinclude/erofs/block_list.h | 4 ++-- lib/block_list.c | 5 ++--- lib/inode.c | 9 +++++++-- 3 files changed, 11 insertions(+), 7 deletions(-)include/erofs/block_list.h +0
-0
include/erofs/block_list.h void erofs_droid_blocklist_fclose(void); · line 22
Quoted 5 lines
include/erofs/block_list.h +1
-1@@ -19,7 +19,7 @@ void erofs_droid_blocklist_fclose(void);void erofs_droid_blocklist_write (struct erofs_inode *inode,erofs_blk_t blk_start,erofs_blk_t nblocks);void erofs_droid_blocklist_write_tail_end (struct erofs_inode *inode, -erofs_blk_t blkaddr); +erofs_blk_t blkaddr,bool first_block);
I still have no idea why we need this, could you describe the Android block map details for discussion?
Thanks,
Gao Xiang
Quoted 10 lines · On Tue, 15 Aug 2023 12:59:56 +0800 Gao Xiang <[email protected]>…
Quoted 7 lines · Yue Hu
From: Yue Hu <[email protected]>
We can determine whether the tail block is the first one or not during the writing process. Therefore, instead of internally checking the block number for the tail block map, just simply pass the flag.
Also, add the missing sbi argument to macro
erofs_blknr.Could you submit a patch to fix this issue first?
ok, will do that.
Quoted 11 lines
Quoted 11 lines
Signed-off-by Yue Hu <[email protected]>---
v2: change commit message a bitinclude/erofs/block_list.h | 4 ++-- lib/block_list.c | 5 ++--- lib/inode.c | 9 +++++++-- 3 files changed, 11 insertions(+), 7 deletions(-)
Quoted 13 lines
include/erofs/block_list.h void erofs_droid_blocklist_fclose(void); · line 22
Quoted 10 lines
include/erofs/block_list.h +1
-1@@ -19,7 +19,7 @@ void erofs_droid_blocklist_fclose(void);void erofs_droid_blocklist_write (struct erofs_inode *inode,erofs_blk_t blk_start,erofs_blk_t nblocks);void erofs_droid_blocklist_write_tail_end (struct erofs_inode *inode, -erofs_blk_t blkaddr); +erofs_blk_t blkaddr,bool first_block);I still have no idea why we need this, could you describe the Android block map details for discussion?
Android block map is just adding file blocks to a range.
So, the tail block should be needed in this range as well.
I think one simple way is just appending the tail block address in it as below:
/file_path block1_address-blockn_address tail_block_address
or
/file_path tail_block_address //only one block
Quoted 3 lines
Thanks,
Gao Xiang
Quoted 41 lines · Yue Hu
Quoted 10 lines · On Tue, 15 Aug 2023 12:59:56 +0800 Gao Xiang <[email protected]>…
Quoted 7 lines · Yue Hu
From: Yue Hu <[email protected]>
We can determine whether the tail block is the first one or not during the writing process. Therefore, instead of internally checking the block number for the tail block map, just simply pass the flag.
Also, add the missing sbi argument to macro
erofs_blknr.Could you submit a patch to fix this issue first?
ok, will do that.
Quoted 11 lines
Quoted 11 lines
Signed-off-by Yue Hu <[email protected]>---
v2: change commit message a bitinclude/erofs/block_list.h | 4 ++-- lib/block_list.c | 5 ++--- lib/inode.c | 9 +++++++-- 3 files changed, 11 insertions(+), 7 deletions(-)Quoted 13 lines
include/erofs/block_list.h void erofs_droid_blocklist_fclose(void); · line 22
Quoted 10 lines
include/erofs/block_list.h +1
-1@@ -19,7 +19,7 @@ void erofs_droid_blocklist_fclose(void);void erofs_droid_blocklist_write (struct erofs_inode *inode,erofs_blk_t blk_start,erofs_blk_t nblocks);void erofs_droid_blocklist_write_tail_end (struct erofs_inode *inode, -erofs_blk_t blkaddr); +erofs_blk_t blkaddr,bool first_block);I still have no idea why we need this, could you describe the Android block map details for discussion?
Quoted 6 lines
Android block map is just adding file blocks to a range.
So, the tail block should be needed in this range as well.
I think one simple way is just appending the tail block address in it as below:/
file_pathblock1_address-blockn_addresstail_block_address
why tail_block_address needs a seperate field?
Quoted 4 lines
or
/
file_pathtail_block_address//only one block
how about recording the previous inode pointer as an internal global variable? if it's not the same inode, trigger "\n" immediately.
and generate files as:
" block1_address-blockn_address" for many blocks; " block1_address" for a single block?
Thanks,
Gao Xiang
Quoted 42 lines · On Tue, 15 Aug 2023 13:36:46 +0800 Gao Xiang <[email protected]>…
Quoted 41 lines · Yue Hu
Quoted 10 lines · On Tue, 15 Aug 2023 12:59:56 +0800 Gao Xiang <[email protected]>…
Quoted 7 lines · Yue Hu
From: Yue Hu <[email protected]>
We can determine whether the tail block is the first one or not during the writing process. Therefore, instead of internally checking the block number for the tail block map, just simply pass the flag.
Also, add the missing sbi argument to macro
erofs_blknr.Could you submit a patch to fix this issue first?
ok, will do that.
Quoted 24 lines
Quoted 16 lines
Signed-off-by Yue Hu <[email protected]>---
v2: change commit message a bitinclude/erofs/block_list.h | 4 ++-- lib/block_list.c | 5 ++--- lib/inode.c | 9 +++++++-- 3 files changed, 11 insertions(+), 7 deletions(-)include/erofs/block_list.h +0
-0include/erofs/block_list.h void erofs_droid_blocklist_fclose(void); · line 22
Quoted 5 lines
include/erofs/block_list.h +1
-1@@ -19,7 +19,7 @@ void erofs_droid_blocklist_fclose(void);void erofs_droid_blocklist_write (struct erofs_inode *inode,erofs_blk_t blk_start,erofs_blk_t nblocks);void erofs_droid_blocklist_write_tail_end (struct erofs_inode *inode, -erofs_blk_t blkaddr); +erofs_blk_t blkaddr,bool first_block);I still have no idea why we need this, could you describe the Android block map details for discussion?
Quoted 8 lines
Quoted 6 lines
Android block map is just adding file blocks to a range.
So, the tail block should be needed in this range as well.
I think one simple way is just appending the tail block address in it as below:/
file_pathblock1_address-blockn_addresstail_block_addresswhy
tail_block_addressneeds a seperate field?
Well, erofs_write_tail_end() is a separate logic and i think appending this block is simple enough since i don't need to consider whether the block address is contiguous with previous one.
And i think Android block map can handle this since i have saw below in ext4:
/system/.../libclang_rt.ubsan_standalone-arm-android.so 51276-51309 0 51310-51403
Quoted 4 lines
Quoted 4 lines
or
Quoted 8 lines
Quoted 1 line
/
file_pathtail_block_address//only one blockhow about recording the previous inode pointer as an internal global variable? if it's not the same inode, trigger "\n" immediately.
and generate files as:
"block1_address-blockn_address" for many blocks; "block1_address" for a single block?
Let me check.
Quoted 3 lines
Thanks,
Gao Xiang
Quoted 54 lines · Yue Hu
Quoted 42 lines · On Tue, 15 Aug 2023 13:36:46 +0800 Gao Xiang <[email protected]>…
Quoted 41 lines · Yue Hu
Quoted 10 lines · On Tue, 15 Aug 2023 12:59:56 +0800 Gao Xiang <[email protected]>…
Quoted 7 lines · Yue Hu
From: Yue Hu <[email protected]>
We can determine whether the tail block is the first one or not during the writing process. Therefore, instead of internally checking the block number for the tail block map, just simply pass the flag.
Also, add the missing sbi argument to macro
erofs_blknr.Could you submit a patch to fix this issue first?
ok, will do that.
Quoted 24 lines
Quoted 16 lines
Signed-off-by Yue Hu <[email protected]>---
v2: change commit message a bitinclude/erofs/block_list.h | 4 ++-- lib/block_list.c | 5 ++--- lib/inode.c | 9 +++++++-- 3 files changed, 11 insertions(+), 7 deletions(-)include/erofs/block_list.h +0
-0include/erofs/block_list.h void erofs_droid_blocklist_fclose(void); · line 22
Quoted 5 lines
include/erofs/block_list.h +1
-1@@ -19,7 +19,7 @@ void erofs_droid_blocklist_fclose(void);void erofs_droid_blocklist_write (struct erofs_inode *inode,erofs_blk_t blk_start,erofs_blk_t nblocks);void erofs_droid_blocklist_write_tail_end (struct erofs_inode *inode, -erofs_blk_t blkaddr); +erofs_blk_t blkaddr,bool first_block);I still have no idea why we need this, could you describe the Android block map details for discussion?
Quoted 8 lines
Quoted 6 lines
Android block map is just adding file blocks to a range.
So, the tail block should be needed in this range as well.
I think one simple way is just appending the tail block address in it as below:/
file_pathblock1_address-blockn_addresstail_block_addresswhy
tail_block_addressneeds a seperate field?
Quoted 7 lines
Well,
erofs_write_tail_end()is a separate logic and i think appending this block is simple enough since i don't need to consider whether the block address is contiguous with previous one.And i think Android block map can handle this since i have saw below in ext4:
/system/.../libclang_rt.ubsan_standalone-arm-android.so 51276-51309 0 51310-51403
What's the meaning of 0 here?
Thanks,
Gao Xiang
Quoted 59 lines · On Tue, 15 Aug 2023 14:18:08 +0800 Gao Xiang <[email protected]>…
Quoted 58 lines · Yue Hu
Quoted 42 lines · On Tue, 15 Aug 2023 13:36:46 +0800 Gao Xiang <[email protected]>…
Quoted 41 lines · Yue Hu
Quoted 10 lines · On Tue, 15 Aug 2023 12:59:56 +0800 Gao Xiang <[email protected]>…
Quoted 7 lines · Yue Hu
From: Yue Hu <[email protected]>
We can determine whether the tail block is the first one or not during the writing process. Therefore, instead of internally checking the block number for the tail block map, just simply pass the flag.
Also, add the missing sbi argument to macro
erofs_blknr.Could you submit a patch to fix this issue first?
ok, will do that.
Quoted 24 lines
Quoted 16 lines
Signed-off-by Yue Hu <[email protected]>---
v2: change commit message a bitinclude/erofs/block_list.h | 4 ++-- lib/block_list.c | 5 ++--- lib/inode.c | 9 +++++++-- 3 files changed, 11 insertions(+), 7 deletions(-)include/erofs/block_list.h +0
-0include/erofs/block_list.h void erofs_droid_blocklist_fclose(void); · line 22
Quoted 5 lines
include/erofs/block_list.h +1
-1@@ -19,7 +19,7 @@ void erofs_droid_blocklist_fclose(void);void erofs_droid_blocklist_write (struct erofs_inode *inode,erofs_blk_t blk_start,erofs_blk_t nblocks);void erofs_droid_blocklist_write_tail_end (struct erofs_inode *inode, -erofs_blk_t blkaddr); +erofs_blk_t blkaddr,bool first_block);I still have no idea why we need this, could you describe the Android block map details for discussion?
Quoted 8 lines
Quoted 6 lines
Android block map is just adding file blocks to a range.
So, the tail block should be needed in this range as well.
I think one simple way is just appending the tail block address in it as below:/
file_pathblock1_address-blockn_addresstail_block_addresswhy
tail_block_addressneeds a seperate field?Well,
erofs_write_tail_end()is a separate logic and i think appending this block is simple enough since i don't need to consider whether the block address is contiguous with previous one.
Quoted 5 lines
Quoted 3 lines
And i think Android block map can handle this since i have saw below in ext4:
/system/.../libclang_rt.ubsan_standalone-arm-android.so 51276-51309 0 51310-51403
What's the meaning of 0 here?
I have not check that yet, maybe i need to find time...
And check this: "/.../libxxx.so 87378-88630 0 0 0 88631 0 0 88632-88637 0 0 0 88638-88663"
so, i guess it looks like null block.
Quoted 4 lines
Thanks,
Gao Xiang
Quoted 66 lines · Yue Hu
Quoted 63 lines · On Tue, 15 Aug 2023 14:18:08 +0800 Gao Xiang <[email protected]>…
Quoted 61 lines · Yue Hu
Quoted 42 lines · On Tue, 15 Aug 2023 13:36:46 +0800 Gao Xiang <[email protected]>…
Quoted 41 lines · Yue Hu
Quoted 10 lines · On Tue, 15 Aug 2023 12:59:56 +0800 Gao Xiang <[email protected]>…
Quoted 7 lines · Yue Hu
From: Yue Hu <[email protected]>
We can determine whether the tail block is the first one or not during the writing process. Therefore, instead of internally checking the block number for the tail block map, just simply pass the flag.
Also, add the missing sbi argument to macro
erofs_blknr.Could you submit a patch to fix this issue first?
ok, will do that.
Quoted 24 lines
Quoted 16 lines
Signed-off-by Yue Hu <[email protected]>---
v2: change commit message a bitinclude/erofs/block_list.h | 4 ++-- lib/block_list.c | 5 ++--- lib/inode.c | 9 +++++++-- 3 files changed, 11 insertions(+), 7 deletions(-)include/erofs/block_list.h +0
-0include/erofs/block_list.h void erofs_droid_blocklist_fclose(void); · line 22
Quoted 5 lines
include/erofs/block_list.h +1
-1@@ -19,7 +19,7 @@ void erofs_droid_blocklist_fclose(void);void erofs_droid_blocklist_write (struct erofs_inode *inode,erofs_blk_t blk_start,erofs_blk_t nblocks);void erofs_droid_blocklist_write_tail_end (struct erofs_inode *inode, -erofs_blk_t blkaddr); +erofs_blk_t blkaddr,bool first_block);I still have no idea why we need this, could you describe the Android block map details for discussion?
Quoted 8 lines
Quoted 6 lines
Android block map is just adding file blocks to a range.
So, the tail block should be needed in this range as well.
I think one simple way is just appending the tail block address in it as below:/
file_pathblock1_address-blockn_addresstail_block_addresswhy
tail_block_addressneeds a seperate field?Well,
erofs_write_tail_end()is a separate logic and i think appending this block is simple enough since i don't need to consider whether the block address is contiguous with previous one.And i think Android block map can handle this since i have saw below in ext4:
/system/.../libclang_rt.ubsan_standalone-arm-android.so 51276-51309 0 51310-51403
Quoted 7 lines
Quoted 1 line
What's the meaning of 0 here?
I have not check that yet, maybe i need to find time...
And check this: "/.../libxxx.so 87378-88630 0 0 0 88631 0 0 88632-88637 0 0 0 88638-88663"
so, i guess it looks like null block.
So here erofs_droid_blocklist_write_tail_end is not actually needed in principle? 0 is just used for sparse block?
Thanks,
Gao Xiang
Quoted 69 lines · On Tue, 15 Aug 2023 14:44:23 +0800 Gao Xiang <[email protected]>…
Quoted 68 lines · Yue Hu
Quoted 64 lines · On Tue, 15 Aug 2023 14:18:08 +0800 Gao Xiang <[email protected]>…
Quoted 54 lines · Yue Hu
Quoted 42 lines · On Tue, 15 Aug 2023 13:36:46 +0800 Gao Xiang <[email protected]>…
Quoted 41 lines · Yue Hu
Quoted 10 lines · On Tue, 15 Aug 2023 12:59:56 +0800 Gao Xiang <[email protected]>…
Quoted 7 lines · Yue Hu
From: Yue Hu <[email protected]>
We can determine whether the tail block is the first one or not during the writing process. Therefore, instead of internally checking the block number for the tail block map, just simply pass the flag.
Also, add the missing sbi argument to macro
erofs_blknr.Could you submit a patch to fix this issue first?
ok, will do that.
Quoted 24 lines
Quoted 16 lines
Signed-off-by Yue Hu <[email protected]>---
v2: change commit message a bitinclude/erofs/block_list.h | 4 ++-- lib/block_list.c | 5 ++--- lib/inode.c | 9 +++++++-- 3 files changed, 11 insertions(+), 7 deletions(-)include/erofs/block_list.h +0
-0include/erofs/block_list.h void erofs_droid_blocklist_fclose(void); · line 22
Quoted 5 lines
include/erofs/block_list.h +1
-1@@ -19,7 +19,7 @@ void erofs_droid_blocklist_fclose(void);void erofs_droid_blocklist_write (struct erofs_inode *inode,erofs_blk_t blk_start,erofs_blk_t nblocks);void erofs_droid_blocklist_write_tail_end (struct erofs_inode *inode, -erofs_blk_t blkaddr); +erofs_blk_t blkaddr,bool first_block);I still have no idea why we need this, could you describe the Android block map details for discussion?
Quoted 8 lines
Quoted 6 lines
Android block map is just adding file blocks to a range.
So, the tail block should be needed in this range as well.
I think one simple way is just appending the tail block address in it as below:/
file_pathblock1_address-blockn_addresstail_block_addresswhy
tail_block_addressneeds a seperate field?Quoted 7 lines
Well,
erofs_write_tail_end()is a separate logic and i think appending this block is simple enough since i don't need to consider whether the block address is contiguous with previous one.And i think Android block map can handle this since i have saw below in ext4:
/system/.../libclang_rt.ubsan_standalone-arm-android.so 51276-51309 0 51310-51403
What's the meaning of 0 here?
Quoted 8 lines
Quoted 5 lines
I have not check that yet, maybe i need to find time...
And check this: "/.../libxxx.so 87378-88630 0 0 0 88631 0 0 88632-88637 0 0 0 88638-88663"
so, i guess it looks like null block.
So here
erofs_droid_blocklist_write_tail_endis not actually needed in principle? 0 is just used for sparse block?
We need to confirm this.
Quoted 3 lines
Thanks,
Gao Xiang