aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-04-04 04:05:48 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2015-04-11 22:29:48 -0400
commit0fa6b005afdb3152ce85df963302e59b61115f9b (patch)
tree23e3c90b10cbcf3d244615356619138055dd4e82
parent7ec7b94a3339756dfbb88234e3e45a428e8c08fb (diff)
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>
-rw-r--r--fs/9p/vfs_file.c2
-rw-r--r--fs/btrfs/file.c2
-rw-r--r--fs/ceph/file.c2
-rw-r--r--fs/cifs/file.c4
-rw-r--r--fs/ext4/file.c2
-rw-r--r--fs/fuse/file.c6
-rw-r--r--fs/ncpfs/file.c2
-rw-r--r--fs/nfs/direct.c2
-rw-r--r--fs/ntfs/file.c2
-rw-r--r--fs/ocfs2/file.c3
-rw-r--r--fs/udf/file.c2
-rw-r--r--fs/xfs/xfs_file.c2
-rw-r--r--include/linux/fs.h2
-rw-r--r--mm/filemap.c63
14 files changed, 36 insertions, 60 deletions
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index d7fcb775311e..b5b020ace1b3 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -409,7 +409,7 @@ v9fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
409 size_t count = iov_iter_count(from); 409 size_t count = iov_iter_count(from);
410 int err = 0; 410 int err = 0;
411 411
412 retval = generic_write_checks(file, &origin, &count, 0); 412 retval = generic_write_checks(file, &origin, &count);
413 if (retval) 413 if (retval)
414 return retval; 414 return retval;
415 415
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index cdc801c85105..691a84a81e09 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1747,7 +1747,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
1747 mutex_lock(&inode->i_mutex); 1747 mutex_lock(&inode->i_mutex);
1748 1748
1749 current->backing_dev_info = inode_to_bdi(inode); 1749 current->backing_dev_info = inode_to_bdi(inode);
1750 err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode)); 1750 err = generic_write_checks(file, &pos, &count);
1751 if (err) { 1751 if (err) {
1752 mutex_unlock(&inode->i_mutex); 1752 mutex_unlock(&inode->i_mutex);
1753 goto out; 1753 goto out;
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 56237ea5fc22..761841903160 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -953,7 +953,7 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from)
953 /* We can write back this queue in page reclaim */ 953 /* We can write back this queue in page reclaim */
954 current->backing_dev_info = inode_to_bdi(inode); 954 current->backing_dev_info = inode_to_bdi(inode);
955 955
956 err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode)); 956 err = generic_write_checks(file, &pos, &count);
957 if (err) 957 if (err)
958 goto out; 958 goto out;
959 959
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 3c5c9bc5cbaf..4202e74b2db5 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2580,7 +2580,7 @@ ssize_t cifs_user_writev(struct kiocb *iocb, struct iov_iter *from)
2580 */ 2580 */
2581 2581
2582 len = iov_iter_count(from); 2582 len = iov_iter_count(from);
2583 rc = generic_write_checks(file, &iocb->ki_pos, &len, 0); 2583 rc = generic_write_checks(file, &iocb->ki_pos, &len);
2584 if (rc) 2584 if (rc)
2585 return rc; 2585 return rc;
2586 2586
@@ -2684,7 +2684,7 @@ cifs_writev(struct kiocb *iocb, struct iov_iter *from)
2684 mutex_lock(&inode->i_mutex); 2684 mutex_lock(&inode->i_mutex);
2685 2685
2686 count = iov_iter_count(from); 2686 count = iov_iter_count(from);
2687 rc = generic_write_checks(file, &iocb->ki_pos, &count, 0); 2687 rc = generic_write_checks(file, &iocb->ki_pos, &count);
2688 if (rc) 2688 if (rc)
2689 goto out; 2689 goto out;
2690 2690
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index f7cca423dded..1f0afc181b7b 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -171,7 +171,7 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
171 } 171 }
172 } 172 }
173 173
174 ret = generic_write_checks(file, &iocb->ki_pos, &length, 0); 174 ret = generic_write_checks(file, &iocb->ki_pos, &length);
175 if (ret) 175 if (ret)
176 goto out; 176 goto out;
177 177
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 3d355e946991..4c04a8144a75 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1167,7 +1167,7 @@ static ssize_t fuse_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
1167 /* We can write back this queue in page reclaim */ 1167 /* We can write back this queue in page reclaim */
1168 current->backing_dev_info = inode_to_bdi(inode); 1168 current->backing_dev_info = inode_to_bdi(inode);
1169 1169
1170 err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode)); 1170 err = generic_write_checks(file, &pos, &count);
1171 if (err) 1171 if (err)
1172 goto out; 1172 goto out;
1173 1173
@@ -1420,7 +1420,7 @@ static ssize_t fuse_direct_write_iter(struct kiocb *iocb, struct iov_iter *from)
1420 1420
1421 /* Don't allow parallel writes to the same file */ 1421 /* Don't allow parallel writes to the same file */
1422 mutex_lock(&inode->i_mutex); 1422 mutex_lock(&inode->i_mutex);
1423 res = generic_write_checks(file, &iocb->ki_pos, &count, 0); 1423 res = generic_write_checks(file, &iocb->ki_pos, &count);
1424 if (!res) { 1424 if (!res) {
1425 iov_iter_truncate(from, count); 1425 iov_iter_truncate(from, count);
1426 res = fuse_direct_io(&io, from, &iocb->ki_pos, FUSE_DIO_WRITE); 1426 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)
2841 io->done = &wait; 2841 io->done = &wait;
2842 2842
2843 if (iov_iter_rw(iter) == WRITE) { 2843 if (iov_iter_rw(iter) == WRITE) {
2844 ret = generic_write_checks(file, &pos, &count, 0); 2844 ret = generic_write_checks(file, &pos, &count);
2845 if (!ret) { 2845 if (!ret) {
2846 iov_iter_truncate(iter, count); 2846 iov_iter_truncate(iter, count);
2847 ret = fuse_direct_io(io, iter, &pos, FUSE_DIO_WRITE); 2847 ret = fuse_direct_io(io, iter, &pos, FUSE_DIO_WRITE);
diff --git a/fs/ncpfs/file.c b/fs/ncpfs/file.c
index 479bf8db264e..ab6363b16556 100644
--- a/fs/ncpfs/file.c
+++ b/fs/ncpfs/file.c
@@ -177,7 +177,7 @@ ncp_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
177 void *bouncebuffer; 177 void *bouncebuffer;
178 178
179 ncp_dbg(1, "enter %pD2\n", file); 179 ncp_dbg(1, "enter %pD2\n", file);
180 errno = generic_write_checks(file, &pos, &count, 0); 180 errno = generic_write_checks(file, &pos, &count);
181 if (errno) 181 if (errno)
182 return errno; 182 return errno;
183 iov_iter_truncate(from, count); 183 iov_iter_truncate(from, count);
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 06503bc604e1..5ddd77acb3f7 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -977,7 +977,7 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter,
977 dfprintk(FILE, "NFS: direct write(%pD2, %zd@%Ld)\n", 977 dfprintk(FILE, "NFS: direct write(%pD2, %zd@%Ld)\n",
978 file, count, (long long) pos); 978 file, count, (long long) pos);
979 979
980 result = generic_write_checks(file, &pos, &count, 0); 980 result = generic_write_checks(file, &pos, &count);
981 if (result) 981 if (result)
982 goto out; 982 goto out;
983 983
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index 77087d5ad458..cec4ec3c1ede 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -345,7 +345,7 @@ static ssize_t ntfs_prepare_file_for_write(struct kiocb *iocb,
345 "0x%llx, count 0x%zx.", vi->i_ino, 345 "0x%llx, count 0x%zx.", vi->i_ino,
346 (unsigned)le32_to_cpu(ni->type), 346 (unsigned)le32_to_cpu(ni->type),
347 (unsigned long long)iocb->ki_pos, count); 347 (unsigned long long)iocb->ki_pos, count);
348 err = generic_write_checks(file, &iocb->ki_pos, &count, S_ISBLK(vi->i_mode)); 348 err = generic_write_checks(file, &iocb->ki_pos, &count);
349 if (unlikely(err)) 349 if (unlikely(err))
350 goto out; 350 goto out;
351 iov_iter_truncate(from, count); 351 iov_iter_truncate(from, count);
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 0a6ec7e6efd8..1c11314946cb 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -2374,8 +2374,7 @@ relock:
2374 /* communicate with ocfs2_dio_end_io */ 2374 /* communicate with ocfs2_dio_end_io */
2375 ocfs2_iocb_set_rw_locked(iocb, rw_level); 2375 ocfs2_iocb_set_rw_locked(iocb, rw_level);
2376 2376
2377 ret = generic_write_checks(file, ppos, &count, 2377 ret = generic_write_checks(file, ppos, &count);
2378 S_ISBLK(inode->i_mode));
2379 if (ret) 2378 if (ret)
2380 goto out_dio; 2379 goto out_dio;
2381 2380
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 35e81ed99405..6834509a7e5a 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -151,7 +151,7 @@ static ssize_t udf_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
151 } else 151 } else
152 up_write(&iinfo->i_data_sem); 152 up_write(&iinfo->i_data_sem);
153 153
154 retval = generic_write_checks(file, &iocb->ki_pos, &count, 0); 154 retval = generic_write_checks(file, &iocb->ki_pos, &count);
155 if (retval) 155 if (retval)
156 goto out; 156 goto out;
157 157
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 44856c3b9617..43c0e6686c47 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -554,7 +554,7 @@ xfs_file_aio_write_checks(
554 int error = 0; 554 int error = 0;
555 555
556restart: 556restart:
557 error = generic_write_checks(file, pos, count, S_ISBLK(inode->i_mode)); 557 error = generic_write_checks(file, pos, count);
558 if (error) 558 if (error)
559 return error; 559 return error;
560 560
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 72e3759de8c3..492948ea4c9b 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2566,7 +2566,7 @@ extern int sb_min_blocksize(struct super_block *, int);
2566 2566
2567extern int generic_file_mmap(struct file *, struct vm_area_struct *); 2567extern int generic_file_mmap(struct file *, struct vm_area_struct *);
2568extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *); 2568extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *);
2569int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk); 2569int generic_write_checks(struct file *file, loff_t *pos, size_t *count);
2570extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *); 2570extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *);
2571extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *); 2571extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *);
2572extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *); 2572extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *);
diff --git a/mm/filemap.c b/mm/filemap.c
index a794a7f98743..dfc573c6ec25 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2260,7 +2260,7 @@ EXPORT_SYMBOL(read_cache_page_gfp);
2260 * Returns appropriate error code that caller should return or 2260 * Returns appropriate error code that caller should return or
2261 * zero in case that write should be allowed. 2261 * zero in case that write should be allowed.
2262 */ 2262 */
2263inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk) 2263inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count)
2264{ 2264{
2265 struct inode *inode = file->f_mapping->host; 2265 struct inode *inode = file->f_mapping->host;
2266 unsigned long limit = rlimit(RLIMIT_FSIZE); 2266 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
2268 if (unlikely(*pos < 0)) 2268 if (unlikely(*pos < 0))
2269 return -EINVAL; 2269 return -EINVAL;
2270 2270
2271 if (!isblk) { 2271 /* FIXME: this is for backwards compatibility with 2.4 */
2272 /* FIXME: this is for backwards compatibility with 2.4 */ 2272 if (file->f_flags & O_APPEND)
2273 if (file->f_flags & O_APPEND) 2273 *pos = i_size_read(inode);
2274 *pos = i_size_read(inode);
2275 2274
2276 if (limit != RLIM_INFINITY) { 2275 if (limit != RLIM_INFINITY) {
2277 if (*pos >= limit) { 2276 if (*pos >= limit) {
2278 send_sig(SIGXFSZ, current, 0); 2277 send_sig(SIGXFSZ, current, 0);
2279 return -EFBIG; 2278 return -EFBIG;
2280 }
2281 if (*count > limit - (typeof(limit))*pos) {
2282 *count = limit - (typeof(limit))*pos;
2283 }
2284 } 2279 }
2280 if (*count > limit - (typeof(limit))*pos)
2281 *count = limit - (typeof(limit))*pos;
2285 } 2282 }
2286 2283
2287 /* 2284 /*
@@ -2289,12 +2286,10 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
2289 */ 2286 */
2290 if (unlikely(*pos + *count > MAX_NON_LFS && 2287 if (unlikely(*pos + *count > MAX_NON_LFS &&
2291 !(file->f_flags & O_LARGEFILE))) { 2288 !(file->f_flags & O_LARGEFILE))) {
2292 if (*pos >= MAX_NON_LFS) { 2289 if (*pos >= MAX_NON_LFS)
2293 return -EFBIG; 2290 return -EFBIG;
2294 } 2291 if (*count > MAX_NON_LFS - (unsigned long)*pos)
2295 if (*count > MAX_NON_LFS - (unsigned long)*pos) {
2296 *count = MAX_NON_LFS - (unsigned long)*pos; 2292 *count = MAX_NON_LFS - (unsigned long)*pos;
2297 }
2298 } 2293 }
2299 2294
2300 /* 2295 /*
@@ -2304,33 +2299,15 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
2304 * exceeded without writing data we send a signal and return EFBIG. 2299 * exceeded without writing data we send a signal and return EFBIG.
2305 * Linus frestrict idea will clean these up nicely.. 2300 * Linus frestrict idea will clean these up nicely..
2306 */ 2301 */
2307 if (likely(!isblk)) { 2302 if (unlikely(*pos >= inode->i_sb->s_maxbytes)) {
2308 if (unlikely(*pos >= inode->i_sb->s_maxbytes)) { 2303 if (*count || *pos > inode->i_sb->s_maxbytes) {
2309 if (*count || *pos > inode->i_sb->s_maxbytes) { 2304 return -EFBIG;
2310 return -EFBIG;
2311 }
2312 /* zero-length writes at ->s_maxbytes are OK */
2313 }
2314
2315 if (unlikely(*pos + *count > inode->i_sb->s_maxbytes))
2316 *count = inode->i_sb->s_maxbytes - *pos;
2317 } else {
2318#ifdef CONFIG_BLOCK
2319 loff_t isize;
2320 if (bdev_read_only(I_BDEV(inode)))
2321 return -EPERM;
2322 isize = i_size_read(inode);
2323 if (*pos >= isize) {
2324 if (*count || *pos > isize)
2325 return -ENOSPC;
2326 } 2305 }
2327 2306 /* zero-length writes at ->s_maxbytes are OK */
2328 if (*pos + *count > isize)
2329 *count = isize - *pos;
2330#else
2331 return -EPERM;
2332#endif
2333 } 2307 }
2308
2309 if (unlikely(*pos + *count > inode->i_sb->s_maxbytes))
2310 *count = inode->i_sb->s_maxbytes - *pos;
2334 return 0; 2311 return 0;
2335} 2312}
2336EXPORT_SYMBOL(generic_write_checks); 2313EXPORT_SYMBOL(generic_write_checks);
@@ -2644,7 +2621,7 @@ ssize_t generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
2644 size_t count = iov_iter_count(from); 2621 size_t count = iov_iter_count(from);
2645 2622
2646 mutex_lock(&inode->i_mutex); 2623 mutex_lock(&inode->i_mutex);
2647 ret = generic_write_checks(file, &iocb->ki_pos, &count, 0); 2624 ret = generic_write_checks(file, &iocb->ki_pos, &count);
2648 if (!ret && count) { 2625 if (!ret && count) {
2649 iov_iter_truncate(from, count); 2626 iov_iter_truncate(from, count);
2650 ret = __generic_file_write_iter(iocb, from); 2627 ret = __generic_file_write_iter(iocb, from);