Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs

Pull f2fs bug fixes from Jaegeuk Kim:
"This patch-set includes two major bug fixes:
- incorrect IUsed provided by *df -i*, and
- lookup failure of parent inodes in corner cases.

[Other Bug Fixes]
- Fix error handling routines
- Trigger recovery process correctly
- Resolve build failures due to missing header files

[Etc]
- Add a MAINTAINERS entry for f2fs
- Fix and clean up variables, functions, and equations
- Avoid warnings during compilation"

* tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs:
f2fs: unify string length declarations and usage
f2fs: clean up unused variables and return values
f2fs: clean up the start_bidx_of_node function
f2fs: remove unneeded variable from f2fs_sync_fs
f2fs: fix fsync_inode list addition logic and avoid invalid access to memory
f2fs: remove unneeded initialization of nr_dirty in dirty_seglist_info
f2fs: handle error from f2fs_iget_nowait
f2fs: fix equation of has_not_enough_free_secs()
f2fs: add MAINTAINERS entry
f2fs: return a default value for non-void function
f2fs: invalidate the node page if allocation is failed
f2fs: add missing #include <linux/prefetch.h>
f2fs: do f2fs_balance_fs in front of dir operations
f2fs: should recover orphan and fsync data
f2fs: fix handling errors got by f2fs_write_inode
f2fs: fix up f2fs_get_parent issue to retrieve correct parent inode number
f2fs: fix wrong calculation on f_files in statfs
f2fs: remove set_page_dirty for atomic f2fs_end_io_write

+117 -137
+10
MAINTAINERS
··· 3273 3273 F: fs/fscache/ 3274 3274 F: include/linux/fscache*.h 3275 3275 3276 + F2FS FILE SYSTEM 3277 + M: Jaegeuk Kim <jaegeuk.kim@samsung.com> 3278 + L: linux-f2fs-devel@lists.sourceforge.net 3279 + W: http://en.wikipedia.org/wiki/F2FS 3280 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git 3281 + S: Maintained 3282 + F: Documentation/filesystems/f2fs.txt 3283 + F: fs/f2fs/ 3284 + F: include/linux/f2fs_fs.h 3285 + 3276 3286 FUJITSU FR-V (FRV) PORT 3277 3287 M: David Howells <dhowells@redhat.com> 3278 3288 S: Maintained
+1
fs/f2fs/data.c
··· 16 16 #include <linux/backing-dev.h> 17 17 #include <linux/blkdev.h> 18 18 #include <linux/bio.h> 19 + #include <linux/prefetch.h> 19 20 20 21 #include "f2fs.h" 21 22 #include "node.h"
+9 -7
fs/f2fs/dir.c
··· 11 11 #include <linux/fs.h> 12 12 #include <linux/f2fs_fs.h> 13 13 #include "f2fs.h" 14 + #include "node.h" 14 15 #include "acl.h" 15 16 16 17 static unsigned long dir_blocks(struct inode *inode) ··· 75 74 return bidx; 76 75 } 77 76 78 - static bool early_match_name(const char *name, int namelen, 77 + static bool early_match_name(const char *name, size_t namelen, 79 78 f2fs_hash_t namehash, struct f2fs_dir_entry *de) 80 79 { 81 80 if (le16_to_cpu(de->name_len) != namelen) ··· 88 87 } 89 88 90 89 static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, 91 - const char *name, int namelen, int *max_slots, 90 + const char *name, size_t namelen, int *max_slots, 92 91 f2fs_hash_t namehash, struct page **res_page) 93 92 { 94 93 struct f2fs_dir_entry *de; ··· 127 126 } 128 127 129 128 static struct f2fs_dir_entry *find_in_level(struct inode *dir, 130 - unsigned int level, const char *name, int namelen, 129 + unsigned int level, const char *name, size_t namelen, 131 130 f2fs_hash_t namehash, struct page **res_page) 132 131 { 133 132 int s = GET_DENTRY_SLOTS(namelen); ··· 182 181 struct qstr *child, struct page **res_page) 183 182 { 184 183 const char *name = child->name; 185 - int namelen = child->len; 184 + size_t namelen = child->len; 186 185 unsigned long npages = dir_blocks(dir); 187 186 struct f2fs_dir_entry *de = NULL; 188 187 f2fs_hash_t name_hash; ··· 309 308 ipage = get_node_page(F2FS_SB(dir->i_sb), inode->i_ino); 310 309 if (IS_ERR(ipage)) 311 310 return PTR_ERR(ipage); 311 + set_cold_node(inode, ipage); 312 312 init_dent_inode(dentry, ipage); 313 313 f2fs_put_page(ipage, 1); 314 314 } ··· 383 381 struct inode *dir = dentry->d_parent->d_inode; 384 382 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); 385 383 const char *name = dentry->d_name.name; 386 - int namelen = dentry->d_name.len; 384 + size_t namelen = dentry->d_name.len; 387 385 struct page *dentry_page = NULL; 388 386 struct f2fs_dentry_block *dentry_blk = NULL; 389 387 int slots = GET_DENTRY_SLOTS(namelen); ··· 542 540 543 541 de = &dentry_blk->dentry[0]; 544 542 de->name_len = cpu_to_le16(1); 545 - de->hash_code = 0; 543 + de->hash_code = f2fs_dentry_hash(".", 1); 546 544 de->ino = cpu_to_le32(inode->i_ino); 547 545 memcpy(dentry_blk->filename[0], ".", 1); 548 546 set_de_type(de, inode); 549 547 550 548 de = &dentry_blk->dentry[1]; 551 - de->hash_code = 0; 549 + de->hash_code = f2fs_dentry_hash("..", 2); 552 550 de->name_len = cpu_to_le16(2); 553 551 de->ino = cpu_to_le32(parent->i_ino); 554 552 memcpy(dentry_blk->filename[1], "..", 2);
+1 -1
fs/f2fs/f2fs.h
··· 881 881 /* 882 882 * hash.c 883 883 */ 884 - f2fs_hash_t f2fs_dentry_hash(const char *, int); 884 + f2fs_hash_t f2fs_dentry_hash(const char *, size_t); 885 885 886 886 /* 887 887 * node.c
+6 -4
fs/f2fs/file.c
··· 160 160 if (need_to_sync_dir(sbi, inode)) 161 161 need_cp = true; 162 162 163 - f2fs_write_inode(inode, NULL); 164 - 165 163 if (need_cp) { 166 164 /* all the dirty node pages should be flushed for POR */ 167 165 ret = f2fs_sync_fs(inode->i_sb, 1); 168 166 clear_inode_flag(F2FS_I(inode), FI_NEED_CP); 169 167 } else { 170 - while (sync_node_pages(sbi, inode->i_ino, &wbc) == 0) 171 - f2fs_write_inode(inode, NULL); 168 + /* if there is no written node page, write its inode page */ 169 + while (!sync_node_pages(sbi, inode->i_ino, &wbc)) { 170 + ret = f2fs_write_inode(inode, NULL); 171 + if (ret) 172 + goto out; 173 + } 172 174 filemap_fdatawait_range(sbi->node_inode->i_mapping, 173 175 0, LONG_MAX); 174 176 }
+11 -23
fs/f2fs/gc.c
··· 390 390 } 391 391 392 392 err = check_valid_map(sbi, segno, off); 393 - if (err == GC_ERROR) 394 - return err; 395 - else if (err == GC_NEXT) 393 + if (err == GC_NEXT) 396 394 continue; 397 395 398 396 if (initial) { ··· 428 430 */ 429 431 block_t start_bidx_of_node(unsigned int node_ofs) 430 432 { 431 - block_t start_bidx; 432 - unsigned int bidx, indirect_blks; 433 - int dec; 433 + unsigned int indirect_blks = 2 * NIDS_PER_BLOCK + 4; 434 + unsigned int bidx; 434 435 435 - indirect_blks = 2 * NIDS_PER_BLOCK + 4; 436 + if (node_ofs == 0) 437 + return 0; 436 438 437 - start_bidx = 1; 438 - if (node_ofs == 0) { 439 - start_bidx = 0; 440 - } else if (node_ofs <= 2) { 439 + if (node_ofs <= 2) { 441 440 bidx = node_ofs - 1; 442 441 } else if (node_ofs <= indirect_blks) { 443 - dec = (node_ofs - 4) / (NIDS_PER_BLOCK + 1); 442 + int dec = (node_ofs - 4) / (NIDS_PER_BLOCK + 1); 444 443 bidx = node_ofs - 2 - dec; 445 444 } else { 446 - dec = (node_ofs - indirect_blks - 3) / (NIDS_PER_BLOCK + 1); 445 + int dec = (node_ofs - indirect_blks - 3) / (NIDS_PER_BLOCK + 1); 447 446 bidx = node_ofs - 5 - dec; 448 447 } 449 - 450 - if (start_bidx) 451 - start_bidx = bidx * ADDRS_PER_BLOCK + ADDRS_PER_INODE; 452 - return start_bidx; 448 + return bidx * ADDRS_PER_BLOCK + ADDRS_PER_INODE; 453 449 } 454 450 455 451 static int check_dnode(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, ··· 548 556 } 549 557 550 558 err = check_valid_map(sbi, segno, off); 551 - if (err == GC_ERROR) 552 - goto stop; 553 - else if (err == GC_NEXT) 559 + if (err == GC_NEXT) 554 560 continue; 555 561 556 562 if (phase == 0) { ··· 558 568 559 569 /* Get an inode by ino with checking validity */ 560 570 err = check_dnode(sbi, entry, &dni, start_addr + off, &nofs); 561 - if (err == GC_ERROR) 562 - goto stop; 563 - else if (err == GC_NEXT) 571 + if (err == GC_NEXT) 564 572 continue; 565 573 566 574 if (phase == 1) {
+11 -7
fs/f2fs/hash.c
··· 42 42 buf[1] += b1; 43 43 } 44 44 45 - static void str2hashbuf(const char *msg, int len, unsigned int *buf, int num) 45 + static void str2hashbuf(const char *msg, size_t len, unsigned int *buf, int num) 46 46 { 47 47 unsigned pad, val; 48 48 int i; ··· 69 69 *buf++ = pad; 70 70 } 71 71 72 - f2fs_hash_t f2fs_dentry_hash(const char *name, int len) 72 + f2fs_hash_t f2fs_dentry_hash(const char *name, size_t len) 73 73 { 74 - __u32 hash, minor_hash; 74 + __u32 hash; 75 75 f2fs_hash_t f2fs_hash; 76 76 const char *p; 77 77 __u32 in[8], buf[4]; 78 + 79 + if ((len <= 2) && (name[0] == '.') && 80 + (name[1] == '.' || name[1] == '\0')) 81 + return 0; 78 82 79 83 /* Initialize the default seed for the hash checksum functions */ 80 84 buf[0] = 0x67452301; ··· 87 83 buf[3] = 0x10325476; 88 84 89 85 p = name; 90 - while (len > 0) { 86 + while (1) { 91 87 str2hashbuf(p, len, in, 4); 92 88 TEA_transform(buf, in); 93 - len -= 16; 94 89 p += 16; 90 + if (len <= 16) 91 + break; 92 + len -= 16; 95 93 } 96 94 hash = buf[0]; 97 - minor_hash = buf[1]; 98 - 99 95 f2fs_hash = cpu_to_le32(hash & ~F2FS_HASH_COL_BIT); 100 96 return f2fs_hash; 101 97 }
+1
fs/f2fs/inode.c
··· 203 203 ri->i_flags = cpu_to_le32(F2FS_I(inode)->i_flags); 204 204 ri->i_pino = cpu_to_le32(F2FS_I(inode)->i_pino); 205 205 ri->i_generation = cpu_to_le32(inode->i_generation); 206 + set_cold_node(inode, node_page); 206 207 set_page_dirty(node_page); 207 208 } 208 209
+17 -17
fs/f2fs/namei.c
··· 77 77 78 78 static int is_multimedia_file(const unsigned char *s, const char *sub) 79 79 { 80 - int slen = strlen(s); 81 - int sublen = strlen(sub); 80 + size_t slen = strlen(s); 81 + size_t sublen = strlen(sub); 82 82 int ret; 83 83 84 84 if (sublen > slen) ··· 123 123 nid_t ino = 0; 124 124 int err; 125 125 126 + f2fs_balance_fs(sbi); 127 + 126 128 inode = f2fs_new_inode(dir, mode); 127 129 if (IS_ERR(inode)) 128 130 return PTR_ERR(inode); ··· 146 144 if (!sbi->por_doing) 147 145 d_instantiate(dentry, inode); 148 146 unlock_new_inode(inode); 149 - 150 - f2fs_balance_fs(sbi); 151 147 return 0; 152 148 out: 153 149 clear_nlink(inode); ··· 163 163 struct f2fs_sb_info *sbi = F2FS_SB(sb); 164 164 int err; 165 165 166 + f2fs_balance_fs(sbi); 167 + 166 168 inode->i_ctime = CURRENT_TIME; 167 169 atomic_inc(&inode->i_count); 168 170 ··· 174 172 goto out; 175 173 176 174 d_instantiate(dentry, inode); 177 - 178 - f2fs_balance_fs(sbi); 179 175 return 0; 180 176 out: 181 177 clear_inode_flag(F2FS_I(inode), FI_INC_LINK); ··· 223 223 struct page *page; 224 224 int err = -ENOENT; 225 225 226 + f2fs_balance_fs(sbi); 227 + 226 228 de = f2fs_find_entry(dir, &dentry->d_name, &page); 227 229 if (!de) 228 230 goto fail; ··· 240 238 241 239 /* In order to evict this inode, we set it dirty */ 242 240 mark_inode_dirty(inode); 243 - f2fs_balance_fs(sbi); 244 241 fail: 245 242 return err; 246 243 } ··· 250 249 struct super_block *sb = dir->i_sb; 251 250 struct f2fs_sb_info *sbi = F2FS_SB(sb); 252 251 struct inode *inode; 253 - unsigned symlen = strlen(symname) + 1; 252 + size_t symlen = strlen(symname) + 1; 254 253 int err; 254 + 255 + f2fs_balance_fs(sbi); 255 256 256 257 inode = f2fs_new_inode(dir, S_IFLNK | S_IRWXUGO); 257 258 if (IS_ERR(inode)) ··· 271 268 272 269 d_instantiate(dentry, inode); 273 270 unlock_new_inode(inode); 274 - 275 - f2fs_balance_fs(sbi); 276 - 277 271 return err; 278 272 out: 279 273 clear_nlink(inode); ··· 285 285 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); 286 286 struct inode *inode; 287 287 int err; 288 + 289 + f2fs_balance_fs(sbi); 288 290 289 291 inode = f2fs_new_inode(dir, S_IFDIR | mode); 290 292 if (IS_ERR(inode)) ··· 307 305 d_instantiate(dentry, inode); 308 306 unlock_new_inode(inode); 309 307 310 - f2fs_balance_fs(sbi); 311 308 return 0; 312 309 313 310 out_fail: ··· 337 336 if (!new_valid_dev(rdev)) 338 337 return -EINVAL; 339 338 339 + f2fs_balance_fs(sbi); 340 + 340 341 inode = f2fs_new_inode(dir, mode); 341 342 if (IS_ERR(inode)) 342 343 return PTR_ERR(inode); ··· 353 350 alloc_nid_done(sbi, inode->i_ino); 354 351 d_instantiate(dentry, inode); 355 352 unlock_new_inode(inode); 356 - 357 - f2fs_balance_fs(sbi); 358 - 359 353 return 0; 360 354 out: 361 355 clear_nlink(inode); ··· 375 375 struct f2fs_dir_entry *old_entry; 376 376 struct f2fs_dir_entry *new_entry; 377 377 int err = -ENOENT; 378 + 379 + f2fs_balance_fs(sbi); 378 380 379 381 old_entry = f2fs_find_entry(old_dir, &old_dentry->d_name, &old_page); 380 382 if (!old_entry) ··· 443 441 } 444 442 445 443 mutex_unlock_op(sbi, RENAME); 446 - 447 - f2fs_balance_fs(sbi); 448 444 return 0; 449 445 450 446 out_dir:
+14 -23
fs/f2fs/node.c
··· 484 484 struct node_info ni; 485 485 486 486 get_node_info(sbi, dn->nid, &ni); 487 + if (dn->inode->i_blocks == 0) { 488 + BUG_ON(ni.blk_addr != NULL_ADDR); 489 + goto invalidate; 490 + } 487 491 BUG_ON(ni.blk_addr == NULL_ADDR); 488 492 489 - if (ni.blk_addr != NULL_ADDR) 490 - invalidate_blocks(sbi, ni.blk_addr); 491 - 492 493 /* Deallocate node address */ 494 + invalidate_blocks(sbi, ni.blk_addr); 493 495 dec_valid_node_count(sbi, dn->inode, 1); 494 496 set_node_addr(sbi, &ni, NULL_ADDR); 495 497 ··· 501 499 } else { 502 500 sync_inode_page(dn); 503 501 } 504 - 502 + invalidate: 505 503 clear_node_page_dirty(dn->node_page); 506 504 F2FS_SET_SB_DIRT(sbi); 507 505 ··· 770 768 dn.inode_page_locked = 1; 771 769 truncate_node(&dn); 772 770 } 773 - if (inode->i_blocks == 1) { 774 - /* inernally call f2fs_put_page() */ 775 - set_new_dnode(&dn, inode, page, page, ino); 776 - truncate_node(&dn); 777 - } else if (inode->i_blocks == 0) { 778 - struct node_info ni; 779 - get_node_info(sbi, inode->i_ino, &ni); 780 771 781 - /* called after f2fs_new_inode() is failed */ 782 - BUG_ON(ni.blk_addr != NULL_ADDR); 783 - f2fs_put_page(page, 1); 784 - } else { 785 - BUG(); 786 - } 772 + /* 0 is possible, after f2fs_new_inode() is failed */ 773 + BUG_ON(inode->i_blocks != 0 && inode->i_blocks != 1); 774 + set_new_dnode(&dn, inode, page, page, ino); 775 + truncate_node(&dn); 776 + 787 777 mutex_unlock_op(sbi, NODE_TRUNC); 788 778 return 0; 789 779 } ··· 828 834 goto fail; 829 835 } 830 836 set_node_addr(sbi, &new_ni, NEW_ADDR); 837 + set_cold_node(dn->inode, page); 831 838 832 839 dn->node_page = page; 833 840 sync_inode_page(dn); 834 841 set_page_dirty(page); 835 - set_cold_node(dn->inode, page); 836 842 if (ofs == 0) 837 843 inc_valid_inode_count(sbi); 838 844 839 845 return page; 840 846 841 847 fail: 848 + clear_node_page_dirty(page); 842 849 f2fs_put_page(page, 1); 843 850 return ERR_PTR(err); 844 851 } ··· 1088 1093 { 1089 1094 struct f2fs_sb_info *sbi = F2FS_SB(page->mapping->host->i_sb); 1090 1095 nid_t nid; 1091 - unsigned int nofs; 1092 1096 block_t new_addr; 1093 1097 struct node_info ni; 1094 1098 ··· 1104 1110 1105 1111 /* get old block addr of this node page */ 1106 1112 nid = nid_of_node(page); 1107 - nofs = ofs_of_node(page); 1108 1113 BUG_ON(page->index != nid); 1109 1114 1110 1115 get_node_info(sbi, nid, &ni); ··· 1564 1571 nid_t nid; 1565 1572 struct f2fs_nat_entry raw_ne; 1566 1573 int offset = -1; 1567 - block_t old_blkaddr, new_blkaddr; 1574 + block_t new_blkaddr; 1568 1575 1569 1576 ne = list_entry(cur, struct nat_entry, list); 1570 1577 nid = nat_get_nid(ne); ··· 1578 1585 offset = lookup_journal_in_cursum(sum, NAT_JOURNAL, nid, 1); 1579 1586 if (offset >= 0) { 1580 1587 raw_ne = nat_in_journal(sum, offset); 1581 - old_blkaddr = le32_to_cpu(raw_ne.block_addr); 1582 1588 goto flush_now; 1583 1589 } 1584 1590 to_nat_page: ··· 1599 1607 1600 1608 BUG_ON(!nat_blk); 1601 1609 raw_ne = nat_blk->entries[nid - start_nid]; 1602 - old_blkaddr = le32_to_cpu(raw_ne.block_addr); 1603 1610 flush_now: 1604 1611 new_blkaddr = nat_get_blkaddr(ne); 1605 1612
+7 -3
fs/f2fs/recovery.c
··· 144 144 goto out; 145 145 } 146 146 147 - INIT_LIST_HEAD(&entry->list); 148 - list_add_tail(&entry->list, head); 149 - 150 147 entry->inode = f2fs_iget(sbi->sb, ino_of_node(page)); 151 148 if (IS_ERR(entry->inode)) { 152 149 err = PTR_ERR(entry->inode); 150 + kmem_cache_free(fsync_entry_slab, entry); 153 151 goto out; 154 152 } 153 + 154 + INIT_LIST_HEAD(&entry->list); 155 + list_add_tail(&entry->list, head); 155 156 entry->blkaddr = blkaddr; 156 157 } 157 158 if (IS_INODE(page)) { ··· 229 228 230 229 /* Deallocate previous index in the node page */ 231 230 inode = f2fs_iget_nowait(sbi->sb, ino); 231 + if (IS_ERR(inode)) 232 + return; 233 + 232 234 truncate_hole(inode, bidx, bidx + 1); 233 235 iput(inode); 234 236 }
+6 -40
fs/f2fs/segment.c
··· 12 12 #include <linux/f2fs_fs.h> 13 13 #include <linux/bio.h> 14 14 #include <linux/blkdev.h> 15 + #include <linux/prefetch.h> 15 16 #include <linux/vmalloc.h> 16 17 17 18 #include "f2fs.h" 18 19 #include "segment.h" 19 20 #include "node.h" 20 - 21 - static int need_to_flush(struct f2fs_sb_info *sbi) 22 - { 23 - unsigned int pages_per_sec = (1 << sbi->log_blocks_per_seg) * 24 - sbi->segs_per_sec; 25 - int node_secs = ((get_pages(sbi, F2FS_DIRTY_NODES) + pages_per_sec - 1) 26 - >> sbi->log_blocks_per_seg) / sbi->segs_per_sec; 27 - int dent_secs = ((get_pages(sbi, F2FS_DIRTY_DENTS) + pages_per_sec - 1) 28 - >> sbi->log_blocks_per_seg) / sbi->segs_per_sec; 29 - 30 - if (sbi->por_doing) 31 - return 0; 32 - 33 - if (free_sections(sbi) <= (node_secs + 2 * dent_secs + 34 - reserved_sections(sbi))) 35 - return 1; 36 - return 0; 37 - } 38 21 39 22 /* 40 23 * This function balances dirty node and dentry pages. ··· 25 42 */ 26 43 void f2fs_balance_fs(struct f2fs_sb_info *sbi) 27 44 { 28 - struct writeback_control wbc = { 29 - .sync_mode = WB_SYNC_ALL, 30 - .nr_to_write = LONG_MAX, 31 - .for_reclaim = 0, 32 - }; 33 - 34 - if (sbi->por_doing) 35 - return; 36 - 37 45 /* 38 - * We should do checkpoint when there are so many dirty node pages 39 - * with enough free segments. After then, we should do GC. 46 + * We should do GC or end up with checkpoint, if there are so many dirty 47 + * dir/node pages without enough free segments. 40 48 */ 41 - if (need_to_flush(sbi)) { 42 - sync_dirty_dir_inodes(sbi); 43 - sync_node_pages(sbi, 0, &wbc); 44 - } 45 - 46 49 if (has_not_enough_free_secs(sbi)) { 47 50 mutex_lock(&sbi->gc_mutex); 48 51 f2fs_gc(sbi, 1); ··· 600 631 if (page->mapping) 601 632 set_bit(AS_EIO, &page->mapping->flags); 602 633 set_ckpt_flags(p->sbi->ckpt, CP_ERROR_FLAG); 603 - set_page_dirty(page); 604 634 } 605 635 end_page_writeback(page); 606 636 dec_page_count(p->sbi, F2FS_WRITEBACK); ··· 759 791 return __get_segment_type_2(page, p_type); 760 792 case 4: 761 793 return __get_segment_type_4(page, p_type); 762 - case 6: 763 - return __get_segment_type_6(page, p_type); 764 - default: 765 - BUG(); 766 794 } 795 + /* NR_CURSEG_TYPE(6) logs by default */ 796 + BUG_ON(sbi->active_logs != NR_CURSEG_TYPE); 797 + return __get_segment_type_6(page, p_type); 767 798 } 768 799 769 800 static void do_write_page(struct f2fs_sb_info *sbi, struct page *page, ··· 1575 1608 1576 1609 for (i = 0; i < NR_DIRTY_TYPE; i++) { 1577 1610 dirty_i->dirty_segmap[i] = kzalloc(bitmap_size, GFP_KERNEL); 1578 - dirty_i->nr_dirty[i] = 0; 1579 1611 if (!dirty_i->dirty_segmap[i]) 1580 1612 return -ENOMEM; 1581 1613 }
+14 -1
fs/f2fs/segment.h
··· 459 459 460 460 static inline bool has_not_enough_free_secs(struct f2fs_sb_info *sbi) 461 461 { 462 - return free_sections(sbi) <= reserved_sections(sbi); 462 + unsigned int pages_per_sec = (1 << sbi->log_blocks_per_seg) * 463 + sbi->segs_per_sec; 464 + int node_secs = ((get_pages(sbi, F2FS_DIRTY_NODES) + pages_per_sec - 1) 465 + >> sbi->log_blocks_per_seg) / sbi->segs_per_sec; 466 + int dent_secs = ((get_pages(sbi, F2FS_DIRTY_DENTS) + pages_per_sec - 1) 467 + >> sbi->log_blocks_per_seg) / sbi->segs_per_sec; 468 + 469 + if (sbi->por_doing) 470 + return false; 471 + 472 + if (free_sections(sbi) <= (node_secs + 2 * dent_secs + 473 + reserved_sections(sbi))) 474 + return true; 475 + return false; 463 476 } 464 477 465 478 static inline int utilization(struct f2fs_sb_info *sbi)
+6 -9
fs/f2fs/super.c
··· 119 119 int f2fs_sync_fs(struct super_block *sb, int sync) 120 120 { 121 121 struct f2fs_sb_info *sbi = F2FS_SB(sb); 122 - int ret = 0; 123 122 124 123 if (!sbi->s_dirty && !get_pages(sbi, F2FS_DIRTY_NODES)) 125 124 return 0; ··· 126 127 if (sync) 127 128 write_checkpoint(sbi, false, false); 128 129 129 - return ret; 130 + return 0; 130 131 } 131 132 132 133 static int f2fs_statfs(struct dentry *dentry, struct kstatfs *buf) ··· 147 148 buf->f_bfree = buf->f_blocks - valid_user_blocks(sbi) - ovp_count; 148 149 buf->f_bavail = user_block_count - valid_user_blocks(sbi); 149 150 150 - buf->f_files = valid_inode_count(sbi); 151 - buf->f_ffree = sbi->total_node_count - valid_node_count(sbi); 151 + buf->f_files = sbi->total_node_count; 152 + buf->f_ffree = sbi->total_node_count - valid_inode_count(sbi); 152 153 153 154 buf->f_namelen = F2FS_MAX_NAME_LEN; 154 155 buf->f_fsid.val[0] = (u32)id; ··· 301 302 case Opt_active_logs: 302 303 if (args->from && match_int(args, &arg)) 303 304 return -EINVAL; 304 - if (arg != 2 && arg != 4 && arg != 6) 305 + if (arg != 2 && arg != 4 && arg != NR_CURSEG_TYPE) 305 306 return -EINVAL; 306 307 sbi->active_logs = arg; 307 308 break; ··· 527 528 528 529 /* if there are nt orphan nodes free them */ 529 530 err = -EINVAL; 530 - if (!is_set_ckpt_flags(F2FS_CKPT(sbi), CP_UMOUNT_FLAG) && 531 - recover_orphan_inodes(sbi)) 531 + if (recover_orphan_inodes(sbi)) 532 532 goto free_node_inode; 533 533 534 534 /* read root inode and dentry */ ··· 546 548 } 547 549 548 550 /* recover fsynced data */ 549 - if (!is_set_ckpt_flags(F2FS_CKPT(sbi), CP_UMOUNT_FLAG) && 550 - !test_opt(sbi, DISABLE_ROLL_FORWARD)) 551 + if (!test_opt(sbi, DISABLE_ROLL_FORWARD)) 551 552 recover_fsync_data(sbi); 552 553 553 554 /* After POR, we can run background GC thread */
+3 -2
fs/f2fs/xattr.c
··· 208 208 struct page *page; 209 209 void *base_addr; 210 210 int error = 0, found = 0; 211 - int value_len, name_len; 211 + size_t value_len, name_len; 212 212 213 213 if (name == NULL) 214 214 return -EINVAL; ··· 304 304 struct f2fs_xattr_entry *here, *last; 305 305 struct page *page; 306 306 void *base_addr; 307 - int error, found, free, name_len, newsize; 307 + int error, found, free, newsize; 308 + size_t name_len; 308 309 char *pval; 309 310 310 311 if (name == NULL)