diff options
author | Anna Schumaker <Anna.Schumaker@netapp.com> | 2014-11-25 13:18:15 -0500 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@primarydata.com> | 2014-11-25 16:38:32 -0500 |
commit | f4ac1674f5da420ef17896f0f222c5215ebcde80 (patch) | |
tree | 5ad22eac7b8ef584ce1b39b618aeb0b242dcccb7 /fs/nfs/nfs4file.c | |
parent | e9f456ca50e579dfacd996f50637f0bb0a585dfc (diff) |
nfs: Add ALLOCATE support
This patch adds support for using the NFS v4.2 operation ALLOCATE to
preallocate data in a file.
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs/nfs4file.c')
-rw-r--r-- | fs/nfs/nfs4file.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index c51fb4db9bfe..f78e9fd0735a 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c | |||
@@ -3,6 +3,8 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 1992 Rick Sladkey | 4 | * Copyright (C) 1992 Rick Sladkey |
5 | */ | 5 | */ |
6 | #include <linux/fs.h> | ||
7 | #include <linux/falloc.h> | ||
6 | #include <linux/nfs_fs.h> | 8 | #include <linux/nfs_fs.h> |
7 | #include "internal.h" | 9 | #include "internal.h" |
8 | #include "fscache.h" | 10 | #include "fscache.h" |
@@ -134,6 +136,29 @@ static loff_t nfs4_file_llseek(struct file *filep, loff_t offset, int whence) | |||
134 | return nfs_file_llseek(filep, offset, whence); | 136 | return nfs_file_llseek(filep, offset, whence); |
135 | } | 137 | } |
136 | } | 138 | } |
139 | |||
140 | static long nfs42_fallocate(struct file *filep, int mode, loff_t offset, loff_t len) | ||
141 | { | ||
142 | struct inode *inode = file_inode(filep); | ||
143 | long ret; | ||
144 | |||
145 | if (!S_ISREG(inode->i_mode)) | ||
146 | return -EOPNOTSUPP; | ||
147 | |||
148 | if (mode != 0) | ||
149 | return -EOPNOTSUPP; | ||
150 | |||
151 | ret = inode_newsize_ok(inode, offset + len); | ||
152 | if (ret < 0) | ||
153 | return ret; | ||
154 | |||
155 | mutex_lock(&inode->i_mutex); | ||
156 | ret = nfs42_proc_allocate(filep, offset, len); | ||
157 | mutex_unlock(&inode->i_mutex); | ||
158 | |||
159 | nfs_zap_caches(inode); | ||
160 | return ret; | ||
161 | } | ||
137 | #endif /* CONFIG_NFS_V4_2 */ | 162 | #endif /* CONFIG_NFS_V4_2 */ |
138 | 163 | ||
139 | const struct file_operations nfs4_file_operations = { | 164 | const struct file_operations nfs4_file_operations = { |
@@ -155,6 +180,9 @@ const struct file_operations nfs4_file_operations = { | |||
155 | .flock = nfs_flock, | 180 | .flock = nfs_flock, |
156 | .splice_read = nfs_file_splice_read, | 181 | .splice_read = nfs_file_splice_read, |
157 | .splice_write = iter_file_splice_write, | 182 | .splice_write = iter_file_splice_write, |
183 | #ifdef CONFIG_NFS_V4_2 | ||
184 | .fallocate = nfs42_fallocate, | ||
185 | #endif /* CONFIG_NFS_V4_2 */ | ||
158 | .check_flags = nfs_check_flags, | 186 | .check_flags = nfs_check_flags, |
159 | .setlease = simple_nosetlease, | 187 | .setlease = simple_nosetlease, |
160 | }; | 188 | }; |