Commit 894b8c00 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 1cfea546 6c1e4d06
...@@ -748,7 +748,6 @@ extern void ext2_free_blocks (struct inode *, unsigned long, ...@@ -748,7 +748,6 @@ extern void ext2_free_blocks (struct inode *, unsigned long,
unsigned long); unsigned long);
extern unsigned long ext2_count_free_blocks (struct super_block *); extern unsigned long ext2_count_free_blocks (struct super_block *);
extern unsigned long ext2_count_dirs (struct super_block *); extern unsigned long ext2_count_dirs (struct super_block *);
extern void ext2_check_blocks_bitmap (struct super_block *);
extern struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb, extern struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
unsigned int block_group, unsigned int block_group,
struct buffer_head ** bh); struct buffer_head ** bh);
...@@ -771,7 +770,6 @@ extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page ...@@ -771,7 +770,6 @@ extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page
extern struct inode * ext2_new_inode (struct inode *, umode_t, const struct qstr *); extern struct inode * ext2_new_inode (struct inode *, umode_t, const struct qstr *);
extern void ext2_free_inode (struct inode *); extern void ext2_free_inode (struct inode *);
extern unsigned long ext2_count_free_inodes (struct super_block *); extern unsigned long ext2_count_free_inodes (struct super_block *);
extern void ext2_check_inodes_bitmap (struct super_block *);
extern unsigned long ext2_count_free (struct buffer_head *, unsigned); extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
/* inode.c */ /* inode.c */
......
...@@ -557,6 +557,9 @@ static int parse_options(char *options, struct super_block *sb, ...@@ -557,6 +557,9 @@ static int parse_options(char *options, struct super_block *sb,
set_opt (opts->s_mount_opt, NO_UID32); set_opt (opts->s_mount_opt, NO_UID32);
break; break;
case Opt_nocheck: case Opt_nocheck:
ext2_msg(sb, KERN_WARNING,
"Option nocheck/check=none is deprecated and"
" will be removed in June 2020.");
clear_opt (opts->s_mount_opt, CHECK); clear_opt (opts->s_mount_opt, CHECK);
break; break;
case Opt_debug: case Opt_debug:
...@@ -1335,9 +1338,6 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data) ...@@ -1335,9 +1338,6 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
new_opts.s_resgid = sbi->s_resgid; new_opts.s_resgid = sbi->s_resgid;
spin_unlock(&sbi->s_lock); spin_unlock(&sbi->s_lock);
/*
* Allow the "check" option to be passed as a remount option.
*/
if (!parse_options(data, sb, &new_opts)) if (!parse_options(data, sb, &new_opts))
return -EINVAL; return -EINVAL;
......
...@@ -711,21 +711,18 @@ EXPORT_SYMBOL(dquot_quota_sync); ...@@ -711,21 +711,18 @@ EXPORT_SYMBOL(dquot_quota_sync);
static unsigned long static unsigned long
dqcache_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) dqcache_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
{ {
struct list_head *head;
struct dquot *dquot; struct dquot *dquot;
unsigned long freed = 0; unsigned long freed = 0;
spin_lock(&dq_list_lock); spin_lock(&dq_list_lock);
head = free_dquots.prev; while (!list_empty(&free_dquots) && sc->nr_to_scan) {
while (head != &free_dquots && sc->nr_to_scan) { dquot = list_first_entry(&free_dquots, struct dquot, dq_free);
dquot = list_entry(head, struct dquot, dq_free);
remove_dquot_hash(dquot); remove_dquot_hash(dquot);
remove_free_dquot(dquot); remove_free_dquot(dquot);
remove_inuse(dquot); remove_inuse(dquot);
do_destroy_dquot(dquot); do_destroy_dquot(dquot);
sc->nr_to_scan--; sc->nr_to_scan--;
freed++; freed++;
head = free_dquots.prev;
} }
spin_unlock(&dq_list_lock); spin_unlock(&dq_list_lock);
return freed; return freed;
......
...@@ -533,8 +533,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb, ...@@ -533,8 +533,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
udf_write_aext(table, &epos, &eloc, udf_write_aext(table, &epos, &eloc,
(etype << 30) | elen, 1); (etype << 30) | elen, 1);
} else } else
udf_delete_aext(table, epos, eloc, udf_delete_aext(table, epos);
(etype << 30) | elen);
} else { } else {
alloc_count = 0; alloc_count = 0;
} }
...@@ -630,7 +629,7 @@ static udf_pblk_t udf_table_new_block(struct super_block *sb, ...@@ -630,7 +629,7 @@ static udf_pblk_t udf_table_new_block(struct super_block *sb,
if (goal_elen) if (goal_elen)
udf_write_aext(table, &goal_epos, &goal_eloc, goal_elen, 1); udf_write_aext(table, &goal_epos, &goal_eloc, goal_elen, 1);
else else
udf_delete_aext(table, goal_epos, goal_eloc, goal_elen); udf_delete_aext(table, goal_epos);
brelse(goal_epos.bh); brelse(goal_epos.bh);
udf_add_free_space(sb, partition, -1); udf_add_free_space(sb, partition, -1);
......
...@@ -141,10 +141,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos, ...@@ -141,10 +141,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
fibh->ebh->b_data, fibh->ebh->b_data,
sizeof(struct fileIdentDesc) + fibh->soffset); sizeof(struct fileIdentDesc) + fibh->soffset);
fi_len = (sizeof(struct fileIdentDesc) + fi_len = udf_dir_entry_len(cfi);
cfi->lengthFileIdent +
le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3;
*nf_pos += fi_len - (fibh->eoffset - fibh->soffset); *nf_pos += fi_len - (fibh->eoffset - fibh->soffset);
fibh->eoffset = fibh->soffset + fi_len; fibh->eoffset = fibh->soffset + fi_len;
} else { } else {
...@@ -152,6 +149,9 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos, ...@@ -152,6 +149,9 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
sizeof(struct fileIdentDesc)); sizeof(struct fileIdentDesc));
} }
} }
/* Got last entry outside of dir size - fs is corrupted! */
if (*nf_pos > dir->i_size)
return NULL;
return fi; return fi;
} }
......
...@@ -1147,8 +1147,7 @@ static void udf_update_extents(struct inode *inode, struct kernel_long_ad *laarr ...@@ -1147,8 +1147,7 @@ static void udf_update_extents(struct inode *inode, struct kernel_long_ad *laarr
if (startnum > endnum) { if (startnum > endnum) {
for (i = 0; i < (startnum - endnum); i++) for (i = 0; i < (startnum - endnum); i++)
udf_delete_aext(inode, *epos, laarr[i].extLocation, udf_delete_aext(inode, *epos);
laarr[i].extLength);
} else if (startnum < endnum) { } else if (startnum < endnum) {
for (i = 0; i < (endnum - startnum); i++) { for (i = 0; i < (endnum - startnum); i++) {
udf_insert_aext(inode, *epos, laarr[i].extLocation, udf_insert_aext(inode, *epos, laarr[i].extLocation,
...@@ -2176,14 +2175,15 @@ static int8_t udf_insert_aext(struct inode *inode, struct extent_position epos, ...@@ -2176,14 +2175,15 @@ static int8_t udf_insert_aext(struct inode *inode, struct extent_position epos,
return (nelen >> 30); return (nelen >> 30);
} }
int8_t udf_delete_aext(struct inode *inode, struct extent_position epos, int8_t udf_delete_aext(struct inode *inode, struct extent_position epos)
struct kernel_lb_addr eloc, uint32_t elen)
{ {
struct extent_position oepos; struct extent_position oepos;
int adsize; int adsize;
int8_t etype; int8_t etype;
struct allocExtDesc *aed; struct allocExtDesc *aed;
struct udf_inode_info *iinfo; struct udf_inode_info *iinfo;
struct kernel_lb_addr eloc;
uint32_t elen;
if (epos.bh) { if (epos.bh) {
get_bh(epos.bh); get_bh(epos.bh);
......
...@@ -351,8 +351,6 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, ...@@ -351,8 +351,6 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
loff_t f_pos; loff_t f_pos;
loff_t size = udf_ext0_offset(dir) + dir->i_size; loff_t size = udf_ext0_offset(dir) + dir->i_size;
int nfidlen; int nfidlen;
uint8_t lfi;
uint16_t liu;
udf_pblk_t block; udf_pblk_t block;
struct kernel_lb_addr eloc; struct kernel_lb_addr eloc;
uint32_t elen = 0; uint32_t elen = 0;
...@@ -383,7 +381,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, ...@@ -383,7 +381,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
namelen = 0; namelen = 0;
} }
nfidlen = (sizeof(struct fileIdentDesc) + namelen + 3) & ~3; nfidlen = ALIGN(sizeof(struct fileIdentDesc) + namelen, UDF_NAME_PAD);
f_pos = udf_ext0_offset(dir); f_pos = udf_ext0_offset(dir);
...@@ -424,12 +422,8 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, ...@@ -424,12 +422,8 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
goto out_err; goto out_err;
} }
liu = le16_to_cpu(cfi->lengthOfImpUse);
lfi = cfi->lengthFileIdent;
if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) { if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) {
if (((sizeof(struct fileIdentDesc) + if (udf_dir_entry_len(cfi) == nfidlen) {
liu + lfi + 3) & ~3) == nfidlen) {
cfi->descTag.tagSerialNum = cpu_to_le16(1); cfi->descTag.tagSerialNum = cpu_to_le16(1);
cfi->fileVersionNum = cpu_to_le16(1); cfi->fileVersionNum = cpu_to_le16(1);
cfi->fileCharacteristics = 0; cfi->fileCharacteristics = 0;
...@@ -1201,9 +1195,7 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1201,9 +1195,7 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
if (dir_fi) { if (dir_fi) {
dir_fi->icb.extLocation = cpu_to_lelb(UDF_I(new_dir)->i_location); dir_fi->icb.extLocation = cpu_to_lelb(UDF_I(new_dir)->i_location);
udf_update_tag((char *)dir_fi, udf_update_tag((char *)dir_fi, udf_dir_entry_len(dir_fi));
(sizeof(struct fileIdentDesc) +
le16_to_cpu(dir_fi->lengthOfImpUse) + 3) & ~3);
if (old_iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) if (old_iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB)
mark_inode_dirty(old_inode); mark_inode_dirty(old_inode);
else else
......
...@@ -132,6 +132,12 @@ struct inode *udf_find_metadata_inode_efe(struct super_block *sb, ...@@ -132,6 +132,12 @@ struct inode *udf_find_metadata_inode_efe(struct super_block *sb,
extern int udf_write_fi(struct inode *inode, struct fileIdentDesc *, extern int udf_write_fi(struct inode *inode, struct fileIdentDesc *,
struct fileIdentDesc *, struct udf_fileident_bh *, struct fileIdentDesc *, struct udf_fileident_bh *,
uint8_t *, uint8_t *); uint8_t *, uint8_t *);
static inline unsigned int udf_dir_entry_len(struct fileIdentDesc *cfi)
{
return ALIGN(sizeof(struct fileIdentDesc) +
le16_to_cpu(cfi->lengthOfImpUse) + cfi->lengthFileIdent,
UDF_NAME_PAD);
}
/* file.c */ /* file.c */
extern long udf_ioctl(struct file *, unsigned int, unsigned long); extern long udf_ioctl(struct file *, unsigned int, unsigned long);
...@@ -167,8 +173,7 @@ extern int udf_add_aext(struct inode *, struct extent_position *, ...@@ -167,8 +173,7 @@ extern int udf_add_aext(struct inode *, struct extent_position *,
struct kernel_lb_addr *, uint32_t, int); struct kernel_lb_addr *, uint32_t, int);
extern void udf_write_aext(struct inode *, struct extent_position *, extern void udf_write_aext(struct inode *, struct extent_position *,
struct kernel_lb_addr *, uint32_t, int); struct kernel_lb_addr *, uint32_t, int);
extern int8_t udf_delete_aext(struct inode *, struct extent_position, extern int8_t udf_delete_aext(struct inode *, struct extent_position);
struct kernel_lb_addr, uint32_t);
extern int8_t udf_next_aext(struct inode *, struct extent_position *, extern int8_t udf_next_aext(struct inode *, struct extent_position *,
struct kernel_lb_addr *, uint32_t *, int); struct kernel_lb_addr *, uint32_t *, int);
extern int8_t udf_current_aext(struct inode *, struct extent_position *, extern int8_t udf_current_aext(struct inode *, struct extent_position *,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment