aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2014-09-15 06:01:10 -0400
committerJaegeuk Kim <jaegeuk@kernel.org>2014-09-23 14:10:20 -0400
commit55cf9cb63f0e5439f208d78ed944de9a8df65011 (patch)
tree2b15d8458854f0da153d958afe4a339f43bbd996 /fs
parent09db6a2ef8d9ca6da71b5de56097e8b769bef299 (diff)
f2fs: support large sector size
Block size in f2fs is 4096 bytes, so theoretically, f2fs can support 4096 bytes sector device at maximum. But now f2fs only support 512 bytes size sector, so block device such as zRAM which uses page cache as its block storage space will not be mounted successfully as mismatch between sector size of zRAM and sector size of f2fs supported. In this patch we support large sector size in f2fs, so block device with sector size of 512/1024/2048/4096 bytes can be supported in f2fs. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/f2fs/data.c2
-rw-r--r--fs/f2fs/segment.c4
-rw-r--r--fs/f2fs/segment.h10
-rw-r--r--fs/f2fs/super.c20
4 files changed, 22 insertions, 14 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index aaf22a912044..13ab72084913 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -85,7 +85,7 @@ static struct bio *__bio_alloc(struct f2fs_sb_info *sbi, block_t blk_addr,
85 bio = bio_alloc(GFP_NOIO, npages); 85 bio = bio_alloc(GFP_NOIO, npages);
86 86
87 bio->bi_bdev = sbi->sb->s_bdev; 87 bio->bi_bdev = sbi->sb->s_bdev;
88 bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr); 88 bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(blk_addr);
89 bio->bi_end_io = is_read ? f2fs_read_end_io : f2fs_write_end_io; 89 bio->bi_end_io = is_read ? f2fs_read_end_io : f2fs_write_end_io;
90 bio->bi_private = sbi; 90 bio->bi_private = sbi;
91 91
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 4ea53aab786d..24b768ae39c4 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -370,8 +370,8 @@ static void locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno)
370static int f2fs_issue_discard(struct f2fs_sb_info *sbi, 370static int f2fs_issue_discard(struct f2fs_sb_info *sbi,
371 block_t blkstart, block_t blklen) 371 block_t blkstart, block_t blklen)
372{ 372{
373 sector_t start = SECTOR_FROM_BLOCK(sbi, blkstart); 373 sector_t start = SECTOR_FROM_BLOCK(blkstart);
374 sector_t len = SECTOR_FROM_BLOCK(sbi, blklen); 374 sector_t len = SECTOR_FROM_BLOCK(blklen);
375 trace_f2fs_issue_discard(sbi->sb, blkstart, blklen); 375 trace_f2fs_issue_discard(sbi->sb, blkstart, blklen);
376 return blkdev_issue_discard(sbi->sb->s_bdev, start, len, GFP_NOFS, 0); 376 return blkdev_issue_discard(sbi->sb->s_bdev, start, len, GFP_NOFS, 0);
377} 377}
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index 848ac519958f..032c0905a12b 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -89,10 +89,10 @@
89#define TOTAL_SECS(sbi) (sbi->total_sections) 89#define TOTAL_SECS(sbi) (sbi->total_sections)
90#define TOTAL_BLKS(sbi) (SM_I(sbi)->segment_count << sbi->log_blocks_per_seg) 90#define TOTAL_BLKS(sbi) (SM_I(sbi)->segment_count << sbi->log_blocks_per_seg)
91 91
92#define SECTOR_FROM_BLOCK(sbi, blk_addr) \ 92#define SECTOR_FROM_BLOCK(blk_addr) \
93 (((sector_t)blk_addr) << (sbi)->log_sectors_per_block) 93 (((sector_t)blk_addr) << F2FS_LOG_SECTORS_PER_BLOCK)
94#define SECTOR_TO_BLOCK(sbi, sectors) \ 94#define SECTOR_TO_BLOCK(sectors) \
95 (sectors >> (sbi)->log_sectors_per_block) 95 (sectors >> F2FS_LOG_SECTORS_PER_BLOCK)
96#define MAX_BIO_BLOCKS(sbi) \ 96#define MAX_BIO_BLOCKS(sbi) \
97 ((int)min((int)max_hw_blocks(sbi), BIO_MAX_PAGES)) 97 ((int)min((int)max_hw_blocks(sbi), BIO_MAX_PAGES))
98 98
@@ -711,7 +711,7 @@ static inline unsigned int max_hw_blocks(struct f2fs_sb_info *sbi)
711{ 711{
712 struct block_device *bdev = sbi->sb->s_bdev; 712 struct block_device *bdev = sbi->sb->s_bdev;
713 struct request_queue *q = bdev_get_queue(bdev); 713 struct request_queue *q = bdev_get_queue(bdev);
714 return SECTOR_TO_BLOCK(sbi, queue_max_sectors(q)); 714 return SECTOR_TO_BLOCK(queue_max_sectors(q));
715} 715}
716 716
717/* 717/*
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index ed4095e5e8a7..3dfa1b5eae2f 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -788,14 +788,22 @@ static int sanity_check_raw_super(struct super_block *sb,
788 return 1; 788 return 1;
789 } 789 }
790 790
791 if (le32_to_cpu(raw_super->log_sectorsize) != 791 /* Currently, support 512/1024/2048/4096 bytes sector size */
792 F2FS_LOG_SECTOR_SIZE) { 792 if (le32_to_cpu(raw_super->log_sectorsize) >
793 f2fs_msg(sb, KERN_INFO, "Invalid log sectorsize"); 793 F2FS_MAX_LOG_SECTOR_SIZE ||
794 le32_to_cpu(raw_super->log_sectorsize) <
795 F2FS_MIN_LOG_SECTOR_SIZE) {
796 f2fs_msg(sb, KERN_INFO, "Invalid log sectorsize (%u)",
797 le32_to_cpu(raw_super->log_sectorsize));
794 return 1; 798 return 1;
795 } 799 }
796 if (le32_to_cpu(raw_super->log_sectors_per_block) != 800 if (le32_to_cpu(raw_super->log_sectors_per_block) +
797 F2FS_LOG_SECTORS_PER_BLOCK) { 801 le32_to_cpu(raw_super->log_sectorsize) !=
798 f2fs_msg(sb, KERN_INFO, "Invalid log sectors per block"); 802 F2FS_MAX_LOG_SECTOR_SIZE) {
803 f2fs_msg(sb, KERN_INFO,
804 "Invalid log sectors per block(%u) log sectorsize(%u)",
805 le32_to_cpu(raw_super->log_sectors_per_block),
806 le32_to_cpu(raw_super->log_sectorsize));
799 return 1; 807 return 1;
800 } 808 }
801 return 0; 809 return 0;