Thread (48 messages) 48 messages, 7 authors, 2023-05-17

Re: [PATCH RFC 14/16] scsi: sd: Add WRITE_ATOMIC_16 support

From: Bart Van Assche <bvanassche@acm.org>
Date: 2023-05-03 18:49:09
Also in: linux-block, linux-fsdevel, linux-nvme, linux-scsi, linux-xfs, lkml

On 5/3/23 11:38, John Garry wrote:
+static blk_status_t sd_setup_atomic_cmnd(struct scsi_cmnd *cmd,
+					sector_t lba, unsigned int nr_blocks,
+					unsigned char flags)
+{
+	cmd->cmd_len  = 16;
+	cmd->cmnd[0]  = WRITE_ATOMIC_16;
+	cmd->cmnd[1]  = flags;
+	put_unaligned_be64(lba, &cmd->cmnd[2]);
+	cmd->cmnd[10] = 0;
+	cmd->cmnd[11] = 0;
+	put_unaligned_be16(nr_blocks, &cmd->cmnd[12]);
+	cmd->cmnd[14] = 0;
+	cmd->cmnd[15] = 0;
+
+	return BLK_STS_OK;
+}
A single space in front of the assignment operator please.
quoted hunk ↗ jump to hunk
+
  static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd)
  {
  	struct request *rq = scsi_cmd_to_rq(cmd);
@@ -1149,6 +1166,7 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd)
  	unsigned int nr_blocks = sectors_to_logical(sdp, blk_rq_sectors(rq));
  	unsigned int mask = logical_to_sectors(sdp, 1) - 1;
  	bool write = rq_data_dir(rq) == WRITE;
+	bool atomic_write = !!(rq->cmd_flags & REQ_ATOMIC) && write;
Isn't the !! superfluous in the above expression? I have not yet seen 
any other kernel code where a flag test is used in a boolean expression 
and where !! occurs in front of the flag test.

Thanks,

Bart.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help