Merge tag 'for_v4.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs

Pull udf, quota, ext2 fixes from Jan Kara:
"UDF:
- fix an oops due to corrupted disk image
- two small cleanups

quota:
- a fixfor lru handling
- cleanup

ext2:
- a warning about a deprecated mount option"

* tag 'for_v4.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
udf: Drop unused arguments of udf_delete_aext()
udf: Provide function for calculating dir entry length
udf: Detect incorrect directory size
ext2: add warning when specifying nocheck option
quota: Cleanup list iteration in dqcache_shrink_scan()
quota: reclaim least recently used dquots

+25 -34
-2
fs/ext2/ext2.h
··· 748 unsigned long); 749 extern unsigned long ext2_count_free_blocks (struct super_block *); 750 extern unsigned long ext2_count_dirs (struct super_block *); 751 - extern void ext2_check_blocks_bitmap (struct super_block *); 752 extern struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb, 753 unsigned int block_group, 754 struct buffer_head ** bh); ··· 770 extern struct inode * ext2_new_inode (struct inode *, umode_t, const struct qstr *); 771 extern void ext2_free_inode (struct inode *); 772 extern unsigned long ext2_count_free_inodes (struct super_block *); 773 - extern void ext2_check_inodes_bitmap (struct super_block *); 774 extern unsigned long ext2_count_free (struct buffer_head *, unsigned); 775 776 /* inode.c */
··· 748 unsigned long); 749 extern unsigned long ext2_count_free_blocks (struct super_block *); 750 extern unsigned long ext2_count_dirs (struct super_block *); 751 extern struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb, 752 unsigned int block_group, 753 struct buffer_head ** bh); ··· 771 extern struct inode * ext2_new_inode (struct inode *, umode_t, const struct qstr *); 772 extern void ext2_free_inode (struct inode *); 773 extern unsigned long ext2_count_free_inodes (struct super_block *); 774 extern unsigned long ext2_count_free (struct buffer_head *, unsigned); 775 776 /* inode.c */
+3 -3
fs/ext2/super.c
··· 557 set_opt (opts->s_mount_opt, NO_UID32); 558 break; 559 case Opt_nocheck: 560 clear_opt (opts->s_mount_opt, CHECK); 561 break; 562 case Opt_debug: ··· 1338 new_opts.s_resgid = sbi->s_resgid; 1339 spin_unlock(&sbi->s_lock); 1340 1341 - /* 1342 - * Allow the "check" option to be passed as a remount option. 1343 - */ 1344 if (!parse_options(data, sb, &new_opts)) 1345 return -EINVAL; 1346
··· 557 set_opt (opts->s_mount_opt, NO_UID32); 558 break; 559 case Opt_nocheck: 560 + ext2_msg(sb, KERN_WARNING, 561 + "Option nocheck/check=none is deprecated and" 562 + " will be removed in June 2020."); 563 clear_opt (opts->s_mount_opt, CHECK); 564 break; 565 case Opt_debug: ··· 1335 new_opts.s_resgid = sbi->s_resgid; 1336 spin_unlock(&sbi->s_lock); 1337 1338 if (!parse_options(data, sb, &new_opts)) 1339 return -EINVAL; 1340
+2 -5
fs/quota/dquot.c
··· 711 static unsigned long 712 dqcache_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) 713 { 714 - struct list_head *head; 715 struct dquot *dquot; 716 unsigned long freed = 0; 717 718 spin_lock(&dq_list_lock); 719 - head = free_dquots.prev; 720 - while (head != &free_dquots && sc->nr_to_scan) { 721 - dquot = list_entry(head, struct dquot, dq_free); 722 remove_dquot_hash(dquot); 723 remove_free_dquot(dquot); 724 remove_inuse(dquot); 725 do_destroy_dquot(dquot); 726 sc->nr_to_scan--; 727 freed++; 728 - head = free_dquots.prev; 729 } 730 spin_unlock(&dq_list_lock); 731 return freed;
··· 711 static unsigned long 712 dqcache_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) 713 { 714 struct dquot *dquot; 715 unsigned long freed = 0; 716 717 spin_lock(&dq_list_lock); 718 + while (!list_empty(&free_dquots) && sc->nr_to_scan) { 719 + dquot = list_first_entry(&free_dquots, struct dquot, dq_free); 720 remove_dquot_hash(dquot); 721 remove_free_dquot(dquot); 722 remove_inuse(dquot); 723 do_destroy_dquot(dquot); 724 sc->nr_to_scan--; 725 freed++; 726 } 727 spin_unlock(&dq_list_lock); 728 return freed;
+2 -3
fs/udf/balloc.c
··· 533 udf_write_aext(table, &epos, &eloc, 534 (etype << 30) | elen, 1); 535 } else 536 - udf_delete_aext(table, epos, eloc, 537 - (etype << 30) | elen); 538 } else { 539 alloc_count = 0; 540 } ··· 629 if (goal_elen) 630 udf_write_aext(table, &goal_epos, &goal_eloc, goal_elen, 1); 631 else 632 - udf_delete_aext(table, goal_epos, goal_eloc, goal_elen); 633 brelse(goal_epos.bh); 634 635 udf_add_free_space(sb, partition, -1);
··· 533 udf_write_aext(table, &epos, &eloc, 534 (etype << 30) | elen, 1); 535 } else 536 + udf_delete_aext(table, epos); 537 } else { 538 alloc_count = 0; 539 } ··· 630 if (goal_elen) 631 udf_write_aext(table, &goal_epos, &goal_eloc, goal_elen, 1); 632 else 633 + udf_delete_aext(table, goal_epos); 634 brelse(goal_epos.bh); 635 636 udf_add_free_space(sb, partition, -1);
+4 -4
fs/udf/directory.c
··· 141 fibh->ebh->b_data, 142 sizeof(struct fileIdentDesc) + fibh->soffset); 143 144 - fi_len = (sizeof(struct fileIdentDesc) + 145 - cfi->lengthFileIdent + 146 - le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3; 147 - 148 *nf_pos += fi_len - (fibh->eoffset - fibh->soffset); 149 fibh->eoffset = fibh->soffset + fi_len; 150 } else { ··· 149 sizeof(struct fileIdentDesc)); 150 } 151 } 152 return fi; 153 } 154
··· 141 fibh->ebh->b_data, 142 sizeof(struct fileIdentDesc) + fibh->soffset); 143 144 + fi_len = udf_dir_entry_len(cfi); 145 *nf_pos += fi_len - (fibh->eoffset - fibh->soffset); 146 fibh->eoffset = fibh->soffset + fi_len; 147 } else { ··· 152 sizeof(struct fileIdentDesc)); 153 } 154 } 155 + /* Got last entry outside of dir size - fs is corrupted! */ 156 + if (*nf_pos > dir->i_size) 157 + return NULL; 158 return fi; 159 } 160
+4 -4
fs/udf/inode.c
··· 1147 1148 if (startnum > endnum) { 1149 for (i = 0; i < (startnum - endnum); i++) 1150 - udf_delete_aext(inode, *epos, laarr[i].extLocation, 1151 - laarr[i].extLength); 1152 } else if (startnum < endnum) { 1153 for (i = 0; i < (endnum - startnum); i++) { 1154 udf_insert_aext(inode, *epos, laarr[i].extLocation, ··· 2175 return (nelen >> 30); 2176 } 2177 2178 - int8_t udf_delete_aext(struct inode *inode, struct extent_position epos, 2179 - struct kernel_lb_addr eloc, uint32_t elen) 2180 { 2181 struct extent_position oepos; 2182 int adsize; 2183 int8_t etype; 2184 struct allocExtDesc *aed; 2185 struct udf_inode_info *iinfo; 2186 2187 if (epos.bh) { 2188 get_bh(epos.bh);
··· 1147 1148 if (startnum > endnum) { 1149 for (i = 0; i < (startnum - endnum); i++) 1150 + udf_delete_aext(inode, *epos); 1151 } else if (startnum < endnum) { 1152 for (i = 0; i < (endnum - startnum); i++) { 1153 udf_insert_aext(inode, *epos, laarr[i].extLocation, ··· 2176 return (nelen >> 30); 2177 } 2178 2179 + int8_t udf_delete_aext(struct inode *inode, struct extent_position epos) 2180 { 2181 struct extent_position oepos; 2182 int adsize; 2183 int8_t etype; 2184 struct allocExtDesc *aed; 2185 struct udf_inode_info *iinfo; 2186 + struct kernel_lb_addr eloc; 2187 + uint32_t elen; 2188 2189 if (epos.bh) { 2190 get_bh(epos.bh);
+3 -11
fs/udf/namei.c
··· 351 loff_t f_pos; 352 loff_t size = udf_ext0_offset(dir) + dir->i_size; 353 int nfidlen; 354 - uint8_t lfi; 355 - uint16_t liu; 356 udf_pblk_t block; 357 struct kernel_lb_addr eloc; 358 uint32_t elen = 0; ··· 381 namelen = 0; 382 } 383 384 - nfidlen = (sizeof(struct fileIdentDesc) + namelen + 3) & ~3; 385 386 f_pos = udf_ext0_offset(dir); 387 ··· 422 goto out_err; 423 } 424 425 - liu = le16_to_cpu(cfi->lengthOfImpUse); 426 - lfi = cfi->lengthFileIdent; 427 - 428 if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) { 429 - if (((sizeof(struct fileIdentDesc) + 430 - liu + lfi + 3) & ~3) == nfidlen) { 431 cfi->descTag.tagSerialNum = cpu_to_le16(1); 432 cfi->fileVersionNum = cpu_to_le16(1); 433 cfi->fileCharacteristics = 0; ··· 1195 1196 if (dir_fi) { 1197 dir_fi->icb.extLocation = cpu_to_lelb(UDF_I(new_dir)->i_location); 1198 - udf_update_tag((char *)dir_fi, 1199 - (sizeof(struct fileIdentDesc) + 1200 - le16_to_cpu(dir_fi->lengthOfImpUse) + 3) & ~3); 1201 if (old_iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) 1202 mark_inode_dirty(old_inode); 1203 else
··· 351 loff_t f_pos; 352 loff_t size = udf_ext0_offset(dir) + dir->i_size; 353 int nfidlen; 354 udf_pblk_t block; 355 struct kernel_lb_addr eloc; 356 uint32_t elen = 0; ··· 383 namelen = 0; 384 } 385 386 + nfidlen = ALIGN(sizeof(struct fileIdentDesc) + namelen, UDF_NAME_PAD); 387 388 f_pos = udf_ext0_offset(dir); 389 ··· 424 goto out_err; 425 } 426 427 if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) { 428 + if (udf_dir_entry_len(cfi) == nfidlen) { 429 cfi->descTag.tagSerialNum = cpu_to_le16(1); 430 cfi->fileVersionNum = cpu_to_le16(1); 431 cfi->fileCharacteristics = 0; ··· 1201 1202 if (dir_fi) { 1203 dir_fi->icb.extLocation = cpu_to_lelb(UDF_I(new_dir)->i_location); 1204 + udf_update_tag((char *)dir_fi, udf_dir_entry_len(dir_fi)); 1205 if (old_iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) 1206 mark_inode_dirty(old_inode); 1207 else
+7 -2
fs/udf/udfdecl.h
··· 132 extern int udf_write_fi(struct inode *inode, struct fileIdentDesc *, 133 struct fileIdentDesc *, struct udf_fileident_bh *, 134 uint8_t *, uint8_t *); 135 136 /* file.c */ 137 extern long udf_ioctl(struct file *, unsigned int, unsigned long); ··· 173 struct kernel_lb_addr *, uint32_t, int); 174 extern void udf_write_aext(struct inode *, struct extent_position *, 175 struct kernel_lb_addr *, uint32_t, int); 176 - extern int8_t udf_delete_aext(struct inode *, struct extent_position, 177 - struct kernel_lb_addr, uint32_t); 178 extern int8_t udf_next_aext(struct inode *, struct extent_position *, 179 struct kernel_lb_addr *, uint32_t *, int); 180 extern int8_t udf_current_aext(struct inode *, struct extent_position *,
··· 132 extern int udf_write_fi(struct inode *inode, struct fileIdentDesc *, 133 struct fileIdentDesc *, struct udf_fileident_bh *, 134 uint8_t *, uint8_t *); 135 + static inline unsigned int udf_dir_entry_len(struct fileIdentDesc *cfi) 136 + { 137 + return ALIGN(sizeof(struct fileIdentDesc) + 138 + le16_to_cpu(cfi->lengthOfImpUse) + cfi->lengthFileIdent, 139 + UDF_NAME_PAD); 140 + } 141 142 /* file.c */ 143 extern long udf_ioctl(struct file *, unsigned int, unsigned long); ··· 167 struct kernel_lb_addr *, uint32_t, int); 168 extern void udf_write_aext(struct inode *, struct extent_position *, 169 struct kernel_lb_addr *, uint32_t, int); 170 + extern int8_t udf_delete_aext(struct inode *, struct extent_position); 171 extern int8_t udf_next_aext(struct inode *, struct extent_position *, 172 struct kernel_lb_addr *, uint32_t *, int); 173 extern int8_t udf_current_aext(struct inode *, struct extent_position *,