target/file: Fix 32-bit highmem breakage for SGL -> iovec mapping
[pandora-kernel.git] / drivers / target / target_core_alua.c
index 1dcbef4..0364ca2 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/export.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
+#include <asm/unaligned.h>
 
 #include <target/target_core_base.h>
 #include <target/target_core_device.h>
@@ -79,7 +80,7 @@ int target_emulate_report_target_port_groups(struct se_task *task)
                return -EINVAL;
        }
 
-       buf = transport_kmap_first_data_page(cmd);
+       buf = transport_kmap_data_sg(cmd);
 
        spin_lock(&su_dev->t10_alua.tg_pt_gps_lock);
        list_for_each_entry(tg_pt_gp, &su_dev->t10_alua.tg_pt_gps_list,
@@ -164,7 +165,7 @@ int target_emulate_report_target_port_groups(struct se_task *task)
        buf[2] = ((rd_len >> 8) & 0xff);
        buf[3] = (rd_len & 0xff);
 
-       transport_kunmap_first_data_page(cmd);
+       transport_kunmap_data_sg(cmd);
 
        task->task_scsi_status = GOOD;
        transport_complete_task(task, 1);
@@ -195,7 +196,7 @@ int target_emulate_set_target_port_groups(struct se_task *task)
                cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
                return -EINVAL;
        }
-       buf = transport_kmap_first_data_page(cmd);
+       buf = transport_kmap_data_sg(cmd);
 
        /*
         * Determine if explict ALUA via SET_TARGET_PORT_GROUPS is allowed
@@ -268,8 +269,7 @@ int target_emulate_set_target_port_groups(struct se_task *task)
                 * changed.
                 */
                if (primary) {
-                       tg_pt_id = ((ptr[2] << 8) & 0xff);
-                       tg_pt_id |= (ptr[3] & 0xff);
+                       tg_pt_id = get_unaligned_be16(ptr + 2);
                        /*
                         * Locate the matching target port group ID from
                         * the global tg_pt_gp list
@@ -313,8 +313,7 @@ int target_emulate_set_target_port_groups(struct se_task *task)
                         * the Target Port in question for the the incoming
                         * SET_TARGET_PORT_GROUPS op.
                         */
-                       rtpi = ((ptr[2] << 8) & 0xff);
-                       rtpi |= (ptr[3] & 0xff);
+                       rtpi = get_unaligned_be16(ptr + 2);
                        /*
                         * Locate the matching relative target port identifer
                         * for the struct se_device storage object.
@@ -352,10 +351,12 @@ int target_emulate_set_target_port_groups(struct se_task *task)
        }
 
 out:
-       transport_kunmap_first_data_page(cmd);
-       task->task_scsi_status = GOOD;
-       transport_complete_task(task, 1);
-       return 0;
+       transport_kunmap_data_sg(cmd);
+       if (!rc) {
+               task->task_scsi_status = GOOD;
+               transport_complete_task(task, 1);
+       }
+       return rc;
 }
 
 static inline int core_alua_state_nonoptimized(