aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2011-09-15 19:06:51 -0400
committerroot <root@serles.lst.de>2011-10-28 08:58:59 -0400
commit4cce0e28b932c11454f75d1c1fae674600c23fbf (patch)
tree3c1a0772eb6e681ebde32c7a9bab2cefb87eaf69 /fs
parent5760495a872d63a182962680a13c2af29235237c (diff)
ext4: replace cut'n'pasted llseek code with generic_file_llseek_size
This gives ext4 the benefits of unlocked llseek. Cc: tytso@mit.edu Signed-off-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext4/file.c47
1 files changed, 1 insertions, 46 deletions
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index e4095e988eba..b9548f477bb8 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -224,53 +224,8 @@ loff_t ext4_llseek(struct file *file, loff_t offset, int origin)
224 maxbytes = EXT4_SB(inode->i_sb)->s_bitmap_maxbytes; 224 maxbytes = EXT4_SB(inode->i_sb)->s_bitmap_maxbytes;
225 else 225 else
226 maxbytes = inode->i_sb->s_maxbytes; 226 maxbytes = inode->i_sb->s_maxbytes;
227 mutex_lock(&inode->i_mutex);
228 switch (origin) {
229 case SEEK_END:
230 offset += inode->i_size;
231 break;
232 case SEEK_CUR:
233 if (offset == 0) {
234 mutex_unlock(&inode->i_mutex);
235 return file->f_pos;
236 }
237 offset += file->f_pos;
238 break;
239 case SEEK_DATA:
240 /*
241 * In the generic case the entire file is data, so as long as
242 * offset isn't at the end of the file then the offset is data.
243 */
244 if (offset >= inode->i_size) {
245 mutex_unlock(&inode->i_mutex);
246 return -ENXIO;
247 }
248 break;
249 case SEEK_HOLE:
250 /*
251 * There is a virtual hole at the end of the file, so as long as
252 * offset isn't i_size or larger, return i_size.
253 */
254 if (offset >= inode->i_size) {
255 mutex_unlock(&inode->i_mutex);
256 return -ENXIO;
257 }
258 offset = inode->i_size;
259 break;
260 }
261
262 if (offset < 0 || offset > maxbytes) {
263 mutex_unlock(&inode->i_mutex);
264 return -EINVAL;
265 }
266
267 if (offset != file->f_pos) {
268 file->f_pos = offset;
269 file->f_version = 0;
270 }
271 mutex_unlock(&inode->i_mutex);
272 227
273 return offset; 228 return generic_file_llseek_size(file, offset, origin, maxbytes);
274} 229}
275 230
276const struct file_operations ext4_file_operations = { 231const struct file_operations ext4_file_operations = {