diff options
| author | Olof Johansson <olof@lixom.net> | 2012-09-21 22:53:48 -0700 | 
|---|---|---|
| committer | Olof Johansson <olof@lixom.net> | 2012-09-21 22:54:15 -0700 | 
| commit | b536661bb0091b19123fa0c22f7087fd886d7b37 (patch) | |
| tree | e83c4ff9bbfe94155cbc7b25fb3b62b814e79ad7 /fs/gfs2/file.c | |
| parent | 20804abdbcfced47b460e5794a685d48225ac754 (diff) | |
| parent | fb997a46626dca2778fa7570bb516d8486f2f837 (diff) | |
| download | olio-linux-3.10-b536661bb0091b19123fa0c22f7087fd886d7b37.tar.xz olio-linux-3.10-b536661bb0091b19123fa0c22f7087fd886d7b37.zip  | |
Merge branch 'v3.7-samsung-fixes-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kgene/linux-samsung into next/fixes-non-critical
A few non-critical fixes/cleanups for samsung platforms.
* 'v3.7-samsung-fixes-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kgene/linux-samsung:
  ARM: SAMSUNG: Add missing variable declaration in s3c64xx_spi1_set_platdata()
  ARM: S3C24XX: removes unnecessary semicolon
  ARM: S3C24xx: delete double assignment
  ARM: EXYNOS: fix address for EXYNOS4 MDMA1
  ARM: EXYNOS: fixed SYSMMU setup definition to mate parameter name
  + sync to 3.6-rc6
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 d1d791ef38d..382000ffac1 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)  }  /** + * gfs2_size_hint - Give a hint to the size of a write request + * @file: The struct file + * @offset: The file offset of the write + * @size: The length of the write + * + * When we are about to do a write, this function records the total + * write size in order to provide a suitable hint to the lower layers + * about how many blocks will be required. + * + */ + +static void gfs2_size_hint(struct file *filep, loff_t offset, size_t size) +{ +	struct inode *inode = filep->f_dentry->d_inode; +	struct gfs2_sbd *sdp = GFS2_SB(inode); +	struct gfs2_inode *ip = GFS2_I(inode); +	size_t blks = (size + sdp->sd_sb.sb_bsize - 1) >> sdp->sd_sb.sb_bsize_shift; +	int hint = min_t(size_t, INT_MAX, blks); + +	atomic_set(&ip->i_res->rs_sizehint, hint); +} + +/**   * gfs2_allocate_page_backing - Use bmap to allocate blocks   * @page: The (locked) page to allocate backing for   * @@ -382,8 +405,7 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)  	if (ret)  		return ret; -	atomic_set(&ip->i_res->rs_sizehint, -		   PAGE_CACHE_SIZE >> sdp->sd_sb.sb_bsize_shift); +	gfs2_size_hint(vma->vm_file, pos, PAGE_CACHE_SIZE);  	gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);  	ret = gfs2_glock_nq(&gh); @@ -663,7 +685,8 @@ static ssize_t gfs2_file_aio_write(struct kiocb *iocb, const struct iovec *iov,  	if (ret)  		return ret; -	atomic_set(&ip->i_res->rs_sizehint, writesize >> sdp->sd_sb.sb_bsize_shift); +	gfs2_size_hint(file, pos, writesize); +  	if (file->f_flags & O_APPEND) {  		struct gfs2_holder gh; @@ -789,7 +812,7 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,  	if (unlikely(error))  		goto out_uninit; -	atomic_set(&ip->i_res->rs_sizehint, len >> sdp->sd_sb.sb_bsize_shift); +	gfs2_size_hint(file, offset, len);  	while (len > 0) {  		if (len < bytes)  |