All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] f2fs: fix to check i_compr_blocks correctly
@ 2020-02-25 10:26 ` Chao Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2020-02-25 10:26 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, chao, Chao Yu

inode.i_blocks counts based on 512byte sector, we need to convert
to 4kb sized block count before comparing to i_compr_blocks.

In addition, add to print message when sanity check on inode
compression configs failed.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/f2fs/inode.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 156cc5ef3044..299611562f7e 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -291,13 +291,30 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page)
 			fi->i_flags & F2FS_COMPR_FL &&
 			F2FS_FITS_IN_INODE(ri, fi->i_extra_isize,
 						i_log_cluster_size)) {
-		if (ri->i_compress_algorithm >= COMPRESS_MAX)
+		if (ri->i_compress_algorithm >= COMPRESS_MAX) {
+			f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported "
+				"compress algorithm: %u, run fsck to fix",
+				  __func__, inode->i_ino,
+				  ri->i_compress_algorithm);
 			return false;
-		if (le64_to_cpu(ri->i_compr_blocks) > inode->i_blocks)
+		}
+		if (le64_to_cpu(ri->i_compr_blocks) >
+				SECTOR_TO_BLOCK(inode->i_blocks)) {
+			f2fs_warn(sbi, "%s: inode (ino=%lx) hash inconsistent "
+				"i_compr_blocks:%llu, i_blocks:%llu, run fsck to fix",
+				  __func__, inode->i_ino,
+				  le64_to_cpu(ri->i_compr_blocks),
+				  SECTOR_TO_BLOCK(inode->i_blocks));
 			return false;
+		}
 		if (ri->i_log_cluster_size < MIN_COMPRESS_LOG_SIZE ||
-			ri->i_log_cluster_size > MAX_COMPRESS_LOG_SIZE)
+			ri->i_log_cluster_size > MAX_COMPRESS_LOG_SIZE) {
+			f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported "
+				"log cluster size: %u, run fsck to fix",
+				  __func__, inode->i_ino,
+				  ri->i_log_cluster_size);
 			return false;
+		}
 	}
 
 	return true;
-- 
2.18.0.rc1


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

* [f2fs-dev] [PATCH] f2fs: fix to check i_compr_blocks correctly
@ 2020-02-25 10:26 ` Chao Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2020-02-25 10:26 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

inode.i_blocks counts based on 512byte sector, we need to convert
to 4kb sized block count before comparing to i_compr_blocks.

In addition, add to print message when sanity check on inode
compression configs failed.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/f2fs/inode.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 156cc5ef3044..299611562f7e 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -291,13 +291,30 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page)
 			fi->i_flags & F2FS_COMPR_FL &&
 			F2FS_FITS_IN_INODE(ri, fi->i_extra_isize,
 						i_log_cluster_size)) {
-		if (ri->i_compress_algorithm >= COMPRESS_MAX)
+		if (ri->i_compress_algorithm >= COMPRESS_MAX) {
+			f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported "
+				"compress algorithm: %u, run fsck to fix",
+				  __func__, inode->i_ino,
+				  ri->i_compress_algorithm);
 			return false;
-		if (le64_to_cpu(ri->i_compr_blocks) > inode->i_blocks)
+		}
+		if (le64_to_cpu(ri->i_compr_blocks) >
+				SECTOR_TO_BLOCK(inode->i_blocks)) {
+			f2fs_warn(sbi, "%s: inode (ino=%lx) hash inconsistent "
+				"i_compr_blocks:%llu, i_blocks:%llu, run fsck to fix",
+				  __func__, inode->i_ino,
+				  le64_to_cpu(ri->i_compr_blocks),
+				  SECTOR_TO_BLOCK(inode->i_blocks));
 			return false;
+		}
 		if (ri->i_log_cluster_size < MIN_COMPRESS_LOG_SIZE ||
-			ri->i_log_cluster_size > MAX_COMPRESS_LOG_SIZE)
+			ri->i_log_cluster_size > MAX_COMPRESS_LOG_SIZE) {
+			f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported "
+				"log cluster size: %u, run fsck to fix",
+				  __func__, inode->i_ino,
+				  ri->i_log_cluster_size);
 			return false;
+		}
 	}
 
 	return true;
-- 
2.18.0.rc1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [PATCH] f2fs: fix to check i_compr_blocks correctly
  2020-02-25 10:26 ` [f2fs-dev] " Chao Yu
@ 2020-03-10 15:26   ` Chao Yu
  -1 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2020-03-10 15:26 UTC (permalink / raw)
  To: Chao Yu, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel

Hi Jaegeuk,

On 2020-2-25 18:26, Chao Yu wrote:
> inode.i_blocks counts based on 512byte sector, we need to convert
> to 4kb sized block count before comparing to i_compr_blocks.
>
> In addition, add to print message when sanity check on inode
> compression configs failed.
>
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> ---
>  fs/f2fs/inode.c | 23 ++++++++++++++++++++---
>  1 file changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
> index 156cc5ef3044..299611562f7e 100644
> --- a/fs/f2fs/inode.c
> +++ b/fs/f2fs/inode.c
> @@ -291,13 +291,30 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page)
>  			fi->i_flags & F2FS_COMPR_FL &&
>  			F2FS_FITS_IN_INODE(ri, fi->i_extra_isize,
>  						i_log_cluster_size)) {
> -		if (ri->i_compress_algorithm >= COMPRESS_MAX)
> +		if (ri->i_compress_algorithm >= COMPRESS_MAX) {
> +			f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported "
> +				"compress algorithm: %u, run fsck to fix",
> +				  __func__, inode->i_ino,
> +				  ri->i_compress_algorithm);
>  			return false;
> -		if (le64_to_cpu(ri->i_compr_blocks) > inode->i_blocks)
> +		}
> +		if (le64_to_cpu(ri->i_compr_blocks) >
> +				SECTOR_TO_BLOCK(inode->i_blocks)) {
> +			f2fs_warn(sbi, "%s: inode (ino=%lx) hash inconsistent "

This is a typo: hash -> has

Could you please manually fix this in your tree?

Thanks

> +				"i_compr_blocks:%llu, i_blocks:%llu, run fsck to fix",
> +				  __func__, inode->i_ino,
> +				  le64_to_cpu(ri->i_compr_blocks),
> +				  SECTOR_TO_BLOCK(inode->i_blocks));
>  			return false;
> +		}
>  		if (ri->i_log_cluster_size < MIN_COMPRESS_LOG_SIZE ||
> -			ri->i_log_cluster_size > MAX_COMPRESS_LOG_SIZE)
> +			ri->i_log_cluster_size > MAX_COMPRESS_LOG_SIZE) {
> +			f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported "
> +				"log cluster size: %u, run fsck to fix",
> +				  __func__, inode->i_ino,
> +				  ri->i_log_cluster_size);
>  			return false;
> +		}
>  	}
>
>  	return true;
>

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

* Re: [f2fs-dev] [PATCH] f2fs: fix to check i_compr_blocks correctly
@ 2020-03-10 15:26   ` Chao Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2020-03-10 15:26 UTC (permalink / raw)
  To: Chao Yu, jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

Hi Jaegeuk,

On 2020-2-25 18:26, Chao Yu wrote:
> inode.i_blocks counts based on 512byte sector, we need to convert
> to 4kb sized block count before comparing to i_compr_blocks.
>
> In addition, add to print message when sanity check on inode
> compression configs failed.
>
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> ---
>  fs/f2fs/inode.c | 23 ++++++++++++++++++++---
>  1 file changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
> index 156cc5ef3044..299611562f7e 100644
> --- a/fs/f2fs/inode.c
> +++ b/fs/f2fs/inode.c
> @@ -291,13 +291,30 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page)
>  			fi->i_flags & F2FS_COMPR_FL &&
>  			F2FS_FITS_IN_INODE(ri, fi->i_extra_isize,
>  						i_log_cluster_size)) {
> -		if (ri->i_compress_algorithm >= COMPRESS_MAX)
> +		if (ri->i_compress_algorithm >= COMPRESS_MAX) {
> +			f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported "
> +				"compress algorithm: %u, run fsck to fix",
> +				  __func__, inode->i_ino,
> +				  ri->i_compress_algorithm);
>  			return false;
> -		if (le64_to_cpu(ri->i_compr_blocks) > inode->i_blocks)
> +		}
> +		if (le64_to_cpu(ri->i_compr_blocks) >
> +				SECTOR_TO_BLOCK(inode->i_blocks)) {
> +			f2fs_warn(sbi, "%s: inode (ino=%lx) hash inconsistent "

This is a typo: hash -> has

Could you please manually fix this in your tree?

Thanks

> +				"i_compr_blocks:%llu, i_blocks:%llu, run fsck to fix",
> +				  __func__, inode->i_ino,
> +				  le64_to_cpu(ri->i_compr_blocks),
> +				  SECTOR_TO_BLOCK(inode->i_blocks));
>  			return false;
> +		}
>  		if (ri->i_log_cluster_size < MIN_COMPRESS_LOG_SIZE ||
> -			ri->i_log_cluster_size > MAX_COMPRESS_LOG_SIZE)
> +			ri->i_log_cluster_size > MAX_COMPRESS_LOG_SIZE) {
> +			f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported "
> +				"log cluster size: %u, run fsck to fix",
> +				  __func__, inode->i_ino,
> +				  ri->i_log_cluster_size);
>  			return false;
> +		}
>  	}
>
>  	return true;
>


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [PATCH] f2fs: fix to check i_compr_blocks correctly
  2020-03-10 15:26   ` [f2fs-dev] " Chao Yu
@ 2020-03-10 16:18     ` Jaegeuk Kim
  -1 siblings, 0 replies; 6+ messages in thread
From: Jaegeuk Kim @ 2020-03-10 16:18 UTC (permalink / raw)
  To: Chao Yu; +Cc: Chao Yu, linux-f2fs-devel, linux-kernel

On 03/10, Chao Yu wrote:
> Hi Jaegeuk,
> 
> On 2020-2-25 18:26, Chao Yu wrote:
> > inode.i_blocks counts based on 512byte sector, we need to convert
> > to 4kb sized block count before comparing to i_compr_blocks.
> > 
> > In addition, add to print message when sanity check on inode
> > compression configs failed.
> > 
> > Signed-off-by: Chao Yu <yuchao0@huawei.com>
> > ---
> >  fs/f2fs/inode.c | 23 ++++++++++++++++++++---
> >  1 file changed, 20 insertions(+), 3 deletions(-)
> > 
> > diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
> > index 156cc5ef3044..299611562f7e 100644
> > --- a/fs/f2fs/inode.c
> > +++ b/fs/f2fs/inode.c
> > @@ -291,13 +291,30 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page)
> >  			fi->i_flags & F2FS_COMPR_FL &&
> >  			F2FS_FITS_IN_INODE(ri, fi->i_extra_isize,
> >  						i_log_cluster_size)) {
> > -		if (ri->i_compress_algorithm >= COMPRESS_MAX)
> > +		if (ri->i_compress_algorithm >= COMPRESS_MAX) {
> > +			f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported "
> > +				"compress algorithm: %u, run fsck to fix",
> > +				  __func__, inode->i_ino,
> > +				  ri->i_compress_algorithm);
> >  			return false;
> > -		if (le64_to_cpu(ri->i_compr_blocks) > inode->i_blocks)
> > +		}
> > +		if (le64_to_cpu(ri->i_compr_blocks) >
> > +				SECTOR_TO_BLOCK(inode->i_blocks)) {
> > +			f2fs_warn(sbi, "%s: inode (ino=%lx) hash inconsistent "
> 
> This is a typo: hash -> has
> 
> Could you please manually fix this in your tree?

Done.

> 
> Thanks
> 
> > +				"i_compr_blocks:%llu, i_blocks:%llu, run fsck to fix",
> > +				  __func__, inode->i_ino,
> > +				  le64_to_cpu(ri->i_compr_blocks),
> > +				  SECTOR_TO_BLOCK(inode->i_blocks));
> >  			return false;
> > +		}
> >  		if (ri->i_log_cluster_size < MIN_COMPRESS_LOG_SIZE ||
> > -			ri->i_log_cluster_size > MAX_COMPRESS_LOG_SIZE)
> > +			ri->i_log_cluster_size > MAX_COMPRESS_LOG_SIZE) {
> > +			f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported "
> > +				"log cluster size: %u, run fsck to fix",
> > +				  __func__, inode->i_ino,
> > +				  ri->i_log_cluster_size);
> >  			return false;
> > +		}
> >  	}
> > 
> >  	return true;
> > 

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

* Re: [f2fs-dev] [PATCH] f2fs: fix to check i_compr_blocks correctly
@ 2020-03-10 16:18     ` Jaegeuk Kim
  0 siblings, 0 replies; 6+ messages in thread
From: Jaegeuk Kim @ 2020-03-10 16:18 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel

On 03/10, Chao Yu wrote:
> Hi Jaegeuk,
> 
> On 2020-2-25 18:26, Chao Yu wrote:
> > inode.i_blocks counts based on 512byte sector, we need to convert
> > to 4kb sized block count before comparing to i_compr_blocks.
> > 
> > In addition, add to print message when sanity check on inode
> > compression configs failed.
> > 
> > Signed-off-by: Chao Yu <yuchao0@huawei.com>
> > ---
> >  fs/f2fs/inode.c | 23 ++++++++++++++++++++---
> >  1 file changed, 20 insertions(+), 3 deletions(-)
> > 
> > diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
> > index 156cc5ef3044..299611562f7e 100644
> > --- a/fs/f2fs/inode.c
> > +++ b/fs/f2fs/inode.c
> > @@ -291,13 +291,30 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page)
> >  			fi->i_flags & F2FS_COMPR_FL &&
> >  			F2FS_FITS_IN_INODE(ri, fi->i_extra_isize,
> >  						i_log_cluster_size)) {
> > -		if (ri->i_compress_algorithm >= COMPRESS_MAX)
> > +		if (ri->i_compress_algorithm >= COMPRESS_MAX) {
> > +			f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported "
> > +				"compress algorithm: %u, run fsck to fix",
> > +				  __func__, inode->i_ino,
> > +				  ri->i_compress_algorithm);
> >  			return false;
> > -		if (le64_to_cpu(ri->i_compr_blocks) > inode->i_blocks)
> > +		}
> > +		if (le64_to_cpu(ri->i_compr_blocks) >
> > +				SECTOR_TO_BLOCK(inode->i_blocks)) {
> > +			f2fs_warn(sbi, "%s: inode (ino=%lx) hash inconsistent "
> 
> This is a typo: hash -> has
> 
> Could you please manually fix this in your tree?

Done.

> 
> Thanks
> 
> > +				"i_compr_blocks:%llu, i_blocks:%llu, run fsck to fix",
> > +				  __func__, inode->i_ino,
> > +				  le64_to_cpu(ri->i_compr_blocks),
> > +				  SECTOR_TO_BLOCK(inode->i_blocks));
> >  			return false;
> > +		}
> >  		if (ri->i_log_cluster_size < MIN_COMPRESS_LOG_SIZE ||
> > -			ri->i_log_cluster_size > MAX_COMPRESS_LOG_SIZE)
> > +			ri->i_log_cluster_size > MAX_COMPRESS_LOG_SIZE) {
> > +			f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported "
> > +				"log cluster size: %u, run fsck to fix",
> > +				  __func__, inode->i_ino,
> > +				  ri->i_log_cluster_size);
> >  			return false;
> > +		}
> >  	}
> > 
> >  	return true;
> > 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2020-03-10 16:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-25 10:26 [PATCH] f2fs: fix to check i_compr_blocks correctly Chao Yu
2020-02-25 10:26 ` [f2fs-dev] " Chao Yu
2020-03-10 15:26 ` Chao Yu
2020-03-10 15:26   ` [f2fs-dev] " Chao Yu
2020-03-10 16:18   ` Jaegeuk Kim
2020-03-10 16:18     ` [f2fs-dev] " Jaegeuk Kim

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.