diff options
author | Murphy Zhou <jencce.kernel@gmail.com> | 2020-01-02 16:04:26 +0800 |
---|---|---|
committer | Anna Schumaker <Anna.Schumaker@Netapp.com> | 2020-01-15 10:54:31 -0500 |
commit | bd89bc67f64fa23846645ce8b1c3cb51efebab32 (patch) | |
tree | 628058e2e3a2ac38c5260e4b38f8a2238acfe97d /fs/nfs/file.c | |
parent | b8457606d95f219052cbcf07bd54c24c4290cd49 (diff) | |
download | linux-bd89bc67f64fa23846645ce8b1c3cb51efebab32.tar.bz2 |
fs/nfs, swapon: check holes in swapfile
swapon over NFS does not go through generic_swapfile_activate
code path when setting up extents. This makes holes in NFS
swapfiles possible which is not expected for swapon.
Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Diffstat (limited to 'fs/nfs/file.c')
-rw-r--r-- | fs/nfs/file.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 8eb731d9be3e..ccd9bc098806 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -489,7 +489,19 @@ static int nfs_launder_page(struct page *page) static int nfs_swap_activate(struct swap_info_struct *sis, struct file *file, sector_t *span) { + unsigned long blocks; + long long isize; struct rpc_clnt *clnt = NFS_CLIENT(file->f_mapping->host); + struct inode *inode = file->f_mapping->host; + + spin_lock(&inode->i_lock); + blocks = inode->i_blocks; + isize = inode->i_size; + spin_unlock(&inode->i_lock); + if (blocks*512 < isize) { + pr_warn("swap activate: swapfile has holes\n"); + return -EINVAL; + } *span = sis->pages; |