summaryrefslogtreecommitdiffstats
path: root/fs/ceph/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ceph/file.c')
-rw-r--r--fs/ceph/file.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 56237ea5fc22..b9b8eb225f66 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -457,7 +457,7 @@ static ssize_t ceph_sync_read(struct kiocb *iocb, struct iov_iter *i,
457 if (ret < 0) 457 if (ret < 0)
458 return ret; 458 return ret;
459 459
460 if (file->f_flags & O_DIRECT) { 460 if (iocb->ki_flags & IOCB_DIRECT) {
461 while (iov_iter_count(i)) { 461 while (iov_iter_count(i)) {
462 size_t start; 462 size_t start;
463 ssize_t n; 463 ssize_t n;
@@ -828,7 +828,7 @@ again:
828 return ret; 828 return ret;
829 829
830 if ((got & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) == 0 || 830 if ((got & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) == 0 ||
831 (iocb->ki_filp->f_flags & O_DIRECT) || 831 (iocb->ki_flags & IOCB_DIRECT) ||
832 (fi->flags & CEPH_F_SYNC)) { 832 (fi->flags & CEPH_F_SYNC)) {
833 833
834 dout("aio_sync_read %p %llx.%llx %llu~%u got cap refs on %s\n", 834 dout("aio_sync_read %p %llx.%llx %llu~%u got cap refs on %s\n",
@@ -941,9 +941,9 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from)
941 struct ceph_inode_info *ci = ceph_inode(inode); 941 struct ceph_inode_info *ci = ceph_inode(inode);
942 struct ceph_osd_client *osdc = 942 struct ceph_osd_client *osdc =
943 &ceph_sb_to_client(inode->i_sb)->client->osdc; 943 &ceph_sb_to_client(inode->i_sb)->client->osdc;
944 ssize_t count = iov_iter_count(from), written = 0; 944 ssize_t count, written = 0;
945 int err, want, got; 945 int err, want, got;
946 loff_t pos = iocb->ki_pos; 946 loff_t pos;
947 947
948 if (ceph_snap(inode) != CEPH_NOSNAP) 948 if (ceph_snap(inode) != CEPH_NOSNAP)
949 return -EROFS; 949 return -EROFS;
@@ -953,14 +953,12 @@ 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(iocb, from);
957 if (err) 957 if (err <= 0)
958 goto out;
959
960 if (count == 0)
961 goto out; 958 goto out;
962 iov_iter_truncate(from, count);
963 959
960 pos = iocb->ki_pos;
961 count = iov_iter_count(from);
964 err = file_remove_suid(file); 962 err = file_remove_suid(file);
965 if (err) 963 if (err)
966 goto out; 964 goto out;
@@ -997,12 +995,12 @@ retry_snap:
997 inode, ceph_vinop(inode), pos, count, ceph_cap_string(got)); 995 inode, ceph_vinop(inode), pos, count, ceph_cap_string(got));
998 996
999 if ((got & (CEPH_CAP_FILE_BUFFER|CEPH_CAP_FILE_LAZYIO)) == 0 || 997 if ((got & (CEPH_CAP_FILE_BUFFER|CEPH_CAP_FILE_LAZYIO)) == 0 ||
1000 (file->f_flags & O_DIRECT) || (fi->flags & CEPH_F_SYNC)) { 998 (iocb->ki_flags & IOCB_DIRECT) || (fi->flags & CEPH_F_SYNC)) {
1001 struct iov_iter data; 999 struct iov_iter data;
1002 mutex_unlock(&inode->i_mutex); 1000 mutex_unlock(&inode->i_mutex);
1003 /* we might need to revert back to that point */ 1001 /* we might need to revert back to that point */
1004 data = *from; 1002 data = *from;
1005 if (file->f_flags & O_DIRECT) 1003 if (iocb->ki_flags & IOCB_DIRECT)
1006 written = ceph_sync_direct_write(iocb, &data, pos); 1004 written = ceph_sync_direct_write(iocb, &data, pos);
1007 else 1005 else
1008 written = ceph_sync_write(iocb, &data, pos); 1006 written = ceph_sync_write(iocb, &data, pos);