diff options
author | Wolfram Sang <w.sang@pengutronix.de> | 2012-10-08 06:46:32 -0400 |
---|---|---|
committer | Wolfram Sang <w.sang@pengutronix.de> | 2012-10-08 06:46:32 -0400 |
commit | 102084d3d3969646cc89ea159e50898aeafc6649 (patch) | |
tree | e92924469b3fab3ee6fa29e338e0a3a4cb167e82 /fs/gfs2/file.c | |
parent | 6ccbe607132bd823abbad8d32b13af89161707da (diff) | |
parent | 979570e02981d4a8fc20b3cc8fd651856c98ee9d (diff) |
Merge tag 'v3.6-rc7' into i2c-embedded/for-next
Linux 3.6-rc7
Needed to get updates from i2c-embedded/for-current into i2c-embedded/for-next
Diffstat (limited to 'fs/gfs2/file.c')
-rw-r--r-- | fs/gfs2/file.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index d1d791ef38de..382000ffac1f 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c | |||
@@ -323,6 +323,29 @@ static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
323 | } | 323 | } |
324 | 324 | ||
325 | /** | 325 | /** |
326 | * gfs2_size_hint - Give a hint to the size of a write request | ||
327 | * @file: The struct file | ||
328 | * @offset: The file offset of the write | ||
329 | * @size: The length of the write | ||
330 | * | ||
331 | * When we are about to do a write, this function records the total | ||
332 | * write size in order to provide a suitable hint to the lower layers | ||
333 | * about how many blocks will be required. | ||
334 | * | ||
335 | */ | ||
336 | |||
337 | static void gfs2_size_hint(struct file *filep, loff_t offset, size_t size) | ||
338 | { | ||
339 | struct inode *inode = filep->f_dentry->d_inode; | ||
340 | struct gfs2_sbd *sdp = GFS2_SB(inode); | ||
341 | struct gfs2_inode *ip = GFS2_I(inode); | ||
342 | size_t blks = (size + sdp->sd_sb.sb_bsize - 1) >> sdp->sd_sb.sb_bsize_shift; | ||
343 | int hint = min_t(size_t, INT_MAX, blks); | ||
344 | |||
345 | atomic_set(&ip->i_res->rs_sizehint, hint); | ||
346 | } | ||
347 | |||
348 | /** | ||
326 | * gfs2_allocate_page_backing - Use bmap to allocate blocks | 349 | * gfs2_allocate_page_backing - Use bmap to allocate blocks |
327 | * @page: The (locked) page to allocate backing for | 350 | * @page: The (locked) page to allocate backing for |
328 | * | 351 | * |
@@ -382,8 +405,7 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
382 | if (ret) | 405 | if (ret) |
383 | return ret; | 406 | return ret; |
384 | 407 | ||
385 | atomic_set(&ip->i_res->rs_sizehint, | 408 | gfs2_size_hint(vma->vm_file, pos, PAGE_CACHE_SIZE); |
386 | PAGE_CACHE_SIZE >> sdp->sd_sb.sb_bsize_shift); | ||
387 | 409 | ||
388 | gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); | 410 | gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); |
389 | ret = gfs2_glock_nq(&gh); | 411 | ret = gfs2_glock_nq(&gh); |
@@ -663,7 +685,8 @@ static ssize_t gfs2_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
663 | if (ret) | 685 | if (ret) |
664 | return ret; | 686 | return ret; |
665 | 687 | ||
666 | atomic_set(&ip->i_res->rs_sizehint, writesize >> sdp->sd_sb.sb_bsize_shift); | 688 | gfs2_size_hint(file, pos, writesize); |
689 | |||
667 | if (file->f_flags & O_APPEND) { | 690 | if (file->f_flags & O_APPEND) { |
668 | struct gfs2_holder gh; | 691 | struct gfs2_holder gh; |
669 | 692 | ||
@@ -789,7 +812,7 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, | |||
789 | if (unlikely(error)) | 812 | if (unlikely(error)) |
790 | goto out_uninit; | 813 | goto out_uninit; |
791 | 814 | ||
792 | atomic_set(&ip->i_res->rs_sizehint, len >> sdp->sd_sb.sb_bsize_shift); | 815 | gfs2_size_hint(file, offset, len); |
793 | 816 | ||
794 | while (len > 0) { | 817 | while (len > 0) { |
795 | if (len < bytes) | 818 | if (len < bytes) |