diff options
author | Marcin Slusarz <marcin.slusarz@gmail.com> | 2008-11-16 13:01:44 -0500 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2009-04-02 06:29:48 -0400 |
commit | ba9aadd80c24775e55a93ebe0c2491b4d2899257 (patch) | |
tree | 29b8f456c6322f9a0d375bfa0a368ef4e18b0cb8 /fs/udf/super.c | |
parent | 97e961fdbf32488b7386c9f1effa2bee97d47929 (diff) |
udf: reduce stack usage of udf_load_pvoldesc
Allocate strings with kmalloc.
Checkstack output:
Before: udf_process_sequence: 712
After: udf_process_sequence: 200
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf/super.c')
-rw-r--r-- | fs/udf/super.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/fs/udf/super.c b/fs/udf/super.c index 627558213746..8364b1719158 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c | |||
@@ -902,14 +902,23 @@ static int udf_find_fileset(struct super_block *sb, | |||
902 | static int udf_load_pvoldesc(struct super_block *sb, sector_t block) | 902 | static int udf_load_pvoldesc(struct super_block *sb, sector_t block) |
903 | { | 903 | { |
904 | struct primaryVolDesc *pvoldesc; | 904 | struct primaryVolDesc *pvoldesc; |
905 | struct ustr instr; | 905 | struct ustr *instr, *outstr; |
906 | struct ustr outstr; | ||
907 | struct buffer_head *bh; | 906 | struct buffer_head *bh; |
908 | uint16_t ident; | 907 | uint16_t ident; |
908 | int ret = 1; | ||
909 | |||
910 | instr = kmalloc(sizeof(struct ustr), GFP_NOFS); | ||
911 | if (!instr) | ||
912 | return 1; | ||
913 | |||
914 | outstr = kmalloc(sizeof(struct ustr), GFP_NOFS); | ||
915 | if (!outstr) | ||
916 | goto out1; | ||
909 | 917 | ||
910 | bh = udf_read_tagged(sb, block, block, &ident); | 918 | bh = udf_read_tagged(sb, block, block, &ident); |
911 | if (!bh) | 919 | if (!bh) |
912 | return 1; | 920 | goto out2; |
921 | |||
913 | BUG_ON(ident != TAG_IDENT_PVD); | 922 | BUG_ON(ident != TAG_IDENT_PVD); |
914 | 923 | ||
915 | pvoldesc = (struct primaryVolDesc *)bh->b_data; | 924 | pvoldesc = (struct primaryVolDesc *)bh->b_data; |
@@ -925,20 +934,25 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block) | |||
925 | #endif | 934 | #endif |
926 | } | 935 | } |
927 | 936 | ||
928 | if (!udf_build_ustr(&instr, pvoldesc->volIdent, 32)) | 937 | if (!udf_build_ustr(instr, pvoldesc->volIdent, 32)) |
929 | if (udf_CS0toUTF8(&outstr, &instr)) { | 938 | if (udf_CS0toUTF8(outstr, instr)) { |
930 | strncpy(UDF_SB(sb)->s_volume_ident, outstr.u_name, | 939 | strncpy(UDF_SB(sb)->s_volume_ident, outstr->u_name, |
931 | outstr.u_len > 31 ? 31 : outstr.u_len); | 940 | outstr->u_len > 31 ? 31 : outstr->u_len); |
932 | udf_debug("volIdent[] = '%s'\n", | 941 | udf_debug("volIdent[] = '%s'\n", |
933 | UDF_SB(sb)->s_volume_ident); | 942 | UDF_SB(sb)->s_volume_ident); |
934 | } | 943 | } |
935 | 944 | ||
936 | if (!udf_build_ustr(&instr, pvoldesc->volSetIdent, 128)) | 945 | if (!udf_build_ustr(instr, pvoldesc->volSetIdent, 128)) |
937 | if (udf_CS0toUTF8(&outstr, &instr)) | 946 | if (udf_CS0toUTF8(outstr, instr)) |
938 | udf_debug("volSetIdent[] = '%s'\n", outstr.u_name); | 947 | udf_debug("volSetIdent[] = '%s'\n", outstr->u_name); |
939 | 948 | ||
940 | brelse(bh); | 949 | brelse(bh); |
941 | return 0; | 950 | ret = 0; |
951 | out2: | ||
952 | kfree(outstr); | ||
953 | out1: | ||
954 | kfree(instr); | ||
955 | return ret; | ||
942 | } | 956 | } |
943 | 957 | ||
944 | static int udf_load_metadata_files(struct super_block *sb, int partition) | 958 | static int udf_load_metadata_files(struct super_block *sb, int partition) |