瀏覽代碼

generic_write_checks(): drop isblk argument

all remaining callers are passing 0; some just obscure that fact.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Al Viro 10 年之前
父節點
當前提交
0fa6b005af
共有 14 個文件被更改,包括 36 次插入60 次删除
  1. 1 1
      fs/9p/vfs_file.c
  2. 1 1
      fs/btrfs/file.c
  3. 1 1
      fs/ceph/file.c
  4. 2 2
      fs/cifs/file.c
  5. 1 1
      fs/ext4/file.c
  6. 3 3
      fs/fuse/file.c
  7. 1 1
      fs/ncpfs/file.c
  8. 1 1
      fs/nfs/direct.c
  9. 1 1
      fs/ntfs/file.c
  10. 1 2
      fs/ocfs2/file.c
  11. 1 1
      fs/udf/file.c
  12. 1 1
      fs/xfs/xfs_file.c
  13. 1 1
      include/linux/fs.h
  14. 20 43
      mm/filemap.c

+ 1 - 1
fs/9p/vfs_file.c

@@ -409,7 +409,7 @@ v9fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 	size_t count = iov_iter_count(from);
 	size_t count = iov_iter_count(from);
 	int err = 0;
 	int err = 0;
 
 
-	retval = generic_write_checks(file, &origin, &count, 0);
+	retval = generic_write_checks(file, &origin, &count);
 	if (retval)
 	if (retval)
 		return retval;
 		return retval;
 
 

+ 1 - 1
fs/btrfs/file.c

@@ -1747,7 +1747,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
 	mutex_lock(&inode->i_mutex);
 	mutex_lock(&inode->i_mutex);
 
 
 	current->backing_dev_info = inode_to_bdi(inode);
 	current->backing_dev_info = inode_to_bdi(inode);
-	err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode));
+	err = generic_write_checks(file, &pos, &count);
 	if (err) {
 	if (err) {
 		mutex_unlock(&inode->i_mutex);
 		mutex_unlock(&inode->i_mutex);
 		goto out;
 		goto out;

+ 1 - 1
fs/ceph/file.c

@@ -953,7 +953,7 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from)
 	/* We can write back this queue in page reclaim */
 	/* We can write back this queue in page reclaim */
 	current->backing_dev_info = inode_to_bdi(inode);
 	current->backing_dev_info = inode_to_bdi(inode);
 
 
-	err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode));
+	err = generic_write_checks(file, &pos, &count);
 	if (err)
 	if (err)
 		goto out;
 		goto out;
 
 

+ 2 - 2
fs/cifs/file.c

@@ -2580,7 +2580,7 @@ ssize_t cifs_user_writev(struct kiocb *iocb, struct iov_iter *from)
 	 */
 	 */
 
 
 	len = iov_iter_count(from);
 	len = iov_iter_count(from);
-	rc = generic_write_checks(file, &iocb->ki_pos, &len, 0);
+	rc = generic_write_checks(file, &iocb->ki_pos, &len);
 	if (rc)
 	if (rc)
 		return rc;
 		return rc;
 
 
@@ -2684,7 +2684,7 @@ cifs_writev(struct kiocb *iocb, struct iov_iter *from)
 	mutex_lock(&inode->i_mutex);
 	mutex_lock(&inode->i_mutex);
 
 
 	count = iov_iter_count(from);
 	count = iov_iter_count(from);
-	rc = generic_write_checks(file, &iocb->ki_pos, &count, 0);
+	rc = generic_write_checks(file, &iocb->ki_pos, &count);
 	if (rc)
 	if (rc)
 		goto out;
 		goto out;
 
 

+ 1 - 1
fs/ext4/file.c

@@ -171,7 +171,7 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 		}
 		}
 	}
 	}
 
 
-	ret = generic_write_checks(file, &iocb->ki_pos, &length, 0);
+	ret = generic_write_checks(file, &iocb->ki_pos, &length);
 	if (ret)
 	if (ret)
 		goto out;
 		goto out;
 
 

+ 3 - 3
fs/fuse/file.c

@@ -1167,7 +1167,7 @@ static ssize_t fuse_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 	/* We can write back this queue in page reclaim */
 	/* We can write back this queue in page reclaim */
 	current->backing_dev_info = inode_to_bdi(inode);
 	current->backing_dev_info = inode_to_bdi(inode);
 
 
-	err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode));
+	err = generic_write_checks(file, &pos, &count);
 	if (err)
 	if (err)
 		goto out;
 		goto out;
 
 
@@ -1420,7 +1420,7 @@ static ssize_t fuse_direct_write_iter(struct kiocb *iocb, struct iov_iter *from)
 
 
 	/* Don't allow parallel writes to the same file */
 	/* Don't allow parallel writes to the same file */
 	mutex_lock(&inode->i_mutex);
 	mutex_lock(&inode->i_mutex);
-	res = generic_write_checks(file, &iocb->ki_pos, &count, 0);
+	res = generic_write_checks(file, &iocb->ki_pos, &count);
 	if (!res) {
 	if (!res) {
 		iov_iter_truncate(from, count);
 		iov_iter_truncate(from, count);
 		res = fuse_direct_io(&io, from, &iocb->ki_pos, FUSE_DIO_WRITE);
 		res = fuse_direct_io(&io, from, &iocb->ki_pos, FUSE_DIO_WRITE);
@@ -2841,7 +2841,7 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter, loff_t offset)
 		io->done = &wait;
 		io->done = &wait;
 
 
 	if (iov_iter_rw(iter) == WRITE) {
 	if (iov_iter_rw(iter) == WRITE) {
-		ret = generic_write_checks(file, &pos, &count, 0);
+		ret = generic_write_checks(file, &pos, &count);
 		if (!ret) {
 		if (!ret) {
 			iov_iter_truncate(iter, count);
 			iov_iter_truncate(iter, count);
 			ret = fuse_direct_io(io, iter, &pos, FUSE_DIO_WRITE);
 			ret = fuse_direct_io(io, iter, &pos, FUSE_DIO_WRITE);

+ 1 - 1
fs/ncpfs/file.c

@@ -177,7 +177,7 @@ ncp_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 	void *bouncebuffer;
 	void *bouncebuffer;
 
 
 	ncp_dbg(1, "enter %pD2\n", file);
 	ncp_dbg(1, "enter %pD2\n", file);
-	errno = generic_write_checks(file, &pos, &count, 0);
+	errno = generic_write_checks(file, &pos, &count);
 	if (errno)
 	if (errno)
 		return errno;
 		return errno;
 	iov_iter_truncate(from, count);
 	iov_iter_truncate(from, count);

+ 1 - 1
fs/nfs/direct.c

@@ -977,7 +977,7 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter,
 	dfprintk(FILE, "NFS: direct write(%pD2, %zd@%Ld)\n",
 	dfprintk(FILE, "NFS: direct write(%pD2, %zd@%Ld)\n",
 		file, count, (long long) pos);
 		file, count, (long long) pos);
 
 
-	result = generic_write_checks(file, &pos, &count, 0);
+	result = generic_write_checks(file, &pos, &count);
 	if (result)
 	if (result)
 		goto out;
 		goto out;
 
 

+ 1 - 1
fs/ntfs/file.c

@@ -345,7 +345,7 @@ static ssize_t ntfs_prepare_file_for_write(struct kiocb *iocb,
 			"0x%llx, count 0x%zx.", vi->i_ino,
 			"0x%llx, count 0x%zx.", vi->i_ino,
 			(unsigned)le32_to_cpu(ni->type),
 			(unsigned)le32_to_cpu(ni->type),
 			(unsigned long long)iocb->ki_pos, count);
 			(unsigned long long)iocb->ki_pos, count);
-	err = generic_write_checks(file, &iocb->ki_pos, &count, S_ISBLK(vi->i_mode));
+	err = generic_write_checks(file, &iocb->ki_pos, &count);
 	if (unlikely(err))
 	if (unlikely(err))
 		goto out;
 		goto out;
 	iov_iter_truncate(from, count);
 	iov_iter_truncate(from, count);

+ 1 - 2
fs/ocfs2/file.c

@@ -2374,8 +2374,7 @@ relock:
 	/* communicate with ocfs2_dio_end_io */
 	/* communicate with ocfs2_dio_end_io */
 	ocfs2_iocb_set_rw_locked(iocb, rw_level);
 	ocfs2_iocb_set_rw_locked(iocb, rw_level);
 
 
-	ret = generic_write_checks(file, ppos, &count,
-				   S_ISBLK(inode->i_mode));
+	ret = generic_write_checks(file, ppos, &count);
 	if (ret)
 	if (ret)
 		goto out_dio;
 		goto out_dio;
 
 

+ 1 - 1
fs/udf/file.c

@@ -151,7 +151,7 @@ static ssize_t udf_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 	} else
 	} else
 		up_write(&iinfo->i_data_sem);
 		up_write(&iinfo->i_data_sem);
 
 
-	retval = generic_write_checks(file, &iocb->ki_pos, &count, 0);
+	retval = generic_write_checks(file, &iocb->ki_pos, &count);
 	if (retval)
 	if (retval)
 		goto out;
 		goto out;
 
 

+ 1 - 1
fs/xfs/xfs_file.c

@@ -554,7 +554,7 @@ xfs_file_aio_write_checks(
 	int			error = 0;
 	int			error = 0;
 
 
 restart:
 restart:
-	error = generic_write_checks(file, pos, count, S_ISBLK(inode->i_mode));
+	error = generic_write_checks(file, pos, count);
 	if (error)
 	if (error)
 		return error;
 		return error;
 
 

+ 1 - 1
include/linux/fs.h

@@ -2566,7 +2566,7 @@ extern int sb_min_blocksize(struct super_block *, int);
 
 
 extern int generic_file_mmap(struct file *, struct vm_area_struct *);
 extern int generic_file_mmap(struct file *, struct vm_area_struct *);
 extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *);
 extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *);
-int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk);
+int generic_write_checks(struct file *file, loff_t *pos, size_t *count);
 extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *);
 extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *);
 extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *);
 extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *);
 extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *);
 extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *);

+ 20 - 43
mm/filemap.c

@@ -2260,7 +2260,7 @@ EXPORT_SYMBOL(read_cache_page_gfp);
  * Returns appropriate error code that caller should return or
  * Returns appropriate error code that caller should return or
  * zero in case that write should be allowed.
  * zero in case that write should be allowed.
  */
  */
-inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk)
+inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count)
 {
 {
 	struct inode *inode = file->f_mapping->host;
 	struct inode *inode = file->f_mapping->host;
 	unsigned long limit = rlimit(RLIMIT_FSIZE);
 	unsigned long limit = rlimit(RLIMIT_FSIZE);
@@ -2268,20 +2268,17 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
         if (unlikely(*pos < 0))
         if (unlikely(*pos < 0))
                 return -EINVAL;
                 return -EINVAL;
 
 
-	if (!isblk) {
-		/* FIXME: this is for backwards compatibility with 2.4 */
-		if (file->f_flags & O_APPEND)
-                        *pos = i_size_read(inode);
+	/* FIXME: this is for backwards compatibility with 2.4 */
+	if (file->f_flags & O_APPEND)
+		*pos = i_size_read(inode);
 
 
-		if (limit != RLIM_INFINITY) {
-			if (*pos >= limit) {
-				send_sig(SIGXFSZ, current, 0);
-				return -EFBIG;
-			}
-			if (*count > limit - (typeof(limit))*pos) {
-				*count = limit - (typeof(limit))*pos;
-			}
+	if (limit != RLIM_INFINITY) {
+		if (*pos >= limit) {
+			send_sig(SIGXFSZ, current, 0);
+			return -EFBIG;
 		}
 		}
+		if (*count > limit - (typeof(limit))*pos)
+			*count = limit - (typeof(limit))*pos;
 	}
 	}
 
 
 	/*
 	/*
@@ -2289,12 +2286,10 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
 	 */
 	 */
 	if (unlikely(*pos + *count > MAX_NON_LFS &&
 	if (unlikely(*pos + *count > MAX_NON_LFS &&
 				!(file->f_flags & O_LARGEFILE))) {
 				!(file->f_flags & O_LARGEFILE))) {
-		if (*pos >= MAX_NON_LFS) {
+		if (*pos >= MAX_NON_LFS)
 			return -EFBIG;
 			return -EFBIG;
-		}
-		if (*count > MAX_NON_LFS - (unsigned long)*pos) {
+		if (*count > MAX_NON_LFS - (unsigned long)*pos)
 			*count = MAX_NON_LFS - (unsigned long)*pos;
 			*count = MAX_NON_LFS - (unsigned long)*pos;
-		}
 	}
 	}
 
 
 	/*
 	/*
@@ -2304,33 +2299,15 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
 	 * exceeded without writing data we send a signal and return EFBIG.
 	 * exceeded without writing data we send a signal and return EFBIG.
 	 * Linus frestrict idea will clean these up nicely..
 	 * Linus frestrict idea will clean these up nicely..
 	 */
 	 */
-	if (likely(!isblk)) {
-		if (unlikely(*pos >= inode->i_sb->s_maxbytes)) {
-			if (*count || *pos > inode->i_sb->s_maxbytes) {
-				return -EFBIG;
-			}
-			/* zero-length writes at ->s_maxbytes are OK */
-		}
-
-		if (unlikely(*pos + *count > inode->i_sb->s_maxbytes))
-			*count = inode->i_sb->s_maxbytes - *pos;
-	} else {
-#ifdef CONFIG_BLOCK
-		loff_t isize;
-		if (bdev_read_only(I_BDEV(inode)))
-			return -EPERM;
-		isize = i_size_read(inode);
-		if (*pos >= isize) {
-			if (*count || *pos > isize)
-				return -ENOSPC;
+	if (unlikely(*pos >= inode->i_sb->s_maxbytes)) {
+		if (*count || *pos > inode->i_sb->s_maxbytes) {
+			return -EFBIG;
 		}
 		}
-
-		if (*pos + *count > isize)
-			*count = isize - *pos;
-#else
-		return -EPERM;
-#endif
+		/* zero-length writes at ->s_maxbytes are OK */
 	}
 	}
+
+	if (unlikely(*pos + *count > inode->i_sb->s_maxbytes))
+		*count = inode->i_sb->s_maxbytes - *pos;
 	return 0;
 	return 0;
 }
 }
 EXPORT_SYMBOL(generic_write_checks);
 EXPORT_SYMBOL(generic_write_checks);
@@ -2644,7 +2621,7 @@ ssize_t generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 	size_t count = iov_iter_count(from);
 	size_t count = iov_iter_count(from);
 
 
 	mutex_lock(&inode->i_mutex);
 	mutex_lock(&inode->i_mutex);
-	ret = generic_write_checks(file, &iocb->ki_pos, &count, 0);
+	ret = generic_write_checks(file, &iocb->ki_pos, &count);
 	if (!ret && count) {
 	if (!ret && count) {
 		iov_iter_truncate(from, count);
 		iov_iter_truncate(from, count);
 		ret = __generic_file_write_iter(iocb, from);
 		ret = __generic_file_write_iter(iocb, from);