super.c (197cd65accc6a274dabcd81f4811ba5d9a4856df) super.c (1d1fe1ee02b9ac2660995b10e35dd41448fef011)
1/*
2 * linux/fs/ext4/super.c
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *

--- 763 unchanged lines hidden (view full) ---

772 /* iget isn't really right if the inode is currently unallocated!!
773 *
774 * ext4_read_inode will return a bad_inode if the inode had been
775 * deleted, so we should be safe.
776 *
777 * Currently we don't know the generation for parent directory, so
778 * a generation of 0 means "accept any"
779 */
1/*
2 * linux/fs/ext4/super.c
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *

--- 763 unchanged lines hidden (view full) ---

772 /* iget isn't really right if the inode is currently unallocated!!
773 *
774 * ext4_read_inode will return a bad_inode if the inode had been
775 * deleted, so we should be safe.
776 *
777 * Currently we don't know the generation for parent directory, so
778 * a generation of 0 means "accept any"
779 */
780 inode = iget(sb, ino);
781 if (inode == NULL)
782 return ERR_PTR(-ENOMEM);
783 if (is_bad_inode(inode) ||
784 (generation && inode->i_generation != generation)) {
780 inode = ext4_iget(sb, ino);
781 if (IS_ERR(inode))
782 return ERR_CAST(inode);
783 if (generation && inode->i_generation != generation) {
785 iput(inode);
786 return ERR_PTR(-ESTALE);
787 }
788
789 return inode;
790}
791
792static struct dentry *ext4_fh_to_dentry(struct super_block *sb, struct fid *fid,

--- 52 unchanged lines hidden (view full) ---

845 .get_dqblk = vfs_get_dqblk,
846 .set_dqblk = vfs_set_dqblk
847};
848#endif
849
850static const struct super_operations ext4_sops = {
851 .alloc_inode = ext4_alloc_inode,
852 .destroy_inode = ext4_destroy_inode,
784 iput(inode);
785 return ERR_PTR(-ESTALE);
786 }
787
788 return inode;
789}
790
791static struct dentry *ext4_fh_to_dentry(struct super_block *sb, struct fid *fid,

--- 52 unchanged lines hidden (view full) ---

844 .get_dqblk = vfs_get_dqblk,
845 .set_dqblk = vfs_set_dqblk
846};
847#endif
848
849static const struct super_operations ext4_sops = {
850 .alloc_inode = ext4_alloc_inode,
851 .destroy_inode = ext4_destroy_inode,
853 .read_inode = ext4_read_inode,
854 .write_inode = ext4_write_inode,
855 .dirty_inode = ext4_dirty_inode,
856 .delete_inode = ext4_delete_inode,
857 .put_super = ext4_put_super,
858 .write_super = ext4_write_super,
859 .sync_fs = ext4_sync_fs,
860 .write_super_lockfs = ext4_write_super_lockfs,
861 .unlockfs = ext4_unlockfs,

--- 938 unchanged lines hidden (view full) ---

1800 ext4_fsblk_t block;
1801 ext4_fsblk_t sb_block = get_sb_block(&data);
1802 ext4_fsblk_t logical_sb_block;
1803 unsigned long offset = 0;
1804 unsigned int journal_inum = 0;
1805 unsigned long journal_devnum = 0;
1806 unsigned long def_mount_opts;
1807 struct inode *root;
852 .write_inode = ext4_write_inode,
853 .dirty_inode = ext4_dirty_inode,
854 .delete_inode = ext4_delete_inode,
855 .put_super = ext4_put_super,
856 .write_super = ext4_write_super,
857 .sync_fs = ext4_sync_fs,
858 .write_super_lockfs = ext4_write_super_lockfs,
859 .unlockfs = ext4_unlockfs,

--- 938 unchanged lines hidden (view full) ---

1798 ext4_fsblk_t block;
1799 ext4_fsblk_t sb_block = get_sb_block(&data);
1800 ext4_fsblk_t logical_sb_block;
1801 unsigned long offset = 0;
1802 unsigned int journal_inum = 0;
1803 unsigned long journal_devnum = 0;
1804 unsigned long def_mount_opts;
1805 struct inode *root;
1806 int ret = -EINVAL;
1808 int blocksize;
1809 int db_count;
1810 int i;
1811 int needs_recovery;
1812 __le32 features;
1813 __u64 blocks_count;
1814 int err;
1815

--- 416 unchanged lines hidden (view full) ---

2232 clear_opt(sbi->s_mount_opt, NOBH);
2233 }
2234 }
2235 /*
2236 * The jbd2_journal_load will have done any necessary log recovery,
2237 * so we can safely mount the rest of the filesystem now.
2238 */
2239
1807 int blocksize;
1808 int db_count;
1809 int i;
1810 int needs_recovery;
1811 __le32 features;
1812 __u64 blocks_count;
1813 int err;
1814

--- 416 unchanged lines hidden (view full) ---

2231 clear_opt(sbi->s_mount_opt, NOBH);
2232 }
2233 }
2234 /*
2235 * The jbd2_journal_load will have done any necessary log recovery,
2236 * so we can safely mount the rest of the filesystem now.
2237 */
2238
2240 root = iget(sb, EXT4_ROOT_INO);
2241 sb->s_root = d_alloc_root(root);
2242 if (!sb->s_root) {
2239 root = ext4_iget(sb, EXT4_ROOT_INO);
2240 if (IS_ERR(root)) {
2243 printk(KERN_ERR "EXT4-fs: get root inode failed\n");
2241 printk(KERN_ERR "EXT4-fs: get root inode failed\n");
2244 iput(root);
2242 ret = PTR_ERR(root);
2245 goto failed_mount4;
2246 }
2247 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
2243 goto failed_mount4;
2244 }
2245 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
2248 dput(sb->s_root);
2249 sb->s_root = NULL;
2246 iput(root);
2250 printk(KERN_ERR "EXT4-fs: corrupt root inode, run e2fsck\n");
2251 goto failed_mount4;
2252 }
2247 printk(KERN_ERR "EXT4-fs: corrupt root inode, run e2fsck\n");
2248 goto failed_mount4;
2249 }
2250 sb->s_root = d_alloc_root(root);
2251 if (!sb->s_root) {
2252 printk(KERN_ERR "EXT4-fs: get root dentry failed\n");
2253 iput(root);
2254 ret = -ENOMEM;
2255 goto failed_mount4;
2256 }
2253
2254 ext4_setup_super (sb, es, sb->s_flags & MS_RDONLY);
2255
2256 /* determine the minimum size of new large inodes, if present */
2257 if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE) {
2258 sbi->s_want_extra_isize = sizeof(struct ext4_inode) -
2259 EXT4_GOOD_OLD_INODE_SIZE;
2260 if (EXT4_HAS_RO_COMPAT_FEATURE(sb,

--- 64 unchanged lines hidden (view full) ---

2325 kfree(sbi->s_qf_names[i]);
2326#endif
2327 ext4_blkdev_remove(sbi);
2328 brelse(bh);
2329out_fail:
2330 sb->s_fs_info = NULL;
2331 kfree(sbi);
2332 lock_kernel();
2257
2258 ext4_setup_super (sb, es, sb->s_flags & MS_RDONLY);
2259
2260 /* determine the minimum size of new large inodes, if present */
2261 if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE) {
2262 sbi->s_want_extra_isize = sizeof(struct ext4_inode) -
2263 EXT4_GOOD_OLD_INODE_SIZE;
2264 if (EXT4_HAS_RO_COMPAT_FEATURE(sb,

--- 64 unchanged lines hidden (view full) ---

2329 kfree(sbi->s_qf_names[i]);
2330#endif
2331 ext4_blkdev_remove(sbi);
2332 brelse(bh);
2333out_fail:
2334 sb->s_fs_info = NULL;
2335 kfree(sbi);
2336 lock_kernel();
2333 return -EINVAL;
2337 return ret;
2334}
2335
2336/*
2337 * Setup any per-fs journal parameters now. We'll do this both on
2338 * initial mount, once the journal has been initialised but before we've
2339 * done any recovery; and again on any subsequent remount.
2340 */
2341static void ext4_init_journal_params(struct super_block *sb, journal_t *journal)

--- 19 unchanged lines hidden (view full) ---

2361{
2362 struct inode *journal_inode;
2363 journal_t *journal;
2364
2365 /* First, test for the existence of a valid inode on disk. Bad
2366 * things happen if we iget() an unused inode, as the subsequent
2367 * iput() will try to delete it. */
2368
2338}
2339
2340/*
2341 * Setup any per-fs journal parameters now. We'll do this both on
2342 * initial mount, once the journal has been initialised but before we've
2343 * done any recovery; and again on any subsequent remount.
2344 */
2345static void ext4_init_journal_params(struct super_block *sb, journal_t *journal)

--- 19 unchanged lines hidden (view full) ---

2365{
2366 struct inode *journal_inode;
2367 journal_t *journal;
2368
2369 /* First, test for the existence of a valid inode on disk. Bad
2370 * things happen if we iget() an unused inode, as the subsequent
2371 * iput() will try to delete it. */
2372
2369 journal_inode = iget(sb, journal_inum);
2370 if (!journal_inode) {
2373 journal_inode = ext4_iget(sb, journal_inum);
2374 if (IS_ERR(journal_inode)) {
2371 printk(KERN_ERR "EXT4-fs: no journal found.\n");
2372 return NULL;
2373 }
2374 if (!journal_inode->i_nlink) {
2375 make_bad_inode(journal_inode);
2376 iput(journal_inode);
2377 printk(KERN_ERR "EXT4-fs: journal inode is deleted.\n");
2378 return NULL;
2379 }
2380
2381 jbd_debug(2, "Journal inode found at %p: %Ld bytes\n",
2382 journal_inode, journal_inode->i_size);
2375 printk(KERN_ERR "EXT4-fs: no journal found.\n");
2376 return NULL;
2377 }
2378 if (!journal_inode->i_nlink) {
2379 make_bad_inode(journal_inode);
2380 iput(journal_inode);
2381 printk(KERN_ERR "EXT4-fs: journal inode is deleted.\n");
2382 return NULL;
2383 }
2384
2385 jbd_debug(2, "Journal inode found at %p: %Ld bytes\n",
2386 journal_inode, journal_inode->i_size);
2383 if (is_bad_inode(journal_inode) || !S_ISREG(journal_inode->i_mode)) {
2387 if (!S_ISREG(journal_inode->i_mode)) {
2384 printk(KERN_ERR "EXT4-fs: invalid journal inode.\n");
2385 iput(journal_inode);
2386 return NULL;
2387 }
2388
2389 journal = jbd2_journal_init_inode(journal_inode);
2390 if (!journal) {
2391 printk(KERN_ERR "EXT4-fs: Could not load journal inode\n");

--- 930 unchanged lines hidden ---
2388 printk(KERN_ERR "EXT4-fs: invalid journal inode.\n");
2389 iput(journal_inode);
2390 return NULL;
2391 }
2392
2393 journal = jbd2_journal_init_inode(journal_inode);
2394 if (!journal) {
2395 printk(KERN_ERR "EXT4-fs: Could not load journal inode\n");

--- 930 unchanged lines hidden ---