Message ID | 1397242665-2183-4-git-send-email-lczerner@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Fri, Apr 11, 2014 at 08:57:45PM +0200, Lukas Czerner wrote: > Currently some file system have IS_SWAPFILE check in their fallocate > implementations and some does 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> > --- > fs/ceph/file.c | 3 --- > fs/ext4/extents.c | 5 ----- > fs/ext4/inode.c | 5 ----- > fs/open.c | 7 +++++++ > 4 files changed, 7 insertions(+), 13 deletions(-) Thanks, applied. Again, if anyone has an objections with my carrying these patches in the ext4 tree and pushing them to Linus shortly after -rc1, please let me know. - Ted -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Given that the earlier patches were about races - what protects us from swapon racing with the check outside the filesystem locks? -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 66075a4..3a69d80 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -1219,9 +1219,6 @@ static long ceph_fallocate(struct file *file, int mode, if (!S_ISREG(inode->i_mode)) return -EOPNOTSUPP; - if (IS_SWAPFILE(inode)) - return -ETXTBSY; - mutex_lock(&inode->i_mutex); if (ceph_snap(inode) != CEPH_NOSNAP) { diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index ff823b7..517b376 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -5394,11 +5394,6 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len) goto out_mutex; } - if (IS_SWAPFILE(inode)) { - ret = -ETXTBSY; - goto out_mutex; - } - /* Currently just for extent based files */ if (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) { ret = -EOPNOTSUPP; diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 56f1ff4..d8a270d 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3529,11 +3529,6 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length) mutex_lock(&inode->i_mutex); - if (IS_SWAPFILE(inode)) { - ret = -ETXTBSY; - goto out_mutex; - } - /* No need to punch hole beyond i_size */ if (offset >= inode->i_size) goto out_mutex; diff --git a/fs/open.c b/fs/open.c index 14af6be..48e3fd0 100644 --- a/fs/open.c +++ b/fs/open.c @@ -266,6 +266,13 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len) return -EPERM; /* + * We can not allow to do any fallocate operation on an active + * swapfile + */ + if (IS_SWAPFILE(inode)) + ret = -ETXTBSY; + + /* * Revalidate the write permissions, in case security policy has * changed since the files were opened. */
Currently some file system have IS_SWAPFILE check in their fallocate implementations and some does 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> --- fs/ceph/file.c | 3 --- fs/ext4/extents.c | 5 ----- fs/ext4/inode.c | 5 ----- fs/open.c | 7 +++++++ 4 files changed, 7 insertions(+), 13 deletions(-)