Merge tag 'xfs-6.8-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
[linux-block.git] / block / blk-map.c
index 8584babf3ea0ca2590f30383b9594231266e9437..71210cdb34426d967b5632667cb7579b11e97a2d 100644 (file)
@@ -205,12 +205,19 @@ static int bio_copy_user_iov(struct request *rq, struct rq_map_data *map_data,
        /*
         * success
         */
-       if ((iov_iter_rw(iter) == WRITE &&
-            (!map_data || !map_data->null_mapped)) ||
-           (map_data && map_data->from_user)) {
+       if (iov_iter_rw(iter) == WRITE &&
+            (!map_data || !map_data->null_mapped)) {
                ret = bio_copy_from_iter(bio, iter);
                if (ret)
                        goto cleanup;
+       } else if (map_data && map_data->from_user) {
+               struct iov_iter iter2 = *iter;
+
+               /* This is the copy-in part of SG_DXFER_TO_FROM_DEV. */
+               iter2.data_source = ITER_SOURCE;
+               ret = bio_copy_from_iter(bio, &iter2);
+               if (ret)
+                       goto cleanup;
        } else {
                if (bmd->is_our_pages)
                        zero_fill_bio(bio);