diff options
Diffstat (limited to 'fs/nfs/nfs4file.c')
-rw-r--r-- | fs/nfs/nfs4file.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index c51fb4db9bfe..8b46389c4c5b 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,32 @@ 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) && (mode != (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE))) | ||
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 | if (mode & FALLOC_FL_PUNCH_HOLE) | ||
157 | ret = nfs42_proc_deallocate(filep, offset, len); | ||
158 | else | ||
159 | ret = nfs42_proc_allocate(filep, offset, len); | ||
160 | mutex_unlock(&inode->i_mutex); | ||
161 | |||
162 | nfs_zap_caches(inode); | ||
163 | return ret; | ||
164 | } | ||
137 | #endif /* CONFIG_NFS_V4_2 */ | 165 | #endif /* CONFIG_NFS_V4_2 */ |
138 | 166 | ||
139 | const struct file_operations nfs4_file_operations = { | 167 | const struct file_operations nfs4_file_operations = { |
@@ -155,6 +183,9 @@ const struct file_operations nfs4_file_operations = { | |||
155 | .flock = nfs_flock, | 183 | .flock = nfs_flock, |
156 | .splice_read = nfs_file_splice_read, | 184 | .splice_read = nfs_file_splice_read, |
157 | .splice_write = iter_file_splice_write, | 185 | .splice_write = iter_file_splice_write, |
186 | #ifdef CONFIG_NFS_V4_2 | ||
187 | .fallocate = nfs42_fallocate, | ||
188 | #endif /* CONFIG_NFS_V4_2 */ | ||
158 | .check_flags = nfs_check_flags, | 189 | .check_flags = nfs_check_flags, |
159 | .setlease = simple_nosetlease, | 190 | .setlease = simple_nosetlease, |
160 | }; | 191 | }; |