aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext3')
-rw-r--r--fs/ext3/inode.c16
-rw-r--r--fs/ext3/namei.c1
-rw-r--r--fs/ext3/resize.c12
-rw-r--r--fs/ext3/super.c52
-rw-r--r--fs/ext3/xattr.c4
5 files changed, 49 insertions, 36 deletions
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index b176d4253544..d512c4bc4ad7 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -676,6 +676,10 @@ static int ext3_alloc_branch(handle_t *handle, struct inode *inode,
676 * parent to disk. 676 * parent to disk.
677 */ 677 */
678 bh = sb_getblk(inode->i_sb, new_blocks[n-1]); 678 bh = sb_getblk(inode->i_sb, new_blocks[n-1]);
679 if (unlikely(!bh)) {
680 err = -ENOMEM;
681 goto failed;
682 }
679 branch[n].bh = bh; 683 branch[n].bh = bh;
680 lock_buffer(bh); 684 lock_buffer(bh);
681 BUFFER_TRACE(bh, "call get_create_access"); 685 BUFFER_TRACE(bh, "call get_create_access");
@@ -717,7 +721,7 @@ failed:
717 BUFFER_TRACE(branch[i].bh, "call journal_forget"); 721 BUFFER_TRACE(branch[i].bh, "call journal_forget");
718 ext3_journal_forget(handle, branch[i].bh); 722 ext3_journal_forget(handle, branch[i].bh);
719 } 723 }
720 for (i = 0; i <indirect_blks; i++) 724 for (i = 0; i < indirect_blks; i++)
721 ext3_free_blocks(handle, inode, new_blocks[i], 1); 725 ext3_free_blocks(handle, inode, new_blocks[i], 1);
722 726
723 ext3_free_blocks(handle, inode, new_blocks[i], num); 727 ext3_free_blocks(handle, inode, new_blocks[i], num);
@@ -1078,8 +1082,8 @@ struct buffer_head *ext3_getblk(handle_t *handle, struct inode *inode,
1078 if (!err && buffer_mapped(&dummy)) { 1082 if (!err && buffer_mapped(&dummy)) {
1079 struct buffer_head *bh; 1083 struct buffer_head *bh;
1080 bh = sb_getblk(inode->i_sb, dummy.b_blocknr); 1084 bh = sb_getblk(inode->i_sb, dummy.b_blocknr);
1081 if (!bh) { 1085 if (unlikely(!bh)) {
1082 *errp = -EIO; 1086 *errp = -ENOMEM;
1083 goto err; 1087 goto err;
1084 } 1088 }
1085 if (buffer_new(&dummy)) { 1089 if (buffer_new(&dummy)) {
@@ -2729,12 +2733,12 @@ static int __ext3_get_inode_loc(struct inode *inode,
2729 return -EIO; 2733 return -EIO;
2730 2734
2731 bh = sb_getblk(inode->i_sb, block); 2735 bh = sb_getblk(inode->i_sb, block);
2732 if (!bh) { 2736 if (unlikely(!bh)) {
2733 ext3_error (inode->i_sb, "ext3_get_inode_loc", 2737 ext3_error (inode->i_sb, "ext3_get_inode_loc",
2734 "unable to read inode block - " 2738 "unable to read inode block - "
2735 "inode=%lu, block="E3FSBLK, 2739 "inode=%lu, block="E3FSBLK,
2736 inode->i_ino, block); 2740 inode->i_ino, block);
2737 return -EIO; 2741 return -ENOMEM;
2738 } 2742 }
2739 if (!buffer_uptodate(bh)) { 2743 if (!buffer_uptodate(bh)) {
2740 lock_buffer(bh); 2744 lock_buffer(bh);
@@ -2783,7 +2787,7 @@ static int __ext3_get_inode_loc(struct inode *inode,
2783 2787
2784 bitmap_bh = sb_getblk(inode->i_sb, 2788 bitmap_bh = sb_getblk(inode->i_sb,
2785 le32_to_cpu(desc->bg_inode_bitmap)); 2789 le32_to_cpu(desc->bg_inode_bitmap));
2786 if (!bitmap_bh) 2790 if (unlikely(!bitmap_bh))
2787 goto make_io; 2791 goto make_io;
2788 2792
2789 /* 2793 /*
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 61fa09eb2501..692de13e3596 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -36,7 +36,6 @@
36#define NAMEI_RA_CHUNKS 2 36#define NAMEI_RA_CHUNKS 2
37#define NAMEI_RA_BLOCKS 4 37#define NAMEI_RA_BLOCKS 4
38#define NAMEI_RA_SIZE (NAMEI_RA_CHUNKS * NAMEI_RA_BLOCKS) 38#define NAMEI_RA_SIZE (NAMEI_RA_CHUNKS * NAMEI_RA_BLOCKS)
39#define NAMEI_RA_INDEX(c,b) (((c) * NAMEI_RA_BLOCKS) + (b))
40 39
41static struct buffer_head *ext3_append(handle_t *handle, 40static struct buffer_head *ext3_append(handle_t *handle,
42 struct inode *inode, 41 struct inode *inode,
diff --git a/fs/ext3/resize.c b/fs/ext3/resize.c
index 0f814f3450de..27105655502c 100644
--- a/fs/ext3/resize.c
+++ b/fs/ext3/resize.c
@@ -116,8 +116,8 @@ static struct buffer_head *bclean(handle_t *handle, struct super_block *sb,
116 int err; 116 int err;
117 117
118 bh = sb_getblk(sb, blk); 118 bh = sb_getblk(sb, blk);
119 if (!bh) 119 if (unlikely(!bh))
120 return ERR_PTR(-EIO); 120 return ERR_PTR(-ENOMEM);
121 if ((err = ext3_journal_get_write_access(handle, bh))) { 121 if ((err = ext3_journal_get_write_access(handle, bh))) {
122 brelse(bh); 122 brelse(bh);
123 bh = ERR_PTR(err); 123 bh = ERR_PTR(err);
@@ -234,8 +234,8 @@ static int setup_new_group_blocks(struct super_block *sb,
234 goto exit_bh; 234 goto exit_bh;
235 235
236 gdb = sb_getblk(sb, block); 236 gdb = sb_getblk(sb, block);
237 if (!gdb) { 237 if (unlikely(!gdb)) {
238 err = -EIO; 238 err = -ENOMEM;
239 goto exit_bh; 239 goto exit_bh;
240 } 240 }
241 if ((err = ext3_journal_get_write_access(handle, gdb))) { 241 if ((err = ext3_journal_get_write_access(handle, gdb))) {
@@ -722,8 +722,8 @@ static void update_backups(struct super_block *sb,
722 break; 722 break;
723 723
724 bh = sb_getblk(sb, group * bpg + blk_off); 724 bh = sb_getblk(sb, group * bpg + blk_off);
725 if (!bh) { 725 if (unlikely(!bh)) {
726 err = -EIO; 726 err = -ENOMEM;
727 break; 727 break;
728 } 728 }
729 ext3_debug("update metadata backup %#04lx\n", 729 ext3_debug("update metadata backup %#04lx\n",
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 6e50223b3299..5546ca225ffe 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -916,21 +916,24 @@ static int set_qf_name(struct super_block *sb, int qtype, substring_t *args)
916 "Not enough memory for storing quotafile name"); 916 "Not enough memory for storing quotafile name");
917 return 0; 917 return 0;
918 } 918 }
919 if (sbi->s_qf_names[qtype] && 919 if (sbi->s_qf_names[qtype]) {
920 strcmp(sbi->s_qf_names[qtype], qname)) { 920 int same = !strcmp(sbi->s_qf_names[qtype], qname);
921 ext3_msg(sb, KERN_ERR, 921
922 "%s quota file already specified", QTYPE2NAME(qtype));
923 kfree(qname); 922 kfree(qname);
924 return 0; 923 if (!same) {
924 ext3_msg(sb, KERN_ERR,
925 "%s quota file already specified",
926 QTYPE2NAME(qtype));
927 }
928 return same;
925 } 929 }
926 sbi->s_qf_names[qtype] = qname; 930 if (strchr(qname, '/')) {
927 if (strchr(sbi->s_qf_names[qtype], '/')) {
928 ext3_msg(sb, KERN_ERR, 931 ext3_msg(sb, KERN_ERR,
929 "quotafile must be on filesystem root"); 932 "quotafile must be on filesystem root");
930 kfree(sbi->s_qf_names[qtype]); 933 kfree(qname);
931 sbi->s_qf_names[qtype] = NULL;
932 return 0; 934 return 0;
933 } 935 }
936 sbi->s_qf_names[qtype] = qname;
934 set_opt(sbi->s_mount_opt, QUOTA); 937 set_opt(sbi->s_mount_opt, QUOTA);
935 return 1; 938 return 1;
936} 939}
@@ -945,11 +948,10 @@ static int clear_qf_name(struct super_block *sb, int qtype) {
945 " when quota turned on"); 948 " when quota turned on");
946 return 0; 949 return 0;
947 } 950 }
948 /* 951 if (sbi->s_qf_names[qtype]) {
949 * The space will be released later when all options are confirmed 952 kfree(sbi->s_qf_names[qtype]);
950 * to be correct 953 sbi->s_qf_names[qtype] = NULL;
951 */ 954 }
952 sbi->s_qf_names[qtype] = NULL;
953 return 1; 955 return 1;
954} 956}
955#endif 957#endif
@@ -2065,6 +2067,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
2065 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA ? "journal": 2067 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA ? "journal":
2066 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered": 2068 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered":
2067 "writeback"); 2069 "writeback");
2070 sb->s_flags |= MS_SNAP_STABLE;
2068 2071
2069 return 0; 2072 return 0;
2070 2073
@@ -2605,7 +2608,18 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2605#ifdef CONFIG_QUOTA 2608#ifdef CONFIG_QUOTA
2606 old_opts.s_jquota_fmt = sbi->s_jquota_fmt; 2609 old_opts.s_jquota_fmt = sbi->s_jquota_fmt;
2607 for (i = 0; i < MAXQUOTAS; i++) 2610 for (i = 0; i < MAXQUOTAS; i++)
2608 old_opts.s_qf_names[i] = sbi->s_qf_names[i]; 2611 if (sbi->s_qf_names[i]) {
2612 old_opts.s_qf_names[i] = kstrdup(sbi->s_qf_names[i],
2613 GFP_KERNEL);
2614 if (!old_opts.s_qf_names[i]) {
2615 int j;
2616
2617 for (j = 0; j < i; j++)
2618 kfree(old_opts.s_qf_names[j]);
2619 return -ENOMEM;
2620 }
2621 } else
2622 old_opts.s_qf_names[i] = NULL;
2609#endif 2623#endif
2610 2624
2611 /* 2625 /*
@@ -2698,9 +2712,7 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2698#ifdef CONFIG_QUOTA 2712#ifdef CONFIG_QUOTA
2699 /* Release old quota file names */ 2713 /* Release old quota file names */
2700 for (i = 0; i < MAXQUOTAS; i++) 2714 for (i = 0; i < MAXQUOTAS; i++)
2701 if (old_opts.s_qf_names[i] && 2715 kfree(old_opts.s_qf_names[i]);
2702 old_opts.s_qf_names[i] != sbi->s_qf_names[i])
2703 kfree(old_opts.s_qf_names[i]);
2704#endif 2716#endif
2705 if (enable_quota) 2717 if (enable_quota)
2706 dquot_resume(sb, -1); 2718 dquot_resume(sb, -1);
@@ -2714,9 +2726,7 @@ restore_opts:
2714#ifdef CONFIG_QUOTA 2726#ifdef CONFIG_QUOTA
2715 sbi->s_jquota_fmt = old_opts.s_jquota_fmt; 2727 sbi->s_jquota_fmt = old_opts.s_jquota_fmt;
2716 for (i = 0; i < MAXQUOTAS; i++) { 2728 for (i = 0; i < MAXQUOTAS; i++) {
2717 if (sbi->s_qf_names[i] && 2729 kfree(sbi->s_qf_names[i]);
2718 old_opts.s_qf_names[i] != sbi->s_qf_names[i])
2719 kfree(sbi->s_qf_names[i]);
2720 sbi->s_qf_names[i] = old_opts.s_qf_names[i]; 2730 sbi->s_qf_names[i] = old_opts.s_qf_names[i];
2721 } 2731 }
2722#endif 2732#endif
diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
index d22ebb7a4f55..b1fc96383e08 100644
--- a/fs/ext3/xattr.c
+++ b/fs/ext3/xattr.c
@@ -813,10 +813,10 @@ inserted:
813 ea_idebug(inode, "creating block %d", block); 813 ea_idebug(inode, "creating block %d", block);
814 814
815 new_bh = sb_getblk(sb, block); 815 new_bh = sb_getblk(sb, block);
816 if (!new_bh) { 816 if (unlikely(!new_bh)) {
817getblk_failed: 817getblk_failed:
818 ext3_free_blocks(handle, inode, block, 1); 818 ext3_free_blocks(handle, inode, block, 1);
819 error = -EIO; 819 error = -ENOMEM;
820 goto cleanup; 820 goto cleanup;
821 } 821 }
822 lock_buffer(new_bh); 822 lock_buffer(new_bh);