|
@@ -7623,11 +7623,18 @@ static void adjust_dio_outstanding_extents(struct inode *inode,
|
|
|
* within our reservation, otherwise we need to adjust our inode
|
|
|
* counter appropriately.
|
|
|
*/
|
|
|
- if (dio_data->outstanding_extents) {
|
|
|
+ if (dio_data->outstanding_extents >= num_extents) {
|
|
|
dio_data->outstanding_extents -= num_extents;
|
|
|
} else {
|
|
|
+ /*
|
|
|
+ * If dio write length has been split due to no large enough
|
|
|
+ * contiguous space, we need to compensate our inode counter
|
|
|
+ * appropriately.
|
|
|
+ */
|
|
|
+ u64 num_needed = num_extents - dio_data->outstanding_extents;
|
|
|
+
|
|
|
spin_lock(&BTRFS_I(inode)->lock);
|
|
|
- BTRFS_I(inode)->outstanding_extents += num_extents;
|
|
|
+ BTRFS_I(inode)->outstanding_extents += num_needed;
|
|
|
spin_unlock(&BTRFS_I(inode)->lock);
|
|
|
}
|
|
|
}
|