[PATCH v2] sd: Write lock zone for REQ_OP_WRITE_ZEROES

2017-05-08 Thread damien . lemoal
From: Damien Le Moal For a zoned block device, sd_zbc_complete() handles zone write unlock on completion of a REQ_OP_WRITE_ZEROES command but the zone write locking is missing from sd_setup_write_zeroes_cmnd(). This patch fixes this problem by locking the target zone of a

[PATCH] sd: Write lock zone for REQ_OP_WRITE_ZEROES

2017-05-08 Thread damien . lemoal
From: Damien Le Moal For a zoned block device, sd_zbc_complete() handles zone write unlock on completion of a REQ_OP_WRITE_ZEROES command but the zone write locking is missing from sd_setup_write_zeroes_cmnd(). This patch fixes this problem by locking the target zone of a

[PATCH] sd: Unlock zone in case of error in sd_setup_write_same_cmnd()

2017-05-08 Thread damien . lemoal
From: Damien Le Moal scsi_io_init() may fail, leaving a zone of a zoned block device locked. Fix this by properly unlocking the write same request target zone if scsi_io_init() fails. Signed-off-by: Damien Le Moal Cc: sta...@vger.kernel.org ---

[PATCH v2 6/7] sd_zbc: Remove superfluous assignments

2017-04-24 Thread damien . lemoal
From: Bart Van Assche A value is assigned to the variable 'capacity' in sd_zbc_read_zones() but that value is never used. Hence remove the variable 'capacity'. [Damien: There is no need to initialize to 0 the variable 'ret' in sd_zbc_read_zones()] Signed-off-by:

[PATCH v2 7/7] sd_zbc: Do not write lock zones for reset

2017-04-24 Thread damien . lemoal
From: Damien Le Moal Resetting a zone write pointer is equivalent to discarding sectors: after a reset, the zone sectors will contain zeros (or the format pattern). So there is no need for mutual exclusion between a zone reset and write. Similarly to discard, make it the

[PATCH v2 5/7] sd_zbc: Rename sd_zbc_setup_write_cmnd

2017-04-24 Thread damien . lemoal
From: Damien Le Moal Rename sd_zbc_setup_write_cmnd() to sd_zbc_write_lock_zone() to be clear about what the function actually does. To be consistent, also rename sd_zbc_cancel_write_cmnd() to sd_zbc_write_unlock_zone(). No functional change is introduced by this patch.

[PATCH v2 3/7] sd: Cleanup sd_done sense data handling

2017-04-24 Thread damien . lemoal
From: Damien Le Moal In sd_done(), for the ILLEGAL REQUEST sense key case, add an 'else if' after the first 'if (sshdr.asc == 0x10)' test to avoid the second test (the values tested are different). Still for the same ILLEGAL REQUEST case, move the declarations of the

[PATCH v2 2/7] sd: Improve sd_completed_bytes

2017-04-24 Thread damien . lemoal
From: Damien Le Moal Re-shuffle the code to be more efficient by not initializing variables upfront (i.e. do it only when necessary). Also replace the do_div calls with calls to sectors_to_logical(). No functional change is introduced by this patch. Signed-off-by: Damien

[PATCH v2 1/7] sd: Fix functions description

2017-04-24 Thread damien . lemoal
From: Damien Le Moal Fix argument names and description of functions documentation comments. No functional change is introduced by this patch. Signed-off-by: Damien Le Moal --- drivers/scsi/sd.c | 29 ++--- 1 file changed,

[PATCH v2 0/7] scsi: sd/sd_zbc cleanup and improvements

2017-04-24 Thread damien . lemoal
From: Damien Le Moal This series of small patches cleanup code mainly in sd.c and sd_zbc.c, with another small improvement in scsi_error.c. Only the last patch of this series introduces a functional change. All other patches do not change any functionality. Changes from

[PATCH v2 4/7] scsi: Improve scsi_get_sense_info_fld

2017-04-24 Thread damien . lemoal
From: Damien Le Moal Use get_unaligned_be32 and get_unaligned_be64 to obtain values from the sense buffer instead of open coding the operations. Also change the function return value to a bool and fix the function signature declaration to remove spaces triggering

[PATCH 8/9] sd_zbc: Remove superfluous assignments

2017-04-21 Thread damien . lemoal
From: Bart Van Assche A value is assigned to the variable 'capacity' in sd_zbc_read_zones() but that value is never used. Hence remove the variable 'capacity'. [Damien: There is no need to initialize to 0 the variable 'ret' in sd_zbc_read_zones()] Signed-off-by:

[PATCH 7/9] sd_zbc: Rename sd_zbc_setup_write_cmnd

2017-04-21 Thread damien . lemoal
From: Damien Le Moal Rename sd_zbc_setup_write_cmnd() to sd_zbc_write_lock_zone() to be clear about what the function actually does. To be consistent, also rename sd_zbc_cancel_write_cmnd() to sd_zbc_write_unlock_zone(). No functional change is introduced by this patch.

[PATCH 4/9] sd: Improve sd_completed_bytes

2017-04-21 Thread damien . lemoal
From: Damien Le Moal Re-shuffle the code to be more efficient by not initializing variables upfront (i.e. do it only when necessary). Also replace the do_div calls with calls to sectors_to_logical(). No functional change is introduced by this patch. Signed-off-by: Damien

[PATCH 5/9] sd: Cleanup sd_done sense data handling

2017-04-21 Thread damien . lemoal
From: Damien Le Moal In sd_done(), for the ILLEGAL REQUEST sense key case, add an 'else' after the first 'if (sshdr.asc == 0x10)' test to avoid the second test (the values tested are different). Still for the same ILLEGAL REQUEST case, move the declarations of the

[PATCH 6/9] scsi: Improve scsi_get_sense_info_fld

2017-04-21 Thread damien . lemoal
From: Damien Le Moal Use get_unaligned_be32 and get_unaligned_be64 to obtain values from the sense buffer instead of open coding the operations. Also change the function return value to a bool. No functional change is introduced by this patch. Signed-off-by: Damien Le

[PATCH 9/9] sd_zbc: Do not write lock zones for reset

2017-04-21 Thread damien . lemoal
From: Damien Le Moal Resetting a zone write pointer is equivalent to discarding sectors: after a reset, the zone sectors will contain zeros (or the format pattern). So there is no need for mutual exclusion between a zone reset and write. Similarly to discard, make it the

[PATCH 3/9] sd: Remove unecessary variable in sd_done()

2017-04-21 Thread damien . lemoal
From: Damien Le Moal The 'sense_deferred' variable in sd_done() is set only if 'sense_valid' is true. So it is not necessary and the result of scsi_sense_is_deferred() and of scsi_command_normalize_sense() can be combined together in 'sense_valid'. Also, since

[PATCH 2/9] sd: Fix functions description

2017-04-21 Thread damien . lemoal
From: Damien Le Moal Use regular format comments documenting functions, fix argument names, etc No functional change is introduced by this patch. Signed-off-by: Damien Le Moal --- drivers/scsi/sd.c | 272

[PATCH 0/9] scsi: sd/sd_zbc cleanup and improvements

2017-04-21 Thread damien . lemoal
From: Damien Le Moal This series of small patches cleanup code mainly in sd.c and sd_zbc.c, with another small improvement in scsi_error.c. The first 2 patches are not stricktly necessary but would be great to apply to make emacs pretty printer happy and reduce its

[PATCH 1/9] sd: Remove white space before EOL

2017-04-21 Thread damien . lemoal
From: Damien Le Moal No functional change is introduced by this patch. Signed-off-by: Damien Le Moal --- drivers/scsi/sd.c | 60 +++ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git