diff options
author | Lukas Czerner <lczerner@redhat.com> | 2014-04-12 10:05:37 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2014-04-12 10:05:37 -0400 |
commit | 0790b31b69374ddadefebb156251b319e5b43345 (patch) | |
tree | ac6daf0dc694e27eaf143cd619459156c4ea477f /fs | |
parent | 23fffa925ea2c9a2bcb1a4453e2c542635aa3545 (diff) |
fs: disallow all fallocate operation on active swapfile
Currently some file system have IS_SWAPFILE check in their fallocate
implementations and some do not. However we should really prevent any
fallocate operation on swapfile so move the check to vfs and remove the
redundant checks from the file systems fallocate implementations.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ceph/file.c | 3 | ||||
-rw-r--r-- | fs/ext4/extents.c | 5 | ||||
-rw-r--r-- | fs/ext4/inode.c | 5 | ||||
-rw-r--r-- | fs/open.c | 7 |
4 files changed, 7 insertions, 13 deletions
diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 09c7afe32e49..596e6cc9f9c4 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c | |||
@@ -1215,9 +1215,6 @@ static long ceph_fallocate(struct file *file, int mode, | |||
1215 | if (!S_ISREG(inode->i_mode)) | 1215 | if (!S_ISREG(inode->i_mode)) |
1216 | return -EOPNOTSUPP; | 1216 | return -EOPNOTSUPP; |
1217 | 1217 | ||
1218 | if (IS_SWAPFILE(inode)) | ||
1219 | return -ETXTBSY; | ||
1220 | |||
1221 | mutex_lock(&inode->i_mutex); | 1218 | mutex_lock(&inode->i_mutex); |
1222 | 1219 | ||
1223 | if (ceph_snap(inode) != CEPH_NOSNAP) { | 1220 | if (ceph_snap(inode) != CEPH_NOSNAP) { |
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index ac5460d0d133..b2d3869b5762 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -5405,11 +5405,6 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len) | |||
5405 | goto out_mutex; | 5405 | goto out_mutex; |
5406 | } | 5406 | } |
5407 | 5407 | ||
5408 | if (IS_SWAPFILE(inode)) { | ||
5409 | ret = -ETXTBSY; | ||
5410 | goto out_mutex; | ||
5411 | } | ||
5412 | |||
5413 | /* Currently just for extent based files */ | 5408 | /* Currently just for extent based files */ |
5414 | if (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) { | 5409 | if (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) { |
5415 | ret = -EOPNOTSUPP; | 5410 | ret = -EOPNOTSUPP; |
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index e2bba76f0d7b..b74cfd2a42ec 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -3542,11 +3542,6 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length) | |||
3542 | 3542 | ||
3543 | mutex_lock(&inode->i_mutex); | 3543 | mutex_lock(&inode->i_mutex); |
3544 | 3544 | ||
3545 | if (IS_SWAPFILE(inode)) { | ||
3546 | ret = -ETXTBSY; | ||
3547 | goto out_mutex; | ||
3548 | } | ||
3549 | |||
3550 | /* No need to punch hole beyond i_size */ | 3545 | /* No need to punch hole beyond i_size */ |
3551 | if (offset >= inode->i_size) | 3546 | if (offset >= inode->i_size) |
3552 | goto out_mutex; | 3547 | goto out_mutex; |
@@ -263,6 +263,13 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len) | |||
263 | return -EPERM; | 263 | return -EPERM; |
264 | 264 | ||
265 | /* | 265 | /* |
266 | * We can not allow to do any fallocate operation on an active | ||
267 | * swapfile | ||
268 | */ | ||
269 | if (IS_SWAPFILE(inode)) | ||
270 | ret = -ETXTBSY; | ||
271 | |||
272 | /* | ||
266 | * Revalidate the write permissions, in case security policy has | 273 | * Revalidate the write permissions, in case security policy has |
267 | * changed since the files were opened. | 274 | * changed since the files were opened. |
268 | */ | 275 | */ |