diff options
Diffstat (limited to 'fs/ubifs/super.c')
-rw-r--r-- | fs/ubifs/super.c | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index ca1e2d4e03cc..f71e6b8822c4 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | #include <linux/ctype.h> | 32 | #include <linux/ctype.h> |
33 | #include <linux/random.h> | ||
34 | #include <linux/kthread.h> | 33 | #include <linux/kthread.h> |
35 | #include <linux/parser.h> | 34 | #include <linux/parser.h> |
36 | #include <linux/seq_file.h> | 35 | #include <linux/seq_file.h> |
@@ -149,7 +148,7 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum) | |||
149 | if (err) | 148 | if (err) |
150 | goto out_invalid; | 149 | goto out_invalid; |
151 | 150 | ||
152 | /* Disable readahead */ | 151 | /* Disable read-ahead */ |
153 | inode->i_mapping->backing_dev_info = &c->bdi; | 152 | inode->i_mapping->backing_dev_info = &c->bdi; |
154 | 153 | ||
155 | switch (inode->i_mode & S_IFMT) { | 154 | switch (inode->i_mode & S_IFMT) { |
@@ -278,7 +277,7 @@ static void ubifs_destroy_inode(struct inode *inode) | |||
278 | */ | 277 | */ |
279 | static int ubifs_write_inode(struct inode *inode, int wait) | 278 | static int ubifs_write_inode(struct inode *inode, int wait) |
280 | { | 279 | { |
281 | int err; | 280 | int err = 0; |
282 | struct ubifs_info *c = inode->i_sb->s_fs_info; | 281 | struct ubifs_info *c = inode->i_sb->s_fs_info; |
283 | struct ubifs_inode *ui = ubifs_inode(inode); | 282 | struct ubifs_inode *ui = ubifs_inode(inode); |
284 | 283 | ||
@@ -299,10 +298,18 @@ static int ubifs_write_inode(struct inode *inode, int wait) | |||
299 | return 0; | 298 | return 0; |
300 | } | 299 | } |
301 | 300 | ||
302 | dbg_gen("inode %lu", inode->i_ino); | 301 | /* |
303 | err = ubifs_jnl_write_inode(c, inode, 0); | 302 | * As an optimization, do not write orphan inodes to the media just |
304 | if (err) | 303 | * because this is not needed. |
305 | ubifs_err("can't write inode %lu, error %d", inode->i_ino, err); | 304 | */ |
305 | dbg_gen("inode %lu, mode %#x, nlink %u", | ||
306 | inode->i_ino, (int)inode->i_mode, inode->i_nlink); | ||
307 | if (inode->i_nlink) { | ||
308 | err = ubifs_jnl_write_inode(c, inode); | ||
309 | if (err) | ||
310 | ubifs_err("can't write inode %lu, error %d", | ||
311 | inode->i_ino, err); | ||
312 | } | ||
306 | 313 | ||
307 | ui->dirty = 0; | 314 | ui->dirty = 0; |
308 | mutex_unlock(&ui->ui_mutex); | 315 | mutex_unlock(&ui->ui_mutex); |
@@ -314,8 +321,9 @@ static void ubifs_delete_inode(struct inode *inode) | |||
314 | { | 321 | { |
315 | int err; | 322 | int err; |
316 | struct ubifs_info *c = inode->i_sb->s_fs_info; | 323 | struct ubifs_info *c = inode->i_sb->s_fs_info; |
324 | struct ubifs_inode *ui = ubifs_inode(inode); | ||
317 | 325 | ||
318 | if (ubifs_inode(inode)->xattr) | 326 | if (ui->xattr) |
319 | /* | 327 | /* |
320 | * Extended attribute inode deletions are fully handled in | 328 | * Extended attribute inode deletions are fully handled in |
321 | * 'ubifs_removexattr()'. These inodes are special and have | 329 | * 'ubifs_removexattr()'. These inodes are special and have |
@@ -323,7 +331,7 @@ static void ubifs_delete_inode(struct inode *inode) | |||
323 | */ | 331 | */ |
324 | goto out; | 332 | goto out; |
325 | 333 | ||
326 | dbg_gen("inode %lu", inode->i_ino); | 334 | dbg_gen("inode %lu, mode %#x", inode->i_ino, (int)inode->i_mode); |
327 | ubifs_assert(!atomic_read(&inode->i_count)); | 335 | ubifs_assert(!atomic_read(&inode->i_count)); |
328 | ubifs_assert(inode->i_nlink == 0); | 336 | ubifs_assert(inode->i_nlink == 0); |
329 | 337 | ||
@@ -331,15 +339,19 @@ static void ubifs_delete_inode(struct inode *inode) | |||
331 | if (is_bad_inode(inode)) | 339 | if (is_bad_inode(inode)) |
332 | goto out; | 340 | goto out; |
333 | 341 | ||
334 | ubifs_inode(inode)->ui_size = inode->i_size = 0; | 342 | ui->ui_size = inode->i_size = 0; |
335 | err = ubifs_jnl_write_inode(c, inode, 1); | 343 | err = ubifs_jnl_delete_inode(c, inode); |
336 | if (err) | 344 | if (err) |
337 | /* | 345 | /* |
338 | * Worst case we have a lost orphan inode wasting space, so a | 346 | * Worst case we have a lost orphan inode wasting space, so a |
339 | * simple error message is ok here. | 347 | * simple error message is OK here. |
340 | */ | 348 | */ |
341 | ubifs_err("can't write inode %lu, error %d", inode->i_ino, err); | 349 | ubifs_err("can't delete inode %lu, error %d", |
350 | inode->i_ino, err); | ||
351 | |||
342 | out: | 352 | out: |
353 | if (ui->dirty) | ||
354 | ubifs_release_dirty_inode_budget(c, ui); | ||
343 | clear_inode(inode); | 355 | clear_inode(inode); |
344 | } | 356 | } |
345 | 357 | ||
@@ -1122,8 +1134,8 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1122 | if (err) | 1134 | if (err) |
1123 | goto out_infos; | 1135 | goto out_infos; |
1124 | 1136 | ||
1125 | ubifs_msg("mounted UBI device %d, volume %d", c->vi.ubi_num, | 1137 | ubifs_msg("mounted UBI device %d, volume %d, name \"%s\"", |
1126 | c->vi.vol_id); | 1138 | c->vi.ubi_num, c->vi.vol_id, c->vi.name); |
1127 | if (mounted_read_only) | 1139 | if (mounted_read_only) |
1128 | ubifs_msg("mounted read-only"); | 1140 | ubifs_msg("mounted read-only"); |
1129 | x = (long long)c->main_lebs * c->leb_size; | 1141 | x = (long long)c->main_lebs * c->leb_size; |
@@ -1469,6 +1481,7 @@ static void ubifs_put_super(struct super_block *sb) | |||
1469 | */ | 1481 | */ |
1470 | ubifs_assert(atomic_long_read(&c->dirty_pg_cnt) == 0); | 1482 | ubifs_assert(atomic_long_read(&c->dirty_pg_cnt) == 0); |
1471 | ubifs_assert(c->budg_idx_growth == 0); | 1483 | ubifs_assert(c->budg_idx_growth == 0); |
1484 | ubifs_assert(c->budg_dd_growth == 0); | ||
1472 | ubifs_assert(c->budg_data_growth == 0); | 1485 | ubifs_assert(c->budg_data_growth == 0); |
1473 | 1486 | ||
1474 | /* | 1487 | /* |
@@ -1657,7 +1670,6 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent) | |||
1657 | INIT_LIST_HEAD(&c->orph_new); | 1670 | INIT_LIST_HEAD(&c->orph_new); |
1658 | 1671 | ||
1659 | c->highest_inum = UBIFS_FIRST_INO; | 1672 | c->highest_inum = UBIFS_FIRST_INO; |
1660 | get_random_bytes(&c->vfs_gen, sizeof(int)); | ||
1661 | c->lhead_lnum = c->ltail_lnum = UBIFS_LOG_LNUM; | 1673 | c->lhead_lnum = c->ltail_lnum = UBIFS_LOG_LNUM; |
1662 | 1674 | ||
1663 | ubi_get_volume_info(ubi, &c->vi); | 1675 | ubi_get_volume_info(ubi, &c->vi); |
@@ -1671,10 +1683,10 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent) | |||
1671 | } | 1683 | } |
1672 | 1684 | ||
1673 | /* | 1685 | /* |
1674 | * UBIFS provids 'backing_dev_info' in order to disable readahead. For | 1686 | * UBIFS provides 'backing_dev_info' in order to disable read-ahead. For |
1675 | * UBIFS, I/O is not deferred, it is done immediately in readpage, | 1687 | * UBIFS, I/O is not deferred, it is done immediately in readpage, |
1676 | * which means the user would have to wait not just for their own I/O | 1688 | * which means the user would have to wait not just for their own I/O |
1677 | * but the readahead I/O as well i.e. completely pointless. | 1689 | * but the read-ahead I/O as well i.e. completely pointless. |
1678 | * | 1690 | * |
1679 | * Read-ahead will be disabled because @c->bdi.ra_pages is 0. | 1691 | * Read-ahead will be disabled because @c->bdi.ra_pages is 0. |
1680 | */ | 1692 | */ |