fsck.f2fs: support large sector size
authorChao Yu <chao2.yu@samsung.com>
Thu, 5 Feb 2015 09:38:09 +0000 (17:38 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 6 Feb 2015 02:42:46 +0000 (18:42 -0800)
Since f2fs support large sector size in commit 55cf9cb63f0e "f2fs: support large
sector size", block device with sector size of 512/1024/2048/4096 bytes can be
supported.

But fsck.f2fs still use default F2FS_LOG_SECTOR_SIZE/F2FS_LOG_SECTORS_PER_BLOCK to
verify related data in f2fs image, it's wrong, let's fix this issue in this patch.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fsck/mount.c
include/f2fs_fs.h

index 73eba6b..6d96db8 100644 (file)
@@ -221,12 +221,15 @@ int sanity_check_raw_super(struct f2fs_super_block *raw_super)
                return -1;
        }
 
-       if (F2FS_LOG_SECTOR_SIZE != le32_to_cpu(raw_super->log_sectorsize)) {
+       if (le32_to_cpu(raw_super->log_sectorsize) > F2FS_MAX_LOG_SECTOR_SIZE ||
+               le32_to_cpu(raw_super->log_sectorsize) <
+                                               F2FS_MIN_LOG_SECTOR_SIZE) {
                return -1;
        }
 
-       if (F2FS_LOG_SECTORS_PER_BLOCK !=
-                               le32_to_cpu(raw_super->log_sectors_per_block)) {
+       if (le32_to_cpu(raw_super->log_sectors_per_block) +
+                               le32_to_cpu(raw_super->log_sectorsize) !=
+                                               F2FS_MAX_LOG_SECTOR_SIZE) {
                return -1;
        }
 
index e7fb8fa..6ce58c2 100644 (file)
@@ -289,8 +289,8 @@ enum {
  * Copied from include/linux/f2fs_sb.h
  */
 #define F2FS_SUPER_OFFSET              1024    /* byte-size offset */
-#define F2FS_LOG_SECTOR_SIZE           9       /* 9 bits for 512 byte */
-#define F2FS_LOG_SECTORS_PER_BLOCK     3       /* 4KB: F2FS_BLKSIZE */
+#define F2FS_MIN_LOG_SECTOR_SIZE       9       /* 9 bits for 512 bytes */
+#define F2FS_MAX_LOG_SECTOR_SIZE       12      /* 12 bits for 4096 bytes */
 #define F2FS_BLKSIZE                   4096    /* support only 4KB block */
 #define F2FS_MAX_EXTENSION             64      /* # of extension entries */
 #define F2FS_BLK_ALIGN(x)      (((x) + F2FS_BLKSIZE - 1) / F2FS_BLKSIZE)