diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-04-09 12:55:47 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-04-11 22:30:21 -0400 |
commit | 3309dd04cbcd2cdad168485af5cf3576b5051e49 (patch) | |
tree | 3e01f865306dee01b31f34c9e7e819a5f42a4087 /fs/ext4 | |
parent | 90320251db0fe3d05f2b10686ec936c7d6ecd99a (diff) |
switch generic_write_checks() to iocb and iter
... returning -E... upon error and amount of data left in iter after
(possible) truncation upon success. Note, that normal case gives
a non-zero (positive) return value, so any tests for != 0 _must_ be
updated.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Conflicts:
fs/ext4/file.c
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/file.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 42b1fa33a17a..c10785f10d1d 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c | |||
@@ -97,9 +97,7 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from) | |||
97 | struct blk_plug plug; | 97 | struct blk_plug plug; |
98 | int o_direct = io_is_direct(file); | 98 | int o_direct = io_is_direct(file); |
99 | int overwrite = 0; | 99 | int overwrite = 0; |
100 | size_t length = iov_iter_count(from); | ||
101 | ssize_t ret; | 100 | ssize_t ret; |
102 | loff_t pos; | ||
103 | 101 | ||
104 | /* | 102 | /* |
105 | * Unaligned direct AIO must be serialized; see comment above | 103 | * Unaligned direct AIO must be serialized; see comment above |
@@ -116,16 +114,10 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from) | |||
116 | } | 114 | } |
117 | 115 | ||
118 | mutex_lock(&inode->i_mutex); | 116 | mutex_lock(&inode->i_mutex); |
119 | ret = generic_write_checks(file, &iocb->ki_pos, &length); | 117 | ret = generic_write_checks(iocb, from); |
120 | if (ret) | 118 | if (ret <= 0) |
121 | goto out; | 119 | goto out; |
122 | 120 | ||
123 | if (length == 0) | ||
124 | goto out; | ||
125 | |||
126 | iov_iter_truncate(from, length); | ||
127 | pos = iocb->ki_pos; | ||
128 | |||
129 | /* | 121 | /* |
130 | * If we have encountered a bitmap-format file, the size limit | 122 | * If we have encountered a bitmap-format file, the size limit |
131 | * is smaller than s_maxbytes, which is for extent-mapped files. | 123 | * is smaller than s_maxbytes, which is for extent-mapped files. |
@@ -133,19 +125,19 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from) | |||
133 | if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) { | 125 | if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) { |
134 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); | 126 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); |
135 | 127 | ||
136 | if (pos >= sbi->s_bitmap_maxbytes) { | 128 | if (iocb->ki_pos >= sbi->s_bitmap_maxbytes) { |
137 | ret = -EFBIG; | 129 | ret = -EFBIG; |
138 | goto out; | 130 | goto out; |
139 | } | 131 | } |
140 | iov_iter_truncate(from, sbi->s_bitmap_maxbytes - pos); | 132 | iov_iter_truncate(from, sbi->s_bitmap_maxbytes - iocb->ki_pos); |
141 | } | 133 | } |
142 | 134 | ||
143 | iocb->private = &overwrite; | 135 | iocb->private = &overwrite; |
144 | if (o_direct) { | 136 | if (o_direct) { |
145 | length = iov_iter_count(from); | 137 | size_t length = iov_iter_count(from); |
138 | loff_t pos = iocb->ki_pos; | ||
146 | blk_start_plug(&plug); | 139 | blk_start_plug(&plug); |
147 | 140 | ||
148 | |||
149 | /* check whether we do a DIO overwrite or not */ | 141 | /* check whether we do a DIO overwrite or not */ |
150 | if (ext4_should_dioread_nolock(inode) && !aio_mutex && | 142 | if (ext4_should_dioread_nolock(inode) && !aio_mutex && |
151 | !file->f_mapping->nrpages && pos + length <= i_size_read(inode)) { | 143 | !file->f_mapping->nrpages && pos + length <= i_size_read(inode)) { |