From patchwork Sat Mar 12 04:12:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 629741 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 p2C4C5Xv015848 for ; Sat, 12 Mar 2011 04:12:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751713Ab1CLEMF (ORCPT ); Fri, 11 Mar 2011 23:12:05 -0500 Received: from mail-iw0-f174.google.com ([209.85.214.174]:41550 "EHLO mail-iw0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751533Ab1CLEMD (ORCPT ); Fri, 11 Mar 2011 23:12:03 -0500 Received: by iwn34 with SMTP id 34so3267207iwn.19 for ; Fri, 11 Mar 2011 20:12:03 -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=cjYNpoMHUbC4asp0mILkAufGkkfLQLBHVtEtFRujLEk=; b=A3DW9BVHBrbskL7tTjC0MNjvRHlNIQ/BIfgQd/ts0nZ0vhhFqJa1V6nTh+lEv1IxgI NM4LaPoaz44X2u6XNQBQu1rUYsqdzaRR3edoKfubustH+5vt2YcIspAjghbehk9ta6TI IyuyrrsHF+0u9p7Siepmy2FImv+a8XB3nzTjk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=nnQW9OZLCJOnpDsTVmjPPXHzSGNN3ZNU23yqHQeVaVer9H6XltQKp7MrYblhW1GGK5 JFptnPtlTkOSq1g42k/p58dI9WGflnCiDVjGzUozbQKqhdV63cBCkiVLPWgsmLT2XyY8 i5mIvyCyhejAtG0lRPh+VNfNqVi3dK+sRGtHE= MIME-Version: 1.0 Received: by 10.42.156.196 with SMTP id a4mr2419078icx.180.1299903123412; Fri, 11 Mar 2011 20:12:03 -0800 (PST) Received: by 10.42.148.195 with HTTP; Fri, 11 Mar 2011 20:12:03 -0800 (PST) Date: Fri, 11 Mar 2011 22:12:03 -0600 Message-ID: Subject: [PATCH] Add routines to free SMB2 mids 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]); Sat, 12 Mar 2011 04:12:06 +0000 (UTC) diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c index 9d33cd2..c62070a 100644 --- a/fs/cifs/smb2transport.c +++ b/fs/cifs/smb2transport.c @@ -206,5 +206,59 @@ static int get_smb2_mid(struct cifs_ses *ses, struct smb2_hdr *in_buf, return 0; } +static void +smb2_mid_entry_free(struct smb2_mid_entry *mid_entry) +{ +#ifdef CONFIG_CIFS_STATS2 + unsigned long now; +#endif + mid_entry->mid_state = MID_FREE; + atomic_dec(&midCount); + + /* the large buf free will eventually use a different + pool (the cifs size is not optimal for smb2) but + it makes the initial conversion simpler to leave + it using the cifs large buf pool */ + if (mid_entry->large_buf) + cifs_buf_release(mid_entry->resp_buf); + else + cifs_small_buf_release(mid_entry->resp_buf); +#ifdef CONFIG_CIFS_STATS2 + now = jiffies; + /* commands taking longer than one second are indications that + something is wrong, unless it is quite a slow link or server */ + /* BB eventually add a mid flag to allow us to indicate other ops such + as SMB2 reads or writes to "offline" files which are ok to be slow */ + if ((now - mid_entry->when_alloc) > HZ) { + if ((cifsFYI & CIFS_TIMER) && + (mid_entry->command != SMB2_LOCK)) { + printk(KERN_DEBUG " SMB2 slow rsp: cmd %d mid %lld", + mid_entry->command, mid_entry->mid); + printk(" A: 0x%lx S: 0x%lx R: 0x%lx\n", + now - mid_entry->when_alloc, + now - mid_entry->when_sent, + now - mid_entry->when_received); + } + } +#endif + +/* The next two lines or equivalent will be needed when pagebuf support + added back in: + if (mid_entry->is_kmap_buf && mid_entry->pagebuf_list) + kfree(mid_entry->pagebuf_list); */ + + mempool_free(mid_entry, smb2_mid_poolp); +} + +static void +free_smb2_mid(struct smb2_mid_entry *mid) +{ + spin_lock(&GlobalMid_Lock); + list_del(&mid->qhead); + spin_unlock(&GlobalMid_Lock); + + smb2_mid_entry_free(mid); +} +