aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-02-26 17:51:52 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-26 17:51:52 -0500
commitbbbd27e694ce2c5fde9c8fcedbea618dd9153fe7 (patch)
tree8811b690085ac784ef73c7b4cdff30c6bedd0e34 /fs/ext3
parenta6590b9f01dca2d45a38b8387f59812c44f68a2f (diff)
parent712ddc52ffa1f5324cd8f682d9e5b047b91f34d3 (diff)
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
Pull ext2, ext3, udf updates from Jan Kara: "Several UDF fixes, a support for UDF extent cache, and couple of ext2 and ext3 cleanups and minor fixes" * 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: Ext2: remove the static function release_blocks to optimize the kernel Ext2: mark inode dirty after the function dquot_free_block_nodirty is called Ext2: remove the overhead check about sb in the function ext2_new_blocks udf: Remove unused s_extLength from udf_bitmap udf: Make s_block_bitmap standard array udf: Fix bitmap overflow on large filesystems with small block size udf: add extent cache support in case of file reading udf: Write LVID to disk after opening / closing Ext3: return ENOMEM rather than EIO if sb_getblk fails Ext2: return ENOMEM rather than EIO if sb_getblk fails Ext3: use unlikely to improve the efficiency of the kernel Ext2: use unlikely to improve the efficiency of the kernel Ext3: add necessary check in case IO error happens Ext2: free memory allocated and forget buffer head when io error happens ext3: Fix memory leak when quota options are specified multiple times ext3, ext4, ocfs2: remove unused macro NAMEI_RA_INDEX
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.c51
-rw-r--r--fs/ext3/xattr.c4
5 files changed, 48 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 890b8947c546..88f64eb1b6fa 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 4ba2683c1d44..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
@@ -2606,7 +2608,18 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2606#ifdef CONFIG_QUOTA 2608#ifdef CONFIG_QUOTA
2607 old_opts.s_jquota_fmt = sbi->s_jquota_fmt; 2609 old_opts.s_jquota_fmt = sbi->s_jquota_fmt;
2608 for (i = 0; i < MAXQUOTAS; i++) 2610 for (i = 0; i < MAXQUOTAS; i++)
2609 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;
2610#endif 2623#endif
2611 2624
2612 /* 2625 /*
@@ -2699,9 +2712,7 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2699#ifdef CONFIG_QUOTA 2712#ifdef CONFIG_QUOTA
2700 /* Release old quota file names */ 2713 /* Release old quota file names */
2701 for (i = 0; i < MAXQUOTAS; i++) 2714 for (i = 0; i < MAXQUOTAS; i++)
2702 if (old_opts.s_qf_names[i] && 2715 kfree(old_opts.s_qf_names[i]);
2703 old_opts.s_qf_names[i] != sbi->s_qf_names[i])
2704 kfree(old_opts.s_qf_names[i]);
2705#endif 2716#endif
2706 if (enable_quota) 2717 if (enable_quota)
2707 dquot_resume(sb, -1); 2718 dquot_resume(sb, -1);
@@ -2715,9 +2726,7 @@ restore_opts:
2715#ifdef CONFIG_QUOTA 2726#ifdef CONFIG_QUOTA
2716 sbi->s_jquota_fmt = old_opts.s_jquota_fmt; 2727 sbi->s_jquota_fmt = old_opts.s_jquota_fmt;
2717 for (i = 0; i < MAXQUOTAS; i++) { 2728 for (i = 0; i < MAXQUOTAS; i++) {
2718 if (sbi->s_qf_names[i] && 2729 kfree(sbi->s_qf_names[i]);
2719 old_opts.s_qf_names[i] != sbi->s_qf_names[i])
2720 kfree(sbi->s_qf_names[i]);
2721 sbi->s_qf_names[i] = old_opts.s_qf_names[i]; 2730 sbi->s_qf_names[i] = old_opts.s_qf_names[i];
2722 } 2731 }
2723#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);