diff options
Diffstat (limited to 'fs/reiserfs/super.c')
-rw-r--r-- | fs/reiserfs/super.c | 76 |
1 files changed, 48 insertions, 28 deletions
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index f0ad05f38022..59125fb36d42 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c | |||
@@ -12,6 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/slab.h> | ||
15 | #include <linux/vmalloc.h> | 16 | #include <linux/vmalloc.h> |
16 | #include <linux/time.h> | 17 | #include <linux/time.h> |
17 | #include <asm/uaccess.h> | 18 | #include <asm/uaccess.h> |
@@ -246,7 +247,7 @@ static int finish_unfinished(struct super_block *s) | |||
246 | retval = remove_save_link_only(s, &save_link_key, 0); | 247 | retval = remove_save_link_only(s, &save_link_key, 0); |
247 | continue; | 248 | continue; |
248 | } | 249 | } |
249 | vfs_dq_init(inode); | 250 | dquot_initialize(inode); |
250 | 251 | ||
251 | if (truncate && S_ISDIR(inode->i_mode)) { | 252 | if (truncate && S_ISDIR(inode->i_mode)) { |
252 | /* We got a truncate request for a dir which is impossible. | 253 | /* We got a truncate request for a dir which is impossible. |
@@ -465,7 +466,7 @@ static void reiserfs_put_super(struct super_block *s) | |||
465 | struct reiserfs_transaction_handle th; | 466 | struct reiserfs_transaction_handle th; |
466 | th.t_trans_id = 0; | 467 | th.t_trans_id = 0; |
467 | 468 | ||
468 | lock_kernel(); | 469 | reiserfs_write_lock(s); |
469 | 470 | ||
470 | if (s->s_dirt) | 471 | if (s->s_dirt) |
471 | reiserfs_write_super(s); | 472 | reiserfs_write_super(s); |
@@ -499,10 +500,10 @@ static void reiserfs_put_super(struct super_block *s) | |||
499 | 500 | ||
500 | reiserfs_proc_info_done(s); | 501 | reiserfs_proc_info_done(s); |
501 | 502 | ||
503 | reiserfs_write_unlock(s); | ||
504 | mutex_destroy(&REISERFS_SB(s)->lock); | ||
502 | kfree(s->s_fs_info); | 505 | kfree(s->s_fs_info); |
503 | s->s_fs_info = NULL; | 506 | s->s_fs_info = NULL; |
504 | |||
505 | unlock_kernel(); | ||
506 | } | 507 | } |
507 | 508 | ||
508 | static struct kmem_cache *reiserfs_inode_cachep; | 509 | static struct kmem_cache *reiserfs_inode_cachep; |
@@ -554,25 +555,33 @@ static void reiserfs_dirty_inode(struct inode *inode) | |||
554 | struct reiserfs_transaction_handle th; | 555 | struct reiserfs_transaction_handle th; |
555 | 556 | ||
556 | int err = 0; | 557 | int err = 0; |
558 | int lock_depth; | ||
559 | |||
557 | if (inode->i_sb->s_flags & MS_RDONLY) { | 560 | if (inode->i_sb->s_flags & MS_RDONLY) { |
558 | reiserfs_warning(inode->i_sb, "clm-6006", | 561 | reiserfs_warning(inode->i_sb, "clm-6006", |
559 | "writing inode %lu on readonly FS", | 562 | "writing inode %lu on readonly FS", |
560 | inode->i_ino); | 563 | inode->i_ino); |
561 | return; | 564 | return; |
562 | } | 565 | } |
563 | reiserfs_write_lock(inode->i_sb); | 566 | lock_depth = reiserfs_write_lock_once(inode->i_sb); |
564 | 567 | ||
565 | /* this is really only used for atime updates, so they don't have | 568 | /* this is really only used for atime updates, so they don't have |
566 | ** to be included in O_SYNC or fsync | 569 | ** to be included in O_SYNC or fsync |
567 | */ | 570 | */ |
568 | err = journal_begin(&th, inode->i_sb, 1); | 571 | err = journal_begin(&th, inode->i_sb, 1); |
569 | if (err) { | 572 | if (err) |
570 | reiserfs_write_unlock(inode->i_sb); | 573 | goto out; |
571 | return; | 574 | |
572 | } | ||
573 | reiserfs_update_sd(&th, inode); | 575 | reiserfs_update_sd(&th, inode); |
574 | journal_end(&th, inode->i_sb, 1); | 576 | journal_end(&th, inode->i_sb, 1); |
575 | reiserfs_write_unlock(inode->i_sb); | 577 | |
578 | out: | ||
579 | reiserfs_write_unlock_once(inode->i_sb, lock_depth); | ||
580 | } | ||
581 | |||
582 | static void reiserfs_clear_inode(struct inode *inode) | ||
583 | { | ||
584 | dquot_drop(inode); | ||
576 | } | 585 | } |
577 | 586 | ||
578 | #ifdef CONFIG_QUOTA | 587 | #ifdef CONFIG_QUOTA |
@@ -587,6 +596,7 @@ static const struct super_operations reiserfs_sops = { | |||
587 | .destroy_inode = reiserfs_destroy_inode, | 596 | .destroy_inode = reiserfs_destroy_inode, |
588 | .write_inode = reiserfs_write_inode, | 597 | .write_inode = reiserfs_write_inode, |
589 | .dirty_inode = reiserfs_dirty_inode, | 598 | .dirty_inode = reiserfs_dirty_inode, |
599 | .clear_inode = reiserfs_clear_inode, | ||
590 | .delete_inode = reiserfs_delete_inode, | 600 | .delete_inode = reiserfs_delete_inode, |
591 | .put_super = reiserfs_put_super, | 601 | .put_super = reiserfs_put_super, |
592 | .write_super = reiserfs_write_super, | 602 | .write_super = reiserfs_write_super, |
@@ -613,13 +623,6 @@ static int reiserfs_write_info(struct super_block *, int); | |||
613 | static int reiserfs_quota_on(struct super_block *, int, int, char *, int); | 623 | static int reiserfs_quota_on(struct super_block *, int, int, char *, int); |
614 | 624 | ||
615 | static const struct dquot_operations reiserfs_quota_operations = { | 625 | static const struct dquot_operations reiserfs_quota_operations = { |
616 | .initialize = dquot_initialize, | ||
617 | .drop = dquot_drop, | ||
618 | .alloc_space = dquot_alloc_space, | ||
619 | .alloc_inode = dquot_alloc_inode, | ||
620 | .free_space = dquot_free_space, | ||
621 | .free_inode = dquot_free_inode, | ||
622 | .transfer = dquot_transfer, | ||
623 | .write_dquot = reiserfs_write_dquot, | 626 | .write_dquot = reiserfs_write_dquot, |
624 | .acquire_dquot = reiserfs_acquire_dquot, | 627 | .acquire_dquot = reiserfs_acquire_dquot, |
625 | .release_dquot = reiserfs_release_dquot, | 628 | .release_dquot = reiserfs_release_dquot, |
@@ -1168,11 +1171,14 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg) | |||
1168 | unsigned int qfmt = 0; | 1171 | unsigned int qfmt = 0; |
1169 | #ifdef CONFIG_QUOTA | 1172 | #ifdef CONFIG_QUOTA |
1170 | int i; | 1173 | int i; |
1174 | #endif | ||
1175 | |||
1176 | reiserfs_write_lock(s); | ||
1171 | 1177 | ||
1178 | #ifdef CONFIG_QUOTA | ||
1172 | memcpy(qf_names, REISERFS_SB(s)->s_qf_names, sizeof(qf_names)); | 1179 | memcpy(qf_names, REISERFS_SB(s)->s_qf_names, sizeof(qf_names)); |
1173 | #endif | 1180 | #endif |
1174 | 1181 | ||
1175 | lock_kernel(); | ||
1176 | rs = SB_DISK_SUPER_BLOCK(s); | 1182 | rs = SB_DISK_SUPER_BLOCK(s); |
1177 | 1183 | ||
1178 | if (!reiserfs_parse_options | 1184 | if (!reiserfs_parse_options |
@@ -1295,12 +1301,12 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg) | |||
1295 | 1301 | ||
1296 | out_ok: | 1302 | out_ok: |
1297 | replace_mount_options(s, new_opts); | 1303 | replace_mount_options(s, new_opts); |
1298 | unlock_kernel(); | 1304 | reiserfs_write_unlock(s); |
1299 | return 0; | 1305 | return 0; |
1300 | 1306 | ||
1301 | out_err: | 1307 | out_err: |
1302 | kfree(new_opts); | 1308 | kfree(new_opts); |
1303 | unlock_kernel(); | 1309 | reiserfs_write_unlock(s); |
1304 | return err; | 1310 | return err; |
1305 | } | 1311 | } |
1306 | 1312 | ||
@@ -1404,7 +1410,9 @@ static int read_super_block(struct super_block *s, int offset) | |||
1404 | static int reread_meta_blocks(struct super_block *s) | 1410 | static int reread_meta_blocks(struct super_block *s) |
1405 | { | 1411 | { |
1406 | ll_rw_block(READ, 1, &(SB_BUFFER_WITH_SB(s))); | 1412 | ll_rw_block(READ, 1, &(SB_BUFFER_WITH_SB(s))); |
1413 | reiserfs_write_unlock(s); | ||
1407 | wait_on_buffer(SB_BUFFER_WITH_SB(s)); | 1414 | wait_on_buffer(SB_BUFFER_WITH_SB(s)); |
1415 | reiserfs_write_lock(s); | ||
1408 | if (!buffer_uptodate(SB_BUFFER_WITH_SB(s))) { | 1416 | if (!buffer_uptodate(SB_BUFFER_WITH_SB(s))) { |
1409 | reiserfs_warning(s, "reiserfs-2504", "error reading the super"); | 1417 | reiserfs_warning(s, "reiserfs-2504", "error reading the super"); |
1410 | return 1; | 1418 | return 1; |
@@ -1611,10 +1619,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) | |||
1611 | save_mount_options(s, data); | 1619 | save_mount_options(s, data); |
1612 | 1620 | ||
1613 | sbi = kzalloc(sizeof(struct reiserfs_sb_info), GFP_KERNEL); | 1621 | sbi = kzalloc(sizeof(struct reiserfs_sb_info), GFP_KERNEL); |
1614 | if (!sbi) { | 1622 | if (!sbi) |
1615 | errval = -ENOMEM; | 1623 | return -ENOMEM; |
1616 | goto error; | ||
1617 | } | ||
1618 | s->s_fs_info = sbi; | 1624 | s->s_fs_info = sbi; |
1619 | /* Set default values for options: non-aggressive tails, RO on errors */ | 1625 | /* Set default values for options: non-aggressive tails, RO on errors */ |
1620 | REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_SMALLTAIL); | 1626 | REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_SMALLTAIL); |
@@ -1627,6 +1633,20 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) | |||
1627 | /* setup default block allocator options */ | 1633 | /* setup default block allocator options */ |
1628 | reiserfs_init_alloc_options(s); | 1634 | reiserfs_init_alloc_options(s); |
1629 | 1635 | ||
1636 | mutex_init(&REISERFS_SB(s)->lock); | ||
1637 | REISERFS_SB(s)->lock_depth = -1; | ||
1638 | |||
1639 | /* | ||
1640 | * This function is called with the bkl, which also was the old | ||
1641 | * locking used here. | ||
1642 | * do_journal_begin() will soon check if we hold the lock (ie: was the | ||
1643 | * bkl). This is likely because do_journal_begin() has several another | ||
1644 | * callers because at this time, it doesn't seem to be necessary to | ||
1645 | * protect against anything. | ||
1646 | * Anyway, let's be conservative and lock for now. | ||
1647 | */ | ||
1648 | reiserfs_write_lock(s); | ||
1649 | |||
1630 | jdev_name = NULL; | 1650 | jdev_name = NULL; |
1631 | if (reiserfs_parse_options | 1651 | if (reiserfs_parse_options |
1632 | (s, (char *)data, &(sbi->s_mount_opt), &blocks, &jdev_name, | 1652 | (s, (char *)data, &(sbi->s_mount_opt), &blocks, &jdev_name, |
@@ -1852,6 +1872,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) | |||
1852 | init_waitqueue_head(&(sbi->s_wait)); | 1872 | init_waitqueue_head(&(sbi->s_wait)); |
1853 | spin_lock_init(&sbi->bitmap_lock); | 1873 | spin_lock_init(&sbi->bitmap_lock); |
1854 | 1874 | ||
1875 | reiserfs_write_unlock(s); | ||
1876 | |||
1855 | return (0); | 1877 | return (0); |
1856 | 1878 | ||
1857 | error: | 1879 | error: |
@@ -1859,6 +1881,8 @@ error: | |||
1859 | journal_release_error(NULL, s); | 1881 | journal_release_error(NULL, s); |
1860 | } | 1882 | } |
1861 | 1883 | ||
1884 | reiserfs_write_unlock(s); | ||
1885 | |||
1862 | reiserfs_free_bitmap_cache(s); | 1886 | reiserfs_free_bitmap_cache(s); |
1863 | if (SB_BUFFER_WITH_SB(s)) | 1887 | if (SB_BUFFER_WITH_SB(s)) |
1864 | brelse(SB_BUFFER_WITH_SB(s)); | 1888 | brelse(SB_BUFFER_WITH_SB(s)); |
@@ -2196,8 +2220,6 @@ static int __init init_reiserfs_fs(void) | |||
2196 | } | 2220 | } |
2197 | 2221 | ||
2198 | reiserfs_proc_info_global_init(); | 2222 | reiserfs_proc_info_global_init(); |
2199 | reiserfs_proc_register_global("version", | ||
2200 | reiserfs_global_version_in_proc); | ||
2201 | 2223 | ||
2202 | ret = register_filesystem(&reiserfs_fs_type); | 2224 | ret = register_filesystem(&reiserfs_fs_type); |
2203 | 2225 | ||
@@ -2205,7 +2227,6 @@ static int __init init_reiserfs_fs(void) | |||
2205 | return 0; | 2227 | return 0; |
2206 | } | 2228 | } |
2207 | 2229 | ||
2208 | reiserfs_proc_unregister_global("version"); | ||
2209 | reiserfs_proc_info_global_done(); | 2230 | reiserfs_proc_info_global_done(); |
2210 | destroy_inodecache(); | 2231 | destroy_inodecache(); |
2211 | 2232 | ||
@@ -2214,7 +2235,6 @@ static int __init init_reiserfs_fs(void) | |||
2214 | 2235 | ||
2215 | static void __exit exit_reiserfs_fs(void) | 2236 | static void __exit exit_reiserfs_fs(void) |
2216 | { | 2237 | { |
2217 | reiserfs_proc_unregister_global("version"); | ||
2218 | reiserfs_proc_info_global_done(); | 2238 | reiserfs_proc_info_global_done(); |
2219 | unregister_filesystem(&reiserfs_fs_type); | 2239 | unregister_filesystem(&reiserfs_fs_type); |
2220 | destroy_inodecache(); | 2240 | destroy_inodecache(); |