super.c (617ba13b31fbf505cc21799826639ef24ed94af0) | super.c (dab291af8d6307a3075c3d67d0cc8f98e646cb94) |
---|---|
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 * --- 6 unchanged lines hidden (view full) --- 15 * Big-endian to little-endian byte-swapping/bitmaps by 16 * David S. Miller (davem@caip.rutgers.edu), 1995 17 */ 18 19#include <linux/module.h> 20#include <linux/string.h> 21#include <linux/fs.h> 22#include <linux/time.h> | 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 * --- 6 unchanged lines hidden (view full) --- 15 * Big-endian to little-endian byte-swapping/bitmaps by 16 * David S. Miller (davem@caip.rutgers.edu), 1995 17 */ 18 19#include <linux/module.h> 20#include <linux/string.h> 21#include <linux/fs.h> 22#include <linux/time.h> |
23#include <linux/jbd.h> | 23#include <linux/jbd2.h> |
24#include <linux/ext4_fs.h> | 24#include <linux/ext4_fs.h> |
25#include <linux/ext4_jbd.h> | 25#include <linux/ext4_jbd2.h> |
26#include <linux/slab.h> 27#include <linux/init.h> 28#include <linux/blkdev.h> 29#include <linux/parser.h> 30#include <linux/smp_lock.h> 31#include <linux/buffer_head.h> 32#include <linux/vfs.h> 33#include <linux/random.h> --- 24 unchanged lines hidden (view full) --- 58 char nbuf[16]); 59static int ext4_remount (struct super_block * sb, int * flags, char * data); 60static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf); 61static void ext4_unlockfs(struct super_block *sb); 62static void ext4_write_super (struct super_block * sb); 63static void ext4_write_super_lockfs(struct super_block *sb); 64 65/* | 26#include <linux/slab.h> 27#include <linux/init.h> 28#include <linux/blkdev.h> 29#include <linux/parser.h> 30#include <linux/smp_lock.h> 31#include <linux/buffer_head.h> 32#include <linux/vfs.h> 33#include <linux/random.h> --- 24 unchanged lines hidden (view full) --- 58 char nbuf[16]); 59static int ext4_remount (struct super_block * sb, int * flags, char * data); 60static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf); 61static void ext4_unlockfs(struct super_block *sb); 62static void ext4_write_super (struct super_block * sb); 63static void ext4_write_super_lockfs(struct super_block *sb); 64 65/* |
66 * Wrappers for journal_start/end. | 66 * Wrappers for jbd2_journal_start/end. |
67 * 68 * The only special thing we need to do here is to make sure that all 69 * journal_end calls result in the superblock being marked dirty, so 70 * that sync() will call the filesystem's write_super callback if 71 * appropriate. 72 */ 73handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks) 74{ --- 7 unchanged lines hidden (view full) --- 82 * take the FS itself readonly cleanly. */ 83 journal = EXT4_SB(sb)->s_journal; 84 if (is_journal_aborted(journal)) { 85 ext4_abort(sb, __FUNCTION__, 86 "Detected aborted journal"); 87 return ERR_PTR(-EROFS); 88 } 89 | 67 * 68 * The only special thing we need to do here is to make sure that all 69 * journal_end calls result in the superblock being marked dirty, so 70 * that sync() will call the filesystem's write_super callback if 71 * appropriate. 72 */ 73handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks) 74{ --- 7 unchanged lines hidden (view full) --- 82 * take the FS itself readonly cleanly. */ 83 journal = EXT4_SB(sb)->s_journal; 84 if (is_journal_aborted(journal)) { 85 ext4_abort(sb, __FUNCTION__, 86 "Detected aborted journal"); 87 return ERR_PTR(-EROFS); 88 } 89 |
90 return journal_start(journal, nblocks); | 90 return jbd2_journal_start(journal, nblocks); |
91} 92 93/* 94 * The only special thing we need to do here is to make sure that all | 91} 92 93/* 94 * The only special thing we need to do here is to make sure that all |
95 * journal_stop calls result in the superblock being marked dirty, so | 95 * jbd2_journal_stop calls result in the superblock being marked dirty, so |
96 * that sync() will call the filesystem's write_super callback if 97 * appropriate. 98 */ 99int __ext4_journal_stop(const char *where, handle_t *handle) 100{ 101 struct super_block *sb; 102 int err; 103 int rc; 104 105 sb = handle->h_transaction->t_journal->j_private; 106 err = handle->h_err; | 96 * that sync() will call the filesystem's write_super callback if 97 * appropriate. 98 */ 99int __ext4_journal_stop(const char *where, handle_t *handle) 100{ 101 struct super_block *sb; 102 int err; 103 int rc; 104 105 sb = handle->h_transaction->t_journal->j_private; 106 err = handle->h_err; |
107 rc = journal_stop(handle); | 107 rc = jbd2_journal_stop(handle); |
108 109 if (!err) 110 err = rc; 111 if (err) 112 __ext4_std_error(sb, where, err); 113 return err; 114} 115 --- 10 unchanged lines hidden (view full) --- 126 handle->h_err = err; 127 128 if (is_handle_aborted(handle)) 129 return; 130 131 printk(KERN_ERR "%s: aborting transaction: %s in %s\n", 132 caller, errstr, err_fn); 133 | 108 109 if (!err) 110 err = rc; 111 if (err) 112 __ext4_std_error(sb, where, err); 113 return err; 114} 115 --- 10 unchanged lines hidden (view full) --- 126 handle->h_err = err; 127 128 if (is_handle_aborted(handle)) 129 return; 130 131 printk(KERN_ERR "%s: aborting transaction: %s in %s\n", 132 caller, errstr, err_fn); 133 |
134 journal_abort_handle(handle); | 134 jbd2_journal_abort_handle(handle); |
135} 136 137/* Deal with the reporting of failure conditions on a filesystem such as 138 * inconsistencies detected or read IO failures. 139 * 140 * On ext2, we can store the error state of the filesystem in the 141 * superblock. That is not possible on ext4, because we may have other 142 * write ordering constraints on the superblock which prevent us from 143 * writing it out straight away; and given that the journal is about to 144 * be aborted, we can't rely on the current, or future, transactions to 145 * write out the superblock safely. 146 * | 135} 136 137/* Deal with the reporting of failure conditions on a filesystem such as 138 * inconsistencies detected or read IO failures. 139 * 140 * On ext2, we can store the error state of the filesystem in the 141 * superblock. That is not possible on ext4, because we may have other 142 * write ordering constraints on the superblock which prevent us from 143 * writing it out straight away; and given that the journal is about to 144 * be aborted, we can't rely on the current, or future, transactions to 145 * write out the superblock safely. 146 * |
147 * We'll just use the journal_abort() error code to record an error in | 147 * We'll just use the jbd2_journal_abort() error code to record an error in |
148 * the journal instead. On recovery, the journal will compain about 149 * that error until we've noted it down and cleared it. 150 */ 151 152static void ext4_handle_error(struct super_block *sb) 153{ 154 struct ext4_super_block *es = EXT4_SB(sb)->s_es; 155 156 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; 157 es->s_state |= cpu_to_le16(EXT4_ERROR_FS); 158 159 if (sb->s_flags & MS_RDONLY) 160 return; 161 162 if (!test_opt (sb, ERRORS_CONT)) { 163 journal_t *journal = EXT4_SB(sb)->s_journal; 164 165 EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT; 166 if (journal) | 148 * the journal instead. On recovery, the journal will compain about 149 * that error until we've noted it down and cleared it. 150 */ 151 152static void ext4_handle_error(struct super_block *sb) 153{ 154 struct ext4_super_block *es = EXT4_SB(sb)->s_es; 155 156 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; 157 es->s_state |= cpu_to_le16(EXT4_ERROR_FS); 158 159 if (sb->s_flags & MS_RDONLY) 160 return; 161 162 if (!test_opt (sb, ERRORS_CONT)) { 163 journal_t *journal = EXT4_SB(sb)->s_journal; 164 165 EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT; 166 if (journal) |
167 journal_abort(journal, -EIO); | 167 jbd2_journal_abort(journal, -EIO); |
168 } 169 if (test_opt (sb, ERRORS_RO)) { 170 printk (KERN_CRIT "Remounting filesystem read-only\n"); 171 sb->s_flags |= MS_RDONLY; 172 } 173 ext4_commit_super(sb, es, 1); 174 if (test_opt(sb, ERRORS_PANIC)) 175 panic("EXT4-fs (device %s): panic forced after error\n", --- 22 unchanged lines hidden (view full) --- 198 switch (errno) { 199 case -EIO: 200 errstr = "IO failure"; 201 break; 202 case -ENOMEM: 203 errstr = "Out of memory"; 204 break; 205 case -EROFS: | 168 } 169 if (test_opt (sb, ERRORS_RO)) { 170 printk (KERN_CRIT "Remounting filesystem read-only\n"); 171 sb->s_flags |= MS_RDONLY; 172 } 173 ext4_commit_super(sb, es, 1); 174 if (test_opt(sb, ERRORS_PANIC)) 175 panic("EXT4-fs (device %s): panic forced after error\n", --- 22 unchanged lines hidden (view full) --- 198 switch (errno) { 199 case -EIO: 200 errstr = "IO failure"; 201 break; 202 case -ENOMEM: 203 errstr = "Out of memory"; 204 break; 205 case -EROFS: |
206 if (!sb || EXT4_SB(sb)->s_journal->j_flags & JFS_ABORT) | 206 if (!sb || EXT4_SB(sb)->s_journal->j_flags & JBD2_ABORT) |
207 errstr = "Journal has aborted"; 208 else 209 errstr = "Readonly filesystem"; 210 break; 211 default: 212 /* If the caller passed in an extra buffer for unknown 213 * errors, textualise them now. Else we just return 214 * NULL. */ --- 59 unchanged lines hidden (view full) --- 274 275 if (sb->s_flags & MS_RDONLY) 276 return; 277 278 printk(KERN_CRIT "Remounting filesystem read-only\n"); 279 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; 280 sb->s_flags |= MS_RDONLY; 281 EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT; | 207 errstr = "Journal has aborted"; 208 else 209 errstr = "Readonly filesystem"; 210 break; 211 default: 212 /* If the caller passed in an extra buffer for unknown 213 * errors, textualise them now. Else we just return 214 * NULL. */ --- 59 unchanged lines hidden (view full) --- 274 275 if (sb->s_flags & MS_RDONLY) 276 return; 277 278 printk(KERN_CRIT "Remounting filesystem read-only\n"); 279 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; 280 sb->s_flags |= MS_RDONLY; 281 EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT; |
282 journal_abort(EXT4_SB(sb)->s_journal, -EIO); | 282 jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO); |
283} 284 285void ext4_warning (struct super_block * sb, const char * function, 286 const char * fmt, ...) 287{ 288 va_list args; 289 290 va_start(args, fmt); --- 95 unchanged lines hidden (view full) --- 386 387static void ext4_put_super (struct super_block * sb) 388{ 389 struct ext4_sb_info *sbi = EXT4_SB(sb); 390 struct ext4_super_block *es = sbi->s_es; 391 int i; 392 393 ext4_xattr_put_super(sb); | 283} 284 285void ext4_warning (struct super_block * sb, const char * function, 286 const char * fmt, ...) 287{ 288 va_list args; 289 290 va_start(args, fmt); --- 95 unchanged lines hidden (view full) --- 386 387static void ext4_put_super (struct super_block * sb) 388{ 389 struct ext4_sb_info *sbi = EXT4_SB(sb); 390 struct ext4_super_block *es = sbi->s_es; 391 int i; 392 393 ext4_xattr_put_super(sb); |
394 journal_destroy(sbi->s_journal); | 394 jbd2_journal_destroy(sbi->s_journal); |
395 if (!(sb->s_flags & MS_RDONLY)) { 396 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 397 es->s_state = cpu_to_le16(sbi->s_mount_state); 398 BUFFER_TRACE(sbi->s_sbh, "marking dirty"); 399 mark_buffer_dirty(sbi->s_sbh); 400 ext4_commit_super(sb, es, 1); 401 } 402 --- 1314 unchanged lines hidden (view full) --- 1717 1718 /* We have now updated the journal if required, so we can 1719 * validate the data journaling mode. */ 1720 switch (test_opt(sb, DATA_FLAGS)) { 1721 case 0: 1722 /* No mode set, assume a default based on the journal 1723 capabilities: ORDERED_DATA if the journal can 1724 cope, else JOURNAL_DATA */ | 395 if (!(sb->s_flags & MS_RDONLY)) { 396 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 397 es->s_state = cpu_to_le16(sbi->s_mount_state); 398 BUFFER_TRACE(sbi->s_sbh, "marking dirty"); 399 mark_buffer_dirty(sbi->s_sbh); 400 ext4_commit_super(sb, es, 1); 401 } 402 --- 1314 unchanged lines hidden (view full) --- 1717 1718 /* We have now updated the journal if required, so we can 1719 * validate the data journaling mode. */ 1720 switch (test_opt(sb, DATA_FLAGS)) { 1721 case 0: 1722 /* No mode set, assume a default based on the journal 1723 capabilities: ORDERED_DATA if the journal can 1724 cope, else JOURNAL_DATA */ |
1725 if (journal_check_available_features 1726 (sbi->s_journal, 0, 0, JFS_FEATURE_INCOMPAT_REVOKE)) | 1725 if (jbd2_journal_check_available_features 1726 (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE)) |
1727 set_opt(sbi->s_mount_opt, ORDERED_DATA); 1728 else 1729 set_opt(sbi->s_mount_opt, JOURNAL_DATA); 1730 break; 1731 1732 case EXT4_MOUNT_ORDERED_DATA: 1733 case EXT4_MOUNT_WRITEBACK_DATA: | 1727 set_opt(sbi->s_mount_opt, ORDERED_DATA); 1728 else 1729 set_opt(sbi->s_mount_opt, JOURNAL_DATA); 1730 break; 1731 1732 case EXT4_MOUNT_ORDERED_DATA: 1733 case EXT4_MOUNT_WRITEBACK_DATA: |
1734 if (!journal_check_available_features 1735 (sbi->s_journal, 0, 0, JFS_FEATURE_INCOMPAT_REVOKE)) { | 1734 if (!jbd2_journal_check_available_features 1735 (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE)) { |
1736 printk(KERN_ERR "EXT4-fs: Journal does not support " 1737 "requested data journaling mode\n"); 1738 goto failed_mount4; 1739 } 1740 default: 1741 break; 1742 } 1743 1744 if (test_opt(sb, NOBH)) { 1745 if (!(test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)) { 1746 printk(KERN_WARNING "EXT4-fs: Ignoring nobh option - " 1747 "its supported only with writeback mode\n"); 1748 clear_opt(sbi->s_mount_opt, NOBH); 1749 } 1750 } 1751 /* | 1736 printk(KERN_ERR "EXT4-fs: Journal does not support " 1737 "requested data journaling mode\n"); 1738 goto failed_mount4; 1739 } 1740 default: 1741 break; 1742 } 1743 1744 if (test_opt(sb, NOBH)) { 1745 if (!(test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)) { 1746 printk(KERN_WARNING "EXT4-fs: Ignoring nobh option - " 1747 "its supported only with writeback mode\n"); 1748 clear_opt(sbi->s_mount_opt, NOBH); 1749 } 1750 } 1751 /* |
1752 * The journal_load will have done any necessary log recovery, | 1752 * The jbd2_journal_load will have done any necessary log recovery, |
1753 * so we can safely mount the rest of the filesystem now. 1754 */ 1755 1756 root = iget(sb, EXT4_ROOT_INO); 1757 sb->s_root = d_alloc_root(root); 1758 if (!sb->s_root) { 1759 printk(KERN_ERR "EXT4-fs: get root inode failed\n"); 1760 iput(root); --- 31 unchanged lines hidden (view full) --- 1792 1793cantfind_ext4: 1794 if (!silent) 1795 printk(KERN_ERR "VFS: Can't find ext4 filesystem on dev %s.\n", 1796 sb->s_id); 1797 goto failed_mount; 1798 1799failed_mount4: | 1753 * so we can safely mount the rest of the filesystem now. 1754 */ 1755 1756 root = iget(sb, EXT4_ROOT_INO); 1757 sb->s_root = d_alloc_root(root); 1758 if (!sb->s_root) { 1759 printk(KERN_ERR "EXT4-fs: get root inode failed\n"); 1760 iput(root); --- 31 unchanged lines hidden (view full) --- 1792 1793cantfind_ext4: 1794 if (!silent) 1795 printk(KERN_ERR "VFS: Can't find ext4 filesystem on dev %s.\n", 1796 sb->s_id); 1797 goto failed_mount; 1798 1799failed_mount4: |
1800 journal_destroy(sbi->s_journal); | 1800 jbd2_journal_destroy(sbi->s_journal); |
1801failed_mount3: 1802 percpu_counter_destroy(&sbi->s_freeblocks_counter); 1803 percpu_counter_destroy(&sbi->s_freeinodes_counter); 1804 percpu_counter_destroy(&sbi->s_dirs_counter); 1805failed_mount2: 1806 for (i = 0; i < db_count; i++) 1807 brelse(sbi->s_group_desc[i]); 1808 kfree(sbi->s_group_desc); --- 23 unchanged lines hidden (view full) --- 1832 if (sbi->s_commit_interval) 1833 journal->j_commit_interval = sbi->s_commit_interval; 1834 /* We could also set up an ext4-specific default for the commit 1835 * interval here, but for now we'll just fall back to the jbd 1836 * default. */ 1837 1838 spin_lock(&journal->j_state_lock); 1839 if (test_opt(sb, BARRIER)) | 1801failed_mount3: 1802 percpu_counter_destroy(&sbi->s_freeblocks_counter); 1803 percpu_counter_destroy(&sbi->s_freeinodes_counter); 1804 percpu_counter_destroy(&sbi->s_dirs_counter); 1805failed_mount2: 1806 for (i = 0; i < db_count; i++) 1807 brelse(sbi->s_group_desc[i]); 1808 kfree(sbi->s_group_desc); --- 23 unchanged lines hidden (view full) --- 1832 if (sbi->s_commit_interval) 1833 journal->j_commit_interval = sbi->s_commit_interval; 1834 /* We could also set up an ext4-specific default for the commit 1835 * interval here, but for now we'll just fall back to the jbd 1836 * default. */ 1837 1838 spin_lock(&journal->j_state_lock); 1839 if (test_opt(sb, BARRIER)) |
1840 journal->j_flags |= JFS_BARRIER; | 1840 journal->j_flags |= JBD2_BARRIER; |
1841 else | 1841 else |
1842 journal->j_flags &= ~JFS_BARRIER; | 1842 journal->j_flags &= ~JBD2_BARRIER; |
1843 spin_unlock(&journal->j_state_lock); 1844} 1845 1846static journal_t *ext4_get_journal(struct super_block *sb, 1847 unsigned int journal_inum) 1848{ 1849 struct inode *journal_inode; 1850 journal_t *journal; --- 17 unchanged lines hidden (view full) --- 1868 jbd_debug(2, "Journal inode found at %p: %Ld bytes\n", 1869 journal_inode, journal_inode->i_size); 1870 if (is_bad_inode(journal_inode) || !S_ISREG(journal_inode->i_mode)) { 1871 printk(KERN_ERR "EXT4-fs: invalid journal inode.\n"); 1872 iput(journal_inode); 1873 return NULL; 1874 } 1875 | 1843 spin_unlock(&journal->j_state_lock); 1844} 1845 1846static journal_t *ext4_get_journal(struct super_block *sb, 1847 unsigned int journal_inum) 1848{ 1849 struct inode *journal_inode; 1850 journal_t *journal; --- 17 unchanged lines hidden (view full) --- 1868 jbd_debug(2, "Journal inode found at %p: %Ld bytes\n", 1869 journal_inode, journal_inode->i_size); 1870 if (is_bad_inode(journal_inode) || !S_ISREG(journal_inode->i_mode)) { 1871 printk(KERN_ERR "EXT4-fs: invalid journal inode.\n"); 1872 iput(journal_inode); 1873 return NULL; 1874 } 1875 |
1876 journal = journal_init_inode(journal_inode); | 1876 journal = jbd2_journal_init_inode(journal_inode); |
1877 if (!journal) { 1878 printk(KERN_ERR "EXT4-fs: Could not load journal inode\n"); 1879 iput(journal_inode); 1880 return NULL; 1881 } 1882 journal->j_private = sb; 1883 ext4_init_journal_params(sb, journal); 1884 return journal; --- 55 unchanged lines hidden (view full) --- 1940 brelse(bh); 1941 goto out_bdev; 1942 } 1943 1944 len = le32_to_cpu(es->s_blocks_count); 1945 start = sb_block + 1; 1946 brelse(bh); /* we're done with the superblock */ 1947 | 1877 if (!journal) { 1878 printk(KERN_ERR "EXT4-fs: Could not load journal inode\n"); 1879 iput(journal_inode); 1880 return NULL; 1881 } 1882 journal->j_private = sb; 1883 ext4_init_journal_params(sb, journal); 1884 return journal; --- 55 unchanged lines hidden (view full) --- 1940 brelse(bh); 1941 goto out_bdev; 1942 } 1943 1944 len = le32_to_cpu(es->s_blocks_count); 1945 start = sb_block + 1; 1946 brelse(bh); /* we're done with the superblock */ 1947 |
1948 journal = journal_init_dev(bdev, sb->s_bdev, | 1948 journal = jbd2_journal_init_dev(bdev, sb->s_bdev, |
1949 start, len, blocksize); 1950 if (!journal) { 1951 printk(KERN_ERR "EXT4-fs: failed to create device journal\n"); 1952 goto out_bdev; 1953 } 1954 journal->j_private = sb; 1955 ll_rw_block(READ, 1, &journal->j_sb_buffer); 1956 wait_on_buffer(journal->j_sb_buffer); --- 6 unchanged lines hidden (view full) --- 1963 "user (unsupported) - %d\n", 1964 be32_to_cpu(journal->j_superblock->s_nr_users)); 1965 goto out_journal; 1966 } 1967 EXT4_SB(sb)->journal_bdev = bdev; 1968 ext4_init_journal_params(sb, journal); 1969 return journal; 1970out_journal: | 1949 start, len, blocksize); 1950 if (!journal) { 1951 printk(KERN_ERR "EXT4-fs: failed to create device journal\n"); 1952 goto out_bdev; 1953 } 1954 journal->j_private = sb; 1955 ll_rw_block(READ, 1, &journal->j_sb_buffer); 1956 wait_on_buffer(journal->j_sb_buffer); --- 6 unchanged lines hidden (view full) --- 1963 "user (unsupported) - %d\n", 1964 be32_to_cpu(journal->j_superblock->s_nr_users)); 1965 goto out_journal; 1966 } 1967 EXT4_SB(sb)->journal_bdev = bdev; 1968 ext4_init_journal_params(sb, journal); 1969 return journal; 1970out_journal: |
1971 journal_destroy(journal); | 1971 jbd2_journal_destroy(journal); |
1972out_bdev: 1973 ext4_blkdev_put(bdev); 1974 return NULL; 1975} 1976 1977static int ext4_load_journal(struct super_block *sb, 1978 struct ext4_super_block *es, 1979 unsigned long journal_devnum) --- 44 unchanged lines hidden (view full) --- 2024 if (!(journal = ext4_get_journal(sb, journal_inum))) 2025 return -EINVAL; 2026 } else { 2027 if (!(journal = ext4_get_dev_journal(sb, journal_dev))) 2028 return -EINVAL; 2029 } 2030 2031 if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) { | 1972out_bdev: 1973 ext4_blkdev_put(bdev); 1974 return NULL; 1975} 1976 1977static int ext4_load_journal(struct super_block *sb, 1978 struct ext4_super_block *es, 1979 unsigned long journal_devnum) --- 44 unchanged lines hidden (view full) --- 2024 if (!(journal = ext4_get_journal(sb, journal_inum))) 2025 return -EINVAL; 2026 } else { 2027 if (!(journal = ext4_get_dev_journal(sb, journal_dev))) 2028 return -EINVAL; 2029 } 2030 2031 if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) { |
2032 err = journal_update_format(journal); | 2032 err = jbd2_journal_update_format(journal); |
2033 if (err) { 2034 printk(KERN_ERR "EXT4-fs: error updating journal.\n"); | 2033 if (err) { 2034 printk(KERN_ERR "EXT4-fs: error updating journal.\n"); |
2035 journal_destroy(journal); | 2035 jbd2_journal_destroy(journal); |
2036 return err; 2037 } 2038 } 2039 2040 if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) | 2036 return err; 2037 } 2038 } 2039 2040 if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) |
2041 err = journal_wipe(journal, !really_read_only); | 2041 err = jbd2_journal_wipe(journal, !really_read_only); |
2042 if (!err) | 2042 if (!err) |
2043 err = journal_load(journal); | 2043 err = jbd2_journal_load(journal); |
2044 2045 if (err) { 2046 printk(KERN_ERR "EXT4-fs: error loading journal.\n"); | 2044 2045 if (err) { 2046 printk(KERN_ERR "EXT4-fs: error loading journal.\n"); |
2047 journal_destroy(journal); | 2047 jbd2_journal_destroy(journal); |
2048 return err; 2049 } 2050 2051 EXT4_SB(sb)->s_journal = journal; 2052 ext4_clear_journal_err(sb, es); 2053 2054 if (journal_devnum && 2055 journal_devnum != le32_to_cpu(es->s_journal_dev)) { --- 20 unchanged lines hidden (view full) --- 2076 } 2077 2078 if (!(journal = ext4_get_journal(sb, journal_inum))) 2079 return -EINVAL; 2080 2081 printk(KERN_INFO "EXT4-fs: creating new journal on inode %u\n", 2082 journal_inum); 2083 | 2048 return err; 2049 } 2050 2051 EXT4_SB(sb)->s_journal = journal; 2052 ext4_clear_journal_err(sb, es); 2053 2054 if (journal_devnum && 2055 journal_devnum != le32_to_cpu(es->s_journal_dev)) { --- 20 unchanged lines hidden (view full) --- 2076 } 2077 2078 if (!(journal = ext4_get_journal(sb, journal_inum))) 2079 return -EINVAL; 2080 2081 printk(KERN_INFO "EXT4-fs: creating new journal on inode %u\n", 2082 journal_inum); 2083 |
2084 if (journal_create(journal)) { | 2084 if (jbd2_journal_create(journal)) { |
2085 printk(KERN_ERR "EXT4-fs: error creating journal.\n"); | 2085 printk(KERN_ERR "EXT4-fs: error creating journal.\n"); |
2086 journal_destroy(journal); | 2086 jbd2_journal_destroy(journal); |
2087 return -EIO; 2088 } 2089 2090 EXT4_SB(sb)->s_journal = journal; 2091 2092 ext4_update_dynamic_rev(sb); 2093 EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 2094 EXT4_SET_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL); --- 30 unchanged lines hidden (view full) --- 2125 * remounting) the filesystem readonly, then we will end up with a 2126 * consistent fs on disk. Record that fact. 2127 */ 2128static void ext4_mark_recovery_complete(struct super_block * sb, 2129 struct ext4_super_block * es) 2130{ 2131 journal_t *journal = EXT4_SB(sb)->s_journal; 2132 | 2087 return -EIO; 2088 } 2089 2090 EXT4_SB(sb)->s_journal = journal; 2091 2092 ext4_update_dynamic_rev(sb); 2093 EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 2094 EXT4_SET_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL); --- 30 unchanged lines hidden (view full) --- 2125 * remounting) the filesystem readonly, then we will end up with a 2126 * consistent fs on disk. Record that fact. 2127 */ 2128static void ext4_mark_recovery_complete(struct super_block * sb, 2129 struct ext4_super_block * es) 2130{ 2131 journal_t *journal = EXT4_SB(sb)->s_journal; 2132 |
2133 journal_lock_updates(journal); 2134 journal_flush(journal); | 2133 jbd2_journal_lock_updates(journal); 2134 jbd2_journal_flush(journal); |
2135 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER) && 2136 sb->s_flags & MS_RDONLY) { 2137 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 2138 sb->s_dirt = 0; 2139 ext4_commit_super(sb, es, 1); 2140 } | 2135 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER) && 2136 sb->s_flags & MS_RDONLY) { 2137 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 2138 sb->s_dirt = 0; 2139 ext4_commit_super(sb, es, 1); 2140 } |
2141 journal_unlock_updates(journal); | 2141 jbd2_journal_unlock_updates(journal); |
2142} 2143 2144/* 2145 * If we are mounting (or read-write remounting) a filesystem whose journal 2146 * has recorded an error from a previous lifetime, move that error to the 2147 * main filesystem now. 2148 */ 2149static void ext4_clear_journal_err(struct super_block * sb, --- 5 unchanged lines hidden (view full) --- 2155 2156 journal = EXT4_SB(sb)->s_journal; 2157 2158 /* 2159 * Now check for any error status which may have been recorded in the 2160 * journal by a prior ext4_error() or ext4_abort() 2161 */ 2162 | 2142} 2143 2144/* 2145 * If we are mounting (or read-write remounting) a filesystem whose journal 2146 * has recorded an error from a previous lifetime, move that error to the 2147 * main filesystem now. 2148 */ 2149static void ext4_clear_journal_err(struct super_block * sb, --- 5 unchanged lines hidden (view full) --- 2155 2156 journal = EXT4_SB(sb)->s_journal; 2157 2158 /* 2159 * Now check for any error status which may have been recorded in the 2160 * journal by a prior ext4_error() or ext4_abort() 2161 */ 2162 |
2163 j_errno = journal_errno(journal); | 2163 j_errno = jbd2_journal_errno(journal); |
2164 if (j_errno) { 2165 char nbuf[16]; 2166 2167 errstr = ext4_decode_error(sb, j_errno, nbuf); 2168 ext4_warning(sb, __FUNCTION__, "Filesystem error recorded " 2169 "from previous mount: %s", errstr); 2170 ext4_warning(sb, __FUNCTION__, "Marking fs in need of " 2171 "filesystem check."); 2172 2173 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; 2174 es->s_state |= cpu_to_le16(EXT4_ERROR_FS); 2175 ext4_commit_super (sb, es, 1); 2176 | 2164 if (j_errno) { 2165 char nbuf[16]; 2166 2167 errstr = ext4_decode_error(sb, j_errno, nbuf); 2168 ext4_warning(sb, __FUNCTION__, "Filesystem error recorded " 2169 "from previous mount: %s", errstr); 2170 ext4_warning(sb, __FUNCTION__, "Marking fs in need of " 2171 "filesystem check."); 2172 2173 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; 2174 es->s_state |= cpu_to_le16(EXT4_ERROR_FS); 2175 ext4_commit_super (sb, es, 1); 2176 |
2177 journal_clear_err(journal); | 2177 jbd2_journal_clear_err(journal); |
2178 } 2179} 2180 2181/* 2182 * Force the running and committing transactions to commit, 2183 * and wait on the commit. 2184 */ 2185int ext4_force_commit(struct super_block *sb) --- 26 unchanged lines hidden (view full) --- 2212 sb->s_dirt = 0; 2213} 2214 2215static int ext4_sync_fs(struct super_block *sb, int wait) 2216{ 2217 tid_t target; 2218 2219 sb->s_dirt = 0; | 2178 } 2179} 2180 2181/* 2182 * Force the running and committing transactions to commit, 2183 * and wait on the commit. 2184 */ 2185int ext4_force_commit(struct super_block *sb) --- 26 unchanged lines hidden (view full) --- 2212 sb->s_dirt = 0; 2213} 2214 2215static int ext4_sync_fs(struct super_block *sb, int wait) 2216{ 2217 tid_t target; 2218 2219 sb->s_dirt = 0; |
2220 if (journal_start_commit(EXT4_SB(sb)->s_journal, &target)) { | 2220 if (jbd2_journal_start_commit(EXT4_SB(sb)->s_journal, &target)) { |
2221 if (wait) | 2221 if (wait) |
2222 log_wait_commit(EXT4_SB(sb)->s_journal, target); | 2222 jbd2_log_wait_commit(EXT4_SB(sb)->s_journal, target); |
2223 } 2224 return 0; 2225} 2226 2227/* 2228 * LVM calls this function before a (read-only) snapshot is created. This 2229 * gives us a chance to flush the journal completely and mark the fs clean. 2230 */ 2231static void ext4_write_super_lockfs(struct super_block *sb) 2232{ 2233 sb->s_dirt = 0; 2234 2235 if (!(sb->s_flags & MS_RDONLY)) { 2236 journal_t *journal = EXT4_SB(sb)->s_journal; 2237 2238 /* Now we set up the journal barrier. */ | 2223 } 2224 return 0; 2225} 2226 2227/* 2228 * LVM calls this function before a (read-only) snapshot is created. This 2229 * gives us a chance to flush the journal completely and mark the fs clean. 2230 */ 2231static void ext4_write_super_lockfs(struct super_block *sb) 2232{ 2233 sb->s_dirt = 0; 2234 2235 if (!(sb->s_flags & MS_RDONLY)) { 2236 journal_t *journal = EXT4_SB(sb)->s_journal; 2237 2238 /* Now we set up the journal barrier. */ |
2239 journal_lock_updates(journal); 2240 journal_flush(journal); | 2239 jbd2_journal_lock_updates(journal); 2240 jbd2_journal_flush(journal); |
2241 2242 /* Journal blocked and flushed, clear needs_recovery flag. */ 2243 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 2244 ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1); 2245 } 2246} 2247 2248/* 2249 * Called by LVM after the snapshot is done. We need to reset the RECOVER 2250 * flag here, even though the filesystem is not technically dirty yet. 2251 */ 2252static void ext4_unlockfs(struct super_block *sb) 2253{ 2254 if (!(sb->s_flags & MS_RDONLY)) { 2255 lock_super(sb); 2256 /* Reser the needs_recovery flag before the fs is unlocked. */ 2257 EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 2258 ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1); 2259 unlock_super(sb); | 2241 2242 /* Journal blocked and flushed, clear needs_recovery flag. */ 2243 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 2244 ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1); 2245 } 2246} 2247 2248/* 2249 * Called by LVM after the snapshot is done. We need to reset the RECOVER 2250 * flag here, even though the filesystem is not technically dirty yet. 2251 */ 2252static void ext4_unlockfs(struct super_block *sb) 2253{ 2254 if (!(sb->s_flags & MS_RDONLY)) { 2255 lock_super(sb); 2256 /* Reser the needs_recovery flag before the fs is unlocked. */ 2257 EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 2258 ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1); 2259 unlock_super(sb); |
2260 journal_unlock_updates(EXT4_SB(sb)->s_journal); | 2260 jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); |
2261 } 2262} 2263 2264static int ext4_remount (struct super_block * sb, int * flags, char * data) 2265{ 2266 struct ext4_super_block * es; 2267 struct ext4_sb_info *sbi = EXT4_SB(sb); 2268 ext4_fsblk_t n_blocks_count = 0; --- 164 unchanged lines hidden (view full) --- 2433 buf->f_namelen = EXT4_NAME_LEN; 2434 return 0; 2435} 2436 2437/* Helper function for writing quotas on sync - we need to start transaction before quota file 2438 * is locked for write. Otherwise the are possible deadlocks: 2439 * Process 1 Process 2 2440 * ext4_create() quota_sync() | 2261 } 2262} 2263 2264static int ext4_remount (struct super_block * sb, int * flags, char * data) 2265{ 2266 struct ext4_super_block * es; 2267 struct ext4_sb_info *sbi = EXT4_SB(sb); 2268 ext4_fsblk_t n_blocks_count = 0; --- 164 unchanged lines hidden (view full) --- 2433 buf->f_namelen = EXT4_NAME_LEN; 2434 return 0; 2435} 2436 2437/* Helper function for writing quotas on sync - we need to start transaction before quota file 2438 * is locked for write. Otherwise the are possible deadlocks: 2439 * Process 1 Process 2 2440 * ext4_create() quota_sync() |
2441 * journal_start() write_dquot() | 2441 * jbd2_journal_start() write_dquot() |
2442 * DQUOT_INIT() down(dqio_mutex) | 2442 * DQUOT_INIT() down(dqio_mutex) |
2443 * down(dqio_mutex) journal_start() | 2443 * down(dqio_mutex) jbd2_journal_start() |
2444 * 2445 */ 2446 2447#ifdef CONFIG_QUOTA 2448 2449static inline struct inode *dquot_to_inode(struct dquot *dquot) 2450{ 2451 return sb_dqopt(dquot->dq_sb)->files[dquot->dq_type]; --- 303 unchanged lines hidden --- | 2444 * 2445 */ 2446 2447#ifdef CONFIG_QUOTA 2448 2449static inline struct inode *dquot_to_inode(struct dquot *dquot) 2450{ 2451 return sb_dqopt(dquot->dq_sb)->files[dquot->dq_type]; --- 303 unchanged lines hidden --- |