Late 4.6-rc fixes

- Fix for max sector calculation in iSER
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJXK3h4AAoJELgmozMOVy/doWMQAJ/O1kMh9ojnlLaFRjm889aV
 vNT/NTV0ilmbjvzgmhzYpbPOYf42hCHOZlI1vCCdTK0FafVlUh67m7oUCdW3OSm2
 b9OVtYsvqk/R6rlSqh8anmqwgAIv1OvmdQ26PBhOpkuokDgZArP4jaH06Tacqjws
 2cxZVuX8SA3f97tquOm1Shj0gqdA8dk9O+/6L3KzV2B6KUaBdYdb3ywvBQAVjIde
 qQJ4WiFl6QEBEQ18Seo6//cTiOez4bNYbR5inkgohciFfO8UIVDZDRLIXBQCE2Ca
 0QyoQ0OmAlSlAzXRCjTe+ZxAXjnmR/ZqRPgQAu9M4klMJF9ri+7U8uwerLQcMQQZ
 D1cQWx14P5BKMGKQ6kOh85+cQsn0qxOHNDRmEC7RIFda3rpsnEhtllg5+A94ZGMz
 FFOZ8uHYuOGxU2cbQUv9bjxDe2ukMjvYRdGbTTnWv+Ifi9S4fuIV1yw6erZ2XTRd
 BZWCMmmjvJWCfiZ1k1ZT1HtHW+dEvilcsFWbkZ4aGjFVF9sFvuWbGynWU57E9JWs
 2SC1CNp40OFCneqyPIVVFOu2kGNvQEp9UNy4espDT4hUP9J9trwkZdZLyE8HFufB
 Rj4BXUpzMt0+RLWQC3tGRDQDtgO4b6SJG1QtwTj7Jb/ttuzCYaVQ463KNo1KeS2y
 7Li0afdLKQ2LslVlKJK1
 =sU6v
 -----END PGP SIGNATURE-----

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma

Pull rdma fix from Doug Ledford:
 "Fix for max sector calculation in iSER"

* tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma:
  IB/iser: Fix max_sectors calculation
This commit is contained in:
Linus Torvalds 2016-05-07 08:10:08 -07:00
commit b4184cbff3

View file

@ -612,6 +612,7 @@ iscsi_iser_session_create(struct iscsi_endpoint *ep,
struct Scsi_Host *shost;
struct iser_conn *iser_conn = NULL;
struct ib_conn *ib_conn;
u32 max_fr_sectors;
u16 max_cmds;
shost = iscsi_host_alloc(&iscsi_iser_sht, 0, 0);
@ -632,7 +633,6 @@ iscsi_iser_session_create(struct iscsi_endpoint *ep,
iser_conn = ep->dd_data;
max_cmds = iser_conn->max_cmds;
shost->sg_tablesize = iser_conn->scsi_sg_tablesize;
shost->max_sectors = iser_conn->scsi_max_sectors;
mutex_lock(&iser_conn->state_mutex);
if (iser_conn->state != ISER_CONN_UP) {
@ -657,8 +657,6 @@ iscsi_iser_session_create(struct iscsi_endpoint *ep,
*/
shost->sg_tablesize = min_t(unsigned short, shost->sg_tablesize,
ib_conn->device->ib_device->attrs.max_fast_reg_page_list_len);
shost->max_sectors = min_t(unsigned int,
1024, (shost->sg_tablesize * PAGE_SIZE) >> 9);
if (iscsi_host_add(shost,
ib_conn->device->ib_device->dma_device)) {
@ -672,6 +670,15 @@ iscsi_iser_session_create(struct iscsi_endpoint *ep,
goto free_host;
}
/*
* FRs or FMRs can only map up to a (device) page per entry, but if the
* first entry is misaligned we'll end up using using two entries
* (head and tail) for a single page worth data, so we have to drop
* one segment from the calculation.
*/
max_fr_sectors = ((shost->sg_tablesize - 1) * PAGE_SIZE) >> 9;
shost->max_sectors = min(iser_max_sectors, max_fr_sectors);
if (cmds_max > max_cmds) {
iser_info("cmds_max changed from %u to %u\n",
cmds_max, max_cmds);
@ -989,7 +996,6 @@ static struct scsi_host_template iscsi_iser_sht = {
.queuecommand = iscsi_queuecommand,
.change_queue_depth = scsi_change_queue_depth,
.sg_tablesize = ISCSI_ISER_DEF_SG_TABLESIZE,
.max_sectors = ISER_DEF_MAX_SECTORS,
.cmd_per_lun = ISER_DEF_CMD_PER_LUN,
.eh_abort_handler = iscsi_eh_abort,
.eh_device_reset_handler= iscsi_eh_device_reset,