Commit b97d4c42 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for_v5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs

Pull ext2, reiserfs, quota and writeback updates from Jan Kara:

 - a couple of quota fixes (mostly for problems found by syzbot)

 - several ext2 cleanups

 - one fix for reiserfs crash on corrupted image

 - a fix for spurious warning in writeback code

* tag 'for_v5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
  writeback: don't warn on an unregistered BDI in __mark_inode_dirty
  fs: quota: fix array-index-out-of-bounds bug by passing correct argument to vfs_cleanup_quota_inode()
  reiserfs: add check for an invalid ih_entry_count
  ext2: Fix fall-through warnings for Clang
  fs/ext2: Use ext2_put_page
  docs: filesystems: Reduce ext2.rst to one top-level heading
  quota: Sanity-check quota file headers on load
  quota: Don't overflow quota file offsets
  ext2: Remove unnecessary blank
  fs/quota: update quota state flags scheme with project quota flags
parents 14bd41e4 f7387170
.. SPDX-License-Identifier: GPL-2.0 .. SPDX-License-Identifier: GPL-2.0
==============================
The Second Extended Filesystem The Second Extended Filesystem
============================== ==============================
......
...@@ -66,12 +66,6 @@ static inline unsigned ext2_chunk_size(struct inode *inode) ...@@ -66,12 +66,6 @@ static inline unsigned ext2_chunk_size(struct inode *inode)
return inode->i_sb->s_blocksize; return inode->i_sb->s_blocksize;
} }
static inline void ext2_put_page(struct page *page)
{
kunmap(page);
put_page(page);
}
/* /*
* Return the offset into page `page_nr' of the last valid * Return the offset into page `page_nr' of the last valid
* byte in that page, plus one. * byte in that page, plus one.
...@@ -336,6 +330,8 @@ ext2_readdir(struct file *file, struct dir_context *ctx) ...@@ -336,6 +330,8 @@ ext2_readdir(struct file *file, struct dir_context *ctx)
* returns the page in which the entry was found (as a parameter - res_page), * returns the page in which the entry was found (as a parameter - res_page),
* and the entry itself. Page is returned mapped and unlocked. * and the entry itself. Page is returned mapped and unlocked.
* Entry is guaranteed to be valid. * Entry is guaranteed to be valid.
*
* On Success ext2_put_page() should be called on *res_page.
*/ */
struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir, struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir,
const struct qstr *child, struct page **res_page) const struct qstr *child, struct page **res_page)
...@@ -401,6 +397,12 @@ struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir, ...@@ -401,6 +397,12 @@ struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir,
return de; return de;
} }
/**
* Return the '..' directory entry and the page in which the entry was found
* (as a parameter - p).
*
* On Success ext2_put_page() should be called on *p.
*/
struct ext2_dir_entry_2 * ext2_dotdot (struct inode *dir, struct page **p) struct ext2_dir_entry_2 * ext2_dotdot (struct inode *dir, struct page **p)
{ {
struct page *page = ext2_get_page(dir, 0, 0); struct page *page = ext2_get_page(dir, 0, 0);
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include <linux/blockgroup_lock.h> #include <linux/blockgroup_lock.h>
#include <linux/percpu_counter.h> #include <linux/percpu_counter.h>
#include <linux/rbtree.h> #include <linux/rbtree.h>
#include <linux/mm.h>
#include <linux/highmem.h>
/* XXX Here for now... not interested in restructing headers JUST now */ /* XXX Here for now... not interested in restructing headers JUST now */
...@@ -745,6 +747,11 @@ extern int ext2_delete_entry (struct ext2_dir_entry_2 *, struct page *); ...@@ -745,6 +747,11 @@ extern int ext2_delete_entry (struct ext2_dir_entry_2 *, struct page *);
extern int ext2_empty_dir (struct inode *); extern int ext2_empty_dir (struct inode *);
extern struct ext2_dir_entry_2 * ext2_dotdot (struct inode *, struct page **); extern struct ext2_dir_entry_2 * ext2_dotdot (struct inode *, struct page **);
extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page *, struct inode *, int); extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page *, struct inode *, int);
static inline void ext2_put_page(struct page *page)
{
kunmap(page);
put_page(page);
}
/* ialloc.c */ /* ialloc.c */
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 *);
......
...@@ -1256,6 +1256,7 @@ static void __ext2_truncate_blocks(struct inode *inode, loff_t offset) ...@@ -1256,6 +1256,7 @@ static void __ext2_truncate_blocks(struct inode *inode, loff_t offset)
mark_inode_dirty(inode); mark_inode_dirty(inode);
ext2_free_branches(inode, &nr, &nr+1, 3); ext2_free_branches(inode, &nr, &nr+1, 3);
} }
break;
case EXT2_TIND_BLOCK: case EXT2_TIND_BLOCK:
; ;
} }
......
...@@ -389,23 +389,18 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry, ...@@ -389,23 +389,18 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
if (dir_de) { if (dir_de) {
if (old_dir != new_dir) if (old_dir != new_dir)
ext2_set_link(old_inode, dir_de, dir_page, new_dir, 0); ext2_set_link(old_inode, dir_de, dir_page, new_dir, 0);
else { else
kunmap(dir_page); ext2_put_page(dir_page);
put_page(dir_page);
}
inode_dec_link_count(old_dir); inode_dec_link_count(old_dir);
} }
return 0; return 0;
out_dir: out_dir:
if (dir_de) { if (dir_de)
kunmap(dir_page); ext2_put_page(dir_page);
put_page(dir_page);
}
out_old: out_old:
kunmap(old_page); ext2_put_page(old_page);
put_page(old_page);
out: out:
return err; return err;
} }
......
...@@ -1070,7 +1070,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1070,7 +1070,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
/ EXT2_BLOCKS_PER_GROUP(sb)) + 1; / EXT2_BLOCKS_PER_GROUP(sb)) + 1;
db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) / db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) /
EXT2_DESC_PER_BLOCK(sb); EXT2_DESC_PER_BLOCK(sb);
sbi->s_group_desc = kmalloc_array (db_count, sbi->s_group_desc = kmalloc_array(db_count,
sizeof(struct buffer_head *), sizeof(struct buffer_head *),
GFP_KERNEL); GFP_KERNEL);
if (sbi->s_group_desc == NULL) { if (sbi->s_group_desc == NULL) {
......
...@@ -2321,10 +2321,6 @@ void __mark_inode_dirty(struct inode *inode, int flags) ...@@ -2321,10 +2321,6 @@ void __mark_inode_dirty(struct inode *inode, int flags)
wb = locked_inode_to_wb_and_lock_list(inode); wb = locked_inode_to_wb_and_lock_list(inode);
WARN((wb->bdi->capabilities & BDI_CAP_WRITEBACK) &&
!test_bit(WB_registered, &wb->state),
"bdi-%s not registered\n", bdi_dev_name(wb->bdi));
inode->dirtied_when = jiffies; inode->dirtied_when = jiffies;
if (dirtytime) if (dirtytime)
inode->dirtied_time_when = jiffies; inode->dirtied_time_when = jiffies;
......
...@@ -2455,7 +2455,7 @@ int dquot_resume(struct super_block *sb, int type) ...@@ -2455,7 +2455,7 @@ int dquot_resume(struct super_block *sb, int type)
ret = dquot_load_quota_sb(sb, cnt, dqopt->info[cnt].dqi_fmt_id, ret = dquot_load_quota_sb(sb, cnt, dqopt->info[cnt].dqi_fmt_id,
flags); flags);
if (ret < 0) if (ret < 0)
vfs_cleanup_quota_inode(sb, type); vfs_cleanup_quota_inode(sb, cnt);
} }
return ret; return ret;
......
...@@ -62,7 +62,7 @@ static ssize_t read_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf) ...@@ -62,7 +62,7 @@ static ssize_t read_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf)
memset(buf, 0, info->dqi_usable_bs); memset(buf, 0, info->dqi_usable_bs);
return sb->s_op->quota_read(sb, info->dqi_type, buf, return sb->s_op->quota_read(sb, info->dqi_type, buf,
info->dqi_usable_bs, blk << info->dqi_blocksize_bits); info->dqi_usable_bs, (loff_t)blk << info->dqi_blocksize_bits);
} }
static ssize_t write_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf) static ssize_t write_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf)
...@@ -71,7 +71,7 @@ static ssize_t write_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf) ...@@ -71,7 +71,7 @@ static ssize_t write_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf)
ssize_t ret; ssize_t ret;
ret = sb->s_op->quota_write(sb, info->dqi_type, buf, ret = sb->s_op->quota_write(sb, info->dqi_type, buf,
info->dqi_usable_bs, blk << info->dqi_blocksize_bits); info->dqi_usable_bs, (loff_t)blk << info->dqi_blocksize_bits);
if (ret != info->dqi_usable_bs) { if (ret != info->dqi_usable_bs) {
quota_error(sb, "dquota write failed"); quota_error(sb, "dquota write failed");
if (ret >= 0) if (ret >= 0)
...@@ -284,7 +284,7 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info, ...@@ -284,7 +284,7 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info,
blk); blk);
goto out_buf; goto out_buf;
} }
dquot->dq_off = (blk << info->dqi_blocksize_bits) + dquot->dq_off = ((loff_t)blk << info->dqi_blocksize_bits) +
sizeof(struct qt_disk_dqdbheader) + sizeof(struct qt_disk_dqdbheader) +
i * info->dqi_entry_size; i * info->dqi_entry_size;
kfree(buf); kfree(buf);
...@@ -559,7 +559,7 @@ static loff_t find_block_dqentry(struct qtree_mem_dqinfo *info, ...@@ -559,7 +559,7 @@ static loff_t find_block_dqentry(struct qtree_mem_dqinfo *info,
ret = -EIO; ret = -EIO;
goto out_buf; goto out_buf;
} else { } else {
ret = (blk << info->dqi_blocksize_bits) + sizeof(struct ret = ((loff_t)blk << info->dqi_blocksize_bits) + sizeof(struct
qt_disk_dqdbheader) + i * info->dqi_entry_size; qt_disk_dqdbheader) + i * info->dqi_entry_size;
} }
out_buf: out_buf:
......
...@@ -157,6 +157,25 @@ static int v2_read_file_info(struct super_block *sb, int type) ...@@ -157,6 +157,25 @@ static int v2_read_file_info(struct super_block *sb, int type)
qinfo->dqi_entry_size = sizeof(struct v2r1_disk_dqblk); qinfo->dqi_entry_size = sizeof(struct v2r1_disk_dqblk);
qinfo->dqi_ops = &v2r1_qtree_ops; qinfo->dqi_ops = &v2r1_qtree_ops;
} }
ret = -EUCLEAN;
/* Some sanity checks of the read headers... */
if ((loff_t)qinfo->dqi_blocks << qinfo->dqi_blocksize_bits >
i_size_read(sb_dqopt(sb)->files[type])) {
quota_error(sb, "Number of blocks too big for quota file size (%llu > %llu).",
(loff_t)qinfo->dqi_blocks << qinfo->dqi_blocksize_bits,
i_size_read(sb_dqopt(sb)->files[type]));
goto out;
}
if (qinfo->dqi_free_blk >= qinfo->dqi_blocks) {
quota_error(sb, "Free block number too big (%u >= %u).",
qinfo->dqi_free_blk, qinfo->dqi_blocks);
goto out;
}
if (qinfo->dqi_free_entry >= qinfo->dqi_blocks) {
quota_error(sb, "Block with free entry too big (%u >= %u).",
qinfo->dqi_free_entry, qinfo->dqi_blocks);
goto out;
}
ret = 0; ret = 0;
out: out:
up_read(&dqopt->dqio_sem); up_read(&dqopt->dqio_sem);
......
...@@ -454,6 +454,12 @@ static int is_leaf(char *buf, int blocksize, struct buffer_head *bh) ...@@ -454,6 +454,12 @@ static int is_leaf(char *buf, int blocksize, struct buffer_head *bh)
"(second one): %h", ih); "(second one): %h", ih);
return 0; return 0;
} }
if (is_direntry_le_ih(ih) && (ih_item_len(ih) < (ih_entry_count(ih) * IH_SIZE))) {
reiserfs_warning(NULL, "reiserfs-5093",
"item entry count seems wrong %h",
ih);
return 0;
}
prev_location = ih_location(ih); prev_location = ih_location(ih);
} }
......
...@@ -448,17 +448,18 @@ struct quota_format_type { ...@@ -448,17 +448,18 @@ struct quota_format_type {
}; };
/** /**
* Quota state flags - they actually come in two flavors - for users and groups. * Quota state flags - they come in three flavors - for users, groups and projects.
* *
* Actual typed flags layout: * Actual typed flags layout:
* USRQUOTA GRPQUOTA * USRQUOTA GRPQUOTA PRJQUOTA
* DQUOT_USAGE_ENABLED 0x0001 0x0002 * DQUOT_USAGE_ENABLED 0x0001 0x0002 0x0004
* DQUOT_LIMITS_ENABLED 0x0004 0x0008 * DQUOT_LIMITS_ENABLED 0x0008 0x0010 0x0020
* DQUOT_SUSPENDED 0x0010 0x0020 * DQUOT_SUSPENDED 0x0040 0x0080 0x0100
* *
* Following bits are used for non-typed flags: * Following bits are used for non-typed flags:
* DQUOT_QUOTA_SYS_FILE 0x0040 * DQUOT_QUOTA_SYS_FILE 0x0200
* DQUOT_NEGATIVE_USAGE 0x0080 * DQUOT_NEGATIVE_USAGE 0x0400
* DQUOT_NOLIST_DIRTY 0x0800
*/ */
enum { enum {
_DQUOT_USAGE_ENABLED = 0, /* Track disk usage for users */ _DQUOT_USAGE_ENABLED = 0, /* Track disk usage for users */
......
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