linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] f2fs: allow to recover node blocks given updated checkpoint
@ 2018-01-20  4:26 Jaegeuk Kim
  2018-01-20  4:26 ` [PATCH 2/2] f2fs: recover some i_inline flags Jaegeuk Kim
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Jaegeuk Kim @ 2018-01-20  4:26 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim

If fsck.f2fs changes crc, we have no way to recover some inode blocks by roll-
forward recovery. Let's relax the condition to recover them.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/node.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
index 0ee3e5ff49a3..15280eeb24ea 100644
--- a/fs/f2fs/node.h
+++ b/fs/f2fs/node.h
@@ -305,10 +305,11 @@ static inline bool is_recoverable_dnode(struct page *page)
 	struct f2fs_checkpoint *ckpt = F2FS_CKPT(F2FS_P_SB(page));
 	__u64 cp_ver = cur_cp_version(ckpt);
 
-	if (__is_set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG))
+	if (__is_set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG)) {
 		cp_ver |= (cur_cp_crc(ckpt) << 32);
-
-	return cp_ver == cpver_of_node(page);
+		return cp_ver == cpver_of_node(page);
+	}
+	return (cp_ver << 32) == (cpver_of_node(page) << 32);
 }
 
 /*
-- 
2.15.0.531.g2ccb3012c9-goog

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

* [PATCH 2/2] f2fs: recover some i_inline flags
  2018-01-20  4:26 [PATCH 1/2] f2fs: allow to recover node blocks given updated checkpoint Jaegeuk Kim
@ 2018-01-20  4:26 ` Jaegeuk Kim
  2018-01-20  9:33   ` [f2fs-dev] " Chao Yu
  2018-01-20 22:06   ` [PATCH 2/2 v2] " Jaegeuk Kim
  2018-01-20  9:29 ` [f2fs-dev] [PATCH 1/2] f2fs: allow to recover node blocks given updated checkpoint Chao Yu
  2018-01-20 22:05 ` [PATCH 1/2 v2] " Jaegeuk Kim
  2 siblings, 2 replies; 8+ messages in thread
From: Jaegeuk Kim @ 2018-01-20  4:26 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim

This fixes lost i_inline flags during roll-forward.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/recovery.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index cbeef73bc4dd..2354f1e05e19 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -211,6 +211,15 @@ static void recover_inode(struct inode *inode, struct page *page)
 
 	F2FS_I(inode)->i_advise = raw->i_advise;
 
+	if (raw->i_inline & F2FS_PIN_FILE)
+		set_inode_flag(inode, FI_PIN_FILE);
+	if (raw->i_inline & F2FS_DATA_EXIST)
+		set_inode_flag(inode, FI_DATA_EXIST);
+	else
+		clear_inode_flag(inode, FI_DATA_EXIST);
+	if (!(raw->i_inline & F2FS_INLINE_DOTS))
+		clear_inode_flag(inode, FI_INLINE_DOTS);
+
 	if (file_enc_name(inode))
 		name = "<encrypted>";
 	else
-- 
2.15.0.531.g2ccb3012c9-goog

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

* Re: [f2fs-dev] [PATCH 1/2] f2fs: allow to recover node blocks given updated checkpoint
  2018-01-20  4:26 [PATCH 1/2] f2fs: allow to recover node blocks given updated checkpoint Jaegeuk Kim
  2018-01-20  4:26 ` [PATCH 2/2] f2fs: recover some i_inline flags Jaegeuk Kim
@ 2018-01-20  9:29 ` Chao Yu
  2018-01-20 22:05 ` [PATCH 1/2 v2] " Jaegeuk Kim
  2 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2018-01-20  9:29 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-f2fs-devel

On 2018/1/20 12:26, Jaegeuk Kim wrote:
> If fsck.f2fs changes crc, we have no way to recover some inode blocks by roll-
> forward recovery. Let's relax the condition to recover them.

As this is fsck case only, what about writing checkpoint with special flag
for such case, and relax the condition if flag was set, so, for normal case,
it can avoid recovering obsolete data.

Thanks,

> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/node.h | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
> index 0ee3e5ff49a3..15280eeb24ea 100644
> --- a/fs/f2fs/node.h
> +++ b/fs/f2fs/node.h
> @@ -305,10 +305,11 @@ static inline bool is_recoverable_dnode(struct page *page)
>  	struct f2fs_checkpoint *ckpt = F2FS_CKPT(F2FS_P_SB(page));
>  	__u64 cp_ver = cur_cp_version(ckpt);
>  
> -	if (__is_set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG))
> +	if (__is_set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG)) {
>  		cp_ver |= (cur_cp_crc(ckpt) << 32);
> -
> -	return cp_ver == cpver_of_node(page);
> +		return cp_ver == cpver_of_node(page);
> +	}
> +	return (cp_ver << 32) == (cpver_of_node(page) << 32);
>  }
>  
>  /*
> 

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

* Re: [f2fs-dev] [PATCH 2/2] f2fs: recover some i_inline flags
  2018-01-20  4:26 ` [PATCH 2/2] f2fs: recover some i_inline flags Jaegeuk Kim
@ 2018-01-20  9:33   ` Chao Yu
  2018-01-20 22:06   ` [PATCH 2/2 v2] " Jaegeuk Kim
  1 sibling, 0 replies; 8+ messages in thread
From: Chao Yu @ 2018-01-20  9:33 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-f2fs-devel

On 2018/1/20 12:26, Jaegeuk Kim wrote:
> This fixes lost i_inline flags during roll-forward.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/recovery.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
> index cbeef73bc4dd..2354f1e05e19 100644
> --- a/fs/f2fs/recovery.c
> +++ b/fs/f2fs/recovery.c
> @@ -211,6 +211,15 @@ static void recover_inode(struct inode *inode, struct page *page)
>  
>  	F2FS_I(inode)->i_advise = raw->i_advise;

How about adding recover_inline_flags() including below changes?

>  
> +	if (raw->i_inline & F2FS_PIN_FILE)
> +		set_inode_flag(inode, FI_PIN_FILE);

else
	clear_inode_flag(inode, FI_PIN_FILE); ?

Thanks,

> +	if (raw->i_inline & F2FS_DATA_EXIST)
> +		set_inode_flag(inode, FI_DATA_EXIST);
> +	else
> +		clear_inode_flag(inode, FI_DATA_EXIST);
> +	if (!(raw->i_inline & F2FS_INLINE_DOTS))
> +		clear_inode_flag(inode, FI_INLINE_DOTS);
> +
>  	if (file_enc_name(inode))
>  		name = "<encrypted>";
>  	else
> 

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

* Re: [PATCH 1/2 v2] f2fs: allow to recover node blocks given updated checkpoint
  2018-01-20  4:26 [PATCH 1/2] f2fs: allow to recover node blocks given updated checkpoint Jaegeuk Kim
  2018-01-20  4:26 ` [PATCH 2/2] f2fs: recover some i_inline flags Jaegeuk Kim
  2018-01-20  9:29 ` [f2fs-dev] [PATCH 1/2] f2fs: allow to recover node blocks given updated checkpoint Chao Yu
@ 2018-01-20 22:05 ` Jaegeuk Kim
  2018-01-21  2:41   ` [f2fs-dev] " Chao Yu
  2 siblings, 1 reply; 8+ messages in thread
From: Jaegeuk Kim @ 2018-01-20 22:05 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel

If fsck.f2fs changes crc, we have no way to recover some inode blocks by roll-
forward recovery. Let's relax the condition to recover them.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---

Change log from v1:
 - add a new checkpoint flag to handle this

 fs/f2fs/checkpoint.c    | 1 +
 fs/f2fs/node.h          | 4 ++++
 include/linux/f2fs_fs.h | 1 +
 3 files changed, 6 insertions(+)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 9c7596f7daae..512dca8abc7d 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -1157,6 +1157,7 @@ static void update_ckpt_flags(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 
 	/* set this flag to activate crc|cp_ver for recovery */
 	__set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG);
+	__clear_ckpt_flags(ckpt, CP_NOCRC_RECOVERY_FLAG);
 
 	spin_unlock_irqrestore(&sbi->cp_lock, flags);
 }
diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
index 0ee3e5ff49a3..081ef0d672bf 100644
--- a/fs/f2fs/node.h
+++ b/fs/f2fs/node.h
@@ -305,6 +305,10 @@ static inline bool is_recoverable_dnode(struct page *page)
 	struct f2fs_checkpoint *ckpt = F2FS_CKPT(F2FS_P_SB(page));
 	__u64 cp_ver = cur_cp_version(ckpt);
 
+	/* Don't care crc part, if fsck.f2fs sets it. */
+	if (__is_set_ckpt_flags(ckpt, CP_NOCRC_RECOVERY_FLAG))
+		return (cp_ver << 32) == (cpver_of_node(page) << 32);
+
 	if (__is_set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG))
 		cp_ver |= (cur_cp_crc(ckpt) << 32);
 
diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
index cfb522e6affc..6eed677b6d9a 100644
--- a/include/linux/f2fs_fs.h
+++ b/include/linux/f2fs_fs.h
@@ -117,6 +117,7 @@ struct f2fs_super_block {
 /*
  * For checkpoint
  */
+#define CP_NOCRC_RECOVERY_FLAG	0x00000200
 #define CP_TRIMMED_FLAG		0x00000100
 #define CP_NAT_BITS_FLAG	0x00000080
 #define CP_CRC_RECOVERY_FLAG	0x00000040
-- 
2.15.0.531.g2ccb3012c9-goog

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

* Re: [PATCH 2/2 v2] f2fs: recover some i_inline flags
  2018-01-20  4:26 ` [PATCH 2/2] f2fs: recover some i_inline flags Jaegeuk Kim
  2018-01-20  9:33   ` [f2fs-dev] " Chao Yu
@ 2018-01-20 22:06   ` Jaegeuk Kim
  2018-01-21  2:42     ` [f2fs-dev] " Chao Yu
  1 sibling, 1 reply; 8+ messages in thread
From: Jaegeuk Kim @ 2018-01-20 22:06 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel

This fixes lost i_inline flags during roll-forward.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---

Change log from v1:
 - add a new function to recover the flag
 - fix missing pin_file unset

 fs/f2fs/recovery.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index cbeef73bc4dd..337f3363f48f 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -195,6 +195,20 @@ static int recover_dentry(struct inode *inode, struct page *ipage,
 	return err;
 }
 
+static void recover_inline_flags(struct inode *inode, struct f2fs_inode *ri)
+{
+	if (ri->i_inline & F2FS_PIN_FILE)
+		set_inode_flag(inode, FI_PIN_FILE);
+	else
+		clear_inode_flag(inode, FI_PIN_FILE);
+	if (ri->i_inline & F2FS_DATA_EXIST)
+		set_inode_flag(inode, FI_DATA_EXIST);
+	else
+		clear_inode_flag(inode, FI_DATA_EXIST);
+	if (!(ri->i_inline & F2FS_INLINE_DOTS))
+		clear_inode_flag(inode, FI_INLINE_DOTS);
+}
+
 static void recover_inode(struct inode *inode, struct page *page)
 {
 	struct f2fs_inode *raw = F2FS_INODE(page);
@@ -211,13 +225,16 @@ static void recover_inode(struct inode *inode, struct page *page)
 
 	F2FS_I(inode)->i_advise = raw->i_advise;
 
+	recover_inline_flags(inode, raw);
+
 	if (file_enc_name(inode))
 		name = "<encrypted>";
 	else
 		name = F2FS_INODE(page)->i_name;
 
-	f2fs_msg(inode->i_sb, KERN_NOTICE, "recover_inode: ino = %x, name = %s",
-			ino_of_node(page), name);
+	f2fs_msg(inode->i_sb, KERN_NOTICE,
+		"recover_inode: ino = %x, name = %s, inline = %x",
+			ino_of_node(page), name, raw->i_inline);
 }
 
 static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head,
-- 
2.15.0.531.g2ccb3012c9-goog

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

* Re: [f2fs-dev] [PATCH 1/2 v2] f2fs: allow to recover node blocks given updated checkpoint
  2018-01-20 22:05 ` [PATCH 1/2 v2] " Jaegeuk Kim
@ 2018-01-21  2:41   ` Chao Yu
  0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2018-01-21  2:41 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-f2fs-devel

On 2018/1/21 6:05, Jaegeuk Kim wrote:
> If fsck.f2fs changes crc, we have no way to recover some inode blocks by roll-
> forward recovery. Let's relax the condition to recover them.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [f2fs-dev] [PATCH 2/2 v2] f2fs: recover some i_inline flags
  2018-01-20 22:06   ` [PATCH 2/2 v2] " Jaegeuk Kim
@ 2018-01-21  2:42     ` Chao Yu
  0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2018-01-21  2:42 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-f2fs-devel

On 2018/1/21 6:06, Jaegeuk Kim wrote:
> This fixes lost i_inline flags during roll-forward.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

end of thread, other threads:[~2018-01-21  2:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-20  4:26 [PATCH 1/2] f2fs: allow to recover node blocks given updated checkpoint Jaegeuk Kim
2018-01-20  4:26 ` [PATCH 2/2] f2fs: recover some i_inline flags Jaegeuk Kim
2018-01-20  9:33   ` [f2fs-dev] " Chao Yu
2018-01-20 22:06   ` [PATCH 2/2 v2] " Jaegeuk Kim
2018-01-21  2:42     ` [f2fs-dev] " Chao Yu
2018-01-20  9:29 ` [f2fs-dev] [PATCH 1/2] f2fs: allow to recover node blocks given updated checkpoint Chao Yu
2018-01-20 22:05 ` [PATCH 1/2 v2] " Jaegeuk Kim
2018-01-21  2:41   ` [f2fs-dev] " Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).