aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/udf/super.c122
1 files changed, 64 insertions, 58 deletions
diff --git a/fs/udf/super.c b/fs/udf/super.c
index e7534fb84c2d..8a7583867811 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -252,6 +252,63 @@ static int udf_sb_alloc_partition_maps(struct super_block *sb, u32 count)
252 return 0; 252 return 0;
253} 253}
254 254
255static void udf_sb_free_bitmap(struct udf_bitmap *bitmap)
256{
257 int i;
258 int nr_groups = bitmap->s_nr_groups;
259 int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) *
260 nr_groups);
261
262 for (i = 0; i < nr_groups; i++)
263 if (bitmap->s_block_bitmap[i])
264 brelse(bitmap->s_block_bitmap[i]);
265
266 if (size <= PAGE_SIZE)
267 kfree(bitmap);
268 else
269 vfree(bitmap);
270}
271
272static void udf_free_partition(struct udf_part_map *map)
273{
274 int i;
275 struct udf_meta_data *mdata;
276
277 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE)
278 iput(map->s_uspace.s_table);
279 if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE)
280 iput(map->s_fspace.s_table);
281 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP)
282 udf_sb_free_bitmap(map->s_uspace.s_bitmap);
283 if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP)
284 udf_sb_free_bitmap(map->s_fspace.s_bitmap);
285 if (map->s_partition_type == UDF_SPARABLE_MAP15)
286 for (i = 0; i < 4; i++)
287 brelse(map->s_type_specific.s_sparing.s_spar_map[i]);
288 else if (map->s_partition_type == UDF_METADATA_MAP25) {
289 mdata = &map->s_type_specific.s_metadata;
290 iput(mdata->s_metadata_fe);
291 mdata->s_metadata_fe = NULL;
292
293 iput(mdata->s_mirror_fe);
294 mdata->s_mirror_fe = NULL;
295
296 iput(mdata->s_bitmap_fe);
297 mdata->s_bitmap_fe = NULL;
298 }
299}
300
301static void udf_sb_free_partitions(struct super_block *sb)
302{
303 struct udf_sb_info *sbi = UDF_SB(sb);
304 int i;
305
306 for (i = 0; i < sbi->s_partitions; i++)
307 udf_free_partition(&sbi->s_partmaps[i]);
308 kfree(sbi->s_partmaps);
309 sbi->s_partmaps = NULL;
310}
311
255static int udf_show_options(struct seq_file *seq, struct dentry *root) 312static int udf_show_options(struct seq_file *seq, struct dentry *root)
256{ 313{
257 struct super_block *sb = root->d_sb; 314 struct super_block *sb = root->d_sb;
@@ -1596,7 +1653,11 @@ static int udf_load_sequence(struct super_block *sb, struct buffer_head *bh,
1596 /* responsible for finding the PartitionDesc(s) */ 1653 /* responsible for finding the PartitionDesc(s) */
1597 if (!udf_process_sequence(sb, main_s, main_e, fileset)) 1654 if (!udf_process_sequence(sb, main_s, main_e, fileset))
1598 return 1; 1655 return 1;
1599 return !udf_process_sequence(sb, reserve_s, reserve_e, fileset); 1656 udf_sb_free_partitions(sb);
1657 if (!udf_process_sequence(sb, reserve_s, reserve_e, fileset))
1658 return 1;
1659 udf_sb_free_partitions(sb);
1660 return 0;
1600} 1661}
1601 1662
1602/* 1663/*
@@ -1861,55 +1922,8 @@ u64 lvid_get_unique_id(struct super_block *sb)
1861 return ret; 1922 return ret;
1862} 1923}
1863 1924
1864static void udf_sb_free_bitmap(struct udf_bitmap *bitmap)
1865{
1866 int i;
1867 int nr_groups = bitmap->s_nr_groups;
1868 int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) *
1869 nr_groups);
1870
1871 for (i = 0; i < nr_groups; i++)
1872 if (bitmap->s_block_bitmap[i])
1873 brelse(bitmap->s_block_bitmap[i]);
1874
1875 if (size <= PAGE_SIZE)
1876 kfree(bitmap);
1877 else
1878 vfree(bitmap);
1879}
1880
1881static void udf_free_partition(struct udf_part_map *map)
1882{
1883 int i;
1884 struct udf_meta_data *mdata;
1885
1886 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE)
1887 iput(map->s_uspace.s_table);
1888 if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE)
1889 iput(map->s_fspace.s_table);
1890 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP)
1891 udf_sb_free_bitmap(map->s_uspace.s_bitmap);
1892 if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP)
1893 udf_sb_free_bitmap(map->s_fspace.s_bitmap);
1894 if (map->s_partition_type == UDF_SPARABLE_MAP15)
1895 for (i = 0; i < 4; i++)
1896 brelse(map->s_type_specific.s_sparing.s_spar_map[i]);
1897 else if (map->s_partition_type == UDF_METADATA_MAP25) {
1898 mdata = &map->s_type_specific.s_metadata;
1899 iput(mdata->s_metadata_fe);
1900 mdata->s_metadata_fe = NULL;
1901
1902 iput(mdata->s_mirror_fe);
1903 mdata->s_mirror_fe = NULL;
1904
1905 iput(mdata->s_bitmap_fe);
1906 mdata->s_bitmap_fe = NULL;
1907 }
1908}
1909
1910static int udf_fill_super(struct super_block *sb, void *options, int silent) 1925static int udf_fill_super(struct super_block *sb, void *options, int silent)
1911{ 1926{
1912 int i;
1913 int ret; 1927 int ret;
1914 struct inode *inode = NULL; 1928 struct inode *inode = NULL;
1915 struct udf_options uopt; 1929 struct udf_options uopt;
@@ -2071,9 +2085,6 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
2071error_out: 2085error_out:
2072 if (sbi->s_vat_inode) 2086 if (sbi->s_vat_inode)
2073 iput(sbi->s_vat_inode); 2087 iput(sbi->s_vat_inode);
2074 if (sbi->s_partitions)
2075 for (i = 0; i < sbi->s_partitions; i++)
2076 udf_free_partition(&sbi->s_partmaps[i]);
2077#ifdef CONFIG_UDF_NLS 2088#ifdef CONFIG_UDF_NLS
2078 if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) 2089 if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
2079 unload_nls(sbi->s_nls_map); 2090 unload_nls(sbi->s_nls_map);
@@ -2081,8 +2092,7 @@ error_out:
2081 if (!(sb->s_flags & MS_RDONLY)) 2092 if (!(sb->s_flags & MS_RDONLY))
2082 udf_close_lvid(sb); 2093 udf_close_lvid(sb);
2083 brelse(sbi->s_lvid_bh); 2094 brelse(sbi->s_lvid_bh);
2084 2095 udf_sb_free_partitions(sb);
2085 kfree(sbi->s_partmaps);
2086 kfree(sbi); 2096 kfree(sbi);
2087 sb->s_fs_info = NULL; 2097 sb->s_fs_info = NULL;
2088 2098
@@ -2123,16 +2133,12 @@ void _udf_warn(struct super_block *sb, const char *function,
2123 2133
2124static void udf_put_super(struct super_block *sb) 2134static void udf_put_super(struct super_block *sb)
2125{ 2135{
2126 int i;
2127 struct udf_sb_info *sbi; 2136 struct udf_sb_info *sbi;
2128 2137
2129 sbi = UDF_SB(sb); 2138 sbi = UDF_SB(sb);
2130 2139
2131 if (sbi->s_vat_inode) 2140 if (sbi->s_vat_inode)
2132 iput(sbi->s_vat_inode); 2141 iput(sbi->s_vat_inode);
2133 if (sbi->s_partitions)
2134 for (i = 0; i < sbi->s_partitions; i++)
2135 udf_free_partition(&sbi->s_partmaps[i]);
2136#ifdef CONFIG_UDF_NLS 2142#ifdef CONFIG_UDF_NLS
2137 if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) 2143 if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
2138 unload_nls(sbi->s_nls_map); 2144 unload_nls(sbi->s_nls_map);
@@ -2140,7 +2146,7 @@ static void udf_put_super(struct super_block *sb)
2140 if (!(sb->s_flags & MS_RDONLY)) 2146 if (!(sb->s_flags & MS_RDONLY))
2141 udf_close_lvid(sb); 2147 udf_close_lvid(sb);
2142 brelse(sbi->s_lvid_bh); 2148 brelse(sbi->s_lvid_bh);
2143 kfree(sbi->s_partmaps); 2149 udf_sb_free_partitions(sb);
2144 kfree(sb->s_fs_info); 2150 kfree(sb->s_fs_info);
2145 sb->s_fs_info = NULL; 2151 sb->s_fs_info = NULL;
2146} 2152}