diff options
Diffstat (limited to 'fs/jfs/super.c')
-rw-r--r-- | fs/jfs/super.c | 98 |
1 files changed, 58 insertions, 40 deletions
diff --git a/fs/jfs/super.c b/fs/jfs/super.c index 8d31f1336431..18f69e6aa719 100644 --- a/fs/jfs/super.c +++ b/fs/jfs/super.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/vfs.h> | 25 | #include <linux/vfs.h> |
26 | #include <linux/mount.h> | 26 | #include <linux/mount.h> |
27 | #include <linux/moduleparam.h> | 27 | #include <linux/moduleparam.h> |
28 | #include <linux/kthread.h> | ||
28 | #include <linux/posix_acl.h> | 29 | #include <linux/posix_acl.h> |
29 | #include <asm/uaccess.h> | 30 | #include <asm/uaccess.h> |
30 | #include <linux/seq_file.h> | 31 | #include <linux/seq_file.h> |
@@ -54,11 +55,9 @@ static int commit_threads = 0; | |||
54 | module_param(commit_threads, int, 0); | 55 | module_param(commit_threads, int, 0); |
55 | MODULE_PARM_DESC(commit_threads, "Number of commit threads"); | 56 | MODULE_PARM_DESC(commit_threads, "Number of commit threads"); |
56 | 57 | ||
57 | int jfs_stop_threads; | 58 | static struct task_struct *jfsCommitThread[MAX_COMMIT_THREADS]; |
58 | static pid_t jfsIOthread; | 59 | struct task_struct *jfsIOthread; |
59 | static pid_t jfsCommitThread[MAX_COMMIT_THREADS]; | 60 | struct task_struct *jfsSyncThread; |
60 | static pid_t jfsSyncThread; | ||
61 | DECLARE_COMPLETION(jfsIOwait); | ||
62 | 61 | ||
63 | #ifdef CONFIG_JFS_DEBUG | 62 | #ifdef CONFIG_JFS_DEBUG |
64 | int jfsloglevel = JFS_LOGLEVEL_WARN; | 63 | int jfsloglevel = JFS_LOGLEVEL_WARN; |
@@ -195,7 +194,7 @@ static void jfs_put_super(struct super_block *sb) | |||
195 | enum { | 194 | enum { |
196 | Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize, | 195 | Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize, |
197 | Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota, | 196 | Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota, |
198 | Opt_usrquota, Opt_grpquota | 197 | Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask |
199 | }; | 198 | }; |
200 | 199 | ||
201 | static match_table_t tokens = { | 200 | static match_table_t tokens = { |
@@ -209,6 +208,9 @@ static match_table_t tokens = { | |||
209 | {Opt_ignore, "quota"}, | 208 | {Opt_ignore, "quota"}, |
210 | {Opt_usrquota, "usrquota"}, | 209 | {Opt_usrquota, "usrquota"}, |
211 | {Opt_grpquota, "grpquota"}, | 210 | {Opt_grpquota, "grpquota"}, |
211 | {Opt_uid, "uid=%u"}, | ||
212 | {Opt_gid, "gid=%u"}, | ||
213 | {Opt_umask, "umask=%u"}, | ||
212 | {Opt_err, NULL} | 214 | {Opt_err, NULL} |
213 | }; | 215 | }; |
214 | 216 | ||
@@ -313,7 +315,29 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize, | |||
313 | "JFS: quota operations not supported\n"); | 315 | "JFS: quota operations not supported\n"); |
314 | break; | 316 | break; |
315 | #endif | 317 | #endif |
316 | 318 | case Opt_uid: | |
319 | { | ||
320 | char *uid = args[0].from; | ||
321 | sbi->uid = simple_strtoul(uid, &uid, 0); | ||
322 | break; | ||
323 | } | ||
324 | case Opt_gid: | ||
325 | { | ||
326 | char *gid = args[0].from; | ||
327 | sbi->gid = simple_strtoul(gid, &gid, 0); | ||
328 | break; | ||
329 | } | ||
330 | case Opt_umask: | ||
331 | { | ||
332 | char *umask = args[0].from; | ||
333 | sbi->umask = simple_strtoul(umask, &umask, 8); | ||
334 | if (sbi->umask & ~0777) { | ||
335 | printk(KERN_ERR | ||
336 | "JFS: Invalid value of umask\n"); | ||
337 | goto cleanup; | ||
338 | } | ||
339 | break; | ||
340 | } | ||
317 | default: | 341 | default: |
318 | printk("jfs: Unrecognized mount option \"%s\" " | 342 | printk("jfs: Unrecognized mount option \"%s\" " |
319 | " or missing value\n", p); | 343 | " or missing value\n", p); |
@@ -396,12 +420,12 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent) | |||
396 | if (!new_valid_dev(sb->s_bdev->bd_dev)) | 420 | if (!new_valid_dev(sb->s_bdev->bd_dev)) |
397 | return -EOVERFLOW; | 421 | return -EOVERFLOW; |
398 | 422 | ||
399 | sbi = kmalloc(sizeof (struct jfs_sb_info), GFP_KERNEL); | 423 | sbi = kzalloc(sizeof (struct jfs_sb_info), GFP_KERNEL); |
400 | if (!sbi) | 424 | if (!sbi) |
401 | return -ENOSPC; | 425 | return -ENOSPC; |
402 | memset(sbi, 0, sizeof (struct jfs_sb_info)); | ||
403 | sb->s_fs_info = sbi; | 426 | sb->s_fs_info = sbi; |
404 | sbi->sb = sb; | 427 | sbi->sb = sb; |
428 | sbi->uid = sbi->gid = sbi->umask = -1; | ||
405 | 429 | ||
406 | /* initialize the mount flag and determine the default error handler */ | 430 | /* initialize the mount flag and determine the default error handler */ |
407 | flag = JFS_ERR_REMOUNT_RO; | 431 | flag = JFS_ERR_REMOUNT_RO; |
@@ -564,10 +588,14 @@ static int jfs_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
564 | { | 588 | { |
565 | struct jfs_sb_info *sbi = JFS_SBI(vfs->mnt_sb); | 589 | struct jfs_sb_info *sbi = JFS_SBI(vfs->mnt_sb); |
566 | 590 | ||
591 | if (sbi->uid != -1) | ||
592 | seq_printf(seq, ",uid=%d", sbi->uid); | ||
593 | if (sbi->gid != -1) | ||
594 | seq_printf(seq, ",gid=%d", sbi->gid); | ||
595 | if (sbi->umask != -1) | ||
596 | seq_printf(seq, ",umask=%03o", sbi->umask); | ||
567 | if (sbi->flag & JFS_NOINTEGRITY) | 597 | if (sbi->flag & JFS_NOINTEGRITY) |
568 | seq_puts(seq, ",nointegrity"); | 598 | seq_puts(seq, ",nointegrity"); |
569 | else | ||
570 | seq_puts(seq, ",integrity"); | ||
571 | 599 | ||
572 | #if defined(CONFIG_QUOTA) | 600 | #if defined(CONFIG_QUOTA) |
573 | if (sbi->flag & JFS_USRQUOTA) | 601 | if (sbi->flag & JFS_USRQUOTA) |
@@ -617,7 +645,7 @@ static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags) | |||
617 | memset(jfs_ip, 0, sizeof(struct jfs_inode_info)); | 645 | memset(jfs_ip, 0, sizeof(struct jfs_inode_info)); |
618 | INIT_LIST_HEAD(&jfs_ip->anon_inode_list); | 646 | INIT_LIST_HEAD(&jfs_ip->anon_inode_list); |
619 | init_rwsem(&jfs_ip->rdwrlock); | 647 | init_rwsem(&jfs_ip->rdwrlock); |
620 | init_MUTEX(&jfs_ip->commit_sem); | 648 | mutex_init(&jfs_ip->commit_mutex); |
621 | init_rwsem(&jfs_ip->xattr_sem); | 649 | init_rwsem(&jfs_ip->xattr_sem); |
622 | spin_lock_init(&jfs_ip->ag_lock); | 650 | spin_lock_init(&jfs_ip->ag_lock); |
623 | jfs_ip->active_ag = -1; | 651 | jfs_ip->active_ag = -1; |
@@ -661,12 +689,12 @@ static int __init init_jfs_fs(void) | |||
661 | /* | 689 | /* |
662 | * I/O completion thread (endio) | 690 | * I/O completion thread (endio) |
663 | */ | 691 | */ |
664 | jfsIOthread = kernel_thread(jfsIOWait, NULL, CLONE_KERNEL); | 692 | jfsIOthread = kthread_run(jfsIOWait, NULL, "jfsIO"); |
665 | if (jfsIOthread < 0) { | 693 | if (IS_ERR(jfsIOthread)) { |
666 | jfs_err("init_jfs_fs: fork failed w/rc = %d", jfsIOthread); | 694 | rc = PTR_ERR(jfsIOthread); |
695 | jfs_err("init_jfs_fs: fork failed w/rc = %d", rc); | ||
667 | goto end_txmngr; | 696 | goto end_txmngr; |
668 | } | 697 | } |
669 | wait_for_completion(&jfsIOwait); /* Wait until thread starts */ | ||
670 | 698 | ||
671 | if (commit_threads < 1) | 699 | if (commit_threads < 1) |
672 | commit_threads = num_online_cpus(); | 700 | commit_threads = num_online_cpus(); |
@@ -674,24 +702,21 @@ static int __init init_jfs_fs(void) | |||
674 | commit_threads = MAX_COMMIT_THREADS; | 702 | commit_threads = MAX_COMMIT_THREADS; |
675 | 703 | ||
676 | for (i = 0; i < commit_threads; i++) { | 704 | for (i = 0; i < commit_threads; i++) { |
677 | jfsCommitThread[i] = kernel_thread(jfs_lazycommit, NULL, | 705 | jfsCommitThread[i] = kthread_run(jfs_lazycommit, NULL, "jfsCommit"); |
678 | CLONE_KERNEL); | 706 | if (IS_ERR(jfsCommitThread[i])) { |
679 | if (jfsCommitThread[i] < 0) { | 707 | rc = PTR_ERR(jfsCommitThread[i]); |
680 | jfs_err("init_jfs_fs: fork failed w/rc = %d", | 708 | jfs_err("init_jfs_fs: fork failed w/rc = %d", rc); |
681 | jfsCommitThread[i]); | ||
682 | commit_threads = i; | 709 | commit_threads = i; |
683 | goto kill_committask; | 710 | goto kill_committask; |
684 | } | 711 | } |
685 | /* Wait until thread starts */ | ||
686 | wait_for_completion(&jfsIOwait); | ||
687 | } | 712 | } |
688 | 713 | ||
689 | jfsSyncThread = kernel_thread(jfs_sync, NULL, CLONE_KERNEL); | 714 | jfsSyncThread = kthread_run(jfs_sync, NULL, "jfsSync"); |
690 | if (jfsSyncThread < 0) { | 715 | if (IS_ERR(jfsSyncThread)) { |
691 | jfs_err("init_jfs_fs: fork failed w/rc = %d", jfsSyncThread); | 716 | rc = PTR_ERR(jfsSyncThread); |
717 | jfs_err("init_jfs_fs: fork failed w/rc = %d", rc); | ||
692 | goto kill_committask; | 718 | goto kill_committask; |
693 | } | 719 | } |
694 | wait_for_completion(&jfsIOwait); /* Wait until thread starts */ | ||
695 | 720 | ||
696 | #ifdef PROC_FS_JFS | 721 | #ifdef PROC_FS_JFS |
697 | jfs_proc_init(); | 722 | jfs_proc_init(); |
@@ -700,13 +725,9 @@ static int __init init_jfs_fs(void) | |||
700 | return register_filesystem(&jfs_fs_type); | 725 | return register_filesystem(&jfs_fs_type); |
701 | 726 | ||
702 | kill_committask: | 727 | kill_committask: |
703 | jfs_stop_threads = 1; | ||
704 | wake_up_all(&jfs_commit_thread_wait); | ||
705 | for (i = 0; i < commit_threads; i++) | 728 | for (i = 0; i < commit_threads; i++) |
706 | wait_for_completion(&jfsIOwait); | 729 | kthread_stop(jfsCommitThread[i]); |
707 | 730 | kthread_stop(jfsIOthread); | |
708 | wake_up(&jfs_IO_thread_wait); | ||
709 | wait_for_completion(&jfsIOwait); /* Wait for thread exit */ | ||
710 | end_txmngr: | 731 | end_txmngr: |
711 | txExit(); | 732 | txExit(); |
712 | free_metapage: | 733 | free_metapage: |
@@ -722,16 +743,13 @@ static void __exit exit_jfs_fs(void) | |||
722 | 743 | ||
723 | jfs_info("exit_jfs_fs called"); | 744 | jfs_info("exit_jfs_fs called"); |
724 | 745 | ||
725 | jfs_stop_threads = 1; | ||
726 | txExit(); | 746 | txExit(); |
727 | metapage_exit(); | 747 | metapage_exit(); |
728 | wake_up(&jfs_IO_thread_wait); | 748 | |
729 | wait_for_completion(&jfsIOwait); /* Wait until IO thread exits */ | 749 | kthread_stop(jfsIOthread); |
730 | wake_up_all(&jfs_commit_thread_wait); | ||
731 | for (i = 0; i < commit_threads; i++) | 750 | for (i = 0; i < commit_threads; i++) |
732 | wait_for_completion(&jfsIOwait); | 751 | kthread_stop(jfsCommitThread[i]); |
733 | wake_up(&jfs_sync_thread_wait); | 752 | kthread_stop(jfsSyncThread); |
734 | wait_for_completion(&jfsIOwait); /* Wait until Sync thread exits */ | ||
735 | #ifdef PROC_FS_JFS | 753 | #ifdef PROC_FS_JFS |
736 | jfs_proc_clean(); | 754 | jfs_proc_clean(); |
737 | #endif | 755 | #endif |