aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-07-24 20:40:44 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-24 20:40:44 -0400
commit08d9329c29ec98477e8ac2f7a513f2bfa3e9f3c5 (patch)
tree464917dd750d7417cc62831c7a119b7ca64d0ec8 /fs/udf
parent2c05b2c838e7adaabb7265ad5d5b632315c20821 (diff)
parent0143fc5e9f6f5aad4764801015bc8d4b4a278200 (diff)
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
Pull misc udf, ext2, ext3, and isofs fixes from Jan Kara: "Assorted, mostly trivial, fixes for udf, ext2, ext3, and isofs. I'm on vacation and scarcely checking email since we are expecting baby any day now but these fixes should be safe to go in and I don't want to delay them unnecessarily." * 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: udf: avoid info leak on export isofs: avoid info leak on export udf: Improve table length check to avoid possible overflow ext3: Check return value of blkdev_issue_flush() jbd: Check return value of blkdev_issue_flush() udf: Do not decrement i_blocks when freeing indirect extent block udf: Fix memory leak when mounting ext2: cleanup the confused goto label UDF: Remove unnecessary variable "offset" from udf_fill_inode udf: stop using s_dirt ext3: force ro mount if ext3_setup_super() fails quota: fix checkpatch.pl warning by replacing <asm/uaccess.h> with <linux/uaccess.h>
Diffstat (limited to 'fs/udf')
-rw-r--r--fs/udf/inode.c4
-rw-r--r--fs/udf/namei.c1
-rw-r--r--fs/udf/super.c130
-rw-r--r--fs/udf/truncate.c4
-rw-r--r--fs/udf/udfdecl.h1
5 files changed, 68 insertions, 72 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 873e1bab9c4c..fafaad795cd6 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1247,7 +1247,6 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
1247{ 1247{
1248 struct fileEntry *fe; 1248 struct fileEntry *fe;
1249 struct extendedFileEntry *efe; 1249 struct extendedFileEntry *efe;
1250 int offset;
1251 struct udf_sb_info *sbi = UDF_SB(inode->i_sb); 1250 struct udf_sb_info *sbi = UDF_SB(inode->i_sb);
1252 struct udf_inode_info *iinfo = UDF_I(inode); 1251 struct udf_inode_info *iinfo = UDF_I(inode);
1253 unsigned int link_count; 1252 unsigned int link_count;
@@ -1359,7 +1358,6 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
1359 iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr); 1358 iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr);
1360 iinfo->i_lenAlloc = le32_to_cpu(fe->lengthAllocDescs); 1359 iinfo->i_lenAlloc = le32_to_cpu(fe->lengthAllocDescs);
1361 iinfo->i_checkpoint = le32_to_cpu(fe->checkpoint); 1360 iinfo->i_checkpoint = le32_to_cpu(fe->checkpoint);
1362 offset = sizeof(struct fileEntry) + iinfo->i_lenEAttr;
1363 } else { 1361 } else {
1364 inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) << 1362 inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) <<
1365 (inode->i_sb->s_blocksize_bits - 9); 1363 (inode->i_sb->s_blocksize_bits - 9);
@@ -1381,8 +1379,6 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
1381 iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr); 1379 iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr);
1382 iinfo->i_lenAlloc = le32_to_cpu(efe->lengthAllocDescs); 1380 iinfo->i_lenAlloc = le32_to_cpu(efe->lengthAllocDescs);
1383 iinfo->i_checkpoint = le32_to_cpu(efe->checkpoint); 1381 iinfo->i_checkpoint = le32_to_cpu(efe->checkpoint);
1384 offset = sizeof(struct extendedFileEntry) +
1385 iinfo->i_lenEAttr;
1386 } 1382 }
1387 1383
1388 switch (fe->icbTag.fileType) { 1384 switch (fe->icbTag.fileType) {
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 544b2799a911..95fee278ab9d 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -1279,6 +1279,7 @@ static int udf_encode_fh(struct inode *inode, __u32 *fh, int *lenp,
1279 *lenp = 3; 1279 *lenp = 3;
1280 fid->udf.block = location.logicalBlockNum; 1280 fid->udf.block = location.logicalBlockNum;
1281 fid->udf.partref = location.partitionReferenceNum; 1281 fid->udf.partref = location.partitionReferenceNum;
1282 fid->udf.parent_partref = 0;
1282 fid->udf.generation = inode->i_generation; 1283 fid->udf.generation = inode->i_generation;
1283 1284
1284 if (parent) { 1285 if (parent) {
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);
diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c
index 4b98fee8e161..8a9657d7f7c6 100644
--- a/fs/udf/truncate.c
+++ b/fs/udf/truncate.c
@@ -248,7 +248,7 @@ void udf_truncate_extents(struct inode *inode)
248 /* We managed to free all extents in the 248 /* We managed to free all extents in the
249 * indirect extent - free it too */ 249 * indirect extent - free it too */
250 BUG_ON(!epos.bh); 250 BUG_ON(!epos.bh);
251 udf_free_blocks(sb, inode, &epos.block, 251 udf_free_blocks(sb, NULL, &epos.block,
252 0, indirect_ext_len); 252 0, indirect_ext_len);
253 } else if (!epos.bh) { 253 } else if (!epos.bh) {
254 iinfo->i_lenAlloc = lenalloc; 254 iinfo->i_lenAlloc = lenalloc;
@@ -275,7 +275,7 @@ void udf_truncate_extents(struct inode *inode)
275 275
276 if (indirect_ext_len) { 276 if (indirect_ext_len) {
277 BUG_ON(!epos.bh); 277 BUG_ON(!epos.bh);
278 udf_free_blocks(sb, inode, &epos.block, 0, indirect_ext_len); 278 udf_free_blocks(sb, NULL, &epos.block, 0, indirect_ext_len);
279 } else if (!epos.bh) { 279 } else if (!epos.bh) {
280 iinfo->i_lenAlloc = lenalloc; 280 iinfo->i_lenAlloc = lenalloc;
281 mark_inode_dirty(inode); 281 mark_inode_dirty(inode);
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index ebe10314e512..de038da6f6bd 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -129,7 +129,6 @@ static inline void udf_updated_lvid(struct super_block *sb)
129 WARN_ON_ONCE(((struct logicalVolIntegrityDesc *) 129 WARN_ON_ONCE(((struct logicalVolIntegrityDesc *)
130 bh->b_data)->integrityType != 130 bh->b_data)->integrityType !=
131 cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN)); 131 cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN));
132 sb->s_dirt = 1;
133 UDF_SB(sb)->s_lvid_dirty = 1; 132 UDF_SB(sb)->s_lvid_dirty = 1;
134} 133}
135extern u64 lvid_get_unique_id(struct super_block *sb); 134extern u64 lvid_get_unique_id(struct super_block *sb);