X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Fext3%2Fsuper.c;h=8d6104ba1ec9eef2c48172b2d997991752626528;hb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;hp=4bbb5a078bbb8c781ee9f29794af03b1c02a219f;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 4bbb5a078..8d6104ba1 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -118,8 +118,6 @@ void ext3_journal_abort_handle(const char *caller, const char *err_fn, handle->h_err = err; } -static char error_buf[1024]; - /* Deal with the reporting of failure conditions on a filesystem such as * inconsistencies detected or read IO failures. * @@ -140,7 +138,7 @@ static void ext3_handle_error(struct super_block *sb) struct ext3_super_block *es = EXT3_SB(sb)->s_es; EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; - es->s_state |= cpu_to_le32(EXT3_ERROR_FS); + es->s_state |= cpu_to_le16(EXT3_ERROR_FS); if (sb->s_flags & MS_RDONLY) return; @@ -166,12 +164,11 @@ void ext3_error (struct super_block * sb, const char * function, { va_list args; - va_start (args, fmt); - vsprintf (error_buf, fmt, args); - va_end (args); - - printk (KERN_CRIT "EXT3-fs error (device %s): %s: %s\n", - sb->s_id, function, error_buf); + va_start(args, fmt); + printk(KERN_CRIT "EXT3-fs error (device %s): %s: ",sb->s_id, function); + vprintk(fmt, args); + printk("\n"); + va_end(args); ext3_handle_error(sb); } @@ -240,21 +237,19 @@ void ext3_abort (struct super_block * sb, const char * function, printk (KERN_CRIT "ext3_abort called.\n"); - va_start (args, fmt); - vsprintf (error_buf, fmt, args); - va_end (args); - - if (test_opt (sb, ERRORS_PANIC)) - panic ("EXT3-fs panic (device %s): %s: %s\n", - sb->s_id, function, error_buf); + va_start(args, fmt); + printk(KERN_CRIT "EXT3-fs error (device %s): %s: ",sb->s_id, function); + vprintk(fmt, args); + printk("\n"); + va_end(args); - printk (KERN_CRIT "EXT3-fs abort (device %s): %s: %s\n", - sb->s_id, function, error_buf); + if (test_opt(sb, ERRORS_PANIC)) + panic("EXT3-fs panic from previous error\n"); if (sb->s_flags & MS_RDONLY) return; - printk (KERN_CRIT "Remounting filesystem read-only\n"); + printk(KERN_CRIT "Remounting filesystem read-only\n"); EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; sb->s_flags |= MS_RDONLY; EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT; @@ -272,15 +267,16 @@ NORET_TYPE void ext3_panic (struct super_block * sb, const char * function, { va_list args; - va_start (args, fmt); - vsprintf (error_buf, fmt, args); - va_end (args); + va_start(args, fmt); + printk(KERN_CRIT "EXT3-fs error (device %s): %s: ",sb->s_id, function); + vprintk(fmt, args); + printk("\n"); + va_end(args); /* this is to prevent panic from syncing this filesystem */ /* AKPM: is this sufficient? */ sb->s_flags |= MS_RDONLY; - panic ("EXT3-fs panic (device %s): %s: %s\n", - sb->s_id, function, error_buf); + panic ("EXT3-fs panic forced\n"); } void ext3_warning (struct super_block * sb, const char * function, @@ -288,11 +284,12 @@ void ext3_warning (struct super_block * sb, const char * function, { va_list args; - va_start (args, fmt); - vsprintf (error_buf, fmt, args); - va_end (args); - printk (KERN_WARNING "EXT3-fs warning (device %s): %s: %s\n", - sb->s_id, function, error_buf); + va_start(args, fmt); + printk(KERN_WARNING "EXT3-fs warning (device %s): %s: ", + sb->s_id, function); + vprintk(fmt, args); + printk("\n"); + va_end(args); } void ext3_update_dynamic_rev(struct super_block *sb) @@ -356,7 +353,7 @@ static int ext3_blkdev_remove(struct ext3_sb_info *sbi) bdev = sbi->journal_bdev; if (bdev) { ret = ext3_blkdev_put(bdev); - sbi->journal_bdev = 0; + sbi->journal_bdev = NULL; } return ret; } @@ -380,7 +377,7 @@ static void dump_orphan_list(struct super_block *sb, struct ext3_sb_info *sbi) "inode %s:%ld at %p: mode %o, nlink %d, next %d\n", inode->i_sb->s_id, inode->i_ino, inode, inode->i_mode, inode->i_nlink, - le32_to_cpu(NEXT_ORPHAN(inode))); + NEXT_ORPHAN(inode)); } } @@ -394,7 +391,7 @@ void ext3_put_super (struct super_block * sb) journal_destroy(sbi->s_journal); if (!(sb->s_flags & MS_RDONLY)) { EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); - es->s_state = le16_to_cpu(sbi->s_mount_state); + es->s_state = cpu_to_le16(sbi->s_mount_state); BUFFER_TRACE(sbi->s_sbh, "marking dirty"); mark_buffer_dirty(sbi->s_sbh); ext3_commit_super(sb, es, 1); @@ -480,7 +477,7 @@ static int init_inodecache(void) { ext3_inode_cachep = kmem_cache_create("ext3_inode_cache", sizeof(struct ext3_inode_info), - 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT, + 0, SLAB_RECLAIM_ACCOUNT, init_once, NULL); if (ext3_inode_cachep == NULL) return -ENOMEM; @@ -521,6 +518,8 @@ static void ext3_clear_inode(struct inode *inode) static int ext3_dquot_initialize(struct inode *inode, int type); static int ext3_dquot_drop(struct inode *inode); static int ext3_write_dquot(struct dquot *dquot); +static int ext3_acquire_dquot(struct dquot *dquot); +static int ext3_release_dquot(struct dquot *dquot); static int ext3_mark_dquot_dirty(struct dquot *dquot); static int ext3_write_info(struct super_block *sb, int type); static int ext3_quota_on(struct super_block *sb, int type, int format_id, char *path); @@ -536,6 +535,8 @@ static struct dquot_operations ext3_quota_operations = { .free_inode = dquot_free_inode, .transfer = dquot_transfer, .write_dquot = ext3_write_dquot, + .acquire_dquot = ext3_acquire_dquot, + .release_dquot = ext3_release_dquot, .mark_dirty = ext3_mark_dquot_dirty, .write_info = ext3_write_info }; @@ -583,7 +584,7 @@ enum { Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback, Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, - Opt_ignore, Opt_err, + Opt_tagxid, Opt_barrier, Opt_ignore, Opt_err, }; static match_table_t tokens = { @@ -624,10 +625,12 @@ static match_table_t tokens = { {Opt_grpjquota, "grpjquota=%s"}, {Opt_jqfmt_vfsold, "jqfmt=vfsold"}, {Opt_jqfmt_vfsv0, "jqfmt=vfsv0"}, + {Opt_tagxid, "tagxid"}, {Opt_ignore, "grpquota"}, {Opt_ignore, "noquota"}, {Opt_ignore, "quota"}, {Opt_ignore, "usrquota"}, + {Opt_barrier, "barrier=%u"}, {Opt_err, NULL} }; @@ -717,6 +720,16 @@ static int parse_options (char * options, struct super_block *sb, case Opt_nouid32: set_opt (sbi->s_mount_opt, NO_UID32); break; +#ifndef CONFIG_INOXID_NONE + case Opt_tagxid: + if (is_remount) { + printk(KERN_ERR "EXT3-fs: cannot specify " + "tagxid on remount\n"); + return 0; + } + set_opt (sbi->s_mount_opt, TAG_XID); + break; +#endif case Opt_check: #ifdef CONFIG_EXT3_CHECK set_opt (sbi->s_mount_opt, CHECK); @@ -893,6 +906,14 @@ clear_qf_name: case Opt_abort: set_opt(sbi->s_mount_opt, ABORT); break; + case Opt_barrier: + if (match_int(&args[0], &option)) + return 0; + if (option) + set_opt(sbi->s_mount_opt, BARRIER); + else + clear_opt(sbi->s_mount_opt, BARRIER); + break; case Opt_ignore: break; default: @@ -954,8 +975,7 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es, es->s_state = cpu_to_le16(le16_to_cpu(es->s_state) & ~EXT3_VALID_FS); #endif if (!(__s16) le16_to_cpu(es->s_max_mnt_count)) - es->s_max_mnt_count = - (__s16) cpu_to_le16(EXT3_DFL_MAX_MNT_COUNT); + es->s_max_mnt_count = cpu_to_le16(EXT3_DFL_MAX_MNT_COUNT); es->s_mnt_count=cpu_to_le16(le16_to_cpu(es->s_mnt_count) + 1); es->s_mtime = cpu_to_le32(get_seconds()); ext3_update_dynamic_rev(sb); @@ -1197,7 +1217,7 @@ static unsigned long descriptor_loc(struct super_block *sb, static int ext3_fill_super (struct super_block *sb, void *data, int silent) { struct buffer_head * bh; - struct ext3_super_block *es = 0; + struct ext3_super_block *es = NULL; struct ext3_sb_info *sbi; unsigned long block; unsigned long sb_block = get_sb_block(&data); @@ -1211,6 +1231,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) int db_count; int i; int needs_recovery; + __le32 features; sbi = kmalloc(sizeof(*sbi), GFP_KERNEL); if (!sbi) @@ -1287,6 +1308,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) if (!parse_options ((char *) data, sb, &journal_inum, 0)) goto failed_mount; + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAG_XID) + sb->s_flags |= MS_TAGXID; sb->s_flags |= MS_ONE_SECOND; sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); @@ -1303,17 +1326,18 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) * previously didn't change the revision level when setting the flags, * so there is a chance incompat flags are set on a rev 0 filesystem. */ - if ((i = EXT3_HAS_INCOMPAT_FEATURE(sb, ~EXT3_FEATURE_INCOMPAT_SUPP))) { + features = EXT3_HAS_INCOMPAT_FEATURE(sb, ~EXT3_FEATURE_INCOMPAT_SUPP); + if (features) { printk(KERN_ERR "EXT3-fs: %s: couldn't mount because of " "unsupported optional features (%x).\n", - sb->s_id, i); + sb->s_id, le32_to_cpu(features)); goto failed_mount; } - if (!(sb->s_flags & MS_RDONLY) && - (i = EXT3_HAS_RO_COMPAT_FEATURE(sb, ~EXT3_FEATURE_RO_COMPAT_SUPP))){ + features = EXT3_HAS_RO_COMPAT_FEATURE(sb, ~EXT3_FEATURE_RO_COMPAT_SUPP); + if (!(sb->s_flags & MS_RDONLY) && features) { printk(KERN_ERR "EXT3-fs: %s: couldn't mount RDWR because of " "unsupported optional features (%x).\n", - sb->s_id, i); + sb->s_id, le32_to_cpu(features)); goto failed_mount; } blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size); @@ -1350,7 +1374,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) } es = (struct ext3_super_block *)(((char *)bh->b_data) + offset); sbi->s_es = es; - if (es->s_magic != le16_to_cpu(EXT3_SUPER_MAGIC)) { + if (es->s_magic != cpu_to_le16(EXT3_SUPER_MAGIC)) { printk (KERN_ERR "EXT3-fs: Magic mismatch, very weird !\n"); goto failed_mount; @@ -1469,7 +1493,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) #endif INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */ - sb->s_root = 0; + sb->s_root = NULL; needs_recovery = (es->s_last_orphan != 0 || EXT3_HAS_INCOMPAT_FEATURE(sb, @@ -1595,16 +1619,23 @@ out_fail: * initial mount, once the journal has been initialised but before we've * done any recovery; and again on any subsequent remount. */ -static void ext3_init_journal_params(struct ext3_sb_info *sbi, - journal_t *journal) +static void ext3_init_journal_params(struct super_block *sb, journal_t *journal) { + struct ext3_sb_info *sbi = EXT3_SB(sb); + if (sbi->s_commit_interval) journal->j_commit_interval = sbi->s_commit_interval; /* We could also set up an ext3-specific default for the commit * interval here, but for now we'll just fall back to the jbd * default. */ -} + spin_lock(&journal->j_state_lock); + if (test_opt(sb, BARRIER)) + journal->j_flags |= JFS_BARRIER; + else + journal->j_flags &= ~JFS_BARRIER; + spin_unlock(&journal->j_state_lock); +} static journal_t *ext3_get_journal(struct super_block *sb, int journal_inum) { @@ -1639,9 +1670,10 @@ static journal_t *ext3_get_journal(struct super_block *sb, int journal_inum) if (!journal) { printk(KERN_ERR "EXT3-fs: Could not load journal inode\n"); iput(journal_inode); + return NULL; } journal->j_private = sb; - ext3_init_journal_params(EXT3_SB(sb), journal); + ext3_init_journal_params(sb, journal); return journal; } @@ -1719,14 +1751,14 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb, printk(KERN_ERR "EXT3-fs: I/O error on journal device\n"); goto out_journal; } - if (ntohl(journal->j_superblock->s_nr_users) != 1) { + if (be32_to_cpu(journal->j_superblock->s_nr_users) != 1) { printk(KERN_ERR "EXT3-fs: External journal has more than one " "user (unsupported) - %d\n", - ntohl(journal->j_superblock->s_nr_users)); + be32_to_cpu(journal->j_superblock->s_nr_users)); goto out_journal; } EXT3_SB(sb)->journal_bdev = bdev; - ext3_init_journal_params(EXT3_SB(sb), journal); + ext3_init_journal_params(sb, journal); return journal; out_journal: journal_destroy(journal); @@ -1870,13 +1902,17 @@ static void ext3_commit_super (struct super_block * sb, static void ext3_mark_recovery_complete(struct super_block * sb, struct ext3_super_block * es) { - journal_flush(EXT3_SB(sb)->s_journal); + journal_t *journal = EXT3_SB(sb)->s_journal; + + journal_lock_updates(journal); + journal_flush(journal); if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER) && sb->s_flags & MS_RDONLY) { EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); sb->s_dirt = 0; ext3_commit_super(sb, es, 1); } + journal_unlock_updates(journal); } /* @@ -2019,7 +2055,7 @@ int ext3_remount (struct super_block * sb, int * flags, char * data) es = sbi->s_es; - ext3_init_journal_params(sbi, sbi->s_journal); + ext3_init_journal_params(sb, sbi->s_journal); if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) { if (sbi->s_mount_opt & EXT3_MOUNT_ABORT) @@ -2043,13 +2079,13 @@ int ext3_remount (struct super_block * sb, int * flags, char * data) ext3_mark_recovery_complete(sb, es); } else { - int ret; + __le32 ret; if ((ret = EXT3_HAS_RO_COMPAT_FEATURE(sb, ~EXT3_FEATURE_RO_COMPAT_SUPP))) { printk(KERN_WARNING "EXT3-fs: %s: couldn't " "remount RDWR because of unsupported " "optional features (%x).\n", - sb->s_id, ret); + sb->s_id, le32_to_cpu(ret)); return -EROFS; } /* @@ -2181,6 +2217,38 @@ static int ext3_write_dquot(struct dquot *dquot) return ret; } +static int ext3_acquire_dquot(struct dquot *dquot) +{ + int ret, err; + handle_t *handle; + + handle = ext3_journal_start(dquot_to_inode(dquot), + EXT3_QUOTA_INIT_BLOCKS); + if (IS_ERR(handle)) + return PTR_ERR(handle); + ret = dquot_acquire(dquot); + err = ext3_journal_stop(handle); + if (!ret) + ret = err; + return ret; +} + +static int ext3_release_dquot(struct dquot *dquot) +{ + int ret, err; + handle_t *handle; + + handle = ext3_journal_start(dquot_to_inode(dquot), + EXT3_QUOTA_INIT_BLOCKS); + if (IS_ERR(handle)) + return PTR_ERR(handle); + ret = dquot_release(dquot); + err = ext3_journal_stop(handle); + if (!ret) + ret = err; + return ret; +} + static int ext3_mark_dquot_dirty(struct dquot *dquot) { /* Are we journalling quotas? */