aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2017-04-11 10:29:12 -0400
committerJan Kara <jack@suse.cz>2017-04-19 08:21:23 -0400
commitaad6cde9adf4879840cc86bc89ed9cdcee615aae (patch)
tree573d5b89ac8731ddeb6c7acf66175dd4d470d943
parent12fd086d3946f753fe0d3db01c2cd037a7d76f4e (diff)
quota: Stop setting IMMUTABLE and NOATIME flags on quota files
Currently we set IMMUTABLE and NOATIME flags on quota files to stop userspace from messing with them. Now that all filesystems set these flags in their quota_on handlers, we can stop setting the flags in generic quota code. This will allow filesystems to stop copying i_flags to their on-disk flags on various occasions. Reviewed-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r--fs/quota/dquot.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 74b489e3714d..7e94cb0ecdde 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -2188,8 +2188,7 @@ int dquot_disable(struct super_block *sb, int type, unsigned int flags)
2188 /* This can happen when suspending quotas on remount-ro... */ 2188 /* This can happen when suspending quotas on remount-ro... */
2189 if (toputinode[cnt] && !sb_has_quota_loaded(sb, cnt)) { 2189 if (toputinode[cnt] && !sb_has_quota_loaded(sb, cnt)) {
2190 inode_lock(toputinode[cnt]); 2190 inode_lock(toputinode[cnt]);
2191 toputinode[cnt]->i_flags &= ~(S_IMMUTABLE | 2191 toputinode[cnt]->i_flags &= ~S_NOQUOTA;
2192 S_NOATIME | S_NOQUOTA);
2193 truncate_inode_pages(&toputinode[cnt]->i_data, 0); 2192 truncate_inode_pages(&toputinode[cnt]->i_data, 0);
2194 inode_unlock(toputinode[cnt]); 2193 inode_unlock(toputinode[cnt]);
2195 mark_inode_dirty_sync(toputinode[cnt]); 2194 mark_inode_dirty_sync(toputinode[cnt]);
@@ -2237,7 +2236,6 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
2237 struct super_block *sb = inode->i_sb; 2236 struct super_block *sb = inode->i_sb;
2238 struct quota_info *dqopt = sb_dqopt(sb); 2237 struct quota_info *dqopt = sb_dqopt(sb);
2239 int error; 2238 int error;
2240 int oldflags = -1;
2241 2239
2242 if (!fmt) 2240 if (!fmt)
2243 return -ESRCH; 2241 return -ESRCH;
@@ -2285,9 +2283,7 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
2285 * possible) Also nobody should write to the file - we use 2283 * possible) Also nobody should write to the file - we use
2286 * special IO operations which ignore the immutable bit. */ 2284 * special IO operations which ignore the immutable bit. */
2287 inode_lock(inode); 2285 inode_lock(inode);
2288 oldflags = inode->i_flags & (S_NOATIME | S_IMMUTABLE | 2286 inode->i_flags |= S_NOQUOTA;
2289 S_NOQUOTA);
2290 inode->i_flags |= S_NOQUOTA | S_NOATIME | S_IMMUTABLE;
2291 inode_unlock(inode); 2287 inode_unlock(inode);
2292 /* 2288 /*
2293 * When S_NOQUOTA is set, remove dquot references as no more 2289 * When S_NOQUOTA is set, remove dquot references as no more
@@ -2329,14 +2325,9 @@ out_file_init:
2329 dqopt->files[type] = NULL; 2325 dqopt->files[type] = NULL;
2330 iput(inode); 2326 iput(inode);
2331out_file_flags: 2327out_file_flags:
2332 if (oldflags != -1) { 2328 inode_lock(inode);
2333 inode_lock(inode); 2329 inode->i_flags &= ~S_NOQUOTA;
2334 /* Set the flags back (in the case of accidental quotaon() 2330 inode_unlock(inode);
2335 * on a wrong file we don't want to mess up the flags) */
2336 inode->i_flags &= ~(S_NOATIME | S_NOQUOTA | S_IMMUTABLE);
2337 inode->i_flags |= oldflags;
2338 inode_unlock(inode);
2339 }
2340out_fmt: 2331out_fmt:
2341 put_quota_format(fmt); 2332 put_quota_format(fmt);
2342 2333