Commit 562c72aa57c36b178eacc3500a0215651eca9429

Authored by Christoph Hellwig
Committed by Al Viro
1 parent 11b80f459a

fs: move inode_dio_wait calls into ->setattr

Let filesystems handle waiting for direct I/O requests themselves instead
of doing it beforehand.  This means filesystem-specific locks to prevent
new dio referenes from appearing can be held.  This is important to allow
generalizing i_dio_count to non-DIO_LOCKING filesystems.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Showing 12 changed files with 24 additions and 3 deletions Side-by-side Diff

... ... @@ -232,9 +232,6 @@
232 232 if (error)
233 233 return error;
234 234  
235   - if (ia_valid & ATTR_SIZE)
236   - inode_dio_wait(inode);
237   -
238 235 if (inode->i_op->setattr)
239 236 error = inode->i_op->setattr(dentry, attr);
240 237 else
... ... @@ -1184,6 +1184,8 @@
1184 1184 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
1185 1185 return -EPERM;
1186 1186  
  1187 + inode_dio_wait(inode);
  1188 +
1187 1189 if (mapping_is_xip(inode->i_mapping))
1188 1190 error = xip_truncate_page(inode->i_mapping, newsize);
1189 1191 else if (test_opt(inode->i_sb, NOBH))
... ... @@ -3216,6 +3216,9 @@
3216 3216 ext3_journal_stop(handle);
3217 3217 }
3218 3218  
  3219 + if (attr->ia_valid & ATTR_SIZE)
  3220 + inode_dio_wait(inode);
  3221 +
3219 3222 if (S_ISREG(inode->i_mode) &&
3220 3223 attr->ia_valid & ATTR_SIZE && attr->ia_size < inode->i_size) {
3221 3224 handle_t *handle;
... ... @@ -5351,6 +5351,8 @@
5351 5351 }
5352 5352  
5353 5353 if (attr->ia_valid & ATTR_SIZE) {
  5354 + inode_dio_wait(inode);
  5355 +
5354 5356 if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) {
5355 5357 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
5356 5358  
... ... @@ -397,6 +397,8 @@
397 397 * sequence.
398 398 */
399 399 if (attr->ia_valid & ATTR_SIZE) {
  400 + inode_dio_wait(inode);
  401 +
400 402 if (attr->ia_size > inode->i_size) {
401 403 error = fat_cont_expand(inode, attr->ia_size);
402 404 if (error || attr->ia_valid == ATTR_SIZE)
... ... @@ -1224,6 +1224,8 @@
1224 1224 if (ret)
1225 1225 return ret;
1226 1226  
  1227 + inode_dio_wait(inode);
  1228 +
1227 1229 oldsize = inode->i_size;
1228 1230 if (newsize >= oldsize)
1229 1231 return do_grow(inode, newsize);
... ... @@ -615,6 +615,8 @@
615 615  
616 616 if ((attr->ia_valid & ATTR_SIZE) &&
617 617 attr->ia_size != i_size_read(inode)) {
  618 + inode_dio_wait(inode);
  619 +
618 620 error = vmtruncate(inode, attr->ia_size);
619 621 if (error)
620 622 return error;
... ... @@ -296,6 +296,8 @@
296 296  
297 297 if ((attr->ia_valid & ATTR_SIZE) &&
298 298 attr->ia_size != i_size_read(inode)) {
  299 + inode_dio_wait(inode);
  300 +
299 301 error = vmtruncate(inode, attr->ia_size);
300 302 if (error)
301 303 return error;
... ... @@ -110,6 +110,8 @@
110 110  
111 111 if ((iattr->ia_valid & ATTR_SIZE) &&
112 112 iattr->ia_size != i_size_read(inode)) {
  113 + inode_dio_wait(inode);
  114 +
113 115 rc = vmtruncate(inode, iattr->ia_size);
114 116 if (rc)
115 117 return rc;
... ... @@ -778,6 +778,8 @@
778 778  
779 779 if ((iattr->ia_valid & ATTR_SIZE) &&
780 780 iattr->ia_size != i_size_read(inode)) {
  781 + inode_dio_wait(inode);
  782 +
781 783 err = vmtruncate(inode, iattr->ia_size);
782 784 if (unlikely(err))
783 785 goto out_err;
... ... @@ -1142,6 +1142,8 @@
1142 1142 if (status)
1143 1143 goto bail_unlock;
1144 1144  
  1145 + inode_dio_wait(inode);
  1146 +
1145 1147 if (i_size_read(inode) > attr->ia_size) {
1146 1148 if (ocfs2_should_order_data(inode)) {
1147 1149 status = ocfs2_begin_ordered_truncate(inode,
... ... @@ -3114,6 +3114,9 @@
3114 3114 error = -EFBIG;
3115 3115 goto out;
3116 3116 }
  3117 +
  3118 + inode_dio_wait(inode);
  3119 +
3117 3120 /* fill in hole pointers in the expanding truncate case. */
3118 3121 if (attr->ia_size > inode->i_size) {
3119 3122 error = generic_cont_expand_simple(inode, attr->ia_size);