@@ -853,18 +853,15 @@ static ssize_t gfs2_file_write_iter(stru
inode_lock(inode);
ret = generic_write_checks(iocb, from);
if (ret <= 0)
- goto out;
-
- /* We can write back this queue in page reclaim */
- current->backing_dev_info = inode_to_bdi(inode);
+ goto out_unlock;
ret = file_remove_privs(file);
if (ret)
- goto out2;
+ goto out_unlock;
ret = file_update_time(file);
if (ret)
- goto out2;
+ goto out_unlock;
if (iocb->ki_flags & IOCB_DIRECT) {
struct address_space *mapping = file->f_mapping;
@@ -873,11 +870,13 @@ static ssize_t gfs2_file_write_iter(stru
written = gfs2_file_direct_write(iocb, from);
if (written < 0 || !iov_iter_count(from))
- goto out2;
+ goto out_unlock;
+ current->backing_dev_info = inode_to_bdi(inode);
ret = iomap_file_buffered_write(iocb, from, &gfs2_iomap_ops);
+ current->backing_dev_info = NULL;
if (unlikely(ret < 0))
- goto out2;
+ goto out_unlock;
buffered = ret;
/*
@@ -901,14 +900,14 @@ static ssize_t gfs2_file_write_iter(stru
*/
}
} else {
+ current->backing_dev_info = inode_to_bdi(inode);
ret = iomap_file_buffered_write(iocb, from, &gfs2_iomap_ops);
+ current->backing_dev_info = NULL;
if (likely(ret > 0))
iocb->ki_pos += ret;
}
-out2:
- current->backing_dev_info = NULL;
-out:
+out_unlock:
inode_unlock(inode);
if (likely(ret > 0)) {
/* Handle various SYNC-type writes */