aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/udf/super.c')
-rw-r--r--fs/udf/super.c130
1 files changed, 65 insertions, 65 deletions
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 8d86a8706c0e..dcbf98722afc 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;
@@ -1283,7 +1340,7 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,
1283 BUG_ON(ident != TAG_IDENT_LVD); 1340 BUG_ON(ident != TAG_IDENT_LVD);
1284 lvd = (struct logicalVolDesc *)bh->b_data; 1341 lvd = (struct logicalVolDesc *)bh->b_data;
1285 table_len = le32_to_cpu(lvd->mapTableLength); 1342 table_len = le32_to_cpu(lvd->mapTableLength);
1286 if (sizeof(*lvd) + table_len > sb->s_blocksize) { 1343 if (table_len > sb->s_blocksize - sizeof(*lvd)) {
1287 udf_err(sb, "error loading logical volume descriptor: " 1344 udf_err(sb, "error loading logical volume descriptor: "
1288 "Partition table too long (%u > %lu)\n", table_len, 1345 "Partition table too long (%u > %lu)\n", table_len,
1289 sb->s_blocksize - sizeof(*lvd)); 1346 sb->s_blocksize - sizeof(*lvd));
@@ -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;
@@ -1974,7 +1988,6 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1974 sb->s_op = &udf_sb_ops; 1988 sb->s_op = &udf_sb_ops;
1975 sb->s_export_op = &udf_export_ops; 1989 sb->s_export_op = &udf_export_ops;
1976 1990
1977 sb->s_dirt = 0;
1978 sb->s_magic = UDF_SUPER_MAGIC; 1991 sb->s_magic = UDF_SUPER_MAGIC;
1979 sb->s_time_gran = 1000; 1992 sb->s_time_gran = 1000;
1980 1993
@@ -2072,9 +2085,6 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
2072error_out: 2085error_out:
2073 if (sbi->s_vat_inode) 2086 if (sbi->s_vat_inode)
2074 iput(sbi->s_vat_inode); 2087 iput(sbi->s_vat_inode);
2075 if (sbi->s_partitions)
2076 for (i = 0; i < sbi->s_partitions; i++)
2077 udf_free_partition(&sbi->s_partmaps[i]);
2078#ifdef CONFIG_UDF_NLS 2088#ifdef CONFIG_UDF_NLS
2079 if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) 2089 if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
2080 unload_nls(sbi->s_nls_map); 2090 unload_nls(sbi->s_nls_map);
@@ -2082,8 +2092,7 @@ error_out:
2082 if (!(sb->s_flags & MS_RDONLY)) 2092 if (!(sb->s_flags & MS_RDONLY))
2083 udf_close_lvid(sb); 2093 udf_close_lvid(sb);
2084 brelse(sbi->s_lvid_bh); 2094 brelse(sbi->s_lvid_bh);
2085 2095 udf_sb_free_partitions(sb);
2086 kfree(sbi->s_partmaps);
2087 kfree(sbi); 2096 kfree(sbi);
2088 sb->s_fs_info = NULL; 2097 sb->s_fs_info = NULL;
2089 2098
@@ -2096,10 +2105,6 @@ void _udf_err(struct super_block *sb, const char *function,
2096 struct va_format vaf; 2105 struct va_format vaf;
2097 va_list args; 2106 va_list args;
2098 2107
2099 /* mark sb error */
2100 if (!(sb->s_flags & MS_RDONLY))
2101 sb->s_dirt = 1;
2102
2103 va_start(args, fmt); 2108 va_start(args, fmt);
2104 2109
2105 vaf.fmt = fmt; 2110 vaf.fmt = fmt;
@@ -2128,16 +2133,12 @@ void _udf_warn(struct super_block *sb, const char *function,
2128 2133
2129static void udf_put_super(struct super_block *sb) 2134static void udf_put_super(struct super_block *sb)
2130{ 2135{
2131 int i;
2132 struct udf_sb_info *sbi; 2136 struct udf_sb_info *sbi;
2133 2137
2134 sbi = UDF_SB(sb); 2138 sbi = UDF_SB(sb);
2135 2139
2136 if (sbi->s_vat_inode) 2140 if (sbi->s_vat_inode)
2137 iput(sbi->s_vat_inode); 2141 iput(sbi->s_vat_inode);
2138 if (sbi->s_partitions)
2139 for (i = 0; i < sbi->s_partitions; i++)
2140 udf_free_partition(&sbi->s_partmaps[i]);
2141#ifdef CONFIG_UDF_NLS 2142#ifdef CONFIG_UDF_NLS
2142 if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) 2143 if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
2143 unload_nls(sbi->s_nls_map); 2144 unload_nls(sbi->s_nls_map);
@@ -2145,7 +2146,7 @@ static void udf_put_super(struct super_block *sb)
2145 if (!(sb->s_flags & MS_RDONLY)) 2146 if (!(sb->s_flags & MS_RDONLY))
2146 udf_close_lvid(sb); 2147 udf_close_lvid(sb);
2147 brelse(sbi->s_lvid_bh); 2148 brelse(sbi->s_lvid_bh);
2148 kfree(sbi->s_partmaps); 2149 udf_sb_free_partitions(sb);
2149 kfree(sb->s_fs_info); 2150 kfree(sb->s_fs_info);
2150 sb->s_fs_info = NULL; 2151 sb->s_fs_info = NULL;
2151} 2152}
@@ -2161,7 +2162,6 @@ static int udf_sync_fs(struct super_block *sb, int wait)
2161 * the buffer for IO 2162 * the buffer for IO
2162 */ 2163 */
2163 mark_buffer_dirty(sbi->s_lvid_bh); 2164 mark_buffer_dirty(sbi->s_lvid_bh);
2164 sb->s_dirt = 0;
2165 sbi->s_lvid_dirty = 0; 2165 sbi->s_lvid_dirty = 0;
2166 } 2166 }
2167 mutex_unlock(&sbi->s_alloc_mutex); 2167 mutex_unlock(&sbi->s_alloc_mutex);