aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/super.c
diff options
context:
space:
mode:
authorMingming Cao <cmm@us.ibm.com>2006-10-11 04:20:53 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-11 14:14:15 -0400
commit617ba13b31fbf505cc21799826639ef24ed94af0 (patch)
tree2a41e8c993f7c1eed115ad24047d546ba56cbdf5 /fs/ext4/super.c
parentac27a0ec112a089f1a5102bc8dffc79c8c815571 (diff)
[PATCH] ext4: rename ext4 symbols to avoid duplication of ext3 symbols
Mingming Cao originally did this work, and Shaggy reproduced it using some scripts from her. Signed-off-by: Mingming Cao <cmm@us.ibm.com> Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r--fs/ext4/super.c1114
1 files changed, 557 insertions, 557 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 8bfd56ef18ca..9e32a2a8d286 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/fs/ext3/super.c 2 * linux/fs/ext4/super.c
3 * 3 *
4 * Copyright (C) 1992, 1993, 1994, 1995 4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr) 5 * Remy Card (card@masi.ibp.fr)
@@ -21,8 +21,8 @@
21#include <linux/fs.h> 21#include <linux/fs.h>
22#include <linux/time.h> 22#include <linux/time.h>
23#include <linux/jbd.h> 23#include <linux/jbd.h>
24#include <linux/ext3_fs.h> 24#include <linux/ext4_fs.h>
25#include <linux/ext3_jbd.h> 25#include <linux/ext4_jbd.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/blkdev.h> 28#include <linux/blkdev.h>
@@ -42,25 +42,25 @@
42#include "acl.h" 42#include "acl.h"
43#include "namei.h" 43#include "namei.h"
44 44
45static int ext3_load_journal(struct super_block *, struct ext3_super_block *, 45static int ext4_load_journal(struct super_block *, struct ext4_super_block *,
46 unsigned long journal_devnum); 46 unsigned long journal_devnum);
47static int ext3_create_journal(struct super_block *, struct ext3_super_block *, 47static int ext4_create_journal(struct super_block *, struct ext4_super_block *,
48 unsigned int); 48 unsigned int);
49static void ext3_commit_super (struct super_block * sb, 49static void ext4_commit_super (struct super_block * sb,
50 struct ext3_super_block * es, 50 struct ext4_super_block * es,
51 int sync); 51 int sync);
52static void ext3_mark_recovery_complete(struct super_block * sb, 52static void ext4_mark_recovery_complete(struct super_block * sb,
53 struct ext3_super_block * es); 53 struct ext4_super_block * es);
54static void ext3_clear_journal_err(struct super_block * sb, 54static void ext4_clear_journal_err(struct super_block * sb,
55 struct ext3_super_block * es); 55 struct ext4_super_block * es);
56static int ext3_sync_fs(struct super_block *sb, int wait); 56static int ext4_sync_fs(struct super_block *sb, int wait);
57static const char *ext3_decode_error(struct super_block * sb, int errno, 57static const char *ext4_decode_error(struct super_block * sb, int errno,
58 char nbuf[16]); 58 char nbuf[16]);
59static int ext3_remount (struct super_block * sb, int * flags, char * data); 59static int ext4_remount (struct super_block * sb, int * flags, char * data);
60static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf); 60static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf);
61static void ext3_unlockfs(struct super_block *sb); 61static void ext4_unlockfs(struct super_block *sb);
62static void ext3_write_super (struct super_block * sb); 62static void ext4_write_super (struct super_block * sb);
63static void ext3_write_super_lockfs(struct super_block *sb); 63static void ext4_write_super_lockfs(struct super_block *sb);
64 64
65/* 65/*
66 * Wrappers for journal_start/end. 66 * Wrappers for journal_start/end.
@@ -70,7 +70,7 @@ static void ext3_write_super_lockfs(struct super_block *sb);
70 * that sync() will call the filesystem's write_super callback if 70 * that sync() will call the filesystem's write_super callback if
71 * appropriate. 71 * appropriate.
72 */ 72 */
73handle_t *ext3_journal_start_sb(struct super_block *sb, int nblocks) 73handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks)
74{ 74{
75 journal_t *journal; 75 journal_t *journal;
76 76
@@ -80,9 +80,9 @@ handle_t *ext3_journal_start_sb(struct super_block *sb, int nblocks)
80 /* Special case here: if the journal has aborted behind our 80 /* Special case here: if the journal has aborted behind our
81 * backs (eg. EIO in the commit thread), then we still need to 81 * backs (eg. EIO in the commit thread), then we still need to
82 * take the FS itself readonly cleanly. */ 82 * take the FS itself readonly cleanly. */
83 journal = EXT3_SB(sb)->s_journal; 83 journal = EXT4_SB(sb)->s_journal;
84 if (is_journal_aborted(journal)) { 84 if (is_journal_aborted(journal)) {
85 ext3_abort(sb, __FUNCTION__, 85 ext4_abort(sb, __FUNCTION__,
86 "Detected aborted journal"); 86 "Detected aborted journal");
87 return ERR_PTR(-EROFS); 87 return ERR_PTR(-EROFS);
88 } 88 }
@@ -96,7 +96,7 @@ handle_t *ext3_journal_start_sb(struct super_block *sb, int nblocks)
96 * that sync() will call the filesystem's write_super callback if 96 * that sync() will call the filesystem's write_super callback if
97 * appropriate. 97 * appropriate.
98 */ 98 */
99int __ext3_journal_stop(const char *where, handle_t *handle) 99int __ext4_journal_stop(const char *where, handle_t *handle)
100{ 100{
101 struct super_block *sb; 101 struct super_block *sb;
102 int err; 102 int err;
@@ -109,15 +109,15 @@ int __ext3_journal_stop(const char *where, handle_t *handle)
109 if (!err) 109 if (!err)
110 err = rc; 110 err = rc;
111 if (err) 111 if (err)
112 __ext3_std_error(sb, where, err); 112 __ext4_std_error(sb, where, err);
113 return err; 113 return err;
114} 114}
115 115
116void ext3_journal_abort_handle(const char *caller, const char *err_fn, 116void ext4_journal_abort_handle(const char *caller, const char *err_fn,
117 struct buffer_head *bh, handle_t *handle, int err) 117 struct buffer_head *bh, handle_t *handle, int err)
118{ 118{
119 char nbuf[16]; 119 char nbuf[16];
120 const char *errstr = ext3_decode_error(NULL, err, nbuf); 120 const char *errstr = ext4_decode_error(NULL, err, nbuf);
121 121
122 if (bh) 122 if (bh)
123 BUFFER_TRACE(bh, "abort"); 123 BUFFER_TRACE(bh, "abort");
@@ -138,7 +138,7 @@ void ext3_journal_abort_handle(const char *caller, const char *err_fn,
138 * inconsistencies detected or read IO failures. 138 * inconsistencies detected or read IO failures.
139 * 139 *
140 * On ext2, we can store the error state of the filesystem in the 140 * On ext2, we can store the error state of the filesystem in the
141 * superblock. That is not possible on ext3, because we may have other 141 * superblock. That is not possible on ext4, because we may have other
142 * write ordering constraints on the superblock which prevent us from 142 * write ordering constraints on the superblock which prevent us from
143 * writing it out straight away; and given that the journal is about to 143 * writing it out straight away; and given that the journal is about to
144 * be aborted, we can't rely on the current, or future, transactions to 144 * be aborted, we can't rely on the current, or future, transactions to
@@ -149,20 +149,20 @@ void ext3_journal_abort_handle(const char *caller, const char *err_fn,
149 * that error until we've noted it down and cleared it. 149 * that error until we've noted it down and cleared it.
150 */ 150 */
151 151
152static void ext3_handle_error(struct super_block *sb) 152static void ext4_handle_error(struct super_block *sb)
153{ 153{
154 struct ext3_super_block *es = EXT3_SB(sb)->s_es; 154 struct ext4_super_block *es = EXT4_SB(sb)->s_es;
155 155
156 EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; 156 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
157 es->s_state |= cpu_to_le16(EXT3_ERROR_FS); 157 es->s_state |= cpu_to_le16(EXT4_ERROR_FS);
158 158
159 if (sb->s_flags & MS_RDONLY) 159 if (sb->s_flags & MS_RDONLY)
160 return; 160 return;
161 161
162 if (!test_opt (sb, ERRORS_CONT)) { 162 if (!test_opt (sb, ERRORS_CONT)) {
163 journal_t *journal = EXT3_SB(sb)->s_journal; 163 journal_t *journal = EXT4_SB(sb)->s_journal;
164 164
165 EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT; 165 EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT;
166 if (journal) 166 if (journal)
167 journal_abort(journal, -EIO); 167 journal_abort(journal, -EIO);
168 } 168 }
@@ -170,27 +170,27 @@ static void ext3_handle_error(struct super_block *sb)
170 printk (KERN_CRIT "Remounting filesystem read-only\n"); 170 printk (KERN_CRIT "Remounting filesystem read-only\n");
171 sb->s_flags |= MS_RDONLY; 171 sb->s_flags |= MS_RDONLY;
172 } 172 }
173 ext3_commit_super(sb, es, 1); 173 ext4_commit_super(sb, es, 1);
174 if (test_opt(sb, ERRORS_PANIC)) 174 if (test_opt(sb, ERRORS_PANIC))
175 panic("EXT3-fs (device %s): panic forced after error\n", 175 panic("EXT4-fs (device %s): panic forced after error\n",
176 sb->s_id); 176 sb->s_id);
177} 177}
178 178
179void ext3_error (struct super_block * sb, const char * function, 179void ext4_error (struct super_block * sb, const char * function,
180 const char * fmt, ...) 180 const char * fmt, ...)
181{ 181{
182 va_list args; 182 va_list args;
183 183
184 va_start(args, fmt); 184 va_start(args, fmt);
185 printk(KERN_CRIT "EXT3-fs error (device %s): %s: ",sb->s_id, function); 185 printk(KERN_CRIT "EXT4-fs error (device %s): %s: ",sb->s_id, function);
186 vprintk(fmt, args); 186 vprintk(fmt, args);
187 printk("\n"); 187 printk("\n");
188 va_end(args); 188 va_end(args);
189 189
190 ext3_handle_error(sb); 190 ext4_handle_error(sb);
191} 191}
192 192
193static const char *ext3_decode_error(struct super_block * sb, int errno, 193static const char *ext4_decode_error(struct super_block * sb, int errno,
194 char nbuf[16]) 194 char nbuf[16])
195{ 195{
196 char *errstr = NULL; 196 char *errstr = NULL;
@@ -203,7 +203,7 @@ static const char *ext3_decode_error(struct super_block * sb, int errno,
203 errstr = "Out of memory"; 203 errstr = "Out of memory";
204 break; 204 break;
205 case -EROFS: 205 case -EROFS:
206 if (!sb || EXT3_SB(sb)->s_journal->j_flags & JFS_ABORT) 206 if (!sb || EXT4_SB(sb)->s_journal->j_flags & JFS_ABORT)
207 errstr = "Journal has aborted"; 207 errstr = "Journal has aborted";
208 else 208 else
209 errstr = "Readonly filesystem"; 209 errstr = "Readonly filesystem";
@@ -223,10 +223,10 @@ static const char *ext3_decode_error(struct super_block * sb, int errno,
223 return errstr; 223 return errstr;
224} 224}
225 225
226/* __ext3_std_error decodes expected errors from journaling functions 226/* __ext4_std_error decodes expected errors from journaling functions
227 * automatically and invokes the appropriate error response. */ 227 * automatically and invokes the appropriate error response. */
228 228
229void __ext3_std_error (struct super_block * sb, const char * function, 229void __ext4_std_error (struct super_block * sb, const char * function,
230 int errno) 230 int errno)
231{ 231{
232 char nbuf[16]; 232 char nbuf[16];
@@ -239,15 +239,15 @@ void __ext3_std_error (struct super_block * sb, const char * function,
239 (sb->s_flags & MS_RDONLY)) 239 (sb->s_flags & MS_RDONLY))
240 return; 240 return;
241 241
242 errstr = ext3_decode_error(sb, errno, nbuf); 242 errstr = ext4_decode_error(sb, errno, nbuf);
243 printk (KERN_CRIT "EXT3-fs error (device %s) in %s: %s\n", 243 printk (KERN_CRIT "EXT4-fs error (device %s) in %s: %s\n",
244 sb->s_id, function, errstr); 244 sb->s_id, function, errstr);
245 245
246 ext3_handle_error(sb); 246 ext4_handle_error(sb);
247} 247}
248 248
249/* 249/*
250 * ext3_abort is a much stronger failure handler than ext3_error. The 250 * ext4_abort is a much stronger failure handler than ext4_error. The
251 * abort function may be used to deal with unrecoverable failures such 251 * abort function may be used to deal with unrecoverable failures such
252 * as journal IO errors or ENOMEM at a critical moment in log management. 252 * as journal IO errors or ENOMEM at a critical moment in log management.
253 * 253 *
@@ -256,60 +256,60 @@ void __ext3_std_error (struct super_block * sb, const char * function,
256 * case we take the easy way out and panic immediately. 256 * case we take the easy way out and panic immediately.
257 */ 257 */
258 258
259void ext3_abort (struct super_block * sb, const char * function, 259void ext4_abort (struct super_block * sb, const char * function,
260 const char * fmt, ...) 260 const char * fmt, ...)
261{ 261{
262 va_list args; 262 va_list args;
263 263
264 printk (KERN_CRIT "ext3_abort called.\n"); 264 printk (KERN_CRIT "ext4_abort called.\n");
265 265
266 va_start(args, fmt); 266 va_start(args, fmt);
267 printk(KERN_CRIT "EXT3-fs error (device %s): %s: ",sb->s_id, function); 267 printk(KERN_CRIT "EXT4-fs error (device %s): %s: ",sb->s_id, function);
268 vprintk(fmt, args); 268 vprintk(fmt, args);
269 printk("\n"); 269 printk("\n");
270 va_end(args); 270 va_end(args);
271 271
272 if (test_opt(sb, ERRORS_PANIC)) 272 if (test_opt(sb, ERRORS_PANIC))
273 panic("EXT3-fs panic from previous error\n"); 273 panic("EXT4-fs panic from previous error\n");
274 274
275 if (sb->s_flags & MS_RDONLY) 275 if (sb->s_flags & MS_RDONLY)
276 return; 276 return;
277 277
278 printk(KERN_CRIT "Remounting filesystem read-only\n"); 278 printk(KERN_CRIT "Remounting filesystem read-only\n");
279 EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; 279 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
280 sb->s_flags |= MS_RDONLY; 280 sb->s_flags |= MS_RDONLY;
281 EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT; 281 EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT;
282 journal_abort(EXT3_SB(sb)->s_journal, -EIO); 282 journal_abort(EXT4_SB(sb)->s_journal, -EIO);
283} 283}
284 284
285void ext3_warning (struct super_block * sb, const char * function, 285void ext4_warning (struct super_block * sb, const char * function,
286 const char * fmt, ...) 286 const char * fmt, ...)
287{ 287{
288 va_list args; 288 va_list args;
289 289
290 va_start(args, fmt); 290 va_start(args, fmt);
291 printk(KERN_WARNING "EXT3-fs warning (device %s): %s: ", 291 printk(KERN_WARNING "EXT4-fs warning (device %s): %s: ",
292 sb->s_id, function); 292 sb->s_id, function);
293 vprintk(fmt, args); 293 vprintk(fmt, args);
294 printk("\n"); 294 printk("\n");
295 va_end(args); 295 va_end(args);
296} 296}
297 297
298void ext3_update_dynamic_rev(struct super_block *sb) 298void ext4_update_dynamic_rev(struct super_block *sb)
299{ 299{
300 struct ext3_super_block *es = EXT3_SB(sb)->s_es; 300 struct ext4_super_block *es = EXT4_SB(sb)->s_es;
301 301
302 if (le32_to_cpu(es->s_rev_level) > EXT3_GOOD_OLD_REV) 302 if (le32_to_cpu(es->s_rev_level) > EXT4_GOOD_OLD_REV)
303 return; 303 return;
304 304
305 ext3_warning(sb, __FUNCTION__, 305 ext4_warning(sb, __FUNCTION__,
306 "updating to rev %d because of new feature flag, " 306 "updating to rev %d because of new feature flag, "
307 "running e2fsck is recommended", 307 "running e2fsck is recommended",
308 EXT3_DYNAMIC_REV); 308 EXT4_DYNAMIC_REV);
309 309
310 es->s_first_ino = cpu_to_le32(EXT3_GOOD_OLD_FIRST_INO); 310 es->s_first_ino = cpu_to_le32(EXT4_GOOD_OLD_FIRST_INO);
311 es->s_inode_size = cpu_to_le16(EXT3_GOOD_OLD_INODE_SIZE); 311 es->s_inode_size = cpu_to_le16(EXT4_GOOD_OLD_INODE_SIZE);
312 es->s_rev_level = cpu_to_le32(EXT3_DYNAMIC_REV); 312 es->s_rev_level = cpu_to_le32(EXT4_DYNAMIC_REV);
313 /* leave es->s_feature_*compat flags alone */ 313 /* leave es->s_feature_*compat flags alone */
314 /* es->s_uuid will be set by e2fsck if empty */ 314 /* es->s_uuid will be set by e2fsck if empty */
315 315
@@ -323,7 +323,7 @@ void ext3_update_dynamic_rev(struct super_block *sb)
323/* 323/*
324 * Open the external journal device 324 * Open the external journal device
325 */ 325 */
326static struct block_device *ext3_blkdev_get(dev_t dev) 326static struct block_device *ext4_blkdev_get(dev_t dev)
327{ 327{
328 struct block_device *bdev; 328 struct block_device *bdev;
329 char b[BDEVNAME_SIZE]; 329 char b[BDEVNAME_SIZE];
@@ -334,7 +334,7 @@ static struct block_device *ext3_blkdev_get(dev_t dev)
334 return bdev; 334 return bdev;
335 335
336fail: 336fail:
337 printk(KERN_ERR "EXT3: failed to open journal device %s: %ld\n", 337 printk(KERN_ERR "EXT4: failed to open journal device %s: %ld\n",
338 __bdevname(dev, b), PTR_ERR(bdev)); 338 __bdevname(dev, b), PTR_ERR(bdev));
339 return NULL; 339 return NULL;
340} 340}
@@ -342,20 +342,20 @@ fail:
342/* 342/*
343 * Release the journal device 343 * Release the journal device
344 */ 344 */
345static int ext3_blkdev_put(struct block_device *bdev) 345static int ext4_blkdev_put(struct block_device *bdev)
346{ 346{
347 bd_release(bdev); 347 bd_release(bdev);
348 return blkdev_put(bdev); 348 return blkdev_put(bdev);
349} 349}
350 350
351static int ext3_blkdev_remove(struct ext3_sb_info *sbi) 351static int ext4_blkdev_remove(struct ext4_sb_info *sbi)
352{ 352{
353 struct block_device *bdev; 353 struct block_device *bdev;
354 int ret = -ENODEV; 354 int ret = -ENODEV;
355 355
356 bdev = sbi->journal_bdev; 356 bdev = sbi->journal_bdev;
357 if (bdev) { 357 if (bdev) {
358 ret = ext3_blkdev_put(bdev); 358 ret = ext4_blkdev_put(bdev);
359 sbi->journal_bdev = NULL; 359 sbi->journal_bdev = NULL;
360 } 360 }
361 return ret; 361 return ret;
@@ -363,10 +363,10 @@ static int ext3_blkdev_remove(struct ext3_sb_info *sbi)
363 363
364static inline struct inode *orphan_list_entry(struct list_head *l) 364static inline struct inode *orphan_list_entry(struct list_head *l)
365{ 365{
366 return &list_entry(l, struct ext3_inode_info, i_orphan)->vfs_inode; 366 return &list_entry(l, struct ext4_inode_info, i_orphan)->vfs_inode;
367} 367}
368 368
369static void dump_orphan_list(struct super_block *sb, struct ext3_sb_info *sbi) 369static void dump_orphan_list(struct super_block *sb, struct ext4_sb_info *sbi)
370{ 370{
371 struct list_head *l; 371 struct list_head *l;
372 372
@@ -384,20 +384,20 @@ static void dump_orphan_list(struct super_block *sb, struct ext3_sb_info *sbi)
384 } 384 }
385} 385}
386 386
387static void ext3_put_super (struct super_block * sb) 387static void ext4_put_super (struct super_block * sb)
388{ 388{
389 struct ext3_sb_info *sbi = EXT3_SB(sb); 389 struct ext4_sb_info *sbi = EXT4_SB(sb);
390 struct ext3_super_block *es = sbi->s_es; 390 struct ext4_super_block *es = sbi->s_es;
391 int i; 391 int i;
392 392
393 ext3_xattr_put_super(sb); 393 ext4_xattr_put_super(sb);
394 journal_destroy(sbi->s_journal); 394 journal_destroy(sbi->s_journal);
395 if (!(sb->s_flags & MS_RDONLY)) { 395 if (!(sb->s_flags & MS_RDONLY)) {
396 EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); 396 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
397 es->s_state = cpu_to_le16(sbi->s_mount_state); 397 es->s_state = cpu_to_le16(sbi->s_mount_state);
398 BUFFER_TRACE(sbi->s_sbh, "marking dirty"); 398 BUFFER_TRACE(sbi->s_sbh, "marking dirty");
399 mark_buffer_dirty(sbi->s_sbh); 399 mark_buffer_dirty(sbi->s_sbh);
400 ext3_commit_super(sb, es, 1); 400 ext4_commit_super(sb, es, 1);
401 } 401 }
402 402
403 for (i = 0; i < sbi->s_gdb_count; i++) 403 for (i = 0; i < sbi->s_gdb_count; i++)
@@ -429,47 +429,47 @@ static void ext3_put_super (struct super_block * sb)
429 */ 429 */
430 sync_blockdev(sbi->journal_bdev); 430 sync_blockdev(sbi->journal_bdev);
431 invalidate_bdev(sbi->journal_bdev, 0); 431 invalidate_bdev(sbi->journal_bdev, 0);
432 ext3_blkdev_remove(sbi); 432 ext4_blkdev_remove(sbi);
433 } 433 }
434 sb->s_fs_info = NULL; 434 sb->s_fs_info = NULL;
435 kfree(sbi); 435 kfree(sbi);
436 return; 436 return;
437} 437}
438 438
439static kmem_cache_t *ext3_inode_cachep; 439static kmem_cache_t *ext4_inode_cachep;
440 440
441/* 441/*
442 * Called inside transaction, so use GFP_NOFS 442 * Called inside transaction, so use GFP_NOFS
443 */ 443 */
444static struct inode *ext3_alloc_inode(struct super_block *sb) 444static struct inode *ext4_alloc_inode(struct super_block *sb)
445{ 445{
446 struct ext3_inode_info *ei; 446 struct ext4_inode_info *ei;
447 447
448 ei = kmem_cache_alloc(ext3_inode_cachep, SLAB_NOFS); 448 ei = kmem_cache_alloc(ext4_inode_cachep, SLAB_NOFS);
449 if (!ei) 449 if (!ei)
450 return NULL; 450 return NULL;
451#ifdef CONFIG_EXT3_FS_POSIX_ACL 451#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
452 ei->i_acl = EXT3_ACL_NOT_CACHED; 452 ei->i_acl = EXT4_ACL_NOT_CACHED;
453 ei->i_default_acl = EXT3_ACL_NOT_CACHED; 453 ei->i_default_acl = EXT4_ACL_NOT_CACHED;
454#endif 454#endif
455 ei->i_block_alloc_info = NULL; 455 ei->i_block_alloc_info = NULL;
456 ei->vfs_inode.i_version = 1; 456 ei->vfs_inode.i_version = 1;
457 return &ei->vfs_inode; 457 return &ei->vfs_inode;
458} 458}
459 459
460static void ext3_destroy_inode(struct inode *inode) 460static void ext4_destroy_inode(struct inode *inode)
461{ 461{
462 kmem_cache_free(ext3_inode_cachep, EXT3_I(inode)); 462 kmem_cache_free(ext4_inode_cachep, EXT4_I(inode));
463} 463}
464 464
465static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 465static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
466{ 466{
467 struct ext3_inode_info *ei = (struct ext3_inode_info *) foo; 467 struct ext4_inode_info *ei = (struct ext4_inode_info *) foo;
468 468
469 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == 469 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
470 SLAB_CTOR_CONSTRUCTOR) { 470 SLAB_CTOR_CONSTRUCTOR) {
471 INIT_LIST_HEAD(&ei->i_orphan); 471 INIT_LIST_HEAD(&ei->i_orphan);
472#ifdef CONFIG_EXT3_FS_XATTR 472#ifdef CONFIG_EXT4DEV_FS_XATTR
473 init_rwsem(&ei->xattr_sem); 473 init_rwsem(&ei->xattr_sem);
474#endif 474#endif
475 mutex_init(&ei->truncate_mutex); 475 mutex_init(&ei->truncate_mutex);
@@ -479,46 +479,46 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
479 479
480static int init_inodecache(void) 480static int init_inodecache(void)
481{ 481{
482 ext3_inode_cachep = kmem_cache_create("ext3_inode_cache", 482 ext4_inode_cachep = kmem_cache_create("ext4_inode_cache",
483 sizeof(struct ext3_inode_info), 483 sizeof(struct ext4_inode_info),
484 0, (SLAB_RECLAIM_ACCOUNT| 484 0, (SLAB_RECLAIM_ACCOUNT|
485 SLAB_MEM_SPREAD), 485 SLAB_MEM_SPREAD),
486 init_once, NULL); 486 init_once, NULL);
487 if (ext3_inode_cachep == NULL) 487 if (ext4_inode_cachep == NULL)
488 return -ENOMEM; 488 return -ENOMEM;
489 return 0; 489 return 0;
490} 490}
491 491
492static void destroy_inodecache(void) 492static void destroy_inodecache(void)
493{ 493{
494 kmem_cache_destroy(ext3_inode_cachep); 494 kmem_cache_destroy(ext4_inode_cachep);
495} 495}
496 496
497static void ext3_clear_inode(struct inode *inode) 497static void ext4_clear_inode(struct inode *inode)
498{ 498{
499 struct ext3_block_alloc_info *rsv = EXT3_I(inode)->i_block_alloc_info; 499 struct ext4_block_alloc_info *rsv = EXT4_I(inode)->i_block_alloc_info;
500#ifdef CONFIG_EXT3_FS_POSIX_ACL 500#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
501 if (EXT3_I(inode)->i_acl && 501 if (EXT4_I(inode)->i_acl &&
502 EXT3_I(inode)->i_acl != EXT3_ACL_NOT_CACHED) { 502 EXT4_I(inode)->i_acl != EXT4_ACL_NOT_CACHED) {
503 posix_acl_release(EXT3_I(inode)->i_acl); 503 posix_acl_release(EXT4_I(inode)->i_acl);
504 EXT3_I(inode)->i_acl = EXT3_ACL_NOT_CACHED; 504 EXT4_I(inode)->i_acl = EXT4_ACL_NOT_CACHED;
505 } 505 }
506 if (EXT3_I(inode)->i_default_acl && 506 if (EXT4_I(inode)->i_default_acl &&
507 EXT3_I(inode)->i_default_acl != EXT3_ACL_NOT_CACHED) { 507 EXT4_I(inode)->i_default_acl != EXT4_ACL_NOT_CACHED) {
508 posix_acl_release(EXT3_I(inode)->i_default_acl); 508 posix_acl_release(EXT4_I(inode)->i_default_acl);
509 EXT3_I(inode)->i_default_acl = EXT3_ACL_NOT_CACHED; 509 EXT4_I(inode)->i_default_acl = EXT4_ACL_NOT_CACHED;
510 } 510 }
511#endif 511#endif
512 ext3_discard_reservation(inode); 512 ext4_discard_reservation(inode);
513 EXT3_I(inode)->i_block_alloc_info = NULL; 513 EXT4_I(inode)->i_block_alloc_info = NULL;
514 if (unlikely(rsv)) 514 if (unlikely(rsv))
515 kfree(rsv); 515 kfree(rsv);
516} 516}
517 517
518static inline void ext3_show_quota_options(struct seq_file *seq, struct super_block *sb) 518static inline void ext4_show_quota_options(struct seq_file *seq, struct super_block *sb)
519{ 519{
520#if defined(CONFIG_QUOTA) 520#if defined(CONFIG_QUOTA)
521 struct ext3_sb_info *sbi = EXT3_SB(sb); 521 struct ext4_sb_info *sbi = EXT4_SB(sb);
522 522
523 if (sbi->s_jquota_fmt) 523 if (sbi->s_jquota_fmt)
524 seq_printf(seq, ",jqfmt=%s", 524 seq_printf(seq, ",jqfmt=%s",
@@ -530,32 +530,32 @@ static inline void ext3_show_quota_options(struct seq_file *seq, struct super_bl
530 if (sbi->s_qf_names[GRPQUOTA]) 530 if (sbi->s_qf_names[GRPQUOTA])
531 seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]); 531 seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]);
532 532
533 if (sbi->s_mount_opt & EXT3_MOUNT_USRQUOTA) 533 if (sbi->s_mount_opt & EXT4_MOUNT_USRQUOTA)
534 seq_puts(seq, ",usrquota"); 534 seq_puts(seq, ",usrquota");
535 535
536 if (sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA) 536 if (sbi->s_mount_opt & EXT4_MOUNT_GRPQUOTA)
537 seq_puts(seq, ",grpquota"); 537 seq_puts(seq, ",grpquota");
538#endif 538#endif
539} 539}
540 540
541static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs) 541static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
542{ 542{
543 struct super_block *sb = vfs->mnt_sb; 543 struct super_block *sb = vfs->mnt_sb;
544 544
545 if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA) 545 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)
546 seq_puts(seq, ",data=journal"); 546 seq_puts(seq, ",data=journal");
547 else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA) 547 else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA)
548 seq_puts(seq, ",data=ordered"); 548 seq_puts(seq, ",data=ordered");
549 else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA) 549 else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)
550 seq_puts(seq, ",data=writeback"); 550 seq_puts(seq, ",data=writeback");
551 551
552 ext3_show_quota_options(seq, sb); 552 ext4_show_quota_options(seq, sb);
553 553
554 return 0; 554 return 0;
555} 555}
556 556
557 557
558static struct dentry *ext3_get_dentry(struct super_block *sb, void *vobjp) 558static struct dentry *ext4_get_dentry(struct super_block *sb, void *vobjp)
559{ 559{
560 __u32 *objp = vobjp; 560 __u32 *objp = vobjp;
561 unsigned long ino = objp[0]; 561 unsigned long ino = objp[0];
@@ -563,14 +563,14 @@ static struct dentry *ext3_get_dentry(struct super_block *sb, void *vobjp)
563 struct inode *inode; 563 struct inode *inode;
564 struct dentry *result; 564 struct dentry *result;
565 565
566 if (ino < EXT3_FIRST_INO(sb) && ino != EXT3_ROOT_INO) 566 if (ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO)
567 return ERR_PTR(-ESTALE); 567 return ERR_PTR(-ESTALE);
568 if (ino > le32_to_cpu(EXT3_SB(sb)->s_es->s_inodes_count)) 568 if (ino > le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count))
569 return ERR_PTR(-ESTALE); 569 return ERR_PTR(-ESTALE);
570 570
571 /* iget isn't really right if the inode is currently unallocated!! 571 /* iget isn't really right if the inode is currently unallocated!!
572 * 572 *
573 * ext3_read_inode will return a bad_inode if the inode had been 573 * ext4_read_inode will return a bad_inode if the inode had been
574 * deleted, so we should be safe. 574 * deleted, so we should be safe.
575 * 575 *
576 * Currently we don't know the generation for parent directory, so 576 * Currently we don't know the generation for parent directory, so
@@ -599,37 +599,37 @@ static struct dentry *ext3_get_dentry(struct super_block *sb, void *vobjp)
599#define QTYPE2NAME(t) ((t)==USRQUOTA?"user":"group") 599#define QTYPE2NAME(t) ((t)==USRQUOTA?"user":"group")
600#define QTYPE2MOPT(on, t) ((t)==USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA)) 600#define QTYPE2MOPT(on, t) ((t)==USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA))
601 601
602static int ext3_dquot_initialize(struct inode *inode, int type); 602static int ext4_dquot_initialize(struct inode *inode, int type);
603static int ext3_dquot_drop(struct inode *inode); 603static int ext4_dquot_drop(struct inode *inode);
604static int ext3_write_dquot(struct dquot *dquot); 604static int ext4_write_dquot(struct dquot *dquot);
605static int ext3_acquire_dquot(struct dquot *dquot); 605static int ext4_acquire_dquot(struct dquot *dquot);
606static int ext3_release_dquot(struct dquot *dquot); 606static int ext4_release_dquot(struct dquot *dquot);
607static int ext3_mark_dquot_dirty(struct dquot *dquot); 607static int ext4_mark_dquot_dirty(struct dquot *dquot);
608static int ext3_write_info(struct super_block *sb, int type); 608static int ext4_write_info(struct super_block *sb, int type);
609static int ext3_quota_on(struct super_block *sb, int type, int format_id, char *path); 609static int ext4_quota_on(struct super_block *sb, int type, int format_id, char *path);
610static int ext3_quota_on_mount(struct super_block *sb, int type); 610static int ext4_quota_on_mount(struct super_block *sb, int type);
611static ssize_t ext3_quota_read(struct super_block *sb, int type, char *data, 611static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data,
612 size_t len, loff_t off); 612 size_t len, loff_t off);
613static ssize_t ext3_quota_write(struct super_block *sb, int type, 613static ssize_t ext4_quota_write(struct super_block *sb, int type,
614 const char *data, size_t len, loff_t off); 614 const char *data, size_t len, loff_t off);
615 615
616static struct dquot_operations ext3_quota_operations = { 616static struct dquot_operations ext4_quota_operations = {
617 .initialize = ext3_dquot_initialize, 617 .initialize = ext4_dquot_initialize,
618 .drop = ext3_dquot_drop, 618 .drop = ext4_dquot_drop,
619 .alloc_space = dquot_alloc_space, 619 .alloc_space = dquot_alloc_space,
620 .alloc_inode = dquot_alloc_inode, 620 .alloc_inode = dquot_alloc_inode,
621 .free_space = dquot_free_space, 621 .free_space = dquot_free_space,
622 .free_inode = dquot_free_inode, 622 .free_inode = dquot_free_inode,
623 .transfer = dquot_transfer, 623 .transfer = dquot_transfer,
624 .write_dquot = ext3_write_dquot, 624 .write_dquot = ext4_write_dquot,
625 .acquire_dquot = ext3_acquire_dquot, 625 .acquire_dquot = ext4_acquire_dquot,
626 .release_dquot = ext3_release_dquot, 626 .release_dquot = ext4_release_dquot,
627 .mark_dirty = ext3_mark_dquot_dirty, 627 .mark_dirty = ext4_mark_dquot_dirty,
628 .write_info = ext3_write_info 628 .write_info = ext4_write_info
629}; 629};
630 630
631static struct quotactl_ops ext3_qctl_operations = { 631static struct quotactl_ops ext4_qctl_operations = {
632 .quota_on = ext3_quota_on, 632 .quota_on = ext4_quota_on,
633 .quota_off = vfs_quota_off, 633 .quota_off = vfs_quota_off,
634 .quota_sync = vfs_quota_sync, 634 .quota_sync = vfs_quota_sync,
635 .get_info = vfs_get_dqinfo, 635 .get_info = vfs_get_dqinfo,
@@ -639,31 +639,31 @@ static struct quotactl_ops ext3_qctl_operations = {
639}; 639};
640#endif 640#endif
641 641
642static struct super_operations ext3_sops = { 642static struct super_operations ext4_sops = {
643 .alloc_inode = ext3_alloc_inode, 643 .alloc_inode = ext4_alloc_inode,
644 .destroy_inode = ext3_destroy_inode, 644 .destroy_inode = ext4_destroy_inode,
645 .read_inode = ext3_read_inode, 645 .read_inode = ext4_read_inode,
646 .write_inode = ext3_write_inode, 646 .write_inode = ext4_write_inode,
647 .dirty_inode = ext3_dirty_inode, 647 .dirty_inode = ext4_dirty_inode,
648 .delete_inode = ext3_delete_inode, 648 .delete_inode = ext4_delete_inode,
649 .put_super = ext3_put_super, 649 .put_super = ext4_put_super,
650 .write_super = ext3_write_super, 650 .write_super = ext4_write_super,
651 .sync_fs = ext3_sync_fs, 651 .sync_fs = ext4_sync_fs,
652 .write_super_lockfs = ext3_write_super_lockfs, 652 .write_super_lockfs = ext4_write_super_lockfs,
653 .unlockfs = ext3_unlockfs, 653 .unlockfs = ext4_unlockfs,
654 .statfs = ext3_statfs, 654 .statfs = ext4_statfs,
655 .remount_fs = ext3_remount, 655 .remount_fs = ext4_remount,
656 .clear_inode = ext3_clear_inode, 656 .clear_inode = ext4_clear_inode,
657 .show_options = ext3_show_options, 657 .show_options = ext4_show_options,
658#ifdef CONFIG_QUOTA 658#ifdef CONFIG_QUOTA
659 .quota_read = ext3_quota_read, 659 .quota_read = ext4_quota_read,
660 .quota_write = ext3_quota_write, 660 .quota_write = ext4_quota_write,
661#endif 661#endif
662}; 662};
663 663
664static struct export_operations ext3_export_ops = { 664static struct export_operations ext4_export_ops = {
665 .get_parent = ext3_get_parent, 665 .get_parent = ext4_get_parent,
666 .get_dentry = ext3_get_dentry, 666 .get_dentry = ext4_get_dentry,
667}; 667};
668 668
669enum { 669enum {
@@ -731,18 +731,18 @@ static match_table_t tokens = {
731 {Opt_resize, "resize"}, 731 {Opt_resize, "resize"},
732}; 732};
733 733
734static ext3_fsblk_t get_sb_block(void **data) 734static ext4_fsblk_t get_sb_block(void **data)
735{ 735{
736 ext3_fsblk_t sb_block; 736 ext4_fsblk_t sb_block;
737 char *options = (char *) *data; 737 char *options = (char *) *data;
738 738
739 if (!options || strncmp(options, "sb=", 3) != 0) 739 if (!options || strncmp(options, "sb=", 3) != 0)
740 return 1; /* Default location */ 740 return 1; /* Default location */
741 options += 3; 741 options += 3;
742 /*todo: use simple_strtoll with >32bit ext3 */ 742 /*todo: use simple_strtoll with >32bit ext4 */
743 sb_block = simple_strtoul(options, &options, 0); 743 sb_block = simple_strtoul(options, &options, 0);
744 if (*options && *options != ',') { 744 if (*options && *options != ',') {
745 printk("EXT3-fs: Invalid sb specification: %s\n", 745 printk("EXT4-fs: Invalid sb specification: %s\n",
746 (char *) *data); 746 (char *) *data);
747 return 1; 747 return 1;
748 } 748 }
@@ -754,9 +754,9 @@ static ext3_fsblk_t get_sb_block(void **data)
754 754
755static int parse_options (char *options, struct super_block *sb, 755static int parse_options (char *options, struct super_block *sb,
756 unsigned int *inum, unsigned long *journal_devnum, 756 unsigned int *inum, unsigned long *journal_devnum,
757 ext3_fsblk_t *n_blocks_count, int is_remount) 757 ext4_fsblk_t *n_blocks_count, int is_remount)
758{ 758{
759 struct ext3_sb_info *sbi = EXT3_SB(sb); 759 struct ext4_sb_info *sbi = EXT4_SB(sb);
760 char * p; 760 char * p;
761 substring_t args[MAX_OPT_ARGS]; 761 substring_t args[MAX_OPT_ARGS];
762 int data_opt = 0; 762 int data_opt = 0;
@@ -832,7 +832,7 @@ static int parse_options (char *options, struct super_block *sb,
832 case Opt_orlov: 832 case Opt_orlov:
833 clear_opt (sbi->s_mount_opt, OLDALLOC); 833 clear_opt (sbi->s_mount_opt, OLDALLOC);
834 break; 834 break;
835#ifdef CONFIG_EXT3_FS_XATTR 835#ifdef CONFIG_EXT4DEV_FS_XATTR
836 case Opt_user_xattr: 836 case Opt_user_xattr:
837 set_opt (sbi->s_mount_opt, XATTR_USER); 837 set_opt (sbi->s_mount_opt, XATTR_USER);
838 break; 838 break;
@@ -842,10 +842,10 @@ static int parse_options (char *options, struct super_block *sb,
842#else 842#else
843 case Opt_user_xattr: 843 case Opt_user_xattr:
844 case Opt_nouser_xattr: 844 case Opt_nouser_xattr:
845 printk("EXT3 (no)user_xattr options not supported\n"); 845 printk("EXT4 (no)user_xattr options not supported\n");
846 break; 846 break;
847#endif 847#endif
848#ifdef CONFIG_EXT3_FS_POSIX_ACL 848#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
849 case Opt_acl: 849 case Opt_acl:
850 set_opt(sbi->s_mount_opt, POSIX_ACL); 850 set_opt(sbi->s_mount_opt, POSIX_ACL);
851 break; 851 break;
@@ -855,7 +855,7 @@ static int parse_options (char *options, struct super_block *sb,
855#else 855#else
856 case Opt_acl: 856 case Opt_acl:
857 case Opt_noacl: 857 case Opt_noacl:
858 printk("EXT3 (no)acl options not supported\n"); 858 printk("EXT4 (no)acl options not supported\n");
859 break; 859 break;
860#endif 860#endif
861 case Opt_reservation: 861 case Opt_reservation:
@@ -871,7 +871,7 @@ static int parse_options (char *options, struct super_block *sb,
871 user to specify an existing inode to be the 871 user to specify an existing inode to be the
872 journal file. */ 872 journal file. */
873 if (is_remount) { 873 if (is_remount) {
874 printk(KERN_ERR "EXT3-fs: cannot specify " 874 printk(KERN_ERR "EXT4-fs: cannot specify "
875 "journal on remount\n"); 875 "journal on remount\n");
876 return 0; 876 return 0;
877 } 877 }
@@ -879,7 +879,7 @@ static int parse_options (char *options, struct super_block *sb,
879 break; 879 break;
880 case Opt_journal_inum: 880 case Opt_journal_inum:
881 if (is_remount) { 881 if (is_remount) {
882 printk(KERN_ERR "EXT3-fs: cannot specify " 882 printk(KERN_ERR "EXT4-fs: cannot specify "
883 "journal on remount\n"); 883 "journal on remount\n");
884 return 0; 884 return 0;
885 } 885 }
@@ -889,7 +889,7 @@ static int parse_options (char *options, struct super_block *sb,
889 break; 889 break;
890 case Opt_journal_dev: 890 case Opt_journal_dev:
891 if (is_remount) { 891 if (is_remount) {
892 printk(KERN_ERR "EXT3-fs: cannot specify " 892 printk(KERN_ERR "EXT4-fs: cannot specify "
893 "journal on remount\n"); 893 "journal on remount\n");
894 return 0; 894 return 0;
895 } 895 }
@@ -910,24 +910,24 @@ static int parse_options (char *options, struct super_block *sb,
910 sbi->s_commit_interval = HZ * option; 910 sbi->s_commit_interval = HZ * option;
911 break; 911 break;
912 case Opt_data_journal: 912 case Opt_data_journal:
913 data_opt = EXT3_MOUNT_JOURNAL_DATA; 913 data_opt = EXT4_MOUNT_JOURNAL_DATA;
914 goto datacheck; 914 goto datacheck;
915 case Opt_data_ordered: 915 case Opt_data_ordered:
916 data_opt = EXT3_MOUNT_ORDERED_DATA; 916 data_opt = EXT4_MOUNT_ORDERED_DATA;
917 goto datacheck; 917 goto datacheck;
918 case Opt_data_writeback: 918 case Opt_data_writeback:
919 data_opt = EXT3_MOUNT_WRITEBACK_DATA; 919 data_opt = EXT4_MOUNT_WRITEBACK_DATA;
920 datacheck: 920 datacheck:
921 if (is_remount) { 921 if (is_remount) {
922 if ((sbi->s_mount_opt & EXT3_MOUNT_DATA_FLAGS) 922 if ((sbi->s_mount_opt & EXT4_MOUNT_DATA_FLAGS)
923 != data_opt) { 923 != data_opt) {
924 printk(KERN_ERR 924 printk(KERN_ERR
925 "EXT3-fs: cannot change data " 925 "EXT4-fs: cannot change data "
926 "mode on remount\n"); 926 "mode on remount\n");
927 return 0; 927 return 0;
928 } 928 }
929 } else { 929 } else {
930 sbi->s_mount_opt &= ~EXT3_MOUNT_DATA_FLAGS; 930 sbi->s_mount_opt &= ~EXT4_MOUNT_DATA_FLAGS;
931 sbi->s_mount_opt |= data_opt; 931 sbi->s_mount_opt |= data_opt;
932 } 932 }
933 break; 933 break;
@@ -940,21 +940,21 @@ static int parse_options (char *options, struct super_block *sb,
940set_qf_name: 940set_qf_name:
941 if (sb_any_quota_enabled(sb)) { 941 if (sb_any_quota_enabled(sb)) {
942 printk(KERN_ERR 942 printk(KERN_ERR
943 "EXT3-fs: Cannot change journalled " 943 "EXT4-fs: Cannot change journalled "
944 "quota options when quota turned on.\n"); 944 "quota options when quota turned on.\n");
945 return 0; 945 return 0;
946 } 946 }
947 qname = match_strdup(&args[0]); 947 qname = match_strdup(&args[0]);
948 if (!qname) { 948 if (!qname) {
949 printk(KERN_ERR 949 printk(KERN_ERR
950 "EXT3-fs: not enough memory for " 950 "EXT4-fs: not enough memory for "
951 "storing quotafile name.\n"); 951 "storing quotafile name.\n");
952 return 0; 952 return 0;
953 } 953 }
954 if (sbi->s_qf_names[qtype] && 954 if (sbi->s_qf_names[qtype] &&
955 strcmp(sbi->s_qf_names[qtype], qname)) { 955 strcmp(sbi->s_qf_names[qtype], qname)) {
956 printk(KERN_ERR 956 printk(KERN_ERR
957 "EXT3-fs: %s quota file already " 957 "EXT4-fs: %s quota file already "
958 "specified.\n", QTYPE2NAME(qtype)); 958 "specified.\n", QTYPE2NAME(qtype));
959 kfree(qname); 959 kfree(qname);
960 return 0; 960 return 0;
@@ -962,7 +962,7 @@ set_qf_name:
962 sbi->s_qf_names[qtype] = qname; 962 sbi->s_qf_names[qtype] = qname;
963 if (strchr(sbi->s_qf_names[qtype], '/')) { 963 if (strchr(sbi->s_qf_names[qtype], '/')) {
964 printk(KERN_ERR 964 printk(KERN_ERR
965 "EXT3-fs: quotafile must be on " 965 "EXT4-fs: quotafile must be on "
966 "filesystem root.\n"); 966 "filesystem root.\n");
967 kfree(sbi->s_qf_names[qtype]); 967 kfree(sbi->s_qf_names[qtype]);
968 sbi->s_qf_names[qtype] = NULL; 968 sbi->s_qf_names[qtype] = NULL;
@@ -977,7 +977,7 @@ set_qf_name:
977 qtype = GRPQUOTA; 977 qtype = GRPQUOTA;
978clear_qf_name: 978clear_qf_name:
979 if (sb_any_quota_enabled(sb)) { 979 if (sb_any_quota_enabled(sb)) {
980 printk(KERN_ERR "EXT3-fs: Cannot change " 980 printk(KERN_ERR "EXT4-fs: Cannot change "
981 "journalled quota options when " 981 "journalled quota options when "
982 "quota turned on.\n"); 982 "quota turned on.\n");
983 return 0; 983 return 0;
@@ -1005,7 +1005,7 @@ clear_qf_name:
1005 break; 1005 break;
1006 case Opt_noquota: 1006 case Opt_noquota:
1007 if (sb_any_quota_enabled(sb)) { 1007 if (sb_any_quota_enabled(sb)) {
1008 printk(KERN_ERR "EXT3-fs: Cannot change quota " 1008 printk(KERN_ERR "EXT4-fs: Cannot change quota "
1009 "options when quota turned on.\n"); 1009 "options when quota turned on.\n");
1010 return 0; 1010 return 0;
1011 } 1011 }
@@ -1024,7 +1024,7 @@ clear_qf_name:
1024 case Opt_jqfmt_vfsold: 1024 case Opt_jqfmt_vfsold:
1025 case Opt_jqfmt_vfsv0: 1025 case Opt_jqfmt_vfsv0:
1026 printk(KERN_ERR 1026 printk(KERN_ERR
1027 "EXT3-fs: journalled quota options not " 1027 "EXT4-fs: journalled quota options not "
1028 "supported.\n"); 1028 "supported.\n");
1029 break; 1029 break;
1030 case Opt_noquota: 1030 case Opt_noquota:
@@ -1045,7 +1045,7 @@ clear_qf_name:
1045 break; 1045 break;
1046 case Opt_resize: 1046 case Opt_resize:
1047 if (!is_remount) { 1047 if (!is_remount) {
1048 printk("EXT3-fs: resize option only available " 1048 printk("EXT4-fs: resize option only available "
1049 "for remount\n"); 1049 "for remount\n");
1050 return 0; 1050 return 0;
1051 } 1051 }
@@ -1061,38 +1061,38 @@ clear_qf_name:
1061 break; 1061 break;
1062 default: 1062 default:
1063 printk (KERN_ERR 1063 printk (KERN_ERR
1064 "EXT3-fs: Unrecognized mount option \"%s\" " 1064 "EXT4-fs: Unrecognized mount option \"%s\" "
1065 "or missing value\n", p); 1065 "or missing value\n", p);
1066 return 0; 1066 return 0;
1067 } 1067 }
1068 } 1068 }
1069#ifdef CONFIG_QUOTA 1069#ifdef CONFIG_QUOTA
1070 if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) { 1070 if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) {
1071 if ((sbi->s_mount_opt & EXT3_MOUNT_USRQUOTA) && 1071 if ((sbi->s_mount_opt & EXT4_MOUNT_USRQUOTA) &&
1072 sbi->s_qf_names[USRQUOTA]) 1072 sbi->s_qf_names[USRQUOTA])
1073 clear_opt(sbi->s_mount_opt, USRQUOTA); 1073 clear_opt(sbi->s_mount_opt, USRQUOTA);
1074 1074
1075 if ((sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA) && 1075 if ((sbi->s_mount_opt & EXT4_MOUNT_GRPQUOTA) &&
1076 sbi->s_qf_names[GRPQUOTA]) 1076 sbi->s_qf_names[GRPQUOTA])
1077 clear_opt(sbi->s_mount_opt, GRPQUOTA); 1077 clear_opt(sbi->s_mount_opt, GRPQUOTA);
1078 1078
1079 if ((sbi->s_qf_names[USRQUOTA] && 1079 if ((sbi->s_qf_names[USRQUOTA] &&
1080 (sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA)) || 1080 (sbi->s_mount_opt & EXT4_MOUNT_GRPQUOTA)) ||
1081 (sbi->s_qf_names[GRPQUOTA] && 1081 (sbi->s_qf_names[GRPQUOTA] &&
1082 (sbi->s_mount_opt & EXT3_MOUNT_USRQUOTA))) { 1082 (sbi->s_mount_opt & EXT4_MOUNT_USRQUOTA))) {
1083 printk(KERN_ERR "EXT3-fs: old and new quota " 1083 printk(KERN_ERR "EXT4-fs: old and new quota "
1084 "format mixing.\n"); 1084 "format mixing.\n");
1085 return 0; 1085 return 0;
1086 } 1086 }
1087 1087
1088 if (!sbi->s_jquota_fmt) { 1088 if (!sbi->s_jquota_fmt) {
1089 printk(KERN_ERR "EXT3-fs: journalled quota format " 1089 printk(KERN_ERR "EXT4-fs: journalled quota format "
1090 "not specified.\n"); 1090 "not specified.\n");
1091 return 0; 1091 return 0;
1092 } 1092 }
1093 } else { 1093 } else {
1094 if (sbi->s_jquota_fmt) { 1094 if (sbi->s_jquota_fmt) {
1095 printk(KERN_ERR "EXT3-fs: journalled quota format " 1095 printk(KERN_ERR "EXT4-fs: journalled quota format "
1096 "specified with no journalling " 1096 "specified with no journalling "
1097 "enabled.\n"); 1097 "enabled.\n");
1098 return 0; 1098 return 0;
@@ -1102,68 +1102,68 @@ clear_qf_name:
1102 return 1; 1102 return 1;
1103} 1103}
1104 1104
1105static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es, 1105static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es,
1106 int read_only) 1106 int read_only)
1107{ 1107{
1108 struct ext3_sb_info *sbi = EXT3_SB(sb); 1108 struct ext4_sb_info *sbi = EXT4_SB(sb);
1109 int res = 0; 1109 int res = 0;
1110 1110
1111 if (le32_to_cpu(es->s_rev_level) > EXT3_MAX_SUPP_REV) { 1111 if (le32_to_cpu(es->s_rev_level) > EXT4_MAX_SUPP_REV) {
1112 printk (KERN_ERR "EXT3-fs warning: revision level too high, " 1112 printk (KERN_ERR "EXT4-fs warning: revision level too high, "
1113 "forcing read-only mode\n"); 1113 "forcing read-only mode\n");
1114 res = MS_RDONLY; 1114 res = MS_RDONLY;
1115 } 1115 }
1116 if (read_only) 1116 if (read_only)
1117 return res; 1117 return res;
1118 if (!(sbi->s_mount_state & EXT3_VALID_FS)) 1118 if (!(sbi->s_mount_state & EXT4_VALID_FS))
1119 printk (KERN_WARNING "EXT3-fs warning: mounting unchecked fs, " 1119 printk (KERN_WARNING "EXT4-fs warning: mounting unchecked fs, "
1120 "running e2fsck is recommended\n"); 1120 "running e2fsck is recommended\n");
1121 else if ((sbi->s_mount_state & EXT3_ERROR_FS)) 1121 else if ((sbi->s_mount_state & EXT4_ERROR_FS))
1122 printk (KERN_WARNING 1122 printk (KERN_WARNING
1123 "EXT3-fs warning: mounting fs with errors, " 1123 "EXT4-fs warning: mounting fs with errors, "
1124 "running e2fsck is recommended\n"); 1124 "running e2fsck is recommended\n");
1125 else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 && 1125 else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 &&
1126 le16_to_cpu(es->s_mnt_count) >= 1126 le16_to_cpu(es->s_mnt_count) >=
1127 (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count)) 1127 (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
1128 printk (KERN_WARNING 1128 printk (KERN_WARNING
1129 "EXT3-fs warning: maximal mount count reached, " 1129 "EXT4-fs warning: maximal mount count reached, "
1130 "running e2fsck is recommended\n"); 1130 "running e2fsck is recommended\n");
1131 else if (le32_to_cpu(es->s_checkinterval) && 1131 else if (le32_to_cpu(es->s_checkinterval) &&
1132 (le32_to_cpu(es->s_lastcheck) + 1132 (le32_to_cpu(es->s_lastcheck) +
1133 le32_to_cpu(es->s_checkinterval) <= get_seconds())) 1133 le32_to_cpu(es->s_checkinterval) <= get_seconds()))
1134 printk (KERN_WARNING 1134 printk (KERN_WARNING
1135 "EXT3-fs warning: checktime reached, " 1135 "EXT4-fs warning: checktime reached, "
1136 "running e2fsck is recommended\n"); 1136 "running e2fsck is recommended\n");
1137#if 0 1137#if 0
1138 /* @@@ We _will_ want to clear the valid bit if we find 1138 /* @@@ We _will_ want to clear the valid bit if we find
1139 inconsistencies, to force a fsck at reboot. But for 1139 inconsistencies, to force a fsck at reboot. But for
1140 a plain journaled filesystem we can keep it set as 1140 a plain journaled filesystem we can keep it set as
1141 valid forever! :) */ 1141 valid forever! :) */
1142 es->s_state = cpu_to_le16(le16_to_cpu(es->s_state) & ~EXT3_VALID_FS); 1142 es->s_state = cpu_to_le16(le16_to_cpu(es->s_state) & ~EXT4_VALID_FS);
1143#endif 1143#endif
1144 if (!(__s16) le16_to_cpu(es->s_max_mnt_count)) 1144 if (!(__s16) le16_to_cpu(es->s_max_mnt_count))
1145 es->s_max_mnt_count = cpu_to_le16(EXT3_DFL_MAX_MNT_COUNT); 1145 es->s_max_mnt_count = cpu_to_le16(EXT4_DFL_MAX_MNT_COUNT);
1146 es->s_mnt_count=cpu_to_le16(le16_to_cpu(es->s_mnt_count) + 1); 1146 es->s_mnt_count=cpu_to_le16(le16_to_cpu(es->s_mnt_count) + 1);
1147 es->s_mtime = cpu_to_le32(get_seconds()); 1147 es->s_mtime = cpu_to_le32(get_seconds());
1148 ext3_update_dynamic_rev(sb); 1148 ext4_update_dynamic_rev(sb);
1149 EXT3_SET_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); 1149 EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
1150 1150
1151 ext3_commit_super(sb, es, 1); 1151 ext4_commit_super(sb, es, 1);
1152 if (test_opt(sb, DEBUG)) 1152 if (test_opt(sb, DEBUG))
1153 printk(KERN_INFO "[EXT3 FS bs=%lu, gc=%lu, " 1153 printk(KERN_INFO "[EXT4 FS bs=%lu, gc=%lu, "
1154 "bpg=%lu, ipg=%lu, mo=%04lx]\n", 1154 "bpg=%lu, ipg=%lu, mo=%04lx]\n",
1155 sb->s_blocksize, 1155 sb->s_blocksize,
1156 sbi->s_groups_count, 1156 sbi->s_groups_count,
1157 EXT3_BLOCKS_PER_GROUP(sb), 1157 EXT4_BLOCKS_PER_GROUP(sb),
1158 EXT3_INODES_PER_GROUP(sb), 1158 EXT4_INODES_PER_GROUP(sb),
1159 sbi->s_mount_opt); 1159 sbi->s_mount_opt);
1160 1160
1161 printk(KERN_INFO "EXT3 FS on %s, ", sb->s_id); 1161 printk(KERN_INFO "EXT4 FS on %s, ", sb->s_id);
1162 if (EXT3_SB(sb)->s_journal->j_inode == NULL) { 1162 if (EXT4_SB(sb)->s_journal->j_inode == NULL) {
1163 char b[BDEVNAME_SIZE]; 1163 char b[BDEVNAME_SIZE];
1164 1164
1165 printk("external journal on %s\n", 1165 printk("external journal on %s\n",
1166 bdevname(EXT3_SB(sb)->s_journal->j_dev, b)); 1166 bdevname(EXT4_SB(sb)->s_journal->j_dev, b));
1167 } else { 1167 } else {
1168 printk("internal journal\n"); 1168 printk("internal journal\n");
1169 } 1169 }
@@ -1171,16 +1171,16 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es,
1171} 1171}
1172 1172
1173/* Called at mount-time, super-block is locked */ 1173/* Called at mount-time, super-block is locked */
1174static int ext3_check_descriptors (struct super_block * sb) 1174static int ext4_check_descriptors (struct super_block * sb)
1175{ 1175{
1176 struct ext3_sb_info *sbi = EXT3_SB(sb); 1176 struct ext4_sb_info *sbi = EXT4_SB(sb);
1177 ext3_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block); 1177 ext4_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
1178 ext3_fsblk_t last_block; 1178 ext4_fsblk_t last_block;
1179 struct ext3_group_desc * gdp = NULL; 1179 struct ext4_group_desc * gdp = NULL;
1180 int desc_block = 0; 1180 int desc_block = 0;
1181 int i; 1181 int i;
1182 1182
1183 ext3_debug ("Checking group descriptors"); 1183 ext4_debug ("Checking group descriptors");
1184 1184
1185 for (i = 0; i < sbi->s_groups_count; i++) 1185 for (i = 0; i < sbi->s_groups_count; i++)
1186 { 1186 {
@@ -1188,15 +1188,15 @@ static int ext3_check_descriptors (struct super_block * sb)
1188 last_block = le32_to_cpu(sbi->s_es->s_blocks_count) - 1; 1188 last_block = le32_to_cpu(sbi->s_es->s_blocks_count) - 1;
1189 else 1189 else
1190 last_block = first_block + 1190 last_block = first_block +
1191 (EXT3_BLOCKS_PER_GROUP(sb) - 1); 1191 (EXT4_BLOCKS_PER_GROUP(sb) - 1);
1192 1192
1193 if ((i % EXT3_DESC_PER_BLOCK(sb)) == 0) 1193 if ((i % EXT4_DESC_PER_BLOCK(sb)) == 0)
1194 gdp = (struct ext3_group_desc *) 1194 gdp = (struct ext4_group_desc *)
1195 sbi->s_group_desc[desc_block++]->b_data; 1195 sbi->s_group_desc[desc_block++]->b_data;
1196 if (le32_to_cpu(gdp->bg_block_bitmap) < first_block || 1196 if (le32_to_cpu(gdp->bg_block_bitmap) < first_block ||
1197 le32_to_cpu(gdp->bg_block_bitmap) > last_block) 1197 le32_to_cpu(gdp->bg_block_bitmap) > last_block)
1198 { 1198 {
1199 ext3_error (sb, "ext3_check_descriptors", 1199 ext4_error (sb, "ext4_check_descriptors",
1200 "Block bitmap for group %d" 1200 "Block bitmap for group %d"
1201 " not in group (block %lu)!", 1201 " not in group (block %lu)!",
1202 i, (unsigned long) 1202 i, (unsigned long)
@@ -1206,7 +1206,7 @@ static int ext3_check_descriptors (struct super_block * sb)
1206 if (le32_to_cpu(gdp->bg_inode_bitmap) < first_block || 1206 if (le32_to_cpu(gdp->bg_inode_bitmap) < first_block ||
1207 le32_to_cpu(gdp->bg_inode_bitmap) > last_block) 1207 le32_to_cpu(gdp->bg_inode_bitmap) > last_block)
1208 { 1208 {
1209 ext3_error (sb, "ext3_check_descriptors", 1209 ext4_error (sb, "ext4_check_descriptors",
1210 "Inode bitmap for group %d" 1210 "Inode bitmap for group %d"
1211 " not in group (block %lu)!", 1211 " not in group (block %lu)!",
1212 i, (unsigned long) 1212 i, (unsigned long)
@@ -1217,24 +1217,24 @@ static int ext3_check_descriptors (struct super_block * sb)
1217 le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group > 1217 le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group >
1218 last_block) 1218 last_block)
1219 { 1219 {
1220 ext3_error (sb, "ext3_check_descriptors", 1220 ext4_error (sb, "ext4_check_descriptors",
1221 "Inode table for group %d" 1221 "Inode table for group %d"
1222 " not in group (block %lu)!", 1222 " not in group (block %lu)!",
1223 i, (unsigned long) 1223 i, (unsigned long)
1224 le32_to_cpu(gdp->bg_inode_table)); 1224 le32_to_cpu(gdp->bg_inode_table));
1225 return 0; 1225 return 0;
1226 } 1226 }
1227 first_block += EXT3_BLOCKS_PER_GROUP(sb); 1227 first_block += EXT4_BLOCKS_PER_GROUP(sb);
1228 gdp++; 1228 gdp++;
1229 } 1229 }
1230 1230
1231 sbi->s_es->s_free_blocks_count=cpu_to_le32(ext3_count_free_blocks(sb)); 1231 sbi->s_es->s_free_blocks_count=cpu_to_le32(ext4_count_free_blocks(sb));
1232 sbi->s_es->s_free_inodes_count=cpu_to_le32(ext3_count_free_inodes(sb)); 1232 sbi->s_es->s_free_inodes_count=cpu_to_le32(ext4_count_free_inodes(sb));
1233 return 1; 1233 return 1;
1234} 1234}
1235 1235
1236 1236
1237/* ext3_orphan_cleanup() walks a singly-linked list of inodes (starting at 1237/* ext4_orphan_cleanup() walks a singly-linked list of inodes (starting at
1238 * the superblock) which were deleted from all directories, but held open by 1238 * the superblock) which were deleted from all directories, but held open by
1239 * a process at the time of a crash. We walk the list and try to delete these 1239 * a process at the time of a crash. We walk the list and try to delete these
1240 * inodes at recovery time (only with a read-write filesystem). 1240 * inodes at recovery time (only with a read-write filesystem).
@@ -1247,12 +1247,12 @@ static int ext3_check_descriptors (struct super_block * sb)
1247 * We only do an iget() and an iput() on each inode, which is very safe if we 1247 * We only do an iget() and an iput() on each inode, which is very safe if we
1248 * accidentally point at an in-use or already deleted inode. The worst that 1248 * accidentally point at an in-use or already deleted inode. The worst that
1249 * can happen in this case is that we get a "bit already cleared" message from 1249 * can happen in this case is that we get a "bit already cleared" message from
1250 * ext3_free_inode(). The only reason we would point at a wrong inode is if 1250 * ext4_free_inode(). The only reason we would point at a wrong inode is if
1251 * e2fsck was run on this filesystem, and it must have already done the orphan 1251 * e2fsck was run on this filesystem, and it must have already done the orphan
1252 * inode cleanup for us, so we can safely abort without any further action. 1252 * inode cleanup for us, so we can safely abort without any further action.
1253 */ 1253 */
1254static void ext3_orphan_cleanup (struct super_block * sb, 1254static void ext4_orphan_cleanup (struct super_block * sb,
1255 struct ext3_super_block * es) 1255 struct ext4_super_block * es)
1256{ 1256{
1257 unsigned int s_flags = sb->s_flags; 1257 unsigned int s_flags = sb->s_flags;
1258 int nr_orphans = 0, nr_truncates = 0; 1258 int nr_orphans = 0, nr_truncates = 0;
@@ -1264,7 +1264,7 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1264 return; 1264 return;
1265 } 1265 }
1266 1266
1267 if (EXT3_SB(sb)->s_mount_state & EXT3_ERROR_FS) { 1267 if (EXT4_SB(sb)->s_mount_state & EXT4_ERROR_FS) {
1268 if (es->s_last_orphan) 1268 if (es->s_last_orphan)
1269 jbd_debug(1, "Errors on filesystem, " 1269 jbd_debug(1, "Errors on filesystem, "
1270 "clearing orphan list.\n"); 1270 "clearing orphan list.\n");
@@ -1274,7 +1274,7 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1274 } 1274 }
1275 1275
1276 if (s_flags & MS_RDONLY) { 1276 if (s_flags & MS_RDONLY) {
1277 printk(KERN_INFO "EXT3-fs: %s: orphan cleanup on readonly fs\n", 1277 printk(KERN_INFO "EXT4-fs: %s: orphan cleanup on readonly fs\n",
1278 sb->s_id); 1278 sb->s_id);
1279 sb->s_flags &= ~MS_RDONLY; 1279 sb->s_flags &= ~MS_RDONLY;
1280 } 1280 }
@@ -1283,11 +1283,11 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1283 sb->s_flags |= MS_ACTIVE; 1283 sb->s_flags |= MS_ACTIVE;
1284 /* Turn on quotas so that they are updated correctly */ 1284 /* Turn on quotas so that they are updated correctly */
1285 for (i = 0; i < MAXQUOTAS; i++) { 1285 for (i = 0; i < MAXQUOTAS; i++) {
1286 if (EXT3_SB(sb)->s_qf_names[i]) { 1286 if (EXT4_SB(sb)->s_qf_names[i]) {
1287 int ret = ext3_quota_on_mount(sb, i); 1287 int ret = ext4_quota_on_mount(sb, i);
1288 if (ret < 0) 1288 if (ret < 0)
1289 printk(KERN_ERR 1289 printk(KERN_ERR
1290 "EXT3-fs: Cannot turn on journalled " 1290 "EXT4-fs: Cannot turn on journalled "
1291 "quota: error %d\n", ret); 1291 "quota: error %d\n", ret);
1292 } 1292 }
1293 } 1293 }
@@ -1297,12 +1297,12 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1297 struct inode *inode; 1297 struct inode *inode;
1298 1298
1299 if (!(inode = 1299 if (!(inode =
1300 ext3_orphan_get(sb, le32_to_cpu(es->s_last_orphan)))) { 1300 ext4_orphan_get(sb, le32_to_cpu(es->s_last_orphan)))) {
1301 es->s_last_orphan = 0; 1301 es->s_last_orphan = 0;
1302 break; 1302 break;
1303 } 1303 }
1304 1304
1305 list_add(&EXT3_I(inode)->i_orphan, &EXT3_SB(sb)->s_orphan); 1305 list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan);
1306 DQUOT_INIT(inode); 1306 DQUOT_INIT(inode);
1307 if (inode->i_nlink) { 1307 if (inode->i_nlink) {
1308 printk(KERN_DEBUG 1308 printk(KERN_DEBUG
@@ -1310,7 +1310,7 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1310 __FUNCTION__, inode->i_ino, inode->i_size); 1310 __FUNCTION__, inode->i_ino, inode->i_size);
1311 jbd_debug(2, "truncating inode %lu to %Ld bytes\n", 1311 jbd_debug(2, "truncating inode %lu to %Ld bytes\n",
1312 inode->i_ino, inode->i_size); 1312 inode->i_ino, inode->i_size);
1313 ext3_truncate(inode); 1313 ext4_truncate(inode);
1314 nr_truncates++; 1314 nr_truncates++;
1315 } else { 1315 } else {
1316 printk(KERN_DEBUG 1316 printk(KERN_DEBUG
@@ -1326,10 +1326,10 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1326#define PLURAL(x) (x), ((x)==1) ? "" : "s" 1326#define PLURAL(x) (x), ((x)==1) ? "" : "s"
1327 1327
1328 if (nr_orphans) 1328 if (nr_orphans)
1329 printk(KERN_INFO "EXT3-fs: %s: %d orphan inode%s deleted\n", 1329 printk(KERN_INFO "EXT4-fs: %s: %d orphan inode%s deleted\n",
1330 sb->s_id, PLURAL(nr_orphans)); 1330 sb->s_id, PLURAL(nr_orphans));
1331 if (nr_truncates) 1331 if (nr_truncates)
1332 printk(KERN_INFO "EXT3-fs: %s: %d truncate%s cleaned up\n", 1332 printk(KERN_INFO "EXT4-fs: %s: %d truncate%s cleaned up\n",
1333 sb->s_id, PLURAL(nr_truncates)); 1333 sb->s_id, PLURAL(nr_truncates));
1334#ifdef CONFIG_QUOTA 1334#ifdef CONFIG_QUOTA
1335 /* Turn quotas off */ 1335 /* Turn quotas off */
@@ -1348,9 +1348,9 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1348 * block limit, and also a limit of (2^32 - 1) 512-byte sectors in i_blocks. 1348 * block limit, and also a limit of (2^32 - 1) 512-byte sectors in i_blocks.
1349 * We need to be 1 filesystem block less than the 2^32 sector limit. 1349 * We need to be 1 filesystem block less than the 2^32 sector limit.
1350 */ 1350 */
1351static loff_t ext3_max_size(int bits) 1351static loff_t ext4_max_size(int bits)
1352{ 1352{
1353 loff_t res = EXT3_NDIR_BLOCKS; 1353 loff_t res = EXT4_NDIR_BLOCKS;
1354 /* This constant is calculated to be the largest file size for a 1354 /* This constant is calculated to be the largest file size for a
1355 * dense, 4k-blocksize file such that the total number of 1355 * dense, 4k-blocksize file such that the total number of
1356 * sectors in the file, including data and all indirect blocks, 1356 * sectors in the file, including data and all indirect blocks,
@@ -1366,34 +1366,34 @@ static loff_t ext3_max_size(int bits)
1366 return res; 1366 return res;
1367} 1367}
1368 1368
1369static ext3_fsblk_t descriptor_loc(struct super_block *sb, 1369static ext4_fsblk_t descriptor_loc(struct super_block *sb,
1370 ext3_fsblk_t logic_sb_block, 1370 ext4_fsblk_t logic_sb_block,
1371 int nr) 1371 int nr)
1372{ 1372{
1373 struct ext3_sb_info *sbi = EXT3_SB(sb); 1373 struct ext4_sb_info *sbi = EXT4_SB(sb);
1374 unsigned long bg, first_meta_bg; 1374 unsigned long bg, first_meta_bg;
1375 int has_super = 0; 1375 int has_super = 0;
1376 1376
1377 first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg); 1377 first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg);
1378 1378
1379 if (!EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_META_BG) || 1379 if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_META_BG) ||
1380 nr < first_meta_bg) 1380 nr < first_meta_bg)
1381 return (logic_sb_block + nr + 1); 1381 return (logic_sb_block + nr + 1);
1382 bg = sbi->s_desc_per_block * nr; 1382 bg = sbi->s_desc_per_block * nr;
1383 if (ext3_bg_has_super(sb, bg)) 1383 if (ext4_bg_has_super(sb, bg))
1384 has_super = 1; 1384 has_super = 1;
1385 return (has_super + ext3_group_first_block_no(sb, bg)); 1385 return (has_super + ext4_group_first_block_no(sb, bg));
1386} 1386}
1387 1387
1388 1388
1389static int ext3_fill_super (struct super_block *sb, void *data, int silent) 1389static int ext4_fill_super (struct super_block *sb, void *data, int silent)
1390{ 1390{
1391 struct buffer_head * bh; 1391 struct buffer_head * bh;
1392 struct ext3_super_block *es = NULL; 1392 struct ext4_super_block *es = NULL;
1393 struct ext3_sb_info *sbi; 1393 struct ext4_sb_info *sbi;
1394 ext3_fsblk_t block; 1394 ext4_fsblk_t block;
1395 ext3_fsblk_t sb_block = get_sb_block(&data); 1395 ext4_fsblk_t sb_block = get_sb_block(&data);
1396 ext3_fsblk_t logic_sb_block; 1396 ext4_fsblk_t logic_sb_block;
1397 unsigned long offset = 0; 1397 unsigned long offset = 0;
1398 unsigned int journal_inum = 0; 1398 unsigned int journal_inum = 0;
1399 unsigned long journal_devnum = 0; 1399 unsigned long journal_devnum = 0;
@@ -1411,64 +1411,64 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1411 return -ENOMEM; 1411 return -ENOMEM;
1412 sb->s_fs_info = sbi; 1412 sb->s_fs_info = sbi;
1413 sbi->s_mount_opt = 0; 1413 sbi->s_mount_opt = 0;
1414 sbi->s_resuid = EXT3_DEF_RESUID; 1414 sbi->s_resuid = EXT4_DEF_RESUID;
1415 sbi->s_resgid = EXT3_DEF_RESGID; 1415 sbi->s_resgid = EXT4_DEF_RESGID;
1416 1416
1417 unlock_kernel(); 1417 unlock_kernel();
1418 1418
1419 blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE); 1419 blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE);
1420 if (!blocksize) { 1420 if (!blocksize) {
1421 printk(KERN_ERR "EXT3-fs: unable to set blocksize\n"); 1421 printk(KERN_ERR "EXT4-fs: unable to set blocksize\n");
1422 goto out_fail; 1422 goto out_fail;
1423 } 1423 }
1424 1424
1425 /* 1425 /*
1426 * The ext3 superblock will not be buffer aligned for other than 1kB 1426 * The ext4 superblock will not be buffer aligned for other than 1kB
1427 * block sizes. We need to calculate the offset from buffer start. 1427 * block sizes. We need to calculate the offset from buffer start.
1428 */ 1428 */
1429 if (blocksize != EXT3_MIN_BLOCK_SIZE) { 1429 if (blocksize != EXT4_MIN_BLOCK_SIZE) {
1430 logic_sb_block = (sb_block * EXT3_MIN_BLOCK_SIZE) / blocksize; 1430 logic_sb_block = (sb_block * EXT4_MIN_BLOCK_SIZE) / blocksize;
1431 offset = (sb_block * EXT3_MIN_BLOCK_SIZE) % blocksize; 1431 offset = (sb_block * EXT4_MIN_BLOCK_SIZE) % blocksize;
1432 } else { 1432 } else {
1433 logic_sb_block = sb_block; 1433 logic_sb_block = sb_block;
1434 } 1434 }
1435 1435
1436 if (!(bh = sb_bread(sb, logic_sb_block))) { 1436 if (!(bh = sb_bread(sb, logic_sb_block))) {
1437 printk (KERN_ERR "EXT3-fs: unable to read superblock\n"); 1437 printk (KERN_ERR "EXT4-fs: unable to read superblock\n");
1438 goto out_fail; 1438 goto out_fail;
1439 } 1439 }
1440 /* 1440 /*
1441 * Note: s_es must be initialized as soon as possible because 1441 * Note: s_es must be initialized as soon as possible because
1442 * some ext3 macro-instructions depend on its value 1442 * some ext4 macro-instructions depend on its value
1443 */ 1443 */
1444 es = (struct ext3_super_block *) (((char *)bh->b_data) + offset); 1444 es = (struct ext4_super_block *) (((char *)bh->b_data) + offset);
1445 sbi->s_es = es; 1445 sbi->s_es = es;
1446 sb->s_magic = le16_to_cpu(es->s_magic); 1446 sb->s_magic = le16_to_cpu(es->s_magic);
1447 if (sb->s_magic != EXT3_SUPER_MAGIC) 1447 if (sb->s_magic != EXT4_SUPER_MAGIC)
1448 goto cantfind_ext3; 1448 goto cantfind_ext4;
1449 1449
1450 /* Set defaults before we parse the mount options */ 1450 /* Set defaults before we parse the mount options */
1451 def_mount_opts = le32_to_cpu(es->s_default_mount_opts); 1451 def_mount_opts = le32_to_cpu(es->s_default_mount_opts);
1452 if (def_mount_opts & EXT3_DEFM_DEBUG) 1452 if (def_mount_opts & EXT4_DEFM_DEBUG)
1453 set_opt(sbi->s_mount_opt, DEBUG); 1453 set_opt(sbi->s_mount_opt, DEBUG);
1454 if (def_mount_opts & EXT3_DEFM_BSDGROUPS) 1454 if (def_mount_opts & EXT4_DEFM_BSDGROUPS)
1455 set_opt(sbi->s_mount_opt, GRPID); 1455 set_opt(sbi->s_mount_opt, GRPID);
1456 if (def_mount_opts & EXT3_DEFM_UID16) 1456 if (def_mount_opts & EXT4_DEFM_UID16)
1457 set_opt(sbi->s_mount_opt, NO_UID32); 1457 set_opt(sbi->s_mount_opt, NO_UID32);
1458 if (def_mount_opts & EXT3_DEFM_XATTR_USER) 1458 if (def_mount_opts & EXT4_DEFM_XATTR_USER)
1459 set_opt(sbi->s_mount_opt, XATTR_USER); 1459 set_opt(sbi->s_mount_opt, XATTR_USER);
1460 if (def_mount_opts & EXT3_DEFM_ACL) 1460 if (def_mount_opts & EXT4_DEFM_ACL)
1461 set_opt(sbi->s_mount_opt, POSIX_ACL); 1461 set_opt(sbi->s_mount_opt, POSIX_ACL);
1462 if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_DATA) 1462 if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_DATA)
1463 sbi->s_mount_opt |= EXT3_MOUNT_JOURNAL_DATA; 1463 sbi->s_mount_opt |= EXT4_MOUNT_JOURNAL_DATA;
1464 else if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_ORDERED) 1464 else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_ORDERED)
1465 sbi->s_mount_opt |= EXT3_MOUNT_ORDERED_DATA; 1465 sbi->s_mount_opt |= EXT4_MOUNT_ORDERED_DATA;
1466 else if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_WBACK) 1466 else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_WBACK)
1467 sbi->s_mount_opt |= EXT3_MOUNT_WRITEBACK_DATA; 1467 sbi->s_mount_opt |= EXT4_MOUNT_WRITEBACK_DATA;
1468 1468
1469 if (le16_to_cpu(sbi->s_es->s_errors) == EXT3_ERRORS_PANIC) 1469 if (le16_to_cpu(sbi->s_es->s_errors) == EXT4_ERRORS_PANIC)
1470 set_opt(sbi->s_mount_opt, ERRORS_PANIC); 1470 set_opt(sbi->s_mount_opt, ERRORS_PANIC);
1471 else if (le16_to_cpu(sbi->s_es->s_errors) == EXT3_ERRORS_RO) 1471 else if (le16_to_cpu(sbi->s_es->s_errors) == EXT4_ERRORS_RO)
1472 set_opt(sbi->s_mount_opt, ERRORS_RO); 1472 set_opt(sbi->s_mount_opt, ERRORS_RO);
1473 1473
1474 sbi->s_resuid = le16_to_cpu(es->s_def_resuid); 1474 sbi->s_resuid = le16_to_cpu(es->s_def_resuid);
@@ -1481,40 +1481,40 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1481 goto failed_mount; 1481 goto failed_mount;
1482 1482
1483 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | 1483 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
1484 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); 1484 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
1485 1485
1486 if (le32_to_cpu(es->s_rev_level) == EXT3_GOOD_OLD_REV && 1486 if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV &&
1487 (EXT3_HAS_COMPAT_FEATURE(sb, ~0U) || 1487 (EXT4_HAS_COMPAT_FEATURE(sb, ~0U) ||
1488 EXT3_HAS_RO_COMPAT_FEATURE(sb, ~0U) || 1488 EXT4_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
1489 EXT3_HAS_INCOMPAT_FEATURE(sb, ~0U))) 1489 EXT4_HAS_INCOMPAT_FEATURE(sb, ~0U)))
1490 printk(KERN_WARNING 1490 printk(KERN_WARNING
1491 "EXT3-fs warning: feature flags set on rev 0 fs, " 1491 "EXT4-fs warning: feature flags set on rev 0 fs, "
1492 "running e2fsck is recommended\n"); 1492 "running e2fsck is recommended\n");
1493 /* 1493 /*
1494 * Check feature flags regardless of the revision level, since we 1494 * Check feature flags regardless of the revision level, since we
1495 * previously didn't change the revision level when setting the flags, 1495 * previously didn't change the revision level when setting the flags,
1496 * so there is a chance incompat flags are set on a rev 0 filesystem. 1496 * so there is a chance incompat flags are set on a rev 0 filesystem.
1497 */ 1497 */
1498 features = EXT3_HAS_INCOMPAT_FEATURE(sb, ~EXT3_FEATURE_INCOMPAT_SUPP); 1498 features = EXT4_HAS_INCOMPAT_FEATURE(sb, ~EXT4_FEATURE_INCOMPAT_SUPP);
1499 if (features) { 1499 if (features) {
1500 printk(KERN_ERR "EXT3-fs: %s: couldn't mount because of " 1500 printk(KERN_ERR "EXT4-fs: %s: couldn't mount because of "
1501 "unsupported optional features (%x).\n", 1501 "unsupported optional features (%x).\n",
1502 sb->s_id, le32_to_cpu(features)); 1502 sb->s_id, le32_to_cpu(features));
1503 goto failed_mount; 1503 goto failed_mount;
1504 } 1504 }
1505 features = EXT3_HAS_RO_COMPAT_FEATURE(sb, ~EXT3_FEATURE_RO_COMPAT_SUPP); 1505 features = EXT4_HAS_RO_COMPAT_FEATURE(sb, ~EXT4_FEATURE_RO_COMPAT_SUPP);
1506 if (!(sb->s_flags & MS_RDONLY) && features) { 1506 if (!(sb->s_flags & MS_RDONLY) && features) {
1507 printk(KERN_ERR "EXT3-fs: %s: couldn't mount RDWR because of " 1507 printk(KERN_ERR "EXT4-fs: %s: couldn't mount RDWR because of "
1508 "unsupported optional features (%x).\n", 1508 "unsupported optional features (%x).\n",
1509 sb->s_id, le32_to_cpu(features)); 1509 sb->s_id, le32_to_cpu(features));
1510 goto failed_mount; 1510 goto failed_mount;
1511 } 1511 }
1512 blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size); 1512 blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size);
1513 1513
1514 if (blocksize < EXT3_MIN_BLOCK_SIZE || 1514 if (blocksize < EXT4_MIN_BLOCK_SIZE ||
1515 blocksize > EXT3_MAX_BLOCK_SIZE) { 1515 blocksize > EXT4_MAX_BLOCK_SIZE) {
1516 printk(KERN_ERR 1516 printk(KERN_ERR
1517 "EXT3-fs: Unsupported filesystem blocksize %d on %s.\n", 1517 "EXT4-fs: Unsupported filesystem blocksize %d on %s.\n",
1518 blocksize, sb->s_id); 1518 blocksize, sb->s_id);
1519 goto failed_mount; 1519 goto failed_mount;
1520 } 1520 }
@@ -1526,52 +1526,52 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1526 * than the hardware sectorsize for the machine. 1526 * than the hardware sectorsize for the machine.
1527 */ 1527 */
1528 if (blocksize < hblock) { 1528 if (blocksize < hblock) {
1529 printk(KERN_ERR "EXT3-fs: blocksize %d too small for " 1529 printk(KERN_ERR "EXT4-fs: blocksize %d too small for "
1530 "device blocksize %d.\n", blocksize, hblock); 1530 "device blocksize %d.\n", blocksize, hblock);
1531 goto failed_mount; 1531 goto failed_mount;
1532 } 1532 }
1533 1533
1534 brelse (bh); 1534 brelse (bh);
1535 sb_set_blocksize(sb, blocksize); 1535 sb_set_blocksize(sb, blocksize);
1536 logic_sb_block = (sb_block * EXT3_MIN_BLOCK_SIZE) / blocksize; 1536 logic_sb_block = (sb_block * EXT4_MIN_BLOCK_SIZE) / blocksize;
1537 offset = (sb_block * EXT3_MIN_BLOCK_SIZE) % blocksize; 1537 offset = (sb_block * EXT4_MIN_BLOCK_SIZE) % blocksize;
1538 bh = sb_bread(sb, logic_sb_block); 1538 bh = sb_bread(sb, logic_sb_block);
1539 if (!bh) { 1539 if (!bh) {
1540 printk(KERN_ERR 1540 printk(KERN_ERR
1541 "EXT3-fs: Can't read superblock on 2nd try.\n"); 1541 "EXT4-fs: Can't read superblock on 2nd try.\n");
1542 goto failed_mount; 1542 goto failed_mount;
1543 } 1543 }
1544 es = (struct ext3_super_block *)(((char *)bh->b_data) + offset); 1544 es = (struct ext4_super_block *)(((char *)bh->b_data) + offset);
1545 sbi->s_es = es; 1545 sbi->s_es = es;
1546 if (es->s_magic != cpu_to_le16(EXT3_SUPER_MAGIC)) { 1546 if (es->s_magic != cpu_to_le16(EXT4_SUPER_MAGIC)) {
1547 printk (KERN_ERR 1547 printk (KERN_ERR
1548 "EXT3-fs: Magic mismatch, very weird !\n"); 1548 "EXT4-fs: Magic mismatch, very weird !\n");
1549 goto failed_mount; 1549 goto failed_mount;
1550 } 1550 }
1551 } 1551 }
1552 1552
1553 sb->s_maxbytes = ext3_max_size(sb->s_blocksize_bits); 1553 sb->s_maxbytes = ext4_max_size(sb->s_blocksize_bits);
1554 1554
1555 if (le32_to_cpu(es->s_rev_level) == EXT3_GOOD_OLD_REV) { 1555 if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV) {
1556 sbi->s_inode_size = EXT3_GOOD_OLD_INODE_SIZE; 1556 sbi->s_inode_size = EXT4_GOOD_OLD_INODE_SIZE;
1557 sbi->s_first_ino = EXT3_GOOD_OLD_FIRST_INO; 1557 sbi->s_first_ino = EXT4_GOOD_OLD_FIRST_INO;
1558 } else { 1558 } else {
1559 sbi->s_inode_size = le16_to_cpu(es->s_inode_size); 1559 sbi->s_inode_size = le16_to_cpu(es->s_inode_size);
1560 sbi->s_first_ino = le32_to_cpu(es->s_first_ino); 1560 sbi->s_first_ino = le32_to_cpu(es->s_first_ino);
1561 if ((sbi->s_inode_size < EXT3_GOOD_OLD_INODE_SIZE) || 1561 if ((sbi->s_inode_size < EXT4_GOOD_OLD_INODE_SIZE) ||
1562 (sbi->s_inode_size & (sbi->s_inode_size - 1)) || 1562 (sbi->s_inode_size & (sbi->s_inode_size - 1)) ||
1563 (sbi->s_inode_size > blocksize)) { 1563 (sbi->s_inode_size > blocksize)) {
1564 printk (KERN_ERR 1564 printk (KERN_ERR
1565 "EXT3-fs: unsupported inode size: %d\n", 1565 "EXT4-fs: unsupported inode size: %d\n",
1566 sbi->s_inode_size); 1566 sbi->s_inode_size);
1567 goto failed_mount; 1567 goto failed_mount;
1568 } 1568 }
1569 } 1569 }
1570 sbi->s_frag_size = EXT3_MIN_FRAG_SIZE << 1570 sbi->s_frag_size = EXT4_MIN_FRAG_SIZE <<
1571 le32_to_cpu(es->s_log_frag_size); 1571 le32_to_cpu(es->s_log_frag_size);
1572 if (blocksize != sbi->s_frag_size) { 1572 if (blocksize != sbi->s_frag_size) {
1573 printk(KERN_ERR 1573 printk(KERN_ERR
1574 "EXT3-fs: fragsize %lu != blocksize %u (unsupported)\n", 1574 "EXT4-fs: fragsize %lu != blocksize %u (unsupported)\n",
1575 sbi->s_frag_size, blocksize); 1575 sbi->s_frag_size, blocksize);
1576 goto failed_mount; 1576 goto failed_mount;
1577 } 1577 }
@@ -1579,62 +1579,62 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1579 sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group); 1579 sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group);
1580 sbi->s_frags_per_group = le32_to_cpu(es->s_frags_per_group); 1580 sbi->s_frags_per_group = le32_to_cpu(es->s_frags_per_group);
1581 sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group); 1581 sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group);
1582 if (EXT3_INODE_SIZE(sb) == 0) 1582 if (EXT4_INODE_SIZE(sb) == 0)
1583 goto cantfind_ext3; 1583 goto cantfind_ext4;
1584 sbi->s_inodes_per_block = blocksize / EXT3_INODE_SIZE(sb); 1584 sbi->s_inodes_per_block = blocksize / EXT4_INODE_SIZE(sb);
1585 if (sbi->s_inodes_per_block == 0) 1585 if (sbi->s_inodes_per_block == 0)
1586 goto cantfind_ext3; 1586 goto cantfind_ext4;
1587 sbi->s_itb_per_group = sbi->s_inodes_per_group / 1587 sbi->s_itb_per_group = sbi->s_inodes_per_group /
1588 sbi->s_inodes_per_block; 1588 sbi->s_inodes_per_block;
1589 sbi->s_desc_per_block = blocksize / sizeof(struct ext3_group_desc); 1589 sbi->s_desc_per_block = blocksize / sizeof(struct ext4_group_desc);
1590 sbi->s_sbh = bh; 1590 sbi->s_sbh = bh;
1591 sbi->s_mount_state = le16_to_cpu(es->s_state); 1591 sbi->s_mount_state = le16_to_cpu(es->s_state);
1592 sbi->s_addr_per_block_bits = log2(EXT3_ADDR_PER_BLOCK(sb)); 1592 sbi->s_addr_per_block_bits = log2(EXT4_ADDR_PER_BLOCK(sb));
1593 sbi->s_desc_per_block_bits = log2(EXT3_DESC_PER_BLOCK(sb)); 1593 sbi->s_desc_per_block_bits = log2(EXT4_DESC_PER_BLOCK(sb));
1594 for (i=0; i < 4; i++) 1594 for (i=0; i < 4; i++)
1595 sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]); 1595 sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]);
1596 sbi->s_def_hash_version = es->s_def_hash_version; 1596 sbi->s_def_hash_version = es->s_def_hash_version;
1597 1597
1598 if (sbi->s_blocks_per_group > blocksize * 8) { 1598 if (sbi->s_blocks_per_group > blocksize * 8) {
1599 printk (KERN_ERR 1599 printk (KERN_ERR
1600 "EXT3-fs: #blocks per group too big: %lu\n", 1600 "EXT4-fs: #blocks per group too big: %lu\n",
1601 sbi->s_blocks_per_group); 1601 sbi->s_blocks_per_group);
1602 goto failed_mount; 1602 goto failed_mount;
1603 } 1603 }
1604 if (sbi->s_frags_per_group > blocksize * 8) { 1604 if (sbi->s_frags_per_group > blocksize * 8) {
1605 printk (KERN_ERR 1605 printk (KERN_ERR
1606 "EXT3-fs: #fragments per group too big: %lu\n", 1606 "EXT4-fs: #fragments per group too big: %lu\n",
1607 sbi->s_frags_per_group); 1607 sbi->s_frags_per_group);
1608 goto failed_mount; 1608 goto failed_mount;
1609 } 1609 }
1610 if (sbi->s_inodes_per_group > blocksize * 8) { 1610 if (sbi->s_inodes_per_group > blocksize * 8) {
1611 printk (KERN_ERR 1611 printk (KERN_ERR
1612 "EXT3-fs: #inodes per group too big: %lu\n", 1612 "EXT4-fs: #inodes per group too big: %lu\n",
1613 sbi->s_inodes_per_group); 1613 sbi->s_inodes_per_group);
1614 goto failed_mount; 1614 goto failed_mount;
1615 } 1615 }
1616 1616
1617 if (le32_to_cpu(es->s_blocks_count) > 1617 if (le32_to_cpu(es->s_blocks_count) >
1618 (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) { 1618 (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) {
1619 printk(KERN_ERR "EXT3-fs: filesystem on %s:" 1619 printk(KERN_ERR "EXT4-fs: filesystem on %s:"
1620 " too large to mount safely\n", sb->s_id); 1620 " too large to mount safely\n", sb->s_id);
1621 if (sizeof(sector_t) < 8) 1621 if (sizeof(sector_t) < 8)
1622 printk(KERN_WARNING "EXT3-fs: CONFIG_LBD not " 1622 printk(KERN_WARNING "EXT4-fs: CONFIG_LBD not "
1623 "enabled\n"); 1623 "enabled\n");
1624 goto failed_mount; 1624 goto failed_mount;
1625 } 1625 }
1626 1626
1627 if (EXT3_BLOCKS_PER_GROUP(sb) == 0) 1627 if (EXT4_BLOCKS_PER_GROUP(sb) == 0)
1628 goto cantfind_ext3; 1628 goto cantfind_ext4;
1629 sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) - 1629 sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) -
1630 le32_to_cpu(es->s_first_data_block) - 1) 1630 le32_to_cpu(es->s_first_data_block) - 1)
1631 / EXT3_BLOCKS_PER_GROUP(sb)) + 1; 1631 / EXT4_BLOCKS_PER_GROUP(sb)) + 1;
1632 db_count = (sbi->s_groups_count + EXT3_DESC_PER_BLOCK(sb) - 1) / 1632 db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) /
1633 EXT3_DESC_PER_BLOCK(sb); 1633 EXT4_DESC_PER_BLOCK(sb);
1634 sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *), 1634 sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *),
1635 GFP_KERNEL); 1635 GFP_KERNEL);
1636 if (sbi->s_group_desc == NULL) { 1636 if (sbi->s_group_desc == NULL) {
1637 printk (KERN_ERR "EXT3-fs: not enough memory\n"); 1637 printk (KERN_ERR "EXT4-fs: not enough memory\n");
1638 goto failed_mount; 1638 goto failed_mount;
1639 } 1639 }
1640 1640
@@ -1644,14 +1644,14 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1644 block = descriptor_loc(sb, logic_sb_block, i); 1644 block = descriptor_loc(sb, logic_sb_block, i);
1645 sbi->s_group_desc[i] = sb_bread(sb, block); 1645 sbi->s_group_desc[i] = sb_bread(sb, block);
1646 if (!sbi->s_group_desc[i]) { 1646 if (!sbi->s_group_desc[i]) {
1647 printk (KERN_ERR "EXT3-fs: " 1647 printk (KERN_ERR "EXT4-fs: "
1648 "can't read group descriptor %d\n", i); 1648 "can't read group descriptor %d\n", i);
1649 db_count = i; 1649 db_count = i;
1650 goto failed_mount2; 1650 goto failed_mount2;
1651 } 1651 }
1652 } 1652 }
1653 if (!ext3_check_descriptors (sb)) { 1653 if (!ext4_check_descriptors (sb)) {
1654 printk(KERN_ERR "EXT3-fs: group descriptors corrupted!\n"); 1654 printk(KERN_ERR "EXT4-fs: group descriptors corrupted!\n");
1655 goto failed_mount2; 1655 goto failed_mount2;
1656 } 1656 }
1657 sbi->s_gdb_count = db_count; 1657 sbi->s_gdb_count = db_count;
@@ -1659,11 +1659,11 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1659 spin_lock_init(&sbi->s_next_gen_lock); 1659 spin_lock_init(&sbi->s_next_gen_lock);
1660 1660
1661 percpu_counter_init(&sbi->s_freeblocks_counter, 1661 percpu_counter_init(&sbi->s_freeblocks_counter,
1662 ext3_count_free_blocks(sb)); 1662 ext4_count_free_blocks(sb));
1663 percpu_counter_init(&sbi->s_freeinodes_counter, 1663 percpu_counter_init(&sbi->s_freeinodes_counter,
1664 ext3_count_free_inodes(sb)); 1664 ext4_count_free_inodes(sb));
1665 percpu_counter_init(&sbi->s_dirs_counter, 1665 percpu_counter_init(&sbi->s_dirs_counter,
1666 ext3_count_dirs(sb)); 1666 ext4_count_dirs(sb));
1667 1667
1668 /* per fileystem reservation list head & lock */ 1668 /* per fileystem reservation list head & lock */
1669 spin_lock_init(&sbi->s_rsv_window_lock); 1669 spin_lock_init(&sbi->s_rsv_window_lock);
@@ -1672,45 +1672,45 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1672 * reservation window list --- it gives us a placeholder for 1672 * reservation window list --- it gives us a placeholder for
1673 * append-at-start-of-list which makes the allocation logic 1673 * append-at-start-of-list which makes the allocation logic
1674 * _much_ simpler. */ 1674 * _much_ simpler. */
1675 sbi->s_rsv_window_head.rsv_start = EXT3_RESERVE_WINDOW_NOT_ALLOCATED; 1675 sbi->s_rsv_window_head.rsv_start = EXT4_RESERVE_WINDOW_NOT_ALLOCATED;
1676 sbi->s_rsv_window_head.rsv_end = EXT3_RESERVE_WINDOW_NOT_ALLOCATED; 1676 sbi->s_rsv_window_head.rsv_end = EXT4_RESERVE_WINDOW_NOT_ALLOCATED;
1677 sbi->s_rsv_window_head.rsv_alloc_hit = 0; 1677 sbi->s_rsv_window_head.rsv_alloc_hit = 0;
1678 sbi->s_rsv_window_head.rsv_goal_size = 0; 1678 sbi->s_rsv_window_head.rsv_goal_size = 0;
1679 ext3_rsv_window_add(sb, &sbi->s_rsv_window_head); 1679 ext4_rsv_window_add(sb, &sbi->s_rsv_window_head);
1680 1680
1681 /* 1681 /*
1682 * set up enough so that it can read an inode 1682 * set up enough so that it can read an inode
1683 */ 1683 */
1684 sb->s_op = &ext3_sops; 1684 sb->s_op = &ext4_sops;
1685 sb->s_export_op = &ext3_export_ops; 1685 sb->s_export_op = &ext4_export_ops;
1686 sb->s_xattr = ext3_xattr_handlers; 1686 sb->s_xattr = ext4_xattr_handlers;
1687#ifdef CONFIG_QUOTA 1687#ifdef CONFIG_QUOTA
1688 sb->s_qcop = &ext3_qctl_operations; 1688 sb->s_qcop = &ext4_qctl_operations;
1689 sb->dq_op = &ext3_quota_operations; 1689 sb->dq_op = &ext4_quota_operations;
1690#endif 1690#endif
1691 INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */ 1691 INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
1692 1692
1693 sb->s_root = NULL; 1693 sb->s_root = NULL;
1694 1694
1695 needs_recovery = (es->s_last_orphan != 0 || 1695 needs_recovery = (es->s_last_orphan != 0 ||
1696 EXT3_HAS_INCOMPAT_FEATURE(sb, 1696 EXT4_HAS_INCOMPAT_FEATURE(sb,
1697 EXT3_FEATURE_INCOMPAT_RECOVER)); 1697 EXT4_FEATURE_INCOMPAT_RECOVER));
1698 1698
1699 /* 1699 /*
1700 * The first inode we look at is the journal inode. Don't try 1700 * The first inode we look at is the journal inode. Don't try
1701 * root first: it may be modified in the journal! 1701 * root first: it may be modified in the journal!
1702 */ 1702 */
1703 if (!test_opt(sb, NOLOAD) && 1703 if (!test_opt(sb, NOLOAD) &&
1704 EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) { 1704 EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {
1705 if (ext3_load_journal(sb, es, journal_devnum)) 1705 if (ext4_load_journal(sb, es, journal_devnum))
1706 goto failed_mount3; 1706 goto failed_mount3;
1707 } else if (journal_inum) { 1707 } else if (journal_inum) {
1708 if (ext3_create_journal(sb, es, journal_inum)) 1708 if (ext4_create_journal(sb, es, journal_inum))
1709 goto failed_mount3; 1709 goto failed_mount3;
1710 } else { 1710 } else {
1711 if (!silent) 1711 if (!silent)
1712 printk (KERN_ERR 1712 printk (KERN_ERR
1713 "ext3: No journal on filesystem on %s\n", 1713 "ext4: No journal on filesystem on %s\n",
1714 sb->s_id); 1714 sb->s_id);
1715 goto failed_mount3; 1715 goto failed_mount3;
1716 } 1716 }
@@ -1729,11 +1729,11 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1729 set_opt(sbi->s_mount_opt, JOURNAL_DATA); 1729 set_opt(sbi->s_mount_opt, JOURNAL_DATA);
1730 break; 1730 break;
1731 1731
1732 case EXT3_MOUNT_ORDERED_DATA: 1732 case EXT4_MOUNT_ORDERED_DATA:
1733 case EXT3_MOUNT_WRITEBACK_DATA: 1733 case EXT4_MOUNT_WRITEBACK_DATA:
1734 if (!journal_check_available_features 1734 if (!journal_check_available_features
1735 (sbi->s_journal, 0, 0, JFS_FEATURE_INCOMPAT_REVOKE)) { 1735 (sbi->s_journal, 0, 0, JFS_FEATURE_INCOMPAT_REVOKE)) {
1736 printk(KERN_ERR "EXT3-fs: Journal does not support " 1736 printk(KERN_ERR "EXT4-fs: Journal does not support "
1737 "requested data journaling mode\n"); 1737 "requested data journaling mode\n");
1738 goto failed_mount4; 1738 goto failed_mount4;
1739 } 1739 }
@@ -1742,8 +1742,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1742 } 1742 }
1743 1743
1744 if (test_opt(sb, NOBH)) { 1744 if (test_opt(sb, NOBH)) {
1745 if (!(test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA)) { 1745 if (!(test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)) {
1746 printk(KERN_WARNING "EXT3-fs: Ignoring nobh option - " 1746 printk(KERN_WARNING "EXT4-fs: Ignoring nobh option - "
1747 "its supported only with writeback mode\n"); 1747 "its supported only with writeback mode\n");
1748 clear_opt(sbi->s_mount_opt, NOBH); 1748 clear_opt(sbi->s_mount_opt, NOBH);
1749 } 1749 }
@@ -1753,21 +1753,21 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1753 * so we can safely mount the rest of the filesystem now. 1753 * so we can safely mount the rest of the filesystem now.
1754 */ 1754 */
1755 1755
1756 root = iget(sb, EXT3_ROOT_INO); 1756 root = iget(sb, EXT4_ROOT_INO);
1757 sb->s_root = d_alloc_root(root); 1757 sb->s_root = d_alloc_root(root);
1758 if (!sb->s_root) { 1758 if (!sb->s_root) {
1759 printk(KERN_ERR "EXT3-fs: get root inode failed\n"); 1759 printk(KERN_ERR "EXT4-fs: get root inode failed\n");
1760 iput(root); 1760 iput(root);
1761 goto failed_mount4; 1761 goto failed_mount4;
1762 } 1762 }
1763 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { 1763 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
1764 dput(sb->s_root); 1764 dput(sb->s_root);
1765 sb->s_root = NULL; 1765 sb->s_root = NULL;
1766 printk(KERN_ERR "EXT3-fs: corrupt root inode, run e2fsck\n"); 1766 printk(KERN_ERR "EXT4-fs: corrupt root inode, run e2fsck\n");
1767 goto failed_mount4; 1767 goto failed_mount4;
1768 } 1768 }
1769 1769
1770 ext3_setup_super (sb, es, sb->s_flags & MS_RDONLY); 1770 ext4_setup_super (sb, es, sb->s_flags & MS_RDONLY);
1771 /* 1771 /*
1772 * akpm: core read_super() calls in here with the superblock locked. 1772 * akpm: core read_super() calls in here with the superblock locked.
1773 * That deadlocks, because orphan cleanup needs to lock the superblock 1773 * That deadlocks, because orphan cleanup needs to lock the superblock
@@ -1776,23 +1776,23 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1776 * and aviro says that's the only reason for hanging onto the 1776 * and aviro says that's the only reason for hanging onto the
1777 * superblock lock. 1777 * superblock lock.
1778 */ 1778 */
1779 EXT3_SB(sb)->s_mount_state |= EXT3_ORPHAN_FS; 1779 EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS;
1780 ext3_orphan_cleanup(sb, es); 1780 ext4_orphan_cleanup(sb, es);
1781 EXT3_SB(sb)->s_mount_state &= ~EXT3_ORPHAN_FS; 1781 EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS;
1782 if (needs_recovery) 1782 if (needs_recovery)
1783 printk (KERN_INFO "EXT3-fs: recovery complete.\n"); 1783 printk (KERN_INFO "EXT4-fs: recovery complete.\n");
1784 ext3_mark_recovery_complete(sb, es); 1784 ext4_mark_recovery_complete(sb, es);
1785 printk (KERN_INFO "EXT3-fs: mounted filesystem with %s data mode.\n", 1785 printk (KERN_INFO "EXT4-fs: mounted filesystem with %s data mode.\n",
1786 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA ? "journal": 1786 test_opt(sb,DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA ? "journal":
1787 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered": 1787 test_opt(sb,DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA ? "ordered":
1788 "writeback"); 1788 "writeback");
1789 1789
1790 lock_kernel(); 1790 lock_kernel();
1791 return 0; 1791 return 0;
1792 1792
1793cantfind_ext3: 1793cantfind_ext4:
1794 if (!silent) 1794 if (!silent)
1795 printk(KERN_ERR "VFS: Can't find ext3 filesystem on dev %s.\n", 1795 printk(KERN_ERR "VFS: Can't find ext4 filesystem on dev %s.\n",
1796 sb->s_id); 1796 sb->s_id);
1797 goto failed_mount; 1797 goto failed_mount;
1798 1798
@@ -1811,7 +1811,7 @@ failed_mount:
1811 for (i = 0; i < MAXQUOTAS; i++) 1811 for (i = 0; i < MAXQUOTAS; i++)
1812 kfree(sbi->s_qf_names[i]); 1812 kfree(sbi->s_qf_names[i]);
1813#endif 1813#endif
1814 ext3_blkdev_remove(sbi); 1814 ext4_blkdev_remove(sbi);
1815 brelse(bh); 1815 brelse(bh);
1816out_fail: 1816out_fail:
1817 sb->s_fs_info = NULL; 1817 sb->s_fs_info = NULL;
@@ -1825,13 +1825,13 @@ out_fail:
1825 * initial mount, once the journal has been initialised but before we've 1825 * initial mount, once the journal has been initialised but before we've
1826 * done any recovery; and again on any subsequent remount. 1826 * done any recovery; and again on any subsequent remount.
1827 */ 1827 */
1828static void ext3_init_journal_params(struct super_block *sb, journal_t *journal) 1828static void ext4_init_journal_params(struct super_block *sb, journal_t *journal)
1829{ 1829{
1830 struct ext3_sb_info *sbi = EXT3_SB(sb); 1830 struct ext4_sb_info *sbi = EXT4_SB(sb);
1831 1831
1832 if (sbi->s_commit_interval) 1832 if (sbi->s_commit_interval)
1833 journal->j_commit_interval = sbi->s_commit_interval; 1833 journal->j_commit_interval = sbi->s_commit_interval;
1834 /* We could also set up an ext3-specific default for the commit 1834 /* We could also set up an ext4-specific default for the commit
1835 * interval here, but for now we'll just fall back to the jbd 1835 * interval here, but for now we'll just fall back to the jbd
1836 * default. */ 1836 * default. */
1837 1837
@@ -1843,7 +1843,7 @@ static void ext3_init_journal_params(struct super_block *sb, journal_t *journal)
1843 spin_unlock(&journal->j_state_lock); 1843 spin_unlock(&journal->j_state_lock);
1844} 1844}
1845 1845
1846static journal_t *ext3_get_journal(struct super_block *sb, 1846static journal_t *ext4_get_journal(struct super_block *sb,
1847 unsigned int journal_inum) 1847 unsigned int journal_inum)
1848{ 1848{
1849 struct inode *journal_inode; 1849 struct inode *journal_inode;
@@ -1855,55 +1855,55 @@ static journal_t *ext3_get_journal(struct super_block *sb,
1855 1855
1856 journal_inode = iget(sb, journal_inum); 1856 journal_inode = iget(sb, journal_inum);
1857 if (!journal_inode) { 1857 if (!journal_inode) {
1858 printk(KERN_ERR "EXT3-fs: no journal found.\n"); 1858 printk(KERN_ERR "EXT4-fs: no journal found.\n");
1859 return NULL; 1859 return NULL;
1860 } 1860 }
1861 if (!journal_inode->i_nlink) { 1861 if (!journal_inode->i_nlink) {
1862 make_bad_inode(journal_inode); 1862 make_bad_inode(journal_inode);
1863 iput(journal_inode); 1863 iput(journal_inode);
1864 printk(KERN_ERR "EXT3-fs: journal inode is deleted.\n"); 1864 printk(KERN_ERR "EXT4-fs: journal inode is deleted.\n");
1865 return NULL; 1865 return NULL;
1866 } 1866 }
1867 1867
1868 jbd_debug(2, "Journal inode found at %p: %Ld bytes\n", 1868 jbd_debug(2, "Journal inode found at %p: %Ld bytes\n",
1869 journal_inode, journal_inode->i_size); 1869 journal_inode, journal_inode->i_size);
1870 if (is_bad_inode(journal_inode) || !S_ISREG(journal_inode->i_mode)) { 1870 if (is_bad_inode(journal_inode) || !S_ISREG(journal_inode->i_mode)) {
1871 printk(KERN_ERR "EXT3-fs: invalid journal inode.\n"); 1871 printk(KERN_ERR "EXT4-fs: invalid journal inode.\n");
1872 iput(journal_inode); 1872 iput(journal_inode);
1873 return NULL; 1873 return NULL;
1874 } 1874 }
1875 1875
1876 journal = journal_init_inode(journal_inode); 1876 journal = journal_init_inode(journal_inode);
1877 if (!journal) { 1877 if (!journal) {
1878 printk(KERN_ERR "EXT3-fs: Could not load journal inode\n"); 1878 printk(KERN_ERR "EXT4-fs: Could not load journal inode\n");
1879 iput(journal_inode); 1879 iput(journal_inode);
1880 return NULL; 1880 return NULL;
1881 } 1881 }
1882 journal->j_private = sb; 1882 journal->j_private = sb;
1883 ext3_init_journal_params(sb, journal); 1883 ext4_init_journal_params(sb, journal);
1884 return journal; 1884 return journal;
1885} 1885}
1886 1886
1887static journal_t *ext3_get_dev_journal(struct super_block *sb, 1887static journal_t *ext4_get_dev_journal(struct super_block *sb,
1888 dev_t j_dev) 1888 dev_t j_dev)
1889{ 1889{
1890 struct buffer_head * bh; 1890 struct buffer_head * bh;
1891 journal_t *journal; 1891 journal_t *journal;
1892 ext3_fsblk_t start; 1892 ext4_fsblk_t start;
1893 ext3_fsblk_t len; 1893 ext4_fsblk_t len;
1894 int hblock, blocksize; 1894 int hblock, blocksize;
1895 ext3_fsblk_t sb_block; 1895 ext4_fsblk_t sb_block;
1896 unsigned long offset; 1896 unsigned long offset;
1897 struct ext3_super_block * es; 1897 struct ext4_super_block * es;
1898 struct block_device *bdev; 1898 struct block_device *bdev;
1899 1899
1900 bdev = ext3_blkdev_get(j_dev); 1900 bdev = ext4_blkdev_get(j_dev);
1901 if (bdev == NULL) 1901 if (bdev == NULL)
1902 return NULL; 1902 return NULL;
1903 1903
1904 if (bd_claim(bdev, sb)) { 1904 if (bd_claim(bdev, sb)) {
1905 printk(KERN_ERR 1905 printk(KERN_ERR
1906 "EXT3: failed to claim external journal device.\n"); 1906 "EXT4: failed to claim external journal device.\n");
1907 blkdev_put(bdev); 1907 blkdev_put(bdev);
1908 return NULL; 1908 return NULL;
1909 } 1909 }
@@ -1912,31 +1912,31 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb,
1912 hblock = bdev_hardsect_size(bdev); 1912 hblock = bdev_hardsect_size(bdev);
1913 if (blocksize < hblock) { 1913 if (blocksize < hblock) {
1914 printk(KERN_ERR 1914 printk(KERN_ERR
1915 "EXT3-fs: blocksize too small for journal device.\n"); 1915 "EXT4-fs: blocksize too small for journal device.\n");
1916 goto out_bdev; 1916 goto out_bdev;
1917 } 1917 }
1918 1918
1919 sb_block = EXT3_MIN_BLOCK_SIZE / blocksize; 1919 sb_block = EXT4_MIN_BLOCK_SIZE / blocksize;
1920 offset = EXT3_MIN_BLOCK_SIZE % blocksize; 1920 offset = EXT4_MIN_BLOCK_SIZE % blocksize;
1921 set_blocksize(bdev, blocksize); 1921 set_blocksize(bdev, blocksize);
1922 if (!(bh = __bread(bdev, sb_block, blocksize))) { 1922 if (!(bh = __bread(bdev, sb_block, blocksize))) {
1923 printk(KERN_ERR "EXT3-fs: couldn't read superblock of " 1923 printk(KERN_ERR "EXT4-fs: couldn't read superblock of "
1924 "external journal\n"); 1924 "external journal\n");
1925 goto out_bdev; 1925 goto out_bdev;
1926 } 1926 }
1927 1927
1928 es = (struct ext3_super_block *) (((char *)bh->b_data) + offset); 1928 es = (struct ext4_super_block *) (((char *)bh->b_data) + offset);
1929 if ((le16_to_cpu(es->s_magic) != EXT3_SUPER_MAGIC) || 1929 if ((le16_to_cpu(es->s_magic) != EXT4_SUPER_MAGIC) ||
1930 !(le32_to_cpu(es->s_feature_incompat) & 1930 !(le32_to_cpu(es->s_feature_incompat) &
1931 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) { 1931 EXT4_FEATURE_INCOMPAT_JOURNAL_DEV)) {
1932 printk(KERN_ERR "EXT3-fs: external journal has " 1932 printk(KERN_ERR "EXT4-fs: external journal has "
1933 "bad superblock\n"); 1933 "bad superblock\n");
1934 brelse(bh); 1934 brelse(bh);
1935 goto out_bdev; 1935 goto out_bdev;
1936 } 1936 }
1937 1937
1938 if (memcmp(EXT3_SB(sb)->s_es->s_journal_uuid, es->s_uuid, 16)) { 1938 if (memcmp(EXT4_SB(sb)->s_es->s_journal_uuid, es->s_uuid, 16)) {
1939 printk(KERN_ERR "EXT3-fs: journal UUID does not match\n"); 1939 printk(KERN_ERR "EXT4-fs: journal UUID does not match\n");
1940 brelse(bh); 1940 brelse(bh);
1941 goto out_bdev; 1941 goto out_bdev;
1942 } 1942 }
@@ -1948,34 +1948,34 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb,
1948 journal = journal_init_dev(bdev, sb->s_bdev, 1948 journal = journal_init_dev(bdev, sb->s_bdev,
1949 start, len, blocksize); 1949 start, len, blocksize);
1950 if (!journal) { 1950 if (!journal) {
1951 printk(KERN_ERR "EXT3-fs: failed to create device journal\n"); 1951 printk(KERN_ERR "EXT4-fs: failed to create device journal\n");
1952 goto out_bdev; 1952 goto out_bdev;
1953 } 1953 }
1954 journal->j_private = sb; 1954 journal->j_private = sb;
1955 ll_rw_block(READ, 1, &journal->j_sb_buffer); 1955 ll_rw_block(READ, 1, &journal->j_sb_buffer);
1956 wait_on_buffer(journal->j_sb_buffer); 1956 wait_on_buffer(journal->j_sb_buffer);
1957 if (!buffer_uptodate(journal->j_sb_buffer)) { 1957 if (!buffer_uptodate(journal->j_sb_buffer)) {
1958 printk(KERN_ERR "EXT3-fs: I/O error on journal device\n"); 1958 printk(KERN_ERR "EXT4-fs: I/O error on journal device\n");
1959 goto out_journal; 1959 goto out_journal;
1960 } 1960 }
1961 if (be32_to_cpu(journal->j_superblock->s_nr_users) != 1) { 1961 if (be32_to_cpu(journal->j_superblock->s_nr_users) != 1) {
1962 printk(KERN_ERR "EXT3-fs: External journal has more than one " 1962 printk(KERN_ERR "EXT4-fs: External journal has more than one "
1963 "user (unsupported) - %d\n", 1963 "user (unsupported) - %d\n",
1964 be32_to_cpu(journal->j_superblock->s_nr_users)); 1964 be32_to_cpu(journal->j_superblock->s_nr_users));
1965 goto out_journal; 1965 goto out_journal;
1966 } 1966 }
1967 EXT3_SB(sb)->journal_bdev = bdev; 1967 EXT4_SB(sb)->journal_bdev = bdev;
1968 ext3_init_journal_params(sb, journal); 1968 ext4_init_journal_params(sb, journal);
1969 return journal; 1969 return journal;
1970out_journal: 1970out_journal:
1971 journal_destroy(journal); 1971 journal_destroy(journal);
1972out_bdev: 1972out_bdev:
1973 ext3_blkdev_put(bdev); 1973 ext4_blkdev_put(bdev);
1974 return NULL; 1974 return NULL;
1975} 1975}
1976 1976
1977static int ext3_load_journal(struct super_block *sb, 1977static int ext4_load_journal(struct super_block *sb,
1978 struct ext3_super_block *es, 1978 struct ext4_super_block *es,
1979 unsigned long journal_devnum) 1979 unsigned long journal_devnum)
1980{ 1980{
1981 journal_t *journal; 1981 journal_t *journal;
@@ -1986,7 +1986,7 @@ static int ext3_load_journal(struct super_block *sb,
1986 1986
1987 if (journal_devnum && 1987 if (journal_devnum &&
1988 journal_devnum != le32_to_cpu(es->s_journal_dev)) { 1988 journal_devnum != le32_to_cpu(es->s_journal_dev)) {
1989 printk(KERN_INFO "EXT3-fs: external journal device major/minor " 1989 printk(KERN_INFO "EXT4-fs: external journal device major/minor "
1990 "numbers have changed\n"); 1990 "numbers have changed\n");
1991 journal_dev = new_decode_dev(journal_devnum); 1991 journal_dev = new_decode_dev(journal_devnum);
1992 } else 1992 } else
@@ -2000,56 +2000,56 @@ static int ext3_load_journal(struct super_block *sb,
2000 * can get read-write access to the device. 2000 * can get read-write access to the device.
2001 */ 2001 */
2002 2002
2003 if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER)) { 2003 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) {
2004 if (sb->s_flags & MS_RDONLY) { 2004 if (sb->s_flags & MS_RDONLY) {
2005 printk(KERN_INFO "EXT3-fs: INFO: recovery " 2005 printk(KERN_INFO "EXT4-fs: INFO: recovery "
2006 "required on readonly filesystem.\n"); 2006 "required on readonly filesystem.\n");
2007 if (really_read_only) { 2007 if (really_read_only) {
2008 printk(KERN_ERR "EXT3-fs: write access " 2008 printk(KERN_ERR "EXT4-fs: write access "
2009 "unavailable, cannot proceed.\n"); 2009 "unavailable, cannot proceed.\n");
2010 return -EROFS; 2010 return -EROFS;
2011 } 2011 }
2012 printk (KERN_INFO "EXT3-fs: write access will " 2012 printk (KERN_INFO "EXT4-fs: write access will "
2013 "be enabled during recovery.\n"); 2013 "be enabled during recovery.\n");
2014 } 2014 }
2015 } 2015 }
2016 2016
2017 if (journal_inum && journal_dev) { 2017 if (journal_inum && journal_dev) {
2018 printk(KERN_ERR "EXT3-fs: filesystem has both journal " 2018 printk(KERN_ERR "EXT4-fs: filesystem has both journal "
2019 "and inode journals!\n"); 2019 "and inode journals!\n");
2020 return -EINVAL; 2020 return -EINVAL;
2021 } 2021 }
2022 2022
2023 if (journal_inum) { 2023 if (journal_inum) {
2024 if (!(journal = ext3_get_journal(sb, journal_inum))) 2024 if (!(journal = ext4_get_journal(sb, journal_inum)))
2025 return -EINVAL; 2025 return -EINVAL;
2026 } else { 2026 } else {
2027 if (!(journal = ext3_get_dev_journal(sb, journal_dev))) 2027 if (!(journal = ext4_get_dev_journal(sb, journal_dev)))
2028 return -EINVAL; 2028 return -EINVAL;
2029 } 2029 }
2030 2030
2031 if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) { 2031 if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) {
2032 err = journal_update_format(journal); 2032 err = journal_update_format(journal);
2033 if (err) { 2033 if (err) {
2034 printk(KERN_ERR "EXT3-fs: error updating journal.\n"); 2034 printk(KERN_ERR "EXT4-fs: error updating journal.\n");
2035 journal_destroy(journal); 2035 journal_destroy(journal);
2036 return err; 2036 return err;
2037 } 2037 }
2038 } 2038 }
2039 2039
2040 if (!EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER)) 2040 if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER))
2041 err = journal_wipe(journal, !really_read_only); 2041 err = journal_wipe(journal, !really_read_only);
2042 if (!err) 2042 if (!err)
2043 err = journal_load(journal); 2043 err = journal_load(journal);
2044 2044
2045 if (err) { 2045 if (err) {
2046 printk(KERN_ERR "EXT3-fs: error loading journal.\n"); 2046 printk(KERN_ERR "EXT4-fs: error loading journal.\n");
2047 journal_destroy(journal); 2047 journal_destroy(journal);
2048 return err; 2048 return err;
2049 } 2049 }
2050 2050
2051 EXT3_SB(sb)->s_journal = journal; 2051 EXT4_SB(sb)->s_journal = journal;
2052 ext3_clear_journal_err(sb, es); 2052 ext4_clear_journal_err(sb, es);
2053 2053
2054 if (journal_devnum && 2054 if (journal_devnum &&
2055 journal_devnum != le32_to_cpu(es->s_journal_dev)) { 2055 journal_devnum != le32_to_cpu(es->s_journal_dev)) {
@@ -2057,62 +2057,62 @@ static int ext3_load_journal(struct super_block *sb,
2057 sb->s_dirt = 1; 2057 sb->s_dirt = 1;
2058 2058
2059 /* Make sure we flush the recovery flag to disk. */ 2059 /* Make sure we flush the recovery flag to disk. */
2060 ext3_commit_super(sb, es, 1); 2060 ext4_commit_super(sb, es, 1);
2061 } 2061 }
2062 2062
2063 return 0; 2063 return 0;
2064} 2064}
2065 2065
2066static int ext3_create_journal(struct super_block * sb, 2066static int ext4_create_journal(struct super_block * sb,
2067 struct ext3_super_block * es, 2067 struct ext4_super_block * es,
2068 unsigned int journal_inum) 2068 unsigned int journal_inum)
2069{ 2069{
2070 journal_t *journal; 2070 journal_t *journal;
2071 2071
2072 if (sb->s_flags & MS_RDONLY) { 2072 if (sb->s_flags & MS_RDONLY) {
2073 printk(KERN_ERR "EXT3-fs: readonly filesystem when trying to " 2073 printk(KERN_ERR "EXT4-fs: readonly filesystem when trying to "
2074 "create journal.\n"); 2074 "create journal.\n");
2075 return -EROFS; 2075 return -EROFS;
2076 } 2076 }
2077 2077
2078 if (!(journal = ext3_get_journal(sb, journal_inum))) 2078 if (!(journal = ext4_get_journal(sb, journal_inum)))
2079 return -EINVAL; 2079 return -EINVAL;
2080 2080
2081 printk(KERN_INFO "EXT3-fs: creating new journal on inode %u\n", 2081 printk(KERN_INFO "EXT4-fs: creating new journal on inode %u\n",
2082 journal_inum); 2082 journal_inum);
2083 2083
2084 if (journal_create(journal)) { 2084 if (journal_create(journal)) {
2085 printk(KERN_ERR "EXT3-fs: error creating journal.\n"); 2085 printk(KERN_ERR "EXT4-fs: error creating journal.\n");
2086 journal_destroy(journal); 2086 journal_destroy(journal);
2087 return -EIO; 2087 return -EIO;
2088 } 2088 }
2089 2089
2090 EXT3_SB(sb)->s_journal = journal; 2090 EXT4_SB(sb)->s_journal = journal;
2091 2091
2092 ext3_update_dynamic_rev(sb); 2092 ext4_update_dynamic_rev(sb);
2093 EXT3_SET_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); 2093 EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
2094 EXT3_SET_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL); 2094 EXT4_SET_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL);
2095 2095
2096 es->s_journal_inum = cpu_to_le32(journal_inum); 2096 es->s_journal_inum = cpu_to_le32(journal_inum);
2097 sb->s_dirt = 1; 2097 sb->s_dirt = 1;
2098 2098
2099 /* Make sure we flush the recovery flag to disk. */ 2099 /* Make sure we flush the recovery flag to disk. */
2100 ext3_commit_super(sb, es, 1); 2100 ext4_commit_super(sb, es, 1);
2101 2101
2102 return 0; 2102 return 0;
2103} 2103}
2104 2104
2105static void ext3_commit_super (struct super_block * sb, 2105static void ext4_commit_super (struct super_block * sb,
2106 struct ext3_super_block * es, 2106 struct ext4_super_block * es,
2107 int sync) 2107 int sync)
2108{ 2108{
2109 struct buffer_head *sbh = EXT3_SB(sb)->s_sbh; 2109 struct buffer_head *sbh = EXT4_SB(sb)->s_sbh;
2110 2110
2111 if (!sbh) 2111 if (!sbh)
2112 return; 2112 return;
2113 es->s_wtime = cpu_to_le32(get_seconds()); 2113 es->s_wtime = cpu_to_le32(get_seconds());
2114 es->s_free_blocks_count = cpu_to_le32(ext3_count_free_blocks(sb)); 2114 es->s_free_blocks_count = cpu_to_le32(ext4_count_free_blocks(sb));
2115 es->s_free_inodes_count = cpu_to_le32(ext3_count_free_inodes(sb)); 2115 es->s_free_inodes_count = cpu_to_le32(ext4_count_free_inodes(sb));
2116 BUFFER_TRACE(sbh, "marking dirty"); 2116 BUFFER_TRACE(sbh, "marking dirty");
2117 mark_buffer_dirty(sbh); 2117 mark_buffer_dirty(sbh);
2118 if (sync) 2118 if (sync)
@@ -2125,18 +2125,18 @@ static void ext3_commit_super (struct super_block * sb,
2125 * remounting) the filesystem readonly, then we will end up with a 2125 * remounting) the filesystem readonly, then we will end up with a
2126 * consistent fs on disk. Record that fact. 2126 * consistent fs on disk. Record that fact.
2127 */ 2127 */
2128static void ext3_mark_recovery_complete(struct super_block * sb, 2128static void ext4_mark_recovery_complete(struct super_block * sb,
2129 struct ext3_super_block * es) 2129 struct ext4_super_block * es)
2130{ 2130{
2131 journal_t *journal = EXT3_SB(sb)->s_journal; 2131 journal_t *journal = EXT4_SB(sb)->s_journal;
2132 2132
2133 journal_lock_updates(journal); 2133 journal_lock_updates(journal);
2134 journal_flush(journal); 2134 journal_flush(journal);
2135 if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER) && 2135 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER) &&
2136 sb->s_flags & MS_RDONLY) { 2136 sb->s_flags & MS_RDONLY) {
2137 EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); 2137 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
2138 sb->s_dirt = 0; 2138 sb->s_dirt = 0;
2139 ext3_commit_super(sb, es, 1); 2139 ext4_commit_super(sb, es, 1);
2140 } 2140 }
2141 journal_unlock_updates(journal); 2141 journal_unlock_updates(journal);
2142} 2142}
@@ -2146,33 +2146,33 @@ static void ext3_mark_recovery_complete(struct super_block * sb,
2146 * has recorded an error from a previous lifetime, move that error to the 2146 * has recorded an error from a previous lifetime, move that error to the
2147 * main filesystem now. 2147 * main filesystem now.
2148 */ 2148 */
2149static void ext3_clear_journal_err(struct super_block * sb, 2149static void ext4_clear_journal_err(struct super_block * sb,
2150 struct ext3_super_block * es) 2150 struct ext4_super_block * es)
2151{ 2151{
2152 journal_t *journal; 2152 journal_t *journal;
2153 int j_errno; 2153 int j_errno;
2154 const char *errstr; 2154 const char *errstr;
2155 2155
2156 journal = EXT3_SB(sb)->s_journal; 2156 journal = EXT4_SB(sb)->s_journal;
2157 2157
2158 /* 2158 /*
2159 * Now check for any error status which may have been recorded in the 2159 * Now check for any error status which may have been recorded in the
2160 * journal by a prior ext3_error() or ext3_abort() 2160 * journal by a prior ext4_error() or ext4_abort()
2161 */ 2161 */
2162 2162
2163 j_errno = journal_errno(journal); 2163 j_errno = journal_errno(journal);
2164 if (j_errno) { 2164 if (j_errno) {
2165 char nbuf[16]; 2165 char nbuf[16];
2166 2166
2167 errstr = ext3_decode_error(sb, j_errno, nbuf); 2167 errstr = ext4_decode_error(sb, j_errno, nbuf);
2168 ext3_warning(sb, __FUNCTION__, "Filesystem error recorded " 2168 ext4_warning(sb, __FUNCTION__, "Filesystem error recorded "
2169 "from previous mount: %s", errstr); 2169 "from previous mount: %s", errstr);
2170 ext3_warning(sb, __FUNCTION__, "Marking fs in need of " 2170 ext4_warning(sb, __FUNCTION__, "Marking fs in need of "
2171 "filesystem check."); 2171 "filesystem check.");
2172 2172
2173 EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; 2173 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
2174 es->s_state |= cpu_to_le16(EXT3_ERROR_FS); 2174 es->s_state |= cpu_to_le16(EXT4_ERROR_FS);
2175 ext3_commit_super (sb, es, 1); 2175 ext4_commit_super (sb, es, 1);
2176 2176
2177 journal_clear_err(journal); 2177 journal_clear_err(journal);
2178 } 2178 }
@@ -2182,7 +2182,7 @@ static void ext3_clear_journal_err(struct super_block * sb,
2182 * Force the running and committing transactions to commit, 2182 * Force the running and committing transactions to commit,
2183 * and wait on the commit. 2183 * and wait on the commit.
2184 */ 2184 */
2185int ext3_force_commit(struct super_block *sb) 2185int ext4_force_commit(struct super_block *sb)
2186{ 2186{
2187 journal_t *journal; 2187 journal_t *journal;
2188 int ret; 2188 int ret;
@@ -2190,14 +2190,14 @@ int ext3_force_commit(struct super_block *sb)
2190 if (sb->s_flags & MS_RDONLY) 2190 if (sb->s_flags & MS_RDONLY)
2191 return 0; 2191 return 0;
2192 2192
2193 journal = EXT3_SB(sb)->s_journal; 2193 journal = EXT4_SB(sb)->s_journal;
2194 sb->s_dirt = 0; 2194 sb->s_dirt = 0;
2195 ret = ext3_journal_force_commit(journal); 2195 ret = ext4_journal_force_commit(journal);
2196 return ret; 2196 return ret;
2197} 2197}
2198 2198
2199/* 2199/*
2200 * Ext3 always journals updates to the superblock itself, so we don't 2200 * Ext4 always journals updates to the superblock itself, so we don't
2201 * have to propagate any other updates to the superblock on disk at this 2201 * have to propagate any other updates to the superblock on disk at this
2202 * point. Just start an async writeback to get the buffers on their way 2202 * point. Just start an async writeback to get the buffers on their way
2203 * to the disk. 2203 * to the disk.
@@ -2205,21 +2205,21 @@ int ext3_force_commit(struct super_block *sb)
2205 * This implicitly triggers the writebehind on sync(). 2205 * This implicitly triggers the writebehind on sync().
2206 */ 2206 */
2207 2207
2208static void ext3_write_super (struct super_block * sb) 2208static void ext4_write_super (struct super_block * sb)
2209{ 2209{
2210 if (mutex_trylock(&sb->s_lock) != 0) 2210 if (mutex_trylock(&sb->s_lock) != 0)
2211 BUG(); 2211 BUG();
2212 sb->s_dirt = 0; 2212 sb->s_dirt = 0;
2213} 2213}
2214 2214
2215static int ext3_sync_fs(struct super_block *sb, int wait) 2215static int ext4_sync_fs(struct super_block *sb, int wait)
2216{ 2216{
2217 tid_t target; 2217 tid_t target;
2218 2218
2219 sb->s_dirt = 0; 2219 sb->s_dirt = 0;
2220 if (journal_start_commit(EXT3_SB(sb)->s_journal, &target)) { 2220 if (journal_start_commit(EXT4_SB(sb)->s_journal, &target)) {
2221 if (wait) 2221 if (wait)
2222 log_wait_commit(EXT3_SB(sb)->s_journal, target); 2222 log_wait_commit(EXT4_SB(sb)->s_journal, target);
2223 } 2223 }
2224 return 0; 2224 return 0;
2225} 2225}
@@ -2228,20 +2228,20 @@ static int ext3_sync_fs(struct super_block *sb, int wait)
2228 * LVM calls this function before a (read-only) snapshot is created. This 2228 * LVM calls this function before a (read-only) snapshot is created. This
2229 * gives us a chance to flush the journal completely and mark the fs clean. 2229 * gives us a chance to flush the journal completely and mark the fs clean.
2230 */ 2230 */
2231static void ext3_write_super_lockfs(struct super_block *sb) 2231static void ext4_write_super_lockfs(struct super_block *sb)
2232{ 2232{
2233 sb->s_dirt = 0; 2233 sb->s_dirt = 0;
2234 2234
2235 if (!(sb->s_flags & MS_RDONLY)) { 2235 if (!(sb->s_flags & MS_RDONLY)) {
2236 journal_t *journal = EXT3_SB(sb)->s_journal; 2236 journal_t *journal = EXT4_SB(sb)->s_journal;
2237 2237
2238 /* Now we set up the journal barrier. */ 2238 /* Now we set up the journal barrier. */
2239 journal_lock_updates(journal); 2239 journal_lock_updates(journal);
2240 journal_flush(journal); 2240 journal_flush(journal);
2241 2241
2242 /* Journal blocked and flushed, clear needs_recovery flag. */ 2242 /* Journal blocked and flushed, clear needs_recovery flag. */
2243 EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); 2243 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
2244 ext3_commit_super(sb, EXT3_SB(sb)->s_es, 1); 2244 ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1);
2245 } 2245 }
2246} 2246}
2247 2247
@@ -2249,25 +2249,25 @@ static void ext3_write_super_lockfs(struct super_block *sb)
2249 * Called by LVM after the snapshot is done. We need to reset the RECOVER 2249 * Called by LVM after the snapshot is done. We need to reset the RECOVER
2250 * flag here, even though the filesystem is not technically dirty yet. 2250 * flag here, even though the filesystem is not technically dirty yet.
2251 */ 2251 */
2252static void ext3_unlockfs(struct super_block *sb) 2252static void ext4_unlockfs(struct super_block *sb)
2253{ 2253{
2254 if (!(sb->s_flags & MS_RDONLY)) { 2254 if (!(sb->s_flags & MS_RDONLY)) {
2255 lock_super(sb); 2255 lock_super(sb);
2256 /* Reser the needs_recovery flag before the fs is unlocked. */ 2256 /* Reser the needs_recovery flag before the fs is unlocked. */
2257 EXT3_SET_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); 2257 EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
2258 ext3_commit_super(sb, EXT3_SB(sb)->s_es, 1); 2258 ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1);
2259 unlock_super(sb); 2259 unlock_super(sb);
2260 journal_unlock_updates(EXT3_SB(sb)->s_journal); 2260 journal_unlock_updates(EXT4_SB(sb)->s_journal);
2261 } 2261 }
2262} 2262}
2263 2263
2264static int ext3_remount (struct super_block * sb, int * flags, char * data) 2264static int ext4_remount (struct super_block * sb, int * flags, char * data)
2265{ 2265{
2266 struct ext3_super_block * es; 2266 struct ext4_super_block * es;
2267 struct ext3_sb_info *sbi = EXT3_SB(sb); 2267 struct ext4_sb_info *sbi = EXT4_SB(sb);
2268 ext3_fsblk_t n_blocks_count = 0; 2268 ext4_fsblk_t n_blocks_count = 0;
2269 unsigned long old_sb_flags; 2269 unsigned long old_sb_flags;
2270 struct ext3_mount_options old_opts; 2270 struct ext4_mount_options old_opts;
2271 int err; 2271 int err;
2272#ifdef CONFIG_QUOTA 2272#ifdef CONFIG_QUOTA
2273 int i; 2273 int i;
@@ -2293,19 +2293,19 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2293 goto restore_opts; 2293 goto restore_opts;
2294 } 2294 }
2295 2295
2296 if (sbi->s_mount_opt & EXT3_MOUNT_ABORT) 2296 if (sbi->s_mount_opt & EXT4_MOUNT_ABORT)
2297 ext3_abort(sb, __FUNCTION__, "Abort forced by user"); 2297 ext4_abort(sb, __FUNCTION__, "Abort forced by user");
2298 2298
2299 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | 2299 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2300 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); 2300 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
2301 2301
2302 es = sbi->s_es; 2302 es = sbi->s_es;
2303 2303
2304 ext3_init_journal_params(sb, sbi->s_journal); 2304 ext4_init_journal_params(sb, sbi->s_journal);
2305 2305
2306 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY) || 2306 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY) ||
2307 n_blocks_count > le32_to_cpu(es->s_blocks_count)) { 2307 n_blocks_count > le32_to_cpu(es->s_blocks_count)) {
2308 if (sbi->s_mount_opt & EXT3_MOUNT_ABORT) { 2308 if (sbi->s_mount_opt & EXT4_MOUNT_ABORT) {
2309 err = -EROFS; 2309 err = -EROFS;
2310 goto restore_opts; 2310 goto restore_opts;
2311 } 2311 }
@@ -2322,16 +2322,16 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2322 * readonly, and if so set the rdonly flag and then 2322 * readonly, and if so set the rdonly flag and then
2323 * mark the partition as valid again. 2323 * mark the partition as valid again.
2324 */ 2324 */
2325 if (!(es->s_state & cpu_to_le16(EXT3_VALID_FS)) && 2325 if (!(es->s_state & cpu_to_le16(EXT4_VALID_FS)) &&
2326 (sbi->s_mount_state & EXT3_VALID_FS)) 2326 (sbi->s_mount_state & EXT4_VALID_FS))
2327 es->s_state = cpu_to_le16(sbi->s_mount_state); 2327 es->s_state = cpu_to_le16(sbi->s_mount_state);
2328 2328
2329 ext3_mark_recovery_complete(sb, es); 2329 ext4_mark_recovery_complete(sb, es);
2330 } else { 2330 } else {
2331 __le32 ret; 2331 __le32 ret;
2332 if ((ret = EXT3_HAS_RO_COMPAT_FEATURE(sb, 2332 if ((ret = EXT4_HAS_RO_COMPAT_FEATURE(sb,
2333 ~EXT3_FEATURE_RO_COMPAT_SUPP))) { 2333 ~EXT4_FEATURE_RO_COMPAT_SUPP))) {
2334 printk(KERN_WARNING "EXT3-fs: %s: couldn't " 2334 printk(KERN_WARNING "EXT4-fs: %s: couldn't "
2335 "remount RDWR because of unsupported " 2335 "remount RDWR because of unsupported "
2336 "optional features (%x).\n", 2336 "optional features (%x).\n",
2337 sb->s_id, le32_to_cpu(ret)); 2337 sb->s_id, le32_to_cpu(ret));
@@ -2344,11 +2344,11 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2344 * been changed by e2fsck since we originally mounted 2344 * been changed by e2fsck since we originally mounted
2345 * the partition.) 2345 * the partition.)
2346 */ 2346 */
2347 ext3_clear_journal_err(sb, es); 2347 ext4_clear_journal_err(sb, es);
2348 sbi->s_mount_state = le16_to_cpu(es->s_state); 2348 sbi->s_mount_state = le16_to_cpu(es->s_state);
2349 if ((err = ext3_group_extend(sb, es, n_blocks_count))) 2349 if ((err = ext4_group_extend(sb, es, n_blocks_count)))
2350 goto restore_opts; 2350 goto restore_opts;
2351 if (!ext3_setup_super (sb, es, 0)) 2351 if (!ext4_setup_super (sb, es, 0))
2352 sb->s_flags &= ~MS_RDONLY; 2352 sb->s_flags &= ~MS_RDONLY;
2353 } 2353 }
2354 } 2354 }
@@ -2378,19 +2378,19 @@ restore_opts:
2378 return err; 2378 return err;
2379} 2379}
2380 2380
2381static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf) 2381static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf)
2382{ 2382{
2383 struct super_block *sb = dentry->d_sb; 2383 struct super_block *sb = dentry->d_sb;
2384 struct ext3_sb_info *sbi = EXT3_SB(sb); 2384 struct ext4_sb_info *sbi = EXT4_SB(sb);
2385 struct ext3_super_block *es = sbi->s_es; 2385 struct ext4_super_block *es = sbi->s_es;
2386 ext3_fsblk_t overhead; 2386 ext4_fsblk_t overhead;
2387 int i; 2387 int i;
2388 2388
2389 if (test_opt (sb, MINIX_DF)) 2389 if (test_opt (sb, MINIX_DF))
2390 overhead = 0; 2390 overhead = 0;
2391 else { 2391 else {
2392 unsigned long ngroups; 2392 unsigned long ngroups;
2393 ngroups = EXT3_SB(sb)->s_groups_count; 2393 ngroups = EXT4_SB(sb)->s_groups_count;
2394 smp_rmb(); 2394 smp_rmb();
2395 2395
2396 /* 2396 /*
@@ -2409,8 +2409,8 @@ static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf)
2409 * feature is turned on, then not all groups have this. 2409 * feature is turned on, then not all groups have this.
2410 */ 2410 */
2411 for (i = 0; i < ngroups; i++) { 2411 for (i = 0; i < ngroups; i++) {
2412 overhead += ext3_bg_has_super(sb, i) + 2412 overhead += ext4_bg_has_super(sb, i) +
2413 ext3_bg_num_gdb(sb, i); 2413 ext4_bg_num_gdb(sb, i);
2414 cond_resched(); 2414 cond_resched();
2415 } 2415 }
2416 2416
@@ -2418,10 +2418,10 @@ static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf)
2418 * Every block group has an inode bitmap, a block 2418 * Every block group has an inode bitmap, a block
2419 * bitmap, and an inode table. 2419 * bitmap, and an inode table.
2420 */ 2420 */
2421 overhead += (ngroups * (2 + EXT3_SB(sb)->s_itb_per_group)); 2421 overhead += (ngroups * (2 + EXT4_SB(sb)->s_itb_per_group));
2422 } 2422 }
2423 2423
2424 buf->f_type = EXT3_SUPER_MAGIC; 2424 buf->f_type = EXT4_SUPER_MAGIC;
2425 buf->f_bsize = sb->s_blocksize; 2425 buf->f_bsize = sb->s_blocksize;
2426 buf->f_blocks = le32_to_cpu(es->s_blocks_count) - overhead; 2426 buf->f_blocks = le32_to_cpu(es->s_blocks_count) - overhead;
2427 buf->f_bfree = percpu_counter_sum(&sbi->s_freeblocks_counter); 2427 buf->f_bfree = percpu_counter_sum(&sbi->s_freeblocks_counter);
@@ -2430,14 +2430,14 @@ static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf)
2430 buf->f_bavail = 0; 2430 buf->f_bavail = 0;
2431 buf->f_files = le32_to_cpu(es->s_inodes_count); 2431 buf->f_files = le32_to_cpu(es->s_inodes_count);
2432 buf->f_ffree = percpu_counter_sum(&sbi->s_freeinodes_counter); 2432 buf->f_ffree = percpu_counter_sum(&sbi->s_freeinodes_counter);
2433 buf->f_namelen = EXT3_NAME_LEN; 2433 buf->f_namelen = EXT4_NAME_LEN;
2434 return 0; 2434 return 0;
2435} 2435}
2436 2436
2437/* Helper function for writing quotas on sync - we need to start transaction before quota file 2437/* Helper function for writing quotas on sync - we need to start transaction before quota file
2438 * is locked for write. Otherwise the are possible deadlocks: 2438 * is locked for write. Otherwise the are possible deadlocks:
2439 * Process 1 Process 2 2439 * Process 1 Process 2
2440 * ext3_create() quota_sync() 2440 * ext4_create() quota_sync()
2441 * journal_start() write_dquot() 2441 * journal_start() write_dquot()
2442 * DQUOT_INIT() down(dqio_mutex) 2442 * DQUOT_INIT() down(dqio_mutex)
2443 * down(dqio_mutex) journal_start() 2443 * down(dqio_mutex) journal_start()
@@ -2451,111 +2451,111 @@ static inline struct inode *dquot_to_inode(struct dquot *dquot)
2451 return sb_dqopt(dquot->dq_sb)->files[dquot->dq_type]; 2451 return sb_dqopt(dquot->dq_sb)->files[dquot->dq_type];
2452} 2452}
2453 2453
2454static int ext3_dquot_initialize(struct inode *inode, int type) 2454static int ext4_dquot_initialize(struct inode *inode, int type)
2455{ 2455{
2456 handle_t *handle; 2456 handle_t *handle;
2457 int ret, err; 2457 int ret, err;
2458 2458
2459 /* We may create quota structure so we need to reserve enough blocks */ 2459 /* We may create quota structure so we need to reserve enough blocks */
2460 handle = ext3_journal_start(inode, 2*EXT3_QUOTA_INIT_BLOCKS(inode->i_sb)); 2460 handle = ext4_journal_start(inode, 2*EXT4_QUOTA_INIT_BLOCKS(inode->i_sb));
2461 if (IS_ERR(handle)) 2461 if (IS_ERR(handle))
2462 return PTR_ERR(handle); 2462 return PTR_ERR(handle);
2463 ret = dquot_initialize(inode, type); 2463 ret = dquot_initialize(inode, type);
2464 err = ext3_journal_stop(handle); 2464 err = ext4_journal_stop(handle);
2465 if (!ret) 2465 if (!ret)
2466 ret = err; 2466 ret = err;
2467 return ret; 2467 return ret;
2468} 2468}
2469 2469
2470static int ext3_dquot_drop(struct inode *inode) 2470static int ext4_dquot_drop(struct inode *inode)
2471{ 2471{
2472 handle_t *handle; 2472 handle_t *handle;
2473 int ret, err; 2473 int ret, err;
2474 2474
2475 /* We may delete quota structure so we need to reserve enough blocks */ 2475 /* We may delete quota structure so we need to reserve enough blocks */
2476 handle = ext3_journal_start(inode, 2*EXT3_QUOTA_DEL_BLOCKS(inode->i_sb)); 2476 handle = ext4_journal_start(inode, 2*EXT4_QUOTA_DEL_BLOCKS(inode->i_sb));
2477 if (IS_ERR(handle)) 2477 if (IS_ERR(handle))
2478 return PTR_ERR(handle); 2478 return PTR_ERR(handle);
2479 ret = dquot_drop(inode); 2479 ret = dquot_drop(inode);
2480 err = ext3_journal_stop(handle); 2480 err = ext4_journal_stop(handle);
2481 if (!ret) 2481 if (!ret)
2482 ret = err; 2482 ret = err;
2483 return ret; 2483 return ret;
2484} 2484}
2485 2485
2486static int ext3_write_dquot(struct dquot *dquot) 2486static int ext4_write_dquot(struct dquot *dquot)
2487{ 2487{
2488 int ret, err; 2488 int ret, err;
2489 handle_t *handle; 2489 handle_t *handle;
2490 struct inode *inode; 2490 struct inode *inode;
2491 2491
2492 inode = dquot_to_inode(dquot); 2492 inode = dquot_to_inode(dquot);
2493 handle = ext3_journal_start(inode, 2493 handle = ext4_journal_start(inode,
2494 EXT3_QUOTA_TRANS_BLOCKS(dquot->dq_sb)); 2494 EXT4_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
2495 if (IS_ERR(handle)) 2495 if (IS_ERR(handle))
2496 return PTR_ERR(handle); 2496 return PTR_ERR(handle);
2497 ret = dquot_commit(dquot); 2497 ret = dquot_commit(dquot);
2498 err = ext3_journal_stop(handle); 2498 err = ext4_journal_stop(handle);
2499 if (!ret) 2499 if (!ret)
2500 ret = err; 2500 ret = err;
2501 return ret; 2501 return ret;
2502} 2502}
2503 2503
2504static int ext3_acquire_dquot(struct dquot *dquot) 2504static int ext4_acquire_dquot(struct dquot *dquot)
2505{ 2505{
2506 int ret, err; 2506 int ret, err;
2507 handle_t *handle; 2507 handle_t *handle;
2508 2508
2509 handle = ext3_journal_start(dquot_to_inode(dquot), 2509 handle = ext4_journal_start(dquot_to_inode(dquot),
2510 EXT3_QUOTA_INIT_BLOCKS(dquot->dq_sb)); 2510 EXT4_QUOTA_INIT_BLOCKS(dquot->dq_sb));
2511 if (IS_ERR(handle)) 2511 if (IS_ERR(handle))
2512 return PTR_ERR(handle); 2512 return PTR_ERR(handle);
2513 ret = dquot_acquire(dquot); 2513 ret = dquot_acquire(dquot);
2514 err = ext3_journal_stop(handle); 2514 err = ext4_journal_stop(handle);
2515 if (!ret) 2515 if (!ret)
2516 ret = err; 2516 ret = err;
2517 return ret; 2517 return ret;
2518} 2518}
2519 2519
2520static int ext3_release_dquot(struct dquot *dquot) 2520static int ext4_release_dquot(struct dquot *dquot)
2521{ 2521{
2522 int ret, err; 2522 int ret, err;
2523 handle_t *handle; 2523 handle_t *handle;
2524 2524
2525 handle = ext3_journal_start(dquot_to_inode(dquot), 2525 handle = ext4_journal_start(dquot_to_inode(dquot),
2526 EXT3_QUOTA_DEL_BLOCKS(dquot->dq_sb)); 2526 EXT4_QUOTA_DEL_BLOCKS(dquot->dq_sb));
2527 if (IS_ERR(handle)) 2527 if (IS_ERR(handle))
2528 return PTR_ERR(handle); 2528 return PTR_ERR(handle);
2529 ret = dquot_release(dquot); 2529 ret = dquot_release(dquot);
2530 err = ext3_journal_stop(handle); 2530 err = ext4_journal_stop(handle);
2531 if (!ret) 2531 if (!ret)
2532 ret = err; 2532 ret = err;
2533 return ret; 2533 return ret;
2534} 2534}
2535 2535
2536static int ext3_mark_dquot_dirty(struct dquot *dquot) 2536static int ext4_mark_dquot_dirty(struct dquot *dquot)
2537{ 2537{
2538 /* Are we journalling quotas? */ 2538 /* Are we journalling quotas? */
2539 if (EXT3_SB(dquot->dq_sb)->s_qf_names[USRQUOTA] || 2539 if (EXT4_SB(dquot->dq_sb)->s_qf_names[USRQUOTA] ||
2540 EXT3_SB(dquot->dq_sb)->s_qf_names[GRPQUOTA]) { 2540 EXT4_SB(dquot->dq_sb)->s_qf_names[GRPQUOTA]) {
2541 dquot_mark_dquot_dirty(dquot); 2541 dquot_mark_dquot_dirty(dquot);
2542 return ext3_write_dquot(dquot); 2542 return ext4_write_dquot(dquot);
2543 } else { 2543 } else {
2544 return dquot_mark_dquot_dirty(dquot); 2544 return dquot_mark_dquot_dirty(dquot);
2545 } 2545 }
2546} 2546}
2547 2547
2548static int ext3_write_info(struct super_block *sb, int type) 2548static int ext4_write_info(struct super_block *sb, int type)
2549{ 2549{
2550 int ret, err; 2550 int ret, err;
2551 handle_t *handle; 2551 handle_t *handle;
2552 2552
2553 /* Data block + inode block */ 2553 /* Data block + inode block */
2554 handle = ext3_journal_start(sb->s_root->d_inode, 2); 2554 handle = ext4_journal_start(sb->s_root->d_inode, 2);
2555 if (IS_ERR(handle)) 2555 if (IS_ERR(handle))
2556 return PTR_ERR(handle); 2556 return PTR_ERR(handle);
2557 ret = dquot_commit_info(sb, type); 2557 ret = dquot_commit_info(sb, type);
2558 err = ext3_journal_stop(handle); 2558 err = ext4_journal_stop(handle);
2559 if (!ret) 2559 if (!ret)
2560 ret = err; 2560 ret = err;
2561 return ret; 2561 return ret;
@@ -2565,16 +2565,16 @@ static int ext3_write_info(struct super_block *sb, int type)
2565 * Turn on quotas during mount time - we need to find 2565 * Turn on quotas during mount time - we need to find
2566 * the quota file and such... 2566 * the quota file and such...
2567 */ 2567 */
2568static int ext3_quota_on_mount(struct super_block *sb, int type) 2568static int ext4_quota_on_mount(struct super_block *sb, int type)
2569{ 2569{
2570 return vfs_quota_on_mount(sb, EXT3_SB(sb)->s_qf_names[type], 2570 return vfs_quota_on_mount(sb, EXT4_SB(sb)->s_qf_names[type],
2571 EXT3_SB(sb)->s_jquota_fmt, type); 2571 EXT4_SB(sb)->s_jquota_fmt, type);
2572} 2572}
2573 2573
2574/* 2574/*
2575 * Standard function to be called on quota_on 2575 * Standard function to be called on quota_on
2576 */ 2576 */
2577static int ext3_quota_on(struct super_block *sb, int type, int format_id, 2577static int ext4_quota_on(struct super_block *sb, int type, int format_id,
2578 char *path) 2578 char *path)
2579{ 2579{
2580 int err; 2580 int err;
@@ -2583,8 +2583,8 @@ static int ext3_quota_on(struct super_block *sb, int type, int format_id,
2583 if (!test_opt(sb, QUOTA)) 2583 if (!test_opt(sb, QUOTA))
2584 return -EINVAL; 2584 return -EINVAL;
2585 /* Not journalling quota? */ 2585 /* Not journalling quota? */
2586 if (!EXT3_SB(sb)->s_qf_names[USRQUOTA] && 2586 if (!EXT4_SB(sb)->s_qf_names[USRQUOTA] &&
2587 !EXT3_SB(sb)->s_qf_names[GRPQUOTA]) 2587 !EXT4_SB(sb)->s_qf_names[GRPQUOTA])
2588 return vfs_quota_on(sb, type, format_id, path); 2588 return vfs_quota_on(sb, type, format_id, path);
2589 err = path_lookup(path, LOOKUP_FOLLOW, &nd); 2589 err = path_lookup(path, LOOKUP_FOLLOW, &nd);
2590 if (err) 2590 if (err)
@@ -2597,7 +2597,7 @@ static int ext3_quota_on(struct super_block *sb, int type, int format_id,
2597 /* Quotafile not of fs root? */ 2597 /* Quotafile not of fs root? */
2598 if (nd.dentry->d_parent->d_inode != sb->s_root->d_inode) 2598 if (nd.dentry->d_parent->d_inode != sb->s_root->d_inode)
2599 printk(KERN_WARNING 2599 printk(KERN_WARNING
2600 "EXT3-fs: Quota file not on filesystem root. " 2600 "EXT4-fs: Quota file not on filesystem root. "
2601 "Journalled quota will not work.\n"); 2601 "Journalled quota will not work.\n");
2602 path_release(&nd); 2602 path_release(&nd);
2603 return vfs_quota_on(sb, type, format_id, path); 2603 return vfs_quota_on(sb, type, format_id, path);
@@ -2607,11 +2607,11 @@ static int ext3_quota_on(struct super_block *sb, int type, int format_id,
2607 * acquiring the locks... As quota files are never truncated and quota code 2607 * acquiring the locks... As quota files are never truncated and quota code
2608 * itself serializes the operations (and noone else should touch the files) 2608 * itself serializes the operations (and noone else should touch the files)
2609 * we don't have to be afraid of races */ 2609 * we don't have to be afraid of races */
2610static ssize_t ext3_quota_read(struct super_block *sb, int type, char *data, 2610static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data,
2611 size_t len, loff_t off) 2611 size_t len, loff_t off)
2612{ 2612{
2613 struct inode *inode = sb_dqopt(sb)->files[type]; 2613 struct inode *inode = sb_dqopt(sb)->files[type];
2614 sector_t blk = off >> EXT3_BLOCK_SIZE_BITS(sb); 2614 sector_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb);
2615 int err = 0; 2615 int err = 0;
2616 int offset = off & (sb->s_blocksize - 1); 2616 int offset = off & (sb->s_blocksize - 1);
2617 int tocopy; 2617 int tocopy;
@@ -2627,7 +2627,7 @@ static ssize_t ext3_quota_read(struct super_block *sb, int type, char *data,
2627 while (toread > 0) { 2627 while (toread > 0) {
2628 tocopy = sb->s_blocksize - offset < toread ? 2628 tocopy = sb->s_blocksize - offset < toread ?
2629 sb->s_blocksize - offset : toread; 2629 sb->s_blocksize - offset : toread;
2630 bh = ext3_bread(NULL, inode, blk, 0, &err); 2630 bh = ext4_bread(NULL, inode, blk, 0, &err);
2631 if (err) 2631 if (err)
2632 return err; 2632 return err;
2633 if (!bh) /* A hole? */ 2633 if (!bh) /* A hole? */
@@ -2645,15 +2645,15 @@ static ssize_t ext3_quota_read(struct super_block *sb, int type, char *data,
2645 2645
2646/* Write to quotafile (we know the transaction is already started and has 2646/* Write to quotafile (we know the transaction is already started and has
2647 * enough credits) */ 2647 * enough credits) */
2648static ssize_t ext3_quota_write(struct super_block *sb, int type, 2648static ssize_t ext4_quota_write(struct super_block *sb, int type,
2649 const char *data, size_t len, loff_t off) 2649 const char *data, size_t len, loff_t off)
2650{ 2650{
2651 struct inode *inode = sb_dqopt(sb)->files[type]; 2651 struct inode *inode = sb_dqopt(sb)->files[type];
2652 sector_t blk = off >> EXT3_BLOCK_SIZE_BITS(sb); 2652 sector_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb);
2653 int err = 0; 2653 int err = 0;
2654 int offset = off & (sb->s_blocksize - 1); 2654 int offset = off & (sb->s_blocksize - 1);
2655 int tocopy; 2655 int tocopy;
2656 int journal_quota = EXT3_SB(sb)->s_qf_names[type] != NULL; 2656 int journal_quota = EXT4_SB(sb)->s_qf_names[type] != NULL;
2657 size_t towrite = len; 2657 size_t towrite = len;
2658 struct buffer_head *bh; 2658 struct buffer_head *bh;
2659 handle_t *handle = journal_current_handle(); 2659 handle_t *handle = journal_current_handle();
@@ -2662,11 +2662,11 @@ static ssize_t ext3_quota_write(struct super_block *sb, int type,
2662 while (towrite > 0) { 2662 while (towrite > 0) {
2663 tocopy = sb->s_blocksize - offset < towrite ? 2663 tocopy = sb->s_blocksize - offset < towrite ?
2664 sb->s_blocksize - offset : towrite; 2664 sb->s_blocksize - offset : towrite;
2665 bh = ext3_bread(handle, inode, blk, 1, &err); 2665 bh = ext4_bread(handle, inode, blk, 1, &err);
2666 if (!bh) 2666 if (!bh)
2667 goto out; 2667 goto out;
2668 if (journal_quota) { 2668 if (journal_quota) {
2669 err = ext3_journal_get_write_access(handle, bh); 2669 err = ext4_journal_get_write_access(handle, bh);
2670 if (err) { 2670 if (err) {
2671 brelse(bh); 2671 brelse(bh);
2672 goto out; 2672 goto out;
@@ -2677,10 +2677,10 @@ static ssize_t ext3_quota_write(struct super_block *sb, int type,
2677 flush_dcache_page(bh->b_page); 2677 flush_dcache_page(bh->b_page);
2678 unlock_buffer(bh); 2678 unlock_buffer(bh);
2679 if (journal_quota) 2679 if (journal_quota)
2680 err = ext3_journal_dirty_metadata(handle, bh); 2680 err = ext4_journal_dirty_metadata(handle, bh);
2681 else { 2681 else {
2682 /* Always do at least ordered writes for quotas */ 2682 /* Always do at least ordered writes for quotas */
2683 err = ext3_journal_dirty_data(handle, bh); 2683 err = ext4_journal_dirty_data(handle, bh);
2684 mark_buffer_dirty(bh); 2684 mark_buffer_dirty(bh);
2685 } 2685 }
2686 brelse(bh); 2686 brelse(bh);
@@ -2696,59 +2696,59 @@ out:
2696 return err; 2696 return err;
2697 if (inode->i_size < off+len-towrite) { 2697 if (inode->i_size < off+len-towrite) {
2698 i_size_write(inode, off+len-towrite); 2698 i_size_write(inode, off+len-towrite);
2699 EXT3_I(inode)->i_disksize = inode->i_size; 2699 EXT4_I(inode)->i_disksize = inode->i_size;
2700 } 2700 }
2701 inode->i_version++; 2701 inode->i_version++;
2702 inode->i_mtime = inode->i_ctime = CURRENT_TIME; 2702 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
2703 ext3_mark_inode_dirty(handle, inode); 2703 ext4_mark_inode_dirty(handle, inode);
2704 mutex_unlock(&inode->i_mutex); 2704 mutex_unlock(&inode->i_mutex);
2705 return len - towrite; 2705 return len - towrite;
2706} 2706}
2707 2707
2708#endif 2708#endif
2709 2709
2710static int ext3_get_sb(struct file_system_type *fs_type, 2710static int ext4_get_sb(struct file_system_type *fs_type,
2711 int flags, const char *dev_name, void *data, struct vfsmount *mnt) 2711 int flags, const char *dev_name, void *data, struct vfsmount *mnt)
2712{ 2712{
2713 return get_sb_bdev(fs_type, flags, dev_name, data, ext3_fill_super, mnt); 2713 return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super, mnt);
2714} 2714}
2715 2715
2716static struct file_system_type ext3_fs_type = { 2716static struct file_system_type ext4dev_fs_type = {
2717 .owner = THIS_MODULE, 2717 .owner = THIS_MODULE,
2718 .name = "ext3", 2718 .name = "ext4dev",
2719 .get_sb = ext3_get_sb, 2719 .get_sb = ext4_get_sb,
2720 .kill_sb = kill_block_super, 2720 .kill_sb = kill_block_super,
2721 .fs_flags = FS_REQUIRES_DEV, 2721 .fs_flags = FS_REQUIRES_DEV,
2722}; 2722};
2723 2723
2724static int __init init_ext3_fs(void) 2724static int __init init_ext4_fs(void)
2725{ 2725{
2726 int err = init_ext3_xattr(); 2726 int err = init_ext4_xattr();
2727 if (err) 2727 if (err)
2728 return err; 2728 return err;
2729 err = init_inodecache(); 2729 err = init_inodecache();
2730 if (err) 2730 if (err)
2731 goto out1; 2731 goto out1;
2732 err = register_filesystem(&ext3_fs_type); 2732 err = register_filesystem(&ext4dev_fs_type);
2733 if (err) 2733 if (err)
2734 goto out; 2734 goto out;
2735 return 0; 2735 return 0;
2736out: 2736out:
2737 destroy_inodecache(); 2737 destroy_inodecache();
2738out1: 2738out1:
2739 exit_ext3_xattr(); 2739 exit_ext4_xattr();
2740 return err; 2740 return err;
2741} 2741}
2742 2742
2743static void __exit exit_ext3_fs(void) 2743static void __exit exit_ext4_fs(void)
2744{ 2744{
2745 unregister_filesystem(&ext3_fs_type); 2745 unregister_filesystem(&ext4dev_fs_type);
2746 destroy_inodecache(); 2746 destroy_inodecache();
2747 exit_ext3_xattr(); 2747 exit_ext4_xattr();
2748} 2748}
2749 2749
2750MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others"); 2750MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
2751MODULE_DESCRIPTION("Second Extended Filesystem with journaling extensions"); 2751MODULE_DESCRIPTION("Fourth Extended Filesystem with extents");
2752MODULE_LICENSE("GPL"); 2752MODULE_LICENSE("GPL");
2753module_init(init_ext3_fs) 2753module_init(init_ext4_fs)
2754module_exit(exit_ext3_fs) 2754module_exit(exit_ext4_fs)