Re: [PATCH] st: trivial: remove form feed characters

2015-11-04 Thread Kai Mäkisara (Kolumbus)

> On 4.11.2015, at 11.52, Maurizio Lombardi  wrote:
> 
> Signed-off-by: Maurizio Lombardi 
> ---
> drivers/scsi/st.c | 24 
> 1 file changed, 8 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
> index b37b9b0..7c4e518 100644
> --- a/drivers/scsi/st.c
> +++ b/drivers/scsi/st.c
> @@ -226,7 +226,6 @@ static DEFINE_SPINLOCK(st_use_lock);
> static DEFINE_IDR(st_index_idr);
> 
> 
> -

What’s the point? Is there an “official” rule that form feeds are not allowed 
(to
put different things to different pages in printout)?

Kai

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 00/27] hpsa updates

2015-11-04 Thread Don Brace
These patches are based on Linus's tree

The changes are:
 - removed unused parameter hostno
 - corrected zeroing out reset_cmds_out during a rescan
 - removed unused function
 - corrected issue with dev_printk
 - add driver requested rescans
 - stop rescans on memory allocation failures and
   skip over unresponsive devices
 - correct 0 byte READ(6)/WRITE(6) transfers
 - correct issues when looking at CISS_REPORT_PHYS data
 - correct mapping of ioaccel2 chain blocks
 - make hpsa_get_device_id more generic
 - add more information to messages
 - simplify device exposure checks
 - simplify hpsa_update_scsi_device
 - add function is_logical_device
 - simplify hpsa_figure_bus_target_lun
 - split out scsi_add_device scsi_remove_device calls
 - correct issues with path_info
 - add in sas transport class for HBA devices
 - add in physical target resets
 - eliminate fake lun0 enclosures
 - add polling for PT RAID devices
 - disable report lu data caching

Changes from initial upload:
 - changed hpsa_scsi_dev_t.devtype to unsigned
 - changed driver initiated rescan messages
 - changed atomic_t to int from ctlr_info.reset_in_progress
 - changed version comment - Tomas Henzl
 - added hpsa-stop-zeroing-reset-cmds-out-during-rescan
 - added hpsa-remove-unused-function
 - added hpsa-fix-multiple-issues-in-path_info_show
   authored by Rasmus Villemoes
 - added hpsa-remove-unused-parameter-hostno

Changes from v1:
 - added hpsa-remove-unused-parameter-hostno
 - updated hpsa-remove-unused-function per Manoj Kumar's review
 - updated hpsa-fix-null-device-issues per Tomas Henzl's and
   Hannes Reinecke's reviews
 - updated hpsa-correct-dev_printk_calls per Hannes's review
 - updated hpsa-abandon-rescan-on-memory-failures per Hannes's review
 - updated hpsa-fix-adjust-hpsa-scsi-table per Hannes's and Tomas's reviews.
 - updated hpsa-simplify-update-scsi-devices per Matthew R. Och's review.
 - updated hpsa-enhance-get_device_id per Hannes's review
 - updated hpsa-bump-version per Tomas's review
 - updated hpsa-add-sas-transport-class to check return code from
   hpsa_add_sas_host

---

Don Brace (15):
  hpsa: remove unused parameter hostno
  hpsa: stop zeroing reset_cmds_out and ioaccel_cmds_out during rescan
  hpsa: remove unused hpsa_tag_discard_error_bits
  hpsa: change devtype to unsigned
  hpsa: check for null arguments to dev_printk
  hpsa: fix null device issues
  hpsa: allow driver requested rescans
  hpsa: abandon rescans on memory alloaction failures.
  hpsa: correct transfer length for 6 byte read/write commands
  hpsa: fix hpsa_adjust_hpsa_scsi_table
  hpsa: correct check for non-disk devices
  hpsa: correct ioaccel2 sg chain len
  hpsa: enhance hpsa_get_device_id
  hpsa: enhance device messages
  hpsa: bump the driver version

Kevin Barnett (6):
  hpsa: simplify check for device exposure
  hpsa: simplify update scsi devices
  hpsa: add function is_logical_device
  hpsa: refactor hpsa_figure_bus_target_lun
  hpsa: move scsi_add_device and scsi_remove_device calls to new function
  hpsa: add in sas transport class

Rasmus Villemoes (1):
  hpsa: fix multiple issues in path_info_show

Scott Teel (5):
  hpsa: fix physical target reset
  hpsa: generalize external arrays
  hpsa: eliminate fake lun0 enclosures
  hpsa: add discovery polling for PT RAID devices.
  hpsa: disable report lun data caching


 drivers/scsi/hpsa.c | 1338 ++-
 drivers/scsi/hpsa.h |   47 +-
 drivers/scsi/hpsa_cmd.h |   30 +
 3 files changed, 1147 insertions(+), 268 deletions(-)

--
Signature
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 01/27] hpsa: remove unused parameter hostno

2015-11-04 Thread Don Brace
This parameter was once used before scan_start was defined
but now it is no longer used.

Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   30 ++
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 40669f8..815dc7f 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -243,7 +243,7 @@ static int hpsa_slave_alloc(struct scsi_device *sdev);
 static int hpsa_slave_configure(struct scsi_device *sdev);
 static void hpsa_slave_destroy(struct scsi_device *sdev);
 
-static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno);
+static void hpsa_update_scsi_devices(struct ctlr_info *h);
 static int check_for_unit_attention(struct ctlr_info *h,
struct CommandList *c);
 static void check_ioctl_unit_attention(struct ctlr_info *h,
@@ -1152,7 +1152,7 @@ static inline void hpsa_show_dev_msg(const char *level, 
struct ctlr_info *h,
 }
 
 /* Add an entry into h->dev[] array. */
-static int hpsa_scsi_add_entry(struct ctlr_info *h, int hostno,
+static int hpsa_scsi_add_entry(struct ctlr_info *h,
struct hpsa_scsi_dev_t *device,
struct hpsa_scsi_dev_t *added[], int *nadded)
 {
@@ -1228,7 +1228,7 @@ lun_assigned:
 }
 
 /* Update an entry in h->dev[] array. */
-static void hpsa_scsi_update_entry(struct ctlr_info *h, int hostno,
+static void hpsa_scsi_update_entry(struct ctlr_info *h,
int entry, struct hpsa_scsi_dev_t *new_entry)
 {
int offload_enabled;
@@ -1276,7 +1276,7 @@ static void hpsa_scsi_update_entry(struct ctlr_info *h, 
int hostno,
 }
 
 /* Replace an entry from h->dev[] array. */
-static void hpsa_scsi_replace_entry(struct ctlr_info *h, int hostno,
+static void hpsa_scsi_replace_entry(struct ctlr_info *h,
int entry, struct hpsa_scsi_dev_t *new_entry,
struct hpsa_scsi_dev_t *added[], int *nadded,
struct hpsa_scsi_dev_t *removed[], int *nremoved)
@@ -1304,7 +1304,7 @@ static void hpsa_scsi_replace_entry(struct ctlr_info *h, 
int hostno,
 }
 
 /* Remove an entry from h->dev[] array. */
-static void hpsa_scsi_remove_entry(struct ctlr_info *h, int hostno, int entry,
+static void hpsa_scsi_remove_entry(struct ctlr_info *h, int entry,
struct hpsa_scsi_dev_t *removed[], int *nremoved)
 {
/* assumes h->devlock is held */
@@ -1638,7 +1638,7 @@ static void hpsa_update_log_drive_phys_drive_ptrs(struct 
ctlr_info *h,
}
 }
 
-static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
+static void adjust_hpsa_scsi_table(struct ctlr_info *h,
struct hpsa_scsi_dev_t *sd[], int nsds)
 {
/* sd contains scsi3 addresses and devtypes, and inquiry
@@ -1678,19 +1678,18 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, 
int hostno,
device_change = hpsa_scsi_find_entry(csd, sd, nsds, );
if (device_change == DEVICE_NOT_FOUND) {
changes++;
-   hpsa_scsi_remove_entry(h, hostno, i,
-   removed, );
+   hpsa_scsi_remove_entry(h, i, removed, );
continue; /* remove ^^^, hence i not incremented */
} else if (device_change == DEVICE_CHANGED) {
changes++;
-   hpsa_scsi_replace_entry(h, hostno, i, sd[entry],
+   hpsa_scsi_replace_entry(h, i, sd[entry],
added, , removed, );
/* Set it to NULL to prevent it from being freed
 * at the bottom of hpsa_update_scsi_devices()
 */
sd[entry] = NULL;
} else if (device_change == DEVICE_UPDATED) {
-   hpsa_scsi_update_entry(h, hostno, i, sd[entry]);
+   hpsa_scsi_update_entry(h, i, sd[entry]);
}
i++;
}
@@ -1718,8 +1717,7 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, 
int hostno,
h->ndevices, );
if (device_change == DEVICE_NOT_FOUND) {
changes++;
-   if (hpsa_scsi_add_entry(h, hostno, sd[i],
-   added, ) != 0)
+   if (hpsa_scsi_add_entry(h, sd[i], added, ) != 0)
break;
sd[i] = NULL; /* prevent from being freed later. */
} else if (device_change == DEVICE_CHANGED) {
@@ -1755,7 +1753,7 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, 
int hostno,
 * (or if there are no changes) scsi_scan_host will do it later the
 * first time through.
 */
-   if (hostno == -1 || !changes)
+   if (!changes)
goto free_and_out;
 
sh = h->scsi_host;
@@ -3702,7 +3700,7 @@ static void hpsa_get_path_info(struct hpsa_scsi_dev_t 
*this_device,
   

[PATCH v2 06/27] hpsa: fix null device issues

2015-11-04 Thread Don Brace
Reviewed-by: Tomas Henzl 
Reviewed-by: Manoj Kumar 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   22 +-
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index b64913f..4468166 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1135,7 +1135,7 @@ static int hpsa_find_target_lun(struct ctlr_info *h,
return !found;
 }
 
-static inline void hpsa_show_dev_msg(const char *level, struct ctlr_info *h,
+static void hpsa_show_dev_msg(const char *level, struct ctlr_info *h,
struct hpsa_scsi_dev_t *dev, char *description)
 {
if (h == NULL || h->pdev == NULL || h->scsi_host == NULL)
@@ -1419,6 +1419,9 @@ static int hpsa_scsi_find_entry(struct hpsa_scsi_dev_t 
*needle,
 #define DEVICE_CHANGED 1
 #define DEVICE_SAME 2
 #define DEVICE_UPDATED 3
+   if (needle == NULL)
+   return DEVICE_NOT_FOUND;
+
for (i = 0; i < haystack_size; i++) {
if (haystack[i] == NULL) /* previously removed. */
continue;
@@ -1581,6 +1584,8 @@ static void hpsa_figure_phys_disk_ptrs(struct ctlr_info 
*h,
if (!logical_drive->offload_config)
continue;
for (j = 0; j < ndevices; j++) {
+   if (dev[j] == NULL)
+   continue;
if (dev[j]->devtype != TYPE_DISK)
continue;
if (is_logical_dev_addr_mode(dev[j]->scsi3addr))
@@ -1624,6 +1629,8 @@ static void hpsa_update_log_drive_phys_drive_ptrs(struct 
ctlr_info *h,
int i;
 
for (i = 0; i < ndevices; i++) {
+   if (dev[i] == NULL)
+   continue;
if (dev[i]->devtype != TYPE_DISK)
continue;
if (!is_logical_dev_addr_mode(dev[i]->scsi3addr))
@@ -1737,8 +1744,11 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h,
/* Now that h->dev[]->phys_disk[] is coherent, we can enable
 * any logical drives that need it enabled.
 */
-   for (i = 0; i < h->ndevices; i++)
+   for (i = 0; i < h->ndevices; i++) {
+   if (h->dev[i] == NULL)
+   continue;
h->dev[i]->offload_enabled = h->dev[i]->offload_to_be_enabled;
+   }
 
spin_unlock_irqrestore(>devlock, flags);
 
@@ -1763,6 +1773,8 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h,
sh = h->scsi_host;
/* Notify scsi mid layer of any removed devices */
for (i = 0; i < nremoved; i++) {
+   if (removed[i] == NULL)
+   continue;
if (removed[i]->expose_state & HPSA_SCSI_ADD) {
struct scsi_device *sdev =
scsi_device_lookup(sh, removed[i]->bus,
@@ -1786,18 +1798,18 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h,
 
/* Notify scsi mid layer of any added devices */
for (i = 0; i < nadded; i++) {
+   if (added[i] == NULL)
+   continue;
if (!(added[i]->expose_state & HPSA_SCSI_ADD))
continue;
if (scsi_add_device(sh, added[i]->bus,
added[i]->target, added[i]->lun) == 0)
continue;
-   hpsa_show_dev_msg(KERN_WARNING, h, added[i],
-   "addition failed, device not added.");
+   dev_warn(>pdev->dev, "addition failed, device not added.");
/* now we have to remove it from h->dev,
 * since it didn't get added to scsi mid layer
 */
fixup_botched_add(h, added[i]);
-   added[i] = NULL;
}
 
 free_and_out:

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 04/27] hpsa: change devtype to unsigned

2015-11-04 Thread Don Brace
This member is used in calls to scsi_device_type.
It should be unsigned since the kernel checks for upper bounds
and it should never be negative.

Suggested-by: Tomas Henzl 
Suggested-by: Hannes Reinecke 
Suggested-by: Matthew R. Ochs 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index 27debb3..d6c4ebf 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -34,7 +34,7 @@ struct access_method {
 };
 
 struct hpsa_scsi_dev_t {
-   int devtype;
+   unsigned int devtype;
int bus, target, lun;   /* as presented to the OS */
unsigned char scsi3addr[8]; /* as presented to the HW */
 #define RAID_CTLR_LUNID "\0\0\0\0\0\0\0\0"

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 30/32] drbd: don't use bi_rw for operations

2015-11-04 Thread mchristi
From: Mike Christie 

This removes drbd's bi_rw use for operations read, write,
discard, write same, etc (REQ_OPs).

Signed-off-by: Mike Christie 
---
 drivers/block/drbd/drbd_actlog.c   |  2 +-
 drivers/block/drbd/drbd_bitmap.c   |  1 -
 drivers/block/drbd/drbd_main.c | 15 ---
 drivers/block/drbd/drbd_receiver.c | 22 --
 drivers/block/drbd/drbd_worker.c   |  4 ++--
 5 files changed, 19 insertions(+), 25 deletions(-)

diff --git a/drivers/block/drbd/drbd_actlog.c b/drivers/block/drbd/drbd_actlog.c
index ed2eafe..fc96a3c 100644
--- a/drivers/block/drbd/drbd_actlog.c
+++ b/drivers/block/drbd/drbd_actlog.c
@@ -159,7 +159,7 @@ static int _drbd_md_sync_page_io(struct drbd_device *device,
goto out;
bio->bi_private = device;
bio->bi_end_io = drbd_md_endio;
-   bio->bi_rw = op | op_flags;
+   bio->bi_rw = op_flags;
bio->bi_op = op;
 
if (op != REQ_OP_WRITE && device->state.disk == D_DISKLESS && 
device->ldev == NULL)
diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c
index 2ff407a..173a3d6 100644
--- a/drivers/block/drbd/drbd_bitmap.c
+++ b/drivers/block/drbd/drbd_bitmap.c
@@ -1022,7 +1022,6 @@ static void bm_page_io_async(struct drbd_bm_aio_ctx *ctx, 
int page_nr) __must_ho
 
if (drbd_insert_fault(device, (rw == REQ_OP_WRITE) ? DRBD_FAULT_MD_WR : 
DRBD_FAULT_MD_RD)) {
bio->bi_op = rw;
-   bio->bi_rw |= rw;
bio_io_error(bio);
} else {
submit_bio(rw, 0, bio);
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 9eb8039..d74178c 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -1602,15 +1602,16 @@ static int _drbd_send_zc_ee(struct drbd_peer_device 
*peer_device,
return 0;
 }
 
-static u32 bio_flags_to_wire(struct drbd_connection *connection, unsigned long 
bi_rw)
+static u32 bio_flags_to_wire(struct drbd_connection *connection,
+struct bio *bio)
 {
if (connection->agreed_pro_version >= 95)
-   return  (bi_rw & REQ_SYNC ? DP_RW_SYNC : 0) |
-   (bi_rw & REQ_FUA ? DP_FUA : 0) |
-   (bi_rw & REQ_FLUSH ? DP_FLUSH : 0) |
-   (bi_rw & REQ_DISCARD ? DP_DISCARD : 0);
+   return  (bio->bi_rw & REQ_SYNC ? DP_RW_SYNC : 0) |
+   (bio->bi_rw & REQ_FUA ? DP_FUA : 0) |
+   (bio->bi_rw & REQ_FLUSH ? DP_FLUSH : 0) |
+   (bio->bi_op == REQ_OP_DISCARD ? DP_DISCARD : 0);
else
-   return bi_rw & REQ_SYNC ? DP_RW_SYNC : 0;
+   return bio->bi_rw & REQ_SYNC ? DP_RW_SYNC : 0;
 }
 
 /* Used to send write or TRIM aka REQ_DISCARD requests
@@ -1635,7 +1636,7 @@ int drbd_send_dblock(struct drbd_peer_device 
*peer_device, struct drbd_request *
p->sector = cpu_to_be64(req->i.sector);
p->block_id = (unsigned long)req;
p->seq_num = cpu_to_be32(atomic_inc_return(>packet_seq));
-   dp_flags = bio_flags_to_wire(peer_device->connection, 
req->master_bio->bi_rw);
+   dp_flags = bio_flags_to_wire(peer_device->connection, req->master_bio);
if (device->state.conn >= C_SYNC_SOURCE &&
device->state.conn <= C_PAUSED_SYNC_T)
dp_flags |= DP_MAY_SET_IN_SYNC;
diff --git a/drivers/block/drbd/drbd_receiver.c 
b/drivers/block/drbd/drbd_receiver.c
index 4e458bd..44193da 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -1418,7 +1418,7 @@ next_bio:
/* > peer_req->i.sector, unless this is the first bio */
bio->bi_iter.bi_sector = sector;
bio->bi_bdev = device->ldev->backing_bdev;
-   bio->bi_rw = op | op_flags;
+   bio->bi_rw = op_flags;
bio->bi_op = op;
bio->bi_private = peer_req;
bio->bi_end_io = drbd_peer_request_endio;
@@ -1427,7 +1427,7 @@ next_bio:
bios = bio;
++n_bios;
 
-   if (op & REQ_OP_DISCARD) {
+   if (op == REQ_OP_DISCARD) {
bio->bi_iter.bi_size = data_size;
goto submit;
}
@@ -2132,8 +2132,7 @@ static unsigned long wire_flags_to_bio_flags(u32 dpf)
 {
return  (dpf & DP_RW_SYNC ? REQ_SYNC : 0) |
(dpf & DP_FUA ? REQ_FUA : 0) |
-   (dpf & DP_FLUSH ? REQ_FLUSH : 0) |
-   (dpf & DP_DISCARD ? REQ_DISCARD : 0);
+   (dpf & DP_FLUSH ? REQ_FLUSH : 0);
 }
 
 static unsigned long wire_flags_to_bio_op(u32 dpf)
@@ -2141,7 +2140,7 @@ static unsigned long wire_flags_to_bio_op(u32 dpf)
if (dpf & DP_DISCARD)
return REQ_OP_DISCARD;
else
-   return 0;
+   return REQ_OP_WRITE;;
 }
 
 static void fail_postponed_requests(struct drbd_device *device, sector_t 
sector,
@@ -2287,7 +2286,7 @@ static int receive_Data(struct 

[PATCH 01/32] block/fs: add REQ_OP definitions.

2015-11-04 Thread mchristi
From: Mike Christie 

This patch adds definitions for request/bio operations which
will be used in the next patches.

In the initial patches the REQ_OPs match the REQ ones for compat reasons
while all the code is converted in this set. In the last patches
that will be removed.

Signed-off-by: Mike Christie 
---
 include/linux/blk_types.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index e813013..d7b6009 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -244,4 +244,11 @@ enum rq_flag_bits {
 #define REQ_MQ_INFLIGHT(1ULL << __REQ_MQ_INFLIGHT)
 #define REQ_NO_TIMEOUT (1ULL << __REQ_NO_TIMEOUT)
 
+enum req_op {
+   REQ_OP_READ,
+   REQ_OP_WRITE= REQ_WRITE,
+   REQ_OP_DISCARD  = REQ_DISCARD,
+   REQ_OP_WRITE_SAME   = REQ_WRITE_SAME,
+};
+
 #endif /* __LINUX_BLK_TYPES_H */
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND RFC PATCH 00/32] separate operations from flags in the bio/request structs

2015-11-04 Thread mchristi
This is just a resend of the patchset from earlier today. There was
a error in the middle of sending the set, so it looks like 10 - 32 got
dropped.

There are a couple new block layer commands we are trying to add support
for in the near term:

compare and write
http://www.spinics.net/lists/target-devel/msg07826.html

copy offload/extended copy/xcopy
https://www.redhat.com/archives/dm-devel/2014-July/msg00070.html

The problem is if we contine to add more commands we will have to one day
extend the cmd_flags/bi_rw fields again. To prevent that, this patchset
separates the operation (REQ_WRITE, REQ_DISCARD, REQ_WRITE_SAME, etc) from
the flags (REQ_SYNC, REQ_QUIET, etc) in the bio and request structs. In the
end of this set, we will have two fields bio->bi_op/request->op and
bio->bi_rw/request->cmd_flags.

The patches were made against Jens's linux-block tree's for-linus branch:
https://git.kernel.org/cgit/linux/kernel/git/axboe/linux-block.git/log/?h=for-linus
(last commit a22c4d7e34402ccdf3414f64c50365436eba7b93).

I have done some basic testing for a lot of the drivers and filesystems,
but I wanted to get comments before trying to track down more hardware/
systems for testing.


Known issues:
- REQ_FLUSH is still a flag, but should probably be a operation.
 For lower level drivers like SCSI where we only get a flush, it makes
more sense to be a operation. However, upper layers like filesystems
can send down flushes with writes, so it is more of a flag for them.
I am still working on this.

- There is a regression with the dm flakey target. It currently
cannot corrupt the operation values.

- The patchset is a little awkward. It touches so much code,
but I wanted to maintain git bisectibility, so there is lots of compat code
left around until the last patches where everyting is cleaned up.



--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 13/27] hpsa: correct ioaccel2 sg chain len

2015-11-04 Thread Don Brace
Reviewed-by: Scott Teel 
Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Reviewed-by: Tomas Henzl 
Reviewed-by: Hannes Reinecke 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 9cf551b..61992c0 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1983,7 +1983,7 @@ static int hpsa_map_ioaccel2_sg_chain_block(struct 
ctlr_info *h,
u32 chain_size;
 
chain_block = h->ioaccel2_cmd_sg_list[c->cmdindex];
-   chain_size = le32_to_cpu(cp->data_len);
+   chain_size = le32_to_cpu(cp->sg[0].length);
temp64 = pci_map_single(h->pdev, chain_block, chain_size,
PCI_DMA_TODEVICE);
if (dma_mapping_error(>pdev->dev, temp64)) {
@@ -2004,7 +2004,7 @@ static void hpsa_unmap_ioaccel2_sg_chain_block(struct 
ctlr_info *h,
 
chain_sg = cp->sg;
temp64 = le64_to_cpu(chain_sg->address);
-   chain_size = le32_to_cpu(cp->data_len);
+   chain_size = le32_to_cpu(cp->sg[0].length);
pci_unmap_single(h->pdev, temp64, chain_size, PCI_DMA_TODEVICE);
 }
 
@@ -4315,6 +4315,7 @@ static int hpsa_scsi_ioaccel2_queue_command(struct 
ctlr_info *h,
/* fill in sg elements */
if (use_sg > h->ioaccel_maxsg) {
cp->sg_count = 1;
+   cp->sg[0].length = cpu_to_le32(use_sg * sizeof(cp->sg[0]));
if (hpsa_map_ioaccel2_sg_chain_block(h, cp, c)) {
atomic_dec(_disk->ioaccel_cmds_out);
scsi_dma_unmap(cmd);

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 12/27] hpsa: correct check for non-disk devices

2015-11-04 Thread Don Brace
The driver is using two MACROs which seemingly are looking in
the wrong location for the device_flags returned from
CISS_REPORT_PHYS. Both MACROs, NON_DISK_PHYS_DEV and
PHYS_IOACCEL, are using the pointer returned from figure_lunaddrbytes
which is the address of the LUN.lunid element in
the extended CISS_REPORT_PHYS.  But the MACROS are using offsets
beyond the range of the element (offset 17 of an 8 byte element).

These MACROs actually are looking at the correct location but
they fail static checker analysis. It also will not work
if any new elements are added to the extended LUN structure.

Change the code to use the structure elements directly
since this MACRO is only used in one location.

Reported-by: Dan Carpenter 
Reviewed-by: Scott Teel 
Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Reviewed-by: Tomas Henzl 
Reviewed-by: Hannes Reinecke 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   28 +++-
 drivers/scsi/hpsa_cmd.h |2 --
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 1607b6d..9cf551b 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3681,19 +3681,18 @@ static u8 *figure_lunaddrbytes(struct ctlr_info *h, int 
raid_ctlr_position,
 /* get physical drive ioaccel handle and queue depth */
 static void hpsa_get_ioaccel_drive_info(struct ctlr_info *h,
struct hpsa_scsi_dev_t *dev,
-   u8 *lunaddrbytes,
+   struct ReportExtendedLUNdata *rlep, int rle_index,
struct bmic_identify_physical_device *id_phys)
 {
int rc;
-   struct ext_report_lun_entry *rle =
-   (struct ext_report_lun_entry *) lunaddrbytes;
+   struct ext_report_lun_entry *rle = >LUN[rle_index];
 
dev->ioaccel_handle = rle->ioaccel_handle;
-   if (PHYS_IOACCEL(lunaddrbytes) && dev->ioaccel_handle)
+   if ((rle->device_flags & 0x08) && dev->ioaccel_handle)
dev->hba_ioaccel_enabled = 1;
memset(id_phys, 0, sizeof(*id_phys));
-   rc = hpsa_bmic_id_physical_device(h, lunaddrbytes,
-   GET_BMIC_DRIVE_NUMBER(lunaddrbytes), id_phys,
+   rc = hpsa_bmic_id_physical_device(h, >lunid[0],
+   GET_BMIC_DRIVE_NUMBER(>lunid[0]), id_phys,
sizeof(*id_phys));
if (!rc)
/* Reserve space for FW operations */
@@ -3707,11 +3706,12 @@ static void hpsa_get_ioaccel_drive_info(struct 
ctlr_info *h,
 }
 
 static void hpsa_get_path_info(struct hpsa_scsi_dev_t *this_device,
-   u8 *lunaddrbytes,
+   struct ReportExtendedLUNdata *rlep, int rle_index,
struct bmic_identify_physical_device *id_phys)
 {
-   if (PHYS_IOACCEL(lunaddrbytes)
-   && this_device->ioaccel_handle)
+   struct ext_report_lun_entry *rle = >LUN[rle_index];
+
+   if ((rle->device_flags & 0x08) && this_device->ioaccel_handle)
this_device->hba_ioaccel_enabled = 1;
 
memcpy(_device->active_path_index,
@@ -3811,6 +3811,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h)
for (i = 0; i < nphysicals + nlogicals + 1; i++) {
u8 *lunaddrbytes, is_OBDR = 0;
int rc = 0;
+   int phys_dev_index = i - (raid_ctlr_position == 0);
 
/* Figure out where the LUN ID info is coming from */
lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position,
@@ -3819,7 +3820,8 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h)
/* skip masked non-disk devices */
if (MASKED_DEVICE(lunaddrbytes))
if (i < nphysicals + (raid_ctlr_position == 0) &&
-   NON_DISK_PHYS_DEV(lunaddrbytes))
+   (physdev_list->
+   LUN[phys_dev_index].device_flags & 0x01))
continue;
 
/* Get device type, vendor, model, device id */
@@ -3884,9 +3886,9 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h)
/* Never use RAID mapper in HBA mode. */
this_device->offload_enabled = 0;
hpsa_get_ioaccel_drive_info(h, this_device,
-   lunaddrbytes, id_phys);
-   hpsa_get_path_info(this_device, lunaddrbytes,
-   id_phys);
+   physdev_list, phys_dev_index, id_phys);
+   hpsa_get_path_info(this_device,
+   physdev_list, phys_dev_index, id_phys);
}
ncurrent++;

[PATCH v2 16/27] hpsa: add function is_logical_device

2015-11-04 Thread Don Brace
From: Kevin Barnett 

simplify checking for logical/physical devices

Reviewed-by: Scott Teel 
Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Reviewed-by: Tomas Henzl 
Reviewed-by: Matthew R. Ochs 
Reviewed-by: Hannes Reinecke 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 62df480..21892c1 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -618,6 +618,11 @@ static const char * const raid_label[] = { "0", "4", 
"1(+0)", "5", "5+1", "6",
 #define HPSA_RAID_ADM  6   /* also used for RAID 1+0 ADM */
 #define RAID_UNKNOWN (ARRAY_SIZE(raid_label) - 1)
 
+static inline bool is_logical_device(struct hpsa_scsi_dev_t *device)
+{
+   return !device->physical_device;
+}
+
 static ssize_t raid_level_show(struct device *dev,
 struct device_attribute *attr, char *buf)
 {
@@ -638,7 +643,7 @@ static ssize_t raid_level_show(struct device *dev,
}
 
/* Is this even a logical drive? */
-   if (!is_logical_dev_addr_mode(hdev->scsi3addr)) {
+   if (!is_logical_device(hdev)) {
spin_unlock_irqrestore(>lock, flags);
l = snprintf(buf, PAGE_SIZE, "N/A\n");
return l;
@@ -772,8 +777,8 @@ static ssize_t path_info_show(struct device *dev,
scsi_device_type(hdev->devtype));
 
if (is_ext_target(h, hdev) ||
-   (hdev->devtype == TYPE_RAID) ||
-   is_logical_dev_addr_mode(hdev->scsi3addr)) {
+   hdev->devtype == TYPE_RAID ||
+   is_logical_device(hdev)) {
output_len += snprintf(path[i] + output_len,
PATH_STRING_LEN, "%s\n",
active);
@@ -1587,7 +1592,7 @@ static void hpsa_figure_phys_disk_ptrs(struct ctlr_info 
*h,
continue;
if (dev[j]->devtype != TYPE_DISK)
continue;
-   if (is_logical_dev_addr_mode(dev[j]->scsi3addr))
+   if (is_logical_device(dev[j]))
continue;
if (dev[j]->ioaccel_handle != dd[i].ioaccel_handle)
continue;
@@ -1632,7 +1637,7 @@ static void hpsa_update_log_drive_phys_drive_ptrs(struct 
ctlr_info *h,
continue;
if (dev[i]->devtype != TYPE_DISK)
continue;
-   if (!is_logical_dev_addr_mode(dev[i]->scsi3addr))
+   if (!is_logical_device(dev[i]))
continue;
 
/*
@@ -2237,7 +2242,7 @@ static void process_ioaccel2_completion(struct ctlr_info 
*h,
 * the normal I/O path so the controller can handle whatever's
 * wrong.
 */
-   if (is_logical_dev_addr_mode(dev->scsi3addr) &&
+   if (is_logical_device(dev) &&
c2->error_data.serv_response ==
IOACCEL2_SERV_RESPONSE_FAILURE) {
if (c2->error_data.status ==
@@ -2357,7 +2362,7 @@ static void complete_scsi_command(struct CommandList *cp)
 * the normal I/O path so the controller can handle whatever's
 * wrong.
 */
-   if (is_logical_dev_addr_mode(dev->scsi3addr)) {
+   if (is_logical_device(dev)) {
if (ei->CommandStatus == CMD_IOACCEL_DISABLED)
dev->offload_enabled = 0;
return hpsa_retry_cmd(h, cp);

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 14/27] hpsa: simplify check for device exposure

2015-11-04 Thread Don Brace
From: Kevin Barnett 

remove macros and cleanup device exposure checking

Reviewed-by: Scott Teel 
Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Reviewed-by: Tomas Henzl 
Reviewed-by: Hannes Reinecke 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   25 +++--
 drivers/scsi/hpsa.h |6 +-
 2 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 61992c0..77c14ae 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -792,8 +792,7 @@ static ssize_t path_info_show(struct device *dev,
PATH_STRING_LEN,
"PORT: %.2s ",
phys_connector);
-   if (hdev->devtype == TYPE_DISK &&
-   hdev->expose_state != HPSA_DO_NOT_EXPOSE) {
+   if (hdev->devtype == TYPE_DISK && hdev->expose_device) {
if (box == 0 || box == 0xFF) {
output_len += snprintf(path[i] + output_len,
PATH_STRING_LEN,
@@ -1152,7 +1151,7 @@ static void hpsa_show_dev_msg(const char *level, struct 
ctlr_info *h,
"RAID-?" : raid_label[dev->raid_level],
dev->offload_config ? '+' : '-',
dev->offload_enabled ? '+' : '-',
-   dev->expose_state);
+   dev->expose_device);
 }
 
 /* Add an entry into h->dev[] array. */
@@ -1225,7 +1224,7 @@ lun_assigned:
added[*nadded] = device;
(*nadded)++;
hpsa_show_dev_msg(KERN_INFO, h, device,
-   device->expose_state & HPSA_SCSI_ADD ? "added" : "masked");
+   device->expose_device ? "added" : "masked");
device->offload_to_be_enabled = device->offload_enabled;
device->offload_enabled = 0;
return 0;
@@ -1788,7 +1787,7 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h,
for (i = 0; i < nremoved; i++) {
if (removed[i] == NULL)
continue;
-   if (removed[i]->expose_state & HPSA_SCSI_ADD) {
+   if (removed[i]->expose_device) {
struct scsi_device *sdev =
scsi_device_lookup(sh, removed[i]->bus,
removed[i]->target, removed[i]->lun);
@@ -1813,7 +1812,7 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h,
for (i = 0; i < nadded; i++) {
if (added[i] == NULL)
continue;
-   if (!(added[i]->expose_state & HPSA_SCSI_ADD))
+   if (!(added[i]->expose_device))
continue;
if (scsi_add_device(sh, added[i]->bus,
added[i]->target, added[i]->lun) == 0)
@@ -1861,7 +1860,7 @@ static int hpsa_slave_alloc(struct scsi_device *sdev)
sdev_id(sdev), sdev->lun);
if (likely(sd)) {
atomic_set(>ioaccel_cmds_out, 0);
-   sdev->hostdata = (sd->expose_state & HPSA_SCSI_ADD) ? sd : NULL;
+   sdev->hostdata = sd->expose_device ? sd : NULL;
} else
sdev->hostdata = NULL;
spin_unlock_irqrestore(>devlock, flags);
@@ -1875,7 +1874,7 @@ static int hpsa_slave_configure(struct scsi_device *sdev)
int queue_depth;
 
sd = sdev->hostdata;
-   sdev->no_uld_attach = !sd || !(sd->expose_state & HPSA_ULD_ATTACH);
+   sdev->no_uld_attach = !sd || !sd->expose_device;
 
if (sd)
queue_depth = sd->queue_depth != 0 ?
@@ -3861,12 +3860,10 @@ static void hpsa_update_scsi_devices(struct ctlr_info 
*h)
 
/* do not expose masked devices */
if (MASKED_DEVICE(lunaddrbytes) &&
-   i < nphysicals + (raid_ctlr_position == 0)) {
-   this_device->expose_state = HPSA_DO_NOT_EXPOSE;
-   } else {
-   this_device->expose_state =
-   HPSA_SG_ATTACH | HPSA_ULD_ATTACH;
-   }
+   i < nphysicals + (raid_ctlr_position == 0))
+   this_device->expose_device = 0;
+   else
+   this_device->expose_device = 1;
 
switch (this_device->devtype) {
case TYPE_ROM:
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index 04f98eb..a6ead07 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -37,6 +37,7 @@ struct hpsa_scsi_dev_t {
unsigned int devtype;
int bus, target, lun;   /* as presented to the OS */
unsigned char scsi3addr[8]; /* as presented to the HW */
+   u8 expose_device;
 #define RAID_CTLR_LUNID 

[PATCH v2 15/27] hpsa: simplify update scsi devices

2015-11-04 Thread Don Brace
From: Kevin Barnett 

remove repeated calculation that checks for physical
or logical devices.

Reviewed-by: Scott Teel 
Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Reviewed-by: Tomas Henzl 
Reviewed-by: Matthew R. Ochs 
Reviewed-by: Hannes Reinecke 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   22 +-
 drivers/scsi/hpsa.h |1 +
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 77c14ae..62df480 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3752,6 +3752,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h)
int ncurrent = 0;
int i, n_ext_target_devs, ndevs_to_allocate;
int raid_ctlr_position;
+   bool physical_device;
DECLARE_BITMAP(lunzerobits, MAX_EXT_TARGETS);
 
currentsd = kzalloc(sizeof(*currentsd) * HPSA_MAX_DEVICES, GFP_KERNEL);
@@ -3812,16 +3813,16 @@ static void hpsa_update_scsi_devices(struct ctlr_info 
*h)
int rc = 0;
int phys_dev_index = i - (raid_ctlr_position == 0);
 
+   physical_device = i < nphysicals + (raid_ctlr_position == 0);
+
/* Figure out where the LUN ID info is coming from */
lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position,
i, nphysicals, nlogicals, physdev_list, logdev_list);
 
/* skip masked non-disk devices */
-   if (MASKED_DEVICE(lunaddrbytes))
-   if (i < nphysicals + (raid_ctlr_position == 0) &&
-   (physdev_list->
-   LUN[phys_dev_index].device_flags & 0x01))
-   continue;
+   if (MASKED_DEVICE(lunaddrbytes) && physical_device &&
+   (physdev_list->LUN[phys_dev_index].device_flags & 0x01))
+   continue;
 
/* Get device type, vendor, model, device id */
rc = hpsa_update_device_info(h, lunaddrbytes, tmpdevice,
@@ -3857,10 +3858,13 @@ static void hpsa_update_scsi_devices(struct ctlr_info 
*h)
}
 
*this_device = *tmpdevice;
+   this_device->physical_device = physical_device;
 
-   /* do not expose masked devices */
-   if (MASKED_DEVICE(lunaddrbytes) &&
-   i < nphysicals + (raid_ctlr_position == 0))
+   /*
+* Expose all devices except for physical devices that
+* are masked.
+*/
+   if (MASKED_DEVICE(lunaddrbytes) && this_device->physical_device)
this_device->expose_device = 0;
else
this_device->expose_device = 1;
@@ -3878,7 +3882,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h)
ncurrent++;
break;
case TYPE_DISK:
-   if (i < nphysicals + (raid_ctlr_position == 0)) {
+   if (this_device->physical_device) {
/* The disk is in HBA mode. */
/* Never use RAID mapper in HBA mode. */
this_device->offload_enabled = 0;
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index a6ead07..50e4780 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -37,6 +37,7 @@ struct hpsa_scsi_dev_t {
unsigned int devtype;
int bus, target, lun;   /* as presented to the OS */
unsigned char scsi3addr[8]; /* as presented to the HW */
+   u8 physical_device : 1;
u8 expose_device;
 #define RAID_CTLR_LUNID "\0\0\0\0\0\0\0\0"
unsigned char device_id[16];/* from inquiry pg. 0x83 */

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 21/27] hpsa: eliminate fake lun0 enclosures

2015-11-04 Thread Don Brace
From: Scott Teel 

We don't need to create fake enclosure devices at Lun0
in external target array configurations anymore.
This was done to support Pre-SCSI rev 5 controllers
that didn't suppoprt report luns commands, so the
SCSI layer had to scan targets. If there was no
LUN at LUN 0, then the target scan would stop, and
move to the next target.  Lun0 enclosure device
was added to prevent sparsely-numbered LUNs from
being missed.

Reviewed-by: Scott Teel 
Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Reviewed-by: Matthew R. Ochs 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   68 ---
 1 file changed, 68 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 1a67d63..c843dd2 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3571,60 +3571,6 @@ static void figure_bus_target_lun(struct ctlr_info *h,
0, lunid & 0x3fff);
 }
 
-/*
- * If there is no lun 0 on a target, linux won't find any devices.
- * For the external targets (arrays), we have to manually detect the enclosure
- * which is at lun zero, as CCISS_REPORT_PHYSICAL_LUNS doesn't report
- * it for some reason.  *tmpdevice is the target we're adding,
- * this_device is a pointer into the current element of currentsd[]
- * that we're building up in update_scsi_devices(), below.
- * lunzerobits is a bitmap that tracks which targets already have a
- * lun 0 assigned.
- * Returns 1 if an enclosure was added, 0 if not.
- */
-static int add_ext_target_dev(struct ctlr_info *h,
-   struct hpsa_scsi_dev_t *tmpdevice,
-   struct hpsa_scsi_dev_t *this_device, u8 *lunaddrbytes,
-   unsigned long lunzerobits[], int *n_ext_target_devs)
-{
-   unsigned char scsi3addr[8];
-
-   if (test_bit(tmpdevice->target, lunzerobits))
-   return 0; /* There is already a lun 0 on this target. */
-
-   if (!is_logical_dev_addr_mode(lunaddrbytes))
-   return 0; /* It's the logical targets that may lack lun 0. */
-
-   if (!tmpdevice->external)
-   return 0; /* Only external target devices have this problem. */
-
-   if (tmpdevice->lun == 0) /* if lun is 0, then we have a lun 0. */
-   return 0;
-
-   memset(scsi3addr, 0, 8);
-   scsi3addr[3] = tmpdevice->target;
-   if (is_hba_lunid(scsi3addr))
-   return 0; /* Don't add the RAID controller here. */
-
-   if (is_scsi_rev_5(h))
-   return 0; /* p1210m doesn't need to do this. */
-
-   if (*n_ext_target_devs >= MAX_EXT_TARGETS) {
-   dev_warn(>pdev->dev, "Maximum number of external "
-   "target devices exceeded.  Check your hardware "
-   "configuration.");
-   return 0;
-   }
-
-   if (hpsa_update_device_info(h, scsi3addr, this_device, NULL))
-   return 0;
-   (*n_ext_target_devs)++;
-   hpsa_set_bus_target_lun(this_device,
-   tmpdevice->bus, tmpdevice->target, 0);
-   hpsa_update_device_supports_aborts(h, this_device, scsi3addr);
-   set_bit(tmpdevice->target, lunzerobits);
-   return 1;
-}
 
 /*
  * Get address of physical disk used for an ioaccel2 mode command:
@@ -3952,20 +3898,6 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h)
hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
this_device = currentsd[ncurrent];
 
-   /*
-* For external target devices, we have to insert a LUN 0 which
-* doesn't show up in CCISS_REPORT_PHYSICAL data, but there
-* is nonetheless an enclosure device there.  We have to
-* present that otherwise linux won't find anything if
-* there is no lun 0.
-*/
-   if (add_ext_target_dev(h, tmpdevice, this_device,
-   lunaddrbytes, lunzerobits,
-   _ext_target_devs)) {
-   ncurrent++;
-   this_device = currentsd[ncurrent];
-   }
-
*this_device = *tmpdevice;
this_device->physical_device = physical_device;
 

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 27/27] hpsa: bump the driver version

2015-11-04 Thread Don Brace
Reviewed-by: Justin Lindley 
Reviewed-by: Scott Teel 
Reviewed-by: Kevin Barnett 
Reviewed-by: Gerry Morong 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Matthew R. Ochs 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 5f02a60..57166e6 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -55,8 +55,11 @@
 #include "hpsa_cmd.h"
 #include "hpsa.h"
 
-/* HPSA_DRIVER_VERSION must be 3 byte values (0-255) separated by '.' */
-#define HPSA_DRIVER_VERSION "3.4.10-0"
+/*
+ * HPSA_DRIVER_VERSION must be 3 byte values (0-255) separated by '.'
+ * with an optional trailing '-' followed by a byte value (0-255).
+ */
+#define HPSA_DRIVER_VERSION "3.4.14-0"
 #define DRIVER_NAME "HP HPSA Driver (v " HPSA_DRIVER_VERSION ")"
 #define HPSA "hpsa"
 

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 26/27] hpsa: add in sas transport class

2015-11-04 Thread Don Brace
From: Kevin Barnett 

Reviewed-by: Scott Teel 
Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
Reviewed-by: Matthew R. Ochs 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |  550 +--
 drivers/scsi/hpsa.h |   27 ++
 drivers/scsi/hpsa_cmd.h |   14 +
 3 files changed, 570 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 910b2d1..5f02a60 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -205,6 +206,16 @@ static struct board_type products[] = {
{0x103C, "Unknown Smart Array", _access},
 };
 
+static struct scsi_transport_template *hpsa_sas_transport_template;
+static int hpsa_add_sas_host(struct ctlr_info *h);
+static void hpsa_delete_sas_host(struct ctlr_info *h);
+static int hpsa_add_sas_device(struct hpsa_sas_node *hpsa_sas_node,
+   struct hpsa_scsi_dev_t *device);
+static void hpsa_remove_sas_device(struct hpsa_scsi_dev_t *device);
+static struct hpsa_scsi_dev_t
+   *hpsa_find_device_by_sas_rphy(struct ctlr_info *h,
+   struct sas_rphy *rphy);
+
 #define SCSI_CMD_BUSY ((struct scsi_cmnd *)_cmd_busy)
 static const struct scsi_cmnd hpsa_cmd_busy;
 #define SCSI_CMD_IDLE ((struct scsi_cmnd *)_cmd_idle)
@@ -276,6 +287,8 @@ static void hpsa_command_resubmit_worker(struct work_struct 
*work);
 static u32 lockup_detected(struct ctlr_info *h);
 static int detect_controller_lockup(struct ctlr_info *h);
 static void hpsa_disable_rld_caching(struct ctlr_info *h);
+static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h,
+   struct ReportExtendedLUNdata *buf, int bufsize);
 static int hpsa_luns_changed(struct ctlr_info *h);
 
 static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
@@ -1692,8 +1705,12 @@ static int hpsa_add_device(struct ctlr_info *h, struct 
hpsa_scsi_dev_t *device)
if (!h->scsi_host)
return 1;
 
-   rc = scsi_add_device(h->scsi_host, device->bus,
+   if (is_logical_device(device)) /* RAID */
+   rc = scsi_add_device(h->scsi_host, device->bus,
device->target, device->lun);
+   else /* HBA */
+   rc = hpsa_add_sas_device(h->sas_host, device);
+
return rc;
 }
 
@@ -1705,21 +1722,23 @@ static void hpsa_remove_device(struct ctlr_info *h,
if (!h->scsi_host)
return;
 
-   sdev = scsi_device_lookup(h->scsi_host, device->bus,
+   if (is_logical_device(device)) { /* RAID */
+   sdev = scsi_device_lookup(h->scsi_host, device->bus,
device->target, device->lun);
-
-   if (sdev) {
-   scsi_remove_device(sdev);
-   scsi_device_put(sdev);
-   } else {
-   /*
-* We don't expect to get here.  Future commands
-* to this device will get a selection timeout as
-* if the device were gone.
-*/
-   hpsa_show_dev_msg(KERN_WARNING, h, device,
+   if (sdev) {
+   scsi_remove_device(sdev);
+   scsi_device_put(sdev);
+   } else {
+   /*
+* We don't expect to get here.  Future commands
+* to this device will get a selection timeout as
+* if the device were gone.
+*/
+   hpsa_show_dev_msg(KERN_WARNING, h, device,
"didn't find device for removal.");
-   }
+   }
+   } else /* HBA */
+   hpsa_remove_sas_device(device);
 }
 
 static void adjust_hpsa_scsi_table(struct ctlr_info *h,
@@ -1912,11 +1931,24 @@ static int hpsa_slave_alloc(struct scsi_device *sdev)
 
h = sdev_to_hba(sdev);
spin_lock_irqsave(>devlock, flags);
-   sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev),
-   sdev_id(sdev), sdev->lun);
-   if (likely(sd)) {
+   if (sdev_channel(sdev) == HPSA_PHYSICAL_DEVICE_BUS) {
+   struct scsi_target *starget;
+   struct sas_rphy *rphy;
+
+   starget = scsi_target(sdev);
+   rphy = target_to_rphy(starget);
+   sd = hpsa_find_device_by_sas_rphy(h, rphy);
+   if (sd) {
+   sd->target = sdev_id(sdev);
+   sd->lun = sdev->lun;
+   }
+   } else
+   sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev),
+   sdev_id(sdev), sdev->lun);
+
+   

[PATCH v2 24/27] hpsa: enhance device messages

2015-11-04 Thread Don Brace
Reviewed-by: Justin Lindley 
Reviewed-by: Scott Teel 
Reviewed-by: Kevin Barnett 
Reviewed-by: Tomas Henzl 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Matthew R. Ochs 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   45 -
 1 file changed, 40 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 91e7005..64638d5 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -608,7 +608,7 @@ static inline int is_logical_dev_addr_mode(unsigned char 
scsi3addr[])
 }
 
 static const char * const raid_label[] = { "0", "4", "1(+0)", "5", "5+1", "6",
-   "1(+0)ADM", "UNKNOWN"
+   "1(+0)ADM", "UNKNOWN", "PHYS DRV"
 };
 #define HPSA_RAID_00
 #define HPSA_RAID_41
@@ -617,7 +617,8 @@ static const char * const raid_label[] = { "0", "4", 
"1(+0)", "5", "5+1", "6",
 #define HPSA_RAID_51   4
 #define HPSA_RAID_65   /* also used for RAID 60 */
 #define HPSA_RAID_ADM  6   /* also used for RAID 1+0 ADM */
-#define RAID_UNKNOWN (ARRAY_SIZE(raid_label) - 1)
+#define RAID_UNKNOWN (ARRAY_SIZE(raid_label) - 2)
+#define PHYSICAL_DRIVE (ARRAY_SIZE(raid_label) - 1)
 
 static inline bool is_logical_device(struct hpsa_scsi_dev_t *device)
 {
@@ -1143,18 +1144,52 @@ static int hpsa_find_target_lun(struct ctlr_info *h,
 static void hpsa_show_dev_msg(const char *level, struct ctlr_info *h,
struct hpsa_scsi_dev_t *dev, char *description)
 {
+#define LABEL_SIZE 25
+   char label[LABEL_SIZE];
+
if (h == NULL || h->pdev == NULL || h->scsi_host == NULL)
return;
 
+   switch (dev->devtype) {
+   case TYPE_RAID:
+   snprintf(label, LABEL_SIZE, "controller");
+   break;
+   case TYPE_ENCLOSURE:
+   snprintf(label, LABEL_SIZE, "enclosure");
+   break;
+   case TYPE_DISK:
+   if (dev->external)
+   snprintf(label, LABEL_SIZE, "external");
+   else if (!is_logical_dev_addr_mode(dev->scsi3addr))
+   snprintf(label, LABEL_SIZE, "%s",
+   raid_label[PHYSICAL_DRIVE]);
+   else
+   snprintf(label, LABEL_SIZE, "RAID-%s",
+   dev->raid_level > RAID_UNKNOWN ? "?" :
+   raid_label[dev->raid_level]);
+   break;
+   case TYPE_ROM:
+   snprintf(label, LABEL_SIZE, "rom");
+   break;
+   case TYPE_TAPE:
+   snprintf(label, LABEL_SIZE, "tape");
+   break;
+   case TYPE_MEDIUM_CHANGER:
+   snprintf(label, LABEL_SIZE, "changer");
+   break;
+   default:
+   snprintf(label, LABEL_SIZE, "UNKNOWN");
+   break;
+   }
+
dev_printk(level, >pdev->dev,
-   "scsi %d:%d:%d:%d: %s %s %.8s %.16s RAID-%s 
SSDSmartPathCap%c En%c Exp=%d\n",
+   "scsi %d:%d:%d:%d: %s %s %.8s %.16s %s 
SSDSmartPathCap%c En%c Exp=%d\n",
h->scsi_host->host_no, dev->bus, dev->target, dev->lun,
description,
scsi_device_type(dev->devtype),
dev->vendor,
dev->model,
-   dev->raid_level > RAID_UNKNOWN ?
-   "RAID-?" : raid_label[dev->raid_level],
+   label,
dev->offload_config ? '+' : '-',
dev->offload_enabled ? '+' : '-',
dev->expose_device);

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 22/27] hpsa: add discovery polling for PT RAID devices.

2015-11-04 Thread Don Brace
From: Scott Teel 

There are problems with getting configuration change notification
in pass-through RAID environments.  So, activate flag
h->discovery_polling when one of these devices is detected in
update_scsi_devices.

After discovery_polling is set, execute a report luns from
rescan_controller_worker (every 30 seconds).

If the data from report_luns is different than last
time (binary compare), execute a full rescan via update_scsi_devices.

Reviewed-by: Scott Teel 
Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Matthew R. Ochs 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   68 +++
 drivers/scsi/hpsa.h |2 ++
 2 files changed, 70 insertions(+)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index c843dd2..acfbbb2 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -275,6 +275,7 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info 
*h,
 static void hpsa_command_resubmit_worker(struct work_struct *work);
 static u32 lockup_detected(struct ctlr_info *h);
 static int detect_controller_lockup(struct ctlr_info *h);
+static int hpsa_luns_changed(struct ctlr_info *h);
 
 static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
 {
@@ -3898,6 +3899,18 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h)
hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
this_device = currentsd[ncurrent];
 
+   /* Turn on discovery_polling if there are ext target devices.
+* Event-based change notification is unreliable for those.
+*/
+   if (!h->discovery_polling) {
+   if (tmpdevice->external) {
+   h->discovery_polling = 1;
+   dev_info(>pdev->dev,
+   "External target, activate discovery 
polling.\n");
+   }
+   }
+
+
*this_device = *tmpdevice;
this_device->physical_device = physical_device;
 
@@ -8016,6 +8029,41 @@ static int hpsa_offline_devices_ready(struct ctlr_info 
*h)
return 0;
 }
 
+static int hpsa_luns_changed(struct ctlr_info *h)
+{
+   int rc = 1; /* assume there are changes */
+   struct ReportLUNdata *logdev = NULL;
+
+   /* if we can't find out if lun data has changed,
+* assume that it has.
+*/
+
+   if (!h->lastlogicals)
+   goto out;
+
+   logdev = kzalloc(sizeof(*logdev), GFP_KERNEL);
+   if (!logdev) {
+   dev_warn(>pdev->dev,
+   "Out of memory, can't track lun changes.\n");
+   goto out;
+   }
+   if (hpsa_scsi_do_report_luns(h, 1, logdev, sizeof(*logdev), 0)) {
+   dev_warn(>pdev->dev,
+   "report luns failed, can't track lun changes.\n");
+   goto out;
+   }
+   if (memcmp(logdev, h->lastlogicals, sizeof(*logdev))) {
+   dev_info(>pdev->dev,
+   "Lun changes detected.\n");
+   memcpy(h->lastlogicals, logdev, sizeof(*logdev));
+   goto out;
+   } else
+   rc = 0; /* no changes detected. */
+out:
+   kfree(logdev);
+   return rc;
+}
+
 static void hpsa_rescan_ctlr_worker(struct work_struct *work)
 {
unsigned long flags;
@@ -8031,6 +8079,18 @@ static void hpsa_rescan_ctlr_worker(struct work_struct 
*work)
hpsa_ack_ctlr_events(h);
hpsa_scan_start(h->scsi_host);
scsi_host_put(h->scsi_host);
+   } else if (h->discovery_polling) {
+   if (hpsa_luns_changed(h)) {
+   struct Scsi_Host *sh = NULL;
+
+   dev_info(>pdev->dev,
+   "driver discovery polling rescan.\n");
+   sh = scsi_host_get(h->scsi_host);
+   if (sh != NULL) {
+   hpsa_scan_start(sh);
+   scsi_host_put(sh);
+   }
+   }
}
spin_lock_irqsave(>lock, flags);
if (!h->remove_in_progress)
@@ -8271,6 +8331,8 @@ reinit_after_soft_reset:
 
/* Enable Accelerated IO path at driver layer */
h->acciopath_status = 1;
+   /* Disable discovery polling.*/
+   h->discovery_polling = 0;
 
 
/* Turn the interrupts on so we can service requests */
@@ -8278,6 +8340,11 @@ reinit_after_soft_reset:
 
hpsa_hba_inquiry(h);
 
+   h->lastlogicals = kzalloc(sizeof(*(h->lastlogicals)), GFP_KERNEL);
+   if (!h->lastlogicals)
+   dev_info(>pdev->dev,
+   "Can't track change to report lun data\n");

[PATCH v2 25/27] hpsa: fix multiple issues in path_info_show

2015-11-04 Thread Don Brace
From: Rasmus Villemoes 

path_info_show() seems to be broken in multiple ways.

First, there's

  817 return snprintf(buf, output_len+1, "%s%s%s%s%s%s%s%s",
  818   path[0], path[1], path[2], path[3],
  819   path[4], path[5], path[6], path[7]);

so hopefully output_len contains the combined length of the eight
strings. Otherwise, snprintf will stop copying to the output
buffer, but still end up reporting that combined length - which
in turn would result in user-space getting a bunch of useless nul
bytes (thankfully the upper sysfs layer seems to clear the output
buffer before passing it to the various ->show routines). But we have

  767  output_len = snprintf(path[i],
  768   PATH_STRING_LEN, "[%d:%d:%d:%d] %20.20s ",
  769   h->scsi_host->host_no,
  770   hdev->bus, hdev->target, hdev->lun,
  771   scsi_device_type(hdev->devtype));

so output_len at best contains the length of the last string printed.

Inside the loop, we then otherwise add to output_len. By magic,
we still have PATH_STRING_LEN available every time... This
wouldn't really be a problem if the bean-counting has been done
properly and each line actually does fit in 50 bytes, and maybe
it does, but I don't immediately see why. Suppose we end up
taking this branch:

  802  output_len += snprintf(path[i] + output_len,
  803  PATH_STRING_LEN,
  804  "BOX: %hhu BAY: %hhu %s\n",
  805  box, bay, active);

An optimistic estimate says this uses strlen("BOX: 1 BAY: 2
Active\n") which is 21. Now add the 20 bytes guaranteed by the
%20.20s and then some for the rest of that format string, and
we're easily over 50 bytes. I don't think we can get over 100
bytes even being pessimistic, so this just means we'll scribble
into the next path[i+1] and maybe get that overwritten later,
leading to some garbled output (in fact, since we'd overwrite the
previous string's 0-terminator, we could end up with one very
long string and then print various suffixes of that, leading to
much more than 400 bytes of output). Except of course when we're
filling path[7], where overrunning it means writing random stuff
to the kernel stack, which is usually a lot of fun.

We can fix all of that and get rid of the 400 byte stack buffer by
simply writing directly to the given output buffer, which the upper
layer guarantees is at least PAGE_SIZE. s[c]nprintf doesn't care where
it is writing to, so this doesn't make the spin lock hold time any
longer. Using scnprintf ensures that output_len always represents the
number of bytes actually written to the buffer, so we'll report the
proper amount to the upper layer.

Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
Reviewed-by: Matthew R. Ochs 
Signed-off-by: Rasmus Villemoes 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   38 +-
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 64638d5..910b2d1 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -734,7 +734,6 @@ static ssize_t host_show_hp_ssd_smart_path_enabled(struct 
device *dev,
 }
 
 #define MAX_PATHS 8
-#define PATH_STRING_LEN 50
 
 static ssize_t path_info_show(struct device *dev,
 struct device_attribute *attr, char *buf)
@@ -750,9 +749,7 @@ static ssize_t path_info_show(struct device *dev,
u8 path_map_index = 0;
char *active;
unsigned char phys_connector[2];
-   unsigned char path[MAX_PATHS][PATH_STRING_LEN];
 
-   memset(path, 0, MAX_PATHS * PATH_STRING_LEN);
sdev = to_scsi_device(dev);
h = sdev_to_hba(sdev);
spin_lock_irqsave(>devlock, flags);
@@ -772,8 +769,9 @@ static ssize_t path_info_show(struct device *dev,
else
continue;
 
-   output_len = snprintf(path[i],
-   PATH_STRING_LEN, "[%d:%d:%d:%d] %20.20s ",
+   output_len += scnprintf(buf + output_len,
+   PAGE_SIZE - output_len,
+   "[%d:%d:%d:%d] %20.20s ",
h->scsi_host->host_no,
hdev->bus, hdev->target, hdev->lun,
scsi_device_type(hdev->devtype));
@@ -781,9 +779,9 @@ static ssize_t path_info_show(struct device *dev,
if (hdev->external ||
hdev->devtype == TYPE_RAID ||
is_logical_device(hdev)) {
-   output_len += snprintf(path[i] + output_len,
-   PATH_STRING_LEN, "%s\n",
-   active);
+   output_len 

[PATCH v2 23/27] hpsa: disable report lun data caching

2015-11-04 Thread Don Brace
From: Scott Teel 

When external target arrays are present, disable the firmware's
normal behavior of returning a cached copy of the report lun data,
and force it to collect new data each time we request a report luns.

This is necessary for external arrays, since there may be no
reliable signal from the external array to the smart array when
lun configuration changes, and thus when driver requests
report luns, it may be stale data.

Use diag options to turn off RPL data caching.

Reviewed-by: Scott Teel 
Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Matthew R. Ochs 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   85 +++
 drivers/scsi/hpsa_cmd.h |3 ++
 2 files changed, 88 insertions(+)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index acfbbb2..91e7005 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -275,6 +275,7 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info 
*h,
 static void hpsa_command_resubmit_worker(struct work_struct *work);
 static u32 lockup_detected(struct ctlr_info *h);
 static int detect_controller_lockup(struct ctlr_info *h);
+static void hpsa_disable_rld_caching(struct ctlr_info *h);
 static int hpsa_luns_changed(struct ctlr_info *h);
 
 static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
@@ -6380,6 +6381,24 @@ static int fill_cmd(struct CommandList *c, u8 cmd, 
struct ctlr_info *h,
c->Request.CDB[8] = (size >> 8) & 0xFF;
c->Request.CDB[9] = size & 0xFF;
break;
+   case BMIC_SENSE_DIAG_OPTIONS:
+   c->Request.CDBLen = 16;
+   c->Request.type_attr_dir =
+   TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_READ);
+   c->Request.Timeout = 0;
+   /* Spec says this should be BMIC_WRITE */
+   c->Request.CDB[0] = BMIC_READ;
+   c->Request.CDB[6] = BMIC_SENSE_DIAG_OPTIONS;
+   break;
+   case BMIC_SET_DIAG_OPTIONS:
+   c->Request.CDBLen = 16;
+   c->Request.type_attr_dir =
+   TYPE_ATTR_DIR(cmd_type,
+   ATTR_SIMPLE, XFER_WRITE);
+   c->Request.Timeout = 0;
+   c->Request.CDB[0] = BMIC_WRITE;
+   c->Request.CDB[6] = BMIC_SET_DIAG_OPTIONS;
+   break;
case HPSA_CACHE_FLUSH:
c->Request.CDBLen = 12;
c->Request.type_attr_dir =
@@ -8080,6 +8099,7 @@ static void hpsa_rescan_ctlr_worker(struct work_struct 
*work)
hpsa_scan_start(h->scsi_host);
scsi_host_put(h->scsi_host);
} else if (h->discovery_polling) {
+   hpsa_disable_rld_caching(h);
if (hpsa_luns_changed(h)) {
struct Scsi_Host *sh = NULL;
 
@@ -8417,6 +8437,71 @@ out:
kfree(flush_buf);
 }
 
+/* Make controller gather fresh report lun data each time we
+ * send down a report luns request
+ */
+static void hpsa_disable_rld_caching(struct ctlr_info *h)
+{
+   u32 *options;
+   struct CommandList *c;
+   int rc;
+
+   /* Don't bother trying to set diag options if locked up */
+   if (unlikely(h->lockup_detected))
+   return;
+
+   options = kzalloc(sizeof(*options), GFP_KERNEL);
+   if (!options) {
+   dev_err(>pdev->dev,
+   "Error: failed to disable rld caching, during 
alloc.\n");
+   return;
+   }
+
+   c = cmd_alloc(h);
+
+   /* first, get the current diag options settings */
+   if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0,
+   RAID_CTLR_LUNID, TYPE_CMD))
+   goto errout;
+
+   rc = hpsa_scsi_do_simple_cmd_with_retry(h, c,
+   PCI_DMA_FROMDEVICE, NO_TIMEOUT);
+   if ((rc != 0) || (c->err_info->CommandStatus != 0))
+   goto errout;
+
+   /* Now, set the bit for disabling the RLD caching */
+   *options |= HPSA_DIAG_OPTS_DISABLE_RLD_CACHING;
+
+   if (fill_cmd(c, BMIC_SET_DIAG_OPTIONS, h, options, 4, 0,
+   RAID_CTLR_LUNID, TYPE_CMD))
+   goto errout;
+
+   rc = hpsa_scsi_do_simple_cmd_with_retry(h, c,
+   PCI_DMA_TODEVICE, NO_TIMEOUT);
+   if ((rc != 0)  || (c->err_info->CommandStatus != 0))
+   goto errout;
+
+   /* Now verify that it got set: */
+   if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0,
+   RAID_CTLR_LUNID, TYPE_CMD))
+   goto errout;
+

[PATCH 26/32] ide cd: do not set REQ_WRITE on requests.

2015-11-04 Thread mchristi
From: Mike Christie 

The block layer will set the correct READ/WRITE operation flags/fields
when creating a request, so there is not need for drivers to set the
REQ_WRITE flag.

Signed-off-by: Mike Christie 
---
 drivers/ide/ide-cd_ioctl.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/ide/ide-cd_ioctl.c b/drivers/ide/ide-cd_ioctl.c
index 066e390..d2d0b38 100644
--- a/drivers/ide/ide-cd_ioctl.c
+++ b/drivers/ide/ide-cd_ioctl.c
@@ -459,9 +459,6 @@ int ide_cdrom_packet(struct cdrom_device_info *cdi,
   layer. the packet must be complete, as we do not
   touch it at all. */
 
-   if (cgc->data_direction == CGC_DATA_WRITE)
-   flags |= REQ_WRITE;
-
if (cgc->sense)
memset(cgc->sense, 0, sizeof(struct request_sense));
 
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 24/32] dm: pass dm stats data dir instead of bi_rw

2015-11-04 Thread mchristi
From: Mike Christie 

It looks like dm stats primarily cares about the data direction
(READ vs WRITE) and does not need the bio/request flags
and in the future operation value. REQ_DISCARD is always set with
REQ_WRITE, so the check for either one in dm_stats_account_io
is not needed.

This patch has it use the bio and request data_dir helpers
instead of accessing the bi_rw/cmd_flags directly. This makes
the next patches that remove the operation from the cmd_flags
and bi_rw cleaner since we do not have to check for multiple
operations.

Signed-off-by: Mike Christie 
---
 drivers/md/dm-stats.c | 6 +++---
 drivers/md/dm.c   | 8 
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
index 8289804..96b5c1b 100644
--- a/drivers/md/dm-stats.c
+++ b/drivers/md/dm-stats.c
@@ -518,7 +518,7 @@ static void dm_stat_for_entry(struct dm_stat *s, size_t 
entry,
  struct dm_stats_aux *stats_aux, bool end,
  unsigned long duration_jiffies)
 {
-   unsigned long idx = bi_rw & REQ_WRITE;
+   unsigned long idx = bi_rw;
struct dm_stat_shared *shared = >stat_shared[entry];
struct dm_stat_percpu *p;
 
@@ -645,8 +645,8 @@ void dm_stats_account_io(struct dm_stats *stats, unsigned 
long bi_rw,
last = raw_cpu_ptr(stats->last);
stats_aux->merged =
(bi_sector == (ACCESS_ONCE(last->last_sector) &&
-  ((bi_rw & (REQ_WRITE | REQ_DISCARD)) ==
-   (ACCESS_ONCE(last->last_rw) & 
(REQ_WRITE | REQ_DISCARD)))
+  ((bi_rw == WRITE) ==
+   (ACCESS_ONCE(last->last_rw) == WRITE))
   ));
ACCESS_ONCE(last->last_sector) = end_sector;
ACCESS_ONCE(last->last_rw) = bi_rw;
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index d2cf6d9..ea4bc70 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -655,7 +655,7 @@ static void start_io_acct(struct dm_io *io)
atomic_inc_return(>pending[rw]));
 
if (unlikely(dm_stats_used(>stats)))
-   dm_stats_account_io(>stats, bio->bi_rw, 
bio->bi_iter.bi_sector,
+   dm_stats_account_io(>stats, bio_data_dir(bio), 
bio->bi_iter.bi_sector,
bio_sectors(bio), false, 0, >stats_aux);
 }
 
@@ -670,7 +670,7 @@ static void end_io_acct(struct dm_io *io)
generic_end_io_acct(rw, _disk(md)->part0, io->start_time);
 
if (unlikely(dm_stats_used(>stats)))
-   dm_stats_account_io(>stats, bio->bi_rw, 
bio->bi_iter.bi_sector,
+   dm_stats_account_io(>stats, bio_data_dir(bio), 
bio->bi_iter.bi_sector,
bio_sectors(bio), true, duration, 
>stats_aux);
 
/*
@@ -1053,7 +1053,7 @@ static void rq_end_stats(struct mapped_device *md, struct 
request *orig)
if (unlikely(dm_stats_used(>stats))) {
struct dm_rq_target_io *tio = tio_from_request(orig);
tio->duration_jiffies = jiffies - tio->duration_jiffies;
-   dm_stats_account_io(>stats, orig->cmd_flags, 
blk_rq_pos(orig),
+   dm_stats_account_io(>stats, rq_data_dir(orig), 
blk_rq_pos(orig),
tio->n_sectors, true, tio->duration_jiffies,
>stats_aux);
}
@@ -1988,7 +1988,7 @@ static void dm_start_request(struct mapped_device *md, 
struct request *orig)
struct dm_rq_target_io *tio = tio_from_request(orig);
tio->duration_jiffies = jiffies;
tio->n_sectors = blk_rq_sectors(orig);
-   dm_stats_account_io(>stats, orig->cmd_flags, 
blk_rq_pos(orig),
+   dm_stats_account_io(>stats, rq_data_dir(orig), 
blk_rq_pos(orig),
tio->n_sectors, false, 0, >stats_aux);
}
 
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 29/32] block/drivers: rm request cmd_flags REQ_OP use

2015-11-04 Thread mchristi
From: Mike Christie 

With this patch the request struct code no longer uses the
cmd_flags field for REQ_OP operations.

---
 block/blk-core.c  | 17 +
 block/blk-merge.c | 10 ++
 block/blk-mq.c| 10 +-
 block/cfq-iosched.c   |  4 ++--
 block/elevator.c  |  8 
 drivers/block/loop.c  |  2 +-
 drivers/block/mtip32xx/mtip32xx.c |  2 +-
 drivers/block/nbd.c   |  2 +-
 drivers/block/nvme-core.c |  6 +++---
 drivers/block/rbd.c   |  2 +-
 drivers/block/skd_main.c  | 11 ---
 drivers/block/xen-blkfront.c  |  8 +---
 drivers/md/dm.c   |  2 +-
 drivers/mmc/card/block.c  |  7 +++
 drivers/mmc/card/queue.c  |  6 ++
 drivers/mmc/card/queue.h  |  5 -
 drivers/mtd/mtd_blkdevs.c |  2 +-
 drivers/scsi/sd.c | 22 ++
 include/linux/blkdev.h| 26 +-
 include/linux/elevator.h  |  4 ++--
 20 files changed, 82 insertions(+), 74 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index e625516..deb8bfd 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -889,10 +889,10 @@ static void __freed_request(struct request_list *rl, int 
sync)
  * A request has just been released.  Account for it, update the full and
  * congestion status, wake up any waiters.   Called under q->queue_lock.
  */
-static void freed_request(struct request_list *rl, unsigned int flags)
+static void freed_request(struct request_list *rl, int op, unsigned int flags)
 {
struct request_queue *q = rl->q;
-   int sync = rw_is_sync(flags);
+   int sync = rw_is_sync(op, flags);
 
q->nr_rqs[sync]--;
rl->count[sync]--;
@@ -1005,13 +1005,13 @@ static struct request *__get_request(struct 
request_list *rl, int op,
struct elevator_type *et = q->elevator->type;
struct io_context *ioc = rq_ioc(bio);
struct io_cq *icq = NULL;
-   const bool is_sync = rw_is_sync(op | op_flags) != 0;
+   const bool is_sync = rw_is_sync(op, op_flags) != 0;
int may_queue;
 
if (unlikely(blk_queue_dying(q)))
return ERR_PTR(-ENODEV);
 
-   may_queue = elv_may_queue(q, op | op_flags);
+   may_queue = elv_may_queue(q, op, op_flags);
if (may_queue == ELV_MQUEUE_NO)
goto rq_starved;
 
@@ -1141,7 +1141,7 @@ fail_alloc:
 * queue, but this is pretty rare.
 */
spin_lock_irq(q->queue_lock);
-   freed_request(rl, op | op_flags);
+   freed_request(rl, op, op_flags);
 
/*
 * in the very unlikely event that allocation failed and no
@@ -1175,7 +1175,7 @@ static struct request *get_request(struct request_queue 
*q, int op,
   int op_flags, struct bio *bio,
   gfp_t gfp_mask)
 {
-   const bool is_sync = rw_is_sync(op | op_flags) != 0;
+   const bool is_sync = rw_is_sync(op, op_flags) != 0;
DEFINE_WAIT(wait);
struct request_list *rl;
struct request *rq;
@@ -1424,13 +1424,14 @@ void __blk_put_request(struct request_queue *q, struct 
request *req)
 */
if (req->cmd_flags & REQ_ALLOCED) {
unsigned int flags = req->cmd_flags;
+   int op = req->op;
struct request_list *rl = blk_rq_rl(req);
 
BUG_ON(!list_empty(>queuelist));
BUG_ON(ELV_ON_HASH(req));
 
blk_free_request(rl, req);
-   freed_request(rl, flags);
+   freed_request(rl, op, flags);
blk_put_rl(rl);
}
 }
@@ -2054,7 +2055,7 @@ int blk_rq_check_limits(struct request_queue *q, struct 
request *rq)
if (!rq_mergeable(rq))
return 0;
 
-   if (blk_rq_sectors(rq) > blk_queue_get_max_sectors(q, rq->cmd_flags)) {
+   if (blk_rq_sectors(rq) > blk_queue_get_max_sectors(q, rq->op)) {
printk(KERN_ERR "%s: over max size limit.\n", __func__);
return -EIO;
}
diff --git a/block/blk-merge.c b/block/blk-merge.c
index fe00d94..ec42c7e 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -582,7 +582,8 @@ static int attempt_merge(struct request_queue *q, struct 
request *req,
if (!rq_mergeable(req) || !rq_mergeable(next))
return 0;
 
-   if (!blk_check_merge_flags(req->cmd_flags, next->cmd_flags))
+   if (!blk_check_merge_flags(req->cmd_flags, req->op, next->cmd_flags,
+  next->op))
return 0;
 
/*
@@ -596,7 +597,7 @@ static int attempt_merge(struct request_queue *q, struct 
request *req,
|| req_no_special_merge(next))
return 0;
 
-   if (req->cmd_flags & REQ_WRITE_SAME &&
+   if (req->op == REQ_OP_WRITE_SAME &&

[PATCH 28/32] block/fs/drivers: use bio/rq_data_dir helpers

2015-11-04 Thread mchristi
From: Mike Christie 

This has the the block layer, drivers and fs code use
the bio and rq data_dir helpers instead of accessing the
bi_rw/cmd_flags and checking for REQ_WRITE.

Signed-off-by: Mike Christie 
---
 block/blk-merge.c| 2 +-
 drivers/ata/libata-scsi.c| 2 +-
 drivers/block/loop.c | 6 +++---
 drivers/block/rbd.c  | 2 +-
 drivers/block/umem.c | 2 +-
 drivers/ide/ide-floppy.c | 2 +-
 drivers/md/bcache/io.c   | 2 +-
 drivers/md/bcache/request.c  | 6 +++---
 drivers/scsi/osd/osd_initiator.c | 4 ++--
 fs/btrfs/disk-io.c   | 2 +-
 fs/btrfs/extent_io.c | 2 +-
 fs/btrfs/inode.c | 2 +-
 include/linux/blkdev.h   | 2 +-
 include/linux/fs.h   | 2 +-
 14 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/block/blk-merge.c b/block/blk-merge.c
index c4e9c37..fe00d94 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -378,7 +378,7 @@ int blk_rq_map_sg(struct request_queue *q, struct request 
*rq,
}
 
if (q->dma_drain_size && q->dma_drain_needed(rq)) {
-   if (rq->cmd_flags & REQ_WRITE)
+   if (rq_data_dir(rq) == WRITE)
memset(q->dma_drain_buffer, 0, q->dma_drain_size);
 
sg_unmark_end(sg);
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 0d7f0da..68c2b34 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1125,7 +1125,7 @@ static int atapi_drain_needed(struct request *rq)
if (likely(rq->cmd_type != REQ_TYPE_BLOCK_PC))
return 0;
 
-   if (!blk_rq_bytes(rq) || (rq->cmd_flags & REQ_WRITE))
+   if (!blk_rq_bytes(rq) || rq_data_dir(rq) == WRITE)
return 0;
 
return atapi_cmd_type(rq->cmd[0]) == ATAPI_MISC;
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 674f800..e214936 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -396,7 +396,7 @@ static int do_req_filebacked(struct loop_device *lo, struct 
request *rq)
 
pos = ((loff_t) blk_rq_pos(rq) << 9) + lo->lo_offset;
 
-   if (rq->cmd_flags & REQ_WRITE) {
+   if (rq_data_dir(rq) == WRITE) {
if (rq->cmd_flags & REQ_FLUSH)
ret = lo_req_flush(lo, rq);
else if (rq->cmd_flags & REQ_DISCARD)
@@ -1461,7 +1461,7 @@ static int loop_queue_rq(struct blk_mq_hw_ctx *hctx,
if (lo->lo_state != Lo_bound)
return -EIO;
 
-   if (cmd->rq->cmd_flags & REQ_WRITE) {
+   if (rq_data_dir(cmd->rq) == WRITE) {
struct loop_device *lo = cmd->rq->q->queuedata;
bool need_sched = true;
 
@@ -1484,7 +1484,7 @@ static int loop_queue_rq(struct blk_mq_hw_ctx *hctx,
 
 static void loop_handle_cmd(struct loop_cmd *cmd)
 {
-   const bool write = cmd->rq->cmd_flags & REQ_WRITE;
+   const bool write = rq_data_dir(cmd->rq);
struct loop_device *lo = cmd->rq->q->queuedata;
int ret = 0;
 
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 6f26cf3..39104ca 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -3377,7 +3377,7 @@ static void rbd_queue_workfn(struct work_struct *work)
 
if (rq->cmd_flags & REQ_DISCARD)
op_type = OBJ_OP_DISCARD;
-   else if (rq->cmd_flags & REQ_WRITE)
+   else if (rq_data_dir(rq) == WRITE)
op_type = OBJ_OP_WRITE;
else
op_type = OBJ_OP_READ;
diff --git a/drivers/block/umem.c b/drivers/block/umem.c
index 04d6579..2355754 100644
--- a/drivers/block/umem.c
+++ b/drivers/block/umem.c
@@ -462,7 +462,7 @@ static void process_page(unsigned long data)
le32_to_cpu(desc->local_addr)>>9,
le32_to_cpu(desc->transfer_size));
dump_dmastat(card, control);
-   } else if ((bio->bi_rw & REQ_WRITE) &&
+   } else if (bio_data_dir(bio) == WRITE &&
   le32_to_cpu(desc->local_addr) >> 9 ==
card->init_size) {
card->init_size += le32_to_cpu(desc->transfer_size) >> 
9;
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 2fb5350..f079d8d 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -206,7 +206,7 @@ static void idefloppy_create_rw_cmd(ide_drive_t *drive,
memcpy(rq->cmd, pc->c, 12);
 
pc->rq = rq;
-   if (rq->cmd_flags & REQ_WRITE)
+   if (cmd == WRITE)
pc->flags |= PC_FLAG_WRITING;
 
pc->flags |= PC_FLAG_DMA_OK;
diff --git a/drivers/md/bcache/io.c b/drivers/md/bcache/io.c
index 86a0bb8..fbc8974 100644
--- a/drivers/md/bcache/io.c
+++ b/drivers/md/bcache/io.c
@@ -111,7 +111,7 @@ void bch_bbio_count_io_errors(struct cache_set *c, struct 
bio *bio,
struct bbio *b = 

[PATCH 03/32] dio/btrfs: prep dio->submit_bio users for bi_rw split.

2015-11-04 Thread mchristi
From: Mike Christie 

Instead of passing around a bitmap of ops and flags, the
next patches separate it into a op field and a flags field.
This patch prepares the dio code and dio->submit_bio users
for the split.

Note that the next patches will fix up the submit_bio() call
with along other users of that function.

Signed-off-by: Mike Christie 
---
 fs/btrfs/inode.c   |  9 -
 fs/direct-io.c | 34 +-
 include/linux/fs.h |  4 ++--
 3 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 611b66d..0ad8bab 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8196,14 +8196,13 @@ out_err:
return 0;
 }
 
-static void btrfs_submit_direct(int rw, struct bio *dio_bio,
+static void btrfs_submit_direct(int op, int op_flags, struct bio *dio_bio,
struct inode *inode, loff_t file_offset)
 {
struct btrfs_dio_private *dip = NULL;
struct bio *io_bio = NULL;
struct btrfs_io_bio *btrfs_bio;
int skip_sum;
-   int write = rw & REQ_WRITE;
int ret = 0;
 
skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
@@ -8232,14 +8231,14 @@ static void btrfs_submit_direct(int rw, struct bio 
*dio_bio,
btrfs_bio = btrfs_io_bio(io_bio);
btrfs_bio->logical = file_offset;
 
-   if (write) {
+   if (op == REQ_OP_WRITE) {
io_bio->bi_end_io = btrfs_endio_direct_write;
} else {
io_bio->bi_end_io = btrfs_endio_direct_read;
dip->subio_endio = btrfs_subio_endio_read;
}
 
-   ret = btrfs_submit_direct_hook(rw, dip, skip_sum);
+   ret = btrfs_submit_direct_hook(op | op_flags, dip, skip_sum);
if (!ret)
return;
 
@@ -8267,7 +8266,7 @@ free_ordered:
dip = NULL;
io_bio = NULL;
} else {
-   if (write) {
+   if (op == REQ_OP_WRITE) {
struct btrfs_ordered_extent *ordered;
 
ordered = btrfs_lookup_ordered_extent(inode,
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 1125629..5e1b1a0 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -108,7 +108,8 @@ struct dio_submit {
 /* dio_state communicated between submission path and end_io */
 struct dio {
int flags;  /* doesn't change */
-   int rw;
+   int op;
+   int op_flags;
struct inode *inode;
loff_t i_size;  /* i_size when submitted */
dio_iodone_t *end_io;   /* IO completion function */
@@ -160,7 +161,7 @@ static inline int dio_refill_pages(struct dio *dio, struct 
dio_submit *sdio)
ret = iov_iter_get_pages(sdio->iter, dio->pages, LONG_MAX, DIO_PAGES,
>from);
 
-   if (ret < 0 && sdio->blocks_available && (dio->rw & WRITE)) {
+   if (ret < 0 && sdio->blocks_available && (dio->op == REQ_OP_WRITE)) {
struct page *page = ZERO_PAGE(0);
/*
 * A memory fault, but the filesystem has some outstanding
@@ -239,7 +240,8 @@ static ssize_t dio_complete(struct dio *dio, loff_t offset, 
ssize_t ret,
transferred = dio->result;
 
/* Check for short read case */
-   if ((dio->rw == READ) && ((offset + transferred) > dio->i_size))
+   if ((dio->op == REQ_OP_READ) &&
+   ((offset + transferred) > dio->i_size))
transferred = dio->i_size - offset;
}
 
@@ -257,7 +259,7 @@ static ssize_t dio_complete(struct dio *dio, loff_t offset, 
ssize_t ret,
inode_dio_end(dio->inode);
 
if (is_async) {
-   if (dio->rw & WRITE) {
+   if (dio->op == REQ_OP_WRITE) {
int err;
 
err = generic_write_sync(dio->iocb->ki_filp, offset,
@@ -393,14 +395,14 @@ static inline void dio_bio_submit(struct dio *dio, struct 
dio_submit *sdio)
dio->refcount++;
spin_unlock_irqrestore(>bio_lock, flags);
 
-   if (dio->is_async && dio->rw == READ)
+   if (dio->is_async && dio->op == REQ_OP_READ)
bio_set_pages_dirty(bio);
 
if (sdio->submit_io)
-   sdio->submit_io(dio->rw, bio, dio->inode,
+   sdio->submit_io(dio->op, dio->op_flags, bio, dio->inode,
   sdio->logical_offset_in_bio);
else
-   submit_bio(dio->rw, bio);
+   submit_bio(dio->op | dio->op_flags, bio);
 
sdio->bio = NULL;
sdio->boundary = 0;
@@ -464,14 +466,14 @@ static int dio_bio_complete(struct dio *dio, struct bio 
*bio)
if (bio->bi_error)
dio->io_error = -EIO;
 
-   if (dio->is_async && dio->rw == READ) {
+   if (dio->is_async && dio->op == REQ_OP_READ) {

[PATCH 02/32] block/fs/mm: prepare submit_bio_wait users for bi_rw split

2015-11-04 Thread mchristi
From: Mike Christie 

This patch prepares submit_bio_wait callers for the next
patches that split bi_rw into a operation and flags field.
Instead of passing in a bitmap with both the operation and
flags mixed in, the callers now pass them in seperately.

Temp issue: When the fs.h read/write types, like WRITE_SYNC or
WRITE_FUA, are used we still pass in the operation along with the
flags in the flags argument. When all the code has been converted
that will be cleaned up. It is left in here for compat and git
bisect use and to try and make the patches smaller.

Signed-off-by: Mike Christie 
---
 block/bio.c|  8 
 block/blk-flush.c  |  2 +-
 drivers/md/bcache/debug.c  |  4 ++--
 drivers/md/md.c|  2 +-
 drivers/md/raid1.c |  2 +-
 drivers/md/raid10.c|  2 +-
 fs/btrfs/check-integrity.c |  8 
 fs/btrfs/check-integrity.h |  2 +-
 fs/btrfs/extent_io.c   |  2 +-
 fs/btrfs/scrub.c   |  6 +++---
 fs/ext4/crypto.c   |  2 +-
 fs/f2fs/segment.c  |  4 ++--
 fs/hfsplus/hfsplus_fs.h|  2 +-
 fs/hfsplus/part_tbl.c  |  5 +++--
 fs/hfsplus/super.c |  6 --
 fs/hfsplus/wrapper.c   | 14 --
 fs/logfs/dev_bdev.c|  2 +-
 include/linux/bio.h|  2 +-
 kernel/power/swap.c| 30 ++
 19 files changed, 58 insertions(+), 47 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index ad3f276..610c704 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -859,21 +859,21 @@ static void submit_bio_wait_endio(struct bio *bio)
 
 /**
  * submit_bio_wait - submit a bio, and wait until it completes
- * @rw: whether to %READ or %WRITE, or maybe to %READA (read ahead)
+ * @op: REQ_OP_*
+ * @flags: rq_flag_bits
  * @bio: The  bio which describes the I/O
  *
  * Simple wrapper around submit_bio(). Returns 0 on success, or the error from
  * bio_endio() on failure.
  */
-int submit_bio_wait(int rw, struct bio *bio)
+int submit_bio_wait(int op, int flags, struct bio *bio)
 {
struct submit_bio_ret ret;
 
-   rw |= REQ_SYNC;
init_completion();
bio->bi_private = 
bio->bi_end_io = submit_bio_wait_endio;
-   submit_bio(rw, bio);
+   submit_bio(op | flags | REQ_SYNC, bio);
wait_for_completion();
 
return ret.error;
diff --git a/block/blk-flush.c b/block/blk-flush.c
index 9c423e5..f707ba1 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -485,7 +485,7 @@ int blkdev_issue_flush(struct block_device *bdev, gfp_t 
gfp_mask,
bio = bio_alloc(gfp_mask, 0);
bio->bi_bdev = bdev;
 
-   ret = submit_bio_wait(WRITE_FLUSH, bio);
+   ret = submit_bio_wait(REQ_OP_WRITE, WRITE_FLUSH, bio);
 
/*
 * The driver must store the error location in ->bi_sector, if
diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
index 8b1f1d5..001f5f1 100644
--- a/drivers/md/bcache/debug.c
+++ b/drivers/md/bcache/debug.c
@@ -54,7 +54,7 @@ void bch_btree_verify(struct btree *b)
bio->bi_iter.bi_size= KEY_SIZE(>key) << 9;
bch_bio_map(bio, sorted);
 
-   submit_bio_wait(REQ_META|READ_SYNC, bio);
+   submit_bio_wait(REQ_OP_READ, READ_SYNC, bio);
bch_bbio_free(bio, b->c);
 
memcpy(ondisk, sorted, KEY_SIZE(>key) << 9);
@@ -117,7 +117,7 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
if (bio_alloc_pages(check, GFP_NOIO))
goto out_put;
 
-   submit_bio_wait(READ_SYNC, check);
+   submit_bio_wait(REQ_OP_READ, READ_SYNC, check);
 
bio_for_each_segment(bv, bio, iter) {
void *p1 = kmap_atomic(bv.bv_page);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index c702de1..1ca5959 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -771,7 +771,7 @@ int sync_page_io(struct md_rdev *rdev, sector_t sector, int 
size,
else
bio->bi_iter.bi_sector = sector + rdev->data_offset;
bio_add_page(bio, page, size, 0);
-   submit_bio_wait(rw, bio);
+   submit_bio_wait(rw, 0, bio);
 
ret = !bio->bi_error;
bio_put(bio);
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index d9d031e..527fdf5 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2195,7 +2195,7 @@ static int narrow_write_error(struct r1bio *r1_bio, int i)
bio_trim(wbio, sector - r1_bio->sector, sectors);
wbio->bi_iter.bi_sector += rdev->data_offset;
wbio->bi_bdev = rdev->bdev;
-   if (submit_bio_wait(WRITE, wbio) < 0)
+   if (submit_bio_wait(REQ_OP_WRITE, 0, wbio) < 0)
/* failure! */
ok = rdev_set_badblocks(rdev, sector,
sectors, 0)
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 96f3659..69352a6 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -2470,7 +2470,7 @@ 

[PATCH 05/32] drbd: prepare drbd for bi_rw split

2015-11-04 Thread mchristi
From: Mike Christie 

This patch prepares drbd's submit_bio use for the next
patches that split bi_rw into a operation and flags field.
Instead of passing in a bitmap with both the operation and
flags mixed in, the callers will now pass them in seperately.

This patch modifies the code related to the submit_bio calls
so the flags and operation are seperated. When this is done
for all code, one of the later patches in the series will
modify the actual submit_bio call, so the patches are bisectable.

Signed-off-by: Mike Christie 
---
 drivers/block/drbd/drbd_actlog.c | 30 --
 drivers/block/drbd/drbd_bitmap.c |  4 ++--
 drivers/block/drbd/drbd_int.h|  2 +-
 drivers/block/drbd/drbd_main.c   |  5 +++--
 4 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/drivers/block/drbd/drbd_actlog.c b/drivers/block/drbd/drbd_actlog.c
index b3868e7..c290e8b 100644
--- a/drivers/block/drbd/drbd_actlog.c
+++ b/drivers/block/drbd/drbd_actlog.c
@@ -137,19 +137,19 @@ void wait_until_done_or_force_detached(struct drbd_device 
*device, struct drbd_b
 
 static int _drbd_md_sync_page_io(struct drbd_device *device,
 struct drbd_backing_dev *bdev,
-sector_t sector, int rw)
+sector_t sector, int op)
 {
struct bio *bio;
/* we do all our meta data IO in aligned 4k blocks. */
const int size = 4096;
-   int err;
+   int err, op_flags = 0;
 
device->md_io.done = 0;
device->md_io.error = -ENODEV;
 
-   if ((rw & WRITE) && !test_bit(MD_NO_FUA, >flags))
-   rw |= REQ_FUA | REQ_FLUSH;
-   rw |= REQ_SYNC | REQ_NOIDLE;
+   if ((op == REQ_OP_WRITE) && !test_bit(MD_NO_FUA, >flags))
+   op_flags |= REQ_FUA | REQ_FLUSH;
+   op_flags |= REQ_SYNC | REQ_NOIDLE;
 
bio = bio_alloc_drbd(GFP_NOIO);
bio->bi_bdev = bdev->md_bdev;
@@ -159,9 +159,9 @@ static int _drbd_md_sync_page_io(struct drbd_device *device,
goto out;
bio->bi_private = device;
bio->bi_end_io = drbd_md_endio;
-   bio->bi_rw = rw;
+   bio->bi_rw = op | op_flags;
 
-   if (!(rw & WRITE) && device->state.disk == D_DISKLESS && device->ldev 
== NULL)
+   if (op != REQ_OP_WRITE && device->state.disk == D_DISKLESS && 
device->ldev == NULL)
/* special case, drbd_md_read() during drbd_adm_attach(): no 
get_ldev */
;
else if (!get_ldev_if_state(device, D_ATTACHING)) {
@@ -174,10 +174,10 @@ static int _drbd_md_sync_page_io(struct drbd_device 
*device,
bio_get(bio); /* one bio_put() is in the completion handler */
atomic_inc(>md_io.in_use); /* drbd_md_put_buffer() is in the 
completion handler */
device->md_io.submit_jif = jiffies;
-   if (drbd_insert_fault(device, (rw & WRITE) ? DRBD_FAULT_MD_WR : 
DRBD_FAULT_MD_RD))
+   if (drbd_insert_fault(device, (op == REQ_OP_WRITE) ? DRBD_FAULT_MD_WR : 
DRBD_FAULT_MD_RD))
bio_io_error(bio);
else
-   submit_bio(rw, bio);
+   submit_bio(op | op_flags, bio);
wait_until_done_or_force_detached(device, bdev, >md_io.done);
if (!bio->bi_error)
err = device->md_io.error;
@@ -188,7 +188,7 @@ static int _drbd_md_sync_page_io(struct drbd_device *device,
 }
 
 int drbd_md_sync_page_io(struct drbd_device *device, struct drbd_backing_dev 
*bdev,
-sector_t sector, int rw)
+sector_t sector, int op)
 {
int err;
D_ASSERT(device, atomic_read(>md_io.in_use) == 1);
@@ -197,19 +197,21 @@ int drbd_md_sync_page_io(struct drbd_device *device, 
struct drbd_backing_dev *bd
 
dynamic_drbd_dbg(device, "meta_data io: %s [%d]:%s(,%llus,%s) %pS\n",
 current->comm, current->pid, __func__,
-(unsigned long long)sector, (rw & WRITE) ? "WRITE" : "READ",
+(unsigned long long)sector, (op == REQ_OP_WRITE) ? "WRITE" : 
"READ",
 (void*)_RET_IP_ );
 
if (sector < drbd_md_first_sector(bdev) ||
sector + 7 > drbd_md_last_sector(bdev))
drbd_alert(device, "%s [%d]:%s(,%llus,%s) out of range md 
access!\n",
 current->comm, current->pid, __func__,
-(unsigned long long)sector, (rw & WRITE) ? "WRITE" : 
"READ");
+(unsigned long long)sector,
+(op == REQ_OP_WRITE) ? "WRITE" : "READ");
 
-   err = _drbd_md_sync_page_io(device, bdev, sector, rw);
+   err = _drbd_md_sync_page_io(device, bdev, sector, op);
if (err) {
drbd_err(device, "drbd_md_sync_page_io(,%llus,%s) failed with 
error %d\n",
-   (unsigned long long)sector, (rw & WRITE) ? "WRITE" : 
"READ", err);
+   (unsigned long long)sector,
+   (op == REQ_OP_WRITE) ? "WRITE" : 

[PATCH 04/32] block: prepare blkdev_issue_discard for bi_rw split

2015-11-04 Thread mchristi
From: Mike Christie 

The next patches will prepare the submit_bio users
for the split. There were a lot more users than
there were for submit_bio_wait, so if the conversion
was not a one liner, I broke it out into its own
patch.

This patch prepares blkdev_issue_discard.

There is some compat code left which will be dropped
in later patches in the series.
1. REQ_WRITE is still being set. This is because a lot
of code assumes it will be set for discard, flushes and
write sames.
2. submit_bio is still taking a bitmap. This is to make
the series git bisectable.

Signed-off-by: Mike Christie 
---
 block/blk-lib.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/block/blk-lib.c b/block/blk-lib.c
index 9ebf653..0861c7a 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -42,7 +42,8 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t 
sector,
 {
DECLARE_COMPLETION_ONSTACK(wait);
struct request_queue *q = bdev_get_queue(bdev);
-   int type = REQ_WRITE | REQ_DISCARD;
+   int op = REQ_OP_DISCARD;
+   int op_flags = REQ_WRITE;
unsigned int granularity;
int alignment;
struct bio_batch bb;
@@ -63,7 +64,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t 
sector,
if (flags & BLKDEV_DISCARD_SECURE) {
if (!blk_queue_secdiscard(q))
return -EOPNOTSUPP;
-   type |= REQ_SECURE;
+   op_flags |= REQ_SECURE;
}
 
atomic_set(, 1);
@@ -108,7 +109,7 @@ int blkdev_issue_discard(struct block_device *bdev, 
sector_t sector,
sector = end_sect;
 
atomic_inc();
-   submit_bio(type, bio);
+   submit_bio(op | op_flags, bio);
 
/*
 * We can loop for a long time in here, if someone does
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 31/32] block/fs/driver: rm bio bi_rw REQ_OP use

2015-11-04 Thread mchristi
From: Mike Christie 

With this patch we no longer use the bio->bi_rw field
for REQ_WRITE, REQ_DISCARD, REQ_WRITE_SAME, (REQ_OPs). bi_rw should
only set REQ_XYZ values and bi_op is for REQ_OPs.

Signed-off-by: Mike Christie 
---
 block/bio.c | 15 +++--
 block/blk-core.c| 10 +++---
 block/blk-lib.c |  9 ++---
 block/blk-map.c |  4 +--
 block/blk-merge.c   | 12 +++
 drivers/block/brd.c |  2 +-
 drivers/block/pktcdvd.c |  2 --
 drivers/block/rsxx/dma.c|  2 +-
 drivers/block/xen-blkfront.c|  5 +--
 drivers/block/zram/zram_drv.c   |  2 +-
 drivers/md/bcache/journal.c |  6 ++--
 drivers/md/bcache/movinggc.c|  2 +-
 drivers/md/bcache/request.c | 11 +++---
 drivers/md/bcache/writeback.c   |  4 +--
 drivers/md/dm-cache-target.c| 10 +++---
 drivers/md/dm-crypt.c   |  2 +-
 drivers/md/dm-io.c  | 12 +++
 drivers/md/dm-kcopyd.c  |  2 +-
 drivers/md/dm-log-writes.c  |  2 +-
 drivers/md/dm-raid1.c   | 10 +++---
 drivers/md/dm-region-hash.c |  4 +--
 drivers/md/dm-stripe.c  |  4 +--
 drivers/md/dm-thin.c| 15 +
 drivers/md/dm.c |  6 ++--
 drivers/md/linear.c |  2 +-
 drivers/md/raid0.c  |  2 +-
 drivers/md/raid1.c  | 25 ++
 drivers/md/raid10.c | 34 +--
 drivers/md/raid5.c  | 20 ---
 drivers/scsi/osd/osd_initiator.c|  4 ---
 drivers/staging/lustre/lustre/llite/lloop.c |  8 ++---
 drivers/target/target_core_pscsi.c  |  4 +--
 fs/btrfs/volumes.c  |  6 ++--
 fs/exofs/ore.c  |  1 -
 include/linux/bio.h | 15 ++---
 include/linux/blk_types.h   | 13 +++-
 include/linux/blktrace_api.h|  2 +-
 include/linux/fs.h  | 29 ++--
 include/trace/events/bcache.h   | 12 ---
 include/trace/events/block.h| 31 +++--
 kernel/trace/blktrace.c | 52 -
 41 files changed, 204 insertions(+), 209 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index 1cf8428..064a858 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -669,10 +669,10 @@ struct bio *bio_clone_bioset(struct bio *bio_src, gfp_t 
gfp_mask,
bio->bi_iter.bi_sector  = bio_src->bi_iter.bi_sector;
bio->bi_iter.bi_size= bio_src->bi_iter.bi_size;
 
-   if (bio->bi_rw & REQ_DISCARD)
+   if (bio->bi_op == REQ_OP_DISCARD)
goto integrity_clone;
 
-   if (bio->bi_rw & REQ_WRITE_SAME) {
+   if (bio->bi_op == REQ_OP_WRITE_SAME) {
bio->bi_io_vec[bio->bi_vcnt++] = bio_src->bi_io_vec[0];
goto integrity_clone;
}
@@ -1170,10 +1170,8 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
if (!bio)
goto out_bmd;
 
-   if (iter->type & WRITE) {
-   bio->bi_rw |= REQ_WRITE;
+   if (iter->type & WRITE)
bio->bi_op = REQ_OP_WRITE;
-   }
 
ret = 0;
 
@@ -1342,10 +1340,8 @@ struct bio *bio_map_user_iov(struct request_queue *q,
/*
 * set data direction, and check if mapped pages need bouncing
 */
-   if (iter->type & WRITE) {
-   bio->bi_rw |= REQ_WRITE;
+   if (iter->type & WRITE)
bio->bi_op = REQ_OP_WRITE;
-   }
 
bio_set_flag(bio, BIO_USER_MAPPED);
 
@@ -1538,7 +1534,6 @@ struct bio *bio_copy_kern(struct request_queue *q, void 
*data, unsigned int len,
bio->bi_private = data;
} else {
bio->bi_end_io = bio_copy_kern_endio;
-   bio->bi_rw |= REQ_WRITE;
bio->bi_op = REQ_OP_WRITE;
}
 
@@ -1798,7 +1793,7 @@ struct bio *bio_split(struct bio *bio, int sectors,
 * Discards need a mutable bio_vec to accommodate the payload
 * required by the DSM TRIM and UNMAP commands.
 */
-   if (bio->bi_rw & REQ_DISCARD)
+   if (bio->bi_op == REQ_OP_DISCARD)
split = bio_clone_bioset(bio, gfp, bs);
else
split = bio_clone_fast(bio, gfp, bs);
diff --git a/block/blk-core.c b/block/blk-core.c
index deb8bfd..c270a4a 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1873,14 +1873,14 @@ generic_make_request_checks(struct bio *bio)
}
}
 
-   if ((bio->bi_rw & REQ_DISCARD) &&

[PATCH 18/32] drbd: set bio bi_op to REQ_OP

2015-11-04 Thread mchristi
From: Mike Christie 

This patch has drbd set the bi_op.

For compat reasons, we are still ORing the op into bi_rw. This
will be dropped in later patches in this series when everyone
is updated.

Signed-off-by: Mike Christie 
---
 drivers/block/drbd/drbd_actlog.c   |  1 +
 drivers/block/drbd/drbd_bitmap.c   |  1 +
 drivers/block/drbd/drbd_int.h  |  2 +-
 drivers/block/drbd/drbd_receiver.c | 39 --
 drivers/block/drbd/drbd_worker.c   |  3 ++-
 5 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/drivers/block/drbd/drbd_actlog.c b/drivers/block/drbd/drbd_actlog.c
index 5ad6b09..ed2eafe 100644
--- a/drivers/block/drbd/drbd_actlog.c
+++ b/drivers/block/drbd/drbd_actlog.c
@@ -160,6 +160,7 @@ static int _drbd_md_sync_page_io(struct drbd_device *device,
bio->bi_private = device;
bio->bi_end_io = drbd_md_endio;
bio->bi_rw = op | op_flags;
+   bio->bi_op = op;
 
if (op != REQ_OP_WRITE && device->state.disk == D_DISKLESS && 
device->ldev == NULL)
/* special case, drbd_md_read() during drbd_adm_attach(): no 
get_ldev */
diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c
index e8c65a4..2ff407a 100644
--- a/drivers/block/drbd/drbd_bitmap.c
+++ b/drivers/block/drbd/drbd_bitmap.c
@@ -1021,6 +1021,7 @@ static void bm_page_io_async(struct drbd_bm_aio_ctx *ctx, 
int page_nr) __must_ho
bio->bi_end_io = drbd_bm_endio;
 
if (drbd_insert_fault(device, (rw == REQ_OP_WRITE) ? DRBD_FAULT_MD_WR : 
DRBD_FAULT_MD_RD)) {
+   bio->bi_op = rw;
bio->bi_rw |= rw;
bio_io_error(bio);
} else {
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 2934481..05eaba8 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -1542,7 +1542,7 @@ extern bool drbd_rs_should_slow_down(struct drbd_device 
*device, sector_t sector
bool throttle_if_app_is_waiting);
 extern int drbd_submit_peer_request(struct drbd_device *,
struct drbd_peer_request *, const unsigned,
-   const int);
+   const unsigned, const int);
 extern int drbd_free_peer_reqs(struct drbd_device *, struct list_head *);
 extern struct drbd_peer_request *drbd_alloc_peer_req(struct drbd_peer_device 
*, u64,
 sector_t, unsigned int,
diff --git a/drivers/block/drbd/drbd_receiver.c 
b/drivers/block/drbd/drbd_receiver.c
index c097909..4e458bd 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -1365,7 +1365,8 @@ void drbd_bump_write_ordering(struct drbd_resource 
*resource, struct drbd_backin
 /* TODO allocate from our own bio_set. */
 int drbd_submit_peer_request(struct drbd_device *device,
 struct drbd_peer_request *peer_req,
-const unsigned rw, const int fault_type)
+const unsigned op, const unsigned op_flags,
+const int fault_type)
 {
struct bio *bios = NULL;
struct bio *bio;
@@ -1417,7 +1418,8 @@ next_bio:
/* > peer_req->i.sector, unless this is the first bio */
bio->bi_iter.bi_sector = sector;
bio->bi_bdev = device->ldev->backing_bdev;
-   bio->bi_rw = rw;
+   bio->bi_rw = op | op_flags;
+   bio->bi_op = op;
bio->bi_private = peer_req;
bio->bi_end_io = drbd_peer_request_endio;
 
@@ -1425,7 +1427,7 @@ next_bio:
bios = bio;
++n_bios;
 
-   if (rw & REQ_DISCARD) {
+   if (op & REQ_OP_DISCARD) {
bio->bi_iter.bi_size = data_size;
goto submit;
}
@@ -1803,7 +1805,8 @@ static int recv_resync_read(struct drbd_peer_device 
*peer_device, sector_t secto
spin_unlock_irq(>resource->req_lock);
 
atomic_add(pi->size >> 9, >rs_sect_ev);
-   if (drbd_submit_peer_request(device, peer_req, WRITE, DRBD_FAULT_RS_WR) 
== 0)
+   if (drbd_submit_peer_request(device, peer_req, REQ_OP_WRITE, 0,
+DRBD_FAULT_RS_WR) == 0)
return 0;
 
/* don't care for the reason here */
@@ -2125,7 +2128,7 @@ static int wait_for_and_update_peer_seq(struct 
drbd_peer_device *peer_device, co
 /* see also bio_flags_to_wire()
  * DRBD_REQ_*, because we need to semantically map the flags to data packet
  * flags and back. We may replicate to other kernel versions. */
-static unsigned long wire_flags_to_bio(u32 dpf)
+static unsigned long wire_flags_to_bio_flags(u32 dpf)
 {
return  (dpf & DP_RW_SYNC ? REQ_SYNC : 0) |
(dpf & DP_FUA ? REQ_FUA : 0) |
@@ -2133,6 +2136,14 @@ static unsigned long wire_flags_to_bio(u32 dpf)
(dpf & DP_DISCARD ? REQ_DISCARD : 0);
 }
 
+static unsigned long 

[PATCH 11/32] gfs2: prepare for bi_rw split

2015-11-04 Thread mchristi
From: Mike Christie 

This patch prepares gfs2's submit_bio use for the next
patches that split bi_rw into a operation and flags field.
Instead of passing in a bitmap with both the operation and
flags mixed in, the callers will now pass them in seperately.

This patch modifies the code related to the submit_bio calls
so the flags and operation are seperated. When this is done
for all code, one of the later patches in the series will
the actual submit_bio call, so the patches are bisectable.

Signed-off-by: Mike Christie 
---
 fs/gfs2/log.c  |  8 
 fs/gfs2/lops.c | 11 ++-
 fs/gfs2/lops.h |  2 +-
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 536e7a6..8324af5 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -657,7 +657,7 @@ static void log_write_header(struct gfs2_sbd *sdp, u32 
flags)
struct gfs2_log_header *lh;
unsigned int tail;
u32 hash;
-   int rw = WRITE_FLUSH_FUA | REQ_META;
+   int op_flags = WRITE_FLUSH_FUA | REQ_META;
struct page *page = mempool_alloc(gfs2_page_pool, GFP_NOIO);
enum gfs2_freeze_state state = atomic_read(>sd_freeze_state);
lh = page_address(page);
@@ -682,12 +682,12 @@ static void log_write_header(struct gfs2_sbd *sdp, u32 
flags)
if (test_bit(SDF_NOBARRIERS, >sd_flags)) {
gfs2_ordered_wait(sdp);
log_flush_wait(sdp);
-   rw = WRITE_SYNC | REQ_META | REQ_PRIO;
+   op_flags = WRITE_SYNC | REQ_META | REQ_PRIO;
}
 
sdp->sd_log_idle = (tail == sdp->sd_log_flush_head);
gfs2_log_write_page(sdp, page);
-   gfs2_log_flush_bio(sdp, rw);
+   gfs2_log_flush_bio(sdp, REQ_OP_WRITE, op_flags);
log_flush_wait(sdp);
 
if (sdp->sd_log_tail != tail)
@@ -735,7 +735,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock 
*gl,
 
gfs2_ordered_write(sdp);
lops_before_commit(sdp, tr);
-   gfs2_log_flush_bio(sdp, WRITE);
+   gfs2_log_flush_bio(sdp, REQ_OP_WRITE, 0);
 
if (sdp->sd_log_head != sdp->sd_log_flush_head) {
log_flush_wait(sdp);
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index d5369a1..36b047a 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -230,17 +230,18 @@ static void gfs2_end_log_write(struct bio *bio)
 /**
  * gfs2_log_flush_bio - Submit any pending log bio
  * @sdp: The superblock
- * @rw: The rw flags
+ * @op: REQ_OP
+ * @op_flags: rq_flag_bits
  *
  * Submit any pending part-built or full bio to the block device. If
  * there is no pending bio, then this is a no-op.
  */
 
-void gfs2_log_flush_bio(struct gfs2_sbd *sdp, int rw)
+void gfs2_log_flush_bio(struct gfs2_sbd *sdp, int op, int op_flags)
 {
if (sdp->sd_log_bio) {
atomic_inc(>sd_log_in_flight);
-   submit_bio(rw, sdp->sd_log_bio);
+   submit_bio(op | op_flags, sdp->sd_log_bio);
sdp->sd_log_bio = NULL;
}
 }
@@ -299,7 +300,7 @@ static struct bio *gfs2_log_get_bio(struct gfs2_sbd *sdp, 
u64 blkno)
nblk >>= sdp->sd_fsb2bb_shift;
if (blkno == nblk)
return bio;
-   gfs2_log_flush_bio(sdp, WRITE);
+   gfs2_log_flush_bio(sdp, REQ_OP_WRITE, 0);
}
 
return gfs2_log_alloc_bio(sdp, blkno);
@@ -328,7 +329,7 @@ static void gfs2_log_write(struct gfs2_sbd *sdp, struct 
page *page,
bio = gfs2_log_get_bio(sdp, blkno);
ret = bio_add_page(bio, page, size, offset);
if (ret == 0) {
-   gfs2_log_flush_bio(sdp, WRITE);
+   gfs2_log_flush_bio(sdp, REQ_OP_WRITE, 0);
bio = gfs2_log_alloc_bio(sdp, blkno);
ret = bio_add_page(bio, page, size, offset);
WARN_ON(ret == 0);
diff --git a/fs/gfs2/lops.h b/fs/gfs2/lops.h
index a65a7ba..e529f53 100644
--- a/fs/gfs2/lops.h
+++ b/fs/gfs2/lops.h
@@ -27,7 +27,7 @@ extern const struct gfs2_log_operations gfs2_databuf_lops;
 
 extern const struct gfs2_log_operations *gfs2_log_ops[];
 extern void gfs2_log_write_page(struct gfs2_sbd *sdp, struct page *page);
-extern void gfs2_log_flush_bio(struct gfs2_sbd *sdp, int rw);
+extern void gfs2_log_flush_bio(struct gfs2_sbd *sdp, int op, int op_flags);
 extern void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh);
 
 static inline unsigned int buf_limit(struct gfs2_sbd *sdp)
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] st: trivial: remove form feed characters

2015-11-04 Thread Laurence Oberman
Reviewed-by: Laurence Oberman 

On Wed, Nov 4, 2015 at 4:52 AM, Maurizio Lombardi  wrote:
> Signed-off-by: Maurizio Lombardi 
> ---
>  drivers/scsi/st.c | 24 
>  1 file changed, 8 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
> index b37b9b0..7c4e518 100644
> --- a/drivers/scsi/st.c
> +++ b/drivers/scsi/st.c
> @@ -226,7 +226,6 @@ static DEFINE_SPINLOCK(st_use_lock);
>  static DEFINE_IDR(st_index_idr);
>
>
> -
>  #include "osst_detect.h"
>  #ifndef SIGS_FROM_OSST
>  #define SIGS_FROM_OSST \
> @@ -305,7 +304,6 @@ static char * st_incompatible(struct scsi_device* SDp)
> }
> return NULL;
>  }
> -
>
>  static inline char *tape_name(struct scsi_tape *tape)
>  {
> @@ -877,7 +875,7 @@ static int flush_buffer(struct scsi_tape *STp, int 
> seek_next)
> return result;
>
>  }
> -
> +
>  /* Set the mode parameters */
>  static int set_mode_densblk(struct scsi_tape * STp, struct st_modedef * STm)
>  {
> @@ -952,7 +950,7 @@ static void reset_state(struct scsi_tape *STp)
> STp->new_partition = STp->partition;
> }
>  }
> -
> +
>  /* Test if the drive is ready. Returns either one of the codes below or a 
> negative system
> error code. */
>  #define CHKRES_READY   0
> @@ -1241,7 +1239,7 @@ static int check_tape(struct scsi_tape *STp, struct 
> file *filp)
>  }
>
>
> - /* Open the device. Needs to take the BKL only because of incrementing the 
> SCSI host
> +/* Open the device. Needs to take the BKL only because of incrementing the 
> SCSI host
> module count. */
>  static int st_open(struct inode *inode, struct file *filp)
>  {
> @@ -1334,7 +1332,6 @@ static int st_open(struct inode *inode, struct file 
> *filp)
> return retval;
>
>  }
> -
>
>  /* Flush the tape buffer before close */
>  static int st_flush(struct file *filp, fl_owner_t id)
> @@ -1470,7 +1467,7 @@ static int st_release(struct inode *inode, struct file 
> *filp)
>
> return result;
>  }
> -
> +
>  /* The checks common to both reading and writing */
>  static ssize_t rw_checks(struct scsi_tape *STp, struct file *filp, size_t 
> count)
>  {
> @@ -1889,7 +1886,7 @@ st_write(struct file *filp, const char __user *buf, 
> size_t count, loff_t * ppos)
>
> return retval;
>  }
> -
> +
>  /* Read data from the tape. Returns zero in the normal case, one if the
> eof status has changed, and the negative error code in case of a
> fatal error. Otherwise updates the buffer and the eof state.
> @@ -2085,7 +2082,6 @@ static long read_tape(struct scsi_tape *STp, long count,
> }
> return retval;
>  }
> -
>
>  /* Read command */
>  static ssize_t
> @@ -2233,7 +2229,6 @@ st_read(struct file *filp, char __user *buf, size_t 
> count, loff_t * ppos)
>
> return retval;
>  }
> -
>
>
>  DEB(
> @@ -2447,7 +2442,7 @@ static int st_set_options(struct scsi_tape *STp, long 
> options)
>
> return 0;
>  }
> -
> +
>  #define MODE_HEADER_LENGTH  4
>
>  /* Mode header and page byte offsets */
> @@ -2665,7 +2660,7 @@ static int do_load_unload(struct scsi_tape *STp, struct 
> file *filp, int load_cod
>
> return retval;
>  }
> -
> +
>  #if DEBUG
>  #define ST_DEB_FORWARD  0
>  #define ST_DEB_BACKWARD 1
> @@ -3091,7 +3086,6 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned 
> int cmd_in, unsigned lon
>
> return ioctl_result;
>  }
> -
>
>  /* Get the tape position. If bt == 2, arg points into a kernel space mt_loc
> structure. */
> @@ -3283,7 +3277,7 @@ static int switch_partition(struct scsi_tape *STp)
> STps->last_block_visited = 0;
> return set_location(STp, STps->last_block_visited, 
> STp->new_partition, 1);
>  }
> -
> +
>  /* Functions for reading and writing the medium partition mode page. */
>
>  #define PART_PAGE   0x11
> @@ -3396,7 +3390,6 @@ static int partition_tape(struct scsi_tape *STp, int 
> size)
>
> return result;
>  }
> -
>
>
>  /* The ioctl command */
> @@ -3766,7 +3759,6 @@ static long st_compat_ioctl(struct file *file, unsigned 
> int cmd, unsigned long a
>  }
>  #endif
>
> -
>
>  /* Try to allocate a new tape buffer. Calling function must not hold
> dev_arr_lock. */
> --
> Maurizio Lombardi
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 27/32] cfq/cgroup: pass operation and flags seperately

2015-11-04 Thread mchristi
From: Mike Christie 

The operation is about to be separated from the flags, so this
patch has users pass them in separately to the cgroup stats.

Signed-off-by: Mike Christie 
---
 block/cfq-iosched.c| 49 +++---
 include/linux/blk-cgroup.h | 13 ++--
 2 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 04de884..dbc3da4 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -660,9 +660,10 @@ static inline void cfqg_put(struct cfq_group *cfqg)
 } while (0)
 
 static inline void cfqg_stats_update_io_add(struct cfq_group *cfqg,
-   struct cfq_group *curr_cfqg, int rw)
+   struct cfq_group *curr_cfqg, int op,
+   int op_flags)
 {
-   blkg_rwstat_add(>stats.queued, rw, 1);
+   blkg_rwstat_add(>stats.queued, op, op_flags, 1);
cfqg_stats_end_empty_time(>stats);
cfqg_stats_set_start_group_wait_time(cfqg, curr_cfqg);
 }
@@ -676,26 +677,30 @@ static inline void 
cfqg_stats_update_timeslice_used(struct cfq_group *cfqg,
 #endif
 }
 
-static inline void cfqg_stats_update_io_remove(struct cfq_group *cfqg, int rw)
+static inline void cfqg_stats_update_io_remove(struct cfq_group *cfqg, int op,
+  int op_flags)
 {
-   blkg_rwstat_add(>stats.queued, rw, -1);
+   blkg_rwstat_add(>stats.queued, op, op_flags, -1);
 }
 
-static inline void cfqg_stats_update_io_merged(struct cfq_group *cfqg, int rw)
+static inline void cfqg_stats_update_io_merged(struct cfq_group *cfqg, int op,
+  int op_flags)
 {
-   blkg_rwstat_add(>stats.merged, rw, 1);
+   blkg_rwstat_add(>stats.merged, op, op_flags, 1);
 }
 
 static inline void cfqg_stats_update_completion(struct cfq_group *cfqg,
-   uint64_t start_time, uint64_t io_start_time, int rw)
+   uint64_t start_time, uint64_t io_start_time, int op,
+   int op_flags)
 {
struct cfqg_stats *stats = >stats;
unsigned long long now = sched_clock();
 
if (time_after64(now, io_start_time))
-   blkg_rwstat_add(>service_time, rw, now - io_start_time);
+   blkg_rwstat_add(>service_time, op, op_flags,
+   now - io_start_time);
if (time_after64(io_start_time, start_time))
-   blkg_rwstat_add(>wait_time, rw,
+   blkg_rwstat_add(>wait_time, op, op_flags,
io_start_time - start_time);
 }
 
@@ -769,13 +774,16 @@ static inline void cfqg_put(struct cfq_group *cfqg) { }
 #define cfq_log_cfqg(cfqd, cfqg, fmt, args...) do {} while (0)
 
 static inline void cfqg_stats_update_io_add(struct cfq_group *cfqg,
-   struct cfq_group *curr_cfqg, int rw) { }
+   struct cfq_group *curr_cfqg, int op, int op_flags) { }
 static inline void cfqg_stats_update_timeslice_used(struct cfq_group *cfqg,
unsigned long time, unsigned long unaccounted_time) { }
-static inline void cfqg_stats_update_io_remove(struct cfq_group *cfqg, int rw) 
{ }
-static inline void cfqg_stats_update_io_merged(struct cfq_group *cfqg, int rw) 
{ }
+static inline void cfqg_stats_update_io_remove(struct cfq_group *cfqg, int op,
+   int op_flags) { }
+static inline void cfqg_stats_update_io_merged(struct cfq_group *cfqg, int op,
+   int op_flags) { }
 static inline void cfqg_stats_update_completion(struct cfq_group *cfqg,
-   uint64_t start_time, uint64_t io_start_time, int rw) { }
+   uint64_t start_time, uint64_t io_start_time, int op,
+   int op_flags) { }
 
 #endif /* CONFIG_CFQ_GROUP_IOSCHED */
 
@@ -2449,10 +2457,10 @@ static void cfq_reposition_rq_rb(struct cfq_queue 
*cfqq, struct request *rq)
 {
elv_rb_del(>sort_list, rq);
cfqq->queued[rq_is_sync(rq)]--;
-   cfqg_stats_update_io_remove(RQ_CFQG(rq), rq->cmd_flags);
+   cfqg_stats_update_io_remove(RQ_CFQG(rq), rq->op, rq->cmd_flags);
cfq_add_rq_rb(rq);
cfqg_stats_update_io_add(RQ_CFQG(rq), cfqq->cfqd->serving_group,
-rq->cmd_flags);
+rq->op, rq->cmd_flags);
 }
 
 static struct request *
@@ -2505,7 +2513,7 @@ static void cfq_remove_request(struct request *rq)
cfq_del_rq_rb(rq);
 
cfqq->cfqd->rq_queued--;
-   cfqg_stats_update_io_remove(RQ_CFQG(rq), rq->cmd_flags);
+   cfqg_stats_update_io_remove(RQ_CFQG(rq), rq->op, rq->cmd_flags);
if (rq->cmd_flags & REQ_PRIO) {
WARN_ON(!cfqq->prio_pending);
cfqq->prio_pending--;
@@ -2540,7 +2548,7 @@ static void cfq_merged_request(struct 

[PATCH 23/32] block/fs: pass in op and flags to ll_rw_block

2015-11-04 Thread mchristi
From: Mike Christie 

This has ll_rw_block users pass in the request op and flags seperately
instead of as a bitmap.

Signed-off-by: Mike Christie 
---
 fs/buffer.c | 19 ++-
 fs/ext4/inode.c |  6 +++---
 fs/ext4/namei.c |  3 ++-
 fs/ext4/super.c |  2 +-
 fs/gfs2/bmap.c  |  2 +-
 fs/gfs2/meta_io.c   |  4 ++--
 fs/gfs2/quota.c |  2 +-
 fs/isofs/compress.c |  2 +-
 fs/jbd2/journal.c   |  2 +-
 fs/jbd2/recovery.c  |  4 ++--
 fs/ocfs2/aops.c |  2 +-
 fs/ocfs2/super.c|  2 +-
 fs/reiserfs/journal.c   |  8 
 fs/reiserfs/stree.c |  4 ++--
 fs/reiserfs/super.c |  2 +-
 fs/squashfs/block.c |  4 ++--
 fs/udf/dir.c|  2 +-
 fs/udf/directory.c  |  2 +-
 fs/udf/inode.c  |  2 +-
 fs/ufs/balloc.c |  2 +-
 include/linux/buffer_head.h |  2 +-
 21 files changed, 40 insertions(+), 38 deletions(-)

diff --git a/fs/buffer.c b/fs/buffer.c
index cd07d86..ba84126 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -595,7 +595,7 @@ void write_boundary_block(struct block_device *bdev,
struct buffer_head *bh = __find_get_block(bdev, bblock + 1, blocksize);
if (bh) {
if (buffer_dirty(bh))
-   ll_rw_block(WRITE, 1, );
+   ll_rw_block(REQ_OP_WRITE, 0, 1, );
put_bh(bh);
}
 }
@@ -1406,7 +1406,7 @@ void __breadahead(struct block_device *bdev, sector_t 
block, unsigned size)
 {
struct buffer_head *bh = __getblk(bdev, block, size);
if (likely(bh)) {
-   ll_rw_block(READA, 1, );
+   ll_rw_block(REQ_OP_READ, REQ_RAHEAD, 1, );
brelse(bh);
}
 }
@@ -1966,7 +1966,7 @@ int __block_write_begin(struct page *page, loff_t pos, 
unsigned len,
if (!buffer_uptodate(bh) && !buffer_delay(bh) &&
!buffer_unwritten(bh) &&
 (block_start < from || block_end > to)) {
-   ll_rw_block(READ, 1, );
+   ll_rw_block(REQ_OP_READ, 0, 1, );
*wait_bh++=bh;
}
}
@@ -2883,7 +2883,7 @@ int block_truncate_page(struct address_space *mapping,
 
if (!buffer_uptodate(bh) && !buffer_delay(bh) && !buffer_unwritten(bh)) 
{
err = -EIO;
-   ll_rw_block(READ, 1, );
+   ll_rw_block(REQ_OP_READ, 0, 1, );
wait_on_buffer(bh);
/* Uhhuh. Read error. Complain and punt. */
if (!buffer_uptodate(bh))
@@ -3081,7 +3081,8 @@ EXPORT_SYMBOL(submit_bh);
 
 /**
  * ll_rw_block: low-level access to block devices (DEPRECATED)
- * @rw: whether to %READ or %WRITE or maybe %READA (readahead)
+ * @op: REQ_OP_READ or REQ_OP_WRITE
+ * op_flags: rq_flag_bits
  * @nr: number of  buffer_heads in the array
  * @bhs: array of pointers to  buffer_head
  *
@@ -3104,7 +3105,7 @@ EXPORT_SYMBOL(submit_bh);
  * All of the buffers must be for the same device, and must also be a
  * multiple of the current approved size for the device.
  */
-void ll_rw_block(int rw, int nr, struct buffer_head *bhs[])
+void ll_rw_block(int op, int op_flags, int nr, struct buffer_head *bhs[])
 {
int i;
 
@@ -3113,18 +3114,18 @@ void ll_rw_block(int rw, int nr, struct buffer_head 
*bhs[])
 
if (!trylock_buffer(bh))
continue;
-   if (rw == WRITE) {
+   if (op == REQ_OP_WRITE) {
if (test_clear_buffer_dirty(bh)) {
bh->b_end_io = end_buffer_write_sync;
get_bh(bh);
-   submit_bh(REQ_OP_WRITE, 0, bh);
+   submit_bh(REQ_OP_WRITE, op_flags, bh);
continue;
}
} else {
if (!buffer_uptodate(bh)) {
bh->b_end_io = end_buffer_read_sync;
get_bh(bh);
-   submit_bh(rw, 0, bh);
+   submit_bh(REQ_OP_READ, op_flags, bh);
continue;
}
}
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index f34ef29..dd2e197 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -791,7 +791,7 @@ struct buffer_head *ext4_bread(handle_t *handle, struct 
inode *inode,
return bh;
if (!bh || buffer_uptodate(bh))
return bh;
-   ll_rw_block(READ | REQ_META | REQ_PRIO, 1, );
+   ll_rw_block(REQ_OP_READ,  REQ_META | REQ_PRIO, 1, );
wait_on_buffer(bh);
if (buffer_uptodate(bh))
return bh;
@@ -948,7 +948,7 @@ static int ext4_block_write_begin(struct page *page, loff_t 

[PATCH 22/32] block/fs/drivers: set bi_op to REQ_OP

2015-11-04 Thread mchristi
From: Mike Christie 

This patch sets the bi_op to a REQ_OP for users where it
was a simple one line change.

For compat reasons, we are still ORing the op into bi_rw. This
will be dropped in later patches in this series when everyone
is updated.

Signed-off-by: Mike Christie 
---
 drivers/block/pktcdvd.c| 2 ++
 drivers/md/dm-crypt.c  | 1 +
 drivers/md/dm.c| 1 +
 drivers/scsi/osd/osd_initiator.c   | 4 
 drivers/target/target_core_pscsi.c | 4 +++-
 fs/btrfs/volumes.c | 1 +
 fs/exofs/ore.c | 1 +
 7 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 7be2375..bbb7a45 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -1075,6 +1075,7 @@ static void pkt_gather_data(struct pktcdvd_device *pd, 
struct packet_data *pkt)
 
atomic_inc(>io_wait);
bio->bi_rw = READ;
+   bio->bi_op = REQ_OP_READ;
pkt_queue_bio(pd, bio);
frames_read++;
}
@@ -1337,6 +1338,7 @@ static void pkt_start_write(struct pktcdvd_device *pd, 
struct packet_data *pkt)
/* Start the write request */
atomic_set(>io_wait, 1);
pkt->w_bio->bi_rw = WRITE;
+   pkt->w_bio->bi_op = REQ_OP_WRITE;
pkt_queue_bio(pd, pkt->w_bio);
 }
 
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 4b3b6f8..92689e5 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1132,6 +1132,7 @@ static void clone_init(struct dm_crypt_io *io, struct bio 
*clone)
clone->bi_private = io;
clone->bi_end_io  = crypt_endio;
clone->bi_bdev= cc->dev->bdev;
+   clone->bi_op  = io->base_bio->bi_op;
clone->bi_rw  = io->base_bio->bi_rw;
 }
 
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 1b5c604..d2cf6d9 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -2329,6 +2329,7 @@ static struct mapped_device *alloc_dev(int minor)
 
bio_init(>flush_bio);
md->flush_bio.bi_bdev = md->bdev;
+   md->flush_bio.bi_op = REQ_OP_WRITE;
md->flush_bio.bi_rw = WRITE_FLUSH;
 
dm_stats_init(>stats);
diff --git a/drivers/scsi/osd/osd_initiator.c b/drivers/scsi/osd/osd_initiator.c
index 0cccd60..ca7b4b6 100644
--- a/drivers/scsi/osd/osd_initiator.c
+++ b/drivers/scsi/osd/osd_initiator.c
@@ -729,6 +729,7 @@ static int _osd_req_list_objects(struct osd_request *or,
return PTR_ERR(bio);
}
 
+   bio->bi_op = REQ_OP_READ;
bio->bi_rw &= ~REQ_WRITE;
or->in.bio = bio;
or->in.total_bytes = bio->bi_iter.bi_size;
@@ -842,6 +843,7 @@ int osd_req_write_kern(struct osd_request *or,
if (IS_ERR(bio))
return PTR_ERR(bio);
 
+   bio->bi_op = REQ_OP_WRITE;
bio->bi_rw |= REQ_WRITE; /* FIXME: bio_set_dir() */
osd_req_write(or, obj, offset, bio, len);
return 0;
@@ -959,6 +961,7 @@ static int _osd_req_finalize_cdb_cont(struct osd_request 
*or, const u8 *cap_key)
if (IS_ERR(bio))
return PTR_ERR(bio);
 
+   bio->bi_op = REQ_OP_WRITE;
bio->bi_rw |= REQ_WRITE;
 
/* integrity check the continuation before the bio is linked
@@ -1080,6 +1083,7 @@ int osd_req_write_sg_kern(struct osd_request *or,
if (IS_ERR(bio))
return PTR_ERR(bio);
 
+   bio->bi_op = REQ_OP_WRITE;
bio->bi_rw |= REQ_WRITE;
osd_req_write_sg(or, obj, bio, sglist, numentries);
 
diff --git a/drivers/target/target_core_pscsi.c 
b/drivers/target/target_core_pscsi.c
index de18790..00a7bda5 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -921,8 +921,10 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, 
u32 sgl_nents,
if (!bio)
goto fail;
 
-   if (rw)
+   if (rw) {
+   bio->bi_op = REQ_OP_WRITE;
bio->bi_rw |= REQ_WRITE;
+   }
 
pr_debug("PSCSI: Allocated bio: %p,"
" dir: %s nr_vecs: %d\n", bio,
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 3dfac71..ef67c2f 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -5847,6 +5847,7 @@ static noinline void btrfs_schedule_bio(struct btrfs_root 
*root,
atomic_inc(>fs_info->nr_async_bios);
WARN_ON(bio->bi_next);
bio->bi_next = NULL;
+   bio->bi_op = op;
bio->bi_rw |= op | op_flags;
 
spin_lock(>io_lock);
diff --git a/fs/exofs/ore.c b/fs/exofs/ore.c
index 7bd8ac8..7339bef 100644
--- a/fs/exofs/ore.c
+++ b/fs/exofs/ore.c
@@ -878,6 +878,7 @@ static int _write_mirror(struct ore_io_state *ios, int 
cur_comp)

[PATCH 19/32] block: add helper to get data dir from op

2015-11-04 Thread mchristi
From: Mike Christie 

In later patches the op will no longer be a bitmap, so we will
not have REQ_WRITE set for all non reads like discard, flush,
and write same. Drivers will still want to treat them as writes
for accounting reasons, so this patch adds a helper to translate
a op to a data direction.

Signed-off-by: Mike Christie 
---
 include/linux/blkdev.h | 12 
 1 file changed, 12 insertions(+)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 19c2e94..cf5f518 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -586,6 +586,18 @@ static inline void queue_flag_clear(unsigned int flag, 
struct request_queue *q)
 
 #define list_entry_rq(ptr) list_entry((ptr), struct request, queuelist)
 
+/*
+ * Non REQ_OP_WRITE requests like discard, write same, etc, are
+ * considered WRITEs.
+ */
+static inline int op_to_data_dir(int op)
+{
+   if (op == REQ_OP_READ)
+   return READ;
+   else
+   return WRITE;
+}
+
 #define rq_data_dir(rq)((int)((rq)->cmd_flags & 1))
 
 /*
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/32] dm: prepare for bi_rw split

2015-11-04 Thread mchristi
From: Mike Christie 

This patch prepares dm's submit_bio use for the next
patches that split bi_rw into a operation and flags field.
Instead of passing in a bitmap with both the operation and
flags mixed in, the callers will now pass them in seperately.

This patch modifies the code related to the submit_bio calls
so the flags and operation are seperated. When this is done
for all code, one of the later patches in the series will
the actual submit_bio call, so the patches are bisectable.

Signed-off-by: Mike Christie 
---
 drivers/md/dm-bufio.c   |  6 +++--
 drivers/md/dm-io.c  | 56 ++---
 drivers/md/dm-kcopyd.c  |  3 ++-
 drivers/md/dm-log.c |  5 ++--
 drivers/md/dm-raid1.c   | 11 +---
 drivers/md/dm-snap-persistent.c | 24 ++
 drivers/md/dm-thin.c|  6 ++---
 include/linux/dm-io.h   |  3 ++-
 8 files changed, 64 insertions(+), 50 deletions(-)

diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
index 83cc52e..9d5ef0c 100644
--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -554,7 +554,8 @@ static void use_dmio(struct dm_buffer *b, int rw, sector_t 
block,
 {
int r;
struct dm_io_request io_req = {
-   .bi_rw = rw,
+   .bi_op = rw,
+   .bi_op_flags = 0,
.notify.fn = dmio_complete,
.notify.context = b,
.client = b->c->dm_io,
@@ -1302,7 +1303,8 @@ EXPORT_SYMBOL_GPL(dm_bufio_write_dirty_buffers);
 int dm_bufio_issue_flush(struct dm_bufio_client *c)
 {
struct dm_io_request io_req = {
-   .bi_rw = WRITE_FLUSH,
+   .bi_op = REQ_OP_WRITE,
+   .bi_op_flags = WRITE_FLUSH,
.mem.type = DM_IO_KMEM,
.mem.ptr.addr = NULL,
.client = c->dm_io,
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
index 6f8e83b2..6479096 100644
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@ -279,8 +279,9 @@ static void km_dp_init(struct dpages *dp, void *data)
 /*-
  * IO routines that accept a list of pages.
  *---*/
-static void do_region(int rw, unsigned region, struct dm_io_region *where,
- struct dpages *dp, struct io *io)
+static void do_region(int op, int op_flags, unsigned region,
+ struct dm_io_region *where, struct dpages *dp,
+ struct io *io)
 {
struct bio *bio;
struct page *page;
@@ -296,24 +297,25 @@ static void do_region(int rw, unsigned region, struct 
dm_io_region *where,
/*
 * Reject unsupported discard and write same requests.
 */
-   if (rw & REQ_DISCARD)
+   if (op == REQ_DISCARD)
special_cmd_max_sectors = q->limits.max_discard_sectors;
-   else if (rw & REQ_WRITE_SAME)
+   else if (op == REQ_WRITE_SAME)
special_cmd_max_sectors = q->limits.max_write_same_sectors;
-   if ((rw & (REQ_DISCARD | REQ_WRITE_SAME)) && special_cmd_max_sectors == 
0) {
+   if ((op == REQ_DISCARD || op == REQ_WRITE_SAME) &&
+   special_cmd_max_sectors == 0) {
dec_count(io, region, -EOPNOTSUPP);
return;
}
 
/*
-* where->count may be zero if rw holds a flush and we need to
+* where->count may be zero if op holds a flush and we need to
 * send a zero-sized flush.
 */
do {
/*
 * Allocate a suitably sized-bio.
 */
-   if ((rw & REQ_DISCARD) || (rw & REQ_WRITE_SAME))
+   if ((op == REQ_DISCARD) || (op == REQ_WRITE_SAME))
num_bvecs = 1;
else
num_bvecs = min_t(int, BIO_MAX_PAGES,
@@ -325,11 +327,11 @@ static void do_region(int rw, unsigned region, struct 
dm_io_region *where,
bio->bi_end_io = endio;
store_io_and_region_in_bio(bio, io, region);
 
-   if (rw & REQ_DISCARD) {
+   if (op == REQ_DISCARD) {
num_sectors = min_t(sector_t, special_cmd_max_sectors, 
remaining);
bio->bi_iter.bi_size = num_sectors << SECTOR_SHIFT;
remaining -= num_sectors;
-   } else if (rw & REQ_WRITE_SAME) {
+   } else if (op == REQ_WRITE_SAME) {
/*
 * WRITE SAME only uses a single page.
 */
@@ -356,11 +358,11 @@ static void do_region(int rw, unsigned region, struct 
dm_io_region *where,
}
 
atomic_inc(>count);
-   submit_bio(rw, bio);
+   submit_bio(op | op_flags, bio);
} while (remaining);
 }
 
-static void dispatch_io(int 

[PATCH 06/32] xen blkback: prepare for bi_rw split

2015-11-04 Thread mchristi
From: Mike Christie 

This patch prepares xen blkback submit_bio use for the next
patches that split bi_rw into a operation and flags field.
Instead of passing in a bitmap with both the operation and
flags mixed in, the callers will now pass them in seperately.

This patch modifies the code related to the submit_bio calls
so the flags and operation are seperated. When this is done
for all code, one of the later patches in the series will
modify the actual submit_bio call, so the patches are bisectable.

Signed-off-by: Mike Christie 
---
 drivers/block/xen-blkback/blkback.c | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/block/xen-blkback/blkback.c 
b/drivers/block/xen-blkback/blkback.c
index 6a685ae..bfffab3 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -488,7 +488,7 @@ static int xen_vbd_translate(struct phys_req *req, struct 
xen_blkif *blkif,
struct xen_vbd *vbd = >vbd;
int rc = -EACCES;
 
-   if ((operation != READ) && vbd->readonly)
+   if ((operation != REQ_OP_READ) && vbd->readonly)
goto out;
 
if (likely(req->nr_sects)) {
@@ -990,7 +990,7 @@ static int dispatch_discard_io(struct xen_blkif *blkif,
preq.sector_number = req->u.discard.sector_number;
preq.nr_sects  = req->u.discard.nr_sectors;
 
-   err = xen_vbd_translate(, blkif, WRITE);
+   err = xen_vbd_translate(, blkif, REQ_OP_WRITE);
if (err) {
pr_warn("access denied: DISCARD [%llu->%llu] on dev=%04x\n",
preq.sector_number,
@@ -1203,6 +1203,7 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
struct bio **biolist = pending_req->biolist;
int i, nbio = 0;
int operation;
+   int operation_flags = 0;
struct blk_plug plug;
bool drain = false;
struct grant_page **pages = pending_req->segments;
@@ -1220,17 +1221,19 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
switch (req_operation) {
case BLKIF_OP_READ:
blkif->st_rd_req++;
-   operation = READ;
+   operation = REQ_OP_READ;
break;
case BLKIF_OP_WRITE:
blkif->st_wr_req++;
-   operation = WRITE_ODIRECT;
+   operation = REQ_OP_WRITE;
+   operation_flags = WRITE_ODIRECT;
break;
case BLKIF_OP_WRITE_BARRIER:
drain = true;
case BLKIF_OP_FLUSH_DISKCACHE:
blkif->st_f_req++;
-   operation = WRITE_FLUSH;
+   operation = REQ_OP_WRITE;
+   operation_flags = WRITE_FLUSH;
break;
default:
operation = 0; /* make gcc happy */
@@ -1242,7 +1245,7 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
nseg = req->operation == BLKIF_OP_INDIRECT ?
   req->u.indirect.nr_segments : req->u.rw.nr_segments;
 
-   if (unlikely(nseg == 0 && operation != WRITE_FLUSH) ||
+   if (unlikely(nseg == 0 && operation_flags != WRITE_FLUSH) ||
unlikely((req->operation != BLKIF_OP_INDIRECT) &&
 (nseg > BLKIF_MAX_SEGMENTS_PER_REQUEST)) ||
unlikely((req->operation == BLKIF_OP_INDIRECT) &&
@@ -1349,7 +1352,7 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
 
/* This will be hit if the operation was a flush or discard. */
if (!bio) {
-   BUG_ON(operation != WRITE_FLUSH);
+   BUG_ON(operation_flags != WRITE_FLUSH);
 
bio = bio_alloc(GFP_KERNEL, 0);
if (unlikely(bio == NULL))
@@ -1365,14 +1368,14 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
blk_start_plug();
 
for (i = 0; i < nbio; i++)
-   submit_bio(operation, biolist[i]);
+   submit_bio(operation | operation_flags, biolist[i]);
 
/* Let the I/Os go.. */
blk_finish_plug();
 
-   if (operation == READ)
+   if (operation == REQ_OP_READ)
blkif->st_rd_sect += preq.nr_sects;
-   else if (operation & WRITE)
+   else if (operation == REQ_OP_WRITE)
blkif->st_wr_sect += preq.nr_sects;
 
return 0;
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] Restart list search after unlock in scsi_remove_target

2015-11-04 Thread Bart Van Assche

On 10/30/2015 03:09 PM, Bart Van Assche wrote:

When dropping a lock while iterating a list we must restart the search
as other threads could have manipulated the list under us. Without this
we can get stuck in an endless loop.

This is a slightly modified version of a patch from Christoph Hellwig
(see also https://www.spinics.net/lists/linux-scsi/msg89416.html).

Reported-by: Johannes Thumshirn 
Signed-off-by: Bart Van Assche 
Cc: Johannes Thumshirn 
Cc: Christoph Hellwig 
Cc: Dan Williams 
Cc: stable 
---
  drivers/scsi/scsi_sysfs.c | 16 
  1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index b9fb61a..5a183d1 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1158,32 +1158,24 @@ static void __scsi_remove_target(struct scsi_target 
*starget)
  void scsi_remove_target(struct device *dev)
  {
struct Scsi_Host *shost = dev_to_shost(dev->parent);
-   struct scsi_target *starget, *last = NULL;
+   struct scsi_target *starget;
unsigned long flags;

-   /* remove targets being careful to lookup next entry before
-* deleting the last
-*/
+restart:
spin_lock_irqsave(shost->host_lock, flags);
list_for_each_entry(starget, >__targets, siblings) {
if (starget->reaped)
continue;
if (starget->dev.parent == dev || >dev == dev) {
-   /* assuming new targets arrive at the end */
kref_get(>reap_ref);
starget->reaped = true;
spin_unlock_irqrestore(shost->host_lock, flags);
-   if (last)
-   scsi_target_reap(last);
-   last = starget;
__scsi_remove_target(starget);
-   spin_lock_irqsave(shost->host_lock, flags);
+   scsi_target_reap(starget);
+   goto restart;
}
}
spin_unlock_irqrestore(shost->host_lock, flags);
-
-   if (last)
-   scsi_target_reap(last);
  }
  EXPORT_SYMBOL(scsi_remove_target);


(replying to my own e-mail)

Hello Christoph,

Is it OK for you if I mention you as author of this e-mail ?

Thanks,

Bart.


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/32] f2fs: prepare for bi_rw split

2015-11-04 Thread mchristi
From: Mike Christie 

This patch prepares f2fs's submit_bio use for the next
patches that split bi_rw into a operation and flags field.
Instead of passing in a bitmap with both the operation and
flags mixed in, the callers will now pass them in seperately.

This patch modifies the code related to the submit_bio calls
so the flags and operation are seperated. When this is done
for all code, one of the later patches in the series will
the actual submit_bio call, so the patches are bisectable.

Signed-off-by: Mike Christie 
---
 fs/f2fs/checkpoint.c|  6 --
 fs/f2fs/data.c  | 30 ++
 fs/f2fs/f2fs.h  |  5 +++--
 fs/f2fs/gc.c| 11 +++
 fs/f2fs/inline.c|  3 ++-
 fs/f2fs/node.c  | 10 ++
 fs/f2fs/segment.c   |  6 --
 fs/f2fs/trace.c |  8 +---
 include/trace/events/f2fs.h | 34 +-
 9 files changed, 70 insertions(+), 43 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index c5a38e3..ebab316 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -54,7 +54,8 @@ struct page *get_meta_page(struct f2fs_sb_info *sbi, pgoff_t 
index)
struct f2fs_io_info fio = {
.sbi = sbi,
.type = META,
-   .rw = READ_SYNC | REQ_META | REQ_PRIO,
+   .op = REQ_OP_READ,
+   .op_flags = READ_SYNC | REQ_META | REQ_PRIO,
.blk_addr = index,
.encrypted_page = NULL,
};
@@ -133,7 +134,8 @@ int ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, 
int nrpages, int type
struct f2fs_io_info fio = {
.sbi = sbi,
.type = META,
-   .rw = READ_SYNC | REQ_META | REQ_PRIO,
+   .op = REQ_OP_READ,
+   .op_flags = READ_SYNC | REQ_META | REQ_PRIO,
.encrypted_page = NULL,
};
 
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index a82abe9..fb767e4f 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -107,12 +107,12 @@ static void __submit_merged_bio(struct f2fs_bio_info *io)
if (!io->bio)
return;
 
-   if (is_read_io(fio->rw))
+   if (is_read_io(fio->op))
trace_f2fs_submit_read_bio(io->sbi->sb, fio, io->bio);
else
trace_f2fs_submit_write_bio(io->sbi->sb, fio, io->bio);
 
-   submit_bio(fio->rw, io->bio);
+   submit_bio(fio->op | fio->op_flags, io->bio);
io->bio = NULL;
 }
 
@@ -129,10 +129,12 @@ void f2fs_submit_merged_bio(struct f2fs_sb_info *sbi,
/* change META to META_FLUSH in the checkpoint procedure */
if (type >= META_FLUSH) {
io->fio.type = META_FLUSH;
+   io->fio.op = REQ_OP_WRITE;
if (test_opt(sbi, NOBARRIER))
-   io->fio.rw = WRITE_FLUSH | REQ_META | REQ_PRIO;
+   io->fio.op_flags = WRITE_FLUSH | REQ_META | REQ_PRIO;
else
-   io->fio.rw = WRITE_FLUSH_FUA | REQ_META | REQ_PRIO;
+   io->fio.op_flags = WRITE_FLUSH_FUA | REQ_META |
+   REQ_PRIO;
}
__submit_merged_bio(io);
up_write(>io_rwsem);
@@ -151,14 +153,14 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio)
f2fs_trace_ios(fio, 0);
 
/* Allocate a new bio */
-   bio = __bio_alloc(fio->sbi, fio->blk_addr, 1, is_read_io(fio->rw));
+   bio = __bio_alloc(fio->sbi, fio->blk_addr, 1, is_read_io(fio->op));
 
if (bio_add_page(bio, page, PAGE_CACHE_SIZE, 0) < PAGE_CACHE_SIZE) {
bio_put(bio);
return -EFAULT;
}
 
-   submit_bio(fio->rw, bio);
+   submit_bio(fio->op | fio->op_flags, bio);
return 0;
 }
 
@@ -167,7 +169,7 @@ void f2fs_submit_page_mbio(struct f2fs_io_info *fio)
struct f2fs_sb_info *sbi = fio->sbi;
enum page_type btype = PAGE_TYPE_OF_BIO(fio->type);
struct f2fs_bio_info *io;
-   bool is_read = is_read_io(fio->rw);
+   bool is_read = is_read_io(fio->op);
struct page *bio_page;
 
io = is_read ? >read_io : >write_io[btype];
@@ -180,7 +182,7 @@ void f2fs_submit_page_mbio(struct f2fs_io_info *fio)
inc_page_count(sbi, F2FS_WRITEBACK);
 
if (io->bio && (io->last_block_in_bio != fio->blk_addr - 1 ||
-   io->fio.rw != fio->rw))
+   io->fio.op != fio->op))
__submit_merged_bio(io);
 alloc_new:
if (io->bio == NULL) {
@@ -275,7 +277,8 @@ int f2fs_get_block(struct dnode_of_data *dn, pgoff_t index)
return f2fs_reserve_block(dn, index);
 }
 
-struct page *get_read_data_page(struct inode *inode, pgoff_t index, int rw)
+struct page *get_read_data_page(struct inode 

[PATCH 09/32] btrfs: prepare for bi_rw split

2015-11-04 Thread mchristi
From: Mike Christie 

This patch prepares btrfs's submit_bio use for the next
patches that split bi_rw into a operation and flags field.
Instead of passing in a bitmap with both the operation and
flags mixed in, the callers will now pass them in seperately.

This patch modifies the code related to the submit_bio calls
so the flags and operation are seperated. When this is done
for all code, one of the later patches in the series will
the actual submit_bio call, so the patches are bisectable.

Signed-off-by: Mike Christie 
---
 fs/btrfs/check-integrity.c |   6 +--
 fs/btrfs/check-integrity.h |   2 +-
 fs/btrfs/compression.c |   8 ++--
 fs/btrfs/ctree.h   |   3 +-
 fs/btrfs/disk-io.c |  48 +++--
 fs/btrfs/disk-io.h |   2 +-
 fs/btrfs/extent-tree.c |   2 +-
 fs/btrfs/extent_io.c   | 103 -
 fs/btrfs/extent_io.h   |   7 +--
 fs/btrfs/inode.c   |  65 ++--
 fs/btrfs/scrub.c   |   4 +-
 fs/btrfs/volumes.c |  88 --
 fs/btrfs/volumes.h |   4 +-
 13 files changed, 177 insertions(+), 165 deletions(-)

diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index fd50b2f..515a92e 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -3058,10 +3058,10 @@ leave:
mutex_unlock(_mutex);
 }
 
-void btrfsic_submit_bio(int rw, struct bio *bio)
+void btrfsic_submit_bio(int op, int op_flags, struct bio *bio)
 {
-   __btrfsic_submit_bio(rw, bio);
-   submit_bio(rw, bio);
+   __btrfsic_submit_bio(op | op_flags, bio);
+   submit_bio(op | op_flags, bio);
 }
 
 int btrfsic_submit_bio_wait(int op, int op_flags, struct bio *bio)
diff --git a/fs/btrfs/check-integrity.h b/fs/btrfs/check-integrity.h
index 13b0d54..a8edc424 100644
--- a/fs/btrfs/check-integrity.h
+++ b/fs/btrfs/check-integrity.h
@@ -21,7 +21,7 @@
 
 #ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
 int btrfsic_submit_bh(int rw, struct buffer_head *bh);
-void btrfsic_submit_bio(int rw, struct bio *bio);
+void btrfsic_submit_bio(int op, int op_flags, struct bio *bio);
 int btrfsic_submit_bio_wait(int op, int op_flags, struct bio *bio);
 #else
 #define btrfsic_submit_bh submit_bh
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 57ee8ca..a7b245d 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -401,7 +401,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 
start,
BUG_ON(ret); /* -ENOMEM */
}
 
-   ret = btrfs_map_bio(root, WRITE, bio, 0, 1);
+   ret = btrfs_map_bio(root, REQ_OP_WRITE, 0, bio, 0, 1);
BUG_ON(ret); /* -ENOMEM */
 
bio_put(bio);
@@ -431,7 +431,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 
start,
BUG_ON(ret); /* -ENOMEM */
}
 
-   ret = btrfs_map_bio(root, WRITE, bio, 0, 1);
+   ret = btrfs_map_bio(root, REQ_OP_WRITE, 0, bio, 0, 1);
BUG_ON(ret); /* -ENOMEM */
 
bio_put(bio);
@@ -692,7 +692,7 @@ int btrfs_submit_compressed_read(struct inode *inode, 
struct bio *bio,
sums += DIV_ROUND_UP(comp_bio->bi_iter.bi_size,
 root->sectorsize);
 
-   ret = btrfs_map_bio(root, READ, comp_bio,
+   ret = btrfs_map_bio(root, REQ_OP_READ, 0, comp_bio,
mirror_num, 0);
if (ret) {
bio->bi_error = ret;
@@ -722,7 +722,7 @@ int btrfs_submit_compressed_read(struct inode *inode, 
struct bio *bio,
BUG_ON(ret); /* -ENOMEM */
}
 
-   ret = btrfs_map_bio(root, READ, comp_bio, mirror_num, 0);
+   ret = btrfs_map_bio(root, REQ_OP_READ, 0, comp_bio, mirror_num, 0);
if (ret) {
bio->bi_error = ret;
bio_endio(comp_bio);
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 938efe3..e4489dd1 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3910,8 +3910,7 @@ int btrfs_create_subvol_root(struct btrfs_trans_handle 
*trans,
 struct btrfs_root *parent_root,
 u64 new_dirid);
 int btrfs_merge_bio_hook(int rw, struct page *page, unsigned long offset,
-size_t size, struct bio *bio,
-unsigned long bio_flags);
+size_t size, struct bio *bio, unsigned long bio_flags);
 int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf);
 int btrfs_readpage(struct file *file, struct page *page);
 void btrfs_evict_inode(struct inode *inode);
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 1e60d00..6c17d5d 100644
--- a/fs/btrfs/disk-io.c
+++ 

Re: [dm-devel] [PATCH 19/32] block: add helper to get data dir from op

2015-11-04 Thread Bart Van Assche

On 11/04/2015 02:08 PM, mchri...@redhat.com wrote:

From: Mike Christie 

In later patches the op will no longer be a bitmap, so we will
not have REQ_WRITE set for all non reads like discard, flush,
and write same. Drivers will still want to treat them as writes
for accounting reasons, so this patch adds a helper to translate
a op to a data direction.

Signed-off-by: Mike Christie 
---
  include/linux/blkdev.h | 12 
  1 file changed, 12 insertions(+)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 19c2e94..cf5f518 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -586,6 +586,18 @@ static inline void queue_flag_clear(unsigned int flag, 
struct request_queue *q)

  #define list_entry_rq(ptr)list_entry((ptr), struct request, queuelist)

+/*
+ * Non REQ_OP_WRITE requests like discard, write same, etc, are
+ * considered WRITEs.
+ */
+static inline int op_to_data_dir(int op)
+{
+   if (op == REQ_OP_READ)
+   return READ;
+   else
+   return WRITE;
+}
+
  #define rq_data_dir(rq)   ((int)((rq)->cmd_flags & 1))

  /*



How about introducing two functions - op_is_write() and op_is_read() ? I 
think that approach will result in shorter and easier to read code in 
the contexts where these functions are used.


Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] Restart list search after unlock in scsi_remove_target

2015-11-04 Thread James Bottomley
On Wed, 2015-11-04 at 14:35 -0800, Bart Van Assche wrote:
> On 10/30/2015 03:09 PM, Bart Van Assche wrote:
> > When dropping a lock while iterating a list we must restart the search
> > as other threads could have manipulated the list under us. Without this
> > we can get stuck in an endless loop.
> >
> > This is a slightly modified version of a patch from Christoph Hellwig
> > (see also https://www.spinics.net/lists/linux-scsi/msg89416.html).
> >
> > Reported-by: Johannes Thumshirn 
> > Signed-off-by: Bart Van Assche 
> > Cc: Johannes Thumshirn 
> > Cc: Christoph Hellwig 
> > Cc: Dan Williams 
> > Cc: stable 
> > ---
> >   drivers/scsi/scsi_sysfs.c | 16 
> >   1 file changed, 4 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> > index b9fb61a..5a183d1 100644
> > --- a/drivers/scsi/scsi_sysfs.c
> > +++ b/drivers/scsi/scsi_sysfs.c
> > @@ -1158,32 +1158,24 @@ static void __scsi_remove_target(struct scsi_target 
> > *starget)
> >   void scsi_remove_target(struct device *dev)
> >   {
> > struct Scsi_Host *shost = dev_to_shost(dev->parent);
> > -   struct scsi_target *starget, *last = NULL;
> > +   struct scsi_target *starget;
> > unsigned long flags;
> >
> > -   /* remove targets being careful to lookup next entry before
> > -* deleting the last
> > -*/
> > +restart:
> > spin_lock_irqsave(shost->host_lock, flags);
> > list_for_each_entry(starget, >__targets, siblings) {
> > if (starget->reaped)
> > continue;
> > if (starget->dev.parent == dev || >dev == dev) {
> > -   /* assuming new targets arrive at the end */
> > kref_get(>reap_ref);
> > starget->reaped = true;
> > spin_unlock_irqrestore(shost->host_lock, flags);
> > -   if (last)
> > -   scsi_target_reap(last);
> > -   last = starget;
> > __scsi_remove_target(starget);
> > -   spin_lock_irqsave(shost->host_lock, flags);
> > +   scsi_target_reap(starget);
> > +   goto restart;
> > }
> > }
> > spin_unlock_irqrestore(shost->host_lock, flags);
> > -
> > -   if (last)
> > -   scsi_target_reap(last);
> >   }
> >   EXPORT_SYMBOL(scsi_remove_target);
> 
> (replying to my own e-mail)
> 
> Hello Christoph,
> 
> Is it OK for you if I mention you as author of this e-mail ?

Could you just both co-operate, especially since there's not much
difference between the patches.

The fundamental problem with this is how have the conditions that caused
us to move away from list restart:

commit bc3f02a795d3b4faa99d37390174be2a75d091bd
Author: Dan Williams 
Date:   Tue Aug 28 22:12:10 2012 -0700

[SCSI] scsi_remove_target: fix softlockup regression on hot remove

Which was triggered by this bug report

http://thread.gmane.org/gmane.linux.kernel/1348679

been mitigated?

James


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 19/27] hpsa: move scsi_add_device and scsi_remove_device calls to new function

2015-11-04 Thread Don Brace
From: Kevin Barnett 

preparation for adding the sas transport class

Reviewed-by: Scott Teel 
Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Reviewed-by: Tomas Henzl 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Matthew R. Ochs 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   71 ---
 1 file changed, 45 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index c95ff8c..0af4c67 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1653,6 +1653,43 @@ static void hpsa_update_log_drive_phys_drive_ptrs(struct 
ctlr_info *h,
}
 }
 
+static int hpsa_add_device(struct ctlr_info *h, struct hpsa_scsi_dev_t *device)
+{
+   int rc = 0;
+
+   if (!h->scsi_host)
+   return 1;
+
+   rc = scsi_add_device(h->scsi_host, device->bus,
+   device->target, device->lun);
+   return rc;
+}
+
+static void hpsa_remove_device(struct ctlr_info *h,
+   struct hpsa_scsi_dev_t *device)
+{
+   struct scsi_device *sdev = NULL;
+
+   if (!h->scsi_host)
+   return;
+
+   sdev = scsi_device_lookup(h->scsi_host, device->bus,
+   device->target, device->lun);
+
+   if (sdev) {
+   scsi_remove_device(sdev);
+   scsi_device_put(sdev);
+   } else {
+   /*
+* We don't expect to get here.  Future commands
+* to this device will get a selection timeout as
+* if the device were gone.
+*/
+   hpsa_show_dev_msg(KERN_WARNING, h, device,
+   "didn't find device for removal.");
+   }
+}
+
 static void adjust_hpsa_scsi_table(struct ctlr_info *h,
struct hpsa_scsi_dev_t *sd[], int nsds)
 {
@@ -1665,7 +1702,6 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h,
unsigned long flags;
struct hpsa_scsi_dev_t **added, **removed;
int nadded, nremoved;
-   struct Scsi_Host *sh = NULL;
 
/*
 * A reset can cause a device status to change
@@ -1783,46 +1819,29 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h,
if (!changes)
goto free_and_out;
 
-   sh = h->scsi_host;
-   if (sh == NULL) {
-   dev_warn(>pdev->dev, "%s: scsi_host is null\n", __func__);
-   goto free_and_out;
-   }
/* Notify scsi mid layer of any removed devices */
for (i = 0; i < nremoved; i++) {
if (removed[i] == NULL)
continue;
-   if (removed[i]->expose_device) {
-   struct scsi_device *sdev =
-   scsi_device_lookup(sh, removed[i]->bus,
-   removed[i]->target, removed[i]->lun);
-   if (sdev != NULL) {
-   scsi_remove_device(sdev);
-   scsi_device_put(sdev);
-   } else {
-   /*
-* We don't expect to get here.
-* future cmds to this device will get selection
-* timeout as if the device was gone.
-*/
-   hpsa_show_dev_msg(KERN_WARNING, h, removed[i],
-   "didn't find device for removal.");
-   }
-   }
+   if (removed[i]->expose_device)
+   hpsa_remove_device(h, removed[i]);
kfree(removed[i]);
removed[i] = NULL;
}
 
/* Notify scsi mid layer of any added devices */
for (i = 0; i < nadded; i++) {
+   int rc = 0;
+
if (added[i] == NULL)
continue;
if (!(added[i]->expose_device))
continue;
-   if (scsi_add_device(sh, added[i]->bus,
-   added[i]->target, added[i]->lun) == 0)
+   rc = hpsa_add_device(h, added[i]);
+   if (!rc)
continue;
-   dev_warn(>pdev->dev, "addition failed, device not added.");
+   dev_warn(>pdev->dev,
+   "addition failed %d, device not added.", rc);
/* now we have to remove it from h->dev,
 * since it didn't get added to scsi mid layer
 */

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 20/27] hpsa: generalize external arrays

2015-11-04 Thread Don Brace
From: Scott Teel 

External array LUNs must use target and lun numbers assigned by the
external array. So the driver must treat these differently from
local LUNs when assigning lun/target.

LUN's 'model' field has been used to detect Lun types that need
special treatment, but the desire is to eliminate the need to reference
specific array models, and support any external array.

Pass-through RAID (PTRAID) luns are not luns of the local controller,
so they are not reported in LUN count of command 'ID controller'.
However, they ARE reported in "Report logical Luns" command.
Local luns are listed first, then PTRAID LUNs.

The number of luns from "Report LUNs" in excess of those reported by
'ID controller' are therefore the PTRAID LUNS.

We can now remove function is_ext_target, and the 'white list'
array of supported model names.

Reviewed-by: Scott Teel 
Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |  139 ++-
 drivers/scsi/hpsa.h |1 
 drivers/scsi/hpsa_cmd.h |   11 
 3 files changed, 125 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 0af4c67..1a67d63 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -275,7 +275,6 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info 
*h,
 static void hpsa_command_resubmit_worker(struct work_struct *work);
 static u32 lockup_detected(struct ctlr_info *h);
 static int detect_controller_lockup(struct ctlr_info *h);
-static int is_ext_target(struct ctlr_info *h, struct hpsa_scsi_dev_t *device);
 
 static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
 {
@@ -776,7 +775,7 @@ static ssize_t path_info_show(struct device *dev,
hdev->bus, hdev->target, hdev->lun,
scsi_device_type(hdev->devtype));
 
-   if (is_ext_target(h, hdev) ||
+   if (hdev->external ||
hdev->devtype == TYPE_RAID ||
is_logical_device(hdev)) {
output_len += snprintf(path[i] + output_len,
@@ -3034,6 +3033,35 @@ out:
return rc;
 }
 
+static int hpsa_bmic_id_controller(struct ctlr_info *h,
+   struct bmic_identify_controller *buf, size_t bufsize)
+{
+   int rc = IO_OK;
+   struct CommandList *c;
+   struct ErrorInfo *ei;
+
+   c = cmd_alloc(h);
+
+   rc = fill_cmd(c, BMIC_IDENTIFY_CONTROLLER, h, buf, bufsize,
+   0, RAID_CTLR_LUNID, TYPE_CMD);
+   if (rc)
+   goto out;
+
+   rc = hpsa_scsi_do_simple_cmd_with_retry(h, c,
+   PCI_DMA_FROMDEVICE, NO_TIMEOUT);
+   if (rc)
+   goto out;
+   ei = c->err_info;
+   if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) {
+   hpsa_scsi_interpret_error(h, c);
+   rc = -1;
+   }
+out:
+   cmd_free(h, c);
+   return rc;
+}
+
+
 static int hpsa_bmic_id_physical_device(struct ctlr_info *h,
unsigned char scsi3addr[], u16 bmic_device_index,
struct bmic_identify_physical_device *buf, size_t bufsize)
@@ -3510,27 +3538,6 @@ static void hpsa_update_device_supports_aborts(struct 
ctlr_info *h,
}
 }
 
-static unsigned char *ext_target_model[] = {
-   "MSA2012",
-   "MSA2024",
-   "MSA2312",
-   "MSA2324",
-   "P2000 G3 SAS",
-   "MSA 2040 SAS",
-   NULL,
-};
-
-static int is_ext_target(struct ctlr_info *h, struct hpsa_scsi_dev_t *device)
-{
-   int i;
-
-   for (i = 0; ext_target_model[i]; i++)
-   if (strncmp(device->model, ext_target_model[i],
-   strlen(ext_target_model[i])) == 0)
-   return 1;
-   return 0;
-}
-
 /*
  * Helper function to assign bus, target, lun mapping of devices.
  * Logical drive target and lun are assigned at this time, but
@@ -3554,7 +3561,7 @@ static void figure_bus_target_lun(struct ctlr_info *h,
return;
}
/* It's a logical device */
-   if (is_ext_target(h, device)) {
+   if (device->external) {
hpsa_set_bus_target_lun(device,
HPSA_EXTERNAL_RAID_VOLUME_BUS, (lunid >> 16) & 0x3fff,
lunid & 0x00ff);
@@ -3588,7 +3595,7 @@ static int add_ext_target_dev(struct ctlr_info *h,
if (!is_logical_dev_addr_mode(lunaddrbytes))
return 0; /* It's the logical targets that may lack lun 0. */
 
-   if (!is_ext_target(h, tmpdevice))
+   if (!tmpdevice->external)
return 0; /* Only external target devices have this problem. */
 
if (tmpdevice->lun == 0) /* if lun is 0, then we have a lun 0. */
@@ -3647,6 +3654,27 @@ static int hpsa_get_pdisk_of_ioaccel2(struct ctlr_info 
*h,
 

[PATCH v2 17/27] hpsa: enhance hpsa_get_device_id

2015-11-04 Thread Don Brace
use an index into vpd data for SAS/SATA drives

Reviewed-by: Scott Teel 
Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Reviewed-by: Tomas Henzl 
Reviewed-by: Matthew R. Ochs 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   23 ---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 21892c1..80d64ac 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3128,7 +3128,7 @@ out:
 
 /* Get the device id from inquiry page 0x83 */
 static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr,
-   unsigned char *device_id, int buflen)
+   unsigned char *device_id, int index, int buflen)
 {
int rc;
unsigned char *buf;
@@ -3140,8 +3140,10 @@ static int hpsa_get_device_id(struct ctlr_info *h, 
unsigned char *scsi3addr,
return -ENOMEM;
rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | 0x83, buf, 64);
if (rc == 0)
-   memcpy(device_id, [8], buflen);
+   memcpy(device_id, [index], buflen);
+
kfree(buf);
+
return rc != 0;
 }
 
@@ -3370,6 +3372,18 @@ static int hpsa_device_supports_aborts(struct ctlr_info 
*h,
return rc;
 }
 
+static void sanitize_inquiry_string(unsigned char *s, int len)
+{
+   bool terminated = false;
+
+   for (; len > 0; (--len, ++s)) {
+   if (*s == 0)
+   terminated = true;
+   if (terminated || *s < 0x20 || *s > 0x7e)
+   *s = ' ';
+   }
+}
+
 static int hpsa_update_device_info(struct ctlr_info *h,
unsigned char scsi3addr[], struct hpsa_scsi_dev_t *this_device,
unsigned char *is_OBDR_device)
@@ -3400,6 +3414,9 @@ static int hpsa_update_device_info(struct ctlr_info *h,
goto bail_out;
}
 
+   sanitize_inquiry_string(_buff[8], 8);
+   sanitize_inquiry_string(_buff[16], 16);
+
this_device->devtype = (inq_buff[0] & 0x1f);
memcpy(this_device->scsi3addr, scsi3addr, 8);
memcpy(this_device->vendor, _buff[8],
@@ -3408,7 +3425,7 @@ static int hpsa_update_device_info(struct ctlr_info *h,
sizeof(this_device->model));
memset(this_device->device_id, 0,
sizeof(this_device->device_id));
-   hpsa_get_device_id(h, scsi3addr, this_device->device_id,
+   hpsa_get_device_id(h, scsi3addr, this_device->device_id, 8,
sizeof(this_device->device_id));
 
if (this_device->devtype == TYPE_DISK &&

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 18/27] hpsa: refactor hpsa_figure_bus_target_lun

2015-11-04 Thread Don Brace
From: Kevin Barnett 

setup for sas transport. Need to set the
bus and target accordingly.

Reviewed-by: Scott Teel 
Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Reviewed-by: Hannes Reinecke 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   25 -
 drivers/scsi/hpsa.h |5 +
 2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 80d64ac..c95ff8c 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3512,38 +3512,37 @@ static int is_ext_target(struct ctlr_info *h, struct 
hpsa_scsi_dev_t *device)
return 0;
 }
 
-/* Helper function to assign bus, target, lun mapping of devices.
- * Puts non-external target logical volumes on bus 0, external target logical
- * volumes on bus 1, physical devices on bus 2. and the hba on bus 3.
+/*
+ * Helper function to assign bus, target, lun mapping of devices.
  * Logical drive target and lun are assigned at this time, but
  * physical device lun and target assignment are deferred (assigned
  * in hpsa_find_target_lun, called by hpsa_scsi_add_entry.)
- */
+*/
 static void figure_bus_target_lun(struct ctlr_info *h,
u8 *lunaddrbytes, struct hpsa_scsi_dev_t *device)
 {
-   u32 lunid = le32_to_cpu(*((__le32 *) lunaddrbytes));
+   u32 lunid = get_unaligned_le32(lunaddrbytes);
 
if (!is_logical_dev_addr_mode(lunaddrbytes)) {
/* physical device, target and lun filled in later */
if (is_hba_lunid(lunaddrbytes))
-   hpsa_set_bus_target_lun(device, 3, 0, lunid & 0x3fff);
+   hpsa_set_bus_target_lun(device,
+   HPSA_HBA_BUS, 0, lunid & 0x3fff);
else
/* defer target, lun assignment for physical devices */
-   hpsa_set_bus_target_lun(device, 2, -1, -1);
+   hpsa_set_bus_target_lun(device,
+   HPSA_PHYSICAL_DEVICE_BUS, -1, -1);
return;
}
/* It's a logical device */
if (is_ext_target(h, device)) {
-   /* external target way, put logicals on bus 1
-* and match target/lun numbers box
-* reports, other smart array, bus 0, target 0, match lunid
-*/
hpsa_set_bus_target_lun(device,
-   1, (lunid >> 16) & 0x3fff, lunid & 0x00ff);
+   HPSA_EXTERNAL_RAID_VOLUME_BUS, (lunid >> 16) & 0x3fff,
+   lunid & 0x00ff);
return;
}
-   hpsa_set_bus_target_lun(device, 0, 0, lunid & 0x3fff);
+   hpsa_set_bus_target_lun(device, HPSA_RAID_VOLUME_BUS,
+   0, lunid & 0x3fff);
 }
 
 /*
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index 50e4780..a4cab12 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -367,6 +367,11 @@ struct offline_device_entry {
 #define IOACCEL2_INBOUND_POSTQ_64_LOW  0xd0
 #define IOACCEL2_INBOUND_POSTQ_64_HI   0xd4
 
+#define HPSA_PHYSICAL_DEVICE_BUS   0
+#define HPSA_RAID_VOLUME_BUS   1
+#define HPSA_EXTERNAL_RAID_VOLUME_BUS  2
+#define HPSA_HBA_BUS   3
+
 /*
Send the command to the hardware
 */

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 10/27] hpsa: fix hpsa_adjust_hpsa_scsi_table

2015-11-04 Thread Don Brace
Fix a NULL pointer issue in the driver when devices are removed
during a reset.

Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   16 
 drivers/scsi/hpsa.h |1 +
 2 files changed, 17 insertions(+)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index ae9968b..382cb5d 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1663,6 +1663,15 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h,
int nadded, nremoved;
struct Scsi_Host *sh = NULL;
 
+   /*
+* A reset can cause a device status to change
+* re-schedule the scan to see what happened.
+*/
+   if (h->reset_in_progress) {
+   h->drv_req_rescan = 1;
+   return;
+   }
+
added = kzalloc(sizeof(*added) * HPSA_MAX_DEVICES, GFP_KERNEL);
removed = kzalloc(sizeof(*removed) * HPSA_MAX_DEVICES, GFP_KERNEL);
 
@@ -1771,6 +1780,10 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h,
goto free_and_out;
 
sh = h->scsi_host;
+   if (sh == NULL) {
+   dev_warn(>pdev->dev, "%s: scsi_host is null\n", __func__);
+   goto free_and_out;
+   }
/* Notify scsi mid layer of any removed devices */
for (i = 0; i < nremoved; i++) {
if (removed[i] == NULL)
@@ -5234,12 +5247,15 @@ static int hpsa_eh_device_reset_handler(struct 
scsi_cmnd *scsicmd)
 
hpsa_show_dev_msg(KERN_WARNING, h, dev, "resetting");
 
+   h->reset_in_progress = 1;
+
/* send a reset to the SCSI LUN which the command was sent to */
rc = hpsa_do_reset(h, dev, dev->scsi3addr, HPSA_RESET_TYPE_LUN,
   DEFAULT_REPLY_QUEUE);
snprintf(msg, sizeof(msg), "reset %s",
 rc == 0 ? "completed successfully" : "failed");
hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
+   h->reset_in_progress = 0;
return rc == 0 ? SUCCESS : FAILED;
 }
 
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index b173c0e..dc113c1a 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -271,6 +271,7 @@ struct ctlr_info {
wait_queue_head_t abort_cmd_wait_queue;
wait_queue_head_t event_sync_wait_queue;
struct mutex reset_mutex;
+   u8 reset_in_progress;
 };
 
 struct offline_device_entry {

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 03/27] hpsa: remove unused hpsa_tag_discard_error_bits

2015-11-04 Thread Don Brace
This function is no longer used.

Reviewed-by: Tomas Henzl 
Reviewed-by: Hannes Reinecke 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 4085401..5a996273 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -230,6 +230,7 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct 
ctlr_info *h,
int cmd_type);
 static void hpsa_free_cmd_pool(struct ctlr_info *h);
 #define VPD_PAGE (1 << 8)
+#define HPSA_SIMPLE_ERROR_BITS 0x03
 
 static int hpsa_scsi_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd);
 static void hpsa_scan_start(struct Scsi_Host *);
@@ -6436,16 +6437,6 @@ static inline void finish_cmd(struct CommandList *c)
complete(c->waiting);
 }
 
-
-static inline u32 hpsa_tag_discard_error_bits(struct ctlr_info *h, u32 tag)
-{
-#define HPSA_PERF_ERROR_BITS ((1 << DIRECT_LOOKUP_SHIFT) - 1)
-#define HPSA_SIMPLE_ERROR_BITS 0x03
-   if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
-   return tag & ~HPSA_SIMPLE_ERROR_BITS;
-   return tag & ~HPSA_PERF_ERROR_BITS;
-}
-
 /* process completion of an indexed ("direct lookup") command */
 static inline void process_indexed_cmd(struct ctlr_info *h,
u32 raw_tag)

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 02/27] hpsa: stop zeroing reset_cmds_out and ioaccel_cmds_out during rescan

2015-11-04 Thread Don Brace
pulling the rug out from under the reset handler
likewise for ioaccel_cmds_out

Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 815dc7f..4085401 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3671,8 +3671,6 @@ static void hpsa_get_ioaccel_drive_info(struct ctlr_info 
*h,
DRIVE_CMDS_RESERVED_FOR_FW;
else
dev->queue_depth = DRIVE_QUEUE_DEPTH; /* conservative */
-   atomic_set(>ioaccel_cmds_out, 0);
-   atomic_set(>reset_cmds_out, 0);
 }
 
 static void hpsa_get_path_info(struct hpsa_scsi_dev_t *this_device,

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 08/27] hpsa: abandon rescans on memory alloaction failures.

2015-11-04 Thread Don Brace
Abandon and reschedule rescan process only if device inquiries
fail due to mem alloc failures, which are likely to occur for
all devices.

Otherwise, skip device if inquiry fails for other reasons,
and continue rescanning process for other devices.

Reviewed-by: Scott Teel 
Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Reviewed-by: Tomas Henzl 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   24 +++-
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index f010b8e..ce0341a 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3366,10 +3366,13 @@ static int hpsa_update_device_info(struct ctlr_info *h,
 
unsigned char *inq_buff;
unsigned char *obdr_sig;
+   int rc = 0;
 
inq_buff = kzalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL);
-   if (!inq_buff)
+   if (!inq_buff) {
+   rc = -ENOMEM;
goto bail_out;
+   }
 
/* Do an inquiry to the device to see what it is. */
if (hpsa_scsi_do_inquiry(h, scsi3addr, 0, inq_buff,
@@ -3377,6 +3380,7 @@ static int hpsa_update_device_info(struct ctlr_info *h,
/* Inquiry failed (msg printed already) */
dev_err(>pdev->dev,
"hpsa_update_device_info: inquiry failed\n");
+   rc = -EIO;
goto bail_out;
}
 
@@ -3426,7 +3430,7 @@ static int hpsa_update_device_info(struct ctlr_info *h,
 
 bail_out:
kfree(inq_buff);
-   return 1;
+   return rc;
 }
 
 static void hpsa_update_device_supports_aborts(struct ctlr_info *h,
@@ -3794,6 +3798,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h)
n_ext_target_devs = 0;
for (i = 0; i < nphysicals + nlogicals + 1; i++) {
u8 *lunaddrbytes, is_OBDR = 0;
+   int rc = 0;
 
/* Figure out where the LUN ID info is coming from */
lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position,
@@ -3806,11 +3811,20 @@ static void hpsa_update_scsi_devices(struct ctlr_info 
*h)
continue;
 
/* Get device type, vendor, model, device id */
-   if (hpsa_update_device_info(h, lunaddrbytes, tmpdevice,
-   _OBDR)) {
+   rc = hpsa_update_device_info(h, lunaddrbytes, tmpdevice,
+   _OBDR);
+   if (rc == -ENOMEM) {
+   dev_warn(>pdev->dev,
+   "Out of memory, rescan deferred.\n");
h->drv_req_rescan = 1;
-   continue; /* skip it if we can't talk to it. */
+   goto out;
}
+   if (rc) {
+   dev_warn(>pdev->dev,
+   "Inquiry failed, skipping device.\n");
+   continue;
+   }
+
figure_bus_target_lun(h, lunaddrbytes, tmpdevice);
hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
this_device = currentsd[ncurrent];

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 05/27] hpsa: check for null arguments to dev_printk

2015-11-04 Thread Don Brace
Check for NULLs.

Reviewed-by: Tomas Henzl 
Reviewed-by: Manoj Kumar 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 5a996273..b64913f 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1138,6 +1138,9 @@ static int hpsa_find_target_lun(struct ctlr_info *h,
 static inline void hpsa_show_dev_msg(const char *level, struct ctlr_info *h,
struct hpsa_scsi_dev_t *dev, char *description)
 {
+   if (h == NULL || h->pdev == NULL || h->scsi_host == NULL)
+   return;
+
dev_printk(level, >pdev->dev,
"scsi %d:%d:%d:%d: %s %s %.8s %.16s RAID-%s 
SSDSmartPathCap%c En%c Exp=%d\n",
h->scsi_host->host_no, dev->bus, dev->target, dev->lun,

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 09/27] hpsa: correct transfer length for 6 byte read/write commands

2015-11-04 Thread Don Brace
handle block counts of 0. Cleanup block and block count calculations.

Reviewed-by: Scott Teel 
Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Reviewed-by: Tomas Henzl 
Reviewed-by: Hannes Reinecke 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   19 ++-
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index ce0341a..ae9968b 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -4012,19 +4012,14 @@ static int fixup_ioaccel_cdb(u8 *cdb, int *cdb_len)
case READ_6:
case READ_12:
if (*cdb_len == 6) {
-   block = (((u32) cdb[2]) << 8) | cdb[3];
+   block = get_unaligned_be16([2]);
block_cnt = cdb[4];
+   if (block_cnt == 0)
+   block_cnt = 256;
} else {
BUG_ON(*cdb_len != 12);
-   block = (((u32) cdb[2]) << 24) |
-   (((u32) cdb[3]) << 16) |
-   (((u32) cdb[4]) << 8) |
-   cdb[5];
-   block_cnt =
-   (((u32) cdb[6]) << 24) |
-   (((u32) cdb[7]) << 16) |
-   (((u32) cdb[8]) << 8) |
-   cdb[9];
+   block = get_unaligned_be32([2]);
+   block_cnt = get_unaligned_be32([6]);
}
if (block_cnt > 0x)
return IO_ACCEL_INELIGIBLE;
@@ -4410,9 +4405,7 @@ static int hpsa_scsi_ioaccel_raid_map(struct ctlr_info *h,
case WRITE_6:
is_write = 1;
case READ_6:
-   first_block =
-   (((u64) cmd->cmnd[2]) << 8) |
-   cmd->cmnd[3];
+   first_block = get_unaligned_be16(>cmnd[2]);
block_cnt = cmd->cmnd[4];
if (block_cnt == 0)
block_cnt = 256;

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 07/27] hpsa: allow driver requested rescans

2015-11-04 Thread Don Brace
Reviewed-by: Scott Teel 
Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Reviewed-by: Tomas Henzl 
Reviewed-by; Hannes Reinecke 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   17 +++--
 drivers/scsi/hpsa.h |1 +
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 4468166..f010b8e 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1810,6 +1810,7 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h,
 * since it didn't get added to scsi mid layer
 */
fixup_botched_add(h, added[i]);
+   h->drv_req_rescan = 1;
}
 
 free_and_out:
@@ -3751,9 +3752,13 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h)
}
memset(lunzerobits, 0, sizeof(lunzerobits));
 
+   h->drv_req_rescan = 0; /* cancel scheduled rescan - we're doing it. */
+
if (hpsa_gather_lun_info(h, physdev_list, ,
-   logdev_list, ))
+   logdev_list, )) {
+   h->drv_req_rescan = 1;
goto out;
+   }
 
/* We might see up to the maximum number of logical and physical disks
 * plus external target devices, and a device for the local RAID
@@ -3774,6 +3779,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h)
if (!currentsd[i]) {
dev_warn(>pdev->dev, "out of memory at %s:%d\n",
__FILE__, __LINE__);
+   h->drv_req_rescan = 1;
goto out;
}
ndev_allocated++;
@@ -3801,8 +3807,10 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h)
 
/* Get device type, vendor, model, device id */
if (hpsa_update_device_info(h, lunaddrbytes, tmpdevice,
-   _OBDR))
+   _OBDR)) {
+   h->drv_req_rescan = 1;
continue; /* skip it if we can't talk to it. */
+   }
figure_bus_target_lun(h, lunaddrbytes, tmpdevice);
hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
this_device = currentsd[ncurrent];
@@ -7862,6 +7870,11 @@ static void hpsa_ack_ctlr_events(struct ctlr_info *h)
  */
 static int hpsa_ctlr_needs_rescan(struct ctlr_info *h)
 {
+   if (h->drv_req_rescan) {
+   h->drv_req_rescan = 0;
+   return 1;
+   }
+
if (!(h->fw_support & MISC_FW_EVENT_NOTIFY))
return 0;
 
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index d6c4ebf..b173c0e 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -262,6 +262,7 @@ struct ctlr_info {
spinlock_t offline_device_lock;
struct list_head offline_device_list;
int acciopath_status;
+   int drv_req_rescan;
int raid_offload_debug;
int needs_abort_tags_swizzled;
struct workqueue_struct *resubmit_wq;

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 11/27] hpsa: fix physical target reset

2015-11-04 Thread Don Brace
From: Scott Teel 

Set reset type in device_reset_handler to do either
logical unit reset for logical devices, or physical
target reset, for physical devices.

Reviewed-by: Scott Teel 
Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Reviewed-by: Tomas Henzl 
Reviewed-by: Hannes Reinecke 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   34 --
 drivers/scsi/hpsa.h |1 +
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 382cb5d..1607b6d 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -2737,9 +2737,8 @@ static int hpsa_send_reset(struct ctlr_info *h, unsigned 
char *scsi3addr,
 
 
/* fill_cmd can't fail here, no data buffer to map. */
-   (void) fill_cmd(c, HPSA_DEVICE_RESET_MSG, h, NULL, 0, 0,
+   (void) fill_cmd(c, reset_type, h, NULL, 0, 0,
scsi3addr, TYPE_MSG);
-   c->Request.CDB[1] = reset_type; /* fill_cmd defaults to LUN reset */
rc = hpsa_scsi_do_simple_cmd(h, c, reply_queue, NO_TIMEOUT);
if (rc) {
dev_warn(>pdev->dev, "Failed to send reset command\n");
@@ -5207,6 +5206,7 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd 
*scsicmd)
int rc;
struct ctlr_info *h;
struct hpsa_scsi_dev_t *dev;
+   u8 reset_type;
char msg[48];
 
/* find the controller to which the command to be aborted was sent */
@@ -5245,15 +5245,23 @@ static int hpsa_eh_device_reset_handler(struct 
scsi_cmnd *scsicmd)
if (is_hba_lunid(dev->scsi3addr))
return SUCCESS;
 
-   hpsa_show_dev_msg(KERN_WARNING, h, dev, "resetting");
+   if (is_logical_dev_addr_mode(dev->scsi3addr))
+   reset_type = HPSA_DEVICE_RESET_MSG;
+   else
+   reset_type = HPSA_PHYS_TARGET_RESET;
+
+   sprintf(msg, "resetting %s",
+   reset_type == HPSA_DEVICE_RESET_MSG ? "logical " : "physical ");
+   hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
 
h->reset_in_progress = 1;
 
/* send a reset to the SCSI LUN which the command was sent to */
-   rc = hpsa_do_reset(h, dev, dev->scsi3addr, HPSA_RESET_TYPE_LUN,
+   rc = hpsa_do_reset(h, dev, dev->scsi3addr, reset_type,
   DEFAULT_REPLY_QUEUE);
-   snprintf(msg, sizeof(msg), "reset %s",
-rc == 0 ? "completed successfully" : "failed");
+   sprintf(msg, "reset %s %s",
+   reset_type == HPSA_DEVICE_RESET_MSG ? "logical " : "physical ",
+   rc == 0 ? "completed successfully" : "failed");
hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
h->reset_in_progress = 0;
return rc == 0 ? SUCCESS : FAILED;
@@ -6370,6 +6378,20 @@ static int fill_cmd(struct CommandList *c, u8 cmd, 
struct ctlr_info *h,
} else if (cmd_type == TYPE_MSG) {
switch (cmd) {
 
+   case  HPSA_PHYS_TARGET_RESET:
+   c->Request.CDBLen = 16;
+   c->Request.type_attr_dir =
+   TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_NONE);
+   c->Request.Timeout = 0; /* Don't time out */
+   memset(>Request.CDB[0], 0, sizeof(c->Request.CDB));
+   c->Request.CDB[0] = HPSA_RESET;
+   c->Request.CDB[1] = HPSA_TARGET_RESET_TYPE;
+   /* Physical target reset needs no control bytes 4-7*/
+   c->Request.CDB[4] = 0x00;
+   c->Request.CDB[5] = 0x00;
+   c->Request.CDB[6] = 0x00;
+   c->Request.CDB[7] = 0x00;
+   break;
case  HPSA_DEVICE_RESET_MSG:
c->Request.CDBLen = 16;
c->Request.type_attr_dir =
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index dc113c1a..04f98eb 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -285,6 +285,7 @@ struct offline_device_entry {
 #define HPSA_RESET_TYPE_BUS 0x01
 #define HPSA_RESET_TYPE_TARGET 0x03
 #define HPSA_RESET_TYPE_LUN 0x04
+#define HPSA_PHYS_TARGET_RESET 0x99 /* not defined by cciss spec */
 #define HPSA_MSG_SEND_RETRY_LIMIT 10
 #define HPSA_MSG_SEND_RETRY_INTERVAL_MSECS (1)
 

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] st: trivial: remove form feed characters

2015-11-04 Thread James Bottomley
On Wed, 2015-11-04 at 23:04 +0200, "Kai Mäkisara (Kolumbus)" wrote:
> > On 4.11.2015, at 11.52, Maurizio Lombardi  wrote:
> > 
> > Signed-off-by: Maurizio Lombardi 
> > ---
> > drivers/scsi/st.c | 24 
> > 1 file changed, 8 insertions(+), 16 deletions(-)
> > 
> > diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
> > index b37b9b0..7c4e518 100644
> > --- a/drivers/scsi/st.c
> > +++ b/drivers/scsi/st.c
> > @@ -226,7 +226,6 @@ static DEFINE_SPINLOCK(st_use_lock);
> > static DEFINE_IDR(st_index_idr);
> > 
> > 
> > -
> 
> What’s the point? Is there an “official” rule that form feeds are not allowed 
> (to
> put different things to different pages in printout)?

No, no official rule.  If you want to keep the form feed, that's fine,
we won't apply this patch.

James


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 32/32] block: remove __REQ op defs and reduce bi_op/bi_rw sizes

2015-11-04 Thread mchristi
From: Mike Christie 

This patches removes the __REQ/REQ definitions for operations
now defined by REQ_OPs.

There is now no need for bi_rw to be a long, so this makes it a
int. I also moved the priority to its own field, but I guess I could
have just kept this in the bi_rw since there is only 16 bio related
REQ_XYZ flags.

bi_op is also no longer a bitmap, so it only needs to be a u8/char,
so that is changed too.

This is more of a RFC patch, because I still need to update the rest
of the block layer code that was treating bi_rw as a long and I can
also shrink the request->cmd_flags.

I was not sure if or how much or where people wanted to stick things.
There also appears to be room in the bi_flags field. If bi_flags is
only using 13 bits and there are only 16 REQ_XYZs bits related bios,
I could put them all in one variable if we wanted to go wild with trying
to shrink the bio while I am at it..

Signed-off-by: Mike Christie 
---
 include/linux/bio.h | 13 ++---
 include/linux/blk_types.h   | 23 ++-
 include/trace/events/f2fs.h |  1 -
 3 files changed, 8 insertions(+), 29 deletions(-)

diff --git a/include/linux/bio.h b/include/linux/bio.h
index 7cbad7a..34a20cf 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -44,18 +44,9 @@
 #define BIO_MAX_SIZE   (BIO_MAX_PAGES << PAGE_CACHE_SHIFT)
 #define BIO_MAX_SECTORS(BIO_MAX_SIZE >> 9)
 
-/*
- * upper 16 bits of bi_rw define the io priority of this bio
- */
-#define BIO_PRIO_SHIFT (8 * sizeof(unsigned long) - IOPRIO_BITS)
-#define bio_prio(bio)  ((bio)->bi_rw >> BIO_PRIO_SHIFT)
+#define bio_prio(bio)  (bio)->bi_ioprio
 #define bio_prio_valid(bio)ioprio_valid(bio_prio(bio))
-
-#define bio_set_prio(bio, prio)do {\
-   WARN_ON(prio >= (1 << IOPRIO_BITS));\
-   (bio)->bi_rw &= ((1UL << BIO_PRIO_SHIFT) - 1);  \
-   (bio)->bi_rw |= ((unsigned long) (prio) << BIO_PRIO_SHIFT); \
-} while (0)
+#define bio_set_prio(bio, prio)((bio)->bi_ioprio = prio)
 
 /*
  * various member access, note that bio_data should of course not be used
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 581d353..c32ae3c 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -48,14 +48,9 @@ struct bio {
struct block_device *bi_bdev;
unsigned intbi_flags;   /* status, command, etc */
int bi_error;
-   unsigned long   bi_rw;  /* bottom bits rq_flags_bits
-* top bits priority
-*/
-   /*
-* this will be a u8 in the next patches and bi_rw can be shrunk to
-* a u32. For compat in these transistional patches op is a int here.
-*/
-   int bi_op;  /* REQ_OP */
+   unsigned intbi_rw;  /* rq_flags_bits */
+   unsigned short  bi_ioprio;
+   u8  bi_op;  /* REQ_OP */
 
 
struct bvec_iterbi_iter;
@@ -151,7 +146,6 @@ struct bio {
  */
 enum rq_flag_bits {
/* common flags */
-   __REQ_WRITE,/* not set, read. set, write */
__REQ_FAILFAST_DEV, /* no driver retries of device errors */
__REQ_FAILFAST_TRANSPORT, /* no driver retries of transport errors */
__REQ_FAILFAST_DRIVER,  /* no driver retries of driver errors */
@@ -159,9 +153,7 @@ enum rq_flag_bits {
__REQ_SYNC, /* request is sync (sync write or read) */
__REQ_META, /* metadata io request */
__REQ_PRIO, /* boost priority in cfq */
-   __REQ_DISCARD,  /* request to discard sectors */
-   __REQ_SECURE,   /* secure discard (used with __REQ_DISCARD) */
-   __REQ_WRITE_SAME,   /* write same block many times */
+   __REQ_SECURE,   /* secure discard (used with REQ_OP_DISCARD) */
 
__REQ_NOIDLE,   /* don't anticipate more IO after this one */
__REQ_INTEGRITY,/* I/O includes block integrity payload */
@@ -198,15 +190,12 @@ enum rq_flag_bits {
__REQ_NR_BITS,  /* stops here */
 };
 
-#define REQ_WRITE  (1ULL << __REQ_WRITE)
 #define REQ_FAILFAST_DEV   (1ULL << __REQ_FAILFAST_DEV)
 #define REQ_FAILFAST_TRANSPORT (1ULL << __REQ_FAILFAST_TRANSPORT)
 #define REQ_FAILFAST_DRIVER(1ULL << __REQ_FAILFAST_DRIVER)
 #define REQ_SYNC   (1ULL << __REQ_SYNC)
 #define REQ_META   (1ULL << __REQ_META)
 #define REQ_PRIO   (1ULL << __REQ_PRIO)
-#define REQ_DISCARD(1ULL << __REQ_DISCARD)
-#define REQ_WRITE_SAME (1ULL << __REQ_WRITE_SAME)
 #define REQ_NOIDLE (1ULL << __REQ_NOIDLE)
 #define REQ_INTEGRITY  (1ULL << __REQ_INTEGRITY)

[PATCH 25/32] block: add operation field to request struct

2015-11-04 Thread mchristi
From: Mike Christie 

This patch adds field to the request to store the REQ_OP, and
has the block layer code set it up.

The next patches will modify the other drivers to get/test the
request->op field. We are still ORing the op into the cmd_flags.
When I am done with the conversion, that will be dropped.

Signed-off-by: Mike Christie 
---
 block/blk-core.c   | 50 --
 block/blk-flush.c  |  1 +
 block/blk-mq.c | 31 +--
 include/linux/blkdev.h |  1 +
 4 files changed, 47 insertions(+), 36 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index c8672f2..e625516 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -984,7 +984,8 @@ static struct io_context *rq_ioc(struct bio *bio)
 /**
  * __get_request - get a free request
  * @rl: request list to allocate from
- * @rw_flags: RW and SYNC flags
+ * @op: REQ_OP
+ * @op_flags: rq_flag_bits
  * @bio: bio to allocate request for (can be %NULL)
  * @gfp_mask: allocation mask
  *
@@ -995,21 +996,22 @@ static struct io_context *rq_ioc(struct bio *bio)
  * Returns ERR_PTR on failure, with @q->queue_lock held.
  * Returns request pointer on success, with @q->queue_lock *not held*.
  */
-static struct request *__get_request(struct request_list *rl, int rw_flags,
-struct bio *bio, gfp_t gfp_mask)
+static struct request *__get_request(struct request_list *rl, int op,
+int op_flags, struct bio *bio,
+gfp_t gfp_mask)
 {
struct request_queue *q = rl->q;
struct request *rq;
struct elevator_type *et = q->elevator->type;
struct io_context *ioc = rq_ioc(bio);
struct io_cq *icq = NULL;
-   const bool is_sync = rw_is_sync(rw_flags) != 0;
+   const bool is_sync = rw_is_sync(op | op_flags) != 0;
int may_queue;
 
if (unlikely(blk_queue_dying(q)))
return ERR_PTR(-ENODEV);
 
-   may_queue = elv_may_queue(q, rw_flags);
+   may_queue = elv_may_queue(q, op | op_flags);
if (may_queue == ELV_MQUEUE_NO)
goto rq_starved;
 
@@ -1053,7 +1055,7 @@ static struct request *__get_request(struct request_list 
*rl, int rw_flags,
 
/*
 * Decide whether the new request will be managed by elevator.  If
-* so, mark @rw_flags and increment elvpriv.  Non-zero elvpriv will
+* so, mark @op_flags and increment elvpriv.  Non-zero elvpriv will
 * prevent the current elevator from being destroyed until the new
 * request is freed.  This guarantees icq's won't be destroyed and
 * makes creating new ones safe.
@@ -1062,14 +1064,14 @@ static struct request *__get_request(struct 
request_list *rl, int rw_flags,
 * it will be created after releasing queue_lock.
 */
if (blk_rq_should_init_elevator(bio) && !blk_queue_bypass(q)) {
-   rw_flags |= REQ_ELVPRIV;
+   op_flags |= REQ_ELVPRIV;
q->nr_rqs_elvpriv++;
if (et->icq_cache && ioc)
icq = ioc_lookup_icq(ioc, q);
}
 
if (blk_queue_io_stat(q))
-   rw_flags |= REQ_IO_STAT;
+   op_flags |= REQ_IO_STAT;
spin_unlock_irq(q->queue_lock);
 
/* allocate and init request */
@@ -1079,10 +1081,11 @@ static struct request *__get_request(struct 
request_list *rl, int rw_flags,
 
blk_rq_init(q, rq);
blk_rq_set_rl(rq, rl);
-   rq->cmd_flags = rw_flags | REQ_ALLOCED;
+   rq->cmd_flags = op | op_flags | REQ_ALLOCED;
+   rq->op = op;
 
/* init elvpriv */
-   if (rw_flags & REQ_ELVPRIV) {
+   if (op_flags & REQ_ELVPRIV) {
if (unlikely(et->icq_cache && !icq)) {
if (ioc)
icq = ioc_create_icq(ioc, q, gfp_mask);
@@ -1108,7 +,7 @@ out:
if (ioc_batching(q, ioc))
ioc->nr_batch_requests--;
 
-   trace_block_getrq(q, bio, rw_flags & 1);
+   trace_block_getrq(q, bio, op);
return rq;
 
 fail_elvpriv:
@@ -1138,7 +1141,7 @@ fail_alloc:
 * queue, but this is pretty rare.
 */
spin_lock_irq(q->queue_lock);
-   freed_request(rl, rw_flags);
+   freed_request(rl, op | op_flags);
 
/*
 * in the very unlikely event that allocation failed and no
@@ -1156,7 +1159,8 @@ rq_starved:
 /**
  * get_request - get a free request
  * @q: request_queue to allocate request from
- * @rw_flags: RW and SYNC flags
+ * op: REQ_OP
+ * @op_flags: rq_flag_bits
  * @bio: bio to allocate request for (can be %NULL)
  * @gfp_mask: allocation mask
  *
@@ -1167,17 +1171,18 @@ rq_starved:
  * Returns ERR_PTR on failure, with @q->queue_lock held.
  * Returns request pointer on success, with @q->queue_lock *not held*.
  */
-static struct request 

[PATCH 21/32] bcache: set bi_op to REQ_OP

2015-11-04 Thread mchristi
From: Mike Christie 

This patch has bcache set the bi_op.

For compat reasons, we are still ORing the op into bi_rw. This
will be dropped in later patches in this series when everyone
is updated.

Signed-off-by: Mike Christie 
---
 drivers/md/bcache/btree.c |  2 ++
 drivers/md/bcache/journal.c   |  3 +++
 drivers/md/bcache/movinggc.c  |  1 +
 drivers/md/bcache/request.c   |  2 ++
 drivers/md/bcache/super.c | 24 ++--
 drivers/md/bcache/writeback.c |  2 ++
 6 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 83392f8..3be5b05 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -295,6 +295,7 @@ static void bch_btree_node_read(struct btree *b)
closure_init_stack();
 
bio = bch_bbio_alloc(b->c);
+   bio->bi_op  = REQ_OP_READ;
bio->bi_rw  = REQ_META|READ_SYNC;
bio->bi_iter.bi_size = KEY_SIZE(>key) << 9;
bio->bi_end_io  = btree_node_read_endio;
@@ -397,6 +398,7 @@ static void do_btree_node_write(struct btree *b)
 
b->bio->bi_end_io   = btree_node_write_endio;
b->bio->bi_private  = cl;
+   b->bio->bi_op   = REQ_OP_WRITE;
b->bio->bi_rw   = REQ_META|WRITE_SYNC|REQ_FUA;
b->bio->bi_iter.bi_size = roundup(set_bytes(i), block_bytes(b->c));
bch_bio_map(b->bio, i);
diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
index ba9192b..d152e78 100644
--- a/drivers/md/bcache/journal.c
+++ b/drivers/md/bcache/journal.c
@@ -54,6 +54,7 @@ reread:   left = ca->sb.bucket_size - offset;
bio_reset(bio);
bio->bi_iter.bi_sector  = bucket + offset;
bio->bi_bdev= ca->bdev;
+   bio->bi_op  = REQ_OP_READ;
bio->bi_rw  = READ;
bio->bi_iter.bi_size= len << 9;
 
@@ -452,6 +453,7 @@ static void do_journal_discard(struct cache *ca)
bio->bi_iter.bi_sector  = bucket_to_sector(ca->set,
ca->sb.d[ja->discard_idx]);
bio->bi_bdev= ca->bdev;
+   bio->bi_op  = REQ_OP_DISCARD;
bio->bi_rw  = REQ_WRITE|REQ_DISCARD;
bio->bi_max_vecs= 1;
bio->bi_io_vec  = bio->bi_inline_vecs;
@@ -626,6 +628,7 @@ static void journal_write_unlocked(struct closure *cl)
bio_reset(bio);
bio->bi_iter.bi_sector  = PTR_OFFSET(k, i);
bio->bi_bdev= ca->bdev;
+   bio->bi_op  = REQ_OP_WRITE;
bio->bi_rw  = REQ_WRITE|REQ_SYNC|REQ_META|REQ_FLUSH|REQ_FUA;
bio->bi_iter.bi_size = sectors << 9;
 
diff --git a/drivers/md/bcache/movinggc.c b/drivers/md/bcache/movinggc.c
index b929fc9..1318f32 100644
--- a/drivers/md/bcache/movinggc.c
+++ b/drivers/md/bcache/movinggc.c
@@ -163,6 +163,7 @@ static void read_moving(struct cache_set *c)
moving_init(io);
bio = >bio.bio;
 
+   bio->bi_op  = REQ_OP_READ;
bio->bi_rw  = READ;
bio->bi_end_io  = read_moving_endio;
 
diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
index 8e9877b..7a84f3b 100644
--- a/drivers/md/bcache/request.c
+++ b/drivers/md/bcache/request.c
@@ -253,6 +253,7 @@ static void bch_data_insert_start(struct closure *cl)
trace_bcache_cache_insert(k);
bch_keylist_push(>insert_keys);
 
+   n->bi_op = REQ_OP_WRITE;
n->bi_rw |= REQ_WRITE;
bch_submit_bbio(n, op->c, k, 0);
} while (n != bio);
@@ -925,6 +926,7 @@ static void cached_dev_write(struct cached_dev *dc, struct 
search *s)
struct bio *flush = bio_alloc_bioset(GFP_NOIO, 0,
 
dc->disk.bio_split);
 
+   flush->bi_op= REQ_OP_WRITE;
flush->bi_rw= WRITE_FLUSH;
flush->bi_bdev  = bio->bi_bdev;
flush->bi_end_io = request_endio;
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index a987c90..ccc6266 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -212,6 +212,7 @@ static void __write_super(struct cache_sb *sb, struct bio 
*bio)
unsigned i;
 
bio->bi_iter.bi_sector  = SB_SECTOR;
+   bio->bi_op  = 0;
bio->bi_rw  = REQ_SYNC|REQ_META;
bio->bi_iter.bi_size= SB_SIZE;
bch_bio_map(bio, NULL);
@@ -333,7 +334,7 @@ static void uuid_io_unlock(struct closure *cl)
up(>uuid_write_mutex);
 }
 
-static void uuid_io(struct cache_set *c, unsigned long rw,
+static void uuid_io(struct cache_set *c, int op, unsigned long op_flags,
 

[PATCH 20/32] md: set bi_op to REQ_OP

2015-11-04 Thread mchristi
From: Mike Christie 

This patch has md set the bi_op.

For compat reasons, we are still ORing the op into bi_rw. This
will be dropped in later patches in this series when everyone
is updated.

For discards, I am also still passing in REQ_WRITE in with the
flags, so code that has not yet been converted will work like
before. This will be cleaned up in later patches when everyone
is converted.

Signed-off-by: Mike Christie 
---
 drivers/md/raid1.c  |  9 +
 drivers/md/raid10.c | 13 +
 drivers/md/raid5.c  | 50 +++---
 3 files changed, 53 insertions(+), 19 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 527fdf5..94e5a63 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1051,6 +1051,7 @@ static void make_request(struct mddev *mddev, struct bio 
* bio)
int i, disks;
struct bitmap *bitmap;
unsigned long flags;
+   const int op = bio->bi_op;
const int rw = bio_data_dir(bio);
const unsigned long do_sync = (bio->bi_rw & REQ_SYNC);
const unsigned long do_flush_fua = (bio->bi_rw & (REQ_FLUSH | REQ_FUA));
@@ -1164,6 +1165,7 @@ read_again:
mirror->rdev->data_offset;
read_bio->bi_bdev = mirror->rdev->bdev;
read_bio->bi_end_io = raid1_end_read_request;
+   read_bio->bi_op = REQ_OP_READ;
read_bio->bi_rw = READ | do_sync;
read_bio->bi_private = r1_bio;
 
@@ -1374,6 +1376,7 @@ read_again:
   conf->mirrors[i].rdev->data_offset);
mbio->bi_bdev = conf->mirrors[i].rdev->bdev;
mbio->bi_end_io = raid1_end_write_request;
+   mbio->bi_op = op;
mbio->bi_rw =
WRITE | do_flush_fua | do_sync | do_discard | do_same;
mbio->bi_private = r1_bio;
@@ -2017,6 +2020,7 @@ static void sync_request_write(struct mddev *mddev, 
struct r1bio *r1_bio)
  !test_bit(MD_RECOVERY_SYNC, >recovery
continue;
 
+   wbio->bi_op = REQ_OP_WRITE;
wbio->bi_rw = WRITE;
wbio->bi_end_io = end_sync_write;
atomic_inc(_bio->remaining);
@@ -2188,6 +2192,7 @@ static int narrow_write_error(struct r1bio *r1_bio, int i)
wbio = bio_clone_mddev(r1_bio->master_bio, GFP_NOIO, 
mddev);
}
 
+   wbio->bi_op = REQ_OP_WRITE;
wbio->bi_rw = WRITE;
wbio->bi_iter.bi_sector = r1_bio->sector;
wbio->bi_iter.bi_size = r1_bio->sectors << 9;
@@ -2329,6 +2334,7 @@ read_more:
bio->bi_iter.bi_sector = r1_bio->sector + rdev->data_offset;
bio->bi_bdev = rdev->bdev;
bio->bi_end_io = raid1_end_read_request;
+   bio->bi_op  = REQ_OP_READ;
bio->bi_rw = READ | do_sync;
bio->bi_private = r1_bio;
if (max_sectors < r1_bio->sectors) {
@@ -2544,6 +2550,7 @@ static sector_t sync_request(struct mddev *mddev, 
sector_t sector_nr, int *skipp
if (i < conf->raid_disks)
still_degraded = 1;
} else if (!test_bit(In_sync, >flags)) {
+   bio->bi_op = REQ_OP_WRITE;
bio->bi_rw = WRITE;
bio->bi_end_io = end_sync_write;
write_targets ++;
@@ -2571,6 +2578,7 @@ static sector_t sync_request(struct mddev *mddev, 
sector_t sector_nr, int *skipp
if (disk < 0)
disk = i;
}
+   bio->bi_op = REQ_OP_READ;
bio->bi_rw = READ;
bio->bi_end_io = end_sync_read;
read_targets++;
@@ -2583,6 +2591,7 @@ static sector_t sync_request(struct mddev *mddev, 
sector_t sector_nr, int *skipp
 * if we are doing resync or repair. Otherwise, 
leave
 * this device alone for this sync request.
 */
+   bio->bi_op = REQ_OP_WRITE;
bio->bi_rw = WRITE;
bio->bi_end_io = end_sync_write;
write_targets++;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 69352a6..c7430f9 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1058,6 +1058,7 @@ static void __make_request(struct mddev *mddev, struct 
bio *bio)
struct r10bio *r10_bio;
struct bio *read_bio;
int i;
+   const int op = bio->bi_op;
const int rw = bio_data_dir(bio);
const unsigned long do_sync = 

[PATCH 13/32] mm: prepare for bi_rw split

2015-11-04 Thread mchristi
From: Mike Christie 

This patch prepares mm's submit_bio use for the next
patches that split bi_rw into a operation and flags field.
Instead of passing in a bitmap with both the operation and
flags mixed in, the callers will now pass them in seperately.

This patch modifies the code related to the submit_bio calls
so the flags and operation are seperated. When this is done
for all code, one of the later patches in the series will
the actual submit_bio call, so the patches are bisectable.

Signed-off-by: Mike Christie 
---
 mm/page_io.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index b995a5b..ec7ad22 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -253,7 +253,8 @@ int __swap_writepage(struct page *page, struct 
writeback_control *wbc,
bio_end_io_t end_write_func)
 {
struct bio *bio;
-   int ret, rw = WRITE;
+   int ret;
+   u32 op_flags = 0;
struct swap_info_struct *sis = page_swap_info(page);
 
if (sis->flags & SWP_FILE) {
@@ -312,11 +313,11 @@ int __swap_writepage(struct page *page, struct 
writeback_control *wbc,
goto out;
}
if (wbc->sync_mode == WB_SYNC_ALL)
-   rw |= REQ_SYNC;
+   op_flags |= REQ_SYNC;
count_vm_event(PSWPOUT);
set_page_writeback(page);
unlock_page(page);
-   submit_bio(rw, bio);
+   submit_bio(REQ_OP_WRITE | op_flags, bio);
 out:
return ret;
 }
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/32] block/fs/mm: pass in op and flags to submit_bio

2015-11-04 Thread mchristi
From: Mike Christie 

This patch prepares submit_bio callers for the next
patches that split bi_rw into a operation and flags field.
Instead of passing in a bitmap with both the operation and
flags mixed in, the callers now pass them in seperately.

Signed-off-by: Mike Christie 
---
 block/bio.c |  2 +-
 block/blk-core.c| 13 +++--
 block/blk-lib.c | 11 ---
 drivers/block/drbd/drbd_actlog.c|  2 +-
 drivers/block/drbd/drbd_bitmap.c|  2 +-
 drivers/block/floppy.c  |  2 +-
 drivers/block/xen-blkback/blkback.c |  2 +-
 drivers/block/xen-blkfront.c|  4 ++--
 drivers/md/bcache/journal.c |  2 +-
 drivers/md/bcache/super.c   |  2 +-
 drivers/md/dm-bufio.c   |  2 +-
 drivers/md/dm-io.c  |  2 +-
 drivers/md/dm-log-writes.c  |  6 +++---
 drivers/md/dm-thin.c|  2 +-
 drivers/md/md.c |  4 ++--
 drivers/target/target_core_iblock.c |  4 ++--
 fs/btrfs/check-integrity.c  |  2 +-
 fs/btrfs/raid56.c   | 10 +-
 fs/buffer.c |  7 ---
 fs/direct-io.c  |  2 +-
 fs/ext4/page-io.c   |  6 +++---
 fs/ext4/readpage.c  |  8 
 fs/f2fs/data.c  | 10 +-
 fs/gfs2/lops.c  |  2 +-
 fs/gfs2/ops_fstype.c|  2 +-
 fs/jfs/jfs_logmgr.c |  4 ++--
 fs/jfs/jfs_metapage.c   |  8 
 fs/logfs/dev_bdev.c |  8 
 fs/mpage.c  |  2 +-
 fs/nfs/blocklayout/blocklayout.c|  2 +-
 fs/nilfs2/segbuf.c  |  2 +-
 fs/ocfs2/cluster/heartbeat.c|  4 ++--
 fs/xfs/xfs_aops.c   |  3 ++-
 fs/xfs/xfs_buf.c|  2 +-
 include/linux/fs.h  |  2 +-
 kernel/power/swap.c |  2 +-
 mm/page_io.c|  4 ++--
 37 files changed, 81 insertions(+), 73 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index 610c704..ae91ccb 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -873,7 +873,7 @@ int submit_bio_wait(int op, int flags, struct bio *bio)
init_completion();
bio->bi_private = 
bio->bi_end_io = submit_bio_wait_endio;
-   submit_bio(op | flags | REQ_SYNC, bio);
+   submit_bio(op, flags | REQ_SYNC, bio);
wait_for_completion();
 
return ret.error;
diff --git a/block/blk-core.c b/block/blk-core.c
index 18e92a6..d325ece 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1976,7 +1976,8 @@ EXPORT_SYMBOL(generic_make_request);
 
 /**
  * submit_bio - submit a bio to the block device layer for I/O
- * @rw: whether to %READ or %WRITE, or maybe to %READA (read ahead)
+ * @op: REQ_OP_*
+ * @flags: rq_flag_bits
  * @bio: The  bio which describes the I/O
  *
  * submit_bio() is very similar in purpose to generic_make_request(), and
@@ -1984,9 +1985,9 @@ EXPORT_SYMBOL(generic_make_request);
  * interfaces; @bio must be presetup and ready for I/O.
  *
  */
-void submit_bio(int rw, struct bio *bio)
+void submit_bio(int op, int flags, struct bio *bio)
 {
-   bio->bi_rw |= rw;
+   bio->bi_rw |= op | flags;
 
/*
 * If it's a regular read/write or a barrier with data attached,
@@ -1995,12 +1996,12 @@ void submit_bio(int rw, struct bio *bio)
if (bio_has_data(bio)) {
unsigned int count;
 
-   if (unlikely(rw & REQ_WRITE_SAME))
+   if (unlikely(op == REQ_WRITE_SAME))
count = bdev_logical_block_size(bio->bi_bdev) >> 9;
else
count = bio_sectors(bio);
 
-   if (rw & WRITE) {
+   if (op == REQ_OP_WRITE) {
count_vm_events(PGPGOUT, count);
} else {
task_io_account_read(bio->bi_iter.bi_size);
@@ -2011,7 +2012,7 @@ void submit_bio(int rw, struct bio *bio)
char b[BDEVNAME_SIZE];
printk(KERN_DEBUG "%s(%d): %s block %Lu on %s (%u 
sectors)\n",
current->comm, task_pid_nr(current),
-   (rw & WRITE) ? "WRITE" : "READ",
+   bio_rw(bio) ? "WRITE" : "READ",
(unsigned long long)bio->bi_iter.bi_sector,
bdevname(bio->bi_bdev, b),
count);
diff --git a/block/blk-lib.c b/block/blk-lib.c
index 0861c7a..49786b0 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -109,7 +109,7 @@ int blkdev_issue_discard(struct block_device *bdev, 
sector_t sector,
sector = end_sect;
 
atomic_inc();
-   submit_bio(op | op_flags, bio);
+   submit_bio(op, op_flags, bio);
 
/*

[PATCH 16/32] block/fs/md: pass in op and flags to submit_bh

2015-11-04 Thread mchristi
From: Mike Christie 

This patch prepares submit_bh callers for the next
patches that split bi_rw into a operation and flags field.
Instead of passing in a bitmap with both the operation and
flags mixed in, the callers now pass them in seperately.

Signed-off-by: Mike Christie 
---
 drivers/md/bitmap.c |  4 ++--
 fs/btrfs/check-integrity.c  |  4 ++--
 fs/buffer.c | 52 ++---
 fs/ext4/balloc.c|  2 +-
 fs/ext4/ialloc.c|  2 +-
 fs/ext4/inode.c |  2 +-
 fs/ext4/mmp.c   |  4 ++--
 fs/ext4/super.c |  2 +-
 fs/fat/misc.c   |  2 +-
 fs/gfs2/bmap.c  |  2 +-
 fs/gfs2/dir.c   |  2 +-
 fs/gfs2/meta_io.c   |  8 +++
 fs/jbd2/commit.c|  7 +++---
 fs/jbd2/journal.c   |  8 +++
 fs/nilfs2/btnode.c  |  6 +++---
 fs/nilfs2/btnode.h  |  2 +-
 fs/nilfs2/btree.c   |  6 --
 fs/nilfs2/gcinode.c |  5 +++--
 fs/nilfs2/mdt.c | 11 +-
 fs/nilfs2/super.c   |  4 ++--
 fs/ntfs/aops.c  |  6 +++---
 fs/ntfs/compress.c  |  2 +-
 fs/ntfs/file.c  |  2 +-
 fs/ntfs/logfile.c   |  2 +-
 fs/ntfs/mft.c   |  4 ++--
 fs/ocfs2/buffer_head_io.c   |  8 +++
 fs/reiserfs/inode.c |  4 ++--
 fs/reiserfs/journal.c   | 12 ++-
 fs/ufs/util.c   |  2 +-
 include/linux/buffer_head.h |  9 
 30 files changed, 97 insertions(+), 89 deletions(-)

diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 48b5890..9070ee8 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -299,7 +299,7 @@ static void write_page(struct bitmap *bitmap, struct page 
*page, int wait)
atomic_inc(>pending_writes);
set_buffer_locked(bh);
set_buffer_mapped(bh);
-   submit_bh(WRITE | REQ_SYNC, bh);
+   submit_bh(REQ_OP_WRITE, REQ_SYNC, bh);
bh = bh->b_this_page;
}
 
@@ -394,7 +394,7 @@ static int read_page(struct file *file, unsigned long index,
atomic_inc(>pending_writes);
set_buffer_locked(bh);
set_buffer_mapped(bh);
-   submit_bh(READ, bh);
+   submit_bh(REQ_OP_READ, 0, bh);
}
block++;
bh = bh->b_this_page;
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 17eba2d..9cb367f0 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -2908,7 +2908,7 @@ int btrfsic_submit_bh(int op, int op_flags, struct 
buffer_head *bh)
struct btrfsic_dev_state *dev_state;
 
if (!btrfsic_is_initialized)
-   return submit_bh(op | op_flags, bh);
+   return submit_bh(op, op_flags, bh);
 
mutex_lock(_mutex);
/* since btrfsic_submit_bh() might also be called before
@@ -2964,7 +2964,7 @@ int btrfsic_submit_bh(int op, int op_flags, struct 
buffer_head *bh)
}
}
mutex_unlock(_mutex);
-   return submit_bh(op | op_flags, bh);
+   return submit_bh(op, op_flags, bh);
 }
 
 static void __btrfsic_submit_bio(int op, int op_flags, struct bio *bio)
diff --git a/fs/buffer.c b/fs/buffer.c
index a190c25..cd07d86 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -45,7 +45,7 @@
 #include 
 
 static int fsync_buffers_list(spinlock_t *lock, struct list_head *list);
-static int submit_bh_wbc(int rw, struct buffer_head *bh,
+static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh,
 unsigned long bio_flags,
 struct writeback_control *wbc);
 
@@ -1236,7 +1236,7 @@ static struct buffer_head *__bread_slow(struct 
buffer_head *bh)
} else {
get_bh(bh);
bh->b_end_io = end_buffer_read_sync;
-   submit_bh(READ, bh);
+   submit_bh(REQ_OP_READ, 0, bh);
wait_on_buffer(bh);
if (buffer_uptodate(bh))
return bh;
@@ -1708,7 +1708,7 @@ static int __block_write_full_page(struct inode *inode, 
struct page *page,
struct buffer_head *bh, *head;
unsigned int blocksize, bbits;
int nr_underway = 0;
-   int write_op = (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE);
+   int write_flags = (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC: 0);
 
head = create_page_buffers(page, inode,
(1 << BH_Dirty)|(1 << BH_Uptodate));
@@ -1797,7 +1797,7 @@ static int __block_write_full_page(struct inode *inode, 
struct page *page,
do {
struct buffer_head *next = bh->b_this_page;
if (buffer_async_write(bh)) {
-   

[PATCH 12/32] xfs: prepare for bi_rw split

2015-11-04 Thread mchristi
From: Mike Christie 

This patch prepares xfs's submit_bio use for the next
patches that split bi_rw into a operation and flags field.
Instead of passing in a bitmap with both the operation and
flags mixed in, the callers will now pass them in seperately.

This patch modifies the code related to the submit_bio calls
so the flags and operation are seperated. When this is done
for all code, one of the later patches in the series will
the actual submit_bio call, so the patches are bisectable.

Signed-off-by: Mike Christie 
---
 fs/xfs/xfs_buf.c | 26 ++
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 8ecffb3..0621d70 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1123,7 +1123,8 @@ xfs_buf_ioapply_map(
int map,
int *buf_offset,
int *count,
-   int rw)
+   int op,
+   int op_flags)
 {
int page_index;
int total_nr_pages = bp->b_page_count;
@@ -1186,7 +1187,7 @@ next_chunk:
flush_kernel_vmap_range(bp->b_addr,
xfs_buf_vmap_len(bp));
}
-   submit_bio(rw, bio);
+   submit_bio(op | op_flags, bio);
if (size)
goto next_chunk;
} else {
@@ -1206,7 +1207,8 @@ _xfs_buf_ioapply(
struct xfs_buf  *bp)
 {
struct blk_plug plug;
-   int rw;
+   int op;
+   int op_flags = 0;
int offset;
int size;
int i;
@@ -1225,14 +1227,13 @@ _xfs_buf_ioapply(
bp->b_ioend_wq = bp->b_target->bt_mount->m_buf_workqueue;
 
if (bp->b_flags & XBF_WRITE) {
+   op = REQ_OP_WRITE;
if (bp->b_flags & XBF_SYNCIO)
-   rw = WRITE_SYNC;
-   else
-   rw = WRITE;
+   op_flags = WRITE_SYNC;
if (bp->b_flags & XBF_FUA)
-   rw |= REQ_FUA;
+   op_flags |= REQ_FUA;
if (bp->b_flags & XBF_FLUSH)
-   rw |= REQ_FLUSH;
+   op_flags |= REQ_FLUSH;
 
/*
 * Run the write verifier callback function if it exists. If
@@ -1262,13 +1263,14 @@ _xfs_buf_ioapply(
}
}
} else if (bp->b_flags & XBF_READ_AHEAD) {
-   rw = READA;
+   op = REQ_OP_READ;
+   op_flags = REQ_RAHEAD;
} else {
-   rw = READ;
+   op = REQ_OP_READ;
}
 
/* we only use the buffer cache for meta-data */
-   rw |= REQ_META;
+   op_flags |= REQ_META;
 
/*
 * Walk all the vectors issuing IO on them. Set up the initial offset
@@ -1280,7 +1282,7 @@ _xfs_buf_ioapply(
size = BBTOB(bp->b_io_length);
blk_start_plug();
for (i = 0; i < bp->b_map_count; i++) {
-   xfs_buf_ioapply_map(bp, i, , , rw);
+   xfs_buf_ioapply_map(bp, i, , , op, op_flags);
if (bp->b_error)
break;
if (size <= 0)
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/32] btrfs: prepare for bi_rw split

2015-11-04 Thread mchristi
From: Mike Christie 

This patch prepares btrfs's submit_bh use for the next
patches that split bi_rw into a operation and flags field.
Instead of passing in a bitmap with both the operation and
flags mixed in, the callers will now pass them in seperately.

This patch modifies the code related to the submit_bh calls
so the flags and operation are seperated. When this is done
for all code, one of the later patches in the series will
the actual submit_bh call, so the patches are bisectable.

Signed-off-by: Mike Christie 
---
 fs/btrfs/check-integrity.c | 68 ++
 fs/btrfs/check-integrity.h |  2 +-
 fs/btrfs/disk-io.c |  4 +--
 3 files changed, 41 insertions(+), 33 deletions(-)

diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index a5ff6e4..17eba2d 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -168,7 +168,8 @@ struct btrfsic_block {
bio_end_io_t *bio;
bh_end_io_t *bh;
} orig_bio_bh_end_io;
-   int submit_bio_bh_rw;
+   int submit_bio_bh_op;
+   int submit_bio_bh_op_flags;
u64 flush_gen; /* only valid if !never_written */
 };
 
@@ -338,7 +339,8 @@ static void btrfsic_process_written_block(struct 
btrfsic_dev_state *dev_state,
  unsigned int num_pages,
  struct bio *bio, int *bio_is_patched,
  struct buffer_head *bh,
- int submit_bio_bh_rw);
+ int submit_bio_bh_op,
+ int submit_bio_bh_op_flags);
 static int btrfsic_process_written_superblock(
struct btrfsic_state *state,
struct btrfsic_block *const block,
@@ -418,7 +420,8 @@ static void btrfsic_block_init(struct btrfsic_block *b)
INIT_LIST_HEAD(>all_blocks_node);
INIT_LIST_HEAD(>ref_to_list);
INIT_LIST_HEAD(>ref_from_list);
-   b->submit_bio_bh_rw = 0;
+   b->submit_bio_bh_op = 0;
+   b->submit_bio_bh_op_flags = 0;
b->flush_gen = 0;
 }
 
@@ -1820,7 +1823,8 @@ static void btrfsic_process_written_block(struct 
btrfsic_dev_state *dev_state,
  unsigned int num_pages,
  struct bio *bio, int *bio_is_patched,
  struct buffer_head *bh,
- int submit_bio_bh_rw)
+ int submit_bio_bh_op,
+ int submit_bio_bh_op_flags)
 {
int is_metadata;
struct btrfsic_block *block;
@@ -2038,7 +2042,8 @@ again:
}
 
block->flush_gen = dev_state->last_flush_gen + 1;
-   block->submit_bio_bh_rw = submit_bio_bh_rw;
+   block->submit_bio_bh_op = submit_bio_bh_op;
+   block->submit_bio_bh_op_flags = submit_bio_bh_op_flags;
if (is_metadata) {
block->logical_bytenr = bytenr;
block->is_metadata = 1;
@@ -2141,7 +2146,8 @@ again:
block->iodone_w_error = 0;
block->mirror_num = 0;  /* unknown */
block->flush_gen = dev_state->last_flush_gen + 1;
-   block->submit_bio_bh_rw = submit_bio_bh_rw;
+   block->submit_bio_bh_op = submit_bio_bh_op;
+   block->submit_bio_bh_op_flags = submit_bio_bh_op_flags;
if (NULL != bio) {
block->is_iodone = 0;
BUG_ON(NULL == bio_is_patched);
@@ -2236,7 +2242,7 @@ static void btrfsic_bio_end_io(struct bio *bp)
   block->dev_bytenr, block->mirror_num);
next_block = block->next_in_same_bio;
block->iodone_w_error = iodone_w_error;
-   if (block->submit_bio_bh_rw & REQ_FLUSH) {
+   if (block->submit_bio_bh_op_flags & REQ_FLUSH) {
dev_state->last_flush_gen++;
if ((dev_state->state->print_mask &
 BTRFSIC_PRINT_MASK_END_IO_BIO_BH))
@@ -2245,7 +2251,7 @@ static void btrfsic_bio_end_io(struct bio *bp)
   dev_state->name,
   dev_state->last_flush_gen);
}
-   if (block->submit_bio_bh_rw & REQ_FUA)
+   if (block->submit_bio_bh_op_flags & REQ_FUA)
block->flush_gen = 0; /* FUA completed means block is
   * on disk */
block->is_iodone = 1; /* for FLUSH, this releases the block */
@@ -2272,7 +2278,7 @@ static void btrfsic_bh_end_io(struct buffer_head *bh, int 
uptodate)
   

[PATCH 17/32] block: add operation field to bio struct

2015-11-04 Thread mchristi
From: Mike Christie 

This patch adds field to the bio to store the REQ_OP, and it
has the block layer code set it.

The next patches will modify the other drivers and filesystems
to also set the bi_op. We are still ORing the op into the bi_rw.
When I am done with the conversion, that will be dropped.

Signed-off-by: Mike Christie 
---
 block/bio.c   | 11 +--
 block/blk-core.c  |  1 +
 block/blk-map.c   |  4 +++-
 include/linux/blk_types.h |  8 +++-
 4 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index ae91ccb..1cf8428 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -582,6 +582,7 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src)
bio->bi_bdev = bio_src->bi_bdev;
bio_set_flag(bio, BIO_CLONED);
bio->bi_rw = bio_src->bi_rw;
+   bio->bi_op = bio_src->bi_op;
bio->bi_iter = bio_src->bi_iter;
bio->bi_io_vec = bio_src->bi_io_vec;
 }
@@ -664,6 +665,7 @@ struct bio *bio_clone_bioset(struct bio *bio_src, gfp_t 
gfp_mask,
 
bio->bi_bdev= bio_src->bi_bdev;
bio->bi_rw  = bio_src->bi_rw;
+   bio->bi_op  = bio_src->bi_op;
bio->bi_iter.bi_sector  = bio_src->bi_iter.bi_sector;
bio->bi_iter.bi_size= bio_src->bi_iter.bi_size;
 
@@ -1168,8 +1170,10 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
if (!bio)
goto out_bmd;
 
-   if (iter->type & WRITE)
+   if (iter->type & WRITE) {
bio->bi_rw |= REQ_WRITE;
+   bio->bi_op = REQ_OP_WRITE;
+   }
 
ret = 0;
 
@@ -1338,8 +1342,10 @@ struct bio *bio_map_user_iov(struct request_queue *q,
/*
 * set data direction, and check if mapped pages need bouncing
 */
-   if (iter->type & WRITE)
+   if (iter->type & WRITE) {
bio->bi_rw |= REQ_WRITE;
+   bio->bi_op = REQ_OP_WRITE;
+   }
 
bio_set_flag(bio, BIO_USER_MAPPED);
 
@@ -1533,6 +1539,7 @@ struct bio *bio_copy_kern(struct request_queue *q, void 
*data, unsigned int len,
} else {
bio->bi_end_io = bio_copy_kern_endio;
bio->bi_rw |= REQ_WRITE;
+   bio->bi_op = REQ_OP_WRITE;
}
 
return bio;
diff --git a/block/blk-core.c b/block/blk-core.c
index d325ece..c8672f2 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1988,6 +1988,7 @@ EXPORT_SYMBOL(generic_make_request);
 void submit_bio(int op, int flags, struct bio *bio)
 {
bio->bi_rw |= op | flags;
+   bio->bi_op = op;
 
/*
 * If it's a regular read/write or a barrier with data attached,
diff --git a/block/blk-map.c b/block/blk-map.c
index f565e11..4a91dc4 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -223,8 +223,10 @@ int blk_rq_map_kern(struct request_queue *q, struct 
request *rq, void *kbuf,
if (IS_ERR(bio))
return PTR_ERR(bio);
 
-   if (!reading)
+   if (!reading) {
bio->bi_rw |= REQ_WRITE;
+   bio->bi_op = REQ_OP_WRITE;
+   }
 
if (do_copy)
rq->cmd_flags |= REQ_COPY_USER;
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index d7b6009..b974aea 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -48,9 +48,15 @@ struct bio {
struct block_device *bi_bdev;
unsigned intbi_flags;   /* status, command, etc */
int bi_error;
-   unsigned long   bi_rw;  /* bottom bits READ/WRITE,
+   unsigned long   bi_rw;  /* bottom bits rq_flags_bits
 * top bits priority
 */
+   /*
+* this will be a u8 in the next patches and bi_rw can be shrunk to
+* a u32. For compat in these transistional patches op is a int here.
+*/
+   int bi_op;  /* REQ_OP */
+
 
struct bvec_iterbi_iter;
 
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 3/3] ibmvscsi: Allow to configure maximum LUN

2015-11-04 Thread Brian King
On 11/04/2015 07:02 AM, Hannes Reinecke wrote:
> On 11/04/2015 12:46 PM, Laurent Vivier wrote:
>>
>>
>> On 04/11/2015 12:16, Hannes Reinecke wrote:
>>> On 11/04/2015 11:20 AM, Laurent Vivier wrote:
 QEMU allows until 32 LUNs.

 Signed-off-by: Laurent Vivier 
 ---
  drivers/scsi/ibmvscsi/ibmvscsi.c | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

 diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c 
 b/drivers/scsi/ibmvscsi/ibmvscsi.c
 index 04de287..4480d3e 100644
 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c
 +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
 @@ -84,6 +84,7 @@
   */
  static int max_id = 64;
  static int max_channel = 3;
 +static int max_lun = 8;
  static int init_timeout = 300;
  static int login_timeout = 60;
  static int info_timeout = 30;
 @@ -117,6 +118,8 @@ module_param_named(fast_fail, fast_fail, int, S_IRUGO 
 | S_IWUSR);
  MODULE_PARM_DESC(fast_fail, "Enable fast fail. [Default=1]");
  module_param_named(client_reserve, client_reserve, int, S_IRUGO );
  MODULE_PARM_DESC(client_reserve, "Attempt client managed 
 reserve/release");
 +module_param(max_lun, int, S_IRUGO);
 +MODULE_PARM_DESC(max_lun, "Maximum LUN value [Default=8]");
  
  static void ibmvscsi_handle_crq(struct viosrp_crq *crq,
struct ibmvscsi_host_data *hostdata);
 @@ -2289,7 +2292,7 @@ static int ibmvscsi_probe(struct vio_dev *vdev, 
 const struct vio_device_id *id)
goto init_pool_failed;
}
  
 -  host->max_lun = 8;
 +  host->max_lun = max_lun;
host->max_id = max_id;
host->max_channel = max_channel;
host->max_cmd_len = 16;

>>> Please, don't do this.
>>>
>>> 'max_lun' should only be set if the HBA / transport has some hard
>>> limitations on the number of bytes it can use.
>>> Otherwise the scanning algorithm in scsi_scan.c should do the
>>> correct thing, independent on the 'max_lun' setting.
>>
>> So you are saying we can remove the line ?
>>
> Ho-hum. In principle you could, as ibmvscsi is using SRP internally,
> which does support 64 bit LUNs.
> 
> However, due to some weird design decisions there is
> the function 'lun_from_dev()', which mangles the incoming LUN number
> into something ... else.
> Which leaves only 4 bits free for the actual LUN number, requiring
> you to use max_lun = 16.
> 
> Personally I would just do away with that function and use the
> incoming LUN numbers as is.

I pulled out my copy of SAM, what lun_from_dev is doing is translating
the incoming bus / id / LUN to a LUN in the logical unit addressing format,
as defined in 4.6.9 of SAM-4.

--
|Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
--
| n  | (10b) |   Target  |
--
| n+1|   Bus |LUN|
--

So this means, in the current implementation, we have 6 bits for target 
(max=63),
3 bits for bus (max=7), and 5 bits for LUN (max=31). 

It might not be a bad idea to enforce these limits on the module parameters. 
Otherwise
we'll have a mess when we run through lun_from_dev...

As far as eliminating lun_from_dev and just passing the LUN through, I don't 
think we
can do that. The LUN list returned by Report LUNs to a VSCSI disk assumes we are
doing the translation above.

-Brian

-- 
Brian King
Power Linux I/O
IBM Linux Technology Center

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] Restart list search after unlock in scsi_remove_target

2015-11-04 Thread Bart Van Assche

On 11/04/2015 02:44 PM, James Bottomley wrote:

On Wed, 2015-11-04 at 14:35 -0800, Bart Van Assche wrote:

(replying to my own e-mail)

Hello Christoph,

Is it OK for you if I mention you as author of this e-mail ?


Could you just both co-operate, especially since there's not much
difference between the patches.


Hello James and Christoph,

Patch [2/2] is identical to the patch Christoph had posted except that 
it has been rebased on top of patch [1/2] of this series. I will be 
happy to step back if Christoph or someone else wants to take the lead 
here. The only reason I started looking into this is that there was no 
further progress on the original e-mail thread about this subject 
(http://thread.gmane.org/gmane.linux.kernel/2052359).


Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/4] Fix performance burning or extracting audio etc. from multiple optical drives.

2015-11-04 Thread Wakko Warner
Tim Small wrote:
> Fix performance burning or extracting audio etc. from multiple optical
> drives.

I know this is a bit late and is still not in 4.3.  I applied 2 of the
patches.  I did not apply the ide-cd, the paride nor the gdrom since I don't
have any of those.

> Patches are against 3.18.0-rc6+

I had to make some modifications to the patch for sr.c since it has changed
since.  cdrom.[ch] worked verbatim.

I tested on a system with 3 drives.  ejecting all drives didn't happen at
the same time, but I think it's because they are different brands and one
didn't have a disc in.  I did notice the leds coming on about the same time
though.  eject -t on all drives happened at the same time.

The patch I used previously on 3.3.0 removed all mutex_lock and mutex_unlock
lines from sr.c where as this patchset didn't.  I plan on trying to burn 3
dvds to see if it works.

Thanks for your work on the patches.

-- 
 Microsoft has beaten Volkswagen's world record.  Volkswagen only created 22
 million bugs.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re:linux-scsi在干吗:(AD)

2015-11-04 Thread 57702
linux-scsi
【天猫】尊敬的淘宝会员,您获得了进群资格,邀请您进QQ群号24662898进群验证码89群内每天抢免单秒杀活动,天天免费红包 退订回T 































































































































































































































































































































































































































































































































































































































































































































































































跂石聊长啸!留伞荔镜记选曲;长沙针毛蕨“玛蒂。精英会员:连续气举设备。邦爱比特!容量性质”沁水龙蛇走?企业注册局,微粒学说:浅灰色哥特式纹身;津津小吃“黑果拨毒散?令影像更为清晰,异乡文学,法语市场推广专员!更得上燕台”费伊心力;滤毒通风”大箱体波动“城口附地菜!古来于异域:軟體研發處:用户建筑群网络“穷泉朽壤!雷矛卫队,中纪委,酷鸟英汉字典
 2.1“樟木乡;车一平六;

[PATCH 2/4] scsi: mpt3sas: try 64 bit DMA when 32 bit DMA fails

2015-11-04 Thread Sinan Kaya
Current code gives up when 32 bit DMA is not supported.
This patch tests 64 bit support before bailing out in
such conditions.

Signed-off-by: Sinan Kaya 
---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
b/drivers/scsi/mpt3sas/mpt3sas_base.c
index d4f1dcd..6dc391c 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -1535,9 +1535,29 @@ _base_config_dma_addressing(struct MPT3SAS_ADAPTER *ioc, 
struct pci_dev *pdev)
ioc->base_add_sg_single = &_base_add_sg_single_32;
ioc->sge_size = sizeof(Mpi2SGESimple32_t);
ioc->dma_mask = 32;
-   } else
+   } else {
+   /* Try 64 bit, 32 bit failed */
+   consistent_dma_mask = DMA_BIT_MASK(64);
+   if (sizeof(dma_addr_t) > 4) {
+   const uint64_t required_mask =
+   dma_get_required_mask(>dev);
+   int consistent_mask =
+   pci_set_consistent_dma_mask(pdev,
+   consistent_dma_mask);
+
+   if ((required_mask > DMA_BIT_MASK(32)) &&
+   !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) &&
+   !consistent_mask) {
+   ioc->base_add_sg_single =
+   &_base_add_sg_single_64;
+   ioc->sge_size = sizeof(Mpi2SGESimple64_t);
+   ioc->dma_mask = 64;
+   goto out;
+   }
+   }
return -ENODEV;
 
+   }
  out:
si_meminfo();
pr_info(MPT3SAS_FMT
-- 
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] scsi: mptxsas: offload IRQ execution

2015-11-04 Thread Sinan Kaya
The mpt2sas and mpt3sas drivers are spinning
forever in their IRQ handlers if there is a lot
of job queued up by the PCIe card. This handler is
causing spikes for the rest of the system and
sluggish behavior.

Marking all MSI interrupts as non-shared and
moving the MSI interrupts to thread context.
This relexes the rest of the system execution.

Signed-off-by: Sinan Kaya 
---
 drivers/scsi/mpt2sas/mpt2sas_base.c | 13 +
 drivers/scsi/mpt3sas/mpt3sas_base.c | 14 ++
 2 files changed, 19 insertions(+), 8 deletions(-)
 mode change 100644 => 100755 drivers/scsi/mpt3sas/mpt3sas_base.c

diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c 
b/drivers/scsi/mpt2sas/mpt2sas_base.c
index c61c82a..ee2aead 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -1359,14 +1359,19 @@ _base_request_irq(struct MPT2SAS_ADAPTER *ioc, u8 
index, u32 vector)
cpumask_clear(reply_q->affinity_hint);
 
atomic_set(_q->busy, 0);
-   if (ioc->msix_enable)
+   if (ioc->msix_enable) {
snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d-msix%d",
MPT2SAS_DRIVER_NAME, ioc->id, index);
-   else
+   r = request_threaded_irq(vector, NULL, _base_interrupt,
+IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+reply_q->name, reply_q);
+   }
+   else {
snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d",
MPT2SAS_DRIVER_NAME, ioc->id);
-   r = request_irq(vector, _base_interrupt, IRQF_SHARED, reply_q->name,
-   reply_q);
+   r = request_irq(vector, _base_interrupt, IRQF_SHARED,
+   reply_q->name, reply_q);
+   }
if (r) {
printk(MPT2SAS_ERR_FMT "unable to allocate interrupt %d!\n",
reply_q->name, vector);
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
b/drivers/scsi/mpt3sas/mpt3sas_base.c
old mode 100644
new mode 100755
index 6dc391c..c29f359
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -1661,14 +1661,20 @@ _base_request_irq(struct MPT3SAS_ADAPTER *ioc, u8 
index, u32 vector)
cpumask_clear(reply_q->affinity_hint);
 
atomic_set(_q->busy, 0);
-   if (ioc->msix_enable)
+   if (ioc->msix_enable) {
snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d-msix%d",
MPT3SAS_DRIVER_NAME, ioc->id, index);
-   else
+
+   r = request_threaded_irq(vector, NULL, _base_interrupt,
+IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+reply_q->name, reply_q);
+   }
+   else {
snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d",
MPT3SAS_DRIVER_NAME, ioc->id);
-   r = request_irq(vector, _base_interrupt, IRQF_SHARED, reply_q->name,
-   reply_q);
+   r = request_irq(vector, _base_interrupt, IRQF_SHARED,
+   reply_q->name, reply_q);
+   }
if (r) {
pr_err(MPT3SAS_FMT "unable to allocate interrupt %d!\n",
reply_q->name, vector);
-- 
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] scsi: fix compiler warning for sg

2015-11-04 Thread Sinan Kaya
The MULDIV macro has been designed for small
numbers. It emits an overflow warning on 64 bit
systems. This patch places type casts in the
parameters to fix the compiler warning.

Signed-off-by: Sinan Kaya 
---
 drivers/scsi/sg.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 9d7b7db..eb2739d 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -88,7 +88,10 @@ static void sg_proc_cleanup(void);
  * Of course an overflow is inavoidable if the result of muldiv doesn't fit
  * in 32 bits.
  */
-#define MULDIV(X,MUL,DIV) X % DIV) * MUL) / DIV) + ((X / DIV) * MUL))
+static inline u64 MULDIV(u64 X, u32 MUL, u32 DIV)
+{
+   return X % DIV) * MUL) / DIV) + ((X / DIV) * MUL));
+}
 
 #define SG_DEFAULT_TIMEOUT MULDIV(SG_DEFAULT_TIMEOUT_USER, HZ, USER_HZ)
 
-- 
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] scsi: fix compiler warning for sg

2015-11-04 Thread kbuild test robot
Hi Sinan,

[auto build test ERROR on: scsi/for-next]
[also build test ERROR on: v4.3 next-20151104]

url:
https://github.com/0day-ci/linux/commits/Sinan-Kaya/scsi-mpt2sas-try-64-bit-DMA-when-32-bit-DMA-fails/20151105-125248
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: i386-defconfig (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/built-in.o: In function `sg_ioctl':
>> sg.c:(.text+0x1b680b): undefined reference to `__umoddi3'
>> sg.c:(.text+0x1b6829): undefined reference to `__udivdi3'
   sg.c:(.text+0x1b6849): undefined reference to `__udivdi3'

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH 3/4] scsi: fix compiler warning for sg

2015-11-04 Thread kbuild test robot
Hi Sinan,

[auto build test ERROR on: scsi/for-next]
[also build test ERROR on: v4.3 next-20151105]

url:
https://github.com/0day-ci/linux/commits/Sinan-Kaya/scsi-mpt2sas-try-64-bit-DMA-when-32-bit-DMA-fails/20151105-125248
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: powerpc-mpc8610_hpcd_defconfig (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=powerpc 

All errors (new ones prefixed by >>):

   drivers/built-in.o: In function `sg_ioctl':
>> drivers/scsi/sg.c:897: undefined reference to `__umoddi3'
>> drivers/scsi/sg.c:897: undefined reference to `__udivdi3'
>> drivers/scsi/sg.c:897: undefined reference to `__udivdi3'

vim +897 drivers/scsi/sg.c

^1da177e Linus Torvalds  2005-04-16  891return 
sfp->timeout_user;
^1da177e Linus Torvalds  2005-04-16  892case SG_SET_FORCE_LOW_DMA:
^1da177e Linus Torvalds  2005-04-16  893result = get_user(val, 
ip);
^1da177e Linus Torvalds  2005-04-16  894if (result)
^1da177e Linus Torvalds  2005-04-16  895return result;
^1da177e Linus Torvalds  2005-04-16  896if (val) {
^1da177e Linus Torvalds  2005-04-16 @897sfp->low_dma = 
1;
^1da177e Linus Torvalds  2005-04-16  898if ((0 == 
sfp->low_dma) && (0 == sg_res_in_use(sfp))) {
^1da177e Linus Torvalds  2005-04-16  899val = 
(int) sfp->reserve.bufflen;
95e159d6 Hannes Reinecke 2014-06-25  900
sg_remove_scat(sfp, >reserve);

:: The code at line 897 was first introduced by commit
:: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:: TO: Linus Torvalds 
:: CC: Linus Torvalds 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[PATCH 1/4] scsi: mpt2sas: try 64 bit DMA when 32 bit DMA fails

2015-11-04 Thread Sinan Kaya
Current code gives up when 32 bit DMA is not supported.
This patch tests 64 bit support before bailing out in
such conditions.

Signed-off-by: Sinan Kaya 
---
 drivers/scsi/mpt2sas/mpt2sas_base.c | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c 
b/drivers/scsi/mpt2sas/mpt2sas_base.c
index c167911..c61c82a 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -1217,8 +1217,27 @@ _base_config_dma_addressing(struct MPT2SAS_ADAPTER *ioc, 
struct pci_dev *pdev)
ioc->base_add_sg_single = &_base_add_sg_single_32;
ioc->sge_size = sizeof(Mpi2SGESimple32_t);
ioc->dma_mask = 32;
-   } else
+   } else {
+   /* Try 64 bit, 32 bit failed */
+   consistent_dma_mask = DMA_BIT_MASK(64);
+
+   if (sizeof(dma_addr_t) > 4) {
+   const uint64_t required_mask =
+   dma_get_required_mask(>dev);
+   if ((required_mask > DMA_BIT_MASK(32)) &&
+   !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) &&
+   !pci_set_consistent_dma_mask(pdev,
+   consistent_dma_mask)) {
+   ioc->base_add_sg_single =
+   &_base_add_sg_single_64;
+   ioc->sge_size = sizeof(Mpi2SGESimple64_t);
+   ioc->dma_mask = 64;
+   goto out;
+   }
+   }
+
return -ENODEV;
+   }
 
  out:
si_meminfo();
-- 
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[scsi:for-next 22/23] ERROR: "__udivdi3" [drivers/scsi/sg.ko] undefined!

2015-11-04 Thread kbuild test robot
Hi Alan,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
head:   a34a7cb8a7905606206559cd8d6605e5a72028e9
commit: b704f70ce2003c8046d5c0128303aeeb0d93d890 [22/23] SCSI: fix bug in 
scsi_dev_info_list matching
config: i386-randconfig-s0-201544 (attached as .config)
reproduce:
git checkout b704f70ce2003c8046d5c0128303aeeb0d93d890
# save the attached .config to linux build tree
make ARCH=i386 

Note: the scsi/for-next HEAD 5575a6ea316b3fa80dc316083c3fac59743ae1db builds 
fine.
  It only hurts bisectibility.

All errors (new ones prefixed by >>):

>> ERROR: "__udivdi3" [drivers/scsi/sg.ko] undefined!
>> ERROR: "__umoddi3" [drivers/scsi/sg.ko] undefined!

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[Bug 107221] New: file not opened

2015-11-04 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=107221

Bug ID: 107221
   Summary: file not opened
   Product: SCSI Drivers
   Version: 2.5
Kernel Version: 4.1.2
  Hardware: Sparc32
OS: Linux
  Tree: Fedora
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: DC390
  Assignee: linux-scsi@vger.kernel.org
  Reporter: swathics...@gmail.com
Regression: No

Created attachment 192151
  --> https://bugzilla.kernel.org/attachment.cgi?id=192151=edit
atm

hiii

-- 
You are receiving this mail because:
You are the assignee for the bug.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] scsi: fix compiler warning for sg

2015-11-04 Thread kbuild test robot
Hi Sinan,

[auto build test ERROR on: scsi/for-next]
[also build test ERROR on: v4.3 next-20151105]

url:
https://github.com/0day-ci/linux/commits/Sinan-Kaya/scsi-mpt2sas-try-64-bit-DMA-when-32-bit-DMA-fails/20151105-125248
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: arm-mv78xx0_defconfig (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

>> ERROR: "__aeabi_uldivmod" [drivers/scsi/sg.ko] undefined!

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH] st: trivial: remove form feed characters

2015-11-04 Thread Matthew R. Ochs
Reviewed-by: Matthew R. Ochs 

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 3/3] ibmvscsi: Allow to configure maximum LUN

2015-11-04 Thread Laurent Vivier


On 04/11/2015 12:16, Hannes Reinecke wrote:
> On 11/04/2015 11:20 AM, Laurent Vivier wrote:
>> QEMU allows until 32 LUNs.
>>
>> Signed-off-by: Laurent Vivier 
>> ---
>>  drivers/scsi/ibmvscsi/ibmvscsi.c | 5 -
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c 
>> b/drivers/scsi/ibmvscsi/ibmvscsi.c
>> index 04de287..4480d3e 100644
>> --- a/drivers/scsi/ibmvscsi/ibmvscsi.c
>> +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
>> @@ -84,6 +84,7 @@
>>   */
>>  static int max_id = 64;
>>  static int max_channel = 3;
>> +static int max_lun = 8;
>>  static int init_timeout = 300;
>>  static int login_timeout = 60;
>>  static int info_timeout = 30;
>> @@ -117,6 +118,8 @@ module_param_named(fast_fail, fast_fail, int, S_IRUGO | 
>> S_IWUSR);
>>  MODULE_PARM_DESC(fast_fail, "Enable fast fail. [Default=1]");
>>  module_param_named(client_reserve, client_reserve, int, S_IRUGO );
>>  MODULE_PARM_DESC(client_reserve, "Attempt client managed reserve/release");
>> +module_param(max_lun, int, S_IRUGO);
>> +MODULE_PARM_DESC(max_lun, "Maximum LUN value [Default=8]");
>>  
>>  static void ibmvscsi_handle_crq(struct viosrp_crq *crq,
>>  struct ibmvscsi_host_data *hostdata);
>> @@ -2289,7 +2292,7 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const 
>> struct vio_device_id *id)
>>  goto init_pool_failed;
>>  }
>>  
>> -host->max_lun = 8;
>> +host->max_lun = max_lun;
>>  host->max_id = max_id;
>>  host->max_channel = max_channel;
>>  host->max_cmd_len = 16;
>>
> Please, don't do this.
> 
> 'max_lun' should only be set if the HBA / transport has some hard
> limitations on the number of bytes it can use.
> Otherwise the scanning algorithm in scsi_scan.c should do the
> correct thing, independent on the 'max_lun' setting.

So you are saying we can remove the line ?

> If qemu has some issues here someone should rather fix qemu ...

There is no issue with QEMU. QEMU can manage more than "8" LUNs, and
we'd like to.

Laurent
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 3/3] ibmvscsi: Allow to configure maximum LUN

2015-11-04 Thread Hannes Reinecke
On 11/04/2015 12:46 PM, Laurent Vivier wrote:
> 
> 
> On 04/11/2015 12:16, Hannes Reinecke wrote:
>> On 11/04/2015 11:20 AM, Laurent Vivier wrote:
>>> QEMU allows until 32 LUNs.
>>>
>>> Signed-off-by: Laurent Vivier 
>>> ---
>>>  drivers/scsi/ibmvscsi/ibmvscsi.c | 5 -
>>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c 
>>> b/drivers/scsi/ibmvscsi/ibmvscsi.c
>>> index 04de287..4480d3e 100644
>>> --- a/drivers/scsi/ibmvscsi/ibmvscsi.c
>>> +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
>>> @@ -84,6 +84,7 @@
>>>   */
>>>  static int max_id = 64;
>>>  static int max_channel = 3;
>>> +static int max_lun = 8;
>>>  static int init_timeout = 300;
>>>  static int login_timeout = 60;
>>>  static int info_timeout = 30;
>>> @@ -117,6 +118,8 @@ module_param_named(fast_fail, fast_fail, int, S_IRUGO | 
>>> S_IWUSR);
>>>  MODULE_PARM_DESC(fast_fail, "Enable fast fail. [Default=1]");
>>>  module_param_named(client_reserve, client_reserve, int, S_IRUGO );
>>>  MODULE_PARM_DESC(client_reserve, "Attempt client managed reserve/release");
>>> +module_param(max_lun, int, S_IRUGO);
>>> +MODULE_PARM_DESC(max_lun, "Maximum LUN value [Default=8]");
>>>  
>>>  static void ibmvscsi_handle_crq(struct viosrp_crq *crq,
>>> struct ibmvscsi_host_data *hostdata);
>>> @@ -2289,7 +2292,7 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const 
>>> struct vio_device_id *id)
>>> goto init_pool_failed;
>>> }
>>>  
>>> -   host->max_lun = 8;
>>> +   host->max_lun = max_lun;
>>> host->max_id = max_id;
>>> host->max_channel = max_channel;
>>> host->max_cmd_len = 16;
>>>
>> Please, don't do this.
>>
>> 'max_lun' should only be set if the HBA / transport has some hard
>> limitations on the number of bytes it can use.
>> Otherwise the scanning algorithm in scsi_scan.c should do the
>> correct thing, independent on the 'max_lun' setting.
> 
> So you are saying we can remove the line ?
> 
Ho-hum. In principle you could, as ibmvscsi is using SRP internally,
which does support 64 bit LUNs.

However, due to some weird design decisions there is
the function 'lun_from_dev()', which mangles the incoming LUN number
into something ... else.
Which leaves only 4 bits free for the actual LUN number, requiring
you to use max_lun = 16.

Personally I would just do away with that function and use the
incoming LUN numbers as is.

Brian? Any comments?

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries & Storage
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/32] target: prepare for bi_rw split

2015-11-04 Thread mchristi
From: Mike Christie 

This patch prepares lio's submit_bio use for the next
patches that split bi_rw into a operation and flags field.
Instead of passing in a bitmap with both the operation and
flags mixed in, the callers will now pass them in seperately.

This patch modifies the code related to the submit_bio calls
so the flags and operation are seperated. When this is done
for all code, one of the later patches in the series will
the actual submit_bio call, so the patches are bisectable.

Signed-off-by: Mike Christie 
---
 drivers/target/target_core_iblock.c | 32 ++--
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/target/target_core_iblock.c 
b/drivers/target/target_core_iblock.c
index 0f19e11..25f75ab 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -354,14 +354,14 @@ iblock_get_bio(struct se_cmd *cmd, sector_t lba, u32 
sg_num)
return bio;
 }
 
-static void iblock_submit_bios(struct bio_list *list, int rw)
+static void iblock_submit_bios(struct bio_list *list, int op, int op_flags)
 {
struct blk_plug plug;
struct bio *bio;
 
blk_start_plug();
while ((bio = bio_list_pop(list)))
-   submit_bio(rw, bio);
+   submit_bio(op | op_flags, bio);
blk_finish_plug();
 }
 
@@ -480,7 +480,7 @@ iblock_execute_write_same(struct se_cmd *cmd)
sectors -= 1;
}
 
-   iblock_submit_bios(, WRITE);
+   iblock_submit_bios(, REQ_OP_WRITE, 0);
return 0;
 
 fail_put_bios:
@@ -653,7 +653,8 @@ iblock_execute_rw(struct se_cmd *cmd, struct scatterlist 
*sgl, u32 sgl_nents,
u32 sg_num = sgl_nents;
sector_t block_lba;
unsigned bio_cnt;
-   int rw = 0;
+   int op_flags = 0;
+   int op = 0;
int i;
 
if (data_direction == DMA_TO_DEVICE) {
@@ -664,17 +665,20 @@ iblock_execute_rw(struct se_cmd *cmd, struct scatterlist 
*sgl, u32 sgl_nents,
 * is not enabled, or if initiator set the Force Unit Access 
bit.
 */
if (q->flush_flags & REQ_FUA) {
-   if (cmd->se_cmd_flags & SCF_FUA)
-   rw = WRITE_FUA;
-   else if (!(q->flush_flags & REQ_FLUSH))
-   rw = WRITE_FUA;
-   else
-   rw = WRITE;
+   if (cmd->se_cmd_flags & SCF_FUA) {
+   op = REQ_OP_WRITE;
+   op_flags = WRITE_FUA;
+   } else if (!(q->flush_flags & REQ_FLUSH)) {
+   op = REQ_OP_WRITE;
+   op_flags = WRITE_FUA;
+   } else {
+   op = REQ_OP_WRITE;
+   }
} else {
-   rw = WRITE;
+   op = REQ_OP_WRITE;
}
} else {
-   rw = READ;
+   op = REQ_OP_READ;
}
 
/*
@@ -726,7 +730,7 @@ iblock_execute_rw(struct se_cmd *cmd, struct scatterlist 
*sgl, u32 sgl_nents,
while (bio_add_page(bio, sg_page(sg), sg->length, sg->offset)
!= sg->length) {
if (bio_cnt >= IBLOCK_MAX_BIO_PER_TASK) {
-   iblock_submit_bios(, rw);
+   iblock_submit_bios(, op, op_flags);
bio_cnt = 0;
}
 
@@ -750,7 +754,7 @@ iblock_execute_rw(struct se_cmd *cmd, struct scatterlist 
*sgl, u32 sgl_nents,
goto fail_put_bios;
}
 
-   iblock_submit_bios(, rw);
+   iblock_submit_bios(, op, op_flags);
iblock_complete_cmd(cmd);
return 0;
 
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/32] drbd: prepare drbd for bi_rw split

2015-11-04 Thread mchristi
From: Mike Christie 

This patch prepares drbd's submit_bio use for the next
patches that split bi_rw into a operation and flags field.
Instead of passing in a bitmap with both the operation and
flags mixed in, the callers will now pass them in seperately.

This patch modifies the code related to the submit_bio calls
so the flags and operation are seperated. When this is done
for all code, one of the later patches in the series will
modify the actual submit_bio call, so the patches are bisectable.

Signed-off-by: Mike Christie 
---
 drivers/block/drbd/drbd_actlog.c | 30 --
 drivers/block/drbd/drbd_bitmap.c |  4 ++--
 drivers/block/drbd/drbd_int.h|  2 +-
 drivers/block/drbd/drbd_main.c   |  5 +++--
 4 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/drivers/block/drbd/drbd_actlog.c b/drivers/block/drbd/drbd_actlog.c
index b3868e7..c290e8b 100644
--- a/drivers/block/drbd/drbd_actlog.c
+++ b/drivers/block/drbd/drbd_actlog.c
@@ -137,19 +137,19 @@ void wait_until_done_or_force_detached(struct drbd_device 
*device, struct drbd_b
 
 static int _drbd_md_sync_page_io(struct drbd_device *device,
 struct drbd_backing_dev *bdev,
-sector_t sector, int rw)
+sector_t sector, int op)
 {
struct bio *bio;
/* we do all our meta data IO in aligned 4k blocks. */
const int size = 4096;
-   int err;
+   int err, op_flags = 0;
 
device->md_io.done = 0;
device->md_io.error = -ENODEV;
 
-   if ((rw & WRITE) && !test_bit(MD_NO_FUA, >flags))
-   rw |= REQ_FUA | REQ_FLUSH;
-   rw |= REQ_SYNC | REQ_NOIDLE;
+   if ((op == REQ_OP_WRITE) && !test_bit(MD_NO_FUA, >flags))
+   op_flags |= REQ_FUA | REQ_FLUSH;
+   op_flags |= REQ_SYNC | REQ_NOIDLE;
 
bio = bio_alloc_drbd(GFP_NOIO);
bio->bi_bdev = bdev->md_bdev;
@@ -159,9 +159,9 @@ static int _drbd_md_sync_page_io(struct drbd_device *device,
goto out;
bio->bi_private = device;
bio->bi_end_io = drbd_md_endio;
-   bio->bi_rw = rw;
+   bio->bi_rw = op | op_flags;
 
-   if (!(rw & WRITE) && device->state.disk == D_DISKLESS && device->ldev 
== NULL)
+   if (op != REQ_OP_WRITE && device->state.disk == D_DISKLESS && 
device->ldev == NULL)
/* special case, drbd_md_read() during drbd_adm_attach(): no 
get_ldev */
;
else if (!get_ldev_if_state(device, D_ATTACHING)) {
@@ -174,10 +174,10 @@ static int _drbd_md_sync_page_io(struct drbd_device 
*device,
bio_get(bio); /* one bio_put() is in the completion handler */
atomic_inc(>md_io.in_use); /* drbd_md_put_buffer() is in the 
completion handler */
device->md_io.submit_jif = jiffies;
-   if (drbd_insert_fault(device, (rw & WRITE) ? DRBD_FAULT_MD_WR : 
DRBD_FAULT_MD_RD))
+   if (drbd_insert_fault(device, (op == REQ_OP_WRITE) ? DRBD_FAULT_MD_WR : 
DRBD_FAULT_MD_RD))
bio_io_error(bio);
else
-   submit_bio(rw, bio);
+   submit_bio(op | op_flags, bio);
wait_until_done_or_force_detached(device, bdev, >md_io.done);
if (!bio->bi_error)
err = device->md_io.error;
@@ -188,7 +188,7 @@ static int _drbd_md_sync_page_io(struct drbd_device *device,
 }
 
 int drbd_md_sync_page_io(struct drbd_device *device, struct drbd_backing_dev 
*bdev,
-sector_t sector, int rw)
+sector_t sector, int op)
 {
int err;
D_ASSERT(device, atomic_read(>md_io.in_use) == 1);
@@ -197,19 +197,21 @@ int drbd_md_sync_page_io(struct drbd_device *device, 
struct drbd_backing_dev *bd
 
dynamic_drbd_dbg(device, "meta_data io: %s [%d]:%s(,%llus,%s) %pS\n",
 current->comm, current->pid, __func__,
-(unsigned long long)sector, (rw & WRITE) ? "WRITE" : "READ",
+(unsigned long long)sector, (op == REQ_OP_WRITE) ? "WRITE" : 
"READ",
 (void*)_RET_IP_ );
 
if (sector < drbd_md_first_sector(bdev) ||
sector + 7 > drbd_md_last_sector(bdev))
drbd_alert(device, "%s [%d]:%s(,%llus,%s) out of range md 
access!\n",
 current->comm, current->pid, __func__,
-(unsigned long long)sector, (rw & WRITE) ? "WRITE" : 
"READ");
+(unsigned long long)sector,
+(op == REQ_OP_WRITE) ? "WRITE" : "READ");
 
-   err = _drbd_md_sync_page_io(device, bdev, sector, rw);
+   err = _drbd_md_sync_page_io(device, bdev, sector, op);
if (err) {
drbd_err(device, "drbd_md_sync_page_io(,%llus,%s) failed with 
error %d\n",
-   (unsigned long long)sector, (rw & WRITE) ? "WRITE" : 
"READ", err);
+   (unsigned long long)sector,
+   (op == REQ_OP_WRITE) ? "WRITE" : 

[PATCH 07/32] dm: prepare for bi_rw split

2015-11-04 Thread mchristi
From: Mike Christie 

This patch prepares dm's submit_bio use for the next
patches that split bi_rw into a operation and flags field.
Instead of passing in a bitmap with both the operation and
flags mixed in, the callers will now pass them in seperately.

This patch modifies the code related to the submit_bio calls
so the flags and operation are seperated. When this is done
for all code, one of the later patches in the series will
the actual submit_bio call, so the patches are bisectable.

Signed-off-by: Mike Christie 
---
 drivers/md/dm-bufio.c   |  6 +++--
 drivers/md/dm-io.c  | 56 ++---
 drivers/md/dm-kcopyd.c  |  3 ++-
 drivers/md/dm-log.c |  5 ++--
 drivers/md/dm-raid1.c   | 11 +---
 drivers/md/dm-snap-persistent.c | 24 ++
 drivers/md/dm-thin.c|  6 ++---
 include/linux/dm-io.h   |  3 ++-
 8 files changed, 64 insertions(+), 50 deletions(-)

diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
index 83cc52e..9d5ef0c 100644
--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -554,7 +554,8 @@ static void use_dmio(struct dm_buffer *b, int rw, sector_t 
block,
 {
int r;
struct dm_io_request io_req = {
-   .bi_rw = rw,
+   .bi_op = rw,
+   .bi_op_flags = 0,
.notify.fn = dmio_complete,
.notify.context = b,
.client = b->c->dm_io,
@@ -1302,7 +1303,8 @@ EXPORT_SYMBOL_GPL(dm_bufio_write_dirty_buffers);
 int dm_bufio_issue_flush(struct dm_bufio_client *c)
 {
struct dm_io_request io_req = {
-   .bi_rw = WRITE_FLUSH,
+   .bi_op = REQ_OP_WRITE,
+   .bi_op_flags = WRITE_FLUSH,
.mem.type = DM_IO_KMEM,
.mem.ptr.addr = NULL,
.client = c->dm_io,
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
index 6f8e83b2..6479096 100644
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@ -279,8 +279,9 @@ static void km_dp_init(struct dpages *dp, void *data)
 /*-
  * IO routines that accept a list of pages.
  *---*/
-static void do_region(int rw, unsigned region, struct dm_io_region *where,
- struct dpages *dp, struct io *io)
+static void do_region(int op, int op_flags, unsigned region,
+ struct dm_io_region *where, struct dpages *dp,
+ struct io *io)
 {
struct bio *bio;
struct page *page;
@@ -296,24 +297,25 @@ static void do_region(int rw, unsigned region, struct 
dm_io_region *where,
/*
 * Reject unsupported discard and write same requests.
 */
-   if (rw & REQ_DISCARD)
+   if (op == REQ_DISCARD)
special_cmd_max_sectors = q->limits.max_discard_sectors;
-   else if (rw & REQ_WRITE_SAME)
+   else if (op == REQ_WRITE_SAME)
special_cmd_max_sectors = q->limits.max_write_same_sectors;
-   if ((rw & (REQ_DISCARD | REQ_WRITE_SAME)) && special_cmd_max_sectors == 
0) {
+   if ((op == REQ_DISCARD || op == REQ_WRITE_SAME) &&
+   special_cmd_max_sectors == 0) {
dec_count(io, region, -EOPNOTSUPP);
return;
}
 
/*
-* where->count may be zero if rw holds a flush and we need to
+* where->count may be zero if op holds a flush and we need to
 * send a zero-sized flush.
 */
do {
/*
 * Allocate a suitably sized-bio.
 */
-   if ((rw & REQ_DISCARD) || (rw & REQ_WRITE_SAME))
+   if ((op == REQ_DISCARD) || (op == REQ_WRITE_SAME))
num_bvecs = 1;
else
num_bvecs = min_t(int, BIO_MAX_PAGES,
@@ -325,11 +327,11 @@ static void do_region(int rw, unsigned region, struct 
dm_io_region *where,
bio->bi_end_io = endio;
store_io_and_region_in_bio(bio, io, region);
 
-   if (rw & REQ_DISCARD) {
+   if (op == REQ_DISCARD) {
num_sectors = min_t(sector_t, special_cmd_max_sectors, 
remaining);
bio->bi_iter.bi_size = num_sectors << SECTOR_SHIFT;
remaining -= num_sectors;
-   } else if (rw & REQ_WRITE_SAME) {
+   } else if (op == REQ_WRITE_SAME) {
/*
 * WRITE SAME only uses a single page.
 */
@@ -356,11 +358,11 @@ static void do_region(int rw, unsigned region, struct 
dm_io_region *where,
}
 
atomic_inc(>count);
-   submit_bio(rw, bio);
+   submit_bio(op | op_flags, bio);
} while (remaining);
 }
 
-static void dispatch_io(int 

[PATCH 04/32] block: prepare blkdev_issue_discard for bi_rw split

2015-11-04 Thread mchristi
From: Mike Christie 

The next patches will prepare the submit_bio users
for the split. There were a lot more users than
there were for submit_bio_wait, so if the conversion
was not a one liner, I broke it out into its own
patch.

This patch prepares blkdev_issue_discard.

There is some compat code left which will be dropped
in later patches in the series.
1. REQ_WRITE is still being set. This is because a lot
of code assumes it will be set for discard, flushes and
write sames.
2. submit_bio is still taking a bitmap. This is to make
the series git bisectable.

Signed-off-by: Mike Christie 
---
 block/blk-lib.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/block/blk-lib.c b/block/blk-lib.c
index 9ebf653..0861c7a 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -42,7 +42,8 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t 
sector,
 {
DECLARE_COMPLETION_ONSTACK(wait);
struct request_queue *q = bdev_get_queue(bdev);
-   int type = REQ_WRITE | REQ_DISCARD;
+   int op = REQ_OP_DISCARD;
+   int op_flags = REQ_WRITE;
unsigned int granularity;
int alignment;
struct bio_batch bb;
@@ -63,7 +64,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t 
sector,
if (flags & BLKDEV_DISCARD_SECURE) {
if (!blk_queue_secdiscard(q))
return -EOPNOTSUPP;
-   type |= REQ_SECURE;
+   op_flags |= REQ_SECURE;
}
 
atomic_set(, 1);
@@ -108,7 +109,7 @@ int blkdev_issue_discard(struct block_device *bdev, 
sector_t sector,
sector = end_sect;
 
atomic_inc();
-   submit_bio(type, bio);
+   submit_bio(op | op_flags, bio);
 
/*
 * We can loop for a long time in here, if someone does
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/32] dio/btrfs: prep dio->submit_bio users for bi_rw split.

2015-11-04 Thread mchristi
From: Mike Christie 

Instead of passing around a bitmap of ops and flags, the
next patches separate it into a op field and a flags field.
This patch prepares the dio code and dio->submit_bio users
for the split.

Note that the next patches will fix up the submit_bio() call
with along other users of that function.

Signed-off-by: Mike Christie 
---
 fs/btrfs/inode.c   |  9 -
 fs/direct-io.c | 34 +-
 include/linux/fs.h |  4 ++--
 3 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 611b66d..0ad8bab 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8196,14 +8196,13 @@ out_err:
return 0;
 }
 
-static void btrfs_submit_direct(int rw, struct bio *dio_bio,
+static void btrfs_submit_direct(int op, int op_flags, struct bio *dio_bio,
struct inode *inode, loff_t file_offset)
 {
struct btrfs_dio_private *dip = NULL;
struct bio *io_bio = NULL;
struct btrfs_io_bio *btrfs_bio;
int skip_sum;
-   int write = rw & REQ_WRITE;
int ret = 0;
 
skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
@@ -8232,14 +8231,14 @@ static void btrfs_submit_direct(int rw, struct bio 
*dio_bio,
btrfs_bio = btrfs_io_bio(io_bio);
btrfs_bio->logical = file_offset;
 
-   if (write) {
+   if (op == REQ_OP_WRITE) {
io_bio->bi_end_io = btrfs_endio_direct_write;
} else {
io_bio->bi_end_io = btrfs_endio_direct_read;
dip->subio_endio = btrfs_subio_endio_read;
}
 
-   ret = btrfs_submit_direct_hook(rw, dip, skip_sum);
+   ret = btrfs_submit_direct_hook(op | op_flags, dip, skip_sum);
if (!ret)
return;
 
@@ -8267,7 +8266,7 @@ free_ordered:
dip = NULL;
io_bio = NULL;
} else {
-   if (write) {
+   if (op == REQ_OP_WRITE) {
struct btrfs_ordered_extent *ordered;
 
ordered = btrfs_lookup_ordered_extent(inode,
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 1125629..5e1b1a0 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -108,7 +108,8 @@ struct dio_submit {
 /* dio_state communicated between submission path and end_io */
 struct dio {
int flags;  /* doesn't change */
-   int rw;
+   int op;
+   int op_flags;
struct inode *inode;
loff_t i_size;  /* i_size when submitted */
dio_iodone_t *end_io;   /* IO completion function */
@@ -160,7 +161,7 @@ static inline int dio_refill_pages(struct dio *dio, struct 
dio_submit *sdio)
ret = iov_iter_get_pages(sdio->iter, dio->pages, LONG_MAX, DIO_PAGES,
>from);
 
-   if (ret < 0 && sdio->blocks_available && (dio->rw & WRITE)) {
+   if (ret < 0 && sdio->blocks_available && (dio->op == REQ_OP_WRITE)) {
struct page *page = ZERO_PAGE(0);
/*
 * A memory fault, but the filesystem has some outstanding
@@ -239,7 +240,8 @@ static ssize_t dio_complete(struct dio *dio, loff_t offset, 
ssize_t ret,
transferred = dio->result;
 
/* Check for short read case */
-   if ((dio->rw == READ) && ((offset + transferred) > dio->i_size))
+   if ((dio->op == REQ_OP_READ) &&
+   ((offset + transferred) > dio->i_size))
transferred = dio->i_size - offset;
}
 
@@ -257,7 +259,7 @@ static ssize_t dio_complete(struct dio *dio, loff_t offset, 
ssize_t ret,
inode_dio_end(dio->inode);
 
if (is_async) {
-   if (dio->rw & WRITE) {
+   if (dio->op == REQ_OP_WRITE) {
int err;
 
err = generic_write_sync(dio->iocb->ki_filp, offset,
@@ -393,14 +395,14 @@ static inline void dio_bio_submit(struct dio *dio, struct 
dio_submit *sdio)
dio->refcount++;
spin_unlock_irqrestore(>bio_lock, flags);
 
-   if (dio->is_async && dio->rw == READ)
+   if (dio->is_async && dio->op == REQ_OP_READ)
bio_set_pages_dirty(bio);
 
if (sdio->submit_io)
-   sdio->submit_io(dio->rw, bio, dio->inode,
+   sdio->submit_io(dio->op, dio->op_flags, bio, dio->inode,
   sdio->logical_offset_in_bio);
else
-   submit_bio(dio->rw, bio);
+   submit_bio(dio->op | dio->op_flags, bio);
 
sdio->bio = NULL;
sdio->boundary = 0;
@@ -464,14 +466,14 @@ static int dio_bio_complete(struct dio *dio, struct bio 
*bio)
if (bio->bi_error)
dio->io_error = -EIO;
 
-   if (dio->is_async && dio->rw == READ) {
+   if (dio->is_async && dio->op == REQ_OP_READ) {

[PATCH 06/32] xen blkback: prepare for bi_rw split

2015-11-04 Thread mchristi
From: Mike Christie 

This patch prepares xen blkback submit_bio use for the next
patches that split bi_rw into a operation and flags field.
Instead of passing in a bitmap with both the operation and
flags mixed in, the callers will now pass them in seperately.

This patch modifies the code related to the submit_bio calls
so the flags and operation are seperated. When this is done
for all code, one of the later patches in the series will
modify the actual submit_bio call, so the patches are bisectable.

Signed-off-by: Mike Christie 
---
 drivers/block/xen-blkback/blkback.c | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/block/xen-blkback/blkback.c 
b/drivers/block/xen-blkback/blkback.c
index 6a685ae..bfffab3 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -488,7 +488,7 @@ static int xen_vbd_translate(struct phys_req *req, struct 
xen_blkif *blkif,
struct xen_vbd *vbd = >vbd;
int rc = -EACCES;
 
-   if ((operation != READ) && vbd->readonly)
+   if ((operation != REQ_OP_READ) && vbd->readonly)
goto out;
 
if (likely(req->nr_sects)) {
@@ -990,7 +990,7 @@ static int dispatch_discard_io(struct xen_blkif *blkif,
preq.sector_number = req->u.discard.sector_number;
preq.nr_sects  = req->u.discard.nr_sectors;
 
-   err = xen_vbd_translate(, blkif, WRITE);
+   err = xen_vbd_translate(, blkif, REQ_OP_WRITE);
if (err) {
pr_warn("access denied: DISCARD [%llu->%llu] on dev=%04x\n",
preq.sector_number,
@@ -1203,6 +1203,7 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
struct bio **biolist = pending_req->biolist;
int i, nbio = 0;
int operation;
+   int operation_flags = 0;
struct blk_plug plug;
bool drain = false;
struct grant_page **pages = pending_req->segments;
@@ -1220,17 +1221,19 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
switch (req_operation) {
case BLKIF_OP_READ:
blkif->st_rd_req++;
-   operation = READ;
+   operation = REQ_OP_READ;
break;
case BLKIF_OP_WRITE:
blkif->st_wr_req++;
-   operation = WRITE_ODIRECT;
+   operation = REQ_OP_WRITE;
+   operation_flags = WRITE_ODIRECT;
break;
case BLKIF_OP_WRITE_BARRIER:
drain = true;
case BLKIF_OP_FLUSH_DISKCACHE:
blkif->st_f_req++;
-   operation = WRITE_FLUSH;
+   operation = REQ_OP_WRITE;
+   operation_flags = WRITE_FLUSH;
break;
default:
operation = 0; /* make gcc happy */
@@ -1242,7 +1245,7 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
nseg = req->operation == BLKIF_OP_INDIRECT ?
   req->u.indirect.nr_segments : req->u.rw.nr_segments;
 
-   if (unlikely(nseg == 0 && operation != WRITE_FLUSH) ||
+   if (unlikely(nseg == 0 && operation_flags != WRITE_FLUSH) ||
unlikely((req->operation != BLKIF_OP_INDIRECT) &&
 (nseg > BLKIF_MAX_SEGMENTS_PER_REQUEST)) ||
unlikely((req->operation == BLKIF_OP_INDIRECT) &&
@@ -1349,7 +1352,7 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
 
/* This will be hit if the operation was a flush or discard. */
if (!bio) {
-   BUG_ON(operation != WRITE_FLUSH);
+   BUG_ON(operation_flags != WRITE_FLUSH);
 
bio = bio_alloc(GFP_KERNEL, 0);
if (unlikely(bio == NULL))
@@ -1365,14 +1368,14 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
blk_start_plug();
 
for (i = 0; i < nbio; i++)
-   submit_bio(operation, biolist[i]);
+   submit_bio(operation | operation_flags, biolist[i]);
 
/* Let the I/Os go.. */
blk_finish_plug();
 
-   if (operation == READ)
+   if (operation == REQ_OP_READ)
blkif->st_rd_sect += preq.nr_sects;
-   else if (operation & WRITE)
+   else if (operation == REQ_OP_WRITE)
blkif->st_wr_sect += preq.nr_sects;
 
return 0;
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/32] btrfs: prepare for bi_rw split

2015-11-04 Thread mchristi
From: Mike Christie 

This patch prepares btrfs's submit_bio use for the next
patches that split bi_rw into a operation and flags field.
Instead of passing in a bitmap with both the operation and
flags mixed in, the callers will now pass them in seperately.

This patch modifies the code related to the submit_bio calls
so the flags and operation are seperated. When this is done
for all code, one of the later patches in the series will
the actual submit_bio call, so the patches are bisectable.

Signed-off-by: Mike Christie 
---
 fs/btrfs/check-integrity.c |   6 +--
 fs/btrfs/check-integrity.h |   2 +-
 fs/btrfs/compression.c |   8 ++--
 fs/btrfs/ctree.h   |   3 +-
 fs/btrfs/disk-io.c |  48 +++--
 fs/btrfs/disk-io.h |   2 +-
 fs/btrfs/extent-tree.c |   2 +-
 fs/btrfs/extent_io.c   | 103 -
 fs/btrfs/extent_io.h   |   7 +--
 fs/btrfs/inode.c   |  65 ++--
 fs/btrfs/scrub.c   |   4 +-
 fs/btrfs/volumes.c |  88 --
 fs/btrfs/volumes.h |   4 +-
 13 files changed, 177 insertions(+), 165 deletions(-)

diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index fd50b2f..515a92e 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -3058,10 +3058,10 @@ leave:
mutex_unlock(_mutex);
 }
 
-void btrfsic_submit_bio(int rw, struct bio *bio)
+void btrfsic_submit_bio(int op, int op_flags, struct bio *bio)
 {
-   __btrfsic_submit_bio(rw, bio);
-   submit_bio(rw, bio);
+   __btrfsic_submit_bio(op | op_flags, bio);
+   submit_bio(op | op_flags, bio);
 }
 
 int btrfsic_submit_bio_wait(int op, int op_flags, struct bio *bio)
diff --git a/fs/btrfs/check-integrity.h b/fs/btrfs/check-integrity.h
index 13b0d54..a8edc424 100644
--- a/fs/btrfs/check-integrity.h
+++ b/fs/btrfs/check-integrity.h
@@ -21,7 +21,7 @@
 
 #ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
 int btrfsic_submit_bh(int rw, struct buffer_head *bh);
-void btrfsic_submit_bio(int rw, struct bio *bio);
+void btrfsic_submit_bio(int op, int op_flags, struct bio *bio);
 int btrfsic_submit_bio_wait(int op, int op_flags, struct bio *bio);
 #else
 #define btrfsic_submit_bh submit_bh
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 57ee8ca..a7b245d 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -401,7 +401,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 
start,
BUG_ON(ret); /* -ENOMEM */
}
 
-   ret = btrfs_map_bio(root, WRITE, bio, 0, 1);
+   ret = btrfs_map_bio(root, REQ_OP_WRITE, 0, bio, 0, 1);
BUG_ON(ret); /* -ENOMEM */
 
bio_put(bio);
@@ -431,7 +431,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 
start,
BUG_ON(ret); /* -ENOMEM */
}
 
-   ret = btrfs_map_bio(root, WRITE, bio, 0, 1);
+   ret = btrfs_map_bio(root, REQ_OP_WRITE, 0, bio, 0, 1);
BUG_ON(ret); /* -ENOMEM */
 
bio_put(bio);
@@ -692,7 +692,7 @@ int btrfs_submit_compressed_read(struct inode *inode, 
struct bio *bio,
sums += DIV_ROUND_UP(comp_bio->bi_iter.bi_size,
 root->sectorsize);
 
-   ret = btrfs_map_bio(root, READ, comp_bio,
+   ret = btrfs_map_bio(root, REQ_OP_READ, 0, comp_bio,
mirror_num, 0);
if (ret) {
bio->bi_error = ret;
@@ -722,7 +722,7 @@ int btrfs_submit_compressed_read(struct inode *inode, 
struct bio *bio,
BUG_ON(ret); /* -ENOMEM */
}
 
-   ret = btrfs_map_bio(root, READ, comp_bio, mirror_num, 0);
+   ret = btrfs_map_bio(root, REQ_OP_READ, 0, comp_bio, mirror_num, 0);
if (ret) {
bio->bi_error = ret;
bio_endio(comp_bio);
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 938efe3..e4489dd1 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3910,8 +3910,7 @@ int btrfs_create_subvol_root(struct btrfs_trans_handle 
*trans,
 struct btrfs_root *parent_root,
 u64 new_dirid);
 int btrfs_merge_bio_hook(int rw, struct page *page, unsigned long offset,
-size_t size, struct bio *bio,
-unsigned long bio_flags);
+size_t size, struct bio *bio, unsigned long bio_flags);
 int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf);
 int btrfs_readpage(struct file *file, struct page *page);
 void btrfs_evict_inode(struct inode *inode);
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 1e60d00..6c17d5d 100644
--- a/fs/btrfs/disk-io.c
+++ 

[PATCH 01/32] block/fs: add REQ_OP definitions.

2015-11-04 Thread mchristi
From: Mike Christie 

This patch adds definitions for request/bio operations which
will be used in the next patches.

In the initial patches the REQ_OPs match the REQ ones for compat reasons
while all the code is converted in this set. In the last patches
that will be removed.

Signed-off-by: Mike Christie 
---
 include/linux/blk_types.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index e813013..d7b6009 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -244,4 +244,11 @@ enum rq_flag_bits {
 #define REQ_MQ_INFLIGHT(1ULL << __REQ_MQ_INFLIGHT)
 #define REQ_NO_TIMEOUT (1ULL << __REQ_NO_TIMEOUT)
 
+enum req_op {
+   REQ_OP_READ,
+   REQ_OP_WRITE= REQ_WRITE,
+   REQ_OP_DISCARD  = REQ_DISCARD,
+   REQ_OP_WRITE_SAME   = REQ_WRITE_SAME,
+};
+
 #endif /* __LINUX_BLK_TYPES_H */
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/32] block/fs/mm: prepare submit_bio_wait users for bi_rw split

2015-11-04 Thread mchristi
From: Mike Christie 

This patch prepares submit_bio_wait callers for the next
patches that split bi_rw into a operation and flags field.
Instead of passing in a bitmap with both the operation and
flags mixed in, the callers now pass them in seperately.

Temp issue: When the fs.h read/write types, like WRITE_SYNC or
WRITE_FUA, are used we still pass in the operation along with the
flags in the flags argument. When all the code has been converted
that will be cleaned up. It is left in here for compat and git
bisect use and to try and make the patches smaller.

Signed-off-by: Mike Christie 
---
 block/bio.c|  8 
 block/blk-flush.c  |  2 +-
 drivers/md/bcache/debug.c  |  4 ++--
 drivers/md/md.c|  2 +-
 drivers/md/raid1.c |  2 +-
 drivers/md/raid10.c|  2 +-
 fs/btrfs/check-integrity.c |  8 
 fs/btrfs/check-integrity.h |  2 +-
 fs/btrfs/extent_io.c   |  2 +-
 fs/btrfs/scrub.c   |  6 +++---
 fs/ext4/crypto.c   |  2 +-
 fs/f2fs/segment.c  |  4 ++--
 fs/hfsplus/hfsplus_fs.h|  2 +-
 fs/hfsplus/part_tbl.c  |  5 +++--
 fs/hfsplus/super.c |  6 --
 fs/hfsplus/wrapper.c   | 14 --
 fs/logfs/dev_bdev.c|  2 +-
 include/linux/bio.h|  2 +-
 kernel/power/swap.c| 30 ++
 19 files changed, 58 insertions(+), 47 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index ad3f276..610c704 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -859,21 +859,21 @@ static void submit_bio_wait_endio(struct bio *bio)
 
 /**
  * submit_bio_wait - submit a bio, and wait until it completes
- * @rw: whether to %READ or %WRITE, or maybe to %READA (read ahead)
+ * @op: REQ_OP_*
+ * @flags: rq_flag_bits
  * @bio: The  bio which describes the I/O
  *
  * Simple wrapper around submit_bio(). Returns 0 on success, or the error from
  * bio_endio() on failure.
  */
-int submit_bio_wait(int rw, struct bio *bio)
+int submit_bio_wait(int op, int flags, struct bio *bio)
 {
struct submit_bio_ret ret;
 
-   rw |= REQ_SYNC;
init_completion();
bio->bi_private = 
bio->bi_end_io = submit_bio_wait_endio;
-   submit_bio(rw, bio);
+   submit_bio(op | flags | REQ_SYNC, bio);
wait_for_completion();
 
return ret.error;
diff --git a/block/blk-flush.c b/block/blk-flush.c
index 9c423e5..f707ba1 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -485,7 +485,7 @@ int blkdev_issue_flush(struct block_device *bdev, gfp_t 
gfp_mask,
bio = bio_alloc(gfp_mask, 0);
bio->bi_bdev = bdev;
 
-   ret = submit_bio_wait(WRITE_FLUSH, bio);
+   ret = submit_bio_wait(REQ_OP_WRITE, WRITE_FLUSH, bio);
 
/*
 * The driver must store the error location in ->bi_sector, if
diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
index 8b1f1d5..001f5f1 100644
--- a/drivers/md/bcache/debug.c
+++ b/drivers/md/bcache/debug.c
@@ -54,7 +54,7 @@ void bch_btree_verify(struct btree *b)
bio->bi_iter.bi_size= KEY_SIZE(>key) << 9;
bch_bio_map(bio, sorted);
 
-   submit_bio_wait(REQ_META|READ_SYNC, bio);
+   submit_bio_wait(REQ_OP_READ, READ_SYNC, bio);
bch_bbio_free(bio, b->c);
 
memcpy(ondisk, sorted, KEY_SIZE(>key) << 9);
@@ -117,7 +117,7 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
if (bio_alloc_pages(check, GFP_NOIO))
goto out_put;
 
-   submit_bio_wait(READ_SYNC, check);
+   submit_bio_wait(REQ_OP_READ, READ_SYNC, check);
 
bio_for_each_segment(bv, bio, iter) {
void *p1 = kmap_atomic(bv.bv_page);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index c702de1..1ca5959 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -771,7 +771,7 @@ int sync_page_io(struct md_rdev *rdev, sector_t sector, int 
size,
else
bio->bi_iter.bi_sector = sector + rdev->data_offset;
bio_add_page(bio, page, size, 0);
-   submit_bio_wait(rw, bio);
+   submit_bio_wait(rw, 0, bio);
 
ret = !bio->bi_error;
bio_put(bio);
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index d9d031e..527fdf5 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2195,7 +2195,7 @@ static int narrow_write_error(struct r1bio *r1_bio, int i)
bio_trim(wbio, sector - r1_bio->sector, sectors);
wbio->bi_iter.bi_sector += rdev->data_offset;
wbio->bi_bdev = rdev->bdev;
-   if (submit_bio_wait(WRITE, wbio) < 0)
+   if (submit_bio_wait(REQ_OP_WRITE, 0, wbio) < 0)
/* failure! */
ok = rdev_set_badblocks(rdev, sector,
sectors, 0)
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 96f3659..69352a6 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -2470,7 +2470,7 @@ 

[RFC PATCH 00/32] separate operations from flags in the bio/request structs

2015-11-04 Thread mchristi
There are a couple new block layer commands we are trying to add support
for in the near term:

compare and write
http://www.spinics.net/lists/target-devel/msg07826.html

copy offload/extended copy/xcopy
https://www.redhat.com/archives/dm-devel/2014-July/msg00070.html

The problem is if we contine to add more commands we will have to one day
extend the cmd_flags/bi_rw fields again. To prevent that, this patchset
separates the operation (REQ_WRITE, REQ_DISCARD, REQ_WRITE_SAME, etc) from
the flags (REQ_SYNC, REQ_QUIET, etc) in the bio and request structs. In the
end of this set, we will have two fields bio->bi_op/request->op and
bio->bi_rw/request->cmd_flags.

The patches were made against Jens's linux-block tree's for-linus branch:
https://git.kernel.org/cgit/linux/kernel/git/axboe/linux-block.git/log/?h=for-linus
(last commit a22c4d7e34402ccdf3414f64c50365436eba7b93).

I have done some basic testing for a lot of the drivers and filesystems,
but I wanted to get comments before trying to track down more hardware/
systems for testing.


Known issues:
- REQ_FLUSH is still a flag, but should probably be a operation.
 For lower level drivers like SCSI where we only get a flush, it makes
more sense to be a operation. However, upper layers like filesystems
can send down flushes with writes, so it is more of a flag for them.
I am still working on this.

- There is a regression with the dm flakey target. It currently
cannot corrupt the operation values.

- The patchset is a little awkward. It touches so much code,
but I wanted to maintain git bisectibility, so there is lots of compat code
left around until the last patches where everyting is cleaned up.


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] isci: isci: remove SCSI host before detaching from SAS transport

2015-11-04 Thread Jinpu Wang
>From b1fb56b6d98610251253dc4b858df509df08e813 Mon Sep 17 00:00:00 2001
From: Jack Wang 
Date: Wed, 4 Nov 2015 09:46:05 +0100
Subject: [PATCH 1/3] isci: remove SCSI host before detaching from SAS
 transport

commit cff549e4860f ("scsi: proper state checking and module refcount
handling in scsi_device_get")
, the reference count of scsi device was changed, which could lead to when
rmmod with at least on drive attached, SCSI error handle will
run into infinite loop, and lockup the system.

Fix it by remove scsi host first, this way scsi core will not send
commands down after detaching SAS transport.

This is a follow up fix for Benjamin's fix for pm80xx.

See also:
http://www.spinics.net/lists/linux-scsi/msg90088.html

Signed-off-by: Jack Wang 
---
 drivers/scsi/isci/init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c
index 0dfcabe..9e0d069 100644
--- a/drivers/scsi/isci/init.c
+++ b/drivers/scsi/isci/init.c
@@ -272,11 +272,11 @@ static void isci_unregister(struct isci_host *isci_host)
  if (!isci_host)
  return;

+ shost = to_shost(isci_host);
+ scsi_remove_host(shost);
  sas_unregister_ha(_host->sas_ha);

- shost = to_shost(isci_host);
  sas_remove_host(shost);
- scsi_remove_host(shost);
  scsi_host_put(shost);
 }

-- 
1.9.1


-- 
Mit freundlichen Grüßen,
Best Regards,

Jack Wang

Linux Kernel Developer Storage
ProfitBricks GmbH  The IaaS-Company.

ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin
Tel: +49 30 5770083-42
Fax: +49 30 5770085-98
Email: jinpu.w...@profitbricks.com
URL: http://www.profitbricks.de

Sitz der Gesellschaft: Berlin.
Registergericht: Amtsgericht Charlottenburg, HRB 125506 B.
Geschäftsführer: Andreas Gauger, Achim Weiss.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [dm-devel] [RFC PATCH 00/32] separate operations from flags in the bio/request structs

2015-11-04 Thread Bart Van Assche

On 11/04/2015 08:32 AM, mchri...@redhat.com wrote:

There are a couple new block layer commands we are trying to add support
for in the near term:

compare and write
http://www.spinics.net/lists/target-devel/msg07826.html

copy offload/extended copy/xcopy
https://www.redhat.com/archives/dm-devel/2014-July/msg00070.html

The problem is if we contine to add more commands we will have to one day
extend the cmd_flags/bi_rw fields again. To prevent that, this patchset
separates the operation (REQ_WRITE, REQ_DISCARD, REQ_WRITE_SAME, etc) from
the flags (REQ_SYNC, REQ_QUIET, etc) in the bio and request structs. In the
end of this set, we will have two fields bio->bi_op/request->op and
bio->bi_rw/request->cmd_flags.

The patches were made against Jens's linux-block tree's for-linus branch:
https://git.kernel.org/cgit/linux/kernel/git/axboe/linux-block.git/log/?h=for-linus
(last commit a22c4d7e34402ccdf3414f64c50365436eba7b93).

I have done some basic testing for a lot of the drivers and filesystems,
but I wanted to get comments before trying to track down more hardware/
systems for testing.


Known issues:
- REQ_FLUSH is still a flag, but should probably be a operation.
  For lower level drivers like SCSI where we only get a flush, it makes
more sense to be a operation. However, upper layers like filesystems
can send down flushes with writes, so it is more of a flag for them.
I am still working on this.

- There is a regression with the dm flakey target. It currently
cannot corrupt the operation values.

- The patchset is a little awkward. It touches so much code,
but I wanted to maintain git bisectibility, so there is lots of compat code
left around until the last patches where everyting is cleaned up.


Hello Mike,

If you have to touch submit_bio() and submit_bio_wait(), how about 
requiring the callers of these functions to set the cmd and flags 
arguments in the bio structure and to leave out the cmd and flags 
arguments from the submit_bio() and submit_bio_wait() functions ? A 
(compile tested only) patch that implements this idea is available at 
https://lkml.org/lkml/2014/6/2/173.


Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] aic94xx: remove SCSI host before detaching from SAS transport

2015-11-04 Thread Jinpu Wang
>From 3aae177e7aa89fa84ae5c60ed5f10056610d Mon Sep 17 00:00:00 2001
From: Jack Wang 
Date: Wed, 4 Nov 2015 10:01:41 +0100
Subject: [PATCH 2/3] aic94xx: remove SCSI host before detaching from SAS
 transport

commit cff549e4860f ("scsi: proper state checking and module refcount
handling in scsi_device_get")
the reference count of scsi device was changed, which could lead to
when rmmod with at least on drive attached, SCSI error handle will
run into infinite loop, and lockup the system.

Fix it by remove scsi host first, this way scsi core will not send
commands down after detaching SAS transport.

This is a follow up fix for Benjamin's fix for pm80xx.

See also:
http://www.spinics.net/lists/linux-scsi/msg90088.html

Signed-off-by: Jack Wang 
---
 drivers/scsi/aic94xx/aic94xx_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/aic94xx/aic94xx_init.c
b/drivers/scsi/aic94xx/aic94xx_init.c
index f6c336b..4b56976 100644
--- a/drivers/scsi/aic94xx/aic94xx_init.c
+++ b/drivers/scsi/aic94xx/aic94xx_init.c
@@ -704,10 +704,10 @@ static int asd_unregister_sas_ha(struct
asd_ha_struct *asd_ha)
 {
  int err;

+ scsi_remove_host(asd_ha->sas_ha.core.shost);
  err = sas_unregister_ha(_ha->sas_ha);

  sas_remove_host(asd_ha->sas_ha.core.shost);
- scsi_remove_host(asd_ha->sas_ha.core.shost);
  scsi_host_put(asd_ha->sas_ha.core.shost);

  kfree(asd_ha->sas_ha.sas_phy);
-- 
1.9.1


-- 
Mit freundlichen Grüßen,
Best Regards,

Jack Wang

Linux Kernel Developer Storage
ProfitBricks GmbH  The IaaS-Company.

ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin
Tel: +49 30 5770083-42
Fax: +49 30 5770085-98
Email: jinpu.w...@profitbricks.com
URL: http://www.profitbricks.de

Sitz der Gesellschaft: Berlin.
Registergericht: Amtsgericht Charlottenburg, HRB 125506 B.
Geschäftsführer: Andreas Gauger, Achim Weiss.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [dm-devel] [RFC PATCH 00/32] separate operations from flags in the bio/request structs

2015-11-04 Thread Mike Christie
On 11/04/2015 10:49 AM, Bart Van Assche wrote:
> Hello Mike,
> 
> If you have to touch submit_bio() and submit_bio_wait(), how about
> requiring the callers of these functions to set the cmd and flags
> arguments in the bio structure and to leave out the cmd and flags
> arguments from the submit_bio() and submit_bio_wait() functions ? A
> (compile tested only) patch that implements this idea is available at
> https://lkml.org/lkml/2014/6/2/173.
> 

Yeah, I can do that.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] mvsas: remove SCSI host before detaching from SAS transport

2015-11-04 Thread Jinpu Wang
>From 6c3cb7d4df1e164008338c922cd99149a6a8191b Mon Sep 17 00:00:00 2001
From: Jack Wang 
Date: Wed, 4 Nov 2015 10:05:01 +0100
Subject: [PATCH 3/3] mvsas: remove SCSI host before detaching from SAS
 transport

commit cff549e4860f ("scsi: proper state checking and module refcount
handling in scsi_device_get")

the reference count of scsi device was changed, which could lead to
when rmmod with at least on drive attached, SCSI error handle will
run into infinite loop, and lockup the system.

Fix it by remove scsi host first, this way scsi core will not send
commands down after detaching SAS transport.

This is a follow up fix for Benjamin's fix for pm80xx.

See also:
http://www.spinics.net/lists/linux-scsi/msg90088.html

Signed-off-by: Jack Wang 
---
 drivers/scsi/mvsas/mv_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
index e2d555c..1960d95 100644
--- a/drivers/scsi/mvsas/mv_init.c
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -641,9 +641,9 @@ static void mvs_pci_remove(struct pci_dev *pdev)
  tasklet_kill(&((struct mvs_prv_info *)sha->lldd_ha)->mv_tasklet);
 #endif

+ scsi_remove_host(mvi->shost);
  sas_unregister_ha(sha);
  sas_remove_host(mvi->shost);
- scsi_remove_host(mvi->shost);

  MVS_CHIP_DISP->interrupt_disable(mvi);
  free_irq(mvi->pdev->irq, sha);
-- 
1.9.1


-- 
Mit freundlichen Grüßen,
Best Regards,

Jack Wang

Linux Kernel Developer Storage
ProfitBricks GmbH  The IaaS-Company.

ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin
Tel: +49 30 5770083-42
Fax: +49 30 5770085-98
Email: jinpu.w...@profitbricks.com
URL: http://www.profitbricks.de

Sitz der Gesellschaft: Berlin.
Registergericht: Amtsgericht Charlottenburg, HRB 125506 B.
Geschäftsführer: Andreas Gauger, Achim Weiss.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] string_helpers: fix precision loss for some inputs

2015-11-04 Thread Rasmus Villemoes
On Wed, Nov 04 2015, James Bottomley  
wrote:

> On Wed, 2015-11-04 at 00:26 +0100, Rasmus Villemoes wrote:
>> On Tue, Nov 03 2015, James Bottomley  
>> wrote:
>> >> Please spell it U32_MAX
>> >
>> > Why?  there's no reason not to use the arithmetic UINT_MAX here.  Either
>> > works, of course but UINT_MAX is standard.
>> 
>> We're dealing with explicitly sized integers
>
> An integer is explicitly sized: it's 32 bits. That's why UINT_MAX is
> a universal constant.

In the Linux universe, yes. It's kind of amusing how you try to argue
based on the UINT_MAX name being (defined in a) standard while at the same
time very much rely on sizeof(int) having a value which is not specified
by the standard. I repeat:

>> U32_MAX is the natural name for the appropriate constant.

(and it's defined right next to UINT_MAX in kernel.h, so it's not like
you'd have to introduce that macro).

>> Also, you could do > U32_MAX instead of >= U32_MAX, but that's unlikely
>> to make any difference (well, except it might generate slightly better
>> code, since it would allow gcc to just test the upper half for being 0,
>> which might be cheaper on some architectures than comparing to a
>> literal).
>
> Heh if we're going to be that concerned about the code generation, then
> we should just tell gcc exactly how to do it instead of hoping it can
> work it out for itself, so
>
> while (blk_size >> 32) {
> ...

Nah, that would still require the compiler to be able to transform that
to the other form, which apparently it isn't. On x86_64, the simplest
is to load U32_MAX once into a register and then do r/r comparisons, but
when it's possible to directly test the upper half (e.g. when the 64 bit
value is represented in a pair of 32 bit registers) that's much
simpler. gcc generates good code for 'blk_size > U32_MAX' on both x86_64
and x86_32, but ends up doing an extra cmp on x86_32 for >=, and ends up
doing mov,shift,test inside the loop on x86_64 for 'blk_size >> 32'.

Rasmus
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/5] ipr: Add delay to ensure coherent dumps.

2015-11-04 Thread wenxiong

Reviewed-by: Wen Xiong 

Thanks,
Wendy


Quoting Gabriel Krisman Bertazi :


Add a holding pattern prior to collecting dump data, to wait for the IOA
indication that the Mailbox register is stable and won't change without
an explicit reset.  This ensures we'll be collecting meaningful dump
data, even when dumping right after an adapter reset.

In the event of a timeout, we still force the dump, since a partial dump
still might be useful.

Changes since v1:
- Fix checkpatch.pl warnings.

Signed-off-by: Gabriel Krisman Bertazi 
---
 drivers/scsi/ipr.c | 51 +++
 drivers/scsi/ipr.h |  3 +++
 2 files changed, 42 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index b62836d..238efab 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -8277,6 +8277,42 @@ static int  
ipr_reset_get_unit_check_job(struct ipr_cmnd *ipr_cmd)

return IPR_RC_JOB_RETURN;
 }

+static int ipr_dump_mailbox_wait(struct ipr_cmnd *ipr_cmd)
+{
+   struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
+
+   ENTER;
+
+   if (ioa_cfg->sdt_state != GET_DUMP)
+   return IPR_RC_JOB_RETURN;
+
+   if (!ioa_cfg->sis64 || !ipr_cmd->u.time_left ||
+   (readl(ioa_cfg->regs.sense_interrupt_reg) &
+IPR_PCII_MAILBOX_STABLE)) {
+
+   if (!ipr_cmd->u.time_left)
+   dev_err(_cfg->pdev->dev,
+   "Timed out waiting for Mailbox register.\n");
+
+   ioa_cfg->sdt_state = READ_DUMP;
+   ioa_cfg->dump_timeout = 0;
+   if (ioa_cfg->sis64)
+   ipr_reset_start_timer(ipr_cmd, IPR_SIS64_DUMP_TIMEOUT);
+   else
+   ipr_reset_start_timer(ipr_cmd, IPR_SIS32_DUMP_TIMEOUT);
+   ipr_cmd->job_step = ipr_reset_wait_for_dump;
+   schedule_work(_cfg->work_q);
+
+   } else {
+   ipr_cmd->u.time_left -= IPR_CHECK_FOR_RESET_TIMEOUT;
+   ipr_reset_start_timer(ipr_cmd,
+ IPR_CHECK_FOR_RESET_TIMEOUT);
+   }
+
+   LEAVE;
+   return IPR_RC_JOB_RETURN;
+}
+
 /**
  * ipr_reset_restore_cfg_space - Restore PCI config space.
  * @ipr_cmd:   ipr command struct
@@ -8326,20 +8362,11 @@ static int  
ipr_reset_restore_cfg_space(struct ipr_cmnd *ipr_cmd)


if (ioa_cfg->in_ioa_bringdown) {
ipr_cmd->job_step = ipr_ioa_bringdown_done;
+   } else if (ioa_cfg->sdt_state == GET_DUMP) {
+   ipr_cmd->job_step = ipr_dump_mailbox_wait;
+   ipr_cmd->u.time_left = IPR_WAIT_FOR_MAILBOX;
} else {
ipr_cmd->job_step = ipr_reset_enable_ioa;
-
-   if (GET_DUMP == ioa_cfg->sdt_state) {
-   ioa_cfg->sdt_state = READ_DUMP;
-   ioa_cfg->dump_timeout = 0;
-   if (ioa_cfg->sis64)
-   ipr_reset_start_timer(ipr_cmd, 
IPR_SIS64_DUMP_TIMEOUT);
-   else
-   ipr_reset_start_timer(ipr_cmd, 
IPR_SIS32_DUMP_TIMEOUT);
-   ipr_cmd->job_step = ipr_reset_wait_for_dump;
-   schedule_work(_cfg->work_q);
-   return IPR_RC_JOB_RETURN;
-   }
}

LEAVE;
diff --git a/drivers/scsi/ipr.h b/drivers/scsi/ipr.h
index e4fb17a..69257c4 100644
--- a/drivers/scsi/ipr.h
+++ b/drivers/scsi/ipr.h
@@ -279,6 +279,9 @@
 #define IPR_IPL_INIT_STAGE_TIME_MASK   0x
 #define IPR_PCII_IPL_STAGE_CHANGE  (0x8000 >> 0)

+#define IPR_PCII_MAILBOX_STABLE(0x8000 >> 
4)
+#define IPR_WAIT_FOR_MAILBOX   (2 * HZ)
+
 #define IPR_PCII_IOA_TRANS_TO_OPER (0x8000 >> 0)
 #define IPR_PCII_IOARCB_XFER_FAILED(0x8000 >> 3)
 #define IPR_PCII_IOA_UNIT_CHECKED  (0x8000 >> 4)
--
2.1.0



--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 4/5] ipr: Issue Configure Cache Parameters command.

2015-11-04 Thread wenxiong

Reviewed-by: Wen Xiong 

Thanks,
Wendy

Quoting Gabriel Krisman Bertazi :


Some new adapters require a special Configure Cache Parameters command
to enable the adapter write cache, so send this during the adapter
initialization if the adapter requires it.

Changes since v1:
- Fix checkpatch.pl warnings.

Signed-off-by: Gabriel Krisman Bertazi 
---
 drivers/scsi/ipr.c | 59  
+-

 drivers/scsi/ipr.h |  4 
 2 files changed, 62 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 5efc7ef..79fd9ff 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -7675,6 +7675,63 @@ static int ipr_ioafp_query_ioa_cfg(struct  
ipr_cmnd *ipr_cmd)

return IPR_RC_JOB_RETURN;
 }

+static int ipr_ioa_service_action_failed(struct ipr_cmnd *ipr_cmd)
+{
+   u32 ioasc = be32_to_cpu(ipr_cmd->s.ioasa.hdr.ioasc);
+
+   if (ioasc == IPR_IOASC_IR_INVALID_REQ_TYPE_OR_PKT)
+   return IPR_RC_JOB_CONTINUE;
+
+   return ipr_reset_cmd_failed(ipr_cmd);
+}
+
+static void ipr_build_ioa_service_action(struct ipr_cmnd *ipr_cmd,
+__be32 res_handle, u8 sa_code)
+{
+   struct ipr_ioarcb *ioarcb = _cmd->ioarcb;
+
+   ioarcb->res_handle = res_handle;
+   ioarcb->cmd_pkt.cdb[0] = IPR_IOA_SERVICE_ACTION;
+   ioarcb->cmd_pkt.cdb[1] = sa_code;
+   ioarcb->cmd_pkt.request_type = IPR_RQTYPE_IOACMD;
+}
+
+/**
+ * ipr_ioafp_set_caching_parameters - Issue Set Cache parameters service
+ * action
+ *
+ * Return value:
+ * none
+ **/
+static int ipr_ioafp_set_caching_parameters(struct ipr_cmnd *ipr_cmd)
+{
+   struct ipr_ioarcb *ioarcb = _cmd->ioarcb;
+   struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
+   struct ipr_inquiry_pageC4 *pageC4 = _cfg->vpd_cbs->pageC4_data;
+
+   ENTER;
+
+   ipr_cmd->job_step = ipr_ioafp_query_ioa_cfg;
+
+   if (pageC4->cache_cap[0] & IPR_CAP_SYNC_CACHE) {
+   ipr_build_ioa_service_action(ipr_cmd,
+cpu_to_be32(IPR_IOA_RES_HANDLE),
+IPR_IOA_SA_CHANGE_CACHE_PARAMS);
+
+   ioarcb->cmd_pkt.cdb[2] = 0x40;
+
+   ipr_cmd->job_step_failed = ipr_ioa_service_action_failed;
+   ipr_do_req(ipr_cmd, ipr_reset_ioa_job, ipr_timeout,
+  IPR_SET_SUP_DEVICE_TIMEOUT);
+
+   LEAVE;
+   return IPR_RC_JOB_RETURN;
+   }
+
+   LEAVE;
+   return IPR_RC_JOB_CONTINUE;
+}
+
 /**
  * ipr_ioafp_inquiry - Send an Inquiry to the adapter.
  * @ipr_cmd:   ipr command struct
@@ -7742,7 +7799,7 @@ static int ipr_ioafp_pageC4_inquiry(struct  
ipr_cmnd *ipr_cmd)

struct ipr_inquiry_pageC4 *pageC4 = _cfg->vpd_cbs->pageC4_data;

ENTER;
-   ipr_cmd->job_step = ipr_ioafp_query_ioa_cfg;
+   ipr_cmd->job_step = ipr_ioafp_set_caching_parameters;
memset(pageC4, 0, sizeof(*pageC4));

if (ipr_inquiry_page_supported(page0, 0xC4)) {
diff --git a/drivers/scsi/ipr.h b/drivers/scsi/ipr.h
index 7be1271..b16bcd1 100644
--- a/drivers/scsi/ipr.h
+++ b/drivers/scsi/ipr.h
@@ -216,6 +216,10 @@
 #define IPR_SET_ALL_SUPPORTED_DEVICES  0x80
 #define IPR_IOA_SHUTDOWN   0xF7
 #defineIPR_WR_BUF_DOWNLOAD_AND_SAVE0x05
+#define IPR_IOA_SERVICE_ACTION 0xD2
+
+/* IOA Service Actions */
+#define IPR_IOA_SA_CHANGE_CACHE_PARAMS 0x14

 /*
  * Timeouts
--
2.1.0



--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   >