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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'erofs-for-7.0-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs

Pull erofs fixes from Gao Xiang:

- Do not share the page cache if the real @aops differs

- Fix the incomplete condition for interlaced plain extents

- Get rid of more unnecessary #ifdefs

* tag 'erofs-for-7.0-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs:
erofs: fix interlaced plain identification for encoded extents
erofs: remove more unnecessary #ifdefs
erofs: allow sharing page cache with the same aops only

+62 -67
+6 -1
fs/erofs/inode.c
··· 222 222 223 223 static int erofs_fill_inode(struct inode *inode) 224 224 { 225 + const struct address_space_operations *aops; 225 226 int err; 226 227 227 228 trace_erofs_fill_inode(inode); ··· 255 254 } 256 255 257 256 mapping_set_large_folios(inode->i_mapping); 258 - return erofs_inode_set_aops(inode, inode, false); 257 + aops = erofs_get_aops(inode, false); 258 + if (IS_ERR(aops)) 259 + return PTR_ERR(aops); 260 + inode->i_mapping->a_ops = aops; 261 + return 0; 259 262 } 260 263 261 264 /*
+7 -9
fs/erofs/internal.h
··· 471 471 return NULL; 472 472 } 473 473 474 - static inline int erofs_inode_set_aops(struct inode *inode, 475 - struct inode *realinode, bool no_fscache) 474 + static inline const struct address_space_operations * 475 + erofs_get_aops(struct inode *realinode, bool no_fscache) 476 476 { 477 477 if (erofs_inode_is_data_compressed(EROFS_I(realinode)->datalayout)) { 478 478 if (!IS_ENABLED(CONFIG_EROFS_FS_ZIP)) 479 - return -EOPNOTSUPP; 479 + return ERR_PTR(-EOPNOTSUPP); 480 480 DO_ONCE_LITE_IF(realinode->i_blkbits != PAGE_SHIFT, 481 481 erofs_info, realinode->i_sb, 482 482 "EXPERIMENTAL EROFS subpage compressed block support in use. Use at your own risk!"); 483 - inode->i_mapping->a_ops = &z_erofs_aops; 484 - return 0; 483 + return &z_erofs_aops; 485 484 } 486 - inode->i_mapping->a_ops = &erofs_aops; 487 485 if (IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND) && !no_fscache && 488 486 erofs_is_fscache_mode(realinode->i_sb)) 489 - inode->i_mapping->a_ops = &erofs_fscache_access_aops; 487 + return &erofs_fscache_access_aops; 490 488 if (IS_ENABLED(CONFIG_EROFS_FS_BACKED_BY_FILE) && 491 489 erofs_is_fileio_mode(EROFS_SB(realinode->i_sb))) 492 - inode->i_mapping->a_ops = &erofs_fileio_aops; 493 - return 0; 490 + return &erofs_fileio_aops; 491 + return &erofs_aops; 494 492 } 495 493 496 494 int erofs_register_sysfs(struct super_block *sb);
+9 -5
fs/erofs/ishare.c
··· 40 40 { 41 41 struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb); 42 42 struct erofs_inode *vi = EROFS_I(inode); 43 + const struct address_space_operations *aops; 43 44 struct erofs_inode_fingerprint fp; 44 45 struct inode *sharedinode; 45 46 unsigned long hash; 46 47 48 + aops = erofs_get_aops(inode, true); 49 + if (IS_ERR(aops)) 50 + return false; 47 51 if (erofs_xattr_fill_inode_fingerprint(&fp, inode, sbi->domain_id)) 48 52 return false; 49 53 hash = xxh32(fp.opaque, fp.size, 0); ··· 60 56 } 61 57 62 58 if (inode_state_read_once(sharedinode) & I_NEW) { 63 - if (erofs_inode_set_aops(sharedinode, inode, true)) { 64 - iget_failed(sharedinode); 65 - kfree(fp.opaque); 66 - return false; 67 - } 59 + sharedinode->i_mapping->a_ops = aops; 68 60 sharedinode->i_size = vi->vfs_inode.i_size; 69 61 unlock_new_inode(sharedinode); 70 62 } else { 71 63 kfree(fp.opaque); 64 + if (aops != sharedinode->i_mapping->a_ops) { 65 + iput(sharedinode); 66 + return false; 67 + } 72 68 if (sharedinode->i_size != vi->vfs_inode.i_size) { 73 69 _erofs_printk(inode->i_sb, KERN_WARNING 74 70 "size(%lld:%lld) not matches for the same fingerprint\n",
+35 -48
fs/erofs/super.c
··· 424 424 425 425 static bool erofs_fc_set_dax_mode(struct fs_context *fc, unsigned int mode) 426 426 { 427 - #ifdef CONFIG_FS_DAX 428 - struct erofs_sb_info *sbi = fc->s_fs_info; 427 + if (IS_ENABLED(CONFIG_FS_DAX)) { 428 + struct erofs_sb_info *sbi = fc->s_fs_info; 429 429 430 - switch (mode) { 431 - case EROFS_MOUNT_DAX_ALWAYS: 432 - set_opt(&sbi->opt, DAX_ALWAYS); 433 - clear_opt(&sbi->opt, DAX_NEVER); 434 - return true; 435 - case EROFS_MOUNT_DAX_NEVER: 436 - set_opt(&sbi->opt, DAX_NEVER); 437 - clear_opt(&sbi->opt, DAX_ALWAYS); 438 - return true; 439 - default: 430 + if (mode == EROFS_MOUNT_DAX_ALWAYS) { 431 + set_opt(&sbi->opt, DAX_ALWAYS); 432 + clear_opt(&sbi->opt, DAX_NEVER); 433 + return true; 434 + } else if (mode == EROFS_MOUNT_DAX_NEVER) { 435 + set_opt(&sbi->opt, DAX_NEVER); 436 + clear_opt(&sbi->opt, DAX_ALWAYS); 437 + return true; 438 + } 440 439 DBG_BUGON(1); 441 440 return false; 442 441 } 443 - #else 444 442 errorfc(fc, "dax options not supported"); 445 443 return false; 446 - #endif 447 444 } 448 445 449 446 static int erofs_fc_parse_param(struct fs_context *fc, ··· 457 460 458 461 switch (opt) { 459 462 case Opt_user_xattr: 460 - #ifdef CONFIG_EROFS_FS_XATTR 461 - if (result.boolean) 463 + if (!IS_ENABLED(CONFIG_EROFS_FS_XATTR)) 464 + errorfc(fc, "{,no}user_xattr options not supported"); 465 + else if (result.boolean) 462 466 set_opt(&sbi->opt, XATTR_USER); 463 467 else 464 468 clear_opt(&sbi->opt, XATTR_USER); 465 - #else 466 - errorfc(fc, "{,no}user_xattr options not supported"); 467 - #endif 468 469 break; 469 470 case Opt_acl: 470 - #ifdef CONFIG_EROFS_FS_POSIX_ACL 471 - if (result.boolean) 471 + if (!IS_ENABLED(CONFIG_EROFS_FS_POSIX_ACL)) 472 + errorfc(fc, "{,no}acl options not supported"); 473 + else if (result.boolean) 472 474 set_opt(&sbi->opt, POSIX_ACL); 473 475 else 474 476 clear_opt(&sbi->opt, POSIX_ACL); 475 - #else 476 - errorfc(fc, "{,no}acl options not supported"); 477 - #endif 478 477 break; 479 478 case Opt_cache_strategy: 480 - #ifdef CONFIG_EROFS_FS_ZIP 481 - sbi->opt.cache_strategy = result.uint_32; 482 - #else 483 - errorfc(fc, "compression not supported, cache_strategy ignored"); 484 - #endif 479 + if (!IS_ENABLED(CONFIG_EROFS_FS_ZIP)) 480 + errorfc(fc, "compression not supported, cache_strategy ignored"); 481 + else 482 + sbi->opt.cache_strategy = result.uint_32; 485 483 break; 486 484 case Opt_dax: 487 485 if (!erofs_fc_set_dax_mode(fc, EROFS_MOUNT_DAX_ALWAYS)) ··· 525 533 break; 526 534 #endif 527 535 case Opt_directio: 528 - #ifdef CONFIG_EROFS_FS_BACKED_BY_FILE 529 - if (result.boolean) 536 + if (!IS_ENABLED(CONFIG_EROFS_FS_BACKED_BY_FILE)) 537 + errorfc(fc, "%s option not supported", erofs_fs_parameters[opt].name); 538 + else if (result.boolean) 530 539 set_opt(&sbi->opt, DIRECT_IO); 531 540 else 532 541 clear_opt(&sbi->opt, DIRECT_IO); 533 - #else 534 - errorfc(fc, "%s option not supported", erofs_fs_parameters[opt].name); 535 - #endif 536 542 break; 537 543 case Opt_fsoffset: 538 544 sbi->dif0.fsoff = result.uint_64; 539 545 break; 540 546 case Opt_inode_share: 541 - #ifdef CONFIG_EROFS_FS_PAGE_CACHE_SHARE 542 - set_opt(&sbi->opt, INODE_SHARE); 543 - #else 544 - errorfc(fc, "%s option not supported", erofs_fs_parameters[opt].name); 545 - #endif 547 + if (!IS_ENABLED(CONFIG_EROFS_FS_PAGE_CACHE_SHARE)) 548 + errorfc(fc, "%s option not supported", erofs_fs_parameters[opt].name); 549 + else 550 + set_opt(&sbi->opt, INODE_SHARE); 546 551 break; 547 552 } 548 553 return 0; ··· 798 809 ret = get_tree_bdev_flags(fc, erofs_fc_fill_super, 799 810 IS_ENABLED(CONFIG_EROFS_FS_BACKED_BY_FILE) ? 800 811 GET_TREE_BDEV_QUIET_LOOKUP : 0); 801 - #ifdef CONFIG_EROFS_FS_BACKED_BY_FILE 802 - if (ret == -ENOTBLK) { 812 + if (IS_ENABLED(CONFIG_EROFS_FS_BACKED_BY_FILE) && ret == -ENOTBLK) { 803 813 struct file *file; 804 814 805 815 if (!fc->source) ··· 812 824 sbi->dif0.file->f_mapping->a_ops->read_folio) 813 825 return get_tree_nodev(fc, erofs_fc_fill_super); 814 826 } 815 - #endif 816 827 return ret; 817 828 } 818 829 ··· 1095 1108 seq_puts(seq, ",dax=never"); 1096 1109 if (erofs_is_fileio_mode(sbi) && test_opt(opt, DIRECT_IO)) 1097 1110 seq_puts(seq, ",directio"); 1098 - #ifdef CONFIG_EROFS_FS_ONDEMAND 1099 - if (sbi->fsid) 1100 - seq_printf(seq, ",fsid=%s", sbi->fsid); 1101 - if (sbi->domain_id) 1102 - seq_printf(seq, ",domain_id=%s", sbi->domain_id); 1103 - #endif 1111 + if (IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND)) { 1112 + if (sbi->fsid) 1113 + seq_printf(seq, ",fsid=%s", sbi->fsid); 1114 + if (sbi->domain_id) 1115 + seq_printf(seq, ",domain_id=%s", sbi->domain_id); 1116 + } 1104 1117 if (sbi->dif0.fsoff) 1105 1118 seq_printf(seq, ",fsoffset=%llu", sbi->dif0.fsoff); 1106 1119 if (test_opt(opt, INODE_SHARE))
+5 -4
fs/erofs/zmap.c
··· 513 513 unsigned int recsz = z_erofs_extent_recsize(vi->z_advise); 514 514 erofs_off_t pos = round_up(Z_EROFS_MAP_HEADER_END(erofs_iloc(inode) + 515 515 vi->inode_isize + vi->xattr_isize), recsz); 516 + unsigned int bmask = sb->s_blocksize - 1; 516 517 bool in_mbox = erofs_inode_in_metabox(inode); 517 518 erofs_off_t lend = inode->i_size; 518 519 erofs_off_t l, r, mid, pa, la, lstart; ··· 597 596 map->m_flags |= EROFS_MAP_MAPPED | 598 597 EROFS_MAP_FULL_MAPPED | EROFS_MAP_ENCODED; 599 598 fmt = map->m_plen >> Z_EROFS_EXTENT_PLEN_FMT_BIT; 599 + if (map->m_plen & Z_EROFS_EXTENT_PLEN_PARTIAL) 600 + map->m_flags |= EROFS_MAP_PARTIAL_REF; 601 + map->m_plen &= Z_EROFS_EXTENT_PLEN_MASK; 600 602 if (fmt) 601 603 map->m_algorithmformat = fmt - 1; 602 - else if (interlaced && !erofs_blkoff(sb, map->m_pa)) 604 + else if (interlaced && !((map->m_pa | map->m_plen) & bmask)) 603 605 map->m_algorithmformat = 604 606 Z_EROFS_COMPRESSION_INTERLACED; 605 607 else 606 608 map->m_algorithmformat = 607 609 Z_EROFS_COMPRESSION_SHIFTED; 608 - if (map->m_plen & Z_EROFS_EXTENT_PLEN_PARTIAL) 609 - map->m_flags |= EROFS_MAP_PARTIAL_REF; 610 - map->m_plen &= Z_EROFS_EXTENT_PLEN_MASK; 611 610 } 612 611 } 613 612 map->m_llen = lend - map->m_la;