From patchwork Mon Dec 27 02:29:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 433351 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBRKCV6O025997 for ; Mon, 27 Dec 2010 20:14:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752826Ab0L0Ca1 (ORCPT ); Sun, 26 Dec 2010 21:30:27 -0500 Received: from mail-vw0-f46.google.com ([209.85.212.46]:35029 "EHLO mail-vw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752437Ab0L0Ca1 (ORCPT ); Sun, 26 Dec 2010 21:30:27 -0500 Received: by mail-vw0-f46.google.com with SMTP id 16so3594960vws.19 for ; Sun, 26 Dec 2010 18:30:27 -0800 (PST) Received: by 10.220.181.71 with SMTP id bx7mr3739712vcb.155.1293417027161; Sun, 26 Dec 2010 18:30:27 -0800 (PST) Received: from salusa.poochiereds.net (cpe-071-070-153-003.nc.res.rr.com [71.70.153.3]) by mx.google.com with ESMTPS id f17sm4249402vbv.6.2010.12.26.18.30.25 (version=SSLv3 cipher=RC4-MD5); Sun, 26 Dec 2010 18:30:26 -0800 (PST) From: Jeff Layton To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org Subject: [PATCH 09/18] cifs: clean up sync_mid_result Date: Sun, 26 Dec 2010 21:29:57 -0500 Message-Id: <1293417006-6417-10-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1293417006-6417-1-git-send-email-jlayton@redhat.com> References: <1293417006-6417-1-git-send-email-jlayton@redhat.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 27 Dec 2010 20:14:34 +0000 (UTC) diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index f65cdec..6abd144 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -363,28 +363,29 @@ sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server) { int rc = 0; - spin_lock(&GlobalMid_Lock); + cFYI(1, "%s: cmd=%d mid=%d state=%d", __func__, mid->command, + mid->mid, mid->midState); - if (mid->resp_buf) { + spin_lock(&GlobalMid_Lock); + switch (mid->midState) { + case MID_RESPONSE_RECEIVED: spin_unlock(&GlobalMid_Lock); return rc; - } - - cERROR(1, "No response to cmd %d mid %d", mid->command, mid->mid); - if (mid->midState == MID_REQUEST_SUBMITTED) { - if (server->tcpStatus == CifsExiting) + case MID_REQUEST_SUBMITTED: + /* socket is going down, reject all calls */ + if (server->tcpStatus == CifsExiting) { + cERROR(1, "%s: canceling mid=%d cmd=0x%x state=%d", + __func__, mid->mid, mid->command, mid->midState); rc = -EHOSTDOWN; - else - mid->midState = MID_RETRY_NEEDED; - } - - if (rc != -EHOSTDOWN) { - if (mid->midState == MID_RETRY_NEEDED) { - rc = -EAGAIN; - cFYI(1, "marking request for retry"); - } else { - rc = -EIO; + break; } + case MID_RETRY_NEEDED: + rc = -EAGAIN; + break; + default: + cERROR(1, "%s: invalid mid state mid=%d state=%d", __func__, + mid->mid, mid->midState); + rc = -EIO; } spin_unlock(&GlobalMid_Lock);