[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <94D0CD8314A33A4D9D801C0FE68B40295AA03CD1@G9W0745.americas.hpqcorp.net>
Date: Thu, 23 Jul 2015 00:33:15 +0000
From: "Elliott, Robert (Server Storage)" <Elliott@...com>
To: Spencer Baugh <sbaugh@...ern.com>,
"Nicholas A. Bellinger" <nab@...ux-iscsi.org>,
Sagi Grimberg <sagig@...lanox.com>,
Christoph Hellwig <hch@....de>,
Bart Van Assche <bart.vanassche@...disk.com>,
Alexei Potashnik <alexei@...estorage.com>,
Andy Grover <agrover@...hat.com>,
"Christophe Vu-Brugier" <cvubrugier@...tmail.fm>,
Roland Dreier <roland@...estorage.com>,
Joern Engel <joern@...fs.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
James Bottomley <JBottomley@...n.com>,
Evgenii Lepikhin <johnlepikhin@...il.com>,
Hannes Reinecke <hare@...e.de>,
Al Viro <viro@...iv.linux.org.uk>,
"open list:TARGET SUBSYSTEM" <linux-scsi@...r.kernel.org>,
"open list:TARGET SUBSYSTEM" <target-devel@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>
CC: Joern Engel <joern@...estorage.com>,
Spencer Baugh <Spencer.baugh@...estorage.com>
Subject: RE: [PATCH] target: Drop iSCSI use of mutex around max_cmd_sn
increment
> -----Original Message-----
> From: linux-kernel-owner@...r.kernel.org [mailto:linux-kernel-
> owner@...r.kernel.org] On Behalf Of Spencer Baugh
> Sent: Wednesday, July 22, 2015 5:08 PM
> Subject: [PATCH] target: Drop iSCSI use of mutex around max_cmd_sn
> increment
...
> diff --git a/drivers/target/iscsi/iscsi_target_configfs.c
> b/drivers/target/iscsi/iscsi_target_configfs.c
> index c1898c8..29d5930 100644
> --- a/drivers/target/iscsi/iscsi_target_configfs.c
> +++ b/drivers/target/iscsi/iscsi_target_configfs.c
> @@ -706,8 +706,8 @@ static ssize_t lio_target_nacl_show_info(
> rb += sprintf(page+rb, " 0x%08x 0x%08x 0x%08x 0x%08x"
> " 0x%08x 0x%08x\n",
> sess->cmdsn_window,
> - (sess->max_cmd_sn - sess->exp_cmd_sn) + 1,
> - sess->exp_cmd_sn, sess->max_cmd_sn,
> + ((u32) atomic_read(&sess->max_cmd_sn) - sess-
> >exp_cmd_sn) + 1,
> + sess->exp_cmd_sn, (u32) atomic_read(&sess->max_cmd_sn),
> sess->init_task_tag, sess->targ_xfer_tag);
> rb += sprintf(page+rb, "----------------------[iSCSI"
> " Connections]-------------------------\n");
Two calls to atomic_read could pick up different values;
calling it once and using the same value twice would ensure
the arguments are consistent with each other.
> diff --git a/drivers/target/iscsi/iscsi_target_device.c
> b/drivers/target/iscsi/iscsi_target_device.c
> index 5fabcd3..a526904 100644
> --- a/drivers/target/iscsi/iscsi_target_device.c
> +++ b/drivers/target/iscsi/iscsi_target_device.c
...
> @@ -57,9 +57,7 @@ void iscsit_increment_maxcmdsn(struct iscsi_cmd *cmd,
> struct iscsi_session *sess
>
> cmd->maxcmdsn_inc = 1;
>
> - mutex_lock(&sess->cmdsn_mutex);
> - sess->max_cmd_sn += 1;
> - pr_debug("Updated MaxCmdSN to 0x%08x\n", sess->max_cmd_sn);
> - mutex_unlock(&sess->cmdsn_mutex);
> + atomic_inc(&sess->max_cmd_sn);
> + pr_debug("Updated MaxCmdSN to 0x%08x\n", atomic_read(&sess-
> >max_cmd_sn));
> }
> EXPORT_SYMBOL(iscsit_increment_maxcmdsn);
If there is another change before the atomic_read, this would
print a value unrelated to the increment done by this thread.
atomic_inc_return would provide the appropriate value to print.
---
Robert Elliott, HP Server Storage
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists