aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jfs/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jfs/super.c')
-rw-r--r--fs/jfs/super.c77
1 files changed, 43 insertions, 34 deletions
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 97f7fda51890..adf8cb045b9e 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -50,14 +50,14 @@ MODULE_DESCRIPTION("The Journaled Filesystem (JFS)");
50MODULE_AUTHOR("Steve Best/Dave Kleikamp/Barry Arndt, IBM"); 50MODULE_AUTHOR("Steve Best/Dave Kleikamp/Barry Arndt, IBM");
51MODULE_LICENSE("GPL"); 51MODULE_LICENSE("GPL");
52 52
53static struct kmem_cache * jfs_inode_cachep; 53static struct kmem_cache *jfs_inode_cachep;
54 54
55static const struct super_operations jfs_super_operations; 55static const struct super_operations jfs_super_operations;
56static const struct export_operations jfs_export_operations; 56static const struct export_operations jfs_export_operations;
57static struct file_system_type jfs_fs_type; 57static struct file_system_type jfs_fs_type;
58 58
59#define MAX_COMMIT_THREADS 64 59#define MAX_COMMIT_THREADS 64
60static int commit_threads = 0; 60static int commit_threads;
61module_param(commit_threads, int, 0); 61module_param(commit_threads, int, 0);
62MODULE_PARM_DESC(commit_threads, "Number of commit threads"); 62MODULE_PARM_DESC(commit_threads, "Number of commit threads");
63 63
@@ -84,8 +84,7 @@ static void jfs_handle_error(struct super_block *sb)
84 panic("JFS (device %s): panic forced after error\n", 84 panic("JFS (device %s): panic forced after error\n",
85 sb->s_id); 85 sb->s_id);
86 else if (sbi->flag & JFS_ERR_REMOUNT_RO) { 86 else if (sbi->flag & JFS_ERR_REMOUNT_RO) {
87 jfs_err("ERROR: (device %s): remounting filesystem " 87 jfs_err("ERROR: (device %s): remounting filesystem as read-only\n",
88 "as read-only\n",
89 sb->s_id); 88 sb->s_id);
90 sb->s_flags |= MS_RDONLY; 89 sb->s_flags |= MS_RDONLY;
91 } 90 }
@@ -273,7 +272,10 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
273 case Opt_resize: 272 case Opt_resize:
274 { 273 {
275 char *resize = args[0].from; 274 char *resize = args[0].from;
276 *newLVSize = simple_strtoull(resize, &resize, 0); 275 int rc = kstrtoll(resize, 0, newLVSize);
276
277 if (rc)
278 goto cleanup;
277 break; 279 break;
278 } 280 }
279 case Opt_resize_nosize: 281 case Opt_resize_nosize:
@@ -327,7 +329,11 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
327 case Opt_uid: 329 case Opt_uid:
328 { 330 {
329 char *uid = args[0].from; 331 char *uid = args[0].from;
330 uid_t val = simple_strtoul(uid, &uid, 0); 332 uid_t val;
333 int rc = kstrtouint(uid, 0, &val);
334
335 if (rc)
336 goto cleanup;
331 sbi->uid = make_kuid(current_user_ns(), val); 337 sbi->uid = make_kuid(current_user_ns(), val);
332 if (!uid_valid(sbi->uid)) 338 if (!uid_valid(sbi->uid))
333 goto cleanup; 339 goto cleanup;
@@ -337,7 +343,11 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
337 case Opt_gid: 343 case Opt_gid:
338 { 344 {
339 char *gid = args[0].from; 345 char *gid = args[0].from;
340 gid_t val = simple_strtoul(gid, &gid, 0); 346 gid_t val;
347 int rc = kstrtouint(gid, 0, &val);
348
349 if (rc)
350 goto cleanup;
341 sbi->gid = make_kgid(current_user_ns(), val); 351 sbi->gid = make_kgid(current_user_ns(), val);
342 if (!gid_valid(sbi->gid)) 352 if (!gid_valid(sbi->gid))
343 goto cleanup; 353 goto cleanup;
@@ -347,7 +357,10 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
347 case Opt_umask: 357 case Opt_umask:
348 { 358 {
349 char *umask = args[0].from; 359 char *umask = args[0].from;
350 sbi->umask = simple_strtoul(umask, &umask, 8); 360 int rc = kstrtouint(umask, 8, &sbi->umask);
361
362 if (rc)
363 goto cleanup;
351 if (sbi->umask & ~0777) { 364 if (sbi->umask & ~0777) {
352 pr_err("JFS: Invalid value of umask\n"); 365 pr_err("JFS: Invalid value of umask\n");
353 goto cleanup; 366 goto cleanup;
@@ -363,12 +376,10 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
363 * -> user has more control over the online trimming 376 * -> user has more control over the online trimming
364 */ 377 */
365 sbi->minblks_trim = 64; 378 sbi->minblks_trim = 64;
366 if (blk_queue_discard(q)) { 379 if (blk_queue_discard(q))
367 *flag |= JFS_DISCARD; 380 *flag |= JFS_DISCARD;
368 } else { 381 else
369 pr_err("JFS: discard option " \ 382 pr_err("JFS: discard option not supported on device\n");
370 "not supported on device\n");
371 }
372 break; 383 break;
373 } 384 }
374 385
@@ -380,20 +391,21 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
380 { 391 {
381 struct request_queue *q = bdev_get_queue(sb->s_bdev); 392 struct request_queue *q = bdev_get_queue(sb->s_bdev);
382 char *minblks_trim = args[0].from; 393 char *minblks_trim = args[0].from;
394 int rc;
383 if (blk_queue_discard(q)) { 395 if (blk_queue_discard(q)) {
384 *flag |= JFS_DISCARD; 396 *flag |= JFS_DISCARD;
385 sbi->minblks_trim = simple_strtoull( 397 rc = kstrtouint(minblks_trim, 0,
386 minblks_trim, &minblks_trim, 0); 398 &sbi->minblks_trim);
387 } else { 399 if (rc)
388 pr_err("JFS: discard option " \ 400 goto cleanup;
389 "not supported on device\n"); 401 } else
390 } 402 pr_err("JFS: discard option not supported on device\n");
391 break; 403 break;
392 } 404 }
393 405
394 default: 406 default:
395 printk("jfs: Unrecognized mount option \"%s\" " 407 printk("jfs: Unrecognized mount option \"%s\" or missing value\n",
396 " or missing value\n", p); 408 p);
397 goto cleanup; 409 goto cleanup;
398 } 410 }
399 } 411 }
@@ -419,14 +431,12 @@ static int jfs_remount(struct super_block *sb, int *flags, char *data)
419 int ret; 431 int ret;
420 432
421 sync_filesystem(sb); 433 sync_filesystem(sb);
422 if (!parse_options(data, sb, &newLVSize, &flag)) { 434 if (!parse_options(data, sb, &newLVSize, &flag))
423 return -EINVAL; 435 return -EINVAL;
424 }
425 436
426 if (newLVSize) { 437 if (newLVSize) {
427 if (sb->s_flags & MS_RDONLY) { 438 if (sb->s_flags & MS_RDONLY) {
428 pr_err("JFS: resize requires volume" \ 439 pr_err("JFS: resize requires volume to be mounted read-write\n");
429 " to be mounted read-write\n");
430 return -EROFS; 440 return -EROFS;
431 } 441 }
432 rc = jfs_extendfs(sb, newLVSize, 0); 442 rc = jfs_extendfs(sb, newLVSize, 0);
@@ -452,9 +462,8 @@ static int jfs_remount(struct super_block *sb, int *flags, char *data)
452 } 462 }
453 if ((!(sb->s_flags & MS_RDONLY)) && (*flags & MS_RDONLY)) { 463 if ((!(sb->s_flags & MS_RDONLY)) && (*flags & MS_RDONLY)) {
454 rc = dquot_suspend(sb, -1); 464 rc = dquot_suspend(sb, -1);
455 if (rc < 0) { 465 if (rc < 0)
456 return rc; 466 return rc;
457 }
458 rc = jfs_umount_rw(sb); 467 rc = jfs_umount_rw(sb);
459 JFS_SBI(sb)->flag = flag; 468 JFS_SBI(sb)->flag = flag;
460 return rc; 469 return rc;
@@ -487,7 +496,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
487 if (!new_valid_dev(sb->s_bdev->bd_dev)) 496 if (!new_valid_dev(sb->s_bdev->bd_dev))
488 return -EOVERFLOW; 497 return -EOVERFLOW;
489 498
490 sbi = kzalloc(sizeof (struct jfs_sb_info), GFP_KERNEL); 499 sbi = kzalloc(sizeof(struct jfs_sb_info), GFP_KERNEL);
491 if (!sbi) 500 if (!sbi)
492 return -ENOMEM; 501 return -ENOMEM;
493 502
@@ -548,9 +557,8 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
548 557
549 rc = jfs_mount(sb); 558 rc = jfs_mount(sb);
550 if (rc) { 559 if (rc) {
551 if (!silent) { 560 if (!silent)
552 jfs_err("jfs_mount failed w/return code = %d", rc); 561 jfs_err("jfs_mount failed w/return code = %d", rc);
553 }
554 goto out_mount_failed; 562 goto out_mount_failed;
555 } 563 }
556 if (sb->s_flags & MS_RDONLY) 564 if (sb->s_flags & MS_RDONLY)
@@ -587,7 +595,8 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
587 * Page cache is indexed by long. 595 * Page cache is indexed by long.
588 * I would use MAX_LFS_FILESIZE, but it's only half as big 596 * I would use MAX_LFS_FILESIZE, but it's only half as big
589 */ 597 */
590 sb->s_maxbytes = min(((u64) PAGE_CACHE_SIZE << 32) - 1, (u64)sb->s_maxbytes); 598 sb->s_maxbytes = min(((u64) PAGE_CACHE_SIZE << 32) - 1,
599 (u64)sb->s_maxbytes);
591#endif 600#endif
592 sb->s_time_gran = 1; 601 sb->s_time_gran = 1;
593 return 0; 602 return 0;
@@ -597,9 +606,8 @@ out_no_root:
597 606
598out_no_rw: 607out_no_rw:
599 rc = jfs_umount(sb); 608 rc = jfs_umount(sb);
600 if (rc) { 609 if (rc)
601 jfs_err("jfs_umount failed with return code %d", rc); 610 jfs_err("jfs_umount failed with return code %d", rc);
602 }
603out_mount_failed: 611out_mount_failed:
604 filemap_write_and_wait(sbi->direct_inode->i_mapping); 612 filemap_write_and_wait(sbi->direct_inode->i_mapping);
605 truncate_inode_pages(sbi->direct_inode->i_mapping, 0); 613 truncate_inode_pages(sbi->direct_inode->i_mapping, 0);
@@ -924,7 +932,8 @@ static int __init init_jfs_fs(void)
924 commit_threads = MAX_COMMIT_THREADS; 932 commit_threads = MAX_COMMIT_THREADS;
925 933
926 for (i = 0; i < commit_threads; i++) { 934 for (i = 0; i < commit_threads; i++) {
927 jfsCommitThread[i] = kthread_run(jfs_lazycommit, NULL, "jfsCommit"); 935 jfsCommitThread[i] = kthread_run(jfs_lazycommit, NULL,
936 "jfsCommit");
928 if (IS_ERR(jfsCommitThread[i])) { 937 if (IS_ERR(jfsCommitThread[i])) {
929 rc = PTR_ERR(jfsCommitThread[i]); 938 rc = PTR_ERR(jfsCommitThread[i]);
930 jfs_err("init_jfs_fs: fork failed w/rc = %d", rc); 939 jfs_err("init_jfs_fs: fork failed w/rc = %d", rc);