diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2015-04-16 15:46:50 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-17 09:04:04 -0400 |
commit | faea2c5311e162f5ceda8e0a261a9f9ece6f921d (patch) | |
tree | 20d2aac1037c83c46e62e6d6bca4393a019780f6 /fs | |
parent | 0ce187c4f32d77eae077f249aa10656b5eef5f28 (diff) |
nilfs2: use inode_set_flags() in nilfs_set_inode_flags()
Use inode_set_flags() to atomically set i_flags instead of clearing out
the S_IMMUTABLE, S_APPEND, etc. flags and then setting them from the
FS_IMMUTABLE_FL, FS_APPEND_FL flags to avoid a race where an immutable
file has the immutable flag cleared for a brief window of time.
This is a similar fix to commit 5f16f3225b06 ("ext4: atomically set
inode->i_flags in ext4_set_inode_flags()").
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nilfs2/inode.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c index 8138b1176867..766cb85fe2f1 100644 --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c | |||
@@ -443,19 +443,20 @@ struct inode *nilfs_new_inode(struct inode *dir, umode_t mode) | |||
443 | void nilfs_set_inode_flags(struct inode *inode) | 443 | void nilfs_set_inode_flags(struct inode *inode) |
444 | { | 444 | { |
445 | unsigned int flags = NILFS_I(inode)->i_flags; | 445 | unsigned int flags = NILFS_I(inode)->i_flags; |
446 | unsigned int new_fl = 0; | ||
446 | 447 | ||
447 | inode->i_flags &= ~(S_SYNC | S_APPEND | S_IMMUTABLE | S_NOATIME | | ||
448 | S_DIRSYNC); | ||
449 | if (flags & FS_SYNC_FL) | 448 | if (flags & FS_SYNC_FL) |
450 | inode->i_flags |= S_SYNC; | 449 | new_fl |= S_SYNC; |
451 | if (flags & FS_APPEND_FL) | 450 | if (flags & FS_APPEND_FL) |
452 | inode->i_flags |= S_APPEND; | 451 | new_fl |= S_APPEND; |
453 | if (flags & FS_IMMUTABLE_FL) | 452 | if (flags & FS_IMMUTABLE_FL) |
454 | inode->i_flags |= S_IMMUTABLE; | 453 | new_fl |= S_IMMUTABLE; |
455 | if (flags & FS_NOATIME_FL) | 454 | if (flags & FS_NOATIME_FL) |
456 | inode->i_flags |= S_NOATIME; | 455 | new_fl |= S_NOATIME; |
457 | if (flags & FS_DIRSYNC_FL) | 456 | if (flags & FS_DIRSYNC_FL) |
458 | inode->i_flags |= S_DIRSYNC; | 457 | new_fl |= S_DIRSYNC; |
458 | inode_set_flags(inode, new_fl, S_SYNC | S_APPEND | S_IMMUTABLE | | ||
459 | S_NOATIME | S_DIRSYNC); | ||
459 | } | 460 | } |
460 | 461 | ||
461 | int nilfs_read_inode_common(struct inode *inode, | 462 | int nilfs_read_inode_common(struct inode *inode, |