From patchwork Sat Sep 1 06:15:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 10584623 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 90A43174C for ; Sat, 1 Sep 2018 06:15:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D5CC2B362 for ; Sat, 1 Sep 2018 06:15:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F0C82B374; Sat, 1 Sep 2018 06:15:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC6002B362 for ; Sat, 1 Sep 2018 06:15:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726621AbeIAK0g (ORCPT ); Sat, 1 Sep 2018 06:26:36 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:45594 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726375AbeIAK0g (ORCPT ); Sat, 1 Sep 2018 06:26:36 -0400 Received: by mail-pg1-f195.google.com with SMTP id m4-v6so6353608pgv.12 for ; Fri, 31 Aug 2018 23:15:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=DrHQ5g5JmzssKY/r/eEGMkVuL1ZKp+aaOSCkRrHSqfc=; b=nrYgT90rI3nMxvEpO1bQ3WmG9rmThhGI+62YdopYnrCYRwy9TGd7IyV4XtvDmF1CUa m2ir6s7rBMxItr0Iwm/AmGFjLxdZqZS4eTGcnwFZK0qaC4s1WkGM3Uoi2PEYH9c6YnwO lT29fQqEwWCODXCiW+GJTM8D0C5c1wfcmfEFWX3fs6z5kZTK1QzxXPG3lO/nXKKbZxad /Vy6g18om4+47mRUNizQCmreC1Dpw/tbDNue43gF2HmllmORDqw/yFPDwHUj5CHH5yxm Qyr7An+dn1x35SJtL+dPg2lbvOO/b66GZRKgOhhwsvNI+VKmxAXFrcS4iDN97gXAQJ1k zLRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=DrHQ5g5JmzssKY/r/eEGMkVuL1ZKp+aaOSCkRrHSqfc=; b=qxCWddjatufBJxmGT7K6T1eNGO0j7netmVyfWTa2K3RPj8vCCtHFSF141oYsr+7kYC FZdVFoK0+C08RCyZ0vEDJs7cojArF5hP/EBOaH2ChEoQQbbg5khMNTZlrzQPYcw+E/mj Iot86bV8PKSO6Yl9c4GIV+vt73PhY/03BYk0+WUYgbCgc7k/24/L4PHi5xhn5PC45LY8 DqmF9YBrzION8W1Lb+FA7LJgeQPqik2ce6xAxdh5j2L18SNWZZ0QHeZkuZEfZADlJ1cb TQgxXM0eFCBZlrGCuLxfU5C9P1vncDb1BbHoUGR93zKoVRI72D8+qDzKx1gsxPRxdded liXg== X-Gm-Message-State: APzg51ABiGzjmVq4igmhV3ayav8XKOmdAfzBPl2MfPtfv6E2ScBbqRCH CImSPDk+ETNRD1yGKjB6IGraMuSDAcCBE/uu+4veQ1l6 X-Google-Smtp-Source: ANB0VdZHzRQWB2DuYNZZhtM6QpthhYIPh5LsXDx+HyNNPcP4MDApiNERIPv1+APHRJBFisssiPKatH1RcUTfLDn2Ejw= X-Received: by 2002:a65:52cc:: with SMTP id z12-v6mr17462666pgp.69.1535782545651; Fri, 31 Aug 2018 23:15:45 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Sat, 1 Sep 2018 01:15:34 -0500 Message-ID: Subject: [PATCH] smb3: add tracepoint to catch cases where credit refund of failed op overlaps reconnect To: CIFS Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add tracepoint to catch potential cases where a pending operation overlapping a reconnect could fail and incorrectly refund its credits causing the client to think it has more credits available than the server thinks it does. Signed-off-by: Steve French --- fs/cifs/smb2ops.c | 6 ++++++ fs/cifs/trace.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) From 971b5a5926d52186b7428b6f4ae2a0f6794552e2 Mon Sep 17 00:00:00 2001 From: Steve French Date: Sat, 1 Sep 2018 01:10:17 -0500 Subject: [PATCH] smb3: add tracepoint to catch cases where credit refund of failed op overlaps reconnect Add tracepoint to catch potential cases where a pending operation overlapping a reconnect could fail and incorrectly refund its credits causing the client to think it has more credits available than the server thinks it does. Signed-off-by: Steve French --- fs/cifs/smb2ops.c | 6 ++++++ fs/cifs/trace.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 23118b7a2bbc..61ecf7eb8842 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -74,6 +74,12 @@ smb2_add_credits(struct TCP_Server_Info *server, const unsigned int add, int *val, rc = 0; spin_lock(&server->req_lock); val = server->ops->get_credits_field(server, optype); + + /* eg found case where write overlapping reconnect messed up credits */ + if (((optype & CIFS_OP_MASK) == CIFS_NEG_OP) && (*val != 0)) + trace_smb3_reconnect_with_invalid_credits(server->CurrentMid, + server->hostname, *val); + *val += add; if (*val > 65000) { *val = 65000; /* Don't get near 64K credits, avoid srv bugs */ diff --git a/fs/cifs/trace.h b/fs/cifs/trace.h index d4aed5217a56..43e5bd417b81 100644 --- a/fs/cifs/trace.h +++ b/fs/cifs/trace.h @@ -486,6 +486,36 @@ DEFINE_EVENT(smb3_reconnect_class, smb3_##name, \ DEFINE_SMB3_RECONNECT_EVENT(reconnect); DEFINE_SMB3_RECONNECT_EVENT(partial_send_reconnect); +DECLARE_EVENT_CLASS(smb3_credit_class, + TP_PROTO(__u64 currmid, + char *hostname, + int credits), + TP_ARGS(currmid, hostname, credits), + TP_STRUCT__entry( + __field(__u64, currmid) + __field(char *, hostname) + __field(int, credits) + ), + TP_fast_assign( + __entry->currmid = currmid; + __entry->hostname = hostname; + __entry->credits = credits; + ), + TP_printk("server=%s current_mid=0x%llx credits=%d", + __entry->hostname, + __entry->currmid, + __entry->credits) +) + +#define DEFINE_SMB3_CREDIT_EVENT(name) \ +DEFINE_EVENT(smb3_credit_class, smb3_##name, \ + TP_PROTO(__u64 currmid, \ + char *hostname, \ + int credits), \ + TP_ARGS(currmid, hostname, credits)) + +DEFINE_SMB3_CREDIT_EVENT(reconnect_with_invalid_credits); + #endif /* _CIFS_TRACE_H */ #undef TRACE_INCLUDE_PATH -- 2.17.1