Merge tag 'for-linus-20180920' of git://git.kernel.dk/linux-block
[sfrench/cifs-2.6.git] / fs / btrfs / volumes.c
index da86706123ffa4d85ce19148be2157edb9d7d3a4..f4405e430da6e003306e1a4d471731e1a13c9230 100644 (file)
@@ -4491,7 +4491,12 @@ again:
 
        /* Now btrfs_update_device() will change the on-disk size. */
        ret = btrfs_update_device(trans, device);
-       btrfs_end_transaction(trans);
+       if (ret < 0) {
+               btrfs_abort_transaction(trans, ret);
+               btrfs_end_transaction(trans);
+       } else {
+               ret = btrfs_commit_transaction(trans);
+       }
 done:
        btrfs_free_path(path);
        if (ret) {