aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /fs/ext3
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'fs/ext3')
-rw-r--r--fs/ext3/acl.c74
-rw-r--r--fs/ext3/balloc.c12
-rw-r--r--fs/ext3/file.c7
-rw-r--r--fs/ext3/ialloc.c20
-rw-r--r--fs/ext3/inode.c75
-rw-r--r--fs/ext3/namei.c52
-rw-r--r--fs/ext3/resize.c37
-rw-r--r--fs/ext3/super.c707
-rw-r--r--fs/ext3/symlink.c2
-rw-r--r--fs/ext3/xattr.c60
-rw-r--r--fs/ext3/xattr_security.c21
-rw-r--r--fs/ext3/xattr_trusted.c18
-rw-r--r--fs/ext3/xattr_user.c25
13 files changed, 584 insertions, 526 deletions
diff --git a/fs/ext3/acl.c b/fs/ext3/acl.c
index c9b0df376b5f..82ba34158661 100644
--- a/fs/ext3/acl.c
+++ b/fs/ext3/acl.c
@@ -366,12 +366,12 @@ out:
366 * Extended attribute handlers 366 * Extended attribute handlers
367 */ 367 */
368static size_t 368static size_t
369ext3_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len, 369ext3_xattr_list_acl_access(struct dentry *dentry, char *list, size_t list_len,
370 const char *name, size_t name_len) 370 const char *name, size_t name_len, int type)
371{ 371{
372 const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); 372 const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
373 373
374 if (!test_opt(inode->i_sb, POSIX_ACL)) 374 if (!test_opt(dentry->d_sb, POSIX_ACL))
375 return 0; 375 return 0;
376 if (list && size <= list_len) 376 if (list && size <= list_len)
377 memcpy(list, POSIX_ACL_XATTR_ACCESS, size); 377 memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
@@ -379,12 +379,12 @@ ext3_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len,
379} 379}
380 380
381static size_t 381static size_t
382ext3_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len, 382ext3_xattr_list_acl_default(struct dentry *dentry, char *list, size_t list_len,
383 const char *name, size_t name_len) 383 const char *name, size_t name_len, int type)
384{ 384{
385 const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); 385 const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
386 386
387 if (!test_opt(inode->i_sb, POSIX_ACL)) 387 if (!test_opt(dentry->d_sb, POSIX_ACL))
388 return 0; 388 return 0;
389 if (list && size <= list_len) 389 if (list && size <= list_len)
390 memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); 390 memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
@@ -392,15 +392,18 @@ ext3_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len,
392} 392}
393 393
394static int 394static int
395ext3_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) 395ext3_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer,
396 size_t size, int type)
396{ 397{
397 struct posix_acl *acl; 398 struct posix_acl *acl;
398 int error; 399 int error;
399 400
400 if (!test_opt(inode->i_sb, POSIX_ACL)) 401 if (strcmp(name, "") != 0)
402 return -EINVAL;
403 if (!test_opt(dentry->d_sb, POSIX_ACL))
401 return -EOPNOTSUPP; 404 return -EOPNOTSUPP;
402 405
403 acl = ext3_get_acl(inode, type); 406 acl = ext3_get_acl(dentry->d_inode, type);
404 if (IS_ERR(acl)) 407 if (IS_ERR(acl))
405 return PTR_ERR(acl); 408 return PTR_ERR(acl);
406 if (acl == NULL) 409 if (acl == NULL)
@@ -412,31 +415,16 @@ ext3_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size)
412} 415}
413 416
414static int 417static int
415ext3_xattr_get_acl_access(struct inode *inode, const char *name, 418ext3_xattr_set_acl(struct dentry *dentry, const char *name, const void *value,
416 void *buffer, size_t size) 419 size_t size, int flags, int type)
417{
418 if (strcmp(name, "") != 0)
419 return -EINVAL;
420 return ext3_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size);
421}
422
423static int
424ext3_xattr_get_acl_default(struct inode *inode, const char *name,
425 void *buffer, size_t size)
426{
427 if (strcmp(name, "") != 0)
428 return -EINVAL;
429 return ext3_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size);
430}
431
432static int
433ext3_xattr_set_acl(struct inode *inode, int type, const void *value,
434 size_t size)
435{ 420{
421 struct inode *inode = dentry->d_inode;
436 handle_t *handle; 422 handle_t *handle;
437 struct posix_acl *acl; 423 struct posix_acl *acl;
438 int error, retries = 0; 424 int error, retries = 0;
439 425
426 if (strcmp(name, "") != 0)
427 return -EINVAL;
440 if (!test_opt(inode->i_sb, POSIX_ACL)) 428 if (!test_opt(inode->i_sb, POSIX_ACL))
441 return -EOPNOTSUPP; 429 return -EOPNOTSUPP;
442 if (!is_owner_or_cap(inode)) 430 if (!is_owner_or_cap(inode))
@@ -468,34 +456,18 @@ release_and_out:
468 return error; 456 return error;
469} 457}
470 458
471static int
472ext3_xattr_set_acl_access(struct inode *inode, const char *name,
473 const void *value, size_t size, int flags)
474{
475 if (strcmp(name, "") != 0)
476 return -EINVAL;
477 return ext3_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size);
478}
479
480static int
481ext3_xattr_set_acl_default(struct inode *inode, const char *name,
482 const void *value, size_t size, int flags)
483{
484 if (strcmp(name, "") != 0)
485 return -EINVAL;
486 return ext3_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
487}
488
489struct xattr_handler ext3_xattr_acl_access_handler = { 459struct xattr_handler ext3_xattr_acl_access_handler = {
490 .prefix = POSIX_ACL_XATTR_ACCESS, 460 .prefix = POSIX_ACL_XATTR_ACCESS,
461 .flags = ACL_TYPE_ACCESS,
491 .list = ext3_xattr_list_acl_access, 462 .list = ext3_xattr_list_acl_access,
492 .get = ext3_xattr_get_acl_access, 463 .get = ext3_xattr_get_acl,
493 .set = ext3_xattr_set_acl_access, 464 .set = ext3_xattr_set_acl,
494}; 465};
495 466
496struct xattr_handler ext3_xattr_acl_default_handler = { 467struct xattr_handler ext3_xattr_acl_default_handler = {
497 .prefix = POSIX_ACL_XATTR_DEFAULT, 468 .prefix = POSIX_ACL_XATTR_DEFAULT,
469 .flags = ACL_TYPE_DEFAULT,
498 .list = ext3_xattr_list_acl_default, 470 .list = ext3_xattr_list_acl_default,
499 .get = ext3_xattr_get_acl_default, 471 .get = ext3_xattr_get_acl,
500 .set = ext3_xattr_set_acl_default, 472 .set = ext3_xattr_set_acl,
501}; 473};
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index 27967f92e820..a177122a1b25 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -14,6 +14,7 @@
14#include <linux/time.h> 14#include <linux/time.h>
15#include <linux/capability.h> 15#include <linux/capability.h>
16#include <linux/fs.h> 16#include <linux/fs.h>
17#include <linux/slab.h>
17#include <linux/jbd.h> 18#include <linux/jbd.h>
18#include <linux/ext3_fs.h> 19#include <linux/ext3_fs.h>
19#include <linux/ext3_jbd.h> 20#include <linux/ext3_jbd.h>
@@ -676,7 +677,7 @@ void ext3_free_blocks(handle_t *handle, struct inode *inode,
676 } 677 }
677 ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks); 678 ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
678 if (dquot_freed_blocks) 679 if (dquot_freed_blocks)
679 vfs_dq_free_block(inode, dquot_freed_blocks); 680 dquot_free_block(inode, dquot_freed_blocks);
680 return; 681 return;
681} 682}
682 683
@@ -1502,8 +1503,9 @@ ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,
1502 /* 1503 /*
1503 * Check quota for allocation of this block. 1504 * Check quota for allocation of this block.
1504 */ 1505 */
1505 if (vfs_dq_alloc_block(inode, num)) { 1506 err = dquot_alloc_block(inode, num);
1506 *errp = -EDQUOT; 1507 if (err) {
1508 *errp = err;
1507 return 0; 1509 return 0;
1508 } 1510 }
1509 1511
@@ -1713,7 +1715,7 @@ allocated:
1713 1715
1714 *errp = 0; 1716 *errp = 0;
1715 brelse(bitmap_bh); 1717 brelse(bitmap_bh);
1716 vfs_dq_free_block(inode, *count-num); 1718 dquot_free_block(inode, *count-num);
1717 *count = num; 1719 *count = num;
1718 return ret_block; 1720 return ret_block;
1719 1721
@@ -1728,7 +1730,7 @@ out:
1728 * Undo the block allocation 1730 * Undo the block allocation
1729 */ 1731 */
1730 if (!performed_allocation) 1732 if (!performed_allocation)
1731 vfs_dq_free_block(inode, *count); 1733 dquot_free_block(inode, *count);
1732 brelse(bitmap_bh); 1734 brelse(bitmap_bh);
1733 return 0; 1735 return 0;
1734} 1736}
diff --git a/fs/ext3/file.c b/fs/ext3/file.c
index 388bbdfa0b4e..f55df0e61cbd 100644
--- a/fs/ext3/file.c
+++ b/fs/ext3/file.c
@@ -21,6 +21,7 @@
21#include <linux/time.h> 21#include <linux/time.h>
22#include <linux/fs.h> 22#include <linux/fs.h>
23#include <linux/jbd.h> 23#include <linux/jbd.h>
24#include <linux/quotaops.h>
24#include <linux/ext3_fs.h> 25#include <linux/ext3_fs.h>
25#include <linux/ext3_jbd.h> 26#include <linux/ext3_jbd.h>
26#include "xattr.h" 27#include "xattr.h"
@@ -33,9 +34,9 @@
33 */ 34 */
34static int ext3_release_file (struct inode * inode, struct file * filp) 35static int ext3_release_file (struct inode * inode, struct file * filp)
35{ 36{
36 if (EXT3_I(inode)->i_state & EXT3_STATE_FLUSH_ON_CLOSE) { 37 if (ext3_test_inode_state(inode, EXT3_STATE_FLUSH_ON_CLOSE)) {
37 filemap_flush(inode->i_mapping); 38 filemap_flush(inode->i_mapping);
38 EXT3_I(inode)->i_state &= ~EXT3_STATE_FLUSH_ON_CLOSE; 39 ext3_clear_inode_state(inode, EXT3_STATE_FLUSH_ON_CLOSE);
39 } 40 }
40 /* if we are the last writer on the inode, drop the block reservation */ 41 /* if we are the last writer on the inode, drop the block reservation */
41 if ((filp->f_mode & FMODE_WRITE) && 42 if ((filp->f_mode & FMODE_WRITE) &&
@@ -62,7 +63,7 @@ const struct file_operations ext3_file_operations = {
62 .compat_ioctl = ext3_compat_ioctl, 63 .compat_ioctl = ext3_compat_ioctl,
63#endif 64#endif
64 .mmap = generic_file_mmap, 65 .mmap = generic_file_mmap,
65 .open = generic_file_open, 66 .open = dquot_file_open,
66 .release = ext3_release_file, 67 .release = ext3_release_file,
67 .fsync = ext3_sync_file, 68 .fsync = ext3_sync_file,
68 .splice_read = generic_file_splice_read, 69 .splice_read = generic_file_splice_read,
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c
index b39991285136..0d0e97ed3ff6 100644
--- a/fs/ext3/ialloc.c
+++ b/fs/ext3/ialloc.c
@@ -123,10 +123,10 @@ void ext3_free_inode (handle_t *handle, struct inode * inode)
123 * Note: we must free any quota before locking the superblock, 123 * Note: we must free any quota before locking the superblock,
124 * as writing the quota to disk may need the lock as well. 124 * as writing the quota to disk may need the lock as well.
125 */ 125 */
126 vfs_dq_init(inode); 126 dquot_initialize(inode);
127 ext3_xattr_delete_inode(handle, inode); 127 ext3_xattr_delete_inode(handle, inode);
128 vfs_dq_free_inode(inode); 128 dquot_free_inode(inode);
129 vfs_dq_drop(inode); 129 dquot_drop(inode);
130 130
131 is_directory = S_ISDIR(inode->i_mode); 131 is_directory = S_ISDIR(inode->i_mode);
132 132
@@ -582,16 +582,18 @@ got:
582 inode->i_generation = sbi->s_next_generation++; 582 inode->i_generation = sbi->s_next_generation++;
583 spin_unlock(&sbi->s_next_gen_lock); 583 spin_unlock(&sbi->s_next_gen_lock);
584 584
585 ei->i_state = EXT3_STATE_NEW; 585 ei->i_state_flags = 0;
586 ext3_set_inode_state(inode, EXT3_STATE_NEW);
587
586 ei->i_extra_isize = 588 ei->i_extra_isize =
587 (EXT3_INODE_SIZE(inode->i_sb) > EXT3_GOOD_OLD_INODE_SIZE) ? 589 (EXT3_INODE_SIZE(inode->i_sb) > EXT3_GOOD_OLD_INODE_SIZE) ?
588 sizeof(struct ext3_inode) - EXT3_GOOD_OLD_INODE_SIZE : 0; 590 sizeof(struct ext3_inode) - EXT3_GOOD_OLD_INODE_SIZE : 0;
589 591
590 ret = inode; 592 ret = inode;
591 if (vfs_dq_alloc_inode(inode)) { 593 dquot_initialize(inode);
592 err = -EDQUOT; 594 err = dquot_alloc_inode(inode);
595 if (err)
593 goto fail_drop; 596 goto fail_drop;
594 }
595 597
596 err = ext3_init_acl(handle, inode, dir); 598 err = ext3_init_acl(handle, inode, dir);
597 if (err) 599 if (err)
@@ -619,10 +621,10 @@ really_out:
619 return ret; 621 return ret;
620 622
621fail_free_drop: 623fail_free_drop:
622 vfs_dq_free_inode(inode); 624 dquot_free_inode(inode);
623 625
624fail_drop: 626fail_drop:
625 vfs_dq_drop(inode); 627 dquot_drop(inode);
626 inode->i_flags |= S_NOQUOTA; 628 inode->i_flags |= S_NOQUOTA;
627 inode->i_nlink = 0; 629 inode->i_nlink = 0;
628 unlock_new_inode(inode); 630 unlock_new_inode(inode);
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 354ed3b47b30..ea33bdf0a300 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -196,6 +196,9 @@ void ext3_delete_inode (struct inode * inode)
196{ 196{
197 handle_t *handle; 197 handle_t *handle;
198 198
199 if (!is_bad_inode(inode))
200 dquot_initialize(inode);
201
199 truncate_inode_pages(&inode->i_data, 0); 202 truncate_inode_pages(&inode->i_data, 0);
200 203
201 if (is_bad_inode(inode)) 204 if (is_bad_inode(inode))
@@ -970,7 +973,7 @@ static int ext3_get_block(struct inode *inode, sector_t iblock,
970 if (max_blocks > DIO_MAX_BLOCKS) 973 if (max_blocks > DIO_MAX_BLOCKS)
971 max_blocks = DIO_MAX_BLOCKS; 974 max_blocks = DIO_MAX_BLOCKS;
972 handle = ext3_journal_start(inode, DIO_CREDITS + 975 handle = ext3_journal_start(inode, DIO_CREDITS +
973 2 * EXT3_QUOTA_TRANS_BLOCKS(inode->i_sb)); 976 EXT3_MAXQUOTAS_TRANS_BLOCKS(inode->i_sb));
974 if (IS_ERR(handle)) { 977 if (IS_ERR(handle)) {
975 ret = PTR_ERR(handle); 978 ret = PTR_ERR(handle);
976 goto out; 979 goto out;
@@ -1151,6 +1154,16 @@ static int do_journal_get_write_access(handle_t *handle,
1151 return ext3_journal_get_write_access(handle, bh); 1154 return ext3_journal_get_write_access(handle, bh);
1152} 1155}
1153 1156
1157/*
1158 * Truncate blocks that were not used by write. We have to truncate the
1159 * pagecache as well so that corresponding buffers get properly unmapped.
1160 */
1161static void ext3_truncate_failed_write(struct inode *inode)
1162{
1163 truncate_inode_pages(inode->i_mapping, inode->i_size);
1164 ext3_truncate(inode);
1165}
1166
1154static int ext3_write_begin(struct file *file, struct address_space *mapping, 1167static int ext3_write_begin(struct file *file, struct address_space *mapping,
1155 loff_t pos, unsigned len, unsigned flags, 1168 loff_t pos, unsigned len, unsigned flags,
1156 struct page **pagep, void **fsdata) 1169 struct page **pagep, void **fsdata)
@@ -1209,7 +1222,7 @@ write_begin_failed:
1209 unlock_page(page); 1222 unlock_page(page);
1210 page_cache_release(page); 1223 page_cache_release(page);
1211 if (pos + len > inode->i_size) 1224 if (pos + len > inode->i_size)
1212 ext3_truncate(inode); 1225 ext3_truncate_failed_write(inode);
1213 } 1226 }
1214 if (ret == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries)) 1227 if (ret == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries))
1215 goto retry; 1228 goto retry;
@@ -1304,7 +1317,7 @@ static int ext3_ordered_write_end(struct file *file,
1304 page_cache_release(page); 1317 page_cache_release(page);
1305 1318
1306 if (pos + len > inode->i_size) 1319 if (pos + len > inode->i_size)
1307 ext3_truncate(inode); 1320 ext3_truncate_failed_write(inode);
1308 return ret ? ret : copied; 1321 return ret ? ret : copied;
1309} 1322}
1310 1323
@@ -1330,7 +1343,7 @@ static int ext3_writeback_write_end(struct file *file,
1330 page_cache_release(page); 1343 page_cache_release(page);
1331 1344
1332 if (pos + len > inode->i_size) 1345 if (pos + len > inode->i_size)
1333 ext3_truncate(inode); 1346 ext3_truncate_failed_write(inode);
1334 return ret ? ret : copied; 1347 return ret ? ret : copied;
1335} 1348}
1336 1349
@@ -1368,7 +1381,7 @@ static int ext3_journalled_write_end(struct file *file,
1368 */ 1381 */
1369 if (pos + len > inode->i_size && ext3_can_truncate(inode)) 1382 if (pos + len > inode->i_size && ext3_can_truncate(inode))
1370 ext3_orphan_add(handle, inode); 1383 ext3_orphan_add(handle, inode);
1371 EXT3_I(inode)->i_state |= EXT3_STATE_JDATA; 1384 ext3_set_inode_state(inode, EXT3_STATE_JDATA);
1372 if (inode->i_size > EXT3_I(inode)->i_disksize) { 1385 if (inode->i_size > EXT3_I(inode)->i_disksize) {
1373 EXT3_I(inode)->i_disksize = inode->i_size; 1386 EXT3_I(inode)->i_disksize = inode->i_size;
1374 ret2 = ext3_mark_inode_dirty(handle, inode); 1387 ret2 = ext3_mark_inode_dirty(handle, inode);
@@ -1383,7 +1396,7 @@ static int ext3_journalled_write_end(struct file *file,
1383 page_cache_release(page); 1396 page_cache_release(page);
1384 1397
1385 if (pos + len > inode->i_size) 1398 if (pos + len > inode->i_size)
1386 ext3_truncate(inode); 1399 ext3_truncate_failed_write(inode);
1387 return ret ? ret : copied; 1400 return ret ? ret : copied;
1388} 1401}
1389 1402
@@ -1407,7 +1420,7 @@ static sector_t ext3_bmap(struct address_space *mapping, sector_t block)
1407 journal_t *journal; 1420 journal_t *journal;
1408 int err; 1421 int err;
1409 1422
1410 if (EXT3_I(inode)->i_state & EXT3_STATE_JDATA) { 1423 if (ext3_test_inode_state(inode, EXT3_STATE_JDATA)) {
1411 /* 1424 /*
1412 * This is a REALLY heavyweight approach, but the use of 1425 * This is a REALLY heavyweight approach, but the use of
1413 * bmap on dirty files is expected to be extremely rare: 1426 * bmap on dirty files is expected to be extremely rare:
@@ -1426,7 +1439,7 @@ static sector_t ext3_bmap(struct address_space *mapping, sector_t block)
1426 * everything they get. 1439 * everything they get.
1427 */ 1440 */
1428 1441
1429 EXT3_I(inode)->i_state &= ~EXT3_STATE_JDATA; 1442 ext3_clear_inode_state(inode, EXT3_STATE_JDATA);
1430 journal = EXT3_JOURNAL(inode); 1443 journal = EXT3_JOURNAL(inode);
1431 journal_lock_updates(journal); 1444 journal_lock_updates(journal);
1432 err = journal_flush(journal); 1445 err = journal_flush(journal);
@@ -1518,6 +1531,7 @@ static int ext3_ordered_writepage(struct page *page,
1518 int err; 1531 int err;
1519 1532
1520 J_ASSERT(PageLocked(page)); 1533 J_ASSERT(PageLocked(page));
1534 WARN_ON_ONCE(IS_RDONLY(inode));
1521 1535
1522 /* 1536 /*
1523 * We give up here if we're reentered, because it might be for a 1537 * We give up here if we're reentered, because it might be for a
@@ -1590,6 +1604,9 @@ static int ext3_writeback_writepage(struct page *page,
1590 int ret = 0; 1604 int ret = 0;
1591 int err; 1605 int err;
1592 1606
1607 J_ASSERT(PageLocked(page));
1608 WARN_ON_ONCE(IS_RDONLY(inode));
1609
1593 if (ext3_journal_current_handle()) 1610 if (ext3_journal_current_handle())
1594 goto out_fail; 1611 goto out_fail;
1595 1612
@@ -1632,6 +1649,9 @@ static int ext3_journalled_writepage(struct page *page,
1632 int ret = 0; 1649 int ret = 0;
1633 int err; 1650 int err;
1634 1651
1652 J_ASSERT(PageLocked(page));
1653 WARN_ON_ONCE(IS_RDONLY(inode));
1654
1635 if (ext3_journal_current_handle()) 1655 if (ext3_journal_current_handle())
1636 goto no_write; 1656 goto no_write;
1637 1657
@@ -1660,7 +1680,7 @@ static int ext3_journalled_writepage(struct page *page,
1660 PAGE_CACHE_SIZE, NULL, write_end_fn); 1680 PAGE_CACHE_SIZE, NULL, write_end_fn);
1661 if (ret == 0) 1681 if (ret == 0)
1662 ret = err; 1682 ret = err;
1663 EXT3_I(inode)->i_state |= EXT3_STATE_JDATA; 1683 ext3_set_inode_state(inode, EXT3_STATE_JDATA);
1664 unlock_page(page); 1684 unlock_page(page);
1665 } else { 1685 } else {
1666 /* 1686 /*
@@ -1775,8 +1795,9 @@ retry:
1775 handle = ext3_journal_start(inode, 2); 1795 handle = ext3_journal_start(inode, 2);
1776 if (IS_ERR(handle)) { 1796 if (IS_ERR(handle)) {
1777 /* This is really bad luck. We've written the data 1797 /* This is really bad luck. We've written the data
1778 * but cannot extend i_size. Bail out and pretend 1798 * but cannot extend i_size. Truncate allocated blocks
1779 * the write failed... */ 1799 * and pretend the write failed... */
1800 ext3_truncate(inode);
1780 ret = PTR_ERR(handle); 1801 ret = PTR_ERR(handle);
1781 goto out; 1802 goto out;
1782 } 1803 }
@@ -2033,7 +2054,7 @@ static Indirect *ext3_find_shared(struct inode *inode, int depth,
2033 int k, err; 2054 int k, err;
2034 2055
2035 *top = 0; 2056 *top = 0;
2036 /* Make k index the deepest non-null offest + 1 */ 2057 /* Make k index the deepest non-null offset + 1 */
2037 for (k = depth; k > 1 && !offsets[k-1]; k--) 2058 for (k = depth; k > 1 && !offsets[k-1]; k--)
2038 ; 2059 ;
2039 partial = ext3_get_branch(inode, k, offsets, chain, &err); 2060 partial = ext3_get_branch(inode, k, offsets, chain, &err);
@@ -2392,7 +2413,7 @@ void ext3_truncate(struct inode *inode)
2392 goto out_notrans; 2413 goto out_notrans;
2393 2414
2394 if (inode->i_size == 0 && ext3_should_writeback_data(inode)) 2415 if (inode->i_size == 0 && ext3_should_writeback_data(inode))
2395 ei->i_state |= EXT3_STATE_FLUSH_ON_CLOSE; 2416 ext3_set_inode_state(inode, EXT3_STATE_FLUSH_ON_CLOSE);
2396 2417
2397 /* 2418 /*
2398 * We have to lock the EOF page here, because lock_page() nests 2419 * We have to lock the EOF page here, because lock_page() nests
@@ -2711,7 +2732,7 @@ int ext3_get_inode_loc(struct inode *inode, struct ext3_iloc *iloc)
2711{ 2732{
2712 /* We have all inode data except xattrs in memory here. */ 2733 /* We have all inode data except xattrs in memory here. */
2713 return __ext3_get_inode_loc(inode, iloc, 2734 return __ext3_get_inode_loc(inode, iloc,
2714 !(EXT3_I(inode)->i_state & EXT3_STATE_XATTR)); 2735 !ext3_test_inode_state(inode, EXT3_STATE_XATTR));
2715} 2736}
2716 2737
2717void ext3_set_inode_flags(struct inode *inode) 2738void ext3_set_inode_flags(struct inode *inode)
@@ -2790,7 +2811,7 @@ struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
2790 inode->i_mtime.tv_sec = (signed)le32_to_cpu(raw_inode->i_mtime); 2811 inode->i_mtime.tv_sec = (signed)le32_to_cpu(raw_inode->i_mtime);
2791 inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_mtime.tv_nsec = 0; 2812 inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_mtime.tv_nsec = 0;
2792 2813
2793 ei->i_state = 0; 2814 ei->i_state_flags = 0;
2794 ei->i_dir_start_lookup = 0; 2815 ei->i_dir_start_lookup = 0;
2795 ei->i_dtime = le32_to_cpu(raw_inode->i_dtime); 2816 ei->i_dtime = le32_to_cpu(raw_inode->i_dtime);
2796 /* We now have enough fields to check if the inode was active or not. 2817 /* We now have enough fields to check if the inode was active or not.
@@ -2883,7 +2904,7 @@ struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
2883 EXT3_GOOD_OLD_INODE_SIZE + 2904 EXT3_GOOD_OLD_INODE_SIZE +
2884 ei->i_extra_isize; 2905 ei->i_extra_isize;
2885 if (*magic == cpu_to_le32(EXT3_XATTR_MAGIC)) 2906 if (*magic == cpu_to_le32(EXT3_XATTR_MAGIC))
2886 ei->i_state |= EXT3_STATE_XATTR; 2907 ext3_set_inode_state(inode, EXT3_STATE_XATTR);
2887 } 2908 }
2888 } else 2909 } else
2889 ei->i_extra_isize = 0; 2910 ei->i_extra_isize = 0;
@@ -2945,7 +2966,7 @@ again:
2945 2966
2946 /* For fields not not tracking in the in-memory inode, 2967 /* For fields not not tracking in the in-memory inode,
2947 * initialise them to zero for new inodes. */ 2968 * initialise them to zero for new inodes. */
2948 if (ei->i_state & EXT3_STATE_NEW) 2969 if (ext3_test_inode_state(inode, EXT3_STATE_NEW))
2949 memset(raw_inode, 0, EXT3_SB(inode->i_sb)->s_inode_size); 2970 memset(raw_inode, 0, EXT3_SB(inode->i_sb)->s_inode_size);
2950 2971
2951 ext3_get_inode_flags(ei); 2972 ext3_get_inode_flags(ei);
@@ -3042,7 +3063,7 @@ again:
3042 rc = ext3_journal_dirty_metadata(handle, bh); 3063 rc = ext3_journal_dirty_metadata(handle, bh);
3043 if (!err) 3064 if (!err)
3044 err = rc; 3065 err = rc;
3045 ei->i_state &= ~EXT3_STATE_NEW; 3066 ext3_clear_inode_state(inode, EXT3_STATE_NEW);
3046 3067
3047 atomic_set(&ei->i_sync_tid, handle->h_transaction->t_tid); 3068 atomic_set(&ei->i_sync_tid, handle->h_transaction->t_tid);
3048out_brelse: 3069out_brelse:
@@ -3086,7 +3107,7 @@ out_brelse:
3086 * `stuff()' is running, and the new i_size will be lost. Plus the inode 3107 * `stuff()' is running, and the new i_size will be lost. Plus the inode
3087 * will no longer be on the superblock's dirty inode list. 3108 * will no longer be on the superblock's dirty inode list.
3088 */ 3109 */
3089int ext3_write_inode(struct inode *inode, int wait) 3110int ext3_write_inode(struct inode *inode, struct writeback_control *wbc)
3090{ 3111{
3091 if (current->flags & PF_MEMALLOC) 3112 if (current->flags & PF_MEMALLOC)
3092 return 0; 3113 return 0;
@@ -3097,7 +3118,7 @@ int ext3_write_inode(struct inode *inode, int wait)
3097 return -EIO; 3118 return -EIO;
3098 } 3119 }
3099 3120
3100 if (!wait) 3121 if (wbc->sync_mode != WB_SYNC_ALL)
3101 return 0; 3122 return 0;
3102 3123
3103 return ext3_force_commit(inode->i_sb); 3124 return ext3_force_commit(inode->i_sb);
@@ -3130,19 +3151,21 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr)
3130 if (error) 3151 if (error)
3131 return error; 3152 return error;
3132 3153
3154 if (ia_valid & ATTR_SIZE)
3155 dquot_initialize(inode);
3133 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || 3156 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3134 (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) { 3157 (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3135 handle_t *handle; 3158 handle_t *handle;
3136 3159
3137 /* (user+group)*(old+new) structure, inode write (sb, 3160 /* (user+group)*(old+new) structure, inode write (sb,
3138 * inode block, ? - but truncate inode update has it) */ 3161 * inode block, ? - but truncate inode update has it) */
3139 handle = ext3_journal_start(inode, 2*(EXT3_QUOTA_INIT_BLOCKS(inode->i_sb)+ 3162 handle = ext3_journal_start(inode, EXT3_MAXQUOTAS_INIT_BLOCKS(inode->i_sb)+
3140 EXT3_QUOTA_DEL_BLOCKS(inode->i_sb))+3); 3163 EXT3_MAXQUOTAS_DEL_BLOCKS(inode->i_sb)+3);
3141 if (IS_ERR(handle)) { 3164 if (IS_ERR(handle)) {
3142 error = PTR_ERR(handle); 3165 error = PTR_ERR(handle);
3143 goto err_out; 3166 goto err_out;
3144 } 3167 }
3145 error = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0; 3168 error = dquot_transfer(inode, attr);
3146 if (error) { 3169 if (error) {
3147 ext3_journal_stop(handle); 3170 ext3_journal_stop(handle);
3148 return error; 3171 return error;
@@ -3227,9 +3250,9 @@ static int ext3_writepage_trans_blocks(struct inode *inode)
3227 ret = 2 * (bpp + indirects) + 2; 3250 ret = 2 * (bpp + indirects) + 2;
3228 3251
3229#ifdef CONFIG_QUOTA 3252#ifdef CONFIG_QUOTA
3230 /* We know that structure was already allocated during vfs_dq_init so 3253 /* We know that structure was already allocated during dquot_initialize so
3231 * we will be updating only the data blocks + inodes */ 3254 * we will be updating only the data blocks + inodes */
3232 ret += 2*EXT3_QUOTA_TRANS_BLOCKS(inode->i_sb); 3255 ret += EXT3_MAXQUOTAS_TRANS_BLOCKS(inode->i_sb);
3233#endif 3256#endif
3234 3257
3235 return ret; 3258 return ret;
@@ -3318,7 +3341,7 @@ int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode)
3318 * i_size has been changed by generic_commit_write() and we thus need 3341 * i_size has been changed by generic_commit_write() and we thus need
3319 * to include the updated inode in the current transaction. 3342 * to include the updated inode in the current transaction.
3320 * 3343 *
3321 * Also, vfs_dq_alloc_space() will always dirty the inode when blocks 3344 * Also, dquot_alloc_space() will always dirty the inode when blocks
3322 * are allocated to the file. 3345 * are allocated to the file.
3323 * 3346 *
3324 * If the inode is marked synchronous, we don't honour that here - doing 3347 * If the inode is marked synchronous, we don't honour that here - doing
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index aad6400c9b77..ee184084ca42 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -1696,10 +1696,12 @@ static int ext3_create (struct inode * dir, struct dentry * dentry, int mode,
1696 struct inode * inode; 1696 struct inode * inode;
1697 int err, retries = 0; 1697 int err, retries = 0;
1698 1698
1699 dquot_initialize(dir);
1700
1699retry: 1701retry:
1700 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + 1702 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
1701 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 + 1703 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 +
1702 2*EXT3_QUOTA_INIT_BLOCKS(dir->i_sb)); 1704 EXT3_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
1703 if (IS_ERR(handle)) 1705 if (IS_ERR(handle))
1704 return PTR_ERR(handle); 1706 return PTR_ERR(handle);
1705 1707
@@ -1730,10 +1732,12 @@ static int ext3_mknod (struct inode * dir, struct dentry *dentry,
1730 if (!new_valid_dev(rdev)) 1732 if (!new_valid_dev(rdev))
1731 return -EINVAL; 1733 return -EINVAL;
1732 1734
1735 dquot_initialize(dir);
1736
1733retry: 1737retry:
1734 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + 1738 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
1735 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 + 1739 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 +
1736 2*EXT3_QUOTA_INIT_BLOCKS(dir->i_sb)); 1740 EXT3_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
1737 if (IS_ERR(handle)) 1741 if (IS_ERR(handle))
1738 return PTR_ERR(handle); 1742 return PTR_ERR(handle);
1739 1743
@@ -1766,10 +1770,12 @@ static int ext3_mkdir(struct inode * dir, struct dentry * dentry, int mode)
1766 if (dir->i_nlink >= EXT3_LINK_MAX) 1770 if (dir->i_nlink >= EXT3_LINK_MAX)
1767 return -EMLINK; 1771 return -EMLINK;
1768 1772
1773 dquot_initialize(dir);
1774
1769retry: 1775retry:
1770 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + 1776 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
1771 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 + 1777 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 +
1772 2*EXT3_QUOTA_INIT_BLOCKS(dir->i_sb)); 1778 EXT3_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
1773 if (IS_ERR(handle)) 1779 if (IS_ERR(handle))
1774 return PTR_ERR(handle); 1780 return PTR_ERR(handle);
1775 1781
@@ -1920,7 +1926,7 @@ int ext3_orphan_add(handle_t *handle, struct inode *inode)
1920 struct ext3_iloc iloc; 1926 struct ext3_iloc iloc;
1921 int err = 0, rc; 1927 int err = 0, rc;
1922 1928
1923 lock_super(sb); 1929 mutex_lock(&EXT3_SB(sb)->s_orphan_lock);
1924 if (!list_empty(&EXT3_I(inode)->i_orphan)) 1930 if (!list_empty(&EXT3_I(inode)->i_orphan))
1925 goto out_unlock; 1931 goto out_unlock;
1926 1932
@@ -1929,9 +1935,13 @@ int ext3_orphan_add(handle_t *handle, struct inode *inode)
1929 1935
1930 /* @@@ FIXME: Observation from aviro: 1936 /* @@@ FIXME: Observation from aviro:
1931 * I think I can trigger J_ASSERT in ext3_orphan_add(). We block 1937 * I think I can trigger J_ASSERT in ext3_orphan_add(). We block
1932 * here (on lock_super()), so race with ext3_link() which might bump 1938 * here (on s_orphan_lock), so race with ext3_link() which might bump
1933 * ->i_nlink. For, say it, character device. Not a regular file, 1939 * ->i_nlink. For, say it, character device. Not a regular file,
1934 * not a directory, not a symlink and ->i_nlink > 0. 1940 * not a directory, not a symlink and ->i_nlink > 0.
1941 *
1942 * tytso, 4/25/2009: I'm not sure how that could happen;
1943 * shouldn't the fs core protect us from these sort of
1944 * unlink()/link() races?
1935 */ 1945 */
1936 J_ASSERT ((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || 1946 J_ASSERT ((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
1937 S_ISLNK(inode->i_mode)) || inode->i_nlink == 0); 1947 S_ISLNK(inode->i_mode)) || inode->i_nlink == 0);
@@ -1968,7 +1978,7 @@ int ext3_orphan_add(handle_t *handle, struct inode *inode)
1968 jbd_debug(4, "orphan inode %lu will point to %d\n", 1978 jbd_debug(4, "orphan inode %lu will point to %d\n",
1969 inode->i_ino, NEXT_ORPHAN(inode)); 1979 inode->i_ino, NEXT_ORPHAN(inode));
1970out_unlock: 1980out_unlock:
1971 unlock_super(sb); 1981 mutex_unlock(&EXT3_SB(sb)->s_orphan_lock);
1972 ext3_std_error(inode->i_sb, err); 1982 ext3_std_error(inode->i_sb, err);
1973 return err; 1983 return err;
1974} 1984}
@@ -1986,11 +1996,9 @@ int ext3_orphan_del(handle_t *handle, struct inode *inode)
1986 struct ext3_iloc iloc; 1996 struct ext3_iloc iloc;
1987 int err = 0; 1997 int err = 0;
1988 1998
1989 lock_super(inode->i_sb); 1999 mutex_lock(&EXT3_SB(inode->i_sb)->s_orphan_lock);
1990 if (list_empty(&ei->i_orphan)) { 2000 if (list_empty(&ei->i_orphan))
1991 unlock_super(inode->i_sb); 2001 goto out;
1992 return 0;
1993 }
1994 2002
1995 ino_next = NEXT_ORPHAN(inode); 2003 ino_next = NEXT_ORPHAN(inode);
1996 prev = ei->i_orphan.prev; 2004 prev = ei->i_orphan.prev;
@@ -2040,7 +2048,7 @@ int ext3_orphan_del(handle_t *handle, struct inode *inode)
2040out_err: 2048out_err:
2041 ext3_std_error(inode->i_sb, err); 2049 ext3_std_error(inode->i_sb, err);
2042out: 2050out:
2043 unlock_super(inode->i_sb); 2051 mutex_unlock(&EXT3_SB(inode->i_sb)->s_orphan_lock);
2044 return err; 2052 return err;
2045 2053
2046out_brelse: 2054out_brelse:
@@ -2058,7 +2066,9 @@ static int ext3_rmdir (struct inode * dir, struct dentry *dentry)
2058 2066
2059 /* Initialize quotas before so that eventual writes go in 2067 /* Initialize quotas before so that eventual writes go in
2060 * separate transaction */ 2068 * separate transaction */
2061 vfs_dq_init(dentry->d_inode); 2069 dquot_initialize(dir);
2070 dquot_initialize(dentry->d_inode);
2071
2062 handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb)); 2072 handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb));
2063 if (IS_ERR(handle)) 2073 if (IS_ERR(handle))
2064 return PTR_ERR(handle); 2074 return PTR_ERR(handle);
@@ -2117,7 +2127,9 @@ static int ext3_unlink(struct inode * dir, struct dentry *dentry)
2117 2127
2118 /* Initialize quotas before so that eventual writes go 2128 /* Initialize quotas before so that eventual writes go
2119 * in separate transaction */ 2129 * in separate transaction */
2120 vfs_dq_init(dentry->d_inode); 2130 dquot_initialize(dir);
2131 dquot_initialize(dentry->d_inode);
2132
2121 handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb)); 2133 handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb));
2122 if (IS_ERR(handle)) 2134 if (IS_ERR(handle))
2123 return PTR_ERR(handle); 2135 return PTR_ERR(handle);
@@ -2172,10 +2184,12 @@ static int ext3_symlink (struct inode * dir,
2172 if (l > dir->i_sb->s_blocksize) 2184 if (l > dir->i_sb->s_blocksize)
2173 return -ENAMETOOLONG; 2185 return -ENAMETOOLONG;
2174 2186
2187 dquot_initialize(dir);
2188
2175retry: 2189retry:
2176 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + 2190 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
2177 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 5 + 2191 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 5 +
2178 2*EXT3_QUOTA_INIT_BLOCKS(dir->i_sb)); 2192 EXT3_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
2179 if (IS_ERR(handle)) 2193 if (IS_ERR(handle))
2180 return PTR_ERR(handle); 2194 return PTR_ERR(handle);
2181 2195
@@ -2226,6 +2240,9 @@ static int ext3_link (struct dentry * old_dentry,
2226 2240
2227 if (inode->i_nlink >= EXT3_LINK_MAX) 2241 if (inode->i_nlink >= EXT3_LINK_MAX)
2228 return -EMLINK; 2242 return -EMLINK;
2243
2244 dquot_initialize(dir);
2245
2229 /* 2246 /*
2230 * Return -ENOENT if we've raced with unlink and i_nlink is 0. Doing 2247 * Return -ENOENT if we've raced with unlink and i_nlink is 0. Doing
2231 * otherwise has the potential to corrupt the orphan inode list. 2248 * otherwise has the potential to corrupt the orphan inode list.
@@ -2276,12 +2293,15 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry,
2276 struct ext3_dir_entry_2 * old_de, * new_de; 2293 struct ext3_dir_entry_2 * old_de, * new_de;
2277 int retval, flush_file = 0; 2294 int retval, flush_file = 0;
2278 2295
2296 dquot_initialize(old_dir);
2297 dquot_initialize(new_dir);
2298
2279 old_bh = new_bh = dir_bh = NULL; 2299 old_bh = new_bh = dir_bh = NULL;
2280 2300
2281 /* Initialize quotas before so that eventual writes go 2301 /* Initialize quotas before so that eventual writes go
2282 * in separate transaction */ 2302 * in separate transaction */
2283 if (new_dentry->d_inode) 2303 if (new_dentry->d_inode)
2284 vfs_dq_init(new_dentry->d_inode); 2304 dquot_initialize(new_dentry->d_inode);
2285 handle = ext3_journal_start(old_dir, 2 * 2305 handle = ext3_journal_start(old_dir, 2 *
2286 EXT3_DATA_TRANS_BLOCKS(old_dir->i_sb) + 2306 EXT3_DATA_TRANS_BLOCKS(old_dir->i_sb) +
2287 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 2); 2307 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 2);
diff --git a/fs/ext3/resize.c b/fs/ext3/resize.c
index 8359e7b3dc89..54351ac7cef9 100644
--- a/fs/ext3/resize.c
+++ b/fs/ext3/resize.c
@@ -209,7 +209,7 @@ static int setup_new_group_blocks(struct super_block *sb,
209 if (IS_ERR(handle)) 209 if (IS_ERR(handle))
210 return PTR_ERR(handle); 210 return PTR_ERR(handle);
211 211
212 lock_super(sb); 212 mutex_lock(&sbi->s_resize_lock);
213 if (input->group != sbi->s_groups_count) { 213 if (input->group != sbi->s_groups_count) {
214 err = -EBUSY; 214 err = -EBUSY;
215 goto exit_journal; 215 goto exit_journal;
@@ -266,7 +266,7 @@ static int setup_new_group_blocks(struct super_block *sb,
266 goto exit_bh; 266 goto exit_bh;
267 267
268 if (IS_ERR(gdb = bclean(handle, sb, block))) { 268 if (IS_ERR(gdb = bclean(handle, sb, block))) {
269 err = PTR_ERR(bh); 269 err = PTR_ERR(gdb);
270 goto exit_bh; 270 goto exit_bh;
271 } 271 }
272 ext3_journal_dirty_metadata(handle, gdb); 272 ext3_journal_dirty_metadata(handle, gdb);
@@ -324,7 +324,7 @@ exit_bh:
324 brelse(bh); 324 brelse(bh);
325 325
326exit_journal: 326exit_journal:
327 unlock_super(sb); 327 mutex_unlock(&sbi->s_resize_lock);
328 if ((err2 = ext3_journal_stop(handle)) && !err) 328 if ((err2 = ext3_journal_stop(handle)) && !err)
329 err = err2; 329 err = err2;
330 330
@@ -662,11 +662,12 @@ exit_free:
662 * important part is that the new block and inode counts are in the backup 662 * important part is that the new block and inode counts are in the backup
663 * superblocks, and the location of the new group metadata in the GDT backups. 663 * superblocks, and the location of the new group metadata in the GDT backups.
664 * 664 *
665 * We do not need lock_super() for this, because these blocks are not 665 * We do not need take the s_resize_lock for this, because these
666 * otherwise touched by the filesystem code when it is mounted. We don't 666 * blocks are not otherwise touched by the filesystem code when it is
667 * need to worry about last changing from sbi->s_groups_count, because the 667 * mounted. We don't need to worry about last changing from
668 * worst that can happen is that we do not copy the full number of backups 668 * sbi->s_groups_count, because the worst that can happen is that we
669 * at this time. The resize which changed s_groups_count will backup again. 669 * do not copy the full number of backups at this time. The resize
670 * which changed s_groups_count will backup again.
670 */ 671 */
671static void update_backups(struct super_block *sb, 672static void update_backups(struct super_block *sb,
672 int blk_off, char *data, int size) 673 int blk_off, char *data, int size)
@@ -825,7 +826,7 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input)
825 goto exit_put; 826 goto exit_put;
826 } 827 }
827 828
828 lock_super(sb); 829 mutex_lock(&sbi->s_resize_lock);
829 if (input->group != sbi->s_groups_count) { 830 if (input->group != sbi->s_groups_count) {
830 ext3_warning(sb, __func__, 831 ext3_warning(sb, __func__,
831 "multiple resizers run on filesystem!"); 832 "multiple resizers run on filesystem!");
@@ -856,7 +857,7 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input)
856 /* 857 /*
857 * OK, now we've set up the new group. Time to make it active. 858 * OK, now we've set up the new group. Time to make it active.
858 * 859 *
859 * Current kernels don't lock all allocations via lock_super(), 860 * We do not lock all allocations via s_resize_lock
860 * so we have to be safe wrt. concurrent accesses the group 861 * so we have to be safe wrt. concurrent accesses the group
861 * data. So we need to be careful to set all of the relevant 862 * data. So we need to be careful to set all of the relevant
862 * group descriptor data etc. *before* we enable the group. 863 * group descriptor data etc. *before* we enable the group.
@@ -900,12 +901,12 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input)
900 * 901 *
901 * The precise rules we use are: 902 * The precise rules we use are:
902 * 903 *
903 * * Writers of s_groups_count *must* hold lock_super 904 * * Writers of s_groups_count *must* hold s_resize_lock
904 * AND 905 * AND
905 * * Writers must perform a smp_wmb() after updating all dependent 906 * * Writers must perform a smp_wmb() after updating all dependent
906 * data and before modifying the groups count 907 * data and before modifying the groups count
907 * 908 *
908 * * Readers must hold lock_super() over the access 909 * * Readers must hold s_resize_lock over the access
909 * OR 910 * OR
910 * * Readers must perform an smp_rmb() after reading the groups count 911 * * Readers must perform an smp_rmb() after reading the groups count
911 * and before reading any dependent data. 912 * and before reading any dependent data.
@@ -936,7 +937,7 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input)
936 ext3_journal_dirty_metadata(handle, sbi->s_sbh); 937 ext3_journal_dirty_metadata(handle, sbi->s_sbh);
937 938
938exit_journal: 939exit_journal:
939 unlock_super(sb); 940 mutex_unlock(&sbi->s_resize_lock);
940 if ((err2 = ext3_journal_stop(handle)) && !err) 941 if ((err2 = ext3_journal_stop(handle)) && !err)
941 err = err2; 942 err = err2;
942 if (!err) { 943 if (!err) {
@@ -973,7 +974,7 @@ int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es,
973 974
974 /* We don't need to worry about locking wrt other resizers just 975 /* We don't need to worry about locking wrt other resizers just
975 * yet: we're going to revalidate es->s_blocks_count after 976 * yet: we're going to revalidate es->s_blocks_count after
976 * taking lock_super() below. */ 977 * taking the s_resize_lock below. */
977 o_blocks_count = le32_to_cpu(es->s_blocks_count); 978 o_blocks_count = le32_to_cpu(es->s_blocks_count);
978 o_groups_count = EXT3_SB(sb)->s_groups_count; 979 o_groups_count = EXT3_SB(sb)->s_groups_count;
979 980
@@ -1045,11 +1046,11 @@ int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es,
1045 goto exit_put; 1046 goto exit_put;
1046 } 1047 }
1047 1048
1048 lock_super(sb); 1049 mutex_lock(&EXT3_SB(sb)->s_resize_lock);
1049 if (o_blocks_count != le32_to_cpu(es->s_blocks_count)) { 1050 if (o_blocks_count != le32_to_cpu(es->s_blocks_count)) {
1050 ext3_warning(sb, __func__, 1051 ext3_warning(sb, __func__,
1051 "multiple resizers run on filesystem!"); 1052 "multiple resizers run on filesystem!");
1052 unlock_super(sb); 1053 mutex_unlock(&EXT3_SB(sb)->s_resize_lock);
1053 ext3_journal_stop(handle); 1054 ext3_journal_stop(handle);
1054 err = -EBUSY; 1055 err = -EBUSY;
1055 goto exit_put; 1056 goto exit_put;
@@ -1059,13 +1060,13 @@ int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es,
1059 EXT3_SB(sb)->s_sbh))) { 1060 EXT3_SB(sb)->s_sbh))) {
1060 ext3_warning(sb, __func__, 1061 ext3_warning(sb, __func__,
1061 "error %d on journal write access", err); 1062 "error %d on journal write access", err);
1062 unlock_super(sb); 1063 mutex_unlock(&EXT3_SB(sb)->s_resize_lock);
1063 ext3_journal_stop(handle); 1064 ext3_journal_stop(handle);
1064 goto exit_put; 1065 goto exit_put;
1065 } 1066 }
1066 es->s_blocks_count = cpu_to_le32(o_blocks_count + add); 1067 es->s_blocks_count = cpu_to_le32(o_blocks_count + add);
1067 ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh); 1068 ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
1068 unlock_super(sb); 1069 mutex_unlock(&EXT3_SB(sb)->s_resize_lock);
1069 ext3_debug("freeing blocks %lu through "E3FSBLK"\n", o_blocks_count, 1070 ext3_debug("freeing blocks %lu through "E3FSBLK"\n", o_blocks_count,
1070 o_blocks_count + add); 1071 o_blocks_count + add);
1071 ext3_free_blocks_sb(handle, sb, o_blocks_count, add, &freed_blocks); 1072 ext3_free_blocks_sb(handle, sb, o_blocks_count, add, &freed_blocks);
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 427496c4767c..1bee604cc6cd 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -135,12 +135,24 @@ void ext3_journal_abort_handle(const char *caller, const char *err_fn,
135 if (is_handle_aborted(handle)) 135 if (is_handle_aborted(handle))
136 return; 136 return;
137 137
138 printk(KERN_ERR "%s: aborting transaction: %s in %s\n", 138 printk(KERN_ERR "EXT3-fs: %s: aborting transaction: %s in %s\n",
139 caller, errstr, err_fn); 139 caller, errstr, err_fn);
140 140
141 journal_abort_handle(handle); 141 journal_abort_handle(handle);
142} 142}
143 143
144void ext3_msg(struct super_block *sb, const char *prefix,
145 const char *fmt, ...)
146{
147 va_list args;
148
149 va_start(args, fmt);
150 printk("%sEXT3-fs (%s): ", prefix, sb->s_id);
151 vprintk(fmt, args);
152 printk("\n");
153 va_end(args);
154}
155
144/* Deal with the reporting of failure conditions on a filesystem such as 156/* Deal with the reporting of failure conditions on a filesystem such as
145 * inconsistencies detected or read IO failures. 157 * inconsistencies detected or read IO failures.
146 * 158 *
@@ -152,7 +164,7 @@ void ext3_journal_abort_handle(const char *caller, const char *err_fn,
152 * write out the superblock safely. 164 * write out the superblock safely.
153 * 165 *
154 * We'll just use the journal_abort() error code to record an error in 166 * We'll just use the journal_abort() error code to record an error in
155 * the journal instead. On recovery, the journal will compain about 167 * the journal instead. On recovery, the journal will complain about
156 * that error until we've noted it down and cleared it. 168 * that error until we've noted it down and cleared it.
157 */ 169 */
158 170
@@ -169,17 +181,18 @@ static void ext3_handle_error(struct super_block *sb)
169 if (!test_opt (sb, ERRORS_CONT)) { 181 if (!test_opt (sb, ERRORS_CONT)) {
170 journal_t *journal = EXT3_SB(sb)->s_journal; 182 journal_t *journal = EXT3_SB(sb)->s_journal;
171 183
172 EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT; 184 set_opt(EXT3_SB(sb)->s_mount_opt, ABORT);
173 if (journal) 185 if (journal)
174 journal_abort(journal, -EIO); 186 journal_abort(journal, -EIO);
175 } 187 }
176 if (test_opt (sb, ERRORS_RO)) { 188 if (test_opt (sb, ERRORS_RO)) {
177 printk (KERN_CRIT "Remounting filesystem read-only\n"); 189 ext3_msg(sb, KERN_CRIT,
190 "error: remounting filesystem read-only");
178 sb->s_flags |= MS_RDONLY; 191 sb->s_flags |= MS_RDONLY;
179 } 192 }
180 ext3_commit_super(sb, es, 1); 193 ext3_commit_super(sb, es, 1);
181 if (test_opt(sb, ERRORS_PANIC)) 194 if (test_opt(sb, ERRORS_PANIC))
182 panic("EXT3-fs (device %s): panic forced after error\n", 195 panic("EXT3-fs (%s): panic forced after error\n",
183 sb->s_id); 196 sb->s_id);
184} 197}
185 198
@@ -247,8 +260,7 @@ void __ext3_std_error (struct super_block * sb, const char * function,
247 return; 260 return;
248 261
249 errstr = ext3_decode_error(sb, errno, nbuf); 262 errstr = ext3_decode_error(sb, errno, nbuf);
250 printk (KERN_CRIT "EXT3-fs error (device %s) in %s: %s\n", 263 ext3_msg(sb, KERN_CRIT, "error in %s: %s", function, errstr);
251 sb->s_id, function, errstr);
252 264
253 ext3_handle_error(sb); 265 ext3_handle_error(sb);
254} 266}
@@ -268,24 +280,23 @@ void ext3_abort (struct super_block * sb, const char * function,
268{ 280{
269 va_list args; 281 va_list args;
270 282
271 printk (KERN_CRIT "ext3_abort called.\n");
272
273 va_start(args, fmt); 283 va_start(args, fmt);
274 printk(KERN_CRIT "EXT3-fs error (device %s): %s: ",sb->s_id, function); 284 printk(KERN_CRIT "EXT3-fs (%s): error: %s: ", sb->s_id, function);
275 vprintk(fmt, args); 285 vprintk(fmt, args);
276 printk("\n"); 286 printk("\n");
277 va_end(args); 287 va_end(args);
278 288
279 if (test_opt(sb, ERRORS_PANIC)) 289 if (test_opt(sb, ERRORS_PANIC))
280 panic("EXT3-fs panic from previous error\n"); 290 panic("EXT3-fs: panic from previous error\n");
281 291
282 if (sb->s_flags & MS_RDONLY) 292 if (sb->s_flags & MS_RDONLY)
283 return; 293 return;
284 294
285 printk(KERN_CRIT "Remounting filesystem read-only\n"); 295 ext3_msg(sb, KERN_CRIT,
296 "error: remounting filesystem read-only");
286 EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; 297 EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS;
287 sb->s_flags |= MS_RDONLY; 298 sb->s_flags |= MS_RDONLY;
288 EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT; 299 set_opt(EXT3_SB(sb)->s_mount_opt, ABORT);
289 if (EXT3_SB(sb)->s_journal) 300 if (EXT3_SB(sb)->s_journal)
290 journal_abort(EXT3_SB(sb)->s_journal, -EIO); 301 journal_abort(EXT3_SB(sb)->s_journal, -EIO);
291} 302}
@@ -296,7 +307,7 @@ void ext3_warning (struct super_block * sb, const char * function,
296 va_list args; 307 va_list args;
297 308
298 va_start(args, fmt); 309 va_start(args, fmt);
299 printk(KERN_WARNING "EXT3-fs warning (device %s): %s: ", 310 printk(KERN_WARNING "EXT3-fs (%s): warning: %s: ",
300 sb->s_id, function); 311 sb->s_id, function);
301 vprintk(fmt, args); 312 vprintk(fmt, args);
302 printk("\n"); 313 printk("\n");
@@ -310,10 +321,10 @@ void ext3_update_dynamic_rev(struct super_block *sb)
310 if (le32_to_cpu(es->s_rev_level) > EXT3_GOOD_OLD_REV) 321 if (le32_to_cpu(es->s_rev_level) > EXT3_GOOD_OLD_REV)
311 return; 322 return;
312 323
313 ext3_warning(sb, __func__, 324 ext3_msg(sb, KERN_WARNING,
314 "updating to rev %d because of new feature flag, " 325 "warning: updating to rev %d because of "
315 "running e2fsck is recommended", 326 "new feature flag, running e2fsck is recommended",
316 EXT3_DYNAMIC_REV); 327 EXT3_DYNAMIC_REV);
317 328
318 es->s_first_ino = cpu_to_le32(EXT3_GOOD_OLD_FIRST_INO); 329 es->s_first_ino = cpu_to_le32(EXT3_GOOD_OLD_FIRST_INO);
319 es->s_inode_size = cpu_to_le16(EXT3_GOOD_OLD_INODE_SIZE); 330 es->s_inode_size = cpu_to_le16(EXT3_GOOD_OLD_INODE_SIZE);
@@ -331,7 +342,7 @@ void ext3_update_dynamic_rev(struct super_block *sb)
331/* 342/*
332 * Open the external journal device 343 * Open the external journal device
333 */ 344 */
334static struct block_device *ext3_blkdev_get(dev_t dev) 345static struct block_device *ext3_blkdev_get(dev_t dev, struct super_block *sb)
335{ 346{
336 struct block_device *bdev; 347 struct block_device *bdev;
337 char b[BDEVNAME_SIZE]; 348 char b[BDEVNAME_SIZE];
@@ -342,8 +353,9 @@ static struct block_device *ext3_blkdev_get(dev_t dev)
342 return bdev; 353 return bdev;
343 354
344fail: 355fail:
345 printk(KERN_ERR "EXT3: failed to open journal device %s: %ld\n", 356 ext3_msg(sb, "error: failed to open journal device %s: %ld",
346 __bdevname(dev, b), PTR_ERR(bdev)); 357 __bdevname(dev, b), PTR_ERR(bdev));
358
347 return NULL; 359 return NULL;
348} 360}
349 361
@@ -378,13 +390,13 @@ static void dump_orphan_list(struct super_block *sb, struct ext3_sb_info *sbi)
378{ 390{
379 struct list_head *l; 391 struct list_head *l;
380 392
381 printk(KERN_ERR "sb orphan head is %d\n", 393 ext3_msg(sb, KERN_ERR, "error: sb orphan head is %d",
382 le32_to_cpu(sbi->s_es->s_last_orphan)); 394 le32_to_cpu(sbi->s_es->s_last_orphan));
383 395
384 printk(KERN_ERR "sb_info orphan list:\n"); 396 ext3_msg(sb, KERN_ERR, "sb_info orphan list:");
385 list_for_each(l, &sbi->s_orphan) { 397 list_for_each(l, &sbi->s_orphan) {
386 struct inode *inode = orphan_list_entry(l); 398 struct inode *inode = orphan_list_entry(l);
387 printk(KERN_ERR " " 399 ext3_msg(sb, KERN_ERR, " "
388 "inode %s:%lu at %p: mode %o, nlink %d, next %d\n", 400 "inode %s:%lu at %p: mode %o, nlink %d, next %d\n",
389 inode->i_sb->s_id, inode->i_ino, inode, 401 inode->i_sb->s_id, inode->i_ino, inode,
390 inode->i_mode, inode->i_nlink, 402 inode->i_mode, inode->i_nlink,
@@ -516,6 +528,8 @@ static void destroy_inodecache(void)
516static void ext3_clear_inode(struct inode *inode) 528static void ext3_clear_inode(struct inode *inode)
517{ 529{
518 struct ext3_block_alloc_info *rsv = EXT3_I(inode)->i_block_alloc_info; 530 struct ext3_block_alloc_info *rsv = EXT3_I(inode)->i_block_alloc_info;
531
532 dquot_drop(inode);
519 ext3_discard_reservation(inode); 533 ext3_discard_reservation(inode);
520 EXT3_I(inode)->i_block_alloc_info = NULL; 534 EXT3_I(inode)->i_block_alloc_info = NULL;
521 if (unlikely(rsv)) 535 if (unlikely(rsv))
@@ -527,9 +541,22 @@ static inline void ext3_show_quota_options(struct seq_file *seq, struct super_bl
527#if defined(CONFIG_QUOTA) 541#if defined(CONFIG_QUOTA)
528 struct ext3_sb_info *sbi = EXT3_SB(sb); 542 struct ext3_sb_info *sbi = EXT3_SB(sb);
529 543
530 if (sbi->s_jquota_fmt) 544 if (sbi->s_jquota_fmt) {
531 seq_printf(seq, ",jqfmt=%s", 545 char *fmtname = "";
532 (sbi->s_jquota_fmt == QFMT_VFS_OLD) ? "vfsold": "vfsv0"); 546
547 switch (sbi->s_jquota_fmt) {
548 case QFMT_VFS_OLD:
549 fmtname = "vfsold";
550 break;
551 case QFMT_VFS_V0:
552 fmtname = "vfsv0";
553 break;
554 case QFMT_VFS_V1:
555 fmtname = "vfsv1";
556 break;
557 }
558 seq_printf(seq, ",jqfmt=%s", fmtname);
559 }
533 560
534 if (sbi->s_qf_names[USRQUOTA]) 561 if (sbi->s_qf_names[USRQUOTA])
535 seq_printf(seq, ",usrjquota=%s", sbi->s_qf_names[USRQUOTA]); 562 seq_printf(seq, ",usrjquota=%s", sbi->s_qf_names[USRQUOTA]);
@@ -537,10 +564,10 @@ static inline void ext3_show_quota_options(struct seq_file *seq, struct super_bl
537 if (sbi->s_qf_names[GRPQUOTA]) 564 if (sbi->s_qf_names[GRPQUOTA])
538 seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]); 565 seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]);
539 566
540 if (sbi->s_mount_opt & EXT3_MOUNT_USRQUOTA) 567 if (test_opt(sb, USRQUOTA))
541 seq_puts(seq, ",usrquota"); 568 seq_puts(seq, ",usrquota");
542 569
543 if (sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA) 570 if (test_opt(sb, GRPQUOTA))
544 seq_puts(seq, ",grpquota"); 571 seq_puts(seq, ",grpquota");
545#endif 572#endif
546} 573}
@@ -631,11 +658,13 @@ static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs)
631 if (test_opt(sb, NOBH)) 658 if (test_opt(sb, NOBH))
632 seq_puts(seq, ",nobh"); 659 seq_puts(seq, ",nobh");
633 660
634 seq_printf(seq, ",data=%s", data_mode_string(sbi->s_mount_opt & 661 seq_printf(seq, ",data=%s", data_mode_string(test_opt(sb, DATA_FLAGS)));
635 EXT3_MOUNT_DATA_FLAGS));
636 if (test_opt(sb, DATA_ERR_ABORT)) 662 if (test_opt(sb, DATA_ERR_ABORT))
637 seq_puts(seq, ",data_err=abort"); 663 seq_puts(seq, ",data_err=abort");
638 664
665 if (test_opt(sb, NOLOAD))
666 seq_puts(seq, ",norecovery");
667
639 ext3_show_quota_options(seq, sb); 668 ext3_show_quota_options(seq, sb);
640 669
641 return 0; 670 return 0;
@@ -723,13 +752,6 @@ static ssize_t ext3_quota_write(struct super_block *sb, int type,
723 const char *data, size_t len, loff_t off); 752 const char *data, size_t len, loff_t off);
724 753
725static const struct dquot_operations ext3_quota_operations = { 754static const struct dquot_operations ext3_quota_operations = {
726 .initialize = dquot_initialize,
727 .drop = dquot_drop,
728 .alloc_space = dquot_alloc_space,
729 .alloc_inode = dquot_alloc_inode,
730 .free_space = dquot_free_space,
731 .free_inode = dquot_free_inode,
732 .transfer = dquot_transfer,
733 .write_dquot = ext3_write_dquot, 755 .write_dquot = ext3_write_dquot,
734 .acquire_dquot = ext3_acquire_dquot, 756 .acquire_dquot = ext3_acquire_dquot,
735 .release_dquot = ext3_release_dquot, 757 .release_dquot = ext3_release_dquot,
@@ -787,9 +809,9 @@ enum {
787 Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback, 809 Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback,
788 Opt_data_err_abort, Opt_data_err_ignore, 810 Opt_data_err_abort, Opt_data_err_ignore,
789 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, 811 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
790 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, 812 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
791 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota, 813 Opt_noquota, Opt_ignore, Opt_barrier, Opt_err, Opt_resize,
792 Opt_grpquota 814 Opt_usrquota, Opt_grpquota
793}; 815};
794 816
795static const match_table_t tokens = { 817static const match_table_t tokens = {
@@ -818,6 +840,7 @@ static const match_table_t tokens = {
818 {Opt_reservation, "reservation"}, 840 {Opt_reservation, "reservation"},
819 {Opt_noreservation, "noreservation"}, 841 {Opt_noreservation, "noreservation"},
820 {Opt_noload, "noload"}, 842 {Opt_noload, "noload"},
843 {Opt_noload, "norecovery"},
821 {Opt_nobh, "nobh"}, 844 {Opt_nobh, "nobh"},
822 {Opt_bh, "bh"}, 845 {Opt_bh, "bh"},
823 {Opt_commit, "commit=%u"}, 846 {Opt_commit, "commit=%u"},
@@ -836,6 +859,7 @@ static const match_table_t tokens = {
836 {Opt_grpjquota, "grpjquota=%s"}, 859 {Opt_grpjquota, "grpjquota=%s"},
837 {Opt_jqfmt_vfsold, "jqfmt=vfsold"}, 860 {Opt_jqfmt_vfsold, "jqfmt=vfsold"},
838 {Opt_jqfmt_vfsv0, "jqfmt=vfsv0"}, 861 {Opt_jqfmt_vfsv0, "jqfmt=vfsv0"},
862 {Opt_jqfmt_vfsv1, "jqfmt=vfsv1"},
839 {Opt_grpquota, "grpquota"}, 863 {Opt_grpquota, "grpquota"},
840 {Opt_noquota, "noquota"}, 864 {Opt_noquota, "noquota"},
841 {Opt_quota, "quota"}, 865 {Opt_quota, "quota"},
@@ -845,7 +869,7 @@ static const match_table_t tokens = {
845 {Opt_err, NULL}, 869 {Opt_err, NULL},
846}; 870};
847 871
848static ext3_fsblk_t get_sb_block(void **data) 872static ext3_fsblk_t get_sb_block(void **data, struct super_block *sb)
849{ 873{
850 ext3_fsblk_t sb_block; 874 ext3_fsblk_t sb_block;
851 char *options = (char *) *data; 875 char *options = (char *) *data;
@@ -856,7 +880,7 @@ static ext3_fsblk_t get_sb_block(void **data)
856 /*todo: use simple_strtoll with >32bit ext3 */ 880 /*todo: use simple_strtoll with >32bit ext3 */
857 sb_block = simple_strtoul(options, &options, 0); 881 sb_block = simple_strtoul(options, &options, 0);
858 if (*options && *options != ',') { 882 if (*options && *options != ',') {
859 printk("EXT3-fs: Invalid sb specification: %s\n", 883 ext3_msg(sb, "error: invalid sb specification: %s",
860 (char *) *data); 884 (char *) *data);
861 return 1; 885 return 1;
862 } 886 }
@@ -866,6 +890,63 @@ static ext3_fsblk_t get_sb_block(void **data)
866 return sb_block; 890 return sb_block;
867} 891}
868 892
893#ifdef CONFIG_QUOTA
894static int set_qf_name(struct super_block *sb, int qtype, substring_t *args)
895{
896 struct ext3_sb_info *sbi = EXT3_SB(sb);
897 char *qname;
898
899 if (sb_any_quota_loaded(sb) &&
900 !sbi->s_qf_names[qtype]) {
901 ext3_msg(sb, KERN_ERR,
902 "Cannot change journaled "
903 "quota options when quota turned on");
904 return 0;
905 }
906 qname = match_strdup(args);
907 if (!qname) {
908 ext3_msg(sb, KERN_ERR,
909 "Not enough memory for storing quotafile name");
910 return 0;
911 }
912 if (sbi->s_qf_names[qtype] &&
913 strcmp(sbi->s_qf_names[qtype], qname)) {
914 ext3_msg(sb, KERN_ERR,
915 "%s quota file already specified", QTYPE2NAME(qtype));
916 kfree(qname);
917 return 0;
918 }
919 sbi->s_qf_names[qtype] = qname;
920 if (strchr(sbi->s_qf_names[qtype], '/')) {
921 ext3_msg(sb, KERN_ERR,
922 "quotafile must be on filesystem root");
923 kfree(sbi->s_qf_names[qtype]);
924 sbi->s_qf_names[qtype] = NULL;
925 return 0;
926 }
927 set_opt(sbi->s_mount_opt, QUOTA);
928 return 1;
929}
930
931static int clear_qf_name(struct super_block *sb, int qtype) {
932
933 struct ext3_sb_info *sbi = EXT3_SB(sb);
934
935 if (sb_any_quota_loaded(sb) &&
936 sbi->s_qf_names[qtype]) {
937 ext3_msg(sb, KERN_ERR, "Cannot change journaled quota options"
938 " when quota turned on");
939 return 0;
940 }
941 /*
942 * The space will be released later when all options are confirmed
943 * to be correct
944 */
945 sbi->s_qf_names[qtype] = NULL;
946 return 1;
947}
948#endif
949
869static int parse_options (char *options, struct super_block *sb, 950static int parse_options (char *options, struct super_block *sb,
870 unsigned int *inum, unsigned long *journal_devnum, 951 unsigned int *inum, unsigned long *journal_devnum,
871 ext3_fsblk_t *n_blocks_count, int is_remount) 952 ext3_fsblk_t *n_blocks_count, int is_remount)
@@ -876,8 +957,7 @@ static int parse_options (char *options, struct super_block *sb,
876 int data_opt = 0; 957 int data_opt = 0;
877 int option; 958 int option;
878#ifdef CONFIG_QUOTA 959#ifdef CONFIG_QUOTA
879 int qtype, qfmt; 960 int qfmt;
880 char *qname;
881#endif 961#endif
882 962
883 if (!options) 963 if (!options)
@@ -956,7 +1036,8 @@ static int parse_options (char *options, struct super_block *sb,
956#else 1036#else
957 case Opt_user_xattr: 1037 case Opt_user_xattr:
958 case Opt_nouser_xattr: 1038 case Opt_nouser_xattr:
959 printk("EXT3 (no)user_xattr options not supported\n"); 1039 ext3_msg(sb, KERN_INFO,
1040 "(no)user_xattr options not supported");
960 break; 1041 break;
961#endif 1042#endif
962#ifdef CONFIG_EXT3_FS_POSIX_ACL 1043#ifdef CONFIG_EXT3_FS_POSIX_ACL
@@ -969,7 +1050,8 @@ static int parse_options (char *options, struct super_block *sb,
969#else 1050#else
970 case Opt_acl: 1051 case Opt_acl:
971 case Opt_noacl: 1052 case Opt_noacl:
972 printk("EXT3 (no)acl options not supported\n"); 1053 ext3_msg(sb, KERN_INFO,
1054 "(no)acl options not supported");
973 break; 1055 break;
974#endif 1056#endif
975 case Opt_reservation: 1057 case Opt_reservation:
@@ -985,16 +1067,16 @@ static int parse_options (char *options, struct super_block *sb,
985 user to specify an existing inode to be the 1067 user to specify an existing inode to be the
986 journal file. */ 1068 journal file. */
987 if (is_remount) { 1069 if (is_remount) {
988 printk(KERN_ERR "EXT3-fs: cannot specify " 1070 ext3_msg(sb, KERN_ERR, "error: cannot specify "
989 "journal on remount\n"); 1071 "journal on remount");
990 return 0; 1072 return 0;
991 } 1073 }
992 set_opt (sbi->s_mount_opt, UPDATE_JOURNAL); 1074 set_opt (sbi->s_mount_opt, UPDATE_JOURNAL);
993 break; 1075 break;
994 case Opt_journal_inum: 1076 case Opt_journal_inum:
995 if (is_remount) { 1077 if (is_remount) {
996 printk(KERN_ERR "EXT3-fs: cannot specify " 1078 ext3_msg(sb, KERN_ERR, "error: cannot specify "
997 "journal on remount\n"); 1079 "journal on remount");
998 return 0; 1080 return 0;
999 } 1081 }
1000 if (match_int(&args[0], &option)) 1082 if (match_int(&args[0], &option))
@@ -1003,8 +1085,8 @@ static int parse_options (char *options, struct super_block *sb,
1003 break; 1085 break;
1004 case Opt_journal_dev: 1086 case Opt_journal_dev:
1005 if (is_remount) { 1087 if (is_remount) {
1006 printk(KERN_ERR "EXT3-fs: cannot specify " 1088 ext3_msg(sb, KERN_ERR, "error: cannot specify "
1007 "journal on remount\n"); 1089 "journal on remount");
1008 return 0; 1090 return 0;
1009 } 1091 }
1010 if (match_int(&args[0], &option)) 1092 if (match_int(&args[0], &option))
@@ -1033,21 +1115,19 @@ static int parse_options (char *options, struct super_block *sb,
1033 data_opt = EXT3_MOUNT_WRITEBACK_DATA; 1115 data_opt = EXT3_MOUNT_WRITEBACK_DATA;
1034 datacheck: 1116 datacheck:
1035 if (is_remount) { 1117 if (is_remount) {
1036 if ((sbi->s_mount_opt & EXT3_MOUNT_DATA_FLAGS) 1118 if (test_opt(sb, DATA_FLAGS) == data_opt)
1037 == data_opt)
1038 break; 1119 break;
1039 printk(KERN_ERR 1120 ext3_msg(sb, KERN_ERR,
1040 "EXT3-fs (device %s): Cannot change " 1121 "error: cannot change "
1041 "data mode on remount. The filesystem " 1122 "data mode on remount. The filesystem "
1042 "is mounted in data=%s mode and you " 1123 "is mounted in data=%s mode and you "
1043 "try to remount it in data=%s mode.\n", 1124 "try to remount it in data=%s mode.",
1044 sb->s_id, 1125 data_mode_string(test_opt(sb,
1045 data_mode_string(sbi->s_mount_opt & 1126 DATA_FLAGS)),
1046 EXT3_MOUNT_DATA_FLAGS),
1047 data_mode_string(data_opt)); 1127 data_mode_string(data_opt));
1048 return 0; 1128 return 0;
1049 } else { 1129 } else {
1050 sbi->s_mount_opt &= ~EXT3_MOUNT_DATA_FLAGS; 1130 clear_opt(sbi->s_mount_opt, DATA_FLAGS);
1051 sbi->s_mount_opt |= data_opt; 1131 sbi->s_mount_opt |= data_opt;
1052 } 1132 }
1053 break; 1133 break;
@@ -1059,74 +1139,35 @@ static int parse_options (char *options, struct super_block *sb,
1059 break; 1139 break;
1060#ifdef CONFIG_QUOTA 1140#ifdef CONFIG_QUOTA
1061 case Opt_usrjquota: 1141 case Opt_usrjquota:
1062 qtype = USRQUOTA; 1142 if (!set_qf_name(sb, USRQUOTA, &args[0]))
1063 goto set_qf_name;
1064 case Opt_grpjquota:
1065 qtype = GRPQUOTA;
1066set_qf_name:
1067 if (sb_any_quota_loaded(sb) &&
1068 !sbi->s_qf_names[qtype]) {
1069 printk(KERN_ERR
1070 "EXT3-fs: Cannot change journaled "
1071 "quota options when quota turned on.\n");
1072 return 0; 1143 return 0;
1073 } 1144 break;
1074 qname = match_strdup(&args[0]); 1145 case Opt_grpjquota:
1075 if (!qname) { 1146 if (!set_qf_name(sb, GRPQUOTA, &args[0]))
1076 printk(KERN_ERR
1077 "EXT3-fs: not enough memory for "
1078 "storing quotafile name.\n");
1079 return 0;
1080 }
1081 if (sbi->s_qf_names[qtype] &&
1082 strcmp(sbi->s_qf_names[qtype], qname)) {
1083 printk(KERN_ERR
1084 "EXT3-fs: %s quota file already "
1085 "specified.\n", QTYPE2NAME(qtype));
1086 kfree(qname);
1087 return 0;
1088 }
1089 sbi->s_qf_names[qtype] = qname;
1090 if (strchr(sbi->s_qf_names[qtype], '/')) {
1091 printk(KERN_ERR
1092 "EXT3-fs: quotafile must be on "
1093 "filesystem root.\n");
1094 kfree(sbi->s_qf_names[qtype]);
1095 sbi->s_qf_names[qtype] = NULL;
1096 return 0; 1147 return 0;
1097 }
1098 set_opt(sbi->s_mount_opt, QUOTA);
1099 break; 1148 break;
1100 case Opt_offusrjquota: 1149 case Opt_offusrjquota:
1101 qtype = USRQUOTA; 1150 if (!clear_qf_name(sb, USRQUOTA))
1102 goto clear_qf_name; 1151 return 0;
1152 break;
1103 case Opt_offgrpjquota: 1153 case Opt_offgrpjquota:
1104 qtype = GRPQUOTA; 1154 if (!clear_qf_name(sb, GRPQUOTA))
1105clear_qf_name:
1106 if (sb_any_quota_loaded(sb) &&
1107 sbi->s_qf_names[qtype]) {
1108 printk(KERN_ERR "EXT3-fs: Cannot change "
1109 "journaled quota options when "
1110 "quota turned on.\n");
1111 return 0; 1155 return 0;
1112 }
1113 /*
1114 * The space will be released later when all options
1115 * are confirmed to be correct
1116 */
1117 sbi->s_qf_names[qtype] = NULL;
1118 break; 1156 break;
1119 case Opt_jqfmt_vfsold: 1157 case Opt_jqfmt_vfsold:
1120 qfmt = QFMT_VFS_OLD; 1158 qfmt = QFMT_VFS_OLD;
1121 goto set_qf_format; 1159 goto set_qf_format;
1122 case Opt_jqfmt_vfsv0: 1160 case Opt_jqfmt_vfsv0:
1123 qfmt = QFMT_VFS_V0; 1161 qfmt = QFMT_VFS_V0;
1162 goto set_qf_format;
1163 case Opt_jqfmt_vfsv1:
1164 qfmt = QFMT_VFS_V1;
1124set_qf_format: 1165set_qf_format:
1125 if (sb_any_quota_loaded(sb) && 1166 if (sb_any_quota_loaded(sb) &&
1126 sbi->s_jquota_fmt != qfmt) { 1167 sbi->s_jquota_fmt != qfmt) {
1127 printk(KERN_ERR "EXT3-fs: Cannot change " 1168 ext3_msg(sb, KERN_ERR, "error: cannot change "
1128 "journaled quota options when " 1169 "journaled quota options when "
1129 "quota turned on.\n"); 1170 "quota turned on.");
1130 return 0; 1171 return 0;
1131 } 1172 }
1132 sbi->s_jquota_fmt = qfmt; 1173 sbi->s_jquota_fmt = qfmt;
@@ -1142,8 +1183,8 @@ set_qf_format:
1142 break; 1183 break;
1143 case Opt_noquota: 1184 case Opt_noquota:
1144 if (sb_any_quota_loaded(sb)) { 1185 if (sb_any_quota_loaded(sb)) {
1145 printk(KERN_ERR "EXT3-fs: Cannot change quota " 1186 ext3_msg(sb, KERN_ERR, "error: cannot change "
1146 "options when quota turned on.\n"); 1187 "quota options when quota turned on.");
1147 return 0; 1188 return 0;
1148 } 1189 }
1149 clear_opt(sbi->s_mount_opt, QUOTA); 1190 clear_opt(sbi->s_mount_opt, QUOTA);
@@ -1154,8 +1195,8 @@ set_qf_format:
1154 case Opt_quota: 1195 case Opt_quota:
1155 case Opt_usrquota: 1196 case Opt_usrquota:
1156 case Opt_grpquota: 1197 case Opt_grpquota:
1157 printk(KERN_ERR 1198 ext3_msg(sb, KERN_ERR,
1158 "EXT3-fs: quota options not supported.\n"); 1199 "error: quota options not supported.");
1159 break; 1200 break;
1160 case Opt_usrjquota: 1201 case Opt_usrjquota:
1161 case Opt_grpjquota: 1202 case Opt_grpjquota:
@@ -1163,9 +1204,10 @@ set_qf_format:
1163 case Opt_offgrpjquota: 1204 case Opt_offgrpjquota:
1164 case Opt_jqfmt_vfsold: 1205 case Opt_jqfmt_vfsold:
1165 case Opt_jqfmt_vfsv0: 1206 case Opt_jqfmt_vfsv0:
1166 printk(KERN_ERR 1207 case Opt_jqfmt_vfsv1:
1167 "EXT3-fs: journaled quota options not " 1208 ext3_msg(sb, KERN_ERR,
1168 "supported.\n"); 1209 "error: journaled quota options not "
1210 "supported.");
1169 break; 1211 break;
1170 case Opt_noquota: 1212 case Opt_noquota:
1171 break; 1213 break;
@@ -1185,8 +1227,9 @@ set_qf_format:
1185 break; 1227 break;
1186 case Opt_resize: 1228 case Opt_resize:
1187 if (!is_remount) { 1229 if (!is_remount) {
1188 printk("EXT3-fs: resize option only available " 1230 ext3_msg(sb, KERN_ERR,
1189 "for remount\n"); 1231 "error: resize option only available "
1232 "for remount");
1190 return 0; 1233 return 0;
1191 } 1234 }
1192 if (match_int(&args[0], &option) != 0) 1235 if (match_int(&args[0], &option) != 0)
@@ -1200,41 +1243,35 @@ set_qf_format:
1200 clear_opt(sbi->s_mount_opt, NOBH); 1243 clear_opt(sbi->s_mount_opt, NOBH);
1201 break; 1244 break;
1202 default: 1245 default:
1203 printk (KERN_ERR 1246 ext3_msg(sb, KERN_ERR,
1204 "EXT3-fs: Unrecognized mount option \"%s\" " 1247 "error: unrecognized mount option \"%s\" "
1205 "or missing value\n", p); 1248 "or missing value", p);
1206 return 0; 1249 return 0;
1207 } 1250 }
1208 } 1251 }
1209#ifdef CONFIG_QUOTA 1252#ifdef CONFIG_QUOTA
1210 if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) { 1253 if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) {
1211 if ((sbi->s_mount_opt & EXT3_MOUNT_USRQUOTA) && 1254 if (test_opt(sb, USRQUOTA) && sbi->s_qf_names[USRQUOTA])
1212 sbi->s_qf_names[USRQUOTA])
1213 clear_opt(sbi->s_mount_opt, USRQUOTA); 1255 clear_opt(sbi->s_mount_opt, USRQUOTA);
1214 1256 if (test_opt(sb, GRPQUOTA) && sbi->s_qf_names[GRPQUOTA])
1215 if ((sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA) &&
1216 sbi->s_qf_names[GRPQUOTA])
1217 clear_opt(sbi->s_mount_opt, GRPQUOTA); 1257 clear_opt(sbi->s_mount_opt, GRPQUOTA);
1218 1258
1219 if ((sbi->s_qf_names[USRQUOTA] && 1259 if (test_opt(sb, GRPQUOTA) || test_opt(sb, USRQUOTA)) {
1220 (sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA)) || 1260 ext3_msg(sb, KERN_ERR, "error: old and new quota "
1221 (sbi->s_qf_names[GRPQUOTA] && 1261 "format mixing.");
1222 (sbi->s_mount_opt & EXT3_MOUNT_USRQUOTA))) {
1223 printk(KERN_ERR "EXT3-fs: old and new quota "
1224 "format mixing.\n");
1225 return 0; 1262 return 0;
1226 } 1263 }
1227 1264
1228 if (!sbi->s_jquota_fmt) { 1265 if (!sbi->s_jquota_fmt) {
1229 printk(KERN_ERR "EXT3-fs: journaled quota format " 1266 ext3_msg(sb, KERN_ERR, "error: journaled quota format "
1230 "not specified.\n"); 1267 "not specified.");
1231 return 0; 1268 return 0;
1232 } 1269 }
1233 } else { 1270 } else {
1234 if (sbi->s_jquota_fmt) { 1271 if (sbi->s_jquota_fmt) {
1235 printk(KERN_ERR "EXT3-fs: journaled quota format " 1272 ext3_msg(sb, KERN_ERR, "error: journaled quota format "
1236 "specified with no journaling " 1273 "specified with no journaling "
1237 "enabled.\n"); 1274 "enabled.");
1238 return 0; 1275 return 0;
1239 } 1276 }
1240 } 1277 }
@@ -1249,31 +1286,33 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es,
1249 int res = 0; 1286 int res = 0;
1250 1287
1251 if (le32_to_cpu(es->s_rev_level) > EXT3_MAX_SUPP_REV) { 1288 if (le32_to_cpu(es->s_rev_level) > EXT3_MAX_SUPP_REV) {
1252 printk (KERN_ERR "EXT3-fs warning: revision level too high, " 1289 ext3_msg(sb, KERN_ERR,
1253 "forcing read-only mode\n"); 1290 "error: revision level too high, "
1291 "forcing read-only mode");
1254 res = MS_RDONLY; 1292 res = MS_RDONLY;
1255 } 1293 }
1256 if (read_only) 1294 if (read_only)
1257 return res; 1295 return res;
1258 if (!(sbi->s_mount_state & EXT3_VALID_FS)) 1296 if (!(sbi->s_mount_state & EXT3_VALID_FS))
1259 printk (KERN_WARNING "EXT3-fs warning: mounting unchecked fs, " 1297 ext3_msg(sb, KERN_WARNING,
1260 "running e2fsck is recommended\n"); 1298 "warning: mounting unchecked fs, "
1299 "running e2fsck is recommended");
1261 else if ((sbi->s_mount_state & EXT3_ERROR_FS)) 1300 else if ((sbi->s_mount_state & EXT3_ERROR_FS))
1262 printk (KERN_WARNING 1301 ext3_msg(sb, KERN_WARNING,
1263 "EXT3-fs warning: mounting fs with errors, " 1302 "warning: mounting fs with errors, "
1264 "running e2fsck is recommended\n"); 1303 "running e2fsck is recommended");
1265 else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 && 1304 else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 &&
1266 le16_to_cpu(es->s_mnt_count) >= 1305 le16_to_cpu(es->s_mnt_count) >=
1267 (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count)) 1306 (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
1268 printk (KERN_WARNING 1307 ext3_msg(sb, KERN_WARNING,
1269 "EXT3-fs warning: maximal mount count reached, " 1308 "warning: maximal mount count reached, "
1270 "running e2fsck is recommended\n"); 1309 "running e2fsck is recommended");
1271 else if (le32_to_cpu(es->s_checkinterval) && 1310 else if (le32_to_cpu(es->s_checkinterval) &&
1272 (le32_to_cpu(es->s_lastcheck) + 1311 (le32_to_cpu(es->s_lastcheck) +
1273 le32_to_cpu(es->s_checkinterval) <= get_seconds())) 1312 le32_to_cpu(es->s_checkinterval) <= get_seconds()))
1274 printk (KERN_WARNING 1313 ext3_msg(sb, KERN_WARNING,
1275 "EXT3-fs warning: checktime reached, " 1314 "warning: checktime reached, "
1276 "running e2fsck is recommended\n"); 1315 "running e2fsck is recommended");
1277#if 0 1316#if 0
1278 /* @@@ We _will_ want to clear the valid bit if we find 1317 /* @@@ We _will_ want to clear the valid bit if we find
1279 inconsistencies, to force a fsck at reboot. But for 1318 inconsistencies, to force a fsck at reboot. But for
@@ -1290,22 +1329,20 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es,
1290 1329
1291 ext3_commit_super(sb, es, 1); 1330 ext3_commit_super(sb, es, 1);
1292 if (test_opt(sb, DEBUG)) 1331 if (test_opt(sb, DEBUG))
1293 printk(KERN_INFO "[EXT3 FS bs=%lu, gc=%lu, " 1332 ext3_msg(sb, KERN_INFO, "[bs=%lu, gc=%lu, "
1294 "bpg=%lu, ipg=%lu, mo=%04lx]\n", 1333 "bpg=%lu, ipg=%lu, mo=%04lx]",
1295 sb->s_blocksize, 1334 sb->s_blocksize,
1296 sbi->s_groups_count, 1335 sbi->s_groups_count,
1297 EXT3_BLOCKS_PER_GROUP(sb), 1336 EXT3_BLOCKS_PER_GROUP(sb),
1298 EXT3_INODES_PER_GROUP(sb), 1337 EXT3_INODES_PER_GROUP(sb),
1299 sbi->s_mount_opt); 1338 sbi->s_mount_opt);
1300 1339
1301 printk(KERN_INFO "EXT3 FS on %s, ", sb->s_id);
1302 if (EXT3_SB(sb)->s_journal->j_inode == NULL) { 1340 if (EXT3_SB(sb)->s_journal->j_inode == NULL) {
1303 char b[BDEVNAME_SIZE]; 1341 char b[BDEVNAME_SIZE];
1304 1342 ext3_msg(sb, KERN_INFO, "using external journal on %s",
1305 printk("external journal on %s\n",
1306 bdevname(EXT3_SB(sb)->s_journal->j_dev, b)); 1343 bdevname(EXT3_SB(sb)->s_journal->j_dev, b));
1307 } else { 1344 } else {
1308 printk("internal journal\n"); 1345 ext3_msg(sb, KERN_INFO, "using internal journal");
1309 } 1346 }
1310 return res; 1347 return res;
1311} 1348}
@@ -1399,8 +1436,8 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1399 } 1436 }
1400 1437
1401 if (bdev_read_only(sb->s_bdev)) { 1438 if (bdev_read_only(sb->s_bdev)) {
1402 printk(KERN_ERR "EXT3-fs: write access " 1439 ext3_msg(sb, KERN_ERR, "error: write access "
1403 "unavailable, skipping orphan cleanup.\n"); 1440 "unavailable, skipping orphan cleanup.");
1404 return; 1441 return;
1405 } 1442 }
1406 1443
@@ -1414,8 +1451,7 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1414 } 1451 }
1415 1452
1416 if (s_flags & MS_RDONLY) { 1453 if (s_flags & MS_RDONLY) {
1417 printk(KERN_INFO "EXT3-fs: %s: orphan cleanup on readonly fs\n", 1454 ext3_msg(sb, KERN_INFO, "orphan cleanup on readonly fs");
1418 sb->s_id);
1419 sb->s_flags &= ~MS_RDONLY; 1455 sb->s_flags &= ~MS_RDONLY;
1420 } 1456 }
1421#ifdef CONFIG_QUOTA 1457#ifdef CONFIG_QUOTA
@@ -1426,9 +1462,9 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1426 if (EXT3_SB(sb)->s_qf_names[i]) { 1462 if (EXT3_SB(sb)->s_qf_names[i]) {
1427 int ret = ext3_quota_on_mount(sb, i); 1463 int ret = ext3_quota_on_mount(sb, i);
1428 if (ret < 0) 1464 if (ret < 0)
1429 printk(KERN_ERR 1465 ext3_msg(sb, KERN_ERR,
1430 "EXT3-fs: Cannot turn on journaled " 1466 "error: cannot turn on journaled "
1431 "quota: error %d\n", ret); 1467 "quota: %d", ret);
1432 } 1468 }
1433 } 1469 }
1434#endif 1470#endif
@@ -1443,7 +1479,7 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1443 } 1479 }
1444 1480
1445 list_add(&EXT3_I(inode)->i_orphan, &EXT3_SB(sb)->s_orphan); 1481 list_add(&EXT3_I(inode)->i_orphan, &EXT3_SB(sb)->s_orphan);
1446 vfs_dq_init(inode); 1482 dquot_initialize(inode);
1447 if (inode->i_nlink) { 1483 if (inode->i_nlink) {
1448 printk(KERN_DEBUG 1484 printk(KERN_DEBUG
1449 "%s: truncating inode %lu to %Ld bytes\n", 1485 "%s: truncating inode %lu to %Ld bytes\n",
@@ -1466,11 +1502,11 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1466#define PLURAL(x) (x), ((x)==1) ? "" : "s" 1502#define PLURAL(x) (x), ((x)==1) ? "" : "s"
1467 1503
1468 if (nr_orphans) 1504 if (nr_orphans)
1469 printk(KERN_INFO "EXT3-fs: %s: %d orphan inode%s deleted\n", 1505 ext3_msg(sb, KERN_INFO, "%d orphan inode%s deleted",
1470 sb->s_id, PLURAL(nr_orphans)); 1506 PLURAL(nr_orphans));
1471 if (nr_truncates) 1507 if (nr_truncates)
1472 printk(KERN_INFO "EXT3-fs: %s: %d truncate%s cleaned up\n", 1508 ext3_msg(sb, KERN_INFO, "%d truncate%s cleaned up",
1473 sb->s_id, PLURAL(nr_truncates)); 1509 PLURAL(nr_truncates));
1474#ifdef CONFIG_QUOTA 1510#ifdef CONFIG_QUOTA
1475 /* Turn quotas off */ 1511 /* Turn quotas off */
1476 for (i = 0; i < MAXQUOTAS; i++) { 1512 for (i = 0; i < MAXQUOTAS; i++) {
@@ -1554,7 +1590,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1554 struct ext3_super_block *es = NULL; 1590 struct ext3_super_block *es = NULL;
1555 struct ext3_sb_info *sbi; 1591 struct ext3_sb_info *sbi;
1556 ext3_fsblk_t block; 1592 ext3_fsblk_t block;
1557 ext3_fsblk_t sb_block = get_sb_block(&data); 1593 ext3_fsblk_t sb_block = get_sb_block(&data, sb);
1558 ext3_fsblk_t logic_sb_block; 1594 ext3_fsblk_t logic_sb_block;
1559 unsigned long offset = 0; 1595 unsigned long offset = 0;
1560 unsigned int journal_inum = 0; 1596 unsigned int journal_inum = 0;
@@ -1590,7 +1626,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1590 1626
1591 blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE); 1627 blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE);
1592 if (!blocksize) { 1628 if (!blocksize) {
1593 printk(KERN_ERR "EXT3-fs: unable to set blocksize\n"); 1629 ext3_msg(sb, KERN_ERR, "error: unable to set blocksize");
1594 goto out_fail; 1630 goto out_fail;
1595 } 1631 }
1596 1632
@@ -1606,7 +1642,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1606 } 1642 }
1607 1643
1608 if (!(bh = sb_bread(sb, logic_sb_block))) { 1644 if (!(bh = sb_bread(sb, logic_sb_block))) {
1609 printk (KERN_ERR "EXT3-fs: unable to read superblock\n"); 1645 ext3_msg(sb, KERN_ERR, "error: unable to read superblock");
1610 goto out_fail; 1646 goto out_fail;
1611 } 1647 }
1612 /* 1648 /*
@@ -1636,11 +1672,11 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1636 set_opt(sbi->s_mount_opt, POSIX_ACL); 1672 set_opt(sbi->s_mount_opt, POSIX_ACL);
1637#endif 1673#endif
1638 if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_DATA) 1674 if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_DATA)
1639 sbi->s_mount_opt |= EXT3_MOUNT_JOURNAL_DATA; 1675 set_opt(sbi->s_mount_opt, JOURNAL_DATA);
1640 else if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_ORDERED) 1676 else if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_ORDERED)
1641 sbi->s_mount_opt |= EXT3_MOUNT_ORDERED_DATA; 1677 set_opt(sbi->s_mount_opt, ORDERED_DATA);
1642 else if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_WBACK) 1678 else if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_WBACK)
1643 sbi->s_mount_opt |= EXT3_MOUNT_WRITEBACK_DATA; 1679 set_opt(sbi->s_mount_opt, WRITEBACK_DATA);
1644 1680
1645 if (le16_to_cpu(sbi->s_es->s_errors) == EXT3_ERRORS_PANIC) 1681 if (le16_to_cpu(sbi->s_es->s_errors) == EXT3_ERRORS_PANIC)
1646 set_opt(sbi->s_mount_opt, ERRORS_PANIC); 1682 set_opt(sbi->s_mount_opt, ERRORS_PANIC);
@@ -1659,15 +1695,15 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1659 goto failed_mount; 1695 goto failed_mount;
1660 1696
1661 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | 1697 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
1662 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); 1698 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
1663 1699
1664 if (le32_to_cpu(es->s_rev_level) == EXT3_GOOD_OLD_REV && 1700 if (le32_to_cpu(es->s_rev_level) == EXT3_GOOD_OLD_REV &&
1665 (EXT3_HAS_COMPAT_FEATURE(sb, ~0U) || 1701 (EXT3_HAS_COMPAT_FEATURE(sb, ~0U) ||
1666 EXT3_HAS_RO_COMPAT_FEATURE(sb, ~0U) || 1702 EXT3_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
1667 EXT3_HAS_INCOMPAT_FEATURE(sb, ~0U))) 1703 EXT3_HAS_INCOMPAT_FEATURE(sb, ~0U)))
1668 printk(KERN_WARNING 1704 ext3_msg(sb, KERN_WARNING,
1669 "EXT3-fs warning: feature flags set on rev 0 fs, " 1705 "warning: feature flags set on rev 0 fs, "
1670 "running e2fsck is recommended\n"); 1706 "running e2fsck is recommended");
1671 /* 1707 /*
1672 * Check feature flags regardless of the revision level, since we 1708 * Check feature flags regardless of the revision level, since we
1673 * previously didn't change the revision level when setting the flags, 1709 * previously didn't change the revision level when setting the flags,
@@ -1675,25 +1711,25 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1675 */ 1711 */
1676 features = EXT3_HAS_INCOMPAT_FEATURE(sb, ~EXT3_FEATURE_INCOMPAT_SUPP); 1712 features = EXT3_HAS_INCOMPAT_FEATURE(sb, ~EXT3_FEATURE_INCOMPAT_SUPP);
1677 if (features) { 1713 if (features) {
1678 printk(KERN_ERR "EXT3-fs: %s: couldn't mount because of " 1714 ext3_msg(sb, KERN_ERR,
1679 "unsupported optional features (%x).\n", 1715 "error: couldn't mount because of unsupported "
1680 sb->s_id, le32_to_cpu(features)); 1716 "optional features (%x)", le32_to_cpu(features));
1681 goto failed_mount; 1717 goto failed_mount;
1682 } 1718 }
1683 features = EXT3_HAS_RO_COMPAT_FEATURE(sb, ~EXT3_FEATURE_RO_COMPAT_SUPP); 1719 features = EXT3_HAS_RO_COMPAT_FEATURE(sb, ~EXT3_FEATURE_RO_COMPAT_SUPP);
1684 if (!(sb->s_flags & MS_RDONLY) && features) { 1720 if (!(sb->s_flags & MS_RDONLY) && features) {
1685 printk(KERN_ERR "EXT3-fs: %s: couldn't mount RDWR because of " 1721 ext3_msg(sb, KERN_ERR,
1686 "unsupported optional features (%x).\n", 1722 "error: couldn't mount RDWR because of unsupported "
1687 sb->s_id, le32_to_cpu(features)); 1723 "optional features (%x)", le32_to_cpu(features));
1688 goto failed_mount; 1724 goto failed_mount;
1689 } 1725 }
1690 blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size); 1726 blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size);
1691 1727
1692 if (blocksize < EXT3_MIN_BLOCK_SIZE || 1728 if (blocksize < EXT3_MIN_BLOCK_SIZE ||
1693 blocksize > EXT3_MAX_BLOCK_SIZE) { 1729 blocksize > EXT3_MAX_BLOCK_SIZE) {
1694 printk(KERN_ERR 1730 ext3_msg(sb, KERN_ERR,
1695 "EXT3-fs: Unsupported filesystem blocksize %d on %s.\n", 1731 "error: couldn't mount because of unsupported "
1696 blocksize, sb->s_id); 1732 "filesystem blocksize %d", blocksize);
1697 goto failed_mount; 1733 goto failed_mount;
1698 } 1734 }
1699 1735
@@ -1704,30 +1740,31 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1704 * than the hardware sectorsize for the machine. 1740 * than the hardware sectorsize for the machine.
1705 */ 1741 */
1706 if (blocksize < hblock) { 1742 if (blocksize < hblock) {
1707 printk(KERN_ERR "EXT3-fs: blocksize %d too small for " 1743 ext3_msg(sb, KERN_ERR,
1708 "device blocksize %d.\n", blocksize, hblock); 1744 "error: fsblocksize %d too small for "
1745 "hardware sectorsize %d", blocksize, hblock);
1709 goto failed_mount; 1746 goto failed_mount;
1710 } 1747 }
1711 1748
1712 brelse (bh); 1749 brelse (bh);
1713 if (!sb_set_blocksize(sb, blocksize)) { 1750 if (!sb_set_blocksize(sb, blocksize)) {
1714 printk(KERN_ERR "EXT3-fs: bad blocksize %d.\n", 1751 ext3_msg(sb, KERN_ERR,
1715 blocksize); 1752 "error: bad blocksize %d", blocksize);
1716 goto out_fail; 1753 goto out_fail;
1717 } 1754 }
1718 logic_sb_block = (sb_block * EXT3_MIN_BLOCK_SIZE) / blocksize; 1755 logic_sb_block = (sb_block * EXT3_MIN_BLOCK_SIZE) / blocksize;
1719 offset = (sb_block * EXT3_MIN_BLOCK_SIZE) % blocksize; 1756 offset = (sb_block * EXT3_MIN_BLOCK_SIZE) % blocksize;
1720 bh = sb_bread(sb, logic_sb_block); 1757 bh = sb_bread(sb, logic_sb_block);
1721 if (!bh) { 1758 if (!bh) {
1722 printk(KERN_ERR 1759 ext3_msg(sb, KERN_ERR,
1723 "EXT3-fs: Can't read superblock on 2nd try.\n"); 1760 "error: can't read superblock on 2nd try");
1724 goto failed_mount; 1761 goto failed_mount;
1725 } 1762 }
1726 es = (struct ext3_super_block *)(((char *)bh->b_data) + offset); 1763 es = (struct ext3_super_block *)(((char *)bh->b_data) + offset);
1727 sbi->s_es = es; 1764 sbi->s_es = es;
1728 if (es->s_magic != cpu_to_le16(EXT3_SUPER_MAGIC)) { 1765 if (es->s_magic != cpu_to_le16(EXT3_SUPER_MAGIC)) {
1729 printk (KERN_ERR 1766 ext3_msg(sb, KERN_ERR,
1730 "EXT3-fs: Magic mismatch, very weird !\n"); 1767 "error: magic mismatch");
1731 goto failed_mount; 1768 goto failed_mount;
1732 } 1769 }
1733 } 1770 }
@@ -1743,8 +1780,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1743 if ((sbi->s_inode_size < EXT3_GOOD_OLD_INODE_SIZE) || 1780 if ((sbi->s_inode_size < EXT3_GOOD_OLD_INODE_SIZE) ||
1744 (!is_power_of_2(sbi->s_inode_size)) || 1781 (!is_power_of_2(sbi->s_inode_size)) ||
1745 (sbi->s_inode_size > blocksize)) { 1782 (sbi->s_inode_size > blocksize)) {
1746 printk (KERN_ERR 1783 ext3_msg(sb, KERN_ERR,
1747 "EXT3-fs: unsupported inode size: %d\n", 1784 "error: unsupported inode size: %d",
1748 sbi->s_inode_size); 1785 sbi->s_inode_size);
1749 goto failed_mount; 1786 goto failed_mount;
1750 } 1787 }
@@ -1752,8 +1789,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1752 sbi->s_frag_size = EXT3_MIN_FRAG_SIZE << 1789 sbi->s_frag_size = EXT3_MIN_FRAG_SIZE <<
1753 le32_to_cpu(es->s_log_frag_size); 1790 le32_to_cpu(es->s_log_frag_size);
1754 if (blocksize != sbi->s_frag_size) { 1791 if (blocksize != sbi->s_frag_size) {
1755 printk(KERN_ERR 1792 ext3_msg(sb, KERN_ERR,
1756 "EXT3-fs: fragsize %lu != blocksize %u (unsupported)\n", 1793 "error: fragsize %lu != blocksize %u (unsupported)",
1757 sbi->s_frag_size, blocksize); 1794 sbi->s_frag_size, blocksize);
1758 goto failed_mount; 1795 goto failed_mount;
1759 } 1796 }
@@ -1789,31 +1826,31 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1789 } 1826 }
1790 1827
1791 if (sbi->s_blocks_per_group > blocksize * 8) { 1828 if (sbi->s_blocks_per_group > blocksize * 8) {
1792 printk (KERN_ERR 1829 ext3_msg(sb, KERN_ERR,
1793 "EXT3-fs: #blocks per group too big: %lu\n", 1830 "#blocks per group too big: %lu",
1794 sbi->s_blocks_per_group); 1831 sbi->s_blocks_per_group);
1795 goto failed_mount; 1832 goto failed_mount;
1796 } 1833 }
1797 if (sbi->s_frags_per_group > blocksize * 8) { 1834 if (sbi->s_frags_per_group > blocksize * 8) {
1798 printk (KERN_ERR 1835 ext3_msg(sb, KERN_ERR,
1799 "EXT3-fs: #fragments per group too big: %lu\n", 1836 "error: #fragments per group too big: %lu",
1800 sbi->s_frags_per_group); 1837 sbi->s_frags_per_group);
1801 goto failed_mount; 1838 goto failed_mount;
1802 } 1839 }
1803 if (sbi->s_inodes_per_group > blocksize * 8) { 1840 if (sbi->s_inodes_per_group > blocksize * 8) {
1804 printk (KERN_ERR 1841 ext3_msg(sb, KERN_ERR,
1805 "EXT3-fs: #inodes per group too big: %lu\n", 1842 "error: #inodes per group too big: %lu",
1806 sbi->s_inodes_per_group); 1843 sbi->s_inodes_per_group);
1807 goto failed_mount; 1844 goto failed_mount;
1808 } 1845 }
1809 1846
1810 if (le32_to_cpu(es->s_blocks_count) > 1847 if (le32_to_cpu(es->s_blocks_count) >
1811 (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) { 1848 (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) {
1812 printk(KERN_ERR "EXT3-fs: filesystem on %s:" 1849 ext3_msg(sb, KERN_ERR,
1813 " too large to mount safely\n", sb->s_id); 1850 "error: filesystem is too large to mount safely");
1814 if (sizeof(sector_t) < 8) 1851 if (sizeof(sector_t) < 8)
1815 printk(KERN_WARNING "EXT3-fs: CONFIG_LBDAF not " 1852 ext3_msg(sb, KERN_ERR,
1816 "enabled\n"); 1853 "error: CONFIG_LBDAF not enabled");
1817 goto failed_mount; 1854 goto failed_mount;
1818 } 1855 }
1819 1856
@@ -1827,7 +1864,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1827 sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *), 1864 sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *),
1828 GFP_KERNEL); 1865 GFP_KERNEL);
1829 if (sbi->s_group_desc == NULL) { 1866 if (sbi->s_group_desc == NULL) {
1830 printk (KERN_ERR "EXT3-fs: not enough memory\n"); 1867 ext3_msg(sb, KERN_ERR,
1868 "error: not enough memory");
1831 goto failed_mount; 1869 goto failed_mount;
1832 } 1870 }
1833 1871
@@ -1837,14 +1875,15 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1837 block = descriptor_loc(sb, logic_sb_block, i); 1875 block = descriptor_loc(sb, logic_sb_block, i);
1838 sbi->s_group_desc[i] = sb_bread(sb, block); 1876 sbi->s_group_desc[i] = sb_bread(sb, block);
1839 if (!sbi->s_group_desc[i]) { 1877 if (!sbi->s_group_desc[i]) {
1840 printk (KERN_ERR "EXT3-fs: " 1878 ext3_msg(sb, KERN_ERR,
1841 "can't read group descriptor %d\n", i); 1879 "error: can't read group descriptor %d", i);
1842 db_count = i; 1880 db_count = i;
1843 goto failed_mount2; 1881 goto failed_mount2;
1844 } 1882 }
1845 } 1883 }
1846 if (!ext3_check_descriptors (sb)) { 1884 if (!ext3_check_descriptors (sb)) {
1847 printk(KERN_ERR "EXT3-fs: group descriptors corrupted!\n"); 1885 ext3_msg(sb, KERN_ERR,
1886 "error: group descriptors corrupted");
1848 goto failed_mount2; 1887 goto failed_mount2;
1849 } 1888 }
1850 sbi->s_gdb_count = db_count; 1889 sbi->s_gdb_count = db_count;
@@ -1862,7 +1901,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1862 ext3_count_dirs(sb)); 1901 ext3_count_dirs(sb));
1863 } 1902 }
1864 if (err) { 1903 if (err) {
1865 printk(KERN_ERR "EXT3-fs: insufficient memory\n"); 1904 ext3_msg(sb, KERN_ERR, "error: insufficient memory");
1866 goto failed_mount3; 1905 goto failed_mount3;
1867 } 1906 }
1868 1907
@@ -1890,6 +1929,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1890 sb->dq_op = &ext3_quota_operations; 1929 sb->dq_op = &ext3_quota_operations;
1891#endif 1930#endif
1892 INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */ 1931 INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
1932 mutex_init(&sbi->s_orphan_lock);
1933 mutex_init(&sbi->s_resize_lock);
1893 1934
1894 sb->s_root = NULL; 1935 sb->s_root = NULL;
1895 1936
@@ -1910,9 +1951,9 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1910 goto failed_mount3; 1951 goto failed_mount3;
1911 } else { 1952 } else {
1912 if (!silent) 1953 if (!silent)
1913 printk (KERN_ERR 1954 ext3_msg(sb, KERN_ERR,
1914 "ext3: No journal on filesystem on %s\n", 1955 "error: no journal found. "
1915 sb->s_id); 1956 "mounting ext3 over ext2?");
1916 goto failed_mount3; 1957 goto failed_mount3;
1917 } 1958 }
1918 1959
@@ -1934,8 +1975,9 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1934 case EXT3_MOUNT_WRITEBACK_DATA: 1975 case EXT3_MOUNT_WRITEBACK_DATA:
1935 if (!journal_check_available_features 1976 if (!journal_check_available_features
1936 (sbi->s_journal, 0, 0, JFS_FEATURE_INCOMPAT_REVOKE)) { 1977 (sbi->s_journal, 0, 0, JFS_FEATURE_INCOMPAT_REVOKE)) {
1937 printk(KERN_ERR "EXT3-fs: Journal does not support " 1978 ext3_msg(sb, KERN_ERR,
1938 "requested data journaling mode\n"); 1979 "error: journal does not support "
1980 "requested data journaling mode");
1939 goto failed_mount4; 1981 goto failed_mount4;
1940 } 1982 }
1941 default: 1983 default:
@@ -1944,8 +1986,9 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1944 1986
1945 if (test_opt(sb, NOBH)) { 1987 if (test_opt(sb, NOBH)) {
1946 if (!(test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA)) { 1988 if (!(test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA)) {
1947 printk(KERN_WARNING "EXT3-fs: Ignoring nobh option - " 1989 ext3_msg(sb, KERN_WARNING,
1948 "its supported only with writeback mode\n"); 1990 "warning: ignoring nobh option - "
1991 "it is supported only with writeback mode");
1949 clear_opt(sbi->s_mount_opt, NOBH); 1992 clear_opt(sbi->s_mount_opt, NOBH);
1950 } 1993 }
1951 } 1994 }
@@ -1956,39 +1999,32 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1956 1999
1957 root = ext3_iget(sb, EXT3_ROOT_INO); 2000 root = ext3_iget(sb, EXT3_ROOT_INO);
1958 if (IS_ERR(root)) { 2001 if (IS_ERR(root)) {
1959 printk(KERN_ERR "EXT3-fs: get root inode failed\n"); 2002 ext3_msg(sb, KERN_ERR, "error: get root inode failed");
1960 ret = PTR_ERR(root); 2003 ret = PTR_ERR(root);
1961 goto failed_mount4; 2004 goto failed_mount4;
1962 } 2005 }
1963 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { 2006 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
1964 iput(root); 2007 iput(root);
1965 printk(KERN_ERR "EXT3-fs: corrupt root inode, run e2fsck\n"); 2008 ext3_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck");
1966 goto failed_mount4; 2009 goto failed_mount4;
1967 } 2010 }
1968 sb->s_root = d_alloc_root(root); 2011 sb->s_root = d_alloc_root(root);
1969 if (!sb->s_root) { 2012 if (!sb->s_root) {
1970 printk(KERN_ERR "EXT3-fs: get root dentry failed\n"); 2013 ext3_msg(sb, KERN_ERR, "error: get root dentry failed");
1971 iput(root); 2014 iput(root);
1972 ret = -ENOMEM; 2015 ret = -ENOMEM;
1973 goto failed_mount4; 2016 goto failed_mount4;
1974 } 2017 }
1975 2018
1976 ext3_setup_super (sb, es, sb->s_flags & MS_RDONLY); 2019 ext3_setup_super (sb, es, sb->s_flags & MS_RDONLY);
1977 /* 2020
1978 * akpm: core read_super() calls in here with the superblock locked.
1979 * That deadlocks, because orphan cleanup needs to lock the superblock
1980 * in numerous places. Here we just pop the lock - it's relatively
1981 * harmless, because we are now ready to accept write_super() requests,
1982 * and aviro says that's the only reason for hanging onto the
1983 * superblock lock.
1984 */
1985 EXT3_SB(sb)->s_mount_state |= EXT3_ORPHAN_FS; 2021 EXT3_SB(sb)->s_mount_state |= EXT3_ORPHAN_FS;
1986 ext3_orphan_cleanup(sb, es); 2022 ext3_orphan_cleanup(sb, es);
1987 EXT3_SB(sb)->s_mount_state &= ~EXT3_ORPHAN_FS; 2023 EXT3_SB(sb)->s_mount_state &= ~EXT3_ORPHAN_FS;
1988 if (needs_recovery) 2024 if (needs_recovery)
1989 printk (KERN_INFO "EXT3-fs: recovery complete.\n"); 2025 ext3_msg(sb, KERN_INFO, "recovery complete");
1990 ext3_mark_recovery_complete(sb, es); 2026 ext3_mark_recovery_complete(sb, es);
1991 printk (KERN_INFO "EXT3-fs: mounted filesystem with %s data mode.\n", 2027 ext3_msg(sb, KERN_INFO, "mounted filesystem with %s data mode",
1992 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA ? "journal": 2028 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA ? "journal":
1993 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered": 2029 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered":
1994 "writeback"); 2030 "writeback");
@@ -1998,7 +2034,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1998 2034
1999cantfind_ext3: 2035cantfind_ext3:
2000 if (!silent) 2036 if (!silent)
2001 printk(KERN_ERR "VFS: Can't find ext3 filesystem on dev %s.\n", 2037 ext3_msg(sb, KERN_INFO,
2038 "error: can't find ext3 filesystem on dev %s.",
2002 sb->s_id); 2039 sb->s_id);
2003 goto failed_mount; 2040 goto failed_mount;
2004 2041
@@ -2066,27 +2103,27 @@ static journal_t *ext3_get_journal(struct super_block *sb,
2066 2103
2067 journal_inode = ext3_iget(sb, journal_inum); 2104 journal_inode = ext3_iget(sb, journal_inum);
2068 if (IS_ERR(journal_inode)) { 2105 if (IS_ERR(journal_inode)) {
2069 printk(KERN_ERR "EXT3-fs: no journal found.\n"); 2106 ext3_msg(sb, KERN_ERR, "error: no journal found");
2070 return NULL; 2107 return NULL;
2071 } 2108 }
2072 if (!journal_inode->i_nlink) { 2109 if (!journal_inode->i_nlink) {
2073 make_bad_inode(journal_inode); 2110 make_bad_inode(journal_inode);
2074 iput(journal_inode); 2111 iput(journal_inode);
2075 printk(KERN_ERR "EXT3-fs: journal inode is deleted.\n"); 2112 ext3_msg(sb, KERN_ERR, "error: journal inode is deleted");
2076 return NULL; 2113 return NULL;
2077 } 2114 }
2078 2115
2079 jbd_debug(2, "Journal inode found at %p: %Ld bytes\n", 2116 jbd_debug(2, "Journal inode found at %p: %Ld bytes\n",
2080 journal_inode, journal_inode->i_size); 2117 journal_inode, journal_inode->i_size);
2081 if (!S_ISREG(journal_inode->i_mode)) { 2118 if (!S_ISREG(journal_inode->i_mode)) {
2082 printk(KERN_ERR "EXT3-fs: invalid journal inode.\n"); 2119 ext3_msg(sb, KERN_ERR, "error: invalid journal inode");
2083 iput(journal_inode); 2120 iput(journal_inode);
2084 return NULL; 2121 return NULL;
2085 } 2122 }
2086 2123
2087 journal = journal_init_inode(journal_inode); 2124 journal = journal_init_inode(journal_inode);
2088 if (!journal) { 2125 if (!journal) {
2089 printk(KERN_ERR "EXT3-fs: Could not load journal inode\n"); 2126 ext3_msg(sb, KERN_ERR, "error: could not load journal inode");
2090 iput(journal_inode); 2127 iput(journal_inode);
2091 return NULL; 2128 return NULL;
2092 } 2129 }
@@ -2108,13 +2145,13 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb,
2108 struct ext3_super_block * es; 2145 struct ext3_super_block * es;
2109 struct block_device *bdev; 2146 struct block_device *bdev;
2110 2147
2111 bdev = ext3_blkdev_get(j_dev); 2148 bdev = ext3_blkdev_get(j_dev, sb);
2112 if (bdev == NULL) 2149 if (bdev == NULL)
2113 return NULL; 2150 return NULL;
2114 2151
2115 if (bd_claim(bdev, sb)) { 2152 if (bd_claim(bdev, sb)) {
2116 printk(KERN_ERR 2153 ext3_msg(sb, KERN_ERR,
2117 "EXT3: failed to claim external journal device.\n"); 2154 "error: failed to claim external journal device");
2118 blkdev_put(bdev, FMODE_READ|FMODE_WRITE); 2155 blkdev_put(bdev, FMODE_READ|FMODE_WRITE);
2119 return NULL; 2156 return NULL;
2120 } 2157 }
@@ -2122,8 +2159,8 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb,
2122 blocksize = sb->s_blocksize; 2159 blocksize = sb->s_blocksize;
2123 hblock = bdev_logical_block_size(bdev); 2160 hblock = bdev_logical_block_size(bdev);
2124 if (blocksize < hblock) { 2161 if (blocksize < hblock) {
2125 printk(KERN_ERR 2162 ext3_msg(sb, KERN_ERR,
2126 "EXT3-fs: blocksize too small for journal device.\n"); 2163 "error: blocksize too small for journal device");
2127 goto out_bdev; 2164 goto out_bdev;
2128 } 2165 }
2129 2166
@@ -2131,8 +2168,8 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb,
2131 offset = EXT3_MIN_BLOCK_SIZE % blocksize; 2168 offset = EXT3_MIN_BLOCK_SIZE % blocksize;
2132 set_blocksize(bdev, blocksize); 2169 set_blocksize(bdev, blocksize);
2133 if (!(bh = __bread(bdev, sb_block, blocksize))) { 2170 if (!(bh = __bread(bdev, sb_block, blocksize))) {
2134 printk(KERN_ERR "EXT3-fs: couldn't read superblock of " 2171 ext3_msg(sb, KERN_ERR, "error: couldn't read superblock of "
2135 "external journal\n"); 2172 "external journal");
2136 goto out_bdev; 2173 goto out_bdev;
2137 } 2174 }
2138 2175
@@ -2140,14 +2177,14 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb,
2140 if ((le16_to_cpu(es->s_magic) != EXT3_SUPER_MAGIC) || 2177 if ((le16_to_cpu(es->s_magic) != EXT3_SUPER_MAGIC) ||
2141 !(le32_to_cpu(es->s_feature_incompat) & 2178 !(le32_to_cpu(es->s_feature_incompat) &
2142 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) { 2179 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) {
2143 printk(KERN_ERR "EXT3-fs: external journal has " 2180 ext3_msg(sb, KERN_ERR, "error: external journal has "
2144 "bad superblock\n"); 2181 "bad superblock");
2145 brelse(bh); 2182 brelse(bh);
2146 goto out_bdev; 2183 goto out_bdev;
2147 } 2184 }
2148 2185
2149 if (memcmp(EXT3_SB(sb)->s_es->s_journal_uuid, es->s_uuid, 16)) { 2186 if (memcmp(EXT3_SB(sb)->s_es->s_journal_uuid, es->s_uuid, 16)) {
2150 printk(KERN_ERR "EXT3-fs: journal UUID does not match\n"); 2187 ext3_msg(sb, KERN_ERR, "error: journal UUID does not match");
2151 brelse(bh); 2188 brelse(bh);
2152 goto out_bdev; 2189 goto out_bdev;
2153 } 2190 }
@@ -2159,19 +2196,21 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb,
2159 journal = journal_init_dev(bdev, sb->s_bdev, 2196 journal = journal_init_dev(bdev, sb->s_bdev,
2160 start, len, blocksize); 2197 start, len, blocksize);
2161 if (!journal) { 2198 if (!journal) {
2162 printk(KERN_ERR "EXT3-fs: failed to create device journal\n"); 2199 ext3_msg(sb, KERN_ERR,
2200 "error: failed to create device journal");
2163 goto out_bdev; 2201 goto out_bdev;
2164 } 2202 }
2165 journal->j_private = sb; 2203 journal->j_private = sb;
2166 ll_rw_block(READ, 1, &journal->j_sb_buffer); 2204 ll_rw_block(READ, 1, &journal->j_sb_buffer);
2167 wait_on_buffer(journal->j_sb_buffer); 2205 wait_on_buffer(journal->j_sb_buffer);
2168 if (!buffer_uptodate(journal->j_sb_buffer)) { 2206 if (!buffer_uptodate(journal->j_sb_buffer)) {
2169 printk(KERN_ERR "EXT3-fs: I/O error on journal device\n"); 2207 ext3_msg(sb, KERN_ERR, "I/O error on journal device");
2170 goto out_journal; 2208 goto out_journal;
2171 } 2209 }
2172 if (be32_to_cpu(journal->j_superblock->s_nr_users) != 1) { 2210 if (be32_to_cpu(journal->j_superblock->s_nr_users) != 1) {
2173 printk(KERN_ERR "EXT3-fs: External journal has more than one " 2211 ext3_msg(sb, KERN_ERR,
2174 "user (unsupported) - %d\n", 2212 "error: external journal has more than one "
2213 "user (unsupported) - %d",
2175 be32_to_cpu(journal->j_superblock->s_nr_users)); 2214 be32_to_cpu(journal->j_superblock->s_nr_users));
2176 goto out_journal; 2215 goto out_journal;
2177 } 2216 }
@@ -2197,8 +2236,8 @@ static int ext3_load_journal(struct super_block *sb,
2197 2236
2198 if (journal_devnum && 2237 if (journal_devnum &&
2199 journal_devnum != le32_to_cpu(es->s_journal_dev)) { 2238 journal_devnum != le32_to_cpu(es->s_journal_dev)) {
2200 printk(KERN_INFO "EXT3-fs: external journal device major/minor " 2239 ext3_msg(sb, KERN_INFO, "external journal device major/minor "
2201 "numbers have changed\n"); 2240 "numbers have changed");
2202 journal_dev = new_decode_dev(journal_devnum); 2241 journal_dev = new_decode_dev(journal_devnum);
2203 } else 2242 } else
2204 journal_dev = new_decode_dev(le32_to_cpu(es->s_journal_dev)); 2243 journal_dev = new_decode_dev(le32_to_cpu(es->s_journal_dev));
@@ -2213,21 +2252,21 @@ static int ext3_load_journal(struct super_block *sb,
2213 2252
2214 if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER)) { 2253 if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER)) {
2215 if (sb->s_flags & MS_RDONLY) { 2254 if (sb->s_flags & MS_RDONLY) {
2216 printk(KERN_INFO "EXT3-fs: INFO: recovery " 2255 ext3_msg(sb, KERN_INFO,
2217 "required on readonly filesystem.\n"); 2256 "recovery required on readonly filesystem");
2218 if (really_read_only) { 2257 if (really_read_only) {
2219 printk(KERN_ERR "EXT3-fs: write access " 2258 ext3_msg(sb, KERN_ERR, "error: write access "
2220 "unavailable, cannot proceed.\n"); 2259 "unavailable, cannot proceed");
2221 return -EROFS; 2260 return -EROFS;
2222 } 2261 }
2223 printk (KERN_INFO "EXT3-fs: write access will " 2262 ext3_msg(sb, KERN_INFO,
2224 "be enabled during recovery.\n"); 2263 "write access will be enabled during recovery");
2225 } 2264 }
2226 } 2265 }
2227 2266
2228 if (journal_inum && journal_dev) { 2267 if (journal_inum && journal_dev) {
2229 printk(KERN_ERR "EXT3-fs: filesystem has both journal " 2268 ext3_msg(sb, KERN_ERR, "error: filesystem has both journal "
2230 "and inode journals!\n"); 2269 "and inode journals");
2231 return -EINVAL; 2270 return -EINVAL;
2232 } 2271 }
2233 2272
@@ -2242,7 +2281,7 @@ static int ext3_load_journal(struct super_block *sb,
2242 if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) { 2281 if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) {
2243 err = journal_update_format(journal); 2282 err = journal_update_format(journal);
2244 if (err) { 2283 if (err) {
2245 printk(KERN_ERR "EXT3-fs: error updating journal.\n"); 2284 ext3_msg(sb, KERN_ERR, "error updating journal");
2246 journal_destroy(journal); 2285 journal_destroy(journal);
2247 return err; 2286 return err;
2248 } 2287 }
@@ -2254,7 +2293,7 @@ static int ext3_load_journal(struct super_block *sb,
2254 err = journal_load(journal); 2293 err = journal_load(journal);
2255 2294
2256 if (err) { 2295 if (err) {
2257 printk(KERN_ERR "EXT3-fs: error loading journal.\n"); 2296 ext3_msg(sb, KERN_ERR, "error loading journal");
2258 journal_destroy(journal); 2297 journal_destroy(journal);
2259 return err; 2298 return err;
2260 } 2299 }
@@ -2273,16 +2312,17 @@ static int ext3_load_journal(struct super_block *sb,
2273 return 0; 2312 return 0;
2274} 2313}
2275 2314
2276static int ext3_create_journal(struct super_block * sb, 2315static int ext3_create_journal(struct super_block *sb,
2277 struct ext3_super_block * es, 2316 struct ext3_super_block *es,
2278 unsigned int journal_inum) 2317 unsigned int journal_inum)
2279{ 2318{
2280 journal_t *journal; 2319 journal_t *journal;
2281 int err; 2320 int err;
2282 2321
2283 if (sb->s_flags & MS_RDONLY) { 2322 if (sb->s_flags & MS_RDONLY) {
2284 printk(KERN_ERR "EXT3-fs: readonly filesystem when trying to " 2323 ext3_msg(sb, KERN_ERR,
2285 "create journal.\n"); 2324 "error: readonly filesystem when trying to "
2325 "create journal");
2286 return -EROFS; 2326 return -EROFS;
2287 } 2327 }
2288 2328
@@ -2290,12 +2330,12 @@ static int ext3_create_journal(struct super_block * sb,
2290 if (!journal) 2330 if (!journal)
2291 return -EINVAL; 2331 return -EINVAL;
2292 2332
2293 printk(KERN_INFO "EXT3-fs: creating new journal on inode %u\n", 2333 ext3_msg(sb, KERN_INFO, "creating new journal on inode %u",
2294 journal_inum); 2334 journal_inum);
2295 2335
2296 err = journal_create(journal); 2336 err = journal_create(journal);
2297 if (err) { 2337 if (err) {
2298 printk(KERN_ERR "EXT3-fs: error creating journal.\n"); 2338 ext3_msg(sb, KERN_ERR, "error creating journal");
2299 journal_destroy(journal); 2339 journal_destroy(journal);
2300 return -EIO; 2340 return -EIO;
2301 } 2341 }
@@ -2359,13 +2399,11 @@ static void ext3_mark_recovery_complete(struct super_block * sb,
2359 if (journal_flush(journal) < 0) 2399 if (journal_flush(journal) < 0)
2360 goto out; 2400 goto out;
2361 2401
2362 lock_super(sb);
2363 if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER) && 2402 if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER) &&
2364 sb->s_flags & MS_RDONLY) { 2403 sb->s_flags & MS_RDONLY) {
2365 EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); 2404 EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER);
2366 ext3_commit_super(sb, es, 1); 2405 ext3_commit_super(sb, es, 1);
2367 } 2406 }
2368 unlock_super(sb);
2369 2407
2370out: 2408out:
2371 journal_unlock_updates(journal); 2409 journal_unlock_updates(journal);
@@ -2376,8 +2414,8 @@ out:
2376 * has recorded an error from a previous lifetime, move that error to the 2414 * has recorded an error from a previous lifetime, move that error to the
2377 * main filesystem now. 2415 * main filesystem now.
2378 */ 2416 */
2379static void ext3_clear_journal_err(struct super_block * sb, 2417static void ext3_clear_journal_err(struct super_block *sb,
2380 struct ext3_super_block * es) 2418 struct ext3_super_block *es)
2381{ 2419{
2382 journal_t *journal; 2420 journal_t *journal;
2383 int j_errno; 2421 int j_errno;
@@ -2524,11 +2562,11 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2524 goto restore_opts; 2562 goto restore_opts;
2525 } 2563 }
2526 2564
2527 if (sbi->s_mount_opt & EXT3_MOUNT_ABORT) 2565 if (test_opt(sb, ABORT))
2528 ext3_abort(sb, __func__, "Abort forced by user"); 2566 ext3_abort(sb, __func__, "Abort forced by user");
2529 2567
2530 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | 2568 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2531 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); 2569 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
2532 2570
2533 es = sbi->s_es; 2571 es = sbi->s_es;
2534 2572
@@ -2536,7 +2574,7 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2536 2574
2537 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY) || 2575 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY) ||
2538 n_blocks_count > le32_to_cpu(es->s_blocks_count)) { 2576 n_blocks_count > le32_to_cpu(es->s_blocks_count)) {
2539 if (sbi->s_mount_opt & EXT3_MOUNT_ABORT) { 2577 if (test_opt(sb, ABORT)) {
2540 err = -EROFS; 2578 err = -EROFS;
2541 goto restore_opts; 2579 goto restore_opts;
2542 } 2580 }
@@ -2557,21 +2595,15 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2557 (sbi->s_mount_state & EXT3_VALID_FS)) 2595 (sbi->s_mount_state & EXT3_VALID_FS))
2558 es->s_state = cpu_to_le16(sbi->s_mount_state); 2596 es->s_state = cpu_to_le16(sbi->s_mount_state);
2559 2597
2560 /*
2561 * We have to unlock super so that we can wait for
2562 * transactions.
2563 */
2564 unlock_super(sb);
2565 ext3_mark_recovery_complete(sb, es); 2598 ext3_mark_recovery_complete(sb, es);
2566 lock_super(sb);
2567 } else { 2599 } else {
2568 __le32 ret; 2600 __le32 ret;
2569 if ((ret = EXT3_HAS_RO_COMPAT_FEATURE(sb, 2601 if ((ret = EXT3_HAS_RO_COMPAT_FEATURE(sb,
2570 ~EXT3_FEATURE_RO_COMPAT_SUPP))) { 2602 ~EXT3_FEATURE_RO_COMPAT_SUPP))) {
2571 printk(KERN_WARNING "EXT3-fs: %s: couldn't " 2603 ext3_msg(sb, KERN_WARNING,
2572 "remount RDWR because of unsupported " 2604 "warning: couldn't remount RDWR "
2573 "optional features (%x).\n", 2605 "because of unsupported optional "
2574 sb->s_id, le32_to_cpu(ret)); 2606 "features (%x)", le32_to_cpu(ret));
2575 err = -EROFS; 2607 err = -EROFS;
2576 goto restore_opts; 2608 goto restore_opts;
2577 } 2609 }
@@ -2582,11 +2614,10 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2582 * require a full umount/remount for now. 2614 * require a full umount/remount for now.
2583 */ 2615 */
2584 if (es->s_last_orphan) { 2616 if (es->s_last_orphan) {
2585 printk(KERN_WARNING "EXT3-fs: %s: couldn't " 2617 ext3_msg(sb, KERN_WARNING, "warning: couldn't "
2586 "remount RDWR because of unprocessed " 2618 "remount RDWR because of unprocessed "
2587 "orphan inode list. Please " 2619 "orphan inode list. Please "
2588 "umount/remount instead.\n", 2620 "umount/remount instead.");
2589 sb->s_id);
2590 err = -EINVAL; 2621 err = -EINVAL;
2591 goto restore_opts; 2622 goto restore_opts;
2592 } 2623 }
@@ -2686,13 +2717,11 @@ static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf)
2686 buf->f_bsize = sb->s_blocksize; 2717 buf->f_bsize = sb->s_blocksize;
2687 buf->f_blocks = le32_to_cpu(es->s_blocks_count) - sbi->s_overhead_last; 2718 buf->f_blocks = le32_to_cpu(es->s_blocks_count) - sbi->s_overhead_last;
2688 buf->f_bfree = percpu_counter_sum_positive(&sbi->s_freeblocks_counter); 2719 buf->f_bfree = percpu_counter_sum_positive(&sbi->s_freeblocks_counter);
2689 es->s_free_blocks_count = cpu_to_le32(buf->f_bfree);
2690 buf->f_bavail = buf->f_bfree - le32_to_cpu(es->s_r_blocks_count); 2720 buf->f_bavail = buf->f_bfree - le32_to_cpu(es->s_r_blocks_count);
2691 if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count)) 2721 if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count))
2692 buf->f_bavail = 0; 2722 buf->f_bavail = 0;
2693 buf->f_files = le32_to_cpu(es->s_inodes_count); 2723 buf->f_files = le32_to_cpu(es->s_inodes_count);
2694 buf->f_ffree = percpu_counter_sum_positive(&sbi->s_freeinodes_counter); 2724 buf->f_ffree = percpu_counter_sum_positive(&sbi->s_freeinodes_counter);
2695 es->s_free_inodes_count = cpu_to_le32(buf->f_ffree);
2696 buf->f_namelen = EXT3_NAME_LEN; 2725 buf->f_namelen = EXT3_NAME_LEN;
2697 fsid = le64_to_cpup((void *)es->s_uuid) ^ 2726 fsid = le64_to_cpup((void *)es->s_uuid) ^
2698 le64_to_cpup((void *)es->s_uuid + sizeof(u64)); 2727 le64_to_cpup((void *)es->s_uuid + sizeof(u64));
@@ -2706,7 +2735,7 @@ static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf)
2706 * Process 1 Process 2 2735 * Process 1 Process 2
2707 * ext3_create() quota_sync() 2736 * ext3_create() quota_sync()
2708 * journal_start() write_dquot() 2737 * journal_start() write_dquot()
2709 * vfs_dq_init() down(dqio_mutex) 2738 * dquot_initialize() down(dqio_mutex)
2710 * down(dqio_mutex) journal_start() 2739 * down(dqio_mutex) journal_start()
2711 * 2740 *
2712 */ 2741 */
@@ -2837,9 +2866,9 @@ static int ext3_quota_on(struct super_block *sb, int type, int format_id,
2837 if (EXT3_SB(sb)->s_qf_names[type]) { 2866 if (EXT3_SB(sb)->s_qf_names[type]) {
2838 /* Quotafile not of fs root? */ 2867 /* Quotafile not of fs root? */
2839 if (path.dentry->d_parent != sb->s_root) 2868 if (path.dentry->d_parent != sb->s_root)
2840 printk(KERN_WARNING 2869 ext3_msg(sb, KERN_WARNING,
2841 "EXT3-fs: Quota file not on filesystem root. " 2870 "warning: Quota file not on filesystem root. "
2842 "Journaled quota will not work.\n"); 2871 "Journaled quota will not work.");
2843 } 2872 }
2844 2873
2845 /* 2874 /*
@@ -2914,65 +2943,65 @@ static ssize_t ext3_quota_write(struct super_block *sb, int type,
2914 sector_t blk = off >> EXT3_BLOCK_SIZE_BITS(sb); 2943 sector_t blk = off >> EXT3_BLOCK_SIZE_BITS(sb);
2915 int err = 0; 2944 int err = 0;
2916 int offset = off & (sb->s_blocksize - 1); 2945 int offset = off & (sb->s_blocksize - 1);
2917 int tocopy;
2918 int journal_quota = EXT3_SB(sb)->s_qf_names[type] != NULL; 2946 int journal_quota = EXT3_SB(sb)->s_qf_names[type] != NULL;
2919 size_t towrite = len;
2920 struct buffer_head *bh; 2947 struct buffer_head *bh;
2921 handle_t *handle = journal_current_handle(); 2948 handle_t *handle = journal_current_handle();
2922 2949
2923 if (!handle) { 2950 if (!handle) {
2924 printk(KERN_WARNING "EXT3-fs: Quota write (off=%Lu, len=%Lu)" 2951 ext3_msg(sb, KERN_WARNING,
2925 " cancelled because transaction is not started.\n", 2952 "warning: quota write (off=%llu, len=%llu)"
2953 " cancelled because transaction is not started.",
2954 (unsigned long long)off, (unsigned long long)len);
2955 return -EIO;
2956 }
2957
2958 /*
2959 * Since we account only one data block in transaction credits,
2960 * then it is impossible to cross a block boundary.
2961 */
2962 if (sb->s_blocksize - offset < len) {
2963 ext3_msg(sb, KERN_WARNING, "Quota write (off=%llu, len=%llu)"
2964 " cancelled because not block aligned",
2926 (unsigned long long)off, (unsigned long long)len); 2965 (unsigned long long)off, (unsigned long long)len);
2927 return -EIO; 2966 return -EIO;
2928 } 2967 }
2929 mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA); 2968 mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA);
2930 while (towrite > 0) { 2969 bh = ext3_bread(handle, inode, blk, 1, &err);
2931 tocopy = sb->s_blocksize - offset < towrite ? 2970 if (!bh)
2932 sb->s_blocksize - offset : towrite; 2971 goto out;
2933 bh = ext3_bread(handle, inode, blk, 1, &err); 2972 if (journal_quota) {
2934 if (!bh) 2973 err = ext3_journal_get_write_access(handle, bh);
2974 if (err) {
2975 brelse(bh);
2935 goto out; 2976 goto out;
2936 if (journal_quota) {
2937 err = ext3_journal_get_write_access(handle, bh);
2938 if (err) {
2939 brelse(bh);
2940 goto out;
2941 }
2942 }
2943 lock_buffer(bh);
2944 memcpy(bh->b_data+offset, data, tocopy);
2945 flush_dcache_page(bh->b_page);
2946 unlock_buffer(bh);
2947 if (journal_quota)
2948 err = ext3_journal_dirty_metadata(handle, bh);
2949 else {
2950 /* Always do at least ordered writes for quotas */
2951 err = ext3_journal_dirty_data(handle, bh);
2952 mark_buffer_dirty(bh);
2953 } 2977 }
2954 brelse(bh);
2955 if (err)
2956 goto out;
2957 offset = 0;
2958 towrite -= tocopy;
2959 data += tocopy;
2960 blk++;
2961 } 2978 }
2979 lock_buffer(bh);
2980 memcpy(bh->b_data+offset, data, len);
2981 flush_dcache_page(bh->b_page);
2982 unlock_buffer(bh);
2983 if (journal_quota)
2984 err = ext3_journal_dirty_metadata(handle, bh);
2985 else {
2986 /* Always do at least ordered writes for quotas */
2987 err = ext3_journal_dirty_data(handle, bh);
2988 mark_buffer_dirty(bh);
2989 }
2990 brelse(bh);
2962out: 2991out:
2963 if (len == towrite) { 2992 if (err) {
2964 mutex_unlock(&inode->i_mutex); 2993 mutex_unlock(&inode->i_mutex);
2965 return err; 2994 return err;
2966 } 2995 }
2967 if (inode->i_size < off+len-towrite) { 2996 if (inode->i_size < off + len) {
2968 i_size_write(inode, off+len-towrite); 2997 i_size_write(inode, off + len);
2969 EXT3_I(inode)->i_disksize = inode->i_size; 2998 EXT3_I(inode)->i_disksize = inode->i_size;
2970 } 2999 }
2971 inode->i_version++; 3000 inode->i_version++;
2972 inode->i_mtime = inode->i_ctime = CURRENT_TIME; 3001 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
2973 ext3_mark_inode_dirty(handle, inode); 3002 ext3_mark_inode_dirty(handle, inode);
2974 mutex_unlock(&inode->i_mutex); 3003 mutex_unlock(&inode->i_mutex);
2975 return len - towrite; 3004 return len;
2976} 3005}
2977 3006
2978#endif 3007#endif
diff --git a/fs/ext3/symlink.c b/fs/ext3/symlink.c
index ff7b4ccd8983..7c4898207776 100644
--- a/fs/ext3/symlink.c
+++ b/fs/ext3/symlink.c
@@ -34,6 +34,7 @@ const struct inode_operations ext3_symlink_inode_operations = {
34 .readlink = generic_readlink, 34 .readlink = generic_readlink,
35 .follow_link = page_follow_link_light, 35 .follow_link = page_follow_link_light,
36 .put_link = page_put_link, 36 .put_link = page_put_link,
37 .setattr = ext3_setattr,
37#ifdef CONFIG_EXT3_FS_XATTR 38#ifdef CONFIG_EXT3_FS_XATTR
38 .setxattr = generic_setxattr, 39 .setxattr = generic_setxattr,
39 .getxattr = generic_getxattr, 40 .getxattr = generic_getxattr,
@@ -45,6 +46,7 @@ const struct inode_operations ext3_symlink_inode_operations = {
45const struct inode_operations ext3_fast_symlink_inode_operations = { 46const struct inode_operations ext3_fast_symlink_inode_operations = {
46 .readlink = generic_readlink, 47 .readlink = generic_readlink,
47 .follow_link = ext3_follow_link, 48 .follow_link = ext3_follow_link,
49 .setattr = ext3_setattr,
48#ifdef CONFIG_EXT3_FS_XATTR 50#ifdef CONFIG_EXT3_FS_XATTR
49 .setxattr = generic_setxattr, 51 .setxattr = generic_setxattr,
50 .getxattr = generic_getxattr, 52 .getxattr = generic_getxattr,
diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
index 545e37c4b91e..534a94c3a933 100644
--- a/fs/ext3/xattr.c
+++ b/fs/ext3/xattr.c
@@ -99,7 +99,7 @@ static struct buffer_head *ext3_xattr_cache_find(struct inode *,
99 struct mb_cache_entry **); 99 struct mb_cache_entry **);
100static void ext3_xattr_rehash(struct ext3_xattr_header *, 100static void ext3_xattr_rehash(struct ext3_xattr_header *,
101 struct ext3_xattr_entry *); 101 struct ext3_xattr_entry *);
102static int ext3_xattr_list(struct inode *inode, char *buffer, 102static int ext3_xattr_list(struct dentry *dentry, char *buffer,
103 size_t buffer_size); 103 size_t buffer_size);
104 104
105static struct mb_cache *ext3_xattr_cache; 105static struct mb_cache *ext3_xattr_cache;
@@ -147,7 +147,7 @@ ext3_xattr_handler(int name_index)
147ssize_t 147ssize_t
148ext3_listxattr(struct dentry *dentry, char *buffer, size_t size) 148ext3_listxattr(struct dentry *dentry, char *buffer, size_t size)
149{ 149{
150 return ext3_xattr_list(dentry->d_inode, buffer, size); 150 return ext3_xattr_list(dentry, buffer, size);
151} 151}
152 152
153static int 153static int
@@ -274,7 +274,7 @@ ext3_xattr_ibody_get(struct inode *inode, int name_index, const char *name,
274 void *end; 274 void *end;
275 int error; 275 int error;
276 276
277 if (!(EXT3_I(inode)->i_state & EXT3_STATE_XATTR)) 277 if (!ext3_test_inode_state(inode, EXT3_STATE_XATTR))
278 return -ENODATA; 278 return -ENODATA;
279 error = ext3_get_inode_loc(inode, &iloc); 279 error = ext3_get_inode_loc(inode, &iloc);
280 if (error) 280 if (error)
@@ -332,7 +332,7 @@ ext3_xattr_get(struct inode *inode, int name_index, const char *name,
332} 332}
333 333
334static int 334static int
335ext3_xattr_list_entries(struct inode *inode, struct ext3_xattr_entry *entry, 335ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
336 char *buffer, size_t buffer_size) 336 char *buffer, size_t buffer_size)
337{ 337{
338 size_t rest = buffer_size; 338 size_t rest = buffer_size;
@@ -342,9 +342,10 @@ ext3_xattr_list_entries(struct inode *inode, struct ext3_xattr_entry *entry,
342 ext3_xattr_handler(entry->e_name_index); 342 ext3_xattr_handler(entry->e_name_index);
343 343
344 if (handler) { 344 if (handler) {
345 size_t size = handler->list(inode, buffer, rest, 345 size_t size = handler->list(dentry, buffer, rest,
346 entry->e_name, 346 entry->e_name,
347 entry->e_name_len); 347 entry->e_name_len,
348 handler->flags);
348 if (buffer) { 349 if (buffer) {
349 if (size > rest) 350 if (size > rest)
350 return -ERANGE; 351 return -ERANGE;
@@ -357,8 +358,9 @@ ext3_xattr_list_entries(struct inode *inode, struct ext3_xattr_entry *entry,
357} 358}
358 359
359static int 360static int
360ext3_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size) 361ext3_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size)
361{ 362{
363 struct inode *inode = dentry->d_inode;
362 struct buffer_head *bh = NULL; 364 struct buffer_head *bh = NULL;
363 int error; 365 int error;
364 366
@@ -383,7 +385,7 @@ ext3_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size)
383 goto cleanup; 385 goto cleanup;
384 } 386 }
385 ext3_xattr_cache_insert(bh); 387 ext3_xattr_cache_insert(bh);
386 error = ext3_xattr_list_entries(inode, BFIRST(bh), buffer, buffer_size); 388 error = ext3_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size);
387 389
388cleanup: 390cleanup:
389 brelse(bh); 391 brelse(bh);
@@ -392,15 +394,16 @@ cleanup:
392} 394}
393 395
394static int 396static int
395ext3_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size) 397ext3_xattr_ibody_list(struct dentry *dentry, char *buffer, size_t buffer_size)
396{ 398{
399 struct inode *inode = dentry->d_inode;
397 struct ext3_xattr_ibody_header *header; 400 struct ext3_xattr_ibody_header *header;
398 struct ext3_inode *raw_inode; 401 struct ext3_inode *raw_inode;
399 struct ext3_iloc iloc; 402 struct ext3_iloc iloc;
400 void *end; 403 void *end;
401 int error; 404 int error;
402 405
403 if (!(EXT3_I(inode)->i_state & EXT3_STATE_XATTR)) 406 if (!ext3_test_inode_state(inode, EXT3_STATE_XATTR))
404 return 0; 407 return 0;
405 error = ext3_get_inode_loc(inode, &iloc); 408 error = ext3_get_inode_loc(inode, &iloc);
406 if (error) 409 if (error)
@@ -411,7 +414,7 @@ ext3_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size)
411 error = ext3_xattr_check_names(IFIRST(header), end); 414 error = ext3_xattr_check_names(IFIRST(header), end);
412 if (error) 415 if (error)
413 goto cleanup; 416 goto cleanup;
414 error = ext3_xattr_list_entries(inode, IFIRST(header), 417 error = ext3_xattr_list_entries(dentry, IFIRST(header),
415 buffer, buffer_size); 418 buffer, buffer_size);
416 419
417cleanup: 420cleanup:
@@ -430,12 +433,12 @@ cleanup:
430 * used / required on success. 433 * used / required on success.
431 */ 434 */
432static int 435static int
433ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) 436ext3_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
434{ 437{
435 int i_error, b_error; 438 int i_error, b_error;
436 439
437 down_read(&EXT3_I(inode)->xattr_sem); 440 down_read(&EXT3_I(dentry->d_inode)->xattr_sem);
438 i_error = ext3_xattr_ibody_list(inode, buffer, buffer_size); 441 i_error = ext3_xattr_ibody_list(dentry, buffer, buffer_size);
439 if (i_error < 0) { 442 if (i_error < 0) {
440 b_error = 0; 443 b_error = 0;
441 } else { 444 } else {
@@ -443,11 +446,11 @@ ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)
443 buffer += i_error; 446 buffer += i_error;
444 buffer_size -= i_error; 447 buffer_size -= i_error;
445 } 448 }
446 b_error = ext3_xattr_block_list(inode, buffer, buffer_size); 449 b_error = ext3_xattr_block_list(dentry, buffer, buffer_size);
447 if (b_error < 0) 450 if (b_error < 0)
448 i_error = 0; 451 i_error = 0;
449 } 452 }
450 up_read(&EXT3_I(inode)->xattr_sem); 453 up_read(&EXT3_I(dentry->d_inode)->xattr_sem);
451 return i_error + b_error; 454 return i_error + b_error;
452} 455}
453 456
@@ -497,7 +500,7 @@ ext3_xattr_release_block(handle_t *handle, struct inode *inode,
497 error = ext3_journal_dirty_metadata(handle, bh); 500 error = ext3_journal_dirty_metadata(handle, bh);
498 if (IS_SYNC(inode)) 501 if (IS_SYNC(inode))
499 handle->h_sync = 1; 502 handle->h_sync = 1;
500 vfs_dq_free_block(inode, 1); 503 dquot_free_block(inode, 1);
501 ea_bdebug(bh, "refcount now=%d; releasing", 504 ea_bdebug(bh, "refcount now=%d; releasing",
502 le32_to_cpu(BHDR(bh)->h_refcount)); 505 le32_to_cpu(BHDR(bh)->h_refcount));
503 if (ce) 506 if (ce)
@@ -772,8 +775,8 @@ inserted:
772 else { 775 else {
773 /* The old block is released after updating 776 /* The old block is released after updating
774 the inode. */ 777 the inode. */
775 error = -EDQUOT; 778 error = dquot_alloc_block(inode, 1);
776 if (vfs_dq_alloc_block(inode, 1)) 779 if (error)
777 goto cleanup; 780 goto cleanup;
778 error = ext3_journal_get_write_access(handle, 781 error = ext3_journal_get_write_access(handle,
779 new_bh); 782 new_bh);
@@ -847,7 +850,7 @@ cleanup:
847 return error; 850 return error;
848 851
849cleanup_dquot: 852cleanup_dquot:
850 vfs_dq_free_block(inode, 1); 853 dquot_free_block(inode, 1);
851 goto cleanup; 854 goto cleanup;
852 855
853bad_block: 856bad_block:
@@ -879,7 +882,7 @@ ext3_xattr_ibody_find(struct inode *inode, struct ext3_xattr_info *i,
879 is->s.base = is->s.first = IFIRST(header); 882 is->s.base = is->s.first = IFIRST(header);
880 is->s.here = is->s.first; 883 is->s.here = is->s.first;
881 is->s.end = (void *)raw_inode + EXT3_SB(inode->i_sb)->s_inode_size; 884 is->s.end = (void *)raw_inode + EXT3_SB(inode->i_sb)->s_inode_size;
882 if (EXT3_I(inode)->i_state & EXT3_STATE_XATTR) { 885 if (ext3_test_inode_state(inode, EXT3_STATE_XATTR)) {
883 error = ext3_xattr_check_names(IFIRST(header), is->s.end); 886 error = ext3_xattr_check_names(IFIRST(header), is->s.end);
884 if (error) 887 if (error)
885 return error; 888 return error;
@@ -911,10 +914,10 @@ ext3_xattr_ibody_set(handle_t *handle, struct inode *inode,
911 header = IHDR(inode, ext3_raw_inode(&is->iloc)); 914 header = IHDR(inode, ext3_raw_inode(&is->iloc));
912 if (!IS_LAST_ENTRY(s->first)) { 915 if (!IS_LAST_ENTRY(s->first)) {
913 header->h_magic = cpu_to_le32(EXT3_XATTR_MAGIC); 916 header->h_magic = cpu_to_le32(EXT3_XATTR_MAGIC);
914 EXT3_I(inode)->i_state |= EXT3_STATE_XATTR; 917 ext3_set_inode_state(inode, EXT3_STATE_XATTR);
915 } else { 918 } else {
916 header->h_magic = cpu_to_le32(0); 919 header->h_magic = cpu_to_le32(0);
917 EXT3_I(inode)->i_state &= ~EXT3_STATE_XATTR; 920 ext3_clear_inode_state(inode, EXT3_STATE_XATTR);
918 } 921 }
919 return 0; 922 return 0;
920} 923}
@@ -960,10 +963,14 @@ ext3_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
960 if (error) 963 if (error)
961 goto cleanup; 964 goto cleanup;
962 965
963 if (EXT3_I(inode)->i_state & EXT3_STATE_NEW) { 966 error = ext3_journal_get_write_access(handle, is.iloc.bh);
967 if (error)
968 goto cleanup;
969
970 if (ext3_test_inode_state(inode, EXT3_STATE_NEW)) {
964 struct ext3_inode *raw_inode = ext3_raw_inode(&is.iloc); 971 struct ext3_inode *raw_inode = ext3_raw_inode(&is.iloc);
965 memset(raw_inode, 0, EXT3_SB(inode->i_sb)->s_inode_size); 972 memset(raw_inode, 0, EXT3_SB(inode->i_sb)->s_inode_size);
966 EXT3_I(inode)->i_state &= ~EXT3_STATE_NEW; 973 ext3_clear_inode_state(inode, EXT3_STATE_NEW);
967 } 974 }
968 975
969 error = ext3_xattr_ibody_find(inode, &i, &is); 976 error = ext3_xattr_ibody_find(inode, &i, &is);
@@ -985,9 +992,6 @@ ext3_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
985 if (flags & XATTR_CREATE) 992 if (flags & XATTR_CREATE)
986 goto cleanup; 993 goto cleanup;
987 } 994 }
988 error = ext3_journal_get_write_access(handle, is.iloc.bh);
989 if (error)
990 goto cleanup;
991 if (!value) { 995 if (!value) {
992 if (!is.s.not_found) 996 if (!is.s.not_found)
993 error = ext3_xattr_ibody_set(handle, inode, &i, &is); 997 error = ext3_xattr_ibody_set(handle, inode, &i, &is);
diff --git a/fs/ext3/xattr_security.c b/fs/ext3/xattr_security.c
index 37b81097bdf2..3af91f476dff 100644
--- a/fs/ext3/xattr_security.c
+++ b/fs/ext3/xattr_security.c
@@ -4,6 +4,7 @@
4 */ 4 */
5 5
6#include <linux/module.h> 6#include <linux/module.h>
7#include <linux/slab.h>
7#include <linux/string.h> 8#include <linux/string.h>
8#include <linux/fs.h> 9#include <linux/fs.h>
9#include <linux/ext3_jbd.h> 10#include <linux/ext3_jbd.h>
@@ -12,8 +13,8 @@
12#include "xattr.h" 13#include "xattr.h"
13 14
14static size_t 15static size_t
15ext3_xattr_security_list(struct inode *inode, char *list, size_t list_size, 16ext3_xattr_security_list(struct dentry *dentry, char *list, size_t list_size,
16 const char *name, size_t name_len) 17 const char *name, size_t name_len, int type)
17{ 18{
18 const size_t prefix_len = XATTR_SECURITY_PREFIX_LEN; 19 const size_t prefix_len = XATTR_SECURITY_PREFIX_LEN;
19 const size_t total_len = prefix_len + name_len + 1; 20 const size_t total_len = prefix_len + name_len + 1;
@@ -28,23 +29,23 @@ ext3_xattr_security_list(struct inode *inode, char *list, size_t list_size,
28} 29}
29 30
30static int 31static int
31ext3_xattr_security_get(struct inode *inode, const char *name, 32ext3_xattr_security_get(struct dentry *dentry, const char *name,
32 void *buffer, size_t size) 33 void *buffer, size_t size, int type)
33{ 34{
34 if (strcmp(name, "") == 0) 35 if (strcmp(name, "") == 0)
35 return -EINVAL; 36 return -EINVAL;
36 return ext3_xattr_get(inode, EXT3_XATTR_INDEX_SECURITY, name, 37 return ext3_xattr_get(dentry->d_inode, EXT3_XATTR_INDEX_SECURITY,
37 buffer, size); 38 name, buffer, size);
38} 39}
39 40
40static int 41static int
41ext3_xattr_security_set(struct inode *inode, const char *name, 42ext3_xattr_security_set(struct dentry *dentry, const char *name,
42 const void *value, size_t size, int flags) 43 const void *value, size_t size, int flags, int type)
43{ 44{
44 if (strcmp(name, "") == 0) 45 if (strcmp(name, "") == 0)
45 return -EINVAL; 46 return -EINVAL;
46 return ext3_xattr_set(inode, EXT3_XATTR_INDEX_SECURITY, name, 47 return ext3_xattr_set(dentry->d_inode, EXT3_XATTR_INDEX_SECURITY,
47 value, size, flags); 48 name, value, size, flags);
48} 49}
49 50
50int 51int
diff --git a/fs/ext3/xattr_trusted.c b/fs/ext3/xattr_trusted.c
index c7c41a410c4b..e5562845ed96 100644
--- a/fs/ext3/xattr_trusted.c
+++ b/fs/ext3/xattr_trusted.c
@@ -14,8 +14,8 @@
14#include "xattr.h" 14#include "xattr.h"
15 15
16static size_t 16static size_t
17ext3_xattr_trusted_list(struct inode *inode, char *list, size_t list_size, 17ext3_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size,
18 const char *name, size_t name_len) 18 const char *name, size_t name_len, int type)
19{ 19{
20 const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN; 20 const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN;
21 const size_t total_len = prefix_len + name_len + 1; 21 const size_t total_len = prefix_len + name_len + 1;
@@ -32,22 +32,22 @@ ext3_xattr_trusted_list(struct inode *inode, char *list, size_t list_size,
32} 32}
33 33
34static int 34static int
35ext3_xattr_trusted_get(struct inode *inode, const char *name, 35ext3_xattr_trusted_get(struct dentry *dentry, const char *name,
36 void *buffer, size_t size) 36 void *buffer, size_t size, int type)
37{ 37{
38 if (strcmp(name, "") == 0) 38 if (strcmp(name, "") == 0)
39 return -EINVAL; 39 return -EINVAL;
40 return ext3_xattr_get(inode, EXT3_XATTR_INDEX_TRUSTED, name, 40 return ext3_xattr_get(dentry->d_inode, EXT3_XATTR_INDEX_TRUSTED,
41 buffer, size); 41 name, buffer, size);
42} 42}
43 43
44static int 44static int
45ext3_xattr_trusted_set(struct inode *inode, const char *name, 45ext3_xattr_trusted_set(struct dentry *dentry, const char *name,
46 const void *value, size_t size, int flags) 46 const void *value, size_t size, int flags, int type)
47{ 47{
48 if (strcmp(name, "") == 0) 48 if (strcmp(name, "") == 0)
49 return -EINVAL; 49 return -EINVAL;
50 return ext3_xattr_set(inode, EXT3_XATTR_INDEX_TRUSTED, name, 50 return ext3_xattr_set(dentry->d_inode, EXT3_XATTR_INDEX_TRUSTED, name,
51 value, size, flags); 51 value, size, flags);
52} 52}
53 53
diff --git a/fs/ext3/xattr_user.c b/fs/ext3/xattr_user.c
index 430fe63b31b3..3bcfe9ee0a68 100644
--- a/fs/ext3/xattr_user.c
+++ b/fs/ext3/xattr_user.c
@@ -13,13 +13,13 @@
13#include "xattr.h" 13#include "xattr.h"
14 14
15static size_t 15static size_t
16ext3_xattr_user_list(struct inode *inode, char *list, size_t list_size, 16ext3_xattr_user_list(struct dentry *dentry, char *list, size_t list_size,
17 const char *name, size_t name_len) 17 const char *name, size_t name_len, int type)
18{ 18{
19 const size_t prefix_len = XATTR_USER_PREFIX_LEN; 19 const size_t prefix_len = XATTR_USER_PREFIX_LEN;
20 const size_t total_len = prefix_len + name_len + 1; 20 const size_t total_len = prefix_len + name_len + 1;
21 21
22 if (!test_opt(inode->i_sb, XATTR_USER)) 22 if (!test_opt(dentry->d_sb, XATTR_USER))
23 return 0; 23 return 0;
24 24
25 if (list && total_len <= list_size) { 25 if (list && total_len <= list_size) {
@@ -31,26 +31,27 @@ ext3_xattr_user_list(struct inode *inode, char *list, size_t list_size,
31} 31}
32 32
33static int 33static int
34ext3_xattr_user_get(struct inode *inode, const char *name, 34ext3_xattr_user_get(struct dentry *dentry, const char *name, void *buffer,
35 void *buffer, size_t size) 35 size_t size, int type)
36{ 36{
37 if (strcmp(name, "") == 0) 37 if (strcmp(name, "") == 0)
38 return -EINVAL; 38 return -EINVAL;
39 if (!test_opt(inode->i_sb, XATTR_USER)) 39 if (!test_opt(dentry->d_sb, XATTR_USER))
40 return -EOPNOTSUPP; 40 return -EOPNOTSUPP;
41 return ext3_xattr_get(inode, EXT3_XATTR_INDEX_USER, name, buffer, size); 41 return ext3_xattr_get(dentry->d_inode, EXT3_XATTR_INDEX_USER,
42 name, buffer, size);
42} 43}
43 44
44static int 45static int
45ext3_xattr_user_set(struct inode *inode, const char *name, 46ext3_xattr_user_set(struct dentry *dentry, const char *name,
46 const void *value, size_t size, int flags) 47 const void *value, size_t size, int flags, int type)
47{ 48{
48 if (strcmp(name, "") == 0) 49 if (strcmp(name, "") == 0)
49 return -EINVAL; 50 return -EINVAL;
50 if (!test_opt(inode->i_sb, XATTR_USER)) 51 if (!test_opt(dentry->d_sb, XATTR_USER))
51 return -EOPNOTSUPP; 52 return -EOPNOTSUPP;
52 return ext3_xattr_set(inode, EXT3_XATTR_INDEX_USER, name, 53 return ext3_xattr_set(dentry->d_inode, EXT3_XATTR_INDEX_USER,
53 value, size, flags); 54 name, value, size, flags);
54} 55}
55 56
56struct xattr_handler ext3_xattr_user_handler = { 57struct xattr_handler ext3_xattr_user_handler = {