All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] fsck.f2fs: fix to do sanity check with extra_attr feature
@ 2018-07-09 15:25 Chao Yu
  2018-07-10  1:55 ` Sheng Yong
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2018-07-09 15:25 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel

From: Chao Yu <yuchao0@huawei.com>

This patch tries to fix incorrect extra_attr bit or i_extra_isize value
in fsck.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
v2:
- fix to replace F2FS_INLINE_DATA with F2FS_EXTRA_ATTR.
 fsck/fsck.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 05a6301..36d1977 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -655,7 +655,7 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
 	u32 i_links = le32_to_cpu(node_blk->i.i_links);
 	u64 i_size = le64_to_cpu(node_blk->i.i_size);
 	u64 i_blocks = le64_to_cpu(node_blk->i.i_blocks);
-	int ofs = get_extra_isize(node_blk);
+	int ofs;
 	unsigned char *en;
 	int namelen;
 	unsigned int idx = 0;
@@ -719,6 +719,22 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
 			ftype == F2FS_FT_FIFO || ftype == F2FS_FT_SOCK)
 		goto check;
 
+	if (f2fs_has_extra_isize(&node_blk->i)) {
+		if (c.feature & cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR)) {
+			if (node_blk->i.i_extra_isize >
+				cpu_to_le16(F2FS_TOTAL_EXTRA_ATTR_SIZE)) {
+				node_blk->i.i_extra_isize =
+					cpu_to_le16(F2FS_TOTAL_EXTRA_ATTR_SIZE);
+				need_fix = 1;
+			}
+		} else {
+			/* we don't support tuning F2FS_FEATURE_EXTRA_ATTR now */
+			node_blk->i.i_inline |= ~F2FS_EXTRA_ATTR;
+			need_fix = 1;
+		}
+	}
+	ofs = get_extra_isize(node_blk);
+
 	if ((node_blk->i.i_inline & F2FS_INLINE_DATA)) {
 		if (le32_to_cpu(node_blk->i.i_addr[ofs]) != 0) {
 			/* should fix this bug all the time */
-- 
2.16.2.17.g38e79b1fd


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] fsck.f2fs: fix to do sanity check with extra_attr feature
  2018-07-09 15:25 [PATCH v2] fsck.f2fs: fix to do sanity check with extra_attr feature Chao Yu
@ 2018-07-10  1:55 ` Sheng Yong
  2018-07-10  2:59   ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Sheng Yong @ 2018-07-10  1:55 UTC (permalink / raw)
  To: Chao Yu, jaegeuk; +Cc: linux-f2fs-devel

Hi, Chao,

On 2018/7/9 23:25, Chao Yu wrote:
> From: Chao Yu <yuchao0@huawei.com>
> 
> This patch tries to fix incorrect extra_attr bit or i_extra_isize value
> in fsck.
> 
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> ---
> v2:
> - fix to replace F2FS_INLINE_DATA with F2FS_EXTRA_ATTR.
>   fsck/fsck.c | 18 +++++++++++++++++-
>   1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/fsck/fsck.c b/fsck/fsck.c
> index 05a6301..36d1977 100644
> --- a/fsck/fsck.c
> +++ b/fsck/fsck.c
> @@ -655,7 +655,7 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
>   	u32 i_links = le32_to_cpu(node_blk->i.i_links);
>   	u64 i_size = le64_to_cpu(node_blk->i.i_size);
>   	u64 i_blocks = le64_to_cpu(node_blk->i.i_blocks);
> -	int ofs = get_extra_isize(node_blk);
> +	int ofs;
>   	unsigned char *en;
>   	int namelen;
>   	unsigned int idx = 0;
> @@ -719,6 +719,22 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
>   			ftype == F2FS_FT_FIFO || ftype == F2FS_FT_SOCK)
>   		goto check;
>   
> +	if (f2fs_has_extra_isize(&node_blk->i)) {
> +		if (c.feature & cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR)) {
> +			if (node_blk->i.i_extra_isize >
> +				cpu_to_le16(F2FS_TOTAL_EXTRA_ATTR_SIZE)) {
> +				node_blk->i.i_extra_isize =
> +					cpu_to_le16(F2FS_TOTAL_EXTRA_ATTR_SIZE);
> +				need_fix = 1;
> +			}
> +		} else {
> +			/* we don't support tuning F2FS_FEATURE_EXTRA_ATTR now */
> +			node_blk->i.i_inline |= ~F2FS_EXTRA_ATTR;

node_blk->i.i_inline &= ~F2FS_EXTRA_ATTR;

thanks :-)
.

> +			need_fix = 1;
> +		}
> +	}
> +	ofs = get_extra_isize(node_blk);
> +
>   	if ((node_blk->i.i_inline & F2FS_INLINE_DATA)) {
>   		if (le32_to_cpu(node_blk->i.i_addr[ofs]) != 0) {
>   			/* should fix this bug all the time */
> 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] fsck.f2fs: fix to do sanity check with extra_attr feature
  2018-07-10  1:55 ` Sheng Yong
@ 2018-07-10  2:59   ` Chao Yu
  0 siblings, 0 replies; 3+ messages in thread
From: Chao Yu @ 2018-07-10  2:59 UTC (permalink / raw)
  To: Sheng Yong, Chao Yu, jaegeuk; +Cc: linux-f2fs-devel

Hi Sheng,

On 2018/7/10 9:55, Sheng Yong wrote:
> Hi, Chao,
> 
> On 2018/7/9 23:25, Chao Yu wrote:
>> From: Chao Yu <yuchao0@huawei.com>
>>
>> This patch tries to fix incorrect extra_attr bit or i_extra_isize value
>> in fsck.
>>
>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>> ---
>> v2:
>> - fix to replace F2FS_INLINE_DATA with F2FS_EXTRA_ATTR.
>>   fsck/fsck.c | 18 +++++++++++++++++-
>>   1 file changed, 17 insertions(+), 1 deletion(-)
>>
>> diff --git a/fsck/fsck.c b/fsck/fsck.c
>> index 05a6301..36d1977 100644
>> --- a/fsck/fsck.c
>> +++ b/fsck/fsck.c
>> @@ -655,7 +655,7 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
>>   	u32 i_links = le32_to_cpu(node_blk->i.i_links);
>>   	u64 i_size = le64_to_cpu(node_blk->i.i_size);
>>   	u64 i_blocks = le64_to_cpu(node_blk->i.i_blocks);
>> -	int ofs = get_extra_isize(node_blk);
>> +	int ofs;
>>   	unsigned char *en;
>>   	int namelen;
>>   	unsigned int idx = 0;
>> @@ -719,6 +719,22 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
>>   			ftype == F2FS_FT_FIFO || ftype == F2FS_FT_SOCK)
>>   		goto check;
>>   
>> +	if (f2fs_has_extra_isize(&node_blk->i)) {
>> +		if (c.feature & cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR)) {
>> +			if (node_blk->i.i_extra_isize >
>> +				cpu_to_le16(F2FS_TOTAL_EXTRA_ATTR_SIZE)) {
>> +				node_blk->i.i_extra_isize =
>> +					cpu_to_le16(F2FS_TOTAL_EXTRA_ATTR_SIZE);
>> +				need_fix = 1;
>> +			}
>> +		} else {
>> +			/* we don't support tuning F2FS_FEATURE_EXTRA_ATTR now */
>> +			node_blk->i.i_inline |= ~F2FS_EXTRA_ATTR;
> 
> node_blk->i.i_inline &= ~F2FS_EXTRA_ATTR;

Oh, sorry, let me fix this in v3, thanks for the review. :)

Thanks,

> 
> thanks :-)
> .
> 
>> +			need_fix = 1;
>> +		}
>> +	}
>> +	ofs = get_extra_isize(node_blk);
>> +
>>   	if ((node_blk->i.i_inline & F2FS_INLINE_DATA)) {
>>   		if (le32_to_cpu(node_blk->i.i_addr[ofs]) != 0) {
>>   			/* should fix this bug all the time */
>>
> 
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
> 
> 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-07-10  3:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-09 15:25 [PATCH v2] fsck.f2fs: fix to do sanity check with extra_attr feature Chao Yu
2018-07-10  1:55 ` Sheng Yong
2018-07-10  2:59   ` Chao Yu

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.