From patchwork Wed Apr 3 18:07:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 2388901 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id F4225DFB79 for ; Wed, 3 Apr 2013 18:07:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762985Ab3DCSHT (ORCPT ); Wed, 3 Apr 2013 14:07:19 -0400 Received: from mail-qa0-f41.google.com ([209.85.216.41]:58890 "EHLO mail-qa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762970Ab3DCSHS (ORCPT ); Wed, 3 Apr 2013 14:07:18 -0400 Received: by mail-qa0-f41.google.com with SMTP id bs12so2205838qab.0 for ; Wed, 03 Apr 2013 11:07:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=7bY6rzlpIMHvJE9DoUUVyxKyj6QeKOwGjwyFI2wUp1w=; b=WD81UgzfIIYIAwXCcQ30L3aWYcYlIDOmfaiFSUM6ZWUKoqQD02Kaxzu0B3vbNpI7Hg 4n3afK0aaLZGOSY+BGEIWiG4ugJ2B2q5FXmD+avS7UCXBYkGUzKuOgrdgv84L9pArr+A xF3sPHSs5QoY8Q7r8CaVVdRUHry1YNshWmlV/IIdMEJwOFhJ54U7lPnzePNFSu+sJrg8 nztfCX7LQab4ePQI2dHGGnYsxYSFtprLeqjXTAeloFCdVxBkRwnWsycFIN/w5lobJuXZ vodwmZ1IB1TujiPnod9WCYvu/mRIAbL9LGj3AKheu/z4H2D21HI8Ckg3g5labr75T9ll gaXQ== X-Received: by 10.224.9.129 with SMTP id l1mr2540703qal.4.1365012435826; Wed, 03 Apr 2013 11:07:15 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-107-015-113-143.nc.res.rr.com. [107.15.113.143]) by mx.google.com with ESMTPS id i4sm7970598qai.5.2013.04.03.11.07.14 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 03 Apr 2013 11:07:14 -0700 (PDT) From: Jeff Layton To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, mikemol@gmail.com Subject: [PATCH] cifs: on send failure, readjust server sequence number downward Date: Wed, 3 Apr 2013 14:07:10 -0400 Message-Id: <1365012430-6795-1-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.7 X-Gm-Message-State: ALoCoQkiwe7EgHUmnG46vFnSW88I2206GUzA03YtBYWC66tDAmGGja5uwl78fgAotoVd43fJZtjQ Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org If sending a call to the server fails for some reason (for instance, the sending thread caught a signal), then we must readjust the sequence number downward again or the next send will have it too high. Signed-off-by: Jeff Layton --- fs/cifs/smb1ops.c | 3 +++ fs/cifs/transport.c | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c index 23bcd11..3efdb9d 100644 --- a/fs/cifs/smb1ops.c +++ b/fs/cifs/smb1ops.c @@ -61,6 +61,9 @@ send_nt_cancel(struct TCP_Server_Info *server, void *buf, */ --server->sequence_number; rc = smb_send(server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); + if (rc < 0) + server->sequence_number--; + mutex_unlock(&server->srv_mutex); cifs_dbg(FYI, "issued NT_CANCEL for mid %u, rc = %d\n", diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 653bf26..293d2c8 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -522,6 +522,9 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst, rc = smb_send_rqst(server, rqst); cifs_in_send_dec(server); cifs_save_when_sent(mid); + + if (rc < 0) + server->sequence_number -= 2; mutex_unlock(&server->srv_mutex); if (rc == 0) @@ -711,6 +714,8 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses, cifs_in_send_dec(ses->server); cifs_save_when_sent(midQ); + if (rc < 0) + ses->server->sequence_number -= 2; mutex_unlock(&ses->server->srv_mutex); if (rc < 0) { @@ -835,6 +840,10 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); cifs_in_send_dec(ses->server); cifs_save_when_sent(midQ); + + if (rc < 0) + ses->server->sequence_number -= 2; + mutex_unlock(&ses->server->srv_mutex); if (rc < 0) @@ -968,6 +977,10 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); cifs_in_send_dec(ses->server); cifs_save_when_sent(midQ); + + if (rc < 0) + ses->server->sequence_number -= 2; + mutex_unlock(&ses->server->srv_mutex); if (rc < 0) {