Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs

Pull quota & reiserfs changes from Jan Kara:

 - two error checking improvements for quota

 - remove bogus i_version increase for reiserfs

* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
  quota: Check for register_shrinker() failure.
  quota: propagate error from __dquot_initialize
  reiserfs: remove unneeded i_version bump
This commit is contained in:
Linus Torvalds 2017-11-30 18:38:47 -05:00
commit 9c41180be4
2 changed files with 15 additions and 8 deletions

View File

@ -941,12 +941,13 @@ static int dqinit_needed(struct inode *inode, int type)
} }
/* This routine is guarded by s_umount semaphore */ /* This routine is guarded by s_umount semaphore */
static void add_dquot_ref(struct super_block *sb, int type) static int add_dquot_ref(struct super_block *sb, int type)
{ {
struct inode *inode, *old_inode = NULL; struct inode *inode, *old_inode = NULL;
#ifdef CONFIG_QUOTA_DEBUG #ifdef CONFIG_QUOTA_DEBUG
int reserved = 0; int reserved = 0;
#endif #endif
int err = 0;
spin_lock(&sb->s_inode_list_lock); spin_lock(&sb->s_inode_list_lock);
list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
@ -966,7 +967,11 @@ static void add_dquot_ref(struct super_block *sb, int type)
reserved = 1; reserved = 1;
#endif #endif
iput(old_inode); iput(old_inode);
__dquot_initialize(inode, type); err = __dquot_initialize(inode, type);
if (err) {
iput(inode);
goto out;
}
/* /*
* We hold a reference to 'inode' so it couldn't have been * We hold a reference to 'inode' so it couldn't have been
@ -981,7 +986,7 @@ static void add_dquot_ref(struct super_block *sb, int type)
} }
spin_unlock(&sb->s_inode_list_lock); spin_unlock(&sb->s_inode_list_lock);
iput(old_inode); iput(old_inode);
out:
#ifdef CONFIG_QUOTA_DEBUG #ifdef CONFIG_QUOTA_DEBUG
if (reserved) { if (reserved) {
quota_error(sb, "Writes happened before quota was turned on " quota_error(sb, "Writes happened before quota was turned on "
@ -989,6 +994,7 @@ static void add_dquot_ref(struct super_block *sb, int type)
"Please run quotacheck(8)"); "Please run quotacheck(8)");
} }
#endif #endif
return err;
} }
/* /*
@ -2379,10 +2385,11 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
dqopt->flags |= dquot_state_flag(flags, type); dqopt->flags |= dquot_state_flag(flags, type);
spin_unlock(&dq_state_lock); spin_unlock(&dq_state_lock);
add_dquot_ref(sb, type); error = add_dquot_ref(sb, type);
if (error)
return 0; dquot_disable(sb, type, flags);
return error;
out_file_init: out_file_init:
dqopt->files[type] = NULL; dqopt->files[type] = NULL;
iput(inode); iput(inode);
@ -2985,7 +2992,8 @@ static int __init dquot_init(void)
pr_info("VFS: Dquot-cache hash table entries: %ld (order %ld," pr_info("VFS: Dquot-cache hash table entries: %ld (order %ld,"
" %ld bytes)\n", nr_hash, order, (PAGE_SIZE << order)); " %ld bytes)\n", nr_hash, order, (PAGE_SIZE << order));
register_shrinker(&dqcache_shrinker); if (register_shrinker(&dqcache_shrinker))
panic("Cannot register dquot shrinker");
return 0; return 0;
} }

View File

@ -2591,7 +2591,6 @@ out:
return err; return err;
if (inode->i_size < off + len - towrite) if (inode->i_size < off + len - towrite)
i_size_write(inode, off + len - towrite); i_size_write(inode, off + len - towrite);
inode->i_version++;
inode->i_mtime = inode->i_ctime = current_time(inode); inode->i_mtime = inode->i_ctime = current_time(inode);
mark_inode_dirty(inode); mark_inode_dirty(inode);
return len - towrite; return len - towrite;