diff options
Diffstat (limited to 'fs/ocfs2/file.c')
-rw-r--r-- | fs/ocfs2/file.c | 33 |
1 files changed, 2 insertions, 31 deletions
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 9395b4fa547d..ac6c96431bbc 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -326,6 +326,7 @@ static int ocfs2_truncate_file(struct inode *inode, | |||
326 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | 326 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
327 | (unsigned long long)new_i_size); | 327 | (unsigned long long)new_i_size); |
328 | 328 | ||
329 | unmap_mapping_range(inode->i_mapping, new_i_size + PAGE_SIZE - 1, 0, 1); | ||
329 | truncate_inode_pages(inode->i_mapping, new_i_size); | 330 | truncate_inode_pages(inode->i_mapping, new_i_size); |
330 | 331 | ||
331 | fe = (struct ocfs2_dinode *) di_bh->b_data; | 332 | fe = (struct ocfs2_dinode *) di_bh->b_data; |
@@ -1418,36 +1419,6 @@ out: | |||
1418 | return total ? total : ret; | 1419 | return total ? total : ret; |
1419 | } | 1420 | } |
1420 | 1421 | ||
1421 | static int ocfs2_check_iovec(const struct iovec *iov, size_t *counted, | ||
1422 | unsigned long *nr_segs) | ||
1423 | { | ||
1424 | size_t ocount; /* original count */ | ||
1425 | unsigned long seg; | ||
1426 | |||
1427 | ocount = 0; | ||
1428 | for (seg = 0; seg < *nr_segs; seg++) { | ||
1429 | const struct iovec *iv = &iov[seg]; | ||
1430 | |||
1431 | /* | ||
1432 | * If any segment has a negative length, or the cumulative | ||
1433 | * length ever wraps negative then return -EINVAL. | ||
1434 | */ | ||
1435 | ocount += iv->iov_len; | ||
1436 | if (unlikely((ssize_t)(ocount|iv->iov_len) < 0)) | ||
1437 | return -EINVAL; | ||
1438 | if (access_ok(VERIFY_READ, iv->iov_base, iv->iov_len)) | ||
1439 | continue; | ||
1440 | if (seg == 0) | ||
1441 | return -EFAULT; | ||
1442 | *nr_segs = seg; | ||
1443 | ocount -= iv->iov_len; /* This segment is no good */ | ||
1444 | break; | ||
1445 | } | ||
1446 | |||
1447 | *counted = ocount; | ||
1448 | return 0; | ||
1449 | } | ||
1450 | |||
1451 | static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | 1422 | static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, |
1452 | const struct iovec *iov, | 1423 | const struct iovec *iov, |
1453 | unsigned long nr_segs, | 1424 | unsigned long nr_segs, |
@@ -1470,7 +1441,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
1470 | if (iocb->ki_left == 0) | 1441 | if (iocb->ki_left == 0) |
1471 | return 0; | 1442 | return 0; |
1472 | 1443 | ||
1473 | ret = ocfs2_check_iovec(iov, &ocount, &nr_segs); | 1444 | ret = generic_segment_checks(iov, &nr_segs, &ocount, VERIFY_READ); |
1474 | if (ret) | 1445 | if (ret) |
1475 | return ret; | 1446 | return ret; |
1476 | 1447 | ||