aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/ext2/balloc.c2
-rw-r--r--fs/ext2/super.c8
-rw-r--r--fs/ext3/balloc.c17
-rw-r--r--fs/ext3/fsync.c10
-rw-r--r--fs/ext3/ialloc.c45
-rw-r--r--fs/ext3/ioctl.c24
-rw-r--r--fs/ext3/super.c12
-rw-r--r--fs/quota/quota.c7
-rw-r--r--fs/udf/balloc.c14
-rw-r--r--fs/udf/directory.c8
-rw-r--r--fs/udf/inode.c48
-rw-r--r--fs/udf/lowlevel.c2
-rw-r--r--fs/udf/misc.c19
-rw-r--r--fs/udf/namei.c5
-rw-r--r--fs/udf/partition.c19
-rw-r--r--fs/udf/super.c280
-rw-r--r--fs/udf/truncate.c22
-rw-r--r--fs/udf/udf_sb.h5
-rw-r--r--fs/udf/udfdecl.h35
-rw-r--r--fs/udf/udftime.c3
-rw-r--r--fs/udf/unicode.c6
21 files changed, 258 insertions, 333 deletions
diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
index 8f44cef1b3ef..a8cbe1bc6ad4 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -421,7 +421,7 @@ static inline int rsv_is_empty(struct ext2_reserve_window *rsv)
421void ext2_init_block_alloc_info(struct inode *inode) 421void ext2_init_block_alloc_info(struct inode *inode)
422{ 422{
423 struct ext2_inode_info *ei = EXT2_I(inode); 423 struct ext2_inode_info *ei = EXT2_I(inode);
424 struct ext2_block_alloc_info *block_i = ei->i_block_alloc_info; 424 struct ext2_block_alloc_info *block_i;
425 struct super_block *sb = inode->i_sb; 425 struct super_block *sb = inode->i_sb;
426 426
427 block_i = kmalloc(sizeof(*block_i), GFP_NOFS); 427 block_i = kmalloc(sizeof(*block_i), GFP_NOFS);
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 1dd62ed35b85..bd8ac164a3bf 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -327,10 +327,10 @@ static struct inode *ext2_nfs_get_inode(struct super_block *sb,
327 if (ino > le32_to_cpu(EXT2_SB(sb)->s_es->s_inodes_count)) 327 if (ino > le32_to_cpu(EXT2_SB(sb)->s_es->s_inodes_count))
328 return ERR_PTR(-ESTALE); 328 return ERR_PTR(-ESTALE);
329 329
330 /* iget isn't really right if the inode is currently unallocated!! 330 /*
331 * ext2_read_inode currently does appropriate checks, but 331 * ext2_iget isn't quite right if the inode is currently unallocated!
332 * it might be "neater" to call ext2_get_inode first and check 332 * However ext2_iget currently does appropriate checks to handle stale
333 * if the inode is valid..... 333 * inodes so everything is OK.
334 */ 334 */
335 inode = ext2_iget(sb, ino); 335 inode = ext2_iget(sb, ino);
336 if (IS_ERR(inode)) 336 if (IS_ERR(inode))
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index 6386d76f44a7..a2038928f9a3 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -427,7 +427,7 @@ static inline int rsv_is_empty(struct ext3_reserve_window *rsv)
427void ext3_init_block_alloc_info(struct inode *inode) 427void ext3_init_block_alloc_info(struct inode *inode)
428{ 428{
429 struct ext3_inode_info *ei = EXT3_I(inode); 429 struct ext3_inode_info *ei = EXT3_I(inode);
430 struct ext3_block_alloc_info *block_i = ei->i_block_alloc_info; 430 struct ext3_block_alloc_info *block_i;
431 struct super_block *sb = inode->i_sb; 431 struct super_block *sb = inode->i_sb;
432 432
433 block_i = kmalloc(sizeof(*block_i), GFP_NOFS); 433 block_i = kmalloc(sizeof(*block_i), GFP_NOFS);
@@ -1440,14 +1440,14 @@ out:
1440 * 1440 *
1441 * Check if filesystem has at least 1 free block available for allocation. 1441 * Check if filesystem has at least 1 free block available for allocation.
1442 */ 1442 */
1443static int ext3_has_free_blocks(struct ext3_sb_info *sbi) 1443static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
1444{ 1444{
1445 ext3_fsblk_t free_blocks, root_blocks; 1445 ext3_fsblk_t free_blocks, root_blocks;
1446 1446
1447 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter); 1447 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
1448 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count); 1448 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
1449 if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) && 1449 if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
1450 sbi->s_resuid != current_fsuid() && 1450 !use_reservation && sbi->s_resuid != current_fsuid() &&
1451 (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) { 1451 (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
1452 return 0; 1452 return 0;
1453 } 1453 }
@@ -1468,7 +1468,7 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
1468 */ 1468 */
1469int ext3_should_retry_alloc(struct super_block *sb, int *retries) 1469int ext3_should_retry_alloc(struct super_block *sb, int *retries)
1470{ 1470{
1471 if (!ext3_has_free_blocks(EXT3_SB(sb)) || (*retries)++ > 3) 1471 if (!ext3_has_free_blocks(EXT3_SB(sb), 0) || (*retries)++ > 3)
1472 return 0; 1472 return 0;
1473 1473
1474 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id); 1474 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
@@ -1546,7 +1546,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,
1546 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0)) 1546 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
1547 my_rsv = &block_i->rsv_window_node; 1547 my_rsv = &block_i->rsv_window_node;
1548 1548
1549 if (!ext3_has_free_blocks(sbi)) { 1549 if (!ext3_has_free_blocks(sbi, IS_NOQUOTA(inode))) {
1550 *errp = -ENOSPC; 1550 *errp = -ENOSPC;
1551 goto out; 1551 goto out;
1552 } 1552 }
@@ -1924,9 +1924,10 @@ unsigned long ext3_bg_num_gdb(struct super_block *sb, int group)
1924 * reaches any used block. Then issue a TRIM command on this extent and free 1924 * reaches any used block. Then issue a TRIM command on this extent and free
1925 * the extent in the block bitmap. This is done until whole group is scanned. 1925 * the extent in the block bitmap. This is done until whole group is scanned.
1926 */ 1926 */
1927ext3_grpblk_t ext3_trim_all_free(struct super_block *sb, unsigned int group, 1927static ext3_grpblk_t ext3_trim_all_free(struct super_block *sb,
1928 ext3_grpblk_t start, ext3_grpblk_t max, 1928 unsigned int group,
1929 ext3_grpblk_t minblocks) 1929 ext3_grpblk_t start, ext3_grpblk_t max,
1930 ext3_grpblk_t minblocks)
1930{ 1931{
1931 handle_t *handle; 1932 handle_t *handle;
1932 ext3_grpblk_t next, free_blocks, bit, freed, count = 0; 1933 ext3_grpblk_t next, free_blocks, bit, freed, count = 0;
diff --git a/fs/ext3/fsync.c b/fs/ext3/fsync.c
index d494c554c6e6..1860ed356323 100644
--- a/fs/ext3/fsync.c
+++ b/fs/ext3/fsync.c
@@ -61,13 +61,6 @@ int ext3_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
61 if (ret) 61 if (ret)
62 goto out; 62 goto out;
63 63
64 /*
65 * Taking the mutex here just to keep consistent with how fsync was
66 * called previously, however it looks like we don't need to take
67 * i_mutex at all.
68 */
69 mutex_lock(&inode->i_mutex);
70
71 J_ASSERT(ext3_journal_current_handle() == NULL); 64 J_ASSERT(ext3_journal_current_handle() == NULL);
72 65
73 /* 66 /*
@@ -85,7 +78,6 @@ int ext3_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
85 * safe in-journal, which is all fsync() needs to ensure. 78 * safe in-journal, which is all fsync() needs to ensure.
86 */ 79 */
87 if (ext3_should_journal_data(inode)) { 80 if (ext3_should_journal_data(inode)) {
88 mutex_unlock(&inode->i_mutex);
89 ret = ext3_force_commit(inode->i_sb); 81 ret = ext3_force_commit(inode->i_sb);
90 goto out; 82 goto out;
91 } 83 }
@@ -108,8 +100,6 @@ int ext3_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
108 */ 100 */
109 if (needs_barrier) 101 if (needs_barrier)
110 blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL); 102 blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
111
112 mutex_unlock(&inode->i_mutex);
113out: 103out:
114 trace_ext3_sync_file_exit(inode, ret); 104 trace_ext3_sync_file_exit(inode, ret);
115 return ret; 105 return ret;
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c
index bf09cbf938cc..635bd8ce6d59 100644
--- a/fs/ext3/ialloc.c
+++ b/fs/ext3/ialloc.c
@@ -178,42 +178,6 @@ error_return:
178} 178}
179 179
180/* 180/*
181 * There are two policies for allocating an inode. If the new inode is
182 * a directory, then a forward search is made for a block group with both
183 * free space and a low directory-to-inode ratio; if that fails, then of
184 * the groups with above-average free space, that group with the fewest
185 * directories already is chosen.
186 *
187 * For other inodes, search forward from the parent directory\'s block
188 * group to find a free inode.
189 */
190static int find_group_dir(struct super_block *sb, struct inode *parent)
191{
192 int ngroups = EXT3_SB(sb)->s_groups_count;
193 unsigned int freei, avefreei;
194 struct ext3_group_desc *desc, *best_desc = NULL;
195 int group, best_group = -1;
196
197 freei = percpu_counter_read_positive(&EXT3_SB(sb)->s_freeinodes_counter);
198 avefreei = freei / ngroups;
199
200 for (group = 0; group < ngroups; group++) {
201 desc = ext3_get_group_desc (sb, group, NULL);
202 if (!desc || !desc->bg_free_inodes_count)
203 continue;
204 if (le16_to_cpu(desc->bg_free_inodes_count) < avefreei)
205 continue;
206 if (!best_desc ||
207 (le16_to_cpu(desc->bg_free_blocks_count) >
208 le16_to_cpu(best_desc->bg_free_blocks_count))) {
209 best_group = group;
210 best_desc = desc;
211 }
212 }
213 return best_group;
214}
215
216/*
217 * Orlov's allocator for directories. 181 * Orlov's allocator for directories.
218 * 182 *
219 * We always try to spread first-level directories. 183 * We always try to spread first-level directories.
@@ -436,12 +400,9 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir,
436 400
437 sbi = EXT3_SB(sb); 401 sbi = EXT3_SB(sb);
438 es = sbi->s_es; 402 es = sbi->s_es;
439 if (S_ISDIR(mode)) { 403 if (S_ISDIR(mode))
440 if (test_opt (sb, OLDALLOC)) 404 group = find_group_orlov(sb, dir);
441 group = find_group_dir(sb, dir); 405 else
442 else
443 group = find_group_orlov(sb, dir);
444 } else
445 group = find_group_other(sb, dir); 406 group = find_group_other(sb, dir);
446 407
447 err = -ENOSPC; 408 err = -ENOSPC;
diff --git a/fs/ext3/ioctl.c b/fs/ext3/ioctl.c
index c7f43944f160..ba1b54e23cae 100644
--- a/fs/ext3/ioctl.c
+++ b/fs/ext3/ioctl.c
@@ -150,30 +150,6 @@ setversion_out:
150 mnt_drop_write(filp->f_path.mnt); 150 mnt_drop_write(filp->f_path.mnt);
151 return err; 151 return err;
152 } 152 }
153#ifdef CONFIG_JBD_DEBUG
154 case EXT3_IOC_WAIT_FOR_READONLY:
155 /*
156 * This is racy - by the time we're woken up and running,
157 * the superblock could be released. And the module could
158 * have been unloaded. So sue me.
159 *
160 * Returns 1 if it slept, else zero.
161 */
162 {
163 struct super_block *sb = inode->i_sb;
164 DECLARE_WAITQUEUE(wait, current);
165 int ret = 0;
166
167 set_current_state(TASK_INTERRUPTIBLE);
168 add_wait_queue(&EXT3_SB(sb)->ro_wait_queue, &wait);
169 if (timer_pending(&EXT3_SB(sb)->turn_ro_timer)) {
170 schedule();
171 ret = 1;
172 }
173 remove_wait_queue(&EXT3_SB(sb)->ro_wait_queue, &wait);
174 return ret;
175 }
176#endif
177 case EXT3_IOC_GETRSVSZ: 153 case EXT3_IOC_GETRSVSZ:
178 if (test_opt(inode->i_sb, RESERVATION) 154 if (test_opt(inode->i_sb, RESERVATION)
179 && S_ISREG(inode->i_mode) 155 && S_ISREG(inode->i_mode)
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 7beb69ae0015..922d289aeeb3 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -652,8 +652,6 @@ static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs)
652 seq_puts(seq, ",nouid32"); 652 seq_puts(seq, ",nouid32");
653 if (test_opt(sb, DEBUG)) 653 if (test_opt(sb, DEBUG))
654 seq_puts(seq, ",debug"); 654 seq_puts(seq, ",debug");
655 if (test_opt(sb, OLDALLOC))
656 seq_puts(seq, ",oldalloc");
657#ifdef CONFIG_EXT3_FS_XATTR 655#ifdef CONFIG_EXT3_FS_XATTR
658 if (test_opt(sb, XATTR_USER)) 656 if (test_opt(sb, XATTR_USER))
659 seq_puts(seq, ",user_xattr"); 657 seq_puts(seq, ",user_xattr");
@@ -1049,10 +1047,12 @@ static int parse_options (char *options, struct super_block *sb,
1049 set_opt (sbi->s_mount_opt, DEBUG); 1047 set_opt (sbi->s_mount_opt, DEBUG);
1050 break; 1048 break;
1051 case Opt_oldalloc: 1049 case Opt_oldalloc:
1052 set_opt (sbi->s_mount_opt, OLDALLOC); 1050 ext3_msg(sb, KERN_WARNING,
1051 "Ignoring deprecated oldalloc option");
1053 break; 1052 break;
1054 case Opt_orlov: 1053 case Opt_orlov:
1055 clear_opt (sbi->s_mount_opt, OLDALLOC); 1054 ext3_msg(sb, KERN_WARNING,
1055 "Ignoring deprecated orlov option");
1056 break; 1056 break;
1057#ifdef CONFIG_EXT3_FS_XATTR 1057#ifdef CONFIG_EXT3_FS_XATTR
1058 case Opt_user_xattr: 1058 case Opt_user_xattr:
@@ -2669,13 +2669,13 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2669 /* 2669 /*
2670 * If we have an unprocessed orphan list hanging 2670 * If we have an unprocessed orphan list hanging
2671 * around from a previously readonly bdev mount, 2671 * around from a previously readonly bdev mount,
2672 * require a full umount/remount for now. 2672 * require a full umount & mount for now.
2673 */ 2673 */
2674 if (es->s_last_orphan) { 2674 if (es->s_last_orphan) {
2675 ext3_msg(sb, KERN_WARNING, "warning: couldn't " 2675 ext3_msg(sb, KERN_WARNING, "warning: couldn't "
2676 "remount RDWR because of unprocessed " 2676 "remount RDWR because of unprocessed "
2677 "orphan inode list. Please " 2677 "orphan inode list. Please "
2678 "umount/remount instead."); 2678 "umount & mount instead.");
2679 err = -EINVAL; 2679 err = -EINVAL;
2680 goto restore_opts; 2680 goto restore_opts;
2681 } 2681 }
diff --git a/fs/quota/quota.c b/fs/quota/quota.c
index 10b6be3ca280..aae0edb95c6c 100644
--- a/fs/quota/quota.c
+++ b/fs/quota/quota.c
@@ -363,12 +363,15 @@ SYSCALL_DEFINE4(quotactl, unsigned int, cmd, const char __user *, special,
363 } 363 }
364 364
365 sb = quotactl_block(special); 365 sb = quotactl_block(special);
366 if (IS_ERR(sb)) 366 if (IS_ERR(sb)) {
367 return PTR_ERR(sb); 367 ret = PTR_ERR(sb);
368 goto out;
369 }
368 370
369 ret = do_quotactl(sb, type, cmds, id, addr, pathp); 371 ret = do_quotactl(sb, type, cmds, id, addr, pathp);
370 372
371 drop_super(sb); 373 drop_super(sb);
374out:
372 if (pathp && !IS_ERR(pathp)) 375 if (pathp && !IS_ERR(pathp))
373 path_put(pathp); 376 path_put(pathp);
374 return ret; 377 return ret;
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index 95518a9f589e..987585bb0a1d 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -59,8 +59,8 @@ static int __load_block_bitmap(struct super_block *sb,
59 int nr_groups = bitmap->s_nr_groups; 59 int nr_groups = bitmap->s_nr_groups;
60 60
61 if (block_group >= nr_groups) { 61 if (block_group >= nr_groups) {
62 udf_debug("block_group (%d) > nr_groups (%d)\n", block_group, 62 udf_debug("block_group (%d) > nr_groups (%d)\n",
63 nr_groups); 63 block_group, nr_groups);
64 } 64 }
65 65
66 if (bitmap->s_block_bitmap[block_group]) { 66 if (bitmap->s_block_bitmap[block_group]) {
@@ -126,8 +126,9 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
126 if (bloc->logicalBlockNum + count < count || 126 if (bloc->logicalBlockNum + count < count ||
127 (bloc->logicalBlockNum + count) > partmap->s_partition_len) { 127 (bloc->logicalBlockNum + count) > partmap->s_partition_len) {
128 udf_debug("%d < %d || %d + %d > %d\n", 128 udf_debug("%d < %d || %d + %d > %d\n",
129 bloc->logicalBlockNum, 0, bloc->logicalBlockNum, 129 bloc->logicalBlockNum, 0,
130 count, partmap->s_partition_len); 130 bloc->logicalBlockNum, count,
131 partmap->s_partition_len);
131 goto error_return; 132 goto error_return;
132 } 133 }
133 134
@@ -155,7 +156,7 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
155 if (udf_set_bit(bit + i, bh->b_data)) { 156 if (udf_set_bit(bit + i, bh->b_data)) {
156 udf_debug("bit %ld already set\n", bit + i); 157 udf_debug("bit %ld already set\n", bit + i);
157 udf_debug("byte=%2x\n", 158 udf_debug("byte=%2x\n",
158 ((char *)bh->b_data)[(bit + i) >> 3]); 159 ((char *)bh->b_data)[(bit + i) >> 3]);
159 } 160 }
160 } 161 }
161 udf_add_free_space(sb, sbi->s_partition, count); 162 udf_add_free_space(sb, sbi->s_partition, count);
@@ -369,7 +370,8 @@ static void udf_table_free_blocks(struct super_block *sb,
369 if (bloc->logicalBlockNum + count < count || 370 if (bloc->logicalBlockNum + count < count ||
370 (bloc->logicalBlockNum + count) > partmap->s_partition_len) { 371 (bloc->logicalBlockNum + count) > partmap->s_partition_len) {
371 udf_debug("%d < %d || %d + %d > %d\n", 372 udf_debug("%d < %d || %d + %d > %d\n",
372 bloc->logicalBlockNum, 0, bloc->logicalBlockNum, count, 373 bloc->logicalBlockNum, 0,
374 bloc->logicalBlockNum, count,
373 partmap->s_partition_len); 375 partmap->s_partition_len);
374 goto error_return; 376 goto error_return;
375 } 377 }
diff --git a/fs/udf/directory.c b/fs/udf/directory.c
index 2ffdb6733af1..3e44f575fb9c 100644
--- a/fs/udf/directory.c
+++ b/fs/udf/directory.c
@@ -162,8 +162,8 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)
162 int padlen; 162 int padlen;
163 163
164 if ((!buffer) || (!offset)) { 164 if ((!buffer) || (!offset)) {
165 udf_debug("invalidparms\n, buffer=%p, offset=%p\n", buffer, 165 udf_debug("invalidparms, buffer=%p, offset=%p\n",
166 offset); 166 buffer, offset);
167 return NULL; 167 return NULL;
168 } 168 }
169 169
@@ -201,7 +201,7 @@ struct short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, uint32_t *offs
201 struct short_ad *sa; 201 struct short_ad *sa;
202 202
203 if ((!ptr) || (!offset)) { 203 if ((!ptr) || (!offset)) {
204 printk(KERN_ERR "udf: udf_get_fileshortad() invalidparms\n"); 204 pr_err("%s: invalidparms\n", __func__);
205 return NULL; 205 return NULL;
206 } 206 }
207 207
@@ -223,7 +223,7 @@ struct long_ad *udf_get_filelongad(uint8_t *ptr, int maxoffset, uint32_t *offset
223 struct long_ad *la; 223 struct long_ad *la;
224 224
225 if ((!ptr) || (!offset)) { 225 if ((!ptr) || (!offset)) {
226 printk(KERN_ERR "udf: udf_get_filelongad() invalidparms\n"); 226 pr_err("%s: invalidparms\n", __func__);
227 return NULL; 227 return NULL;
228 } 228 }
229 229
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 1d1358ed80c1..329e7a108ab7 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -37,6 +37,7 @@
37#include <linux/writeback.h> 37#include <linux/writeback.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/crc-itu-t.h> 39#include <linux/crc-itu-t.h>
40#include <linux/mpage.h>
40 41
41#include "udf_i.h" 42#include "udf_i.h"
42#include "udf_sb.h" 43#include "udf_sb.h"
@@ -83,12 +84,10 @@ void udf_evict_inode(struct inode *inode)
83 end_writeback(inode); 84 end_writeback(inode);
84 if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB && 85 if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB &&
85 inode->i_size != iinfo->i_lenExtents) { 86 inode->i_size != iinfo->i_lenExtents) {
86 printk(KERN_WARNING "UDF-fs (%s): Inode %lu (mode %o) has " 87 udf_warn(inode->i_sb, "Inode %lu (mode %o) has inode size %llu different from extent length %llu. Filesystem need not be standards compliant.\n",
87 "inode size %llu different from extent length %llu. " 88 inode->i_ino, inode->i_mode,
88 "Filesystem need not be standards compliant.\n", 89 (unsigned long long)inode->i_size,
89 inode->i_sb->s_id, inode->i_ino, inode->i_mode, 90 (unsigned long long)iinfo->i_lenExtents);
90 (unsigned long long)inode->i_size,
91 (unsigned long long)iinfo->i_lenExtents);
92 } 91 }
93 kfree(iinfo->i_ext.i_data); 92 kfree(iinfo->i_ext.i_data);
94 iinfo->i_ext.i_data = NULL; 93 iinfo->i_ext.i_data = NULL;
@@ -104,7 +103,13 @@ static int udf_writepage(struct page *page, struct writeback_control *wbc)
104 103
105static int udf_readpage(struct file *file, struct page *page) 104static int udf_readpage(struct file *file, struct page *page)
106{ 105{
107 return block_read_full_page(page, udf_get_block); 106 return mpage_readpage(page, udf_get_block);
107}
108
109static int udf_readpages(struct file *file, struct address_space *mapping,
110 struct list_head *pages, unsigned nr_pages)
111{
112 return mpage_readpages(mapping, pages, nr_pages, udf_get_block);
108} 113}
109 114
110static int udf_write_begin(struct file *file, struct address_space *mapping, 115static int udf_write_begin(struct file *file, struct address_space *mapping,
@@ -139,6 +144,7 @@ static sector_t udf_bmap(struct address_space *mapping, sector_t block)
139 144
140const struct address_space_operations udf_aops = { 145const struct address_space_operations udf_aops = {
141 .readpage = udf_readpage, 146 .readpage = udf_readpage,
147 .readpages = udf_readpages,
142 .writepage = udf_writepage, 148 .writepage = udf_writepage,
143 .write_begin = udf_write_begin, 149 .write_begin = udf_write_begin,
144 .write_end = generic_write_end, 150 .write_end = generic_write_end,
@@ -1169,16 +1175,15 @@ static void __udf_read_inode(struct inode *inode)
1169 */ 1175 */
1170 bh = udf_read_ptagged(inode->i_sb, &iinfo->i_location, 0, &ident); 1176 bh = udf_read_ptagged(inode->i_sb, &iinfo->i_location, 0, &ident);
1171 if (!bh) { 1177 if (!bh) {
1172 printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed !bh\n", 1178 udf_err(inode->i_sb, "(ino %ld) failed !bh\n", inode->i_ino);
1173 inode->i_ino);
1174 make_bad_inode(inode); 1179 make_bad_inode(inode);
1175 return; 1180 return;
1176 } 1181 }
1177 1182
1178 if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE && 1183 if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE &&
1179 ident != TAG_IDENT_USE) { 1184 ident != TAG_IDENT_USE) {
1180 printk(KERN_ERR "udf: udf_read_inode(ino %ld) " 1185 udf_err(inode->i_sb, "(ino %ld) failed ident=%d\n",
1181 "failed ident=%d\n", inode->i_ino, ident); 1186 inode->i_ino, ident);
1182 brelse(bh); 1187 brelse(bh);
1183 make_bad_inode(inode); 1188 make_bad_inode(inode);
1184 return; 1189 return;
@@ -1218,8 +1223,8 @@ static void __udf_read_inode(struct inode *inode)
1218 } 1223 }
1219 brelse(ibh); 1224 brelse(ibh);
1220 } else if (fe->icbTag.strategyType != cpu_to_le16(4)) { 1225 } else if (fe->icbTag.strategyType != cpu_to_le16(4)) {
1221 printk(KERN_ERR "udf: unsupported strategy type: %d\n", 1226 udf_err(inode->i_sb, "unsupported strategy type: %d\n",
1222 le16_to_cpu(fe->icbTag.strategyType)); 1227 le16_to_cpu(fe->icbTag.strategyType));
1223 brelse(bh); 1228 brelse(bh);
1224 make_bad_inode(inode); 1229 make_bad_inode(inode);
1225 return; 1230 return;
@@ -1413,9 +1418,8 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
1413 udf_debug("METADATA BITMAP FILE-----\n"); 1418 udf_debug("METADATA BITMAP FILE-----\n");
1414 break; 1419 break;
1415 default: 1420 default:
1416 printk(KERN_ERR "udf: udf_fill_inode(ino %ld) failed unknown " 1421 udf_err(inode->i_sb, "(ino %ld) failed unknown file type=%d\n",
1417 "file type=%d\n", inode->i_ino, 1422 inode->i_ino, fe->icbTag.fileType);
1418 fe->icbTag.fileType);
1419 make_bad_inode(inode); 1423 make_bad_inode(inode);
1420 return; 1424 return;
1421 } 1425 }
@@ -1438,8 +1442,8 @@ static int udf_alloc_i_data(struct inode *inode, size_t size)
1438 iinfo->i_ext.i_data = kmalloc(size, GFP_KERNEL); 1442 iinfo->i_ext.i_data = kmalloc(size, GFP_KERNEL);
1439 1443
1440 if (!iinfo->i_ext.i_data) { 1444 if (!iinfo->i_ext.i_data) {
1441 printk(KERN_ERR "udf:udf_alloc_i_data (ino %ld) " 1445 udf_err(inode->i_sb, "(ino %ld) no free memory\n",
1442 "no free memory\n", inode->i_ino); 1446 inode->i_ino);
1443 return -ENOMEM; 1447 return -ENOMEM;
1444 } 1448 }
1445 1449
@@ -1689,9 +1693,8 @@ out:
1689 if (do_sync) { 1693 if (do_sync) {
1690 sync_dirty_buffer(bh); 1694 sync_dirty_buffer(bh);
1691 if (buffer_write_io_error(bh)) { 1695 if (buffer_write_io_error(bh)) {
1692 printk(KERN_WARNING "IO error syncing udf inode " 1696 udf_warn(inode->i_sb, "IO error syncing udf inode [%08lx]\n",
1693 "[%s:%08lx]\n", inode->i_sb->s_id, 1697 inode->i_ino);
1694 inode->i_ino);
1695 err = -EIO; 1698 err = -EIO;
1696 } 1699 }
1697 } 1700 }
@@ -1982,8 +1985,7 @@ int8_t udf_current_aext(struct inode *inode, struct extent_position *epos,
1982 *elen = le32_to_cpu(lad->extLength) & UDF_EXTENT_LENGTH_MASK; 1985 *elen = le32_to_cpu(lad->extLength) & UDF_EXTENT_LENGTH_MASK;
1983 break; 1986 break;
1984 default: 1987 default:
1985 udf_debug("alloc_type = %d unsupported\n", 1988 udf_debug("alloc_type = %d unsupported\n", iinfo->i_alloc_type);
1986 iinfo->i_alloc_type);
1987 return -1; 1989 return -1;
1988 } 1990 }
1989 1991
diff --git a/fs/udf/lowlevel.c b/fs/udf/lowlevel.c
index 43e24a3b8e10..6583fe9b0645 100644
--- a/fs/udf/lowlevel.c
+++ b/fs/udf/lowlevel.c
@@ -38,7 +38,7 @@ unsigned int udf_get_last_session(struct super_block *sb)
38 38
39 if (i == 0) { 39 if (i == 0) {
40 udf_debug("XA disk: %s, vol_desc_start=%d\n", 40 udf_debug("XA disk: %s, vol_desc_start=%d\n",
41 (ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba); 41 ms_info.xa_flag ? "yes" : "no", ms_info.addr.lba);
42 if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */ 42 if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */
43 vol_desc_start = ms_info.addr.lba; 43 vol_desc_start = ms_info.addr.lba;
44 } else { 44 } else {
diff --git a/fs/udf/misc.c b/fs/udf/misc.c
index 9215700c00a4..c175b4dabc14 100644
--- a/fs/udf/misc.c
+++ b/fs/udf/misc.c
@@ -204,6 +204,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
204{ 204{
205 struct tag *tag_p; 205 struct tag *tag_p;
206 struct buffer_head *bh = NULL; 206 struct buffer_head *bh = NULL;
207 u8 checksum;
207 208
208 /* Read the block */ 209 /* Read the block */
209 if (block == 0xFFFFFFFF) 210 if (block == 0xFFFFFFFF)
@@ -211,8 +212,8 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
211 212
212 bh = udf_tread(sb, block); 213 bh = udf_tread(sb, block);
213 if (!bh) { 214 if (!bh) {
214 udf_debug("block=%d, location=%d: read failed\n", 215 udf_err(sb, "read failed, block=%u, location=%d\n",
215 block, location); 216 block, location);
216 return NULL; 217 return NULL;
217 } 218 }
218 219
@@ -227,16 +228,18 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
227 } 228 }
228 229
229 /* Verify the tag checksum */ 230 /* Verify the tag checksum */
230 if (udf_tag_checksum(tag_p) != tag_p->tagChecksum) { 231 checksum = udf_tag_checksum(tag_p);
231 printk(KERN_ERR "udf: tag checksum failed block %d\n", block); 232 if (checksum != tag_p->tagChecksum) {
233 udf_err(sb, "tag checksum failed, block %u: 0x%02x != 0x%02x\n",
234 block, checksum, tag_p->tagChecksum);
232 goto error_out; 235 goto error_out;
233 } 236 }
234 237
235 /* Verify the tag version */ 238 /* Verify the tag version */
236 if (tag_p->descVersion != cpu_to_le16(0x0002U) && 239 if (tag_p->descVersion != cpu_to_le16(0x0002U) &&
237 tag_p->descVersion != cpu_to_le16(0x0003U)) { 240 tag_p->descVersion != cpu_to_le16(0x0003U)) {
238 udf_debug("tag version 0x%04x != 0x0002 || 0x0003 block %d\n", 241 udf_err(sb, "tag version 0x%04x != 0x0002 || 0x0003, block %u\n",
239 le16_to_cpu(tag_p->descVersion), block); 242 le16_to_cpu(tag_p->descVersion), block);
240 goto error_out; 243 goto error_out;
241 } 244 }
242 245
@@ -248,8 +251,8 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
248 return bh; 251 return bh;
249 252
250 udf_debug("Crc failure block %d: crc = %d, crclen = %d\n", block, 253 udf_debug("Crc failure block %d: crc = %d, crclen = %d\n", block,
251 le16_to_cpu(tag_p->descCRC), le16_to_cpu(tag_p->descCRCLength)); 254 le16_to_cpu(tag_p->descCRC),
252 255 le16_to_cpu(tag_p->descCRCLength));
253error_out: 256error_out:
254 brelse(bh); 257 brelse(bh);
255 return NULL; 258 return NULL;
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index f1dce848ef96..78d59ebd0656 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -799,9 +799,8 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry)
799 if (retval) 799 if (retval)
800 goto end_rmdir; 800 goto end_rmdir;
801 if (inode->i_nlink != 2) 801 if (inode->i_nlink != 2)
802 udf_warning(inode->i_sb, "udf_rmdir", 802 udf_warn(inode->i_sb, "empty directory has nlink != 2 (%d)\n",
803 "empty directory has nlink != 2 (%d)", 803 inode->i_nlink);
804 inode->i_nlink);
805 clear_nlink(inode); 804 clear_nlink(inode);
806 inode->i_size = 0; 805 inode->i_size = 0;
807 inode_dec_link_count(dir); 806 inode_dec_link_count(dir);
diff --git a/fs/udf/partition.c b/fs/udf/partition.c
index a71090ea0e07..d6caf01a2097 100644
--- a/fs/udf/partition.c
+++ b/fs/udf/partition.c
@@ -33,8 +33,8 @@ uint32_t udf_get_pblock(struct super_block *sb, uint32_t block,
33 struct udf_sb_info *sbi = UDF_SB(sb); 33 struct udf_sb_info *sbi = UDF_SB(sb);
34 struct udf_part_map *map; 34 struct udf_part_map *map;
35 if (partition >= sbi->s_partitions) { 35 if (partition >= sbi->s_partitions) {
36 udf_debug("block=%d, partition=%d, offset=%d: " 36 udf_debug("block=%d, partition=%d, offset=%d: invalid partition\n",
37 "invalid partition\n", block, partition, offset); 37 block, partition, offset);
38 return 0xFFFFFFFF; 38 return 0xFFFFFFFF;
39 } 39 }
40 map = &sbi->s_partmaps[partition]; 40 map = &sbi->s_partmaps[partition];
@@ -60,8 +60,8 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,
60 vdata = &map->s_type_specific.s_virtual; 60 vdata = &map->s_type_specific.s_virtual;
61 61
62 if (block > vdata->s_num_entries) { 62 if (block > vdata->s_num_entries) {
63 udf_debug("Trying to access block beyond end of VAT " 63 udf_debug("Trying to access block beyond end of VAT (%d max %d)\n",
64 "(%d max %d)\n", block, vdata->s_num_entries); 64 block, vdata->s_num_entries);
65 return 0xFFFFFFFF; 65 return 0xFFFFFFFF;
66 } 66 }
67 67
@@ -321,9 +321,14 @@ uint32_t udf_get_pblock_meta25(struct super_block *sb, uint32_t block,
321 /* We shouldn't mount such media... */ 321 /* We shouldn't mount such media... */
322 BUG_ON(!inode); 322 BUG_ON(!inode);
323 retblk = udf_try_read_meta(inode, block, partition, offset); 323 retblk = udf_try_read_meta(inode, block, partition, offset);
324 if (retblk == 0xFFFFFFFF) { 324 if (retblk == 0xFFFFFFFF && mdata->s_metadata_fe) {
325 udf_warning(sb, __func__, "error reading from METADATA, " 325 udf_warn(sb, "error reading from METADATA, trying to read from MIRROR\n");
326 "trying to read from MIRROR"); 326 if (!(mdata->s_flags & MF_MIRROR_FE_LOADED)) {
327 mdata->s_mirror_fe = udf_find_metadata_inode_efe(sb,
328 mdata->s_mirror_file_loc, map->s_partition_num);
329 mdata->s_flags |= MF_MIRROR_FE_LOADED;
330 }
331
327 inode = mdata->s_mirror_fe; 332 inode = mdata->s_mirror_fe;
328 if (!inode) 333 if (!inode)
329 return 0xFFFFFFFF; 334 return 0xFFFFFFFF;
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 7b27b063ff6d..e185253470df 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -75,8 +75,6 @@
75 75
76#define UDF_DEFAULT_BLOCKSIZE 2048 76#define UDF_DEFAULT_BLOCKSIZE 2048
77 77
78static char error_buf[1024];
79
80/* These are the "meat" - everything else is stuffing */ 78/* These are the "meat" - everything else is stuffing */
81static int udf_fill_super(struct super_block *, void *, int); 79static int udf_fill_super(struct super_block *, void *, int);
82static void udf_put_super(struct super_block *); 80static void udf_put_super(struct super_block *);
@@ -92,8 +90,6 @@ static void udf_close_lvid(struct super_block *);
92static unsigned int udf_count_free(struct super_block *); 90static unsigned int udf_count_free(struct super_block *);
93static int udf_statfs(struct dentry *, struct kstatfs *); 91static int udf_statfs(struct dentry *, struct kstatfs *);
94static int udf_show_options(struct seq_file *, struct vfsmount *); 92static int udf_show_options(struct seq_file *, struct vfsmount *);
95static void udf_error(struct super_block *sb, const char *function,
96 const char *fmt, ...);
97 93
98struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct udf_sb_info *sbi) 94struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct udf_sb_info *sbi)
99{ 95{
@@ -244,9 +240,8 @@ static int udf_sb_alloc_partition_maps(struct super_block *sb, u32 count)
244 sbi->s_partmaps = kcalloc(count, sizeof(struct udf_part_map), 240 sbi->s_partmaps = kcalloc(count, sizeof(struct udf_part_map),
245 GFP_KERNEL); 241 GFP_KERNEL);
246 if (!sbi->s_partmaps) { 242 if (!sbi->s_partmaps) {
247 udf_error(sb, __func__, 243 udf_err(sb, "Unable to allocate space for %d partition maps\n",
248 "Unable to allocate space for %d partition maps", 244 count);
249 count);
250 sbi->s_partitions = 0; 245 sbi->s_partitions = 0;
251 return -ENOMEM; 246 return -ENOMEM;
252 } 247 }
@@ -550,8 +545,7 @@ static int udf_parse_options(char *options, struct udf_options *uopt,
550 uopt->dmode = option & 0777; 545 uopt->dmode = option & 0777;
551 break; 546 break;
552 default: 547 default:
553 printk(KERN_ERR "udf: bad mount option \"%s\" " 548 pr_err("bad mount option \"%s\" or missing value\n", p);
554 "or missing value\n", p);
555 return 0; 549 return 0;
556 } 550 }
557 } 551 }
@@ -645,20 +639,16 @@ static loff_t udf_check_vsd(struct super_block *sb)
645 udf_debug("ISO9660 Boot Record found\n"); 639 udf_debug("ISO9660 Boot Record found\n");
646 break; 640 break;
647 case 1: 641 case 1:
648 udf_debug("ISO9660 Primary Volume Descriptor " 642 udf_debug("ISO9660 Primary Volume Descriptor found\n");
649 "found\n");
650 break; 643 break;
651 case 2: 644 case 2:
652 udf_debug("ISO9660 Supplementary Volume " 645 udf_debug("ISO9660 Supplementary Volume Descriptor found\n");
653 "Descriptor found\n");
654 break; 646 break;
655 case 3: 647 case 3:
656 udf_debug("ISO9660 Volume Partition Descriptor " 648 udf_debug("ISO9660 Volume Partition Descriptor found\n");
657 "found\n");
658 break; 649 break;
659 case 255: 650 case 255:
660 udf_debug("ISO9660 Volume Descriptor Set " 651 udf_debug("ISO9660 Volume Descriptor Set Terminator found\n");
661 "Terminator found\n");
662 break; 652 break;
663 default: 653 default:
664 udf_debug("ISO9660 VRS (%u) found\n", 654 udf_debug("ISO9660 VRS (%u) found\n",
@@ -809,8 +799,7 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
809 pvoldesc->recordingDateAndTime)) { 799 pvoldesc->recordingDateAndTime)) {
810#ifdef UDFFS_DEBUG 800#ifdef UDFFS_DEBUG
811 struct timestamp *ts = &pvoldesc->recordingDateAndTime; 801 struct timestamp *ts = &pvoldesc->recordingDateAndTime;
812 udf_debug("recording time %04u/%02u/%02u" 802 udf_debug("recording time %04u/%02u/%02u %02u:%02u (%x)\n",
813 " %02u:%02u (%x)\n",
814 le16_to_cpu(ts->year), ts->month, ts->day, ts->hour, 803 le16_to_cpu(ts->year), ts->month, ts->day, ts->hour,
815 ts->minute, le16_to_cpu(ts->typeAndTimezone)); 804 ts->minute, le16_to_cpu(ts->typeAndTimezone));
816#endif 805#endif
@@ -821,7 +810,7 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
821 strncpy(UDF_SB(sb)->s_volume_ident, outstr->u_name, 810 strncpy(UDF_SB(sb)->s_volume_ident, outstr->u_name,
822 outstr->u_len > 31 ? 31 : outstr->u_len); 811 outstr->u_len > 31 ? 31 : outstr->u_len);
823 udf_debug("volIdent[] = '%s'\n", 812 udf_debug("volIdent[] = '%s'\n",
824 UDF_SB(sb)->s_volume_ident); 813 UDF_SB(sb)->s_volume_ident);
825 } 814 }
826 815
827 if (!udf_build_ustr(instr, pvoldesc->volSetIdent, 128)) 816 if (!udf_build_ustr(instr, pvoldesc->volSetIdent, 128))
@@ -837,64 +826,57 @@ out1:
837 return ret; 826 return ret;
838} 827}
839 828
829struct inode *udf_find_metadata_inode_efe(struct super_block *sb,
830 u32 meta_file_loc, u32 partition_num)
831{
832 struct kernel_lb_addr addr;
833 struct inode *metadata_fe;
834
835 addr.logicalBlockNum = meta_file_loc;
836 addr.partitionReferenceNum = partition_num;
837
838 metadata_fe = udf_iget(sb, &addr);
839
840 if (metadata_fe == NULL)
841 udf_warn(sb, "metadata inode efe not found\n");
842 else if (UDF_I(metadata_fe)->i_alloc_type != ICBTAG_FLAG_AD_SHORT) {
843 udf_warn(sb, "metadata inode efe does not have short allocation descriptors!\n");
844 iput(metadata_fe);
845 metadata_fe = NULL;
846 }
847
848 return metadata_fe;
849}
850
840static int udf_load_metadata_files(struct super_block *sb, int partition) 851static int udf_load_metadata_files(struct super_block *sb, int partition)
841{ 852{
842 struct udf_sb_info *sbi = UDF_SB(sb); 853 struct udf_sb_info *sbi = UDF_SB(sb);
843 struct udf_part_map *map; 854 struct udf_part_map *map;
844 struct udf_meta_data *mdata; 855 struct udf_meta_data *mdata;
845 struct kernel_lb_addr addr; 856 struct kernel_lb_addr addr;
846 int fe_error = 0;
847 857
848 map = &sbi->s_partmaps[partition]; 858 map = &sbi->s_partmaps[partition];
849 mdata = &map->s_type_specific.s_metadata; 859 mdata = &map->s_type_specific.s_metadata;
850 860
851 /* metadata address */ 861 /* metadata address */
852 addr.logicalBlockNum = mdata->s_meta_file_loc;
853 addr.partitionReferenceNum = map->s_partition_num;
854
855 udf_debug("Metadata file location: block = %d part = %d\n", 862 udf_debug("Metadata file location: block = %d part = %d\n",
856 addr.logicalBlockNum, addr.partitionReferenceNum); 863 mdata->s_meta_file_loc, map->s_partition_num);
857 864
858 mdata->s_metadata_fe = udf_iget(sb, &addr); 865 mdata->s_metadata_fe = udf_find_metadata_inode_efe(sb,
866 mdata->s_meta_file_loc, map->s_partition_num);
859 867
860 if (mdata->s_metadata_fe == NULL) { 868 if (mdata->s_metadata_fe == NULL) {
861 udf_warning(sb, __func__, "metadata inode efe not found, " 869 /* mirror file entry */
862 "will try mirror inode."); 870 udf_debug("Mirror metadata file location: block = %d part = %d\n",
863 fe_error = 1; 871 mdata->s_mirror_file_loc, map->s_partition_num);
864 } else if (UDF_I(mdata->s_metadata_fe)->i_alloc_type !=
865 ICBTAG_FLAG_AD_SHORT) {
866 udf_warning(sb, __func__, "metadata inode efe does not have "
867 "short allocation descriptors!");
868 fe_error = 1;
869 iput(mdata->s_metadata_fe);
870 mdata->s_metadata_fe = NULL;
871 }
872 872
873 /* mirror file entry */ 873 mdata->s_mirror_fe = udf_find_metadata_inode_efe(sb,
874 addr.logicalBlockNum = mdata->s_mirror_file_loc; 874 mdata->s_mirror_file_loc, map->s_partition_num);
875 addr.partitionReferenceNum = map->s_partition_num;
876
877 udf_debug("Mirror metadata file location: block = %d part = %d\n",
878 addr.logicalBlockNum, addr.partitionReferenceNum);
879 875
880 mdata->s_mirror_fe = udf_iget(sb, &addr); 876 if (mdata->s_mirror_fe == NULL) {
881 877 udf_err(sb, "Both metadata and mirror metadata inode efe can not found\n");
882 if (mdata->s_mirror_fe == NULL) {
883 if (fe_error) {
884 udf_error(sb, __func__, "mirror inode efe not found "
885 "and metadata inode is missing too, exiting...");
886 goto error_exit;
887 } else
888 udf_warning(sb, __func__, "mirror inode efe not found,"
889 " but metadata inode is OK");
890 } else if (UDF_I(mdata->s_mirror_fe)->i_alloc_type !=
891 ICBTAG_FLAG_AD_SHORT) {
892 udf_warning(sb, __func__, "mirror inode efe does not have "
893 "short allocation descriptors!");
894 iput(mdata->s_mirror_fe);
895 mdata->s_mirror_fe = NULL;
896 if (fe_error)
897 goto error_exit; 878 goto error_exit;
879 }
898 } 880 }
899 881
900 /* 882 /*
@@ -907,18 +889,15 @@ static int udf_load_metadata_files(struct super_block *sb, int partition)
907 addr.partitionReferenceNum = map->s_partition_num; 889 addr.partitionReferenceNum = map->s_partition_num;
908 890
909 udf_debug("Bitmap file location: block = %d part = %d\n", 891 udf_debug("Bitmap file location: block = %d part = %d\n",
910 addr.logicalBlockNum, addr.partitionReferenceNum); 892 addr.logicalBlockNum, addr.partitionReferenceNum);
911 893
912 mdata->s_bitmap_fe = udf_iget(sb, &addr); 894 mdata->s_bitmap_fe = udf_iget(sb, &addr);
913 895
914 if (mdata->s_bitmap_fe == NULL) { 896 if (mdata->s_bitmap_fe == NULL) {
915 if (sb->s_flags & MS_RDONLY) 897 if (sb->s_flags & MS_RDONLY)
916 udf_warning(sb, __func__, "bitmap inode efe " 898 udf_warn(sb, "bitmap inode efe not found but it's ok since the disc is mounted read-only\n");
917 "not found but it's ok since the disc"
918 " is mounted read-only");
919 else { 899 else {
920 udf_error(sb, __func__, "bitmap inode efe not " 900 udf_err(sb, "bitmap inode efe not found and attempted read-write mount\n");
921 "found and attempted read-write mount");
922 goto error_exit; 901 goto error_exit;
923 } 902 }
924 } 903 }
@@ -971,9 +950,8 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index)
971 bitmap = vzalloc(size); /* TODO: get rid of vzalloc */ 950 bitmap = vzalloc(size); /* TODO: get rid of vzalloc */
972 951
973 if (bitmap == NULL) { 952 if (bitmap == NULL) {
974 udf_error(sb, __func__, 953 udf_err(sb, "Unable to allocate space for bitmap and %d buffer_head pointers\n",
975 "Unable to allocate space for bitmap " 954 nr_groups);
976 "and %d buffer_head pointers", nr_groups);
977 return NULL; 955 return NULL;
978 } 956 }
979 957
@@ -1003,10 +981,9 @@ static int udf_fill_partdesc_info(struct super_block *sb,
1003 if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_OVERWRITABLE)) 981 if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_OVERWRITABLE))
1004 map->s_partition_flags |= UDF_PART_FLAG_OVERWRITABLE; 982 map->s_partition_flags |= UDF_PART_FLAG_OVERWRITABLE;
1005 983
1006 udf_debug("Partition (%d type %x) starts at physical %d, " 984 udf_debug("Partition (%d type %x) starts at physical %d, block length %d\n",
1007 "block length %d\n", p_index, 985 p_index, map->s_partition_type,
1008 map->s_partition_type, map->s_partition_root, 986 map->s_partition_root, map->s_partition_len);
1009 map->s_partition_len);
1010 987
1011 if (strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) && 988 if (strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) &&
1012 strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03)) 989 strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03))
@@ -1023,12 +1000,12 @@ static int udf_fill_partdesc_info(struct super_block *sb,
1023 map->s_uspace.s_table = udf_iget(sb, &loc); 1000 map->s_uspace.s_table = udf_iget(sb, &loc);
1024 if (!map->s_uspace.s_table) { 1001 if (!map->s_uspace.s_table) {
1025 udf_debug("cannot load unallocSpaceTable (part %d)\n", 1002 udf_debug("cannot load unallocSpaceTable (part %d)\n",
1026 p_index); 1003 p_index);
1027 return 1; 1004 return 1;
1028 } 1005 }
1029 map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_TABLE; 1006 map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_TABLE;
1030 udf_debug("unallocSpaceTable (part %d) @ %ld\n", 1007 udf_debug("unallocSpaceTable (part %d) @ %ld\n",
1031 p_index, map->s_uspace.s_table->i_ino); 1008 p_index, map->s_uspace.s_table->i_ino);
1032 } 1009 }
1033 1010
1034 if (phd->unallocSpaceBitmap.extLength) { 1011 if (phd->unallocSpaceBitmap.extLength) {
@@ -1041,8 +1018,8 @@ static int udf_fill_partdesc_info(struct super_block *sb,
1041 bitmap->s_extPosition = le32_to_cpu( 1018 bitmap->s_extPosition = le32_to_cpu(
1042 phd->unallocSpaceBitmap.extPosition); 1019 phd->unallocSpaceBitmap.extPosition);
1043 map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_BITMAP; 1020 map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_BITMAP;
1044 udf_debug("unallocSpaceBitmap (part %d) @ %d\n", p_index, 1021 udf_debug("unallocSpaceBitmap (part %d) @ %d\n",
1045 bitmap->s_extPosition); 1022 p_index, bitmap->s_extPosition);
1046 } 1023 }
1047 1024
1048 if (phd->partitionIntegrityTable.extLength) 1025 if (phd->partitionIntegrityTable.extLength)
@@ -1058,13 +1035,13 @@ static int udf_fill_partdesc_info(struct super_block *sb,
1058 map->s_fspace.s_table = udf_iget(sb, &loc); 1035 map->s_fspace.s_table = udf_iget(sb, &loc);
1059 if (!map->s_fspace.s_table) { 1036 if (!map->s_fspace.s_table) {
1060 udf_debug("cannot load freedSpaceTable (part %d)\n", 1037 udf_debug("cannot load freedSpaceTable (part %d)\n",
1061 p_index); 1038 p_index);
1062 return 1; 1039 return 1;
1063 } 1040 }
1064 1041
1065 map->s_partition_flags |= UDF_PART_FLAG_FREED_TABLE; 1042 map->s_partition_flags |= UDF_PART_FLAG_FREED_TABLE;
1066 udf_debug("freedSpaceTable (part %d) @ %ld\n", 1043 udf_debug("freedSpaceTable (part %d) @ %ld\n",
1067 p_index, map->s_fspace.s_table->i_ino); 1044 p_index, map->s_fspace.s_table->i_ino);
1068 } 1045 }
1069 1046
1070 if (phd->freedSpaceBitmap.extLength) { 1047 if (phd->freedSpaceBitmap.extLength) {
@@ -1077,8 +1054,8 @@ static int udf_fill_partdesc_info(struct super_block *sb,
1077 bitmap->s_extPosition = le32_to_cpu( 1054 bitmap->s_extPosition = le32_to_cpu(
1078 phd->freedSpaceBitmap.extPosition); 1055 phd->freedSpaceBitmap.extPosition);
1079 map->s_partition_flags |= UDF_PART_FLAG_FREED_BITMAP; 1056 map->s_partition_flags |= UDF_PART_FLAG_FREED_BITMAP;
1080 udf_debug("freedSpaceBitmap (part %d) @ %d\n", p_index, 1057 udf_debug("freedSpaceBitmap (part %d) @ %d\n",
1081 bitmap->s_extPosition); 1058 p_index, bitmap->s_extPosition);
1082 } 1059 }
1083 return 0; 1060 return 0;
1084} 1061}
@@ -1118,11 +1095,9 @@ static int udf_load_vat(struct super_block *sb, int p_index, int type1_index)
1118 udf_find_vat_block(sb, p_index, type1_index, sbi->s_last_block); 1095 udf_find_vat_block(sb, p_index, type1_index, sbi->s_last_block);
1119 if (!sbi->s_vat_inode && 1096 if (!sbi->s_vat_inode &&
1120 sbi->s_last_block != blocks - 1) { 1097 sbi->s_last_block != blocks - 1) {
1121 printk(KERN_NOTICE "UDF-fs: Failed to read VAT inode from the" 1098 pr_notice("Failed to read VAT inode from the last recorded block (%lu), retrying with the last block of the device (%lu).\n",
1122 " last recorded block (%lu), retrying with the last " 1099 (unsigned long)sbi->s_last_block,
1123 "block of the device (%lu).\n", 1100 (unsigned long)blocks - 1);
1124 (unsigned long)sbi->s_last_block,
1125 (unsigned long)blocks - 1);
1126 udf_find_vat_block(sb, p_index, type1_index, blocks - 1); 1101 udf_find_vat_block(sb, p_index, type1_index, blocks - 1);
1127 } 1102 }
1128 if (!sbi->s_vat_inode) 1103 if (!sbi->s_vat_inode)
@@ -1220,8 +1195,8 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block)
1220 if (map->s_partition_type == UDF_METADATA_MAP25) { 1195 if (map->s_partition_type == UDF_METADATA_MAP25) {
1221 ret = udf_load_metadata_files(sb, i); 1196 ret = udf_load_metadata_files(sb, i);
1222 if (ret) { 1197 if (ret) {
1223 printk(KERN_ERR "UDF-fs: error loading MetaData " 1198 udf_err(sb, "error loading MetaData partition map %d\n",
1224 "partition map %d\n", i); 1199 i);
1225 goto out_bh; 1200 goto out_bh;
1226 } 1201 }
1227 } else { 1202 } else {
@@ -1234,9 +1209,7 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block)
1234 * overwrite blocks instead of relocating them). 1209 * overwrite blocks instead of relocating them).
1235 */ 1210 */
1236 sb->s_flags |= MS_RDONLY; 1211 sb->s_flags |= MS_RDONLY;
1237 printk(KERN_NOTICE "UDF-fs: Filesystem marked read-only " 1212 pr_notice("Filesystem marked read-only because writing to pseudooverwrite partition is not implemented\n");
1238 "because writing to pseudooverwrite partition is "
1239 "not implemented.\n");
1240 } 1213 }
1241out_bh: 1214out_bh:
1242 /* In case loading failed, we handle cleanup in udf_fill_super */ 1215 /* In case loading failed, we handle cleanup in udf_fill_super */
@@ -1344,9 +1317,8 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,
1344 struct metadataPartitionMap *mdm = 1317 struct metadataPartitionMap *mdm =
1345 (struct metadataPartitionMap *) 1318 (struct metadataPartitionMap *)
1346 &(lvd->partitionMaps[offset]); 1319 &(lvd->partitionMaps[offset]);
1347 udf_debug("Parsing Logical vol part %d " 1320 udf_debug("Parsing Logical vol part %d type %d id=%s\n",
1348 "type %d id=%s\n", i, type, 1321 i, type, UDF_ID_METADATA);
1349 UDF_ID_METADATA);
1350 1322
1351 map->s_partition_type = UDF_METADATA_MAP25; 1323 map->s_partition_type = UDF_METADATA_MAP25;
1352 map->s_partition_func = udf_get_pblock_meta25; 1324 map->s_partition_func = udf_get_pblock_meta25;
@@ -1361,25 +1333,24 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,
1361 le32_to_cpu(mdm->allocUnitSize); 1333 le32_to_cpu(mdm->allocUnitSize);
1362 mdata->s_align_unit_size = 1334 mdata->s_align_unit_size =
1363 le16_to_cpu(mdm->alignUnitSize); 1335 le16_to_cpu(mdm->alignUnitSize);
1364 mdata->s_dup_md_flag = 1336 if (mdm->flags & 0x01)
1365 mdm->flags & 0x01; 1337 mdata->s_flags |= MF_DUPLICATE_MD;
1366 1338
1367 udf_debug("Metadata Ident suffix=0x%x\n", 1339 udf_debug("Metadata Ident suffix=0x%x\n",
1368 (le16_to_cpu( 1340 le16_to_cpu(*(__le16 *)
1369 ((__le16 *) 1341 mdm->partIdent.identSuffix));
1370 mdm->partIdent.identSuffix)[0])));
1371 udf_debug("Metadata part num=%d\n", 1342 udf_debug("Metadata part num=%d\n",
1372 le16_to_cpu(mdm->partitionNum)); 1343 le16_to_cpu(mdm->partitionNum));
1373 udf_debug("Metadata part alloc unit size=%d\n", 1344 udf_debug("Metadata part alloc unit size=%d\n",
1374 le32_to_cpu(mdm->allocUnitSize)); 1345 le32_to_cpu(mdm->allocUnitSize));
1375 udf_debug("Metadata file loc=%d\n", 1346 udf_debug("Metadata file loc=%d\n",
1376 le32_to_cpu(mdm->metadataFileLoc)); 1347 le32_to_cpu(mdm->metadataFileLoc));
1377 udf_debug("Mirror file loc=%d\n", 1348 udf_debug("Mirror file loc=%d\n",
1378 le32_to_cpu(mdm->metadataMirrorFileLoc)); 1349 le32_to_cpu(mdm->metadataMirrorFileLoc));
1379 udf_debug("Bitmap file loc=%d\n", 1350 udf_debug("Bitmap file loc=%d\n",
1380 le32_to_cpu(mdm->metadataBitmapFileLoc)); 1351 le32_to_cpu(mdm->metadataBitmapFileLoc));
1381 udf_debug("Duplicate Flag: %d %d\n", 1352 udf_debug("Flags: %d %d\n",
1382 mdata->s_dup_md_flag, mdm->flags); 1353 mdata->s_flags, mdm->flags);
1383 } else { 1354 } else {
1384 udf_debug("Unknown ident: %s\n", 1355 udf_debug("Unknown ident: %s\n",
1385 upm2->partIdent.ident); 1356 upm2->partIdent.ident);
@@ -1389,16 +1360,15 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,
1389 map->s_partition_num = le16_to_cpu(upm2->partitionNum); 1360 map->s_partition_num = le16_to_cpu(upm2->partitionNum);
1390 } 1361 }
1391 udf_debug("Partition (%d:%d) type %d on volume %d\n", 1362 udf_debug("Partition (%d:%d) type %d on volume %d\n",
1392 i, map->s_partition_num, type, 1363 i, map->s_partition_num, type, map->s_volumeseqnum);
1393 map->s_volumeseqnum);
1394 } 1364 }
1395 1365
1396 if (fileset) { 1366 if (fileset) {
1397 struct long_ad *la = (struct long_ad *)&(lvd->logicalVolContentsUse[0]); 1367 struct long_ad *la = (struct long_ad *)&(lvd->logicalVolContentsUse[0]);
1398 1368
1399 *fileset = lelb_to_cpu(la->extLocation); 1369 *fileset = lelb_to_cpu(la->extLocation);
1400 udf_debug("FileSet found in LogicalVolDesc at block=%d, " 1370 udf_debug("FileSet found in LogicalVolDesc at block=%d, partition=%d\n",
1401 "partition=%d\n", fileset->logicalBlockNum, 1371 fileset->logicalBlockNum,
1402 fileset->partitionReferenceNum); 1372 fileset->partitionReferenceNum);
1403 } 1373 }
1404 if (lvd->integritySeqExt.extLength) 1374 if (lvd->integritySeqExt.extLength)
@@ -1478,9 +1448,9 @@ static noinline int udf_process_sequence(struct super_block *sb, long block,
1478 1448
1479 bh = udf_read_tagged(sb, block, block, &ident); 1449 bh = udf_read_tagged(sb, block, block, &ident);
1480 if (!bh) { 1450 if (!bh) {
1481 printk(KERN_ERR "udf: Block %Lu of volume descriptor " 1451 udf_err(sb,
1482 "sequence is corrupted or we could not read " 1452 "Block %llu of volume descriptor sequence is corrupted or we could not read it\n",
1483 "it.\n", (unsigned long long)block); 1453 (unsigned long long)block);
1484 return 1; 1454 return 1;
1485 } 1455 }
1486 1456
@@ -1553,7 +1523,7 @@ static noinline int udf_process_sequence(struct super_block *sb, long block,
1553 * in a suitable order 1523 * in a suitable order
1554 */ 1524 */
1555 if (!vds[VDS_POS_PRIMARY_VOL_DESC].block) { 1525 if (!vds[VDS_POS_PRIMARY_VOL_DESC].block) {
1556 printk(KERN_ERR "udf: Primary Volume Descriptor not found!\n"); 1526 udf_err(sb, "Primary Volume Descriptor not found!\n");
1557 return 1; 1527 return 1;
1558 } 1528 }
1559 if (udf_load_pvoldesc(sb, vds[VDS_POS_PRIMARY_VOL_DESC].block)) 1529 if (udf_load_pvoldesc(sb, vds[VDS_POS_PRIMARY_VOL_DESC].block))
@@ -1740,7 +1710,7 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt,
1740 1710
1741 if (!sb_set_blocksize(sb, uopt->blocksize)) { 1711 if (!sb_set_blocksize(sb, uopt->blocksize)) {
1742 if (!silent) 1712 if (!silent)
1743 printk(KERN_WARNING "UDF-fs: Bad block size\n"); 1713 udf_warn(sb, "Bad block size\n");
1744 return 0; 1714 return 0;
1745 } 1715 }
1746 sbi->s_last_block = uopt->lastblock; 1716 sbi->s_last_block = uopt->lastblock;
@@ -1749,12 +1719,11 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt,
1749 nsr_off = udf_check_vsd(sb); 1719 nsr_off = udf_check_vsd(sb);
1750 if (!nsr_off) { 1720 if (!nsr_off) {
1751 if (!silent) 1721 if (!silent)
1752 printk(KERN_WARNING "UDF-fs: No VRS found\n"); 1722 udf_warn(sb, "No VRS found\n");
1753 return 0; 1723 return 0;
1754 } 1724 }
1755 if (nsr_off == -1) 1725 if (nsr_off == -1)
1756 udf_debug("Failed to read byte 32768. Assuming open " 1726 udf_debug("Failed to read byte 32768. Assuming open disc. Skipping validity check\n");
1757 "disc. Skipping validity check\n");
1758 if (!sbi->s_last_block) 1727 if (!sbi->s_last_block)
1759 sbi->s_last_block = udf_get_last_block(sb); 1728 sbi->s_last_block = udf_get_last_block(sb);
1760 } else { 1729 } else {
@@ -1765,7 +1734,7 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt,
1765 sbi->s_anchor = uopt->anchor; 1734 sbi->s_anchor = uopt->anchor;
1766 if (!udf_find_anchor(sb, fileset)) { 1735 if (!udf_find_anchor(sb, fileset)) {
1767 if (!silent) 1736 if (!silent)
1768 printk(KERN_WARNING "UDF-fs: No anchor found\n"); 1737 udf_warn(sb, "No anchor found\n");
1769 return 0; 1738 return 0;
1770 } 1739 }
1771 return 1; 1740 return 1;
@@ -1937,8 +1906,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1937 1906
1938 if (uopt.flags & (1 << UDF_FLAG_UTF8) && 1907 if (uopt.flags & (1 << UDF_FLAG_UTF8) &&
1939 uopt.flags & (1 << UDF_FLAG_NLS_MAP)) { 1908 uopt.flags & (1 << UDF_FLAG_NLS_MAP)) {
1940 udf_error(sb, "udf_read_super", 1909 udf_err(sb, "utf8 cannot be combined with iocharset\n");
1941 "utf8 cannot be combined with iocharset\n");
1942 goto error_out; 1910 goto error_out;
1943 } 1911 }
1944#ifdef CONFIG_UDF_NLS 1912#ifdef CONFIG_UDF_NLS
@@ -1987,15 +1955,14 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1987 ret = udf_load_vrs(sb, &uopt, silent, &fileset); 1955 ret = udf_load_vrs(sb, &uopt, silent, &fileset);
1988 if (!ret && uopt.blocksize != UDF_DEFAULT_BLOCKSIZE) { 1956 if (!ret && uopt.blocksize != UDF_DEFAULT_BLOCKSIZE) {
1989 if (!silent) 1957 if (!silent)
1990 printk(KERN_NOTICE 1958 pr_notice("Rescanning with blocksize %d\n",
1991 "UDF-fs: Rescanning with blocksize " 1959 UDF_DEFAULT_BLOCKSIZE);
1992 "%d\n", UDF_DEFAULT_BLOCKSIZE);
1993 uopt.blocksize = UDF_DEFAULT_BLOCKSIZE; 1960 uopt.blocksize = UDF_DEFAULT_BLOCKSIZE;
1994 ret = udf_load_vrs(sb, &uopt, silent, &fileset); 1961 ret = udf_load_vrs(sb, &uopt, silent, &fileset);
1995 } 1962 }
1996 } 1963 }
1997 if (!ret) { 1964 if (!ret) {
1998 printk(KERN_WARNING "UDF-fs: No partition found (1)\n"); 1965 udf_warn(sb, "No partition found (1)\n");
1999 goto error_out; 1966 goto error_out;
2000 } 1967 }
2001 1968
@@ -2010,10 +1977,9 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
2010 le16_to_cpu(lvidiu->maxUDFWriteRev); */ 1977 le16_to_cpu(lvidiu->maxUDFWriteRev); */
2011 1978
2012 if (minUDFReadRev > UDF_MAX_READ_VERSION) { 1979 if (minUDFReadRev > UDF_MAX_READ_VERSION) {
2013 printk(KERN_ERR "UDF-fs: minUDFReadRev=%x " 1980 udf_err(sb, "minUDFReadRev=%x (max is %x)\n",
2014 "(max is %x)\n", 1981 le16_to_cpu(lvidiu->minUDFReadRev),
2015 le16_to_cpu(lvidiu->minUDFReadRev), 1982 UDF_MAX_READ_VERSION);
2016 UDF_MAX_READ_VERSION);
2017 goto error_out; 1983 goto error_out;
2018 } else if (minUDFWriteRev > UDF_MAX_WRITE_VERSION) 1984 } else if (minUDFWriteRev > UDF_MAX_WRITE_VERSION)
2019 sb->s_flags |= MS_RDONLY; 1985 sb->s_flags |= MS_RDONLY;
@@ -2027,28 +1993,27 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
2027 } 1993 }
2028 1994
2029 if (!sbi->s_partitions) { 1995 if (!sbi->s_partitions) {
2030 printk(KERN_WARNING "UDF-fs: No partition found (2)\n"); 1996 udf_warn(sb, "No partition found (2)\n");
2031 goto error_out; 1997 goto error_out;
2032 } 1998 }
2033 1999
2034 if (sbi->s_partmaps[sbi->s_partition].s_partition_flags & 2000 if (sbi->s_partmaps[sbi->s_partition].s_partition_flags &
2035 UDF_PART_FLAG_READ_ONLY) { 2001 UDF_PART_FLAG_READ_ONLY) {
2036 printk(KERN_NOTICE "UDF-fs: Partition marked readonly; " 2002 pr_notice("Partition marked readonly; forcing readonly mount\n");
2037 "forcing readonly mount\n");
2038 sb->s_flags |= MS_RDONLY; 2003 sb->s_flags |= MS_RDONLY;
2039 } 2004 }
2040 2005
2041 if (udf_find_fileset(sb, &fileset, &rootdir)) { 2006 if (udf_find_fileset(sb, &fileset, &rootdir)) {
2042 printk(KERN_WARNING "UDF-fs: No fileset found\n"); 2007 udf_warn(sb, "No fileset found\n");
2043 goto error_out; 2008 goto error_out;
2044 } 2009 }
2045 2010
2046 if (!silent) { 2011 if (!silent) {
2047 struct timestamp ts; 2012 struct timestamp ts;
2048 udf_time_to_disk_stamp(&ts, sbi->s_record_time); 2013 udf_time_to_disk_stamp(&ts, sbi->s_record_time);
2049 udf_info("UDF: Mounting volume '%s', " 2014 udf_info("Mounting volume '%s', timestamp %04u/%02u/%02u %02u:%02u (%x)\n",
2050 "timestamp %04u/%02u/%02u %02u:%02u (%x)\n", 2015 sbi->s_volume_ident,
2051 sbi->s_volume_ident, le16_to_cpu(ts.year), ts.month, ts.day, 2016 le16_to_cpu(ts.year), ts.month, ts.day,
2052 ts.hour, ts.minute, le16_to_cpu(ts.typeAndTimezone)); 2017 ts.hour, ts.minute, le16_to_cpu(ts.typeAndTimezone));
2053 } 2018 }
2054 if (!(sb->s_flags & MS_RDONLY)) 2019 if (!(sb->s_flags & MS_RDONLY))
@@ -2059,8 +2024,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
2059 /* perhaps it's not extensible enough, but for now ... */ 2024 /* perhaps it's not extensible enough, but for now ... */
2060 inode = udf_iget(sb, &rootdir); 2025 inode = udf_iget(sb, &rootdir);
2061 if (!inode) { 2026 if (!inode) {
2062 printk(KERN_ERR "UDF-fs: Error in udf_iget, block=%d, " 2027 udf_err(sb, "Error in udf_iget, block=%d, partition=%d\n",
2063 "partition=%d\n",
2064 rootdir.logicalBlockNum, rootdir.partitionReferenceNum); 2028 rootdir.logicalBlockNum, rootdir.partitionReferenceNum);
2065 goto error_out; 2029 goto error_out;
2066 } 2030 }
@@ -2068,7 +2032,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
2068 /* Allocate a dentry for the root inode */ 2032 /* Allocate a dentry for the root inode */
2069 sb->s_root = d_alloc_root(inode); 2033 sb->s_root = d_alloc_root(inode);
2070 if (!sb->s_root) { 2034 if (!sb->s_root) {
2071 printk(KERN_ERR "UDF-fs: Couldn't allocate root dentry\n"); 2035 udf_err(sb, "Couldn't allocate root dentry\n");
2072 iput(inode); 2036 iput(inode);
2073 goto error_out; 2037 goto error_out;
2074 } 2038 }
@@ -2096,32 +2060,40 @@ error_out:
2096 return -EINVAL; 2060 return -EINVAL;
2097} 2061}
2098 2062
2099static void udf_error(struct super_block *sb, const char *function, 2063void _udf_err(struct super_block *sb, const char *function,
2100 const char *fmt, ...) 2064 const char *fmt, ...)
2101{ 2065{
2066 struct va_format vaf;
2102 va_list args; 2067 va_list args;
2103 2068
2104 if (!(sb->s_flags & MS_RDONLY)) { 2069 /* mark sb error */
2105 /* mark sb error */ 2070 if (!(sb->s_flags & MS_RDONLY))
2106 sb->s_dirt = 1; 2071 sb->s_dirt = 1;
2107 } 2072
2108 va_start(args, fmt); 2073 va_start(args, fmt);
2109 vsnprintf(error_buf, sizeof(error_buf), fmt, args); 2074
2075 vaf.fmt = fmt;
2076 vaf.va = &args;
2077
2078 pr_err("error (device %s): %s: %pV", sb->s_id, function, &vaf);
2079
2110 va_end(args); 2080 va_end(args);
2111 printk(KERN_CRIT "UDF-fs error (device %s): %s: %s\n",
2112 sb->s_id, function, error_buf);
2113} 2081}
2114 2082
2115void udf_warning(struct super_block *sb, const char *function, 2083void _udf_warn(struct super_block *sb, const char *function,
2116 const char *fmt, ...) 2084 const char *fmt, ...)
2117{ 2085{
2086 struct va_format vaf;
2118 va_list args; 2087 va_list args;
2119 2088
2120 va_start(args, fmt); 2089 va_start(args, fmt);
2121 vsnprintf(error_buf, sizeof(error_buf), fmt, args); 2090
2091 vaf.fmt = fmt;
2092 vaf.va = &args;
2093
2094 pr_warn("warning (device %s): %s: %pV", sb->s_id, function, &vaf);
2095
2122 va_end(args); 2096 va_end(args);
2123 printk(KERN_WARNING "UDF-fs warning (device %s): %s: %s\n",
2124 sb->s_id, function, error_buf);
2125} 2097}
2126 2098
2127static void udf_put_super(struct super_block *sb) 2099static void udf_put_super(struct super_block *sb)
@@ -2213,11 +2185,11 @@ static unsigned int udf_count_free_bitmap(struct super_block *sb,
2213 bh = udf_read_ptagged(sb, &loc, 0, &ident); 2185 bh = udf_read_ptagged(sb, &loc, 0, &ident);
2214 2186
2215 if (!bh) { 2187 if (!bh) {
2216 printk(KERN_ERR "udf: udf_count_free failed\n"); 2188 udf_err(sb, "udf_count_free failed\n");
2217 goto out; 2189 goto out;
2218 } else if (ident != TAG_IDENT_SBD) { 2190 } else if (ident != TAG_IDENT_SBD) {
2219 brelse(bh); 2191 brelse(bh);
2220 printk(KERN_ERR "udf: udf_count_free failed\n"); 2192 udf_err(sb, "udf_count_free failed\n");
2221 goto out; 2193 goto out;
2222 } 2194 }
2223 2195
diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c
index 8424308db4b4..4b98fee8e161 100644
--- a/fs/udf/truncate.c
+++ b/fs/udf/truncate.c
@@ -95,23 +95,21 @@ void udf_truncate_tail_extent(struct inode *inode)
95 lbcount += elen; 95 lbcount += elen;
96 if (lbcount > inode->i_size) { 96 if (lbcount > inode->i_size) {
97 if (lbcount - inode->i_size >= inode->i_sb->s_blocksize) 97 if (lbcount - inode->i_size >= inode->i_sb->s_blocksize)
98 printk(KERN_WARNING 98 udf_warn(inode->i_sb,
99 "udf_truncate_tail_extent(): Too long " 99 "Too long extent after EOF in inode %u: i_size: %lld lbcount: %lld extent %u+%u\n",
100 "extent after EOF in inode %u: i_size: " 100 (unsigned)inode->i_ino,
101 "%Ld lbcount: %Ld extent %u+%u\n", 101 (long long)inode->i_size,
102 (unsigned)inode->i_ino, 102 (long long)lbcount,
103 (long long)inode->i_size, 103 (unsigned)eloc.logicalBlockNum,
104 (long long)lbcount, 104 (unsigned)elen);
105 (unsigned)eloc.logicalBlockNum,
106 (unsigned)elen);
107 nelen = elen - (lbcount - inode->i_size); 105 nelen = elen - (lbcount - inode->i_size);
108 epos.offset -= adsize; 106 epos.offset -= adsize;
109 extent_trunc(inode, &epos, &eloc, etype, elen, nelen); 107 extent_trunc(inode, &epos, &eloc, etype, elen, nelen);
110 epos.offset += adsize; 108 epos.offset += adsize;
111 if (udf_next_aext(inode, &epos, &eloc, &elen, 1) != -1) 109 if (udf_next_aext(inode, &epos, &eloc, &elen, 1) != -1)
112 printk(KERN_ERR "udf_truncate_tail_extent(): " 110 udf_err(inode->i_sb,
113 "Extent after EOF in inode %u.\n", 111 "Extent after EOF in inode %u\n",
114 (unsigned)inode->i_ino); 112 (unsigned)inode->i_ino);
115 break; 113 break;
116 } 114 }
117 } 115 }
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index 4858c191242b..5142a82e3276 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -54,13 +54,16 @@
54 54
55#pragma pack(1) /* XXX(hch): Why? This file just defines in-core structures */ 55#pragma pack(1) /* XXX(hch): Why? This file just defines in-core structures */
56 56
57#define MF_DUPLICATE_MD 0x01
58#define MF_MIRROR_FE_LOADED 0x02
59
57struct udf_meta_data { 60struct udf_meta_data {
58 __u32 s_meta_file_loc; 61 __u32 s_meta_file_loc;
59 __u32 s_mirror_file_loc; 62 __u32 s_mirror_file_loc;
60 __u32 s_bitmap_file_loc; 63 __u32 s_bitmap_file_loc;
61 __u32 s_alloc_unit_size; 64 __u32 s_alloc_unit_size;
62 __u16 s_align_unit_size; 65 __u16 s_align_unit_size;
63 __u8 s_dup_md_flag; 66 int s_flags;
64 struct inode *s_metadata_fe; 67 struct inode *s_metadata_fe;
65 struct inode *s_mirror_fe; 68 struct inode *s_mirror_fe;
66 struct inode *s_bitmap_fe; 69 struct inode *s_bitmap_fe;
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index dc8a8dcc5ae1..f34e6fc0cdaa 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -1,6 +1,8 @@
1#ifndef __UDF_DECL_H 1#ifndef __UDF_DECL_H
2#define __UDF_DECL_H 2#define __UDF_DECL_H
3 3
4#define pr_fmt(fmt) "UDF-fs: " fmt
5
4#include "ecma_167.h" 6#include "ecma_167.h"
5#include "osta_udf.h" 7#include "osta_udf.h"
6 8
@@ -16,23 +18,30 @@
16#define UDF_PREALLOCATE 18#define UDF_PREALLOCATE
17#define UDF_DEFAULT_PREALLOC_BLOCKS 8 19#define UDF_DEFAULT_PREALLOC_BLOCKS 8
18 20
21extern __printf(3, 4) void _udf_err(struct super_block *sb,
22 const char *function, const char *fmt, ...);
23#define udf_err(sb, fmt, ...) \
24 _udf_err(sb, __func__, fmt, ##__VA_ARGS__)
25
26extern __printf(3, 4) void _udf_warn(struct super_block *sb,
27 const char *function, const char *fmt, ...);
28#define udf_warn(sb, fmt, ...) \
29 _udf_warn(sb, __func__, fmt, ##__VA_ARGS__)
30
31#define udf_info(fmt, ...) \
32 pr_info("INFO " fmt, ##__VA_ARGS__)
33
19#undef UDFFS_DEBUG 34#undef UDFFS_DEBUG
20 35
21#ifdef UDFFS_DEBUG 36#ifdef UDFFS_DEBUG
22#define udf_debug(f, a...) \ 37#define udf_debug(fmt, ...) \
23do { \ 38 printk(KERN_DEBUG pr_fmt("%s:%d:%s: " fmt), \
24 printk(KERN_DEBUG "UDF-fs DEBUG %s:%d:%s: ", \ 39 __FILE__, __LINE__, __func__, ##__VA_ARGS__)
25 __FILE__, __LINE__, __func__); \
26 printk(f, ##a); \
27} while (0)
28#else 40#else
29#define udf_debug(f, a...) /**/ 41#define udf_debug(fmt, ...) \
42 no_printk(fmt, ##__VA_ARGS__)
30#endif 43#endif
31 44
32#define udf_info(f, a...) \
33 printk(KERN_INFO "UDF-fs INFO " f, ##a);
34
35
36#define udf_fixed_to_variable(x) ( ( ( (x) >> 5 ) * 39 ) + ( (x) & 0x0000001F ) ) 45#define udf_fixed_to_variable(x) ( ( ( (x) >> 5 ) * 39 ) + ( (x) & 0x0000001F ) )
37#define udf_variable_to_fixed(x) ( ( ( (x) / 39 ) << 5 ) + ( (x) % 39 ) ) 46#define udf_variable_to_fixed(x) ( ( ( (x) / 39 ) << 5 ) + ( (x) % 39 ) )
38 47
@@ -112,8 +121,6 @@ struct extent_position {
112 121
113/* super.c */ 122/* super.c */
114 123
115extern __printf(3, 4) void udf_warning(struct super_block *, const char *,
116 const char *, ...);
117static inline void udf_updated_lvid(struct super_block *sb) 124static inline void udf_updated_lvid(struct super_block *sb)
118{ 125{
119 struct buffer_head *bh = UDF_SB(sb)->s_lvid_bh; 126 struct buffer_head *bh = UDF_SB(sb)->s_lvid_bh;
@@ -126,6 +133,8 @@ static inline void udf_updated_lvid(struct super_block *sb)
126 UDF_SB(sb)->s_lvid_dirty = 1; 133 UDF_SB(sb)->s_lvid_dirty = 1;
127} 134}
128extern u64 lvid_get_unique_id(struct super_block *sb); 135extern u64 lvid_get_unique_id(struct super_block *sb);
136struct inode *udf_find_metadata_inode_efe(struct super_block *sb,
137 u32 meta_file_loc, u32 partition_num);
129 138
130/* namei.c */ 139/* namei.c */
131extern int udf_write_fi(struct inode *inode, struct fileIdentDesc *, 140extern int udf_write_fi(struct inode *inode, struct fileIdentDesc *,
diff --git a/fs/udf/udftime.c b/fs/udf/udftime.c
index b8c828c4d200..1f11483eba6a 100644
--- a/fs/udf/udftime.c
+++ b/fs/udf/udftime.c
@@ -34,9 +34,10 @@
34 * http://www.boulder.nist.gov/timefreq/pubs/bulletin/leapsecond.htm 34 * http://www.boulder.nist.gov/timefreq/pubs/bulletin/leapsecond.htm
35 */ 35 */
36 36
37#include "udfdecl.h"
38
37#include <linux/types.h> 39#include <linux/types.h>
38#include <linux/kernel.h> 40#include <linux/kernel.h>
39#include "udfdecl.h"
40 41
41#define EPOCH_YEAR 1970 42#define EPOCH_YEAR 1970
42 43
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index d03a90b6ad69..44b815e57f94 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -114,7 +114,7 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i)
114 cmp_id = ocu_i->u_cmpID; 114 cmp_id = ocu_i->u_cmpID;
115 if (cmp_id != 8 && cmp_id != 16) { 115 if (cmp_id != 8 && cmp_id != 16) {
116 memset(utf_o, 0, sizeof(struct ustr)); 116 memset(utf_o, 0, sizeof(struct ustr));
117 printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n", 117 pr_err("unknown compression code (%d) stri=%s\n",
118 cmp_id, ocu_i->u_name); 118 cmp_id, ocu_i->u_name);
119 return 0; 119 return 0;
120 } 120 }
@@ -242,7 +242,7 @@ try_again:
242 if (utf_cnt) { 242 if (utf_cnt) {
243error_out: 243error_out:
244 ocu[++u_len] = '?'; 244 ocu[++u_len] = '?';
245 printk(KERN_DEBUG "udf: bad UTF-8 character\n"); 245 printk(KERN_DEBUG pr_fmt("bad UTF-8 character\n"));
246 } 246 }
247 247
248 ocu[length - 1] = (uint8_t)u_len + 1; 248 ocu[length - 1] = (uint8_t)u_len + 1;
@@ -267,7 +267,7 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o,
267 cmp_id = ocu_i->u_cmpID; 267 cmp_id = ocu_i->u_cmpID;
268 if (cmp_id != 8 && cmp_id != 16) { 268 if (cmp_id != 8 && cmp_id != 16) {
269 memset(utf_o, 0, sizeof(struct ustr)); 269 memset(utf_o, 0, sizeof(struct ustr));
270 printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n", 270 pr_err("unknown compression code (%d) stri=%s\n",
271 cmp_id, ocu_i->u_name); 271 cmp_id, ocu_i->u_name);
272 return 0; 272 return 0;
273 } 273 }