[PATCH 2/6] block: add a API for persistent reservations

2015-08-04 Thread Christoph Hellwig
This commits adds a driver API and ioctls for controling persistent
reservations genericly at the block layer.  Persistent reservations
are supported by SCSI and NVMe and allow controlling who gets access
to a device in a shared storage setup.

Note that we add a pr_ops structure to struct block_device_operation
instead of adding the members directly to avoid bloating all instances
of devices that will never support persistent reservations.

Signed-off-by: Christoph Hellwig h...@lst.de
---
 Documentation/block/pr.txt | 107 +
 block/ioctl.c  |  85 +++
 include/linux/blkdev.h |   2 +
 include/linux/pr.h |  18 
 include/uapi/linux/pr.h|  45 +++
 5 files changed, 257 insertions(+)
 create mode 100644 Documentation/block/pr.txt
 create mode 100644 include/linux/pr.h
 create mode 100644 include/uapi/linux/pr.h

diff --git a/Documentation/block/pr.txt b/Documentation/block/pr.txt
new file mode 100644
index 000..1ced450
--- /dev/null
+++ b/Documentation/block/pr.txt
@@ -0,0 +1,107 @@
+
+Block layer support for Persistent reservations
+===
+
+The Linux kernel supports a user space interface for simplified
+Persistent Reservations which map to block devices that support
+these (like SCSI). Persistent Reservations allow restricting
+access to block devices to specific initiators in a shared storage
+setup.
+
+This document gives a general overview of the support ioctl commands,
+but for a more detailed reference please refer the the SCSI Primary
+Command standard, specifically the section on Reservations and the
+PERSISTENT RESERVE IN and PERSISTENT RESERVE OUT commands.
+
+All implementations are expected to ensure the reservations survive
+a power loss and cover all connections in a multi path environment.
+These behavior are optional in SPC but will be automatically applied
+by Linux.
+
+The following types of reservations are supported:
+
+ - PR_WRITE_EXCLUSIVE
+
+   Only the initiator that owns the reservation can write to the
+   device.  Any initiator can read from the device.
+
+ - PR_EXCLUSIVE_ACCESS
+
+   Only the initiator that owns the reservation can access the
+   device.
+
+ - PR_WRITE_EXCLUSIVE_REG_ONLY
+
+   Only initiators with a registered key can write to the device,
+   Any initiator can read from the device.
+
+ - PR_EXCLUSIVE_ACCESS_REG_ONLY
+
+   Only initiators with a registered key can access the device.
+
+ - PR_WRITE_EXCLUSIVE_ALL_REGS
+
+   Only initiators with a registered key can write to the device,
+   Any initiator can read from the device.
+   All initiators with a registered key are considered reservation
+   holders.
+   Please reference the SPC spec on the meaning of a reservation
+   holder if you want to use this type. 
+
+ - PR_EXCLUSIVE_ACCESS_ALL_REGS
+
+   Only initiators with a registered key can access the device.
+   All initiators with a registered key are considered reservation
+   holders.
+   Please reference the SPC spec on the meaning of a reservation
+   holder if you want to use this type. 
+
+
+1. IOC_PR_REGISTER
+
+This ioctl command registers a new reservation if the new_key argument
+is non-null.  If no existing reservation exists old_key must be zero,
+if an existing reservation should be replaced old_key must contain
+the old reservation key.
+
+If the new_key argument is 0 it unregisters the existing reservation passed
+in old_key.
+
+
+2. IOC_PR_REGISTER_IGNORE
+
+This ioctl command registers a new reservations with the key passed in
+new_key, ignoring and replacing any existing previous reservation.  The
+old_key argument is ignored.
+
+
+3. IOC_PR_RESERVE
+
+This ioctl command reserves the device and thus restricts access for other
+devices based on the type argument.  The key argument must be the existing
+reservation key for the device as acquired by the IOC_PR_REGISTER,
+IOC_PR_REGISTER_IGNORE, IOC_PR_PREEMPT or IOC_PR_PREEMPT_ABORT commands.
+
+
+4. IOC_PR_RELEASE
+
+This ioctl command releases the reservation specified by key and flags
+and thus removes any access restriction implied by it.
+
+
+5. IOC_PR_PREEMPT
+
+This ioctl command releases the existing reservation referred to by
+old_key and replaces it with a a new reservation of type type for the
+reservation key new_key.
+
+
+6. IOC_PR_PREEMPT_ABORT
+
+This ioctl command work like IOC_PR_PREEMPT except that it also aborts
+any outstanding command sent over a connection identified by old_key.
+
+7. IOC_PR_CLEAR
+
+This ioctl command unregisters both key and any other reservation key
+registered with the device and drops any existing reservation.
diff --git a/block/ioctl.c b/block/ioctl.c
index df62b47..34d8c77 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -7,6 +7,7 @@
 #include linux/backing-dev.h
 #include linux/fs.h
 #include 

[PATCH 3/6] sd: implement the persisten reservation API

2015-08-04 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig h...@lst.de
---
 drivers/scsi/sd.c | 90 +++
 1 file changed, 90 insertions(+)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 160e44e..e9bc210 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -51,6 +51,7 @@
 #include linux/async.h
 #include linux/slab.h
 #include linux/pm_runtime.h
+#include linux/pr.h
 #include asm/uaccess.h
 #include asm/unaligned.h
 
@@ -1535,6 +1536,94 @@ static int sd_compat_ioctl(struct block_device *bdev, 
fmode_t mode,
 }
 #endif
 
+static char sd_pr_type(enum pr_type type)
+{
+   switch (type) {
+   case PR_WRITE_EXCLUSIVE:
+   return 0x01;
+   case PR_EXCLUSIVE_ACCESS:
+   return 0x03;
+   case PR_WRITE_EXCLUSIVE_REG_ONLY:
+   return 0x05;
+   case PR_EXCLUSIVE_ACCESS_REG_ONLY:
+   return 0x06;
+   case PR_WRITE_EXCLUSIVE_ALL_REGS:
+   return 0x07;
+   case PR_EXCLUSIVE_ACCESS_ALL_REGS:
+   return 0x08;
+   default:
+   return 0;
+   }
+};
+
+static int sd_pr_command(struct block_device *bdev, u8 sa,
+   u64 key, u64 sa_key, u8 type, u8 flags)
+{
+   struct scsi_device *sdev = scsi_disk(bdev-bd_disk)-device;
+   struct scsi_sense_hdr sshdr;
+   int result;
+   u8 cmd[16] = { 0, };
+   u8 data[24] = { 0, };
+
+   cmd[0] = PERSISTENT_RESERVE_OUT;
+   cmd[1] = sa;
+   cmd[2] = type;
+   put_unaligned_be32(sizeof(data), cmd[5]);
+
+   put_unaligned_be64(key, data[0]);
+   put_unaligned_be64(sa_key, data[8]);
+   data[20] = flags;
+
+   result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, data, sizeof(data),
+   sshdr, SD_TIMEOUT, SD_MAX_RETRIES, NULL);
+
+   if ((driver_byte(result)  DRIVER_SENSE) 
+   (scsi_sense_valid(sshdr))) {
+   sdev_printk(KERN_INFO, sdev, PR commad failed: %d\n, result);
+   scsi_print_sense_hdr(sdev, NULL, sshdr);
+   }
+
+   return result;
+}
+
+static int sd_pr_register(struct block_device *bdev, u64 old_key, u64 new_key,
+   bool ignore)
+{
+   return sd_pr_command(bdev, ignore ? 0x06 : 0x00, old_key, new_key, 0,
+(1  0) /* APTPL */ |
+(1  2) /* ALL_TG_PT */);
+}
+
+static int sd_pr_reserve(struct block_device *bdev, u64 key, enum pr_type type)
+{
+   return sd_pr_command(bdev, 0x01, key, 0, sd_pr_type(type), 0);
+}
+
+static int sd_pr_release(struct block_device *bdev, u64 key, enum pr_type type)
+{
+   return sd_pr_command(bdev, 0x02, key, 0, sd_pr_type(type), 0);
+}
+
+static int sd_pr_preempt(struct block_device *bdev, u64 old_key, u64 new_key,
+   enum pr_type type, bool abort)
+{
+   return sd_pr_command(bdev, abort ? 0x05 : 0x04, old_key, new_key,
+sd_pr_type(type), 0);
+}
+
+static int sd_pr_clear(struct block_device *bdev, u64 key)
+{
+   return sd_pr_command(bdev, 0x03, key, 0, 0, 0);
+}
+
+static const struct pr_ops sd_pr_ops = {
+   .pr_register= sd_pr_register,
+   .pr_reserve = sd_pr_reserve,
+   .pr_release = sd_pr_release,
+   .pr_preempt = sd_pr_preempt,
+   .pr_clear   = sd_pr_clear,
+};
+
 static const struct block_device_operations sd_fops = {
.owner  = THIS_MODULE,
.open   = sd_open,
@@ -1547,6 +1636,7 @@ static const struct block_device_operations sd_fops = {
.check_events   = sd_check_events,
.revalidate_disk= sd_revalidate_disk,
.unlock_native_capacity = sd_unlock_native_capacity,
+   .pr_ops = sd_pr_ops,
 };
 
 /**
-- 
1.9.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 5/6] dm: split out a helper to find the ioctl target

2015-08-04 Thread Christoph Hellwig
We want to reuse this code for the persistent reservation handling,
so move it into a helper.

Signed-off-by: Christoph Hellwig h...@lst.de
---
 drivers/md/dm.c | 50 --
 1 file changed, 32 insertions(+), 18 deletions(-)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index c68eb91..8dfc760 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -556,18 +556,16 @@ static int dm_blk_getgeo(struct block_device *bdev, 
struct hd_geometry *geo)
return dm_get_geometry(md, geo);
 }
 
-static int dm_blk_ioctl(struct block_device *bdev, fmode_t mode,
-   unsigned int cmd, unsigned long arg)
+static int dm_get_ioctl_table(struct mapped_device *md,
+   struct dm_target **tgt, struct block_device **bdev,
+   fmode_t *mode, int *srcu_idx)
 {
-   struct mapped_device *md = bdev-bd_disk-private_data;
-   int srcu_idx;
struct dm_table *map;
-   struct dm_target *tgt;
-   int r = -ENOTTY;
+   int r;
 
 retry:
-   map = dm_get_live_table(md, srcu_idx);
-
+   r = -ENOTTY;
+   map = dm_get_live_table(md, srcu_idx);
if (!map || !dm_table_get_size(map))
goto out;
 
@@ -575,8 +573,9 @@ retry:
if (dm_table_get_num_targets(map) != 1)
goto out;
 
-   tgt = dm_table_get_target(map, 0);
-   if (!tgt-type-ioctl)
+   *tgt = dm_table_get_target(map, 0);
+
+   if (!(*tgt)-type-ioctl)
goto out;
 
if (dm_suspended_md(md)) {
@@ -584,10 +583,32 @@ retry:
goto out;
}
 
-   r = tgt-type-ioctl(tgt, bdev, mode);
+   r = (*tgt)-type-ioctl(*tgt, bdev, mode);
if (r  0)
goto out;
 
+   return r;
+
+out:
+   dm_put_live_table(md, *srcu_idx);
+   if (r == -ENOTCONN) {
+   msleep(10);
+   goto retry;
+   }
+   return r;
+}
+
+static int dm_blk_ioctl(struct block_device *bdev, fmode_t mode,
+   unsigned int cmd, unsigned long arg)
+{
+   struct mapped_device *md = bdev-bd_disk-private_data;
+   struct dm_target *tgt;
+   int srcu_idx, r;
+
+   r = dm_get_ioctl_table(md, tgt, bdev, mode, srcu_idx);
+   if (r  0)
+   return r;
+
if (r  0) {
r = scsi_verify_blk_ioctl(NULL, cmd);
if (r)
@@ -595,15 +616,8 @@ retry:
}
 
r =  __blkdev_driver_ioctl(bdev, mode, cmd, arg);
-
 out:
dm_put_live_table(md, srcu_idx);
-
-   if (r == -ENOTCONN) {
-   msleep(10);
-   goto retry;
-   }
-
return r;
 }
 
-- 
1.9.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 6/6] dm: add support for passing through persistent reservations

2015-08-04 Thread Christoph Hellwig
This adds support to pass through persistent reservation requests
similar to the existing ioctl handling, and with the same limitations,
e.g. devices may only have a single target attached.

This is mostly intended for multipathing.

Signed-off-by: Christoph Hellwig h...@lst.de
---
 drivers/md/dm.c | 122 
 1 file changed, 122 insertions(+)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 8dfc760..3388fa6 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -24,6 +24,7 @@
 #include linux/ktime.h
 #include linux/elevator.h /* for rq_end_sector() */
 #include linux/blk-mq.h
+#include linux/pr.h
 
 #include trace/events/block.h
 
@@ -3670,11 +3671,132 @@ void dm_free_md_mempools(struct dm_md_mempools *pools)
kfree(pools);
 }
 
+static int dm_pr_register(struct block_device *bdev, u64 old_key, u64 new_key,
+   bool ignore)
+{
+   struct mapped_device *md = bdev-bd_disk-private_data;
+   const struct pr_ops *ops;
+   struct dm_target *tgt;
+   fmode_t mode;
+   int srcu_idx, r;
+
+   r = dm_get_ioctl_table(md, tgt, bdev, mode, srcu_idx);
+   if (r  0)
+   return r;
+
+   ops = bdev-bd_disk-fops-pr_ops;
+   if (ops  ops-pr_register)
+   r = ops-pr_register(bdev, old_key, new_key, ignore);
+   else
+   r = -EOPNOTSUPP;
+
+   dm_put_live_table(md, srcu_idx);
+   return r;
+}
+
+static int dm_pr_reserve(struct block_device *bdev, u64 key, enum pr_type type)
+{
+   struct mapped_device *md = bdev-bd_disk-private_data;
+   const struct pr_ops *ops;
+   struct dm_target *tgt;
+   fmode_t mode;
+   int srcu_idx, r;
+
+   r = dm_get_ioctl_table(md, tgt, bdev, mode, srcu_idx);
+   if (r  0)
+   return r;
+
+   ops = bdev-bd_disk-fops-pr_ops;
+   if (ops  ops-pr_reserve)
+   r = ops-pr_reserve(bdev, key, type);
+   else
+   r = -EOPNOTSUPP;
+
+   dm_put_live_table(md, srcu_idx);
+   return r;
+}
+
+static int dm_pr_release(struct block_device *bdev, u64 key, enum pr_type type)
+{
+   struct mapped_device *md = bdev-bd_disk-private_data;
+   const struct pr_ops *ops;
+   struct dm_target *tgt;
+   fmode_t mode;
+   int srcu_idx, r;
+
+   r = dm_get_ioctl_table(md, tgt, bdev, mode, srcu_idx);
+   if (r  0)
+   return r;
+
+   ops = bdev-bd_disk-fops-pr_ops;
+   if (ops  ops-pr_release)
+   r = ops-pr_release(bdev, key, type);
+   else
+   r = -EOPNOTSUPP;
+
+   dm_put_live_table(md, srcu_idx);
+   return r;
+}
+
+static int dm_pr_preempt(struct block_device *bdev, u64 old_key, u64 new_key,
+   enum pr_type type, bool abort)
+{
+   struct mapped_device *md = bdev-bd_disk-private_data;
+   const struct pr_ops *ops;
+   struct dm_target *tgt;
+   fmode_t mode;
+   int srcu_idx, r;
+
+   r = dm_get_ioctl_table(md, tgt, bdev, mode, srcu_idx);
+   if (r  0)
+   return r;
+
+   ops = bdev-bd_disk-fops-pr_ops;
+   if (ops  ops-pr_preempt)
+   r = ops-pr_preempt(bdev, old_key, new_key, type, abort);
+   else
+   r = -EOPNOTSUPP;
+
+   dm_put_live_table(md, srcu_idx);
+   return r;
+}
+
+static int dm_pr_clear(struct block_device *bdev, u64 key)
+{
+   struct mapped_device *md = bdev-bd_disk-private_data;
+   const struct pr_ops *ops;
+   struct dm_target *tgt;
+   fmode_t mode;
+   int srcu_idx, r;
+
+   r = dm_get_ioctl_table(md, tgt, bdev, mode, srcu_idx);
+   if (r  0)
+   return r;
+
+   ops = bdev-bd_disk-fops-pr_ops;
+   if (ops  ops-pr_clear)
+   r = ops-pr_clear(bdev, key);
+   else
+   r = -EOPNOTSUPP;
+
+   dm_put_live_table(md, srcu_idx);
+   return r;
+}
+
+static const struct pr_ops dm_pr_ops = {
+   .pr_register= dm_pr_register,
+   .pr_reserve = dm_pr_reserve,
+   .pr_release = dm_pr_release,
+   .pr_preempt = dm_pr_preempt,
+   .pr_clear   = dm_pr_clear,
+};
+
 static const struct block_device_operations dm_blk_dops = {
.open = dm_blk_open,
.release = dm_blk_close,
.ioctl = dm_blk_ioctl,
.getgeo = dm_blk_getgeo,
+   .pr_ops = dm_pr_ops,
.owner = THIS_MODULE
 };
 
-- 
1.9.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] scsi/be2iscsi: Fix logical-not-parentheses compilation warning

2015-08-04 Thread Johannes Thumshirn

Ok, it has cost me quite some time to figure out what !length  0 is
actually doing, but looks ok to me.


Tomer Barletz barl...@gmail.com writes:

 This fixes the following warning seen with GCC v5.1:
 warning: logical not is only applied to the left hand side of
 comparison [-Wlogical-not-parentheses].

 Signed-off-by: Tomer Barletz barl...@gmail.com
 ---
  drivers/scsi/be2iscsi/be_main.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
 index 7a6dbfb..ff8d40e 100644
 --- a/drivers/scsi/be2iscsi/be_main.c
 +++ b/drivers/scsi/be2iscsi/be_main.c
 @@ -3184,7 +3184,7 @@ be_sgl_create_contiguous(void *virtual_address,
  {
   WARN_ON(!virtual_address);
   WARN_ON(!physical_address);
 - WARN_ON(!length  0);
 + WARN_ON(0 == length);

Please write WARN_ON(length == 0);

   WARN_ON(!sgl);
  
   sgl-va = virtual_address;


Given the above is swapped:
Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
Key fingerprint = EC38 9CAB C2C4 F25D 8600  D0D0 0393 969D 2D76 0850
--
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] megaraid_sas: fix missing { } braces

2015-08-04 Thread Johannes Thumshirn

Hi Colin,

Colin King colin.k...@canonical.com writes:

 From: Colin Ian King colin.k...@canonical.com

 Static analysis by smatch indicated that there was a curly
 braces issue:

 drivers/scsi/megaraid/megaraid_sas_base.c:6139
   megasas_mgmt_fw_ioctl() warn: curly braces intended?

 Add braces in the appropriate place so that kbuf_arr[i] gets
 set to NULL only when we need to.  Also, remove whitespace
 between kbuff_arr and [].

I don't quite get where you removed that whitespace. Might it be a left
over from another version of the patch?


 Signed-off-by: Colin Ian King colin.k...@canonical.com
 ---
  drivers/scsi/megaraid/megaraid_sas_base.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

 diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
 b/drivers/scsi/megaraid/megaraid_sas_base.c
 index 71b884d..8face78 100644
 --- a/drivers/scsi/megaraid/megaraid_sas_base.c
 +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
 @@ -6131,12 +6131,13 @@ megasas_mgmt_fw_ioctl(struct megasas_instance 
 *instance,
   }
  
   for (i = 0; i  ioc-sge_count; i++) {
 - if (kbuff_arr[i])
 + if (kbuff_arr[i]) {
   dma_free_coherent(instance-pdev-dev,
 le32_to_cpu(kern_sge32[i].length),
 kbuff_arr[i],
 le32_to_cpu(kern_sge32[i].phys_addr));
   kbuff_arr[i] = NULL;
 + }
   }
  
   megasas_return_cmd(instance, cmd);

For the curly braces part:
Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

While you're up to it, care to check drivers/scsi/bfa as well? There was
a patch somewhen in the past but it seems it wasn't applied. But if
found this bugzilla entry
https://bugzilla.kernel.org/show_bug.cgi?id=98261
for it.

Thanks,
Johannes

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
Key fingerprint = EC38 9CAB C2C4 F25D 8600  D0D0 0393 969D 2D76 0850
--
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/6] block: cleanup blkdev_ioctl

2015-08-04 Thread Christoph Hellwig
Split out helpers for all non-trivial ioctls to make this function simpler,
and also start passing around a pointer version of the argument, as that's
what most ioctl handlers actually need.

Signed-off-by: Christoph Hellwig h...@lst.de
---
 block/ioctl.c | 227 --
 1 file changed, 127 insertions(+), 100 deletions(-)

diff --git a/block/ioctl.c b/block/ioctl.c
index 8061eba..df62b47 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -193,10 +193,20 @@ int blkdev_reread_part(struct block_device *bdev)
 }
 EXPORT_SYMBOL(blkdev_reread_part);
 
-static int blk_ioctl_discard(struct block_device *bdev, uint64_t start,
-uint64_t len, int secure)
+static int blk_ioctl_discard(struct block_device *bdev, fmode_t mode,
+   unsigned long arg, unsigned long flags)
 {
-   unsigned long flags = 0;
+   uint64_t range[2];
+   uint64_t start, len;
+
+   if (!(mode  FMODE_WRITE))
+   return -EBADF;
+
+   if (copy_from_user(range, (void __user *)arg, sizeof(range)))
+   return -EFAULT;
+
+   start = range[0];
+   len = range[1];
 
if (start  511)
return -EINVAL;
@@ -207,14 +217,24 @@ static int blk_ioctl_discard(struct block_device *bdev, 
uint64_t start,
 
if (start + len  (i_size_read(bdev-bd_inode)  9))
return -EINVAL;
-   if (secure)
-   flags |= BLKDEV_DISCARD_SECURE;
return blkdev_issue_discard(bdev, start, len, GFP_KERNEL, flags);
 }
 
-static int blk_ioctl_zeroout(struct block_device *bdev, uint64_t start,
-uint64_t len)
+static int blk_ioctl_zeroout(struct block_device *bdev, fmode_t mode,
+   unsigned long arg)
 {
+   uint64_t range[2];
+   uint64_t start, len;
+
+   if (!(mode  FMODE_WRITE))
+   return -EBADF;
+
+   if (copy_from_user(range, (void __user *)arg, sizeof(range)))
+   return -EFAULT;
+
+   start = range[0];
+   len = range[1];
+
if (start  511)
return -EINVAL;
if (len  511)
@@ -295,89 +315,115 @@ static inline int is_unrecognized_ioctl(int ret)
ret == -ENOIOCTLCMD;
 }
 
-/*
- * always keep this in sync with compat_blkdev_ioctl()
- */
-int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
-   unsigned long arg)
+static int blkdev_flushbuf(struct block_device *bdev, fmode_t mode,
+   unsigned cmd, unsigned long arg)
 {
-   struct gendisk *disk = bdev-bd_disk;
-   struct backing_dev_info *bdi;
-   loff_t size;
-   int ret, n;
-   unsigned int max_sectors;
+   int ret;
 
-   switch(cmd) {
-   case BLKFLSBUF:
-   if (!capable(CAP_SYS_ADMIN))
-   return -EACCES;
-
-   ret = __blkdev_driver_ioctl(bdev, mode, cmd, arg);
-   if (!is_unrecognized_ioctl(ret))
-   return ret;
+   if (!capable(CAP_SYS_ADMIN))
+   return -EACCES;
 
-   fsync_bdev(bdev);
-   invalidate_bdev(bdev);
-   return 0;
+   ret = __blkdev_driver_ioctl(bdev, mode, cmd, arg);
+   if (!is_unrecognized_ioctl(ret))
+   return ret;
 
-   case BLKROSET:
-   ret = __blkdev_driver_ioctl(bdev, mode, cmd, arg);
-   if (!is_unrecognized_ioctl(ret))
-   return ret;
-   if (!capable(CAP_SYS_ADMIN))
-   return -EACCES;
-   if (get_user(n, (int __user *)(arg)))
-   return -EFAULT;
-   set_device_ro(bdev, n);
-   return 0;
+   fsync_bdev(bdev);
+   invalidate_bdev(bdev);
+   return 0;
+}
 
-   case BLKDISCARD:
-   case BLKSECDISCARD: {
-   uint64_t range[2];
+static int blkdev_roset(struct block_device *bdev, fmode_t mode,
+   unsigned cmd, unsigned long arg)
+{
+   int ret, n;
 
-   if (!(mode  FMODE_WRITE))
-   return -EBADF;
+   ret = __blkdev_driver_ioctl(bdev, mode, cmd, arg);
+   if (!is_unrecognized_ioctl(ret))
+   return ret;
+   if (!capable(CAP_SYS_ADMIN))
+   return -EACCES;
+   if (get_user(n, (int __user *)arg))
+   return -EFAULT;
+   set_device_ro(bdev, n);
+   return 0;
+}
 
-   if (copy_from_user(range, (void __user *)arg, sizeof(range)))
-   return -EFAULT;
+static int blkdev_getgeo(struct block_device *bdev,
+   struct hd_geometry __user *argp)
+{
+   struct gendisk *disk = bdev-bd_disk;
+   struct hd_geometry geo;
+   int ret;
 
-   return blk_ioctl_discard(bdev, range[0], range[1],
-cmd == BLKSECDISCARD);
-   }
-   case BLKZEROOUT: {
-   uint64_t range[2];
+   if 

Persistent Reservation API

2015-08-04 Thread Christoph Hellwig
This series adds support for a simplified persistent reservation API
to the block layer.  The intent is that both in-kernel and userspace
consumers can use the API instead of having to hand craft SCSI or NVMe
command through the various pass through interfaces.  It also adds
DM support as getting reservations through dm-multipath is a major
pain with the current scheme.

NVMe support currently isn't included as I don't have a multihost
NVMe setup to test on, but if I can find a volunteer to test it I'm
happy to write the code for it.

The ioctl API is documented in Documentation/block/pr.txt, but to
fully understand the concept you'll have to read up the SPC spec,
PRs are too complicated that trying to rephrase them into different
terminology is just going to create confusion.

I also have a set of simple test tools available at:

git://git.infradead.org/users/hch/pr-tests.git

--
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] [SCSI] bfa: fix missing { } braces

2015-08-04 Thread Anil Gurumurthy
Hi Colin,
  We will fix the indentation in the next set of patches that we submit 
upstream.

Thanks,
Anil

-Original Message-
From: Colin King [mailto:colin.k...@canonical.com] 
Sent: 03 August 2015 20:05
To: Anil Gurumurthy; Sudarsana Kalluru; James E.J. Bottomley; linux-scsi
Cc: linux-kernel
Subject: [PATCH] [SCSI] bfa: fix missing { } braces

From: Colin Ian King colin.k...@canonical.com

Static analysis by smatch indicated that there was a curly braces issue:

drivers/scsi/bfa/bfa_ioc.c:3668 bfa_cb_sfp_state_query()
warn: curly braces intended?
drivers/scsi/bfa/bfa_ioc.c:3671 bfa_cb_sfp_state_query()
warn: inconsistent indenting
drivers/scsi/bfa/bfa_ioc.c:3676 bfa_cb_sfp_state_query()
warn: curly braces intended?

The fix matches the intended logic based on the original indentation layout of 
the code.

Signed-off-by: Colin Ian King colin.k...@canonical.com
---
 drivers/scsi/bfa/bfa_ioc.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c index 
315d6d6..59c3492 100644
--- a/drivers/scsi/bfa/bfa_ioc.c
+++ b/drivers/scsi/bfa/bfa_ioc.c
@@ -3662,7 +3662,7 @@ bfa_cb_sfp_state_query(struct bfa_sfp_s *sfp)
bfa_trc(sfp, sfp-portspeed);
if (sfp-media) {
bfa_sfp_media_get(sfp);
-   if (sfp-state_query_cbfn)
+   if (sfp-state_query_cbfn) {
sfp-state_query_cbfn(sfp-state_query_cbarg,
sfp-status);
sfp-media = NULL;
@@ -3670,14 +3670,16 @@ bfa_cb_sfp_state_query(struct bfa_sfp_s *sfp)
 
if (sfp-portspeed) {
sfp-status = bfa_sfp_speed_valid(sfp, sfp-portspeed);
-   if (sfp-state_query_cbfn)
+   if (sfp-state_query_cbfn) {
sfp-state_query_cbfn(sfp-state_query_cbarg,
sfp-status);
sfp-portspeed = BFA_PORT_SPEED_UNKNOWN;
+   }
}
 
sfp-state_query_lock = 0;
sfp-state_query_cbfn = NULL;
+   }
 }
 
 /*
--
2.5.0

attachment: winmail.dat

Re: [PATCH v2 4/8] xen: Use the correctly the Xen memory terminologies

2015-08-04 Thread Boris Ostrovsky

On 08/04/2015 02:12 PM, Julien Grall wrote:
  
  /*

   * We detect special mappings in one of two ways:
@@ -217,9 +232,13 @@ static inline unsigned long bfn_to_local_pfn(unsigned long 
mfn)
  
  /* VIRT - MACHINE conversion */

  #define virt_to_machine(v)(phys_to_machine(XPADDR(__pa(v
-#define virt_to_pfn(v)  (PFN_DOWN(__pa(v)))
  #define virt_to_mfn(v)(pfn_to_mfn(virt_to_pfn(v)))
  #define mfn_to_virt(m)(__va(mfn_to_pfn(m)  PAGE_SHIFT))
+#define virt_to_pfn(v)  (PFN_DOWN(__pa(v)))


This looks like unnecessary change.



diff --git a/drivers/video/fbdev/xen-fbfront.c 
b/drivers/video/fbdev/xen-fbfront.c
index 09dc447..25e3cce 100644
--- a/drivers/video/fbdev/xen-fbfront.c
+++ b/drivers/video/fbdev/xen-fbfront.c
@@ -539,7 +539,7 @@ static int xenfb_remove(struct xenbus_device *dev)
  
  static unsigned long vmalloc_to_mfn(void *address)

  {
-   return pfn_to_mfn(vmalloc_to_pfn(address));
+   return pfn_to_gfn(vmalloc_to_pfn(address));
  }


Are you sure? This will return vmalloc_to_pfn(address)).


-boris
--
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/14] qla2xxx: Do not reset ISP for error entry with an out of range handle.

2015-08-04 Thread Himanshu Madhani
From: Chad Dupuis chad.dup...@qlogic.com

Instead of resetting the adapter wait for the login to timeout
and retry. Resetting the adapter can cause extended path recovery
times.

Signed-off-by: Chad Dupuis chad.dup...@qlogic.com
Signed-off-by: Himanshu Madhani himanshu.madh...@qlogic.com
---
 drivers/scsi/qla2xxx/qla_isr.c |8 +---
 1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index a82ba35..fd7b86a 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -2474,13 +2474,7 @@ qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que 
*rsp, sts_entry_t *pkt)
}
 fatal:
ql_log(ql_log_warn, vha, 0x5030,
-   Error entry - invalid handle/queue.\n);
-
-   if (IS_P3P_TYPE(ha))
-   set_bit(FCOE_CTX_RESET_NEEDED, vha-dpc_flags);
-   else
-   set_bit(ISP_ABORT_NEEDED, vha-dpc_flags);
-   qla2xxx_wake_dpc(vha);
+   Error entry - invalid handle/queue (%04x).\n, que);
 }
 
 /**
-- 
1.7.7

--
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/14] qla2xxx: Add support to show MPI and PEP FW version for ISP27xx.

2015-08-04 Thread Himanshu Madhani
From: Sawan Chandak sawan.chan...@qlogic.com

Signed-off-by: Sawan Chandak sawan.chan...@qlogic.com
Signed-off-by: Himanshu Madhani himanshu.madh...@qlogic.com
---
 drivers/scsi/qla2xxx/qla_attr.c |   19 ++-
 drivers/scsi/qla2xxx/qla_def.h  |1 +
 drivers/scsi/qla2xxx/qla_mbx.c  |   13 -
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 437254e..b6bf948 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -1348,7 +1348,8 @@ qla2x00_mpi_version_show(struct device *dev, struct 
device_attribute *attr,
scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
struct qla_hw_data *ha = vha-hw;
 
-   if (!IS_QLA81XX(ha)  !IS_QLA8031(ha)  !IS_QLA8044(ha))
+   if (!IS_QLA81XX(ha)  !IS_QLA8031(ha)  !IS_QLA8044(ha) 
+   !IS_QLA27XX(ha))
return scnprintf(buf, PAGE_SIZE, \n);
 
return scnprintf(buf, PAGE_SIZE, %d.%02d.%02d (%x)\n,
@@ -1537,6 +1538,20 @@ qla2x00_allow_cna_fw_dump_store(struct device *dev,
return strlen(buf);
 }
 
+static ssize_t
+qla2x00_pep_version_show(struct device *dev, struct device_attribute *attr,
+   char *buf)
+{
+   scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+   struct qla_hw_data *ha = vha-hw;
+
+   if (!IS_QLA27XX(ha))
+   return scnprintf(buf, PAGE_SIZE, \n);
+
+   return scnprintf(buf, PAGE_SIZE, %d.%02d.%02d\n,
+   ha-pep_version[0], ha-pep_version[1], ha-pep_version[2]);
+}
+
 static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, NULL);
 static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL);
 static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL);
@@ -1581,6 +1596,7 @@ static DEVICE_ATTR(fw_dump_size, S_IRUGO, 
qla2x00_fw_dump_size_show, NULL);
 static DEVICE_ATTR(allow_cna_fw_dump, S_IRUGO | S_IWUSR,
   qla2x00_allow_cna_fw_dump_show,
   qla2x00_allow_cna_fw_dump_store);
+static DEVICE_ATTR(pep_version, S_IRUGO, qla2x00_pep_version_show, NULL);
 
 struct device_attribute *qla2x00_host_attrs[] = {
dev_attr_driver_version,
@@ -1614,6 +1630,7 @@ struct device_attribute *qla2x00_host_attrs[] = {
dev_attr_diag_megabytes,
dev_attr_fw_dump_size,
dev_attr_allow_cna_fw_dump,
+   dev_attr_pep_version,
NULL,
 };
 
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 06d61a4..8becec9 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -3289,6 +3289,7 @@ struct qla_hw_data {
uint8_t mpi_version[3];
uint32_tmpi_capabilities;
uint8_t phy_version[3];
+   uint8_t pep_version[3];
 
/* Firmware dump template */
void*fw_dump_template;
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 5ac6577..9da519b 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -555,7 +555,9 @@ qla2x00_get_fw_version(scsi_qla_host_t *vha)
if (IS_FWI2_CAPABLE(ha))
mcp-in_mb |= MBX_17|MBX_16|MBX_15;
if (IS_QLA27XX(ha))
-   mcp-in_mb |= MBX_21|MBX_20|MBX_19|MBX_18;
+   mcp-in_mb |= MBX_23 | MBX_22 | MBX_21 | MBX_20 | MBX_19 |
+   MBX_18 | MBX_14 | MBX_13 | MBX_11 | MBX_10 | MBX_9 | MBX_8;
+
mcp-flags = 0;
mcp-tov = MBX_TOV_SECONDS;
rval = qla2x00_mailbox_command(vha, mcp);
@@ -571,6 +573,7 @@ qla2x00_get_fw_version(scsi_qla_host_t *vha)
ha-fw_memory_size = 0x1;   /* Defaults to 128KB. */
else
ha-fw_memory_size = (mcp-mb[5]  16) | mcp-mb[4];
+
if (IS_QLA81XX(vha-hw) || IS_QLA8031(vha-hw) || IS_QLA8044(ha)) {
ha-mpi_version[0] = mcp-mb[10]  0xff;
ha-mpi_version[1] = mcp-mb[11]  8;
@@ -580,6 +583,7 @@ qla2x00_get_fw_version(scsi_qla_host_t *vha)
ha-phy_version[1] = mcp-mb[9]  8;
ha-phy_version[2] = mcp-mb[9]  0xff;
}
+
if (IS_FWI2_CAPABLE(ha)) {
ha-fw_attributes_h = mcp-mb[15];
ha-fw_attributes_ext[0] = mcp-mb[16];
@@ -591,7 +595,14 @@ qla2x00_get_fw_version(scsi_qla_host_t *vha)
%s: Ext_FwAttributes Upper: 0x%x, Lower: 0x%x.\n,
__func__, mcp-mb[17], mcp-mb[16]);
}
+
if (IS_QLA27XX(ha)) {
+   ha-mpi_version[0] = mcp-mb[10]  0xff;
+   ha-mpi_version[1] = mcp-mb[11]  8;
+   ha-mpi_version[2] = mcp-mb[11]  0xff;
+   ha-pep_version[0] = mcp-mb[13]  0xff;
+   ha-pep_version[1] = mcp-mb[14]  8;
+   ha-pep_version[2] = mcp-mb[14]  0xff;
ha-fw_shared_ram_start = (mcp-mb[19]  16) | mcp-mb[18];
ha-fw_shared_ram_end = (mcp-mb[21]  

[PATCH v2 0/8] Use correctly the Xen memory terminologies in Linux

2015-08-04 Thread Julien Grall
Hi all,

This patch series aims to use the memory terminologies described in
include/xen/mm.h [1] for Linux xen code.

Linux is using mistakenly MFN when GFN is meant, I suspect this is because the
first support of Xen was for PV. This has brought some misimplementation
of memory helpers on ARM and make the developper confused about the expected
behavior.

For instance, with pfn_to_mfn, we expect to get a MFN based on the name.
Although, if we look at the implementation on x86, it's returning a GFN.
Most of the callers are also using it this way.

The first 2 patches of this series is ARM related in order to remove
PV specific helpers which should not be used and fixing the implementation of
pfn_to_mfn.

The rest of the series is here rename most of the usage in the common code
of MFN to GFN. I also took the opportunity to replace most of the call to
pfn_to_gfn in the common code by page_to_gfn avoid construction such
as pfn_to_gfn(page_to_pfn(...).

Note the one xen-blkfront will be dropped by 64K series [2], I can include it
if necessary.

Major changes in v2:
- Use bfn rather than dfn for the DMA address
- Re-introduced pfn_to_mfn for PV guests only
- Typoes

For all the changes see in each patch.

This series is based on linus's branch. A branch with all the patches
can be found here:
git://xenbits.xen.org/people/julieng/linux-arm.git branch page-renaming-v2

It was been boot tested on ARM64 and only built for x86 and ARM32.
I would be happy if someone can give a try on x86 as I don't have a x86
box setup with Xen.

Sincerely yours,

[1] 
http://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=e758ed14f390342513405dd766e874934573e6cb
[2] https://lkml.org/lkml/2015/7/9/628

Cc: Boris Ostrovsky boris.ostrov...@oracle.com
Cc: David Vrabel david.vra...@citrix.com
Cc: Dmitry Torokhov dmitry.torok...@gmail.com
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Cc: H. Peter Anvin h...@zytor.com
Cc: Ian Campbell ian.campb...@citrix.com
Cc: Ingo Molnar mi...@redhat.com
Cc: James E.J. Bottomley jbottom...@odin.com
Cc: Jean-Christophe Plagniol-Villard plagn...@jcrosoft.com
Cc: Jiri Slaby jsl...@suse.com
Cc: Juergen Gross jgr...@suse.com
Cc: Konrad Rzeszutek Wilk konrad.w...@oracle.com
Cc: linux-...@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-fb...@vger.kernel.org
Cc: linux-in...@vger.kernel.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-scsi@vger.kernel.org
Cc: net...@vger.kernel.org
Cc: Roger Pau Monné roger@citrix.com
Cc: Russell King li...@arm.linux.org.uk
Cc: Stefano Stabellini stefano.stabell...@eu.citrix.com
Cc: Thomas Gleixner t...@linutronix.de
Cc: Tomi Valkeinen tomi.valkei...@ti.com
Cc: Wei Liu wei.l...@citrix.com
Cc: x...@kernel.org

Julien Grall (8):
  arm/xen: Remove helpers which are PV specific
  xen: Make clear that swiotlb and biomerge are dealing with DMA address
  arm/xen: implement correctly pfn_to_mfn
  xen: Use the correctly the Xen memory terminologies
  xen/tmem: Use page_to_gfn rather than pfn_to_gfn
  video/xen-fbfront: Further s/MFN/GFN clean-up
  hvc/xen: Further s/MFN/GFN clean-up
  xen/privcmd: Further s/MFN/GFN/ clean-up

 arch/arm/include/asm/xen/page.h | 44 -
 arch/arm/xen/enlighten.c| 18 +++---
 arch/arm/xen/mm.c   |  4 +--
 arch/x86/include/asm/xen/page.h | 37 +--
 arch/x86/xen/mmu.c  | 32 
 arch/x86/xen/smp.c  |  2 +-
 drivers/block/xen-blkfront.c|  6 ++---
 drivers/input/misc/xen-kbdfront.c   |  4 +--
 drivers/net/xen-netback/netback.c   |  4 +--
 drivers/net/xen-netfront.c  |  8 +++---
 drivers/scsi/xen-scsifront.c|  8 +++---
 drivers/tty/hvc/hvc_xen.c   | 18 ++
 drivers/video/fbdev/xen-fbfront.c   | 20 +++
 drivers/xen/balloon.c   |  2 +-
 drivers/xen/biomerge.c  |  6 ++---
 drivers/xen/events/events_base.c|  2 +-
 drivers/xen/events/events_fifo.c|  4 +--
 drivers/xen/gntalloc.c  |  3 ++-
 drivers/xen/manage.c|  2 +-
 drivers/xen/privcmd.c   | 44 -
 drivers/xen/swiotlb-xen.c   | 16 ++--
 drivers/xen/tmem.c  | 21 ++--
 drivers/xen/xenbus/xenbus_client.c  |  2 +-
 drivers/xen/xenbus/xenbus_dev_backend.c |  2 +-
 drivers/xen/xenbus/xenbus_probe.c   |  8 +++---
 drivers/xen/xlate_mmu.c | 18 +++---
 include/uapi/xen/privcmd.h  |  4 +++
 include/xen/page.h  |  4 +--
 include/xen/xen-ops.h   | 10 
 29 files changed, 183 insertions(+), 170 deletions(-)

-- 
2.1.4

--
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  

Re: Persistent Reservation API

2015-08-04 Thread Mike Snitzer
On Tue, Aug 04 2015 at  3:11am -0400,
Christoph Hellwig h...@lst.de wrote:

 This series adds support for a simplified persistent reservation API
 to the block layer.  The intent is that both in-kernel and userspace
 consumers can use the API instead of having to hand craft SCSI or NVMe
 command through the various pass through interfaces.  It also adds
 DM support as getting reservations through dm-multipath is a major
 pain with the current scheme.

The DM changes need to go through linux-dm.git.  Once the block and SCSI
bits land I'll rebase accordingly.  That cross-maintainer logisitics
aside, I'll reply with feedback on the DM patches.
--
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 4/8] xen: Use the correctly the Xen memory terminologies

2015-08-04 Thread Julien Grall
Based on include/xen/mm.h [1], Linux is mistakenly using MFN when GFN
is meant, I suspect this is because the first support for Xen was for
PV. This resulted in some misimplementation of helpers on ARM and
confused developers about the expected behavior.

For instance, with pfn_to_mfn, we expect to get an MFN based on the name.
Although, if we look at the implementation on x86, it's returning a GFN.

For clarity and avoid new confusion, replace any reference to mfn with
gfn in any helpers used by PV drivers. The x86 code will still keep some
reference of pfn_to_mfn but exclusively for PV (a BUG_ON has been added
to ensure this). No changes as been made in the hypercall field, even
though they may be invalid, in order to keep the same as the defintion
in xen repo.

Take also the opportunity to simplify simple construction such
as pfn_to_mfn(page_to_pfn(page)) into page_to_gfn. More complex clean up
will come in follow-up patches.

[1] 
http://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=e758ed14f390342513405dd766e874934573e6cb

Signed-off-by: Julien Grall julien.gr...@citrix.com
Cc: Stefano Stabellini stefano.stabell...@eu.citrix.com
Cc: Russell King li...@arm.linux.org.uk
Cc: Konrad Rzeszutek Wilk konrad.w...@oracle.com
Cc: Boris Ostrovsky boris.ostrov...@oracle.com
Cc: David Vrabel david.vra...@citrix.com
Cc: Thomas Gleixner t...@linutronix.de
Cc: Ingo Molnar mi...@redhat.com
Cc: H. Peter Anvin h...@zytor.com
Cc: x...@kernel.org
Cc: Roger Pau Monné roger@citrix.com
Cc: Dmitry Torokhov dmitry.torok...@gmail.com
Cc: Ian Campbell ian.campb...@citrix.com
Cc: Wei Liu wei.l...@citrix.com
Cc: Juergen Gross jgr...@suse.com
Cc: James E.J. Bottomley jbottom...@odin.com
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Cc: Jiri Slaby jsl...@suse.com
Cc: Jean-Christophe Plagniol-Villard plagn...@jcrosoft.com
Cc: Tomi Valkeinen tomi.valkei...@ti.com
Cc: linux-in...@vger.kernel.org
Cc: net...@vger.kernel.org
Cc: linux-scsi@vger.kernel.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-fb...@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org

---
Note that I've re-introduced mfn_to_pfn  co only for x86 PV code.
The helpers contain a BUG_ON to ensure that it's never called for
auto-translated guests. I did as best as my can to determine whether
mfn or gfn helpers should be used. Although, I haven't tried to boot
it.

It may be possible to do further cleanup in the mmu.c where I found
some check to auto-translated. I'm not sure why given that the pvmmu
callback are only used for non-auto translated guest.

Finally, given those changes, I didn't retain the Reviewed-by/Acked-by.

Changes in v2:
- Give directly the URL to the commit rather than the commit ID
- xenstored_local_init: keep the cast to void *
- Typoes
- Keep pfn_to_mfn for x86 and PV-only. The *mfn* helpers are
used in arch/x86/xen for enlighten.c, mmu.c, p2m.c, setup.c,
smp.c and mm.c
---
 arch/arm/include/asm/xen/page.h | 13 +++--
 arch/x86/include/asm/xen/page.h | 33 ++---
 arch/x86/xen/smp.c  |  2 +-
 drivers/block/xen-blkfront.c|  6 +++---
 drivers/input/misc/xen-kbdfront.c   |  4 ++--
 drivers/net/xen-netback/netback.c   |  4 ++--
 drivers/net/xen-netfront.c  |  8 
 drivers/scsi/xen-scsifront.c|  8 +++-
 drivers/tty/hvc/hvc_xen.c   |  5 +++--
 drivers/video/fbdev/xen-fbfront.c   |  4 ++--
 drivers/xen/balloon.c   |  2 +-
 drivers/xen/events/events_base.c|  2 +-
 drivers/xen/events/events_fifo.c|  4 ++--
 drivers/xen/gntalloc.c  |  3 ++-
 drivers/xen/manage.c|  2 +-
 drivers/xen/tmem.c  |  4 ++--
 drivers/xen/xenbus/xenbus_client.c  |  2 +-
 drivers/xen/xenbus/xenbus_dev_backend.c |  2 +-
 drivers/xen/xenbus/xenbus_probe.c   |  8 +++-
 include/xen/page.h  |  4 ++--
 20 files changed, 69 insertions(+), 51 deletions(-)

diff --git a/arch/arm/include/asm/xen/page.h b/arch/arm/include/asm/xen/page.h
index 087d86e..51e5bf1 100644
--- a/arch/arm/include/asm/xen/page.h
+++ b/arch/arm/include/asm/xen/page.h
@@ -34,14 +34,15 @@ typedef struct xpaddr {
 unsigned long __pfn_to_mfn(unsigned long pfn);
 extern struct rb_root phys_to_mach;
 
-static inline unsigned long pfn_to_mfn(unsigned long pfn)
+/* Pseudo-physical - Guest conversion */
+static inline unsigned long pfn_to_gfn(unsigned long pfn)
 {
return pfn;
 }
 
-static inline unsigned long mfn_to_pfn(unsigned long mfn)
+static inline unsigned long gfn_to_pfn(unsigned long gfn)
 {
-   return mfn;
+   return gfn;
 }
 
 /* Pseudo-physical - BUS conversion */
@@ -65,9 +66,9 @@ static inline unsigned long bfn_to_pfn(unsigned long bfn)
 
 #define bfn_to_local_pfn(bfn)  bfn_to_pfn(bfn)
 
-/* VIRT - MACHINE conversion */
-#define virt_to_mfn(v)  

[PATCH 12/14] qla2xxx: Fix missing device login retries.

2015-08-04 Thread Himanshu Madhani
From: Arun Easi arun.e...@qlogic.com

On certain conditions, login failures will just invoke
qla2x00_mark_device_lost() with the intend to do login again;
but if login_retry has been set already, that would fail to set the
relogin needed flag which is required to wakeup the DPC to retry.

Signed-off-by: Arun Easi arun.e...@qlogic.com
Signed-off-by: Himanshu Madhani himanshu.madh...@qlogic.com
---
 drivers/scsi/qla2xxx/qla_os.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 94d7a6d..aca6577 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -3264,9 +3264,10 @@ void qla2x00_mark_device_lost(scsi_qla_host_t *vha, 
fc_port_t *fcport,
if (!do_login)
return;
 
+   set_bit(RELOGIN_NEEDED, vha-dpc_flags);
+
if (fcport-login_retry == 0) {
fcport-login_retry = vha-hw-login_retry_count;
-   set_bit(RELOGIN_NEEDED, vha-dpc_flags);
 
ql_dbg(ql_dbg_disc, vha, 0x2067,
Port login retry %8phN, id = 0x%04x retry cnt=%d.\n,
-- 
1.7.7

--
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] csiostor:Fix error handling in the function csio_hws_ready

2015-08-04 Thread Nicholas Krause
From: Nicholas Krause xerofo...@gmail.com

This fixes error handling in the function csio_hws_ready for when
this function calls csio_scim_cleanup_io to cleanup outstanding
commands by checking if it cleaned a error code to signal internal
failure and if so tell the user we are unable to clean up the
outstanding io commands by printing this to the console before

Signed-off-by: Nicholas Krause xerofo...@gmail.com
---
 drivers/scsi/csiostor/csio_hw.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/csiostor/csio_hw.c b/drivers/scsi/csiostor/csio_hw.c
index 622bdab..49c47d3 100644
--- a/drivers/scsi/csiostor/csio_hw.c
+++ b/drivers/scsi/csiostor/csio_hw.c
@@ -2445,11 +2445,17 @@ csio_hws_ready(struct csio_hw *hw, enum csio_hw_ev evt)
csio_set_state(hw-sm, csio_hws_quiescing);
/* cleanup all outstanding cmds */
if (evt == CSIO_HWE_HBA_RESET ||
-   evt == CSIO_HWE_PCIERR_DETECTED)
-   csio_scsim_cleanup_io(csio_hw_to_scsim(hw), false);
-   else
-   csio_scsim_cleanup_io(csio_hw_to_scsim(hw), true);
-
+   evt == CSIO_HWE_PCIERR_DETECTED) {
+   if (csio_scsim_cleanup_io(csio_hw_to_scsim(hw), false)) 
{
+   csio_err(hw, Unable to properly cleanup 
outstanding commands on this device\n);
+   return;
+   }
+   } else {
+   if (csio_scsim_cleanup_io(csio_hw_to_scsim(hw), true)) {
+   csio_err(hw, Unable to properly cleanup 
outstanding commands on this device\n);
+   return;
+   }
+   }
csio_hw_intr_disable(hw);
csio_hw_mbm_cleanup(hw);
csio_evtq_stop(hw);
-- 
2.1.4

--
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