aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext3/super.c')
-rw-r--r--fs/ext3/super.c185
1 files changed, 106 insertions, 79 deletions
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 5dbf4dba03c4..aad153ef6b78 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -27,7 +27,6 @@
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/blkdev.h> 28#include <linux/blkdev.h>
29#include <linux/parser.h> 29#include <linux/parser.h>
30#include <linux/smp_lock.h>
31#include <linux/buffer_head.h> 30#include <linux/buffer_head.h>
32#include <linux/exportfs.h> 31#include <linux/exportfs.h>
33#include <linux/vfs.h> 32#include <linux/vfs.h>
@@ -37,6 +36,7 @@
37#include <linux/quotaops.h> 36#include <linux/quotaops.h>
38#include <linux/seq_file.h> 37#include <linux/seq_file.h>
39#include <linux/log2.h> 38#include <linux/log2.h>
39#include <linux/cleancache.h>
40 40
41#include <asm/uaccess.h> 41#include <asm/uaccess.h>
42 42
@@ -144,12 +144,16 @@ void ext3_journal_abort_handle(const char *caller, const char *err_fn,
144void ext3_msg(struct super_block *sb, const char *prefix, 144void ext3_msg(struct super_block *sb, const char *prefix,
145 const char *fmt, ...) 145 const char *fmt, ...)
146{ 146{
147 struct va_format vaf;
147 va_list args; 148 va_list args;
148 149
149 va_start(args, fmt); 150 va_start(args, fmt);
150 printk("%sEXT3-fs (%s): ", prefix, sb->s_id); 151
151 vprintk(fmt, args); 152 vaf.fmt = fmt;
152 printk("\n"); 153 vaf.va = &args;
154
155 printk("%sEXT3-fs (%s): %pV\n", prefix, sb->s_id, &vaf);
156
153 va_end(args); 157 va_end(args);
154} 158}
155 159
@@ -196,15 +200,20 @@ static void ext3_handle_error(struct super_block *sb)
196 sb->s_id); 200 sb->s_id);
197} 201}
198 202
199void ext3_error (struct super_block * sb, const char * function, 203void ext3_error(struct super_block *sb, const char *function,
200 const char * fmt, ...) 204 const char *fmt, ...)
201{ 205{
206 struct va_format vaf;
202 va_list args; 207 va_list args;
203 208
204 va_start(args, fmt); 209 va_start(args, fmt);
205 printk(KERN_CRIT "EXT3-fs error (device %s): %s: ",sb->s_id, function); 210
206 vprintk(fmt, args); 211 vaf.fmt = fmt;
207 printk("\n"); 212 vaf.va = &args;
213
214 printk(KERN_CRIT "EXT3-fs error (device %s): %s: %pV\n",
215 sb->s_id, function, &vaf);
216
208 va_end(args); 217 va_end(args);
209 218
210 ext3_handle_error(sb); 219 ext3_handle_error(sb);
@@ -275,15 +284,20 @@ void __ext3_std_error (struct super_block * sb, const char * function,
275 * case we take the easy way out and panic immediately. 284 * case we take the easy way out and panic immediately.
276 */ 285 */
277 286
278void ext3_abort (struct super_block * sb, const char * function, 287void ext3_abort(struct super_block *sb, const char *function,
279 const char * fmt, ...) 288 const char *fmt, ...)
280{ 289{
290 struct va_format vaf;
281 va_list args; 291 va_list args;
282 292
283 va_start(args, fmt); 293 va_start(args, fmt);
284 printk(KERN_CRIT "EXT3-fs (%s): error: %s: ", sb->s_id, function); 294
285 vprintk(fmt, args); 295 vaf.fmt = fmt;
286 printk("\n"); 296 vaf.va = &args;
297
298 printk(KERN_CRIT "EXT3-fs (%s): error: %s: %pV\n",
299 sb->s_id, function, &vaf);
300
287 va_end(args); 301 va_end(args);
288 302
289 if (test_opt(sb, ERRORS_PANIC)) 303 if (test_opt(sb, ERRORS_PANIC))
@@ -301,16 +315,20 @@ void ext3_abort (struct super_block * sb, const char * function,
301 journal_abort(EXT3_SB(sb)->s_journal, -EIO); 315 journal_abort(EXT3_SB(sb)->s_journal, -EIO);
302} 316}
303 317
304void ext3_warning (struct super_block * sb, const char * function, 318void ext3_warning(struct super_block *sb, const char *function,
305 const char * fmt, ...) 319 const char *fmt, ...)
306{ 320{
321 struct va_format vaf;
307 va_list args; 322 va_list args;
308 323
309 va_start(args, fmt); 324 va_start(args, fmt);
310 printk(KERN_WARNING "EXT3-fs (%s): warning: %s: ", 325
311 sb->s_id, function); 326 vaf.fmt = fmt;
312 vprintk(fmt, args); 327 vaf.va = &args;
313 printk("\n"); 328
329 printk(KERN_WARNING "EXT3-fs (%s): warning: %s: %pV\n",
330 sb->s_id, function, &vaf);
331
314 va_end(args); 332 va_end(args);
315} 333}
316 334
@@ -347,7 +365,7 @@ static struct block_device *ext3_blkdev_get(dev_t dev, struct super_block *sb)
347 struct block_device *bdev; 365 struct block_device *bdev;
348 char b[BDEVNAME_SIZE]; 366 char b[BDEVNAME_SIZE];
349 367
350 bdev = open_by_devnum(dev, FMODE_READ|FMODE_WRITE); 368 bdev = blkdev_get_by_dev(dev, FMODE_READ|FMODE_WRITE|FMODE_EXCL, sb);
351 if (IS_ERR(bdev)) 369 if (IS_ERR(bdev))
352 goto fail; 370 goto fail;
353 return bdev; 371 return bdev;
@@ -364,8 +382,7 @@ fail:
364 */ 382 */
365static int ext3_blkdev_put(struct block_device *bdev) 383static int ext3_blkdev_put(struct block_device *bdev)
366{ 384{
367 bd_release(bdev); 385 return blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
368 return blkdev_put(bdev, FMODE_READ|FMODE_WRITE);
369} 386}
370 387
371static int ext3_blkdev_remove(struct ext3_sb_info *sbi) 388static int ext3_blkdev_remove(struct ext3_sb_info *sbi)
@@ -411,9 +428,6 @@ static void ext3_put_super (struct super_block * sb)
411 int i, err; 428 int i, err;
412 429
413 dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); 430 dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED);
414
415 lock_kernel();
416
417 ext3_xattr_put_super(sb); 431 ext3_xattr_put_super(sb);
418 err = journal_destroy(sbi->s_journal); 432 err = journal_destroy(sbi->s_journal);
419 sbi->s_journal = NULL; 433 sbi->s_journal = NULL;
@@ -462,8 +476,6 @@ static void ext3_put_super (struct super_block * sb)
462 sb->s_fs_info = NULL; 476 sb->s_fs_info = NULL;
463 kfree(sbi->s_blockgroup_lock); 477 kfree(sbi->s_blockgroup_lock);
464 kfree(sbi); 478 kfree(sbi);
465
466 unlock_kernel();
467} 479}
468 480
469static struct kmem_cache *ext3_inode_cachep; 481static struct kmem_cache *ext3_inode_cachep;
@@ -485,6 +497,13 @@ static struct inode *ext3_alloc_inode(struct super_block *sb)
485 return &ei->vfs_inode; 497 return &ei->vfs_inode;
486} 498}
487 499
500static void ext3_i_callback(struct rcu_head *head)
501{
502 struct inode *inode = container_of(head, struct inode, i_rcu);
503 INIT_LIST_HEAD(&inode->i_dentry);
504 kmem_cache_free(ext3_inode_cachep, EXT3_I(inode));
505}
506
488static void ext3_destroy_inode(struct inode *inode) 507static void ext3_destroy_inode(struct inode *inode)
489{ 508{
490 if (!list_empty(&(EXT3_I(inode)->i_orphan))) { 509 if (!list_empty(&(EXT3_I(inode)->i_orphan))) {
@@ -495,7 +514,7 @@ static void ext3_destroy_inode(struct inode *inode)
495 false); 514 false);
496 dump_stack(); 515 dump_stack();
497 } 516 }
498 kmem_cache_free(ext3_inode_cachep, EXT3_I(inode)); 517 call_rcu(&inode->i_rcu, ext3_i_callback);
499} 518}
500 519
501static void init_once(void *foo) 520static void init_once(void *foo)
@@ -736,7 +755,7 @@ static int ext3_release_dquot(struct dquot *dquot);
736static int ext3_mark_dquot_dirty(struct dquot *dquot); 755static int ext3_mark_dquot_dirty(struct dquot *dquot);
737static int ext3_write_info(struct super_block *sb, int type); 756static int ext3_write_info(struct super_block *sb, int type);
738static int ext3_quota_on(struct super_block *sb, int type, int format_id, 757static int ext3_quota_on(struct super_block *sb, int type, int format_id,
739 char *path); 758 struct path *path);
740static int ext3_quota_on_mount(struct super_block *sb, int type); 759static int ext3_quota_on_mount(struct super_block *sb, int type);
741static ssize_t ext3_quota_read(struct super_block *sb, int type, char *data, 760static ssize_t ext3_quota_read(struct super_block *sb, int type, char *data,
742 size_t len, loff_t off); 761 size_t len, loff_t off);
@@ -1306,9 +1325,9 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es,
1306 ext3_msg(sb, KERN_WARNING, 1325 ext3_msg(sb, KERN_WARNING,
1307 "warning: mounting fs with errors, " 1326 "warning: mounting fs with errors, "
1308 "running e2fsck is recommended"); 1327 "running e2fsck is recommended");
1309 else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 && 1328 else if ((__s16) le16_to_cpu(es->s_max_mnt_count) > 0 &&
1310 le16_to_cpu(es->s_mnt_count) >= 1329 le16_to_cpu(es->s_mnt_count) >=
1311 (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count)) 1330 le16_to_cpu(es->s_max_mnt_count))
1312 ext3_msg(sb, KERN_WARNING, 1331 ext3_msg(sb, KERN_WARNING,
1313 "warning: maximal mount count reached, " 1332 "warning: maximal mount count reached, "
1314 "running e2fsck is recommended"); 1333 "running e2fsck is recommended");
@@ -1325,7 +1344,7 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es,
1325 valid forever! :) */ 1344 valid forever! :) */
1326 es->s_state &= cpu_to_le16(~EXT3_VALID_FS); 1345 es->s_state &= cpu_to_le16(~EXT3_VALID_FS);
1327#endif 1346#endif
1328 if (!(__s16) le16_to_cpu(es->s_max_mnt_count)) 1347 if (!le16_to_cpu(es->s_max_mnt_count))
1329 es->s_max_mnt_count = cpu_to_le16(EXT3_DFL_MAX_MNT_COUNT); 1348 es->s_max_mnt_count = cpu_to_le16(EXT3_DFL_MAX_MNT_COUNT);
1330 le16_add_cpu(&es->s_mnt_count, 1); 1349 le16_add_cpu(&es->s_mnt_count, 1);
1331 es->s_mtime = cpu_to_le32(get_seconds()); 1350 es->s_mtime = cpu_to_le32(get_seconds());
@@ -1349,6 +1368,7 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es,
1349 } else { 1368 } else {
1350 ext3_msg(sb, KERN_INFO, "using internal journal"); 1369 ext3_msg(sb, KERN_INFO, "using internal journal");
1351 } 1370 }
1371 cleancache_init_fs(sb);
1352 return res; 1372 return res;
1353} 1373}
1354 1374
@@ -1446,6 +1466,13 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1446 return; 1466 return;
1447 } 1467 }
1448 1468
1469 /* Check if feature set allows readwrite operations */
1470 if (EXT3_HAS_RO_COMPAT_FEATURE(sb, ~EXT3_FEATURE_RO_COMPAT_SUPP)) {
1471 ext3_msg(sb, KERN_INFO, "Skipping orphan cleanup due to "
1472 "unknown ROCOMPAT features");
1473 return;
1474 }
1475
1449 if (EXT3_SB(sb)->s_mount_state & EXT3_ERROR_FS) { 1476 if (EXT3_SB(sb)->s_mount_state & EXT3_ERROR_FS) {
1450 if (es->s_last_orphan) 1477 if (es->s_last_orphan)
1451 jbd_debug(1, "Errors on filesystem, " 1478 jbd_debug(1, "Errors on filesystem, "
@@ -1627,8 +1654,6 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1627 sbi->s_resgid = EXT3_DEF_RESGID; 1654 sbi->s_resgid = EXT3_DEF_RESGID;
1628 sbi->s_sb_block = sb_block; 1655 sbi->s_sb_block = sb_block;
1629 1656
1630 unlock_kernel();
1631
1632 blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE); 1657 blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE);
1633 if (!blocksize) { 1658 if (!blocksize) {
1634 ext3_msg(sb, KERN_ERR, "error: unable to set blocksize"); 1659 ext3_msg(sb, KERN_ERR, "error: unable to set blocksize");
@@ -1654,7 +1679,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1654 * Note: s_es must be initialized as soon as possible because 1679 * Note: s_es must be initialized as soon as possible because
1655 * some ext3 macro-instructions depend on its value 1680 * some ext3 macro-instructions depend on its value
1656 */ 1681 */
1657 es = (struct ext3_super_block *) (((char *)bh->b_data) + offset); 1682 es = (struct ext3_super_block *) (bh->b_data + offset);
1658 sbi->s_es = es; 1683 sbi->s_es = es;
1659 sb->s_magic = le16_to_cpu(es->s_magic); 1684 sb->s_magic = le16_to_cpu(es->s_magic);
1660 if (sb->s_magic != EXT3_SUPER_MAGIC) 1685 if (sb->s_magic != EXT3_SUPER_MAGIC)
@@ -1765,7 +1790,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1765 "error: can't read superblock on 2nd try"); 1790 "error: can't read superblock on 2nd try");
1766 goto failed_mount; 1791 goto failed_mount;
1767 } 1792 }
1768 es = (struct ext3_super_block *)(((char *)bh->b_data) + offset); 1793 es = (struct ext3_super_block *)(bh->b_data + offset);
1769 sbi->s_es = es; 1794 sbi->s_es = es;
1770 if (es->s_magic != cpu_to_le16(EXT3_SUPER_MAGIC)) { 1795 if (es->s_magic != cpu_to_le16(EXT3_SUPER_MAGIC)) {
1771 ext3_msg(sb, KERN_ERR, 1796 ext3_msg(sb, KERN_ERR,
@@ -1849,13 +1874,15 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1849 goto failed_mount; 1874 goto failed_mount;
1850 } 1875 }
1851 1876
1852 if (le32_to_cpu(es->s_blocks_count) > 1877 err = generic_check_addressable(sb->s_blocksize_bits,
1853 (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) { 1878 le32_to_cpu(es->s_blocks_count));
1879 if (err) {
1854 ext3_msg(sb, KERN_ERR, 1880 ext3_msg(sb, KERN_ERR,
1855 "error: filesystem is too large to mount safely"); 1881 "error: filesystem is too large to mount safely");
1856 if (sizeof(sector_t) < 8) 1882 if (sizeof(sector_t) < 8)
1857 ext3_msg(sb, KERN_ERR, 1883 ext3_msg(sb, KERN_ERR,
1858 "error: CONFIG_LBDAF not enabled"); 1884 "error: CONFIG_LBDAF not enabled");
1885 ret = err;
1859 goto failed_mount; 1886 goto failed_mount;
1860 } 1887 }
1861 1888
@@ -1864,13 +1891,13 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1864 sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) - 1891 sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) -
1865 le32_to_cpu(es->s_first_data_block) - 1) 1892 le32_to_cpu(es->s_first_data_block) - 1)
1866 / EXT3_BLOCKS_PER_GROUP(sb)) + 1; 1893 / EXT3_BLOCKS_PER_GROUP(sb)) + 1;
1867 db_count = (sbi->s_groups_count + EXT3_DESC_PER_BLOCK(sb) - 1) / 1894 db_count = DIV_ROUND_UP(sbi->s_groups_count, EXT3_DESC_PER_BLOCK(sb));
1868 EXT3_DESC_PER_BLOCK(sb);
1869 sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *), 1895 sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *),
1870 GFP_KERNEL); 1896 GFP_KERNEL);
1871 if (sbi->s_group_desc == NULL) { 1897 if (sbi->s_group_desc == NULL) {
1872 ext3_msg(sb, KERN_ERR, 1898 ext3_msg(sb, KERN_ERR,
1873 "error: not enough memory"); 1899 "error: not enough memory");
1900 ret = -ENOMEM;
1874 goto failed_mount; 1901 goto failed_mount;
1875 } 1902 }
1876 1903
@@ -1918,6 +1945,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1918 sb->s_qcop = &ext3_qctl_operations; 1945 sb->s_qcop = &ext3_qctl_operations;
1919 sb->dq_op = &ext3_quota_operations; 1946 sb->dq_op = &ext3_quota_operations;
1920#endif 1947#endif
1948 memcpy(sb->s_uuid, es->s_uuid, sizeof(es->s_uuid));
1921 INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */ 1949 INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
1922 mutex_init(&sbi->s_orphan_lock); 1950 mutex_init(&sbi->s_orphan_lock);
1923 mutex_init(&sbi->s_resize_lock); 1951 mutex_init(&sbi->s_resize_lock);
@@ -1958,6 +1986,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1958 } 1986 }
1959 if (err) { 1987 if (err) {
1960 ext3_msg(sb, KERN_ERR, "error: insufficient memory"); 1988 ext3_msg(sb, KERN_ERR, "error: insufficient memory");
1989 ret = err;
1961 goto failed_mount3; 1990 goto failed_mount3;
1962 } 1991 }
1963 1992
@@ -2025,7 +2054,6 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
2025 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered": 2054 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered":
2026 "writeback"); 2055 "writeback");
2027 2056
2028 lock_kernel();
2029 return 0; 2057 return 0;
2030 2058
2031cantfind_ext3: 2059cantfind_ext3:
@@ -2055,7 +2083,6 @@ out_fail:
2055 sb->s_fs_info = NULL; 2083 sb->s_fs_info = NULL;
2056 kfree(sbi->s_blockgroup_lock); 2084 kfree(sbi->s_blockgroup_lock);
2057 kfree(sbi); 2085 kfree(sbi);
2058 lock_kernel();
2059 return ret; 2086 return ret;
2060} 2087}
2061 2088
@@ -2144,13 +2171,6 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb,
2144 if (bdev == NULL) 2171 if (bdev == NULL)
2145 return NULL; 2172 return NULL;
2146 2173
2147 if (bd_claim(bdev, sb)) {
2148 ext3_msg(sb, KERN_ERR,
2149 "error: failed to claim external journal device");
2150 blkdev_put(bdev, FMODE_READ|FMODE_WRITE);
2151 return NULL;
2152 }
2153
2154 blocksize = sb->s_blocksize; 2174 blocksize = sb->s_blocksize;
2155 hblock = bdev_logical_block_size(bdev); 2175 hblock = bdev_logical_block_size(bdev);
2156 if (blocksize < hblock) { 2176 if (blocksize < hblock) {
@@ -2168,7 +2188,7 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb,
2168 goto out_bdev; 2188 goto out_bdev;
2169 } 2189 }
2170 2190
2171 es = (struct ext3_super_block *) (((char *)bh->b_data) + offset); 2191 es = (struct ext3_super_block *) (bh->b_data + offset);
2172 if ((le16_to_cpu(es->s_magic) != EXT3_SUPER_MAGIC) || 2192 if ((le16_to_cpu(es->s_magic) != EXT3_SUPER_MAGIC) ||
2173 !(le32_to_cpu(es->s_feature_incompat) & 2193 !(le32_to_cpu(es->s_feature_incompat) &
2174 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) { 2194 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) {
@@ -2299,7 +2319,7 @@ static int ext3_load_journal(struct super_block *sb,
2299 EXT3_SB(sb)->s_journal = journal; 2319 EXT3_SB(sb)->s_journal = journal;
2300 ext3_clear_journal_err(sb, es); 2320 ext3_clear_journal_err(sb, es);
2301 2321
2302 if (journal_devnum && 2322 if (!really_read_only && journal_devnum &&
2303 journal_devnum != le32_to_cpu(es->s_journal_dev)) { 2323 journal_devnum != le32_to_cpu(es->s_journal_dev)) {
2304 es->s_journal_dev = cpu_to_le32(journal_devnum); 2324 es->s_journal_dev = cpu_to_le32(journal_devnum);
2305 2325
@@ -2361,6 +2381,21 @@ static int ext3_commit_super(struct super_block *sb,
2361 2381
2362 if (!sbh) 2382 if (!sbh)
2363 return error; 2383 return error;
2384
2385 if (buffer_write_io_error(sbh)) {
2386 /*
2387 * Oh, dear. A previous attempt to write the
2388 * superblock failed. This could happen because the
2389 * USB device was yanked out. Or it could happen to
2390 * be a transient write error and maybe the block will
2391 * be remapped. Nothing we can do but to retry the
2392 * write and hope for the best.
2393 */
2394 ext3_msg(sb, KERN_ERR, "previous I/O error to "
2395 "superblock detected");
2396 clear_buffer_write_io_error(sbh);
2397 set_buffer_uptodate(sbh);
2398 }
2364 /* 2399 /*
2365 * If the file system is mounted read-only, don't update the 2400 * If the file system is mounted read-only, don't update the
2366 * superblock write time. This avoids updating the superblock 2401 * superblock write time. This avoids updating the superblock
@@ -2377,8 +2412,15 @@ static int ext3_commit_super(struct super_block *sb,
2377 es->s_free_inodes_count = cpu_to_le32(ext3_count_free_inodes(sb)); 2412 es->s_free_inodes_count = cpu_to_le32(ext3_count_free_inodes(sb));
2378 BUFFER_TRACE(sbh, "marking dirty"); 2413 BUFFER_TRACE(sbh, "marking dirty");
2379 mark_buffer_dirty(sbh); 2414 mark_buffer_dirty(sbh);
2380 if (sync) 2415 if (sync) {
2381 error = sync_dirty_buffer(sbh); 2416 error = sync_dirty_buffer(sbh);
2417 if (buffer_write_io_error(sbh)) {
2418 ext3_msg(sb, KERN_ERR, "I/O error while writing "
2419 "superblock");
2420 clear_buffer_write_io_error(sbh);
2421 set_buffer_uptodate(sbh);
2422 }
2423 }
2382 return error; 2424 return error;
2383} 2425}
2384 2426
@@ -2538,8 +2580,6 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2538 int i; 2580 int i;
2539#endif 2581#endif
2540 2582
2541 lock_kernel();
2542
2543 /* Store the original options */ 2583 /* Store the original options */
2544 lock_super(sb); 2584 lock_super(sb);
2545 old_sb_flags = sb->s_flags; 2585 old_sb_flags = sb->s_flags;
@@ -2648,7 +2688,6 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2648 kfree(old_opts.s_qf_names[i]); 2688 kfree(old_opts.s_qf_names[i]);
2649#endif 2689#endif
2650 unlock_super(sb); 2690 unlock_super(sb);
2651 unlock_kernel();
2652 2691
2653 if (enable_quota) 2692 if (enable_quota)
2654 dquot_resume(sb, -1); 2693 dquot_resume(sb, -1);
@@ -2669,7 +2708,6 @@ restore_opts:
2669 } 2708 }
2670#endif 2709#endif
2671 unlock_super(sb); 2710 unlock_super(sb);
2672 unlock_kernel();
2673 return err; 2711 return err;
2674} 2712}
2675 2713
@@ -2849,27 +2887,20 @@ static int ext3_quota_on_mount(struct super_block *sb, int type)
2849 * Standard function to be called on quota_on 2887 * Standard function to be called on quota_on
2850 */ 2888 */
2851static int ext3_quota_on(struct super_block *sb, int type, int format_id, 2889static int ext3_quota_on(struct super_block *sb, int type, int format_id,
2852 char *name) 2890 struct path *path)
2853{ 2891{
2854 int err; 2892 int err;
2855 struct path path;
2856 2893
2857 if (!test_opt(sb, QUOTA)) 2894 if (!test_opt(sb, QUOTA))
2858 return -EINVAL; 2895 return -EINVAL;
2859 2896
2860 err = kern_path(name, LOOKUP_FOLLOW, &path);
2861 if (err)
2862 return err;
2863
2864 /* Quotafile not on the same filesystem? */ 2897 /* Quotafile not on the same filesystem? */
2865 if (path.mnt->mnt_sb != sb) { 2898 if (path->mnt->mnt_sb != sb)
2866 path_put(&path);
2867 return -EXDEV; 2899 return -EXDEV;
2868 }
2869 /* Journaling quota? */ 2900 /* Journaling quota? */
2870 if (EXT3_SB(sb)->s_qf_names[type]) { 2901 if (EXT3_SB(sb)->s_qf_names[type]) {
2871 /* Quotafile not of fs root? */ 2902 /* Quotafile not of fs root? */
2872 if (path.dentry->d_parent != sb->s_root) 2903 if (path->dentry->d_parent != sb->s_root)
2873 ext3_msg(sb, KERN_WARNING, 2904 ext3_msg(sb, KERN_WARNING,
2874 "warning: Quota file not on filesystem root. " 2905 "warning: Quota file not on filesystem root. "
2875 "Journaled quota will not work."); 2906 "Journaled quota will not work.");
@@ -2879,7 +2910,7 @@ static int ext3_quota_on(struct super_block *sb, int type, int format_id,
2879 * When we journal data on quota file, we have to flush journal to see 2910 * When we journal data on quota file, we have to flush journal to see
2880 * all updates to the file when we bypass pagecache... 2911 * all updates to the file when we bypass pagecache...
2881 */ 2912 */
2882 if (ext3_should_journal_data(path.dentry->d_inode)) { 2913 if (ext3_should_journal_data(path->dentry->d_inode)) {
2883 /* 2914 /*
2884 * We don't need to lock updates but journal_flush() could 2915 * We don't need to lock updates but journal_flush() could
2885 * otherwise be livelocked... 2916 * otherwise be livelocked...
@@ -2887,20 +2918,16 @@ static int ext3_quota_on(struct super_block *sb, int type, int format_id,
2887 journal_lock_updates(EXT3_SB(sb)->s_journal); 2918 journal_lock_updates(EXT3_SB(sb)->s_journal);
2888 err = journal_flush(EXT3_SB(sb)->s_journal); 2919 err = journal_flush(EXT3_SB(sb)->s_journal);
2889 journal_unlock_updates(EXT3_SB(sb)->s_journal); 2920 journal_unlock_updates(EXT3_SB(sb)->s_journal);
2890 if (err) { 2921 if (err)
2891 path_put(&path);
2892 return err; 2922 return err;
2893 }
2894 } 2923 }
2895 2924
2896 err = dquot_quota_on_path(sb, type, format_id, &path); 2925 return dquot_quota_on(sb, type, format_id, path);
2897 path_put(&path);
2898 return err;
2899} 2926}
2900 2927
2901/* Read data from quotafile - avoid pagecache and such because we cannot afford 2928/* Read data from quotafile - avoid pagecache and such because we cannot afford
2902 * acquiring the locks... As quota files are never truncated and quota code 2929 * acquiring the locks... As quota files are never truncated and quota code
2903 * itself serializes the operations (and noone else should touch the files) 2930 * itself serializes the operations (and no one else should touch the files)
2904 * we don't have to be afraid of races */ 2931 * we don't have to be afraid of races */
2905static ssize_t ext3_quota_read(struct super_block *sb, int type, char *data, 2932static ssize_t ext3_quota_read(struct super_block *sb, int type, char *data,
2906 size_t len, loff_t off) 2933 size_t len, loff_t off)
@@ -3010,16 +3037,16 @@ out:
3010 3037
3011#endif 3038#endif
3012 3039
3013static int ext3_get_sb(struct file_system_type *fs_type, 3040static struct dentry *ext3_mount(struct file_system_type *fs_type,
3014 int flags, const char *dev_name, void *data, struct vfsmount *mnt) 3041 int flags, const char *dev_name, void *data)
3015{ 3042{
3016 return get_sb_bdev(fs_type, flags, dev_name, data, ext3_fill_super, mnt); 3043 return mount_bdev(fs_type, flags, dev_name, data, ext3_fill_super);
3017} 3044}
3018 3045
3019static struct file_system_type ext3_fs_type = { 3046static struct file_system_type ext3_fs_type = {
3020 .owner = THIS_MODULE, 3047 .owner = THIS_MODULE,
3021 .name = "ext3", 3048 .name = "ext3",
3022 .get_sb = ext3_get_sb, 3049 .mount = ext3_mount,
3023 .kill_sb = kill_block_super, 3050 .kill_sb = kill_block_super,
3024 .fs_flags = FS_REQUIRES_DEV, 3051 .fs_flags = FS_REQUIRES_DEV,
3025}; 3052};