1. extent_cache
- let's drop the largest extent_cache
2. invalidate_block
- don't show the warnings
Signed-off-by: Jaegeuk Kim <[email protected]>
---
fs/f2fs/checkpoint.c | 5 +++++
fs/f2fs/extent_cache.c | 22 +++++++++++++++-------
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 5774076d7ca3..73ae4e85e70d 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -152,6 +152,11 @@ static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr,
se = get_seg_entry(sbi, segno);
exist = f2fs_test_bit(offset, se->cur_valid_map);
+
+ /* skip, if we already have an error in checkpoint. */
+ if (is_set_ckpt_flags(sbi, CP_ERROR_FLAG))
+ return exist;
+
if (exist && type == DATA_GENERIC_ENHANCE_UPDATE) {
f2fs_err(sbi, "Inconsistent error blkaddr:%u, sit bitmap:%d",
blkaddr, exist);
diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
index 9a8153895d20..bea6ab9d846a 100644
--- a/fs/f2fs/extent_cache.c
+++ b/fs/f2fs/extent_cache.c
@@ -23,18 +23,26 @@ bool sanity_check_extent_cache(struct inode *inode)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
struct f2fs_inode_info *fi = F2FS_I(inode);
+ struct extent_tree *et = fi->extent_tree[EX_READ];
struct extent_info *ei;
- if (!fi->extent_tree[EX_READ])
+ if (!et)
+ return true;
+
+ ei = &et->largest;
+ if (!ei->len)
return true;
- ei = &fi->extent_tree[EX_READ]->largest;
+ /* Let's drop, if checkpoint got corrupted. */
+ if (is_set_ckpt_flags(sbi, CP_ERROR_FLAG)) {
+ ei->len = 0;
+ et->largest_updated = true;
+ return true;
+ }
- if (ei->len &&
- (!f2fs_is_valid_blkaddr(sbi, ei->blk,
- DATA_GENERIC_ENHANCE) ||
- !f2fs_is_valid_blkaddr(sbi, ei->blk + ei->len - 1,
- DATA_GENERIC_ENHANCE))) {
+ if (!f2fs_is_valid_blkaddr(sbi, ei->blk, DATA_GENERIC_ENHANCE) ||
+ !f2fs_is_valid_blkaddr(sbi, ei->blk + ei->len - 1,
+ DATA_GENERIC_ENHANCE)) {
set_sbi_flag(sbi, SBI_NEED_FSCK);
f2fs_warn(sbi, "%s: inode (ino=%lx) extent info [%u, %u, %u] is incorrect, run fsck to fix",
__func__, inode->i_ino,
--
2.40.0.577.gac1e443424-goog
1. extent_cache
- let's drop the largest extent_cache
2. invalidate_block
- don't show the warnings
Signed-off-by: Jaegeuk Kim <[email protected]>
---
Change log from v1:
- add one more case to skip the error message
fs/f2fs/checkpoint.c | 10 ++++++++++
fs/f2fs/extent_cache.c | 22 +++++++++++++++-------
2 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 448ecf5000b8..64b3860f50ee 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -152,6 +152,11 @@ static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr,
se = get_seg_entry(sbi, segno);
exist = f2fs_test_bit(offset, se->cur_valid_map);
+
+ /* skip data, if we already have an error in checkpoint. */
+ if (unlikely(f2fs_cp_error(sbi)))
+ return exist;
+
if (exist && type == DATA_GENERIC_ENHANCE_UPDATE) {
f2fs_err(sbi, "Inconsistent error blkaddr:%u, sit bitmap:%d",
blkaddr, exist);
@@ -202,6 +207,11 @@ bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
case DATA_GENERIC_ENHANCE_UPDATE:
if (unlikely(blkaddr >= MAX_BLKADDR(sbi) ||
blkaddr < MAIN_BLKADDR(sbi))) {
+
+ /* Skip to emit an error message. */
+ if (unlikely(f2fs_cp_error(sbi)))
+ return false;
+
f2fs_warn(sbi, "access invalid blkaddr:%u",
blkaddr);
set_sbi_flag(sbi, SBI_NEED_FSCK);
diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
index 9a8153895d20..bea6ab9d846a 100644
--- a/fs/f2fs/extent_cache.c
+++ b/fs/f2fs/extent_cache.c
@@ -23,18 +23,26 @@ bool sanity_check_extent_cache(struct inode *inode)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
struct f2fs_inode_info *fi = F2FS_I(inode);
+ struct extent_tree *et = fi->extent_tree[EX_READ];
struct extent_info *ei;
- if (!fi->extent_tree[EX_READ])
+ if (!et)
+ return true;
+
+ ei = &et->largest;
+ if (!ei->len)
return true;
- ei = &fi->extent_tree[EX_READ]->largest;
+ /* Let's drop, if checkpoint got corrupted. */
+ if (is_set_ckpt_flags(sbi, CP_ERROR_FLAG)) {
+ ei->len = 0;
+ et->largest_updated = true;
+ return true;
+ }
- if (ei->len &&
- (!f2fs_is_valid_blkaddr(sbi, ei->blk,
- DATA_GENERIC_ENHANCE) ||
- !f2fs_is_valid_blkaddr(sbi, ei->blk + ei->len - 1,
- DATA_GENERIC_ENHANCE))) {
+ if (!f2fs_is_valid_blkaddr(sbi, ei->blk, DATA_GENERIC_ENHANCE) ||
+ !f2fs_is_valid_blkaddr(sbi, ei->blk + ei->len - 1,
+ DATA_GENERIC_ENHANCE)) {
set_sbi_flag(sbi, SBI_NEED_FSCK);
f2fs_warn(sbi, "%s: inode (ino=%lx) extent info [%u, %u, %u] is incorrect, run fsck to fix",
__func__, inode->i_ino,
--
2.40.0.577.gac1e443424-goog
On 2023/4/13 0:17, Jaegeuk Kim wrote:
> 1. extent_cache
> - let's drop the largest extent_cache
> 2. invalidate_block
> - don't show the warnings
>
> Signed-off-by: Jaegeuk Kim <[email protected]>
> ---
>
> Change log from v1:
> - add one more case to skip the error message
>
> fs/f2fs/checkpoint.c | 10 ++++++++++
> fs/f2fs/extent_cache.c | 22 +++++++++++++++-------
> 2 files changed, 25 insertions(+), 7 deletions(-)
>
> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
> index 448ecf5000b8..64b3860f50ee 100644
> --- a/fs/f2fs/checkpoint.c
> +++ b/fs/f2fs/checkpoint.c
> @@ -152,6 +152,11 @@ static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr,
> se = get_seg_entry(sbi, segno);
>
> exist = f2fs_test_bit(offset, se->cur_valid_map);
> +
> + /* skip data, if we already have an error in checkpoint. */
> + if (unlikely(f2fs_cp_error(sbi)))
> + return exist;
> +
> if (exist && type == DATA_GENERIC_ENHANCE_UPDATE) {
> f2fs_err(sbi, "Inconsistent error blkaddr:%u, sit bitmap:%d",
> blkaddr, exist);
> @@ -202,6 +207,11 @@ bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
> case DATA_GENERIC_ENHANCE_UPDATE:
> if (unlikely(blkaddr >= MAX_BLKADDR(sbi) ||
> blkaddr < MAIN_BLKADDR(sbi))) {
> +
> + /* Skip to emit an error message. */
> + if (unlikely(f2fs_cp_error(sbi)))
> + return false;
> +
> f2fs_warn(sbi, "access invalid blkaddr:%u",
> blkaddr);
> set_sbi_flag(sbi, SBI_NEED_FSCK);
> diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
> index 9a8153895d20..bea6ab9d846a 100644
> --- a/fs/f2fs/extent_cache.c
> +++ b/fs/f2fs/extent_cache.c
> @@ -23,18 +23,26 @@ bool sanity_check_extent_cache(struct inode *inode)
> {
> struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
> struct f2fs_inode_info *fi = F2FS_I(inode);
> + struct extent_tree *et = fi->extent_tree[EX_READ];
> struct extent_info *ei;
>
> - if (!fi->extent_tree[EX_READ])
> + if (!et)
> + return true;
> +
> + ei = &et->largest;
> + if (!ei->len)
> return true;
>
> - ei = &fi->extent_tree[EX_READ]->largest;
> + /* Let's drop, if checkpoint got corrupted. */
> + if (is_set_ckpt_flags(sbi, CP_ERROR_FLAG)) {
> + ei->len = 0;
> + et->largest_updated = true;
Thsi field indicates whether it is needed to update largest extent into
inode page, since cp_error is unrecoverable, it seems we don't needed to
update it.
Thanks,
> + return true;
> + }
>
> - if (ei->len &&
> - (!f2fs_is_valid_blkaddr(sbi, ei->blk,
> - DATA_GENERIC_ENHANCE) ||
> - !f2fs_is_valid_blkaddr(sbi, ei->blk + ei->len - 1,
> - DATA_GENERIC_ENHANCE))) {
> + if (!f2fs_is_valid_blkaddr(sbi, ei->blk, DATA_GENERIC_ENHANCE) ||
> + !f2fs_is_valid_blkaddr(sbi, ei->blk + ei->len - 1,
> + DATA_GENERIC_ENHANCE)) {
> set_sbi_flag(sbi, SBI_NEED_FSCK);
> f2fs_warn(sbi, "%s: inode (ino=%lx) extent info [%u, %u, %u] is incorrect, run fsck to fix",
> __func__, inode->i_ino,
On 04/13, Chao Yu wrote:
> On 2023/4/13 0:17, Jaegeuk Kim wrote:
> > 1. extent_cache
> > - let's drop the largest extent_cache
> > 2. invalidate_block
> > - don't show the warnings
> >
> > Signed-off-by: Jaegeuk Kim <[email protected]>
> > ---
> >
> > Change log from v1:
> > - add one more case to skip the error message
> >
> > fs/f2fs/checkpoint.c | 10 ++++++++++
> > fs/f2fs/extent_cache.c | 22 +++++++++++++++-------
> > 2 files changed, 25 insertions(+), 7 deletions(-)
> >
> > diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
> > index 448ecf5000b8..64b3860f50ee 100644
> > --- a/fs/f2fs/checkpoint.c
> > +++ b/fs/f2fs/checkpoint.c
> > @@ -152,6 +152,11 @@ static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr,
> > se = get_seg_entry(sbi, segno);
> > exist = f2fs_test_bit(offset, se->cur_valid_map);
> > +
> > + /* skip data, if we already have an error in checkpoint. */
> > + if (unlikely(f2fs_cp_error(sbi)))
> > + return exist;
> > +
> > if (exist && type == DATA_GENERIC_ENHANCE_UPDATE) {
> > f2fs_err(sbi, "Inconsistent error blkaddr:%u, sit bitmap:%d",
> > blkaddr, exist);
> > @@ -202,6 +207,11 @@ bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
> > case DATA_GENERIC_ENHANCE_UPDATE:
> > if (unlikely(blkaddr >= MAX_BLKADDR(sbi) ||
> > blkaddr < MAIN_BLKADDR(sbi))) {
> > +
> > + /* Skip to emit an error message. */
> > + if (unlikely(f2fs_cp_error(sbi)))
> > + return false;
> > +
> > f2fs_warn(sbi, "access invalid blkaddr:%u",
> > blkaddr);
> > set_sbi_flag(sbi, SBI_NEED_FSCK);
> > diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
> > index 9a8153895d20..bea6ab9d846a 100644
> > --- a/fs/f2fs/extent_cache.c
> > +++ b/fs/f2fs/extent_cache.c
> > @@ -23,18 +23,26 @@ bool sanity_check_extent_cache(struct inode *inode)
> > {
> > struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
> > struct f2fs_inode_info *fi = F2FS_I(inode);
> > + struct extent_tree *et = fi->extent_tree[EX_READ];
> > struct extent_info *ei;
> > - if (!fi->extent_tree[EX_READ])
> > + if (!et)
> > + return true;
> > +
> > + ei = &et->largest;
> > + if (!ei->len)
> > return true;
> > - ei = &fi->extent_tree[EX_READ]->largest;
> > + /* Let's drop, if checkpoint got corrupted. */
> > + if (is_set_ckpt_flags(sbi, CP_ERROR_FLAG)) {
> > + ei->len = 0;
> > + et->largest_updated = true;
>
> Thsi field indicates whether it is needed to update largest extent into
> inode page, since cp_error is unrecoverable, it seems we don't needed to
> update it.
Intention is to avoid any assumption like that, but sync the same logic when
updating this.
>
> Thanks,
>
> > + return true;
> > + }
> > - if (ei->len &&
> > - (!f2fs_is_valid_blkaddr(sbi, ei->blk,
> > - DATA_GENERIC_ENHANCE) ||
> > - !f2fs_is_valid_blkaddr(sbi, ei->blk + ei->len - 1,
> > - DATA_GENERIC_ENHANCE))) {
> > + if (!f2fs_is_valid_blkaddr(sbi, ei->blk, DATA_GENERIC_ENHANCE) ||
> > + !f2fs_is_valid_blkaddr(sbi, ei->blk + ei->len - 1,
> > + DATA_GENERIC_ENHANCE)) {
> > set_sbi_flag(sbi, SBI_NEED_FSCK);
> > f2fs_warn(sbi, "%s: inode (ino=%lx) extent info [%u, %u, %u] is incorrect, run fsck to fix",
> > __func__, inode->i_ino,
1. extent_cache
- let's drop the largest extent_cache
2. invalidate_block
- don't show the warnings
Signed-off-by: Jaegeuk Kim <[email protected]>
---
change log from v1:
- cover f2fs_read_multi_pages
fs/f2fs/checkpoint.c | 10 ++++++++++
fs/f2fs/data.c | 4 ++++
fs/f2fs/extent_cache.c | 22 +++++++++++++++-------
3 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 448ecf5000b8..64b3860f50ee 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -152,6 +152,11 @@ static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr,
se = get_seg_entry(sbi, segno);
exist = f2fs_test_bit(offset, se->cur_valid_map);
+
+ /* skip data, if we already have an error in checkpoint. */
+ if (unlikely(f2fs_cp_error(sbi)))
+ return exist;
+
if (exist && type == DATA_GENERIC_ENHANCE_UPDATE) {
f2fs_err(sbi, "Inconsistent error blkaddr:%u, sit bitmap:%d",
blkaddr, exist);
@@ -202,6 +207,11 @@ bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
case DATA_GENERIC_ENHANCE_UPDATE:
if (unlikely(blkaddr >= MAX_BLKADDR(sbi) ||
blkaddr < MAIN_BLKADDR(sbi))) {
+
+ /* Skip to emit an error message. */
+ if (unlikely(f2fs_cp_error(sbi)))
+ return false;
+
f2fs_warn(sbi, "access invalid blkaddr:%u",
blkaddr);
set_sbi_flag(sbi, SBI_NEED_FSCK);
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index f21e3aaa2474..8df225014304 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2237,6 +2237,10 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
if (ret)
goto out;
+ if (unlikely(f2fs_cp_error(sbi))) {
+ ret = -EIO;
+ goto out_put_dnode;
+ }
f2fs_bug_on(sbi, dn.data_blkaddr != COMPRESS_ADDR);
skip_reading_dnode:
diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
index 9a8153895d20..bea6ab9d846a 100644
--- a/fs/f2fs/extent_cache.c
+++ b/fs/f2fs/extent_cache.c
@@ -23,18 +23,26 @@ bool sanity_check_extent_cache(struct inode *inode)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
struct f2fs_inode_info *fi = F2FS_I(inode);
+ struct extent_tree *et = fi->extent_tree[EX_READ];
struct extent_info *ei;
- if (!fi->extent_tree[EX_READ])
+ if (!et)
+ return true;
+
+ ei = &et->largest;
+ if (!ei->len)
return true;
- ei = &fi->extent_tree[EX_READ]->largest;
+ /* Let's drop, if checkpoint got corrupted. */
+ if (is_set_ckpt_flags(sbi, CP_ERROR_FLAG)) {
+ ei->len = 0;
+ et->largest_updated = true;
+ return true;
+ }
- if (ei->len &&
- (!f2fs_is_valid_blkaddr(sbi, ei->blk,
- DATA_GENERIC_ENHANCE) ||
- !f2fs_is_valid_blkaddr(sbi, ei->blk + ei->len - 1,
- DATA_GENERIC_ENHANCE))) {
+ if (!f2fs_is_valid_blkaddr(sbi, ei->blk, DATA_GENERIC_ENHANCE) ||
+ !f2fs_is_valid_blkaddr(sbi, ei->blk + ei->len - 1,
+ DATA_GENERIC_ENHANCE)) {
set_sbi_flag(sbi, SBI_NEED_FSCK);
f2fs_warn(sbi, "%s: inode (ino=%lx) extent info [%u, %u, %u] is incorrect, run fsck to fix",
__func__, inode->i_ino,
--
2.40.0.634.g4ca3ef3211-goog
On 2023/4/13 23:52, Jaegeuk Kim wrote:
> On 04/13, Chao Yu wrote:
>> On 2023/4/13 0:17, Jaegeuk Kim wrote:
>>> 1. extent_cache
>>> - let's drop the largest extent_cache
>>> 2. invalidate_block
>>> - don't show the warnings
>>>
>>> Signed-off-by: Jaegeuk Kim <[email protected]>
>>> ---
>>>
>>> Change log from v1:
>>> - add one more case to skip the error message
>>>
>>> fs/f2fs/checkpoint.c | 10 ++++++++++
>>> fs/f2fs/extent_cache.c | 22 +++++++++++++++-------
>>> 2 files changed, 25 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
>>> index 448ecf5000b8..64b3860f50ee 100644
>>> --- a/fs/f2fs/checkpoint.c
>>> +++ b/fs/f2fs/checkpoint.c
>>> @@ -152,6 +152,11 @@ static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr,
>>> se = get_seg_entry(sbi, segno);
>>> exist = f2fs_test_bit(offset, se->cur_valid_map);
>>> +
>>> + /* skip data, if we already have an error in checkpoint. */
>>> + if (unlikely(f2fs_cp_error(sbi)))
>>> + return exist;
>>> +
>>> if (exist && type == DATA_GENERIC_ENHANCE_UPDATE) {
>>> f2fs_err(sbi, "Inconsistent error blkaddr:%u, sit bitmap:%d",
>>> blkaddr, exist);
>>> @@ -202,6 +207,11 @@ bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
>>> case DATA_GENERIC_ENHANCE_UPDATE:
>>> if (unlikely(blkaddr >= MAX_BLKADDR(sbi) ||
>>> blkaddr < MAIN_BLKADDR(sbi))) {
>>> +
>>> + /* Skip to emit an error message. */
>>> + if (unlikely(f2fs_cp_error(sbi)))
>>> + return false;
>>> +
>>> f2fs_warn(sbi, "access invalid blkaddr:%u",
>>> blkaddr);
>>> set_sbi_flag(sbi, SBI_NEED_FSCK);
>>> diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
>>> index 9a8153895d20..bea6ab9d846a 100644
>>> --- a/fs/f2fs/extent_cache.c
>>> +++ b/fs/f2fs/extent_cache.c
>>> @@ -23,18 +23,26 @@ bool sanity_check_extent_cache(struct inode *inode)
>>> {
>>> struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
>>> struct f2fs_inode_info *fi = F2FS_I(inode);
>>> + struct extent_tree *et = fi->extent_tree[EX_READ];
>>> struct extent_info *ei;
>>> - if (!fi->extent_tree[EX_READ])
>>> + if (!et)
>>> + return true;
>>> +
>>> + ei = &et->largest;
>>> + if (!ei->len)
>>> return true;
>>> - ei = &fi->extent_tree[EX_READ]->largest;
>>> + /* Let's drop, if checkpoint got corrupted. */
>>> + if (is_set_ckpt_flags(sbi, CP_ERROR_FLAG)) {
>>> + ei->len = 0;
>>> + et->largest_updated = true;
>>
>> Thsi field indicates whether it is needed to update largest extent into
>> inode page, since cp_error is unrecoverable, it seems we don't needed to
>> update it.
>
> Intention is to avoid any assumption like that, but sync the same logic when
> updating this.
Sure, fine to me.
Reviewed-by: Chao Yu <[email protected]>
Thanks,
>
>>
>> Thanks,
>>
>>> + return true;
>>> + }
>>> - if (ei->len &&
>>> - (!f2fs_is_valid_blkaddr(sbi, ei->blk,
>>> - DATA_GENERIC_ENHANCE) ||
>>> - !f2fs_is_valid_blkaddr(sbi, ei->blk + ei->len - 1,
>>> - DATA_GENERIC_ENHANCE))) {
>>> + if (!f2fs_is_valid_blkaddr(sbi, ei->blk, DATA_GENERIC_ENHANCE) ||
>>> + !f2fs_is_valid_blkaddr(sbi, ei->blk + ei->len - 1,
>>> + DATA_GENERIC_ENHANCE)) {
>>> set_sbi_flag(sbi, SBI_NEED_FSCK);
>>> f2fs_warn(sbi, "%s: inode (ino=%lx) extent info [%u, %u, %u] is incorrect, run fsck to fix",
>>> __func__, inode->i_ino,
On 2023/4/14 6:57, Jaegeuk Kim wrote:
> 1. extent_cache
> - let's drop the largest extent_cache
> 2. invalidate_block
> - don't show the warnings
>
> Signed-off-by: Jaegeuk Kim <[email protected]>
Oh, just notice v3.
Reviewed-by: Chao Yu <[email protected]>
Thanks,