From patchwork Sun Mar 13 01:55:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 630861 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 p2D1tvGA021506 for ; Sun, 13 Mar 2011 01:55:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755930Ab1CMBz4 (ORCPT ); Sat, 12 Mar 2011 20:55:56 -0500 Received: from mail-iw0-f174.google.com ([209.85.214.174]:46109 "EHLO mail-iw0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755126Ab1CMBz4 (ORCPT ); Sat, 12 Mar 2011 20:55:56 -0500 Received: by iwn34 with SMTP id 34so3847468iwn.19 for ; Sat, 12 Mar 2011 17:55:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=XhcevxJWrtej3qbGMoOf/LnpI2KBKHOIFGYdxsZ6US8=; b=kkRolQoStH637BHe1SUdC9kvm/Xw3HED09GweMerCCPKNFmxncXg10VIPbWQ0S4p00 8iEeOY3OCdSl6dCcvMTA4xpeGpsC/8+Myh41Wq60hqJvrxB77rMKPHdLD/yDmoWLQF/m y/0X0wp7pPzUNHWk9NwZ/1roeAey8VuXuPClo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=IY+VginOtg72HE0TKnrOaMABIvH6h/doa5u8OKalTqt6kgH/cEScLzFjtDsWkdf+5b wX4w/nquXCbAMMwM+ZGmum/cyP+OWLFbTHn+6OirVIML+PuSzTKyuVEMLJriAg4DIOhN jPyW8qEq/tZrjs20+bI7Ea+oBvXnsksM84Oas= MIME-Version: 1.0 Received: by 10.42.156.67 with SMTP id y3mr6894615icw.381.1299981355785; Sat, 12 Mar 2011 17:55:55 -0800 (PST) Received: by 10.42.148.195 with HTTP; Sat, 12 Mar 2011 17:55:55 -0800 (PST) Date: Sat, 12 Mar 2011 19:55:55 -0600 Message-ID: Subject: [PATCH] sync_smb2_mid_result From: Steve French To: linux-cifs@vger.kernel.org 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.6 (demeter1.kernel.org [140.211.167.41]); Sun, 13 Mar 2011 01:56:05 +0000 (UTC) diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c index c62070a..a05b37b 100644 --- a/fs/cifs/smb2transport.c +++ b/fs/cifs/smb2transport.c @@ -250,6 +235,64 @@ smb2_mid_entry_free(struct smb2_mid_entry *mid_entry) mempool_free(mid_entry, smb2_mid_poolp); } +/* This is similar to cifs's wait_for_response but obviously for smb2 mids */ +static int +wait_for_smb2_response(struct TCP_Server_Info *server, + struct smb2_mid_entry *midq) +{ + int error; + + error = wait_event_killable(server->response_q, + midq->mid_state != MID_REQUEST_SUBMITTED); + if (error < 0) + return -ERESTARTSYS; + + return 0; +} + +/* This is similar to cifs's sync_mid_result but for smb2 mids */ +static int +sync_smb2_mid_result(struct smb2_mid_entry *mid, struct TCP_Server_Info *server) +{ + int rc = 0; + + cFYI(1, "%s: cmd=%d mid=%lld state=%d", __func__, + le16_to_cpu(mid->command), mid->mid, mid->mid_state); + + spin_lock(&GlobalMid_Lock); + /* ensure that it's no longer on the pending_mid_q */ + list_del_init(&mid->qhead); + + switch (mid->midState) { + case MID_RESPONSE_RECEIVED: + spin_unlock(&GlobalMid_Lock); + return rc; + case MID_REQUEST_SUBMITTED: + /* socket is going down, reject all calls */ + if (server->tcpStatus == CifsExiting) { + cERROR(1, "%s: canceling mid=%lld cmd=0x%x state=%d", + __func__, mid->mid, le16_to_cpu(mid->command), + mid->mid_state); + rc = -EHOSTDOWN; + break; + } + case MID_RETRY_NEEDED: + rc = -EAGAIN; + break; + case MID_RESPONSE_MALFORMED: + rc = -EIO; + break; + default: + cERROR(1, "%s: invalid mid state mid=%lld state=%d", __func__, + mid->mid, mid->mid_state); + rc = -EIO; + } + spin_unlock(&GlobalMid_Lock); + + smb2_mid_entry_free(mid); + return rc; +} + static void free_smb2_mid(struct smb2_mid_entry *mid)