Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753273AbbGWAh2 (ORCPT ); Wed, 22 Jul 2015 20:37:28 -0400 Received: from g4t3427.houston.hp.com ([15.201.208.55]:44855 "EHLO g4t3427.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750779AbbGWAhZ convert rfc822-to-8bit (ORCPT ); Wed, 22 Jul 2015 20:37:25 -0400 From: "Elliott, Robert (Server Storage)" To: Spencer Baugh , "Nicholas A. Bellinger" , Sagi Grimberg , Christoph Hellwig , Bart Van Assche , Alexei Potashnik , Andy Grover , "Christophe Vu-Brugier" , Roland Dreier , Joern Engel , Andy Shevchenko , James Bottomley , Evgenii Lepikhin , Hannes Reinecke , Al Viro , "open list:TARGET SUBSYSTEM" , "open list:TARGET SUBSYSTEM" , open list CC: Joern Engel , Spencer Baugh Subject: RE: [PATCH] target: Drop iSCSI use of mutex around max_cmd_sn increment Thread-Topic: [PATCH] target: Drop iSCSI use of mutex around max_cmd_sn increment Thread-Index: AQHQxMsbo9gmiMeN20+fktxhpiDqhZ3oMeug Date: Thu, 23 Jul 2015 00:33:15 +0000 Message-ID: <94D0CD8314A33A4D9D801C0FE68B40295AA03CD1@G9W0745.americas.hpqcorp.net> References: <1437602898-15229-2-git-send-email-sbaugh@catern.com> In-Reply-To: <1437602898-15229-2-git-send-email-sbaugh@catern.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [16.210.48.26] Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2440 Lines: 61 > -----Original Message----- > From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel- > owner@vger.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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/