From: H. Peter Anvin Date: Tue, 16 Feb 2010 20:22:12 +0000 (-0800) Subject: fs: move cache_init() into fs_init, to handle special needs X-Git-Tag: syslinux-4.00-pre24~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=362daa623200248b789ec6d4703070cb001cc929;p=platform%2Fupstream%2Fsyslinux.git fs: move cache_init() into fs_init, to handle special needs Move cache_init() into the fs_init methods, to accommodate special handling, e.g. the all-zero zero block for ext2. Signed-off-by: H. Peter Anvin --- diff --git a/core/fs/btrfs/btrfs.c b/core/fs/btrfs/btrfs.c index 5557c87..4389302 100644 --- a/core/fs/btrfs/btrfs.c +++ b/core/fs/btrfs/btrfs.c @@ -691,8 +691,15 @@ static void btrfs_get_fs_tree(void) /* init. the fs meta data, return the block size shift bits. */ static int btrfs_fs_init(struct fs_info *_fs) { + struct disk *disk = fs->fs_dev->disk; + btrfs_init_crc32c(); + fs->sector_shift = disk->sector_shift; + fs->sector_size = 1 << fs->sector_shift; + fs->block_shift = BTRFS_BLOCK_SHIFT; + fs->block_size = 1 << fs->block_shift; + fs = _fs; btrfs_read_super_block(); if (strncmp((char *)(&sb.magic), BTRFS_MAGIC, sizeof(sb.magic))) @@ -702,7 +709,11 @@ static int btrfs_fs_init(struct fs_info *_fs) btrfs_get_fs_tree(); btrfs_set_cwd(); cache_ready = 1; - return BTRFS_BLOCK_SHIFT;/* to determine cache size */ + + /* Initialize the block cache */ + cache_init(fs->fs_dev, fs->block_size); + + return fs->block_size; } const struct fs_ops btrfs_fs_ops = { diff --git a/core/fs/ext2/ext2.c b/core/fs/ext2/ext2.c index 020cefe..fcf5cb9 100644 --- a/core/fs/ext2/ext2.c +++ b/core/fs/ext2/ext2.c @@ -358,6 +358,7 @@ static int ext2_fs_init(struct fs_info *fs) struct disk *disk = fs->fs_dev->disk; struct ext2_sb_info *sbi; struct ext2_super_block sb; + struct cache *cs; /* read the super block */ disk->rdwr_sectors(disk, &sb, 2, 2, 0); @@ -395,6 +396,12 @@ static int ext2_fs_init(struct fs_info *fs) sbi->s_first_data_block = sb.s_first_data_block; sbi->s_inode_size = sb.s_inode_size; + /* Initialize the cache, and force block zero to all zero */ + cache_init(fs->fs_dev, fs->block_shift); + cs = _get_cache_block(fs->fs_dev, 0); + memset(cs->data, 0, fs->block_size); + cache_lock_block(cs); + return fs->block_shift; } diff --git a/core/fs/fat/fat.c b/core/fs/fat/fat.c index bea6a89..ba4ae1a 100644 --- a/core/fs/fat/fat.c +++ b/core/fs/fat/fat.c @@ -824,8 +824,10 @@ static int vfat_fs_init(struct fs_info *fs) } sbi->clusters = clusters; - /* for SYSLINUX, the cache is based on sector size */ - return fs->sector_shift; + /* Initialize the cache */ + cache_init(fs->fs_dev, fs->block_shift); + + return fs->block_shift; } const struct fs_ops vfat_fs_ops = { diff --git a/core/fs/iso9660/iso9660.c b/core/fs/iso9660/iso9660.c index a7c70a3..6186041 100644 --- a/core/fs/iso9660/iso9660.c +++ b/core/fs/iso9660/iso9660.c @@ -423,6 +423,9 @@ static int iso_fs_init(struct fs_info *fs) fs->sector_size = 1 << fs->sector_shift; fs->block_size = 1 << fs->block_shift; + /* Initialize the cache */ + cache_init(fs->fs_dev, fs->block_shift); + return fs->block_shift; }