[syslinux:pathbased] fs: move cache_init() into fs_init, to handle special needs
syslinux-bot for H. Peter Anvin
hpa at zytor.com
Tue Feb 16 12:24:38 PST 2010
Commit-ID: 362daa623200248b789ec6d4703070cb001cc929
Gitweb: http://syslinux.zytor.com/commit/362daa623200248b789ec6d4703070cb001cc929
Author: H. Peter Anvin <hpa at zytor.com>
AuthorDate: Tue, 16 Feb 2010 12:22:12 -0800
Committer: H. Peter Anvin <hpa at zytor.com>
CommitDate: Tue, 16 Feb 2010 12:22:12 -0800
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 <hpa at zytor.com>
---
core/fs/btrfs/btrfs.c | 13 ++++++++++++-
core/fs/ext2/ext2.c | 7 +++++++
core/fs/fat/fat.c | 6 ++++--
core/fs/iso9660/iso9660.c | 3 +++
4 files changed, 26 insertions(+), 3 deletions(-)
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;
}
More information about the Syslinux-commits
mailing list