diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-04-04 04:05:48 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-04-11 22:29:48 -0400 |
commit | 0fa6b005afdb3152ce85df963302e59b61115f9b (patch) | |
tree | 23e3c90b10cbcf3d244615356619138055dd4e82 /mm | |
parent | 7ec7b94a3339756dfbb88234e3e45a428e8c08fb (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>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/filemap.c | 63 |
1 files changed, 20 insertions, 43 deletions
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 | */ |
2263 | inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk) | 2263 | inline 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 | } |
2336 | EXPORT_SYMBOL(generic_write_checks); | 2313 | EXPORT_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); |