From patchwork Mon Dec 5 21:20:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9461513 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8348060231 for ; Mon, 5 Dec 2016 21:20:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75C412621F for ; Mon, 5 Dec 2016 21:20:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A68D27FE4; Mon, 5 Dec 2016 21:20:52 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 C7C2F2621F for ; Mon, 5 Dec 2016 21:20:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751563AbcLEVUv (ORCPT ); Mon, 5 Dec 2016 16:20:51 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:33806 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751373AbcLEVUt (ORCPT ); Mon, 5 Dec 2016 16:20:49 -0500 Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.16.0.17/8.16.0.17) with SMTP id uB5LGfrp000683; Mon, 5 Dec 2016 13:20:39 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : subject : date : message-id : mime-version : content-type; s=facebook; bh=r23zHSY3yax1DT/6PxQrga9nHTELhfPUQPbrHwoesxI=; b=h2gy/1FpGsJFhctKNnz3ocuRHru5KfWgCBMzPUfNuoPxhk2kA476kzgOS51z8uvxdMK8 txZa6o5UcbyB+d12c/Vku36n5+Mv4ywDcB83MuDLdM4dLjrBEhmgoHvselXJQTfDDBpW xc6RPL1VgJygX12WyV0rULd5rBEz9t8WKkY= Received: from mail.thefacebook.com ([199.201.64.23]) by m0001303.ppops.net with ESMTP id 273tkm7pt1-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 05 Dec 2016 13:20:39 -0800 Received: from NAM03-BY2-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.15) with Microsoft SMTP Server (TLS) id 14.3.294.0; Mon, 5 Dec 2016 13:20:38 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=207WKcLMrawUuV7wCYq4n5hzaeFnTRyhLukp/Q/lGec=; b=SGPl+bON5Mv/srV5hby3Ir+67wVSpCyWGBK7mGE0cQev99CZhc4k2uXnA0qDiXuPDGM2Cg9T2vap80HrMq8A30KupdLk4hFg+/vZnX9SvBfNuvzS7zBeobPhJ6Md7C0t3ukw/3oybveH7eh8jZxJbASU5i8FIckouuBjfNZLxCg= Received: from localhost (2620:10d:c091:180::1:126f) by MWHPR15MB1325.namprd15.prod.outlook.com (10.175.3.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.761.9; Mon, 5 Dec 2016 21:20:35 +0000 From: Josef Bacik To: , , , Subject: [PATCH] nbd: use dev_err_ratelimited in io path Date: Mon, 5 Dec 2016 16:20:29 -0500 Message-ID: <1480972829-30845-1-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.5.5 MIME-Version: 1.0 X-Originating-IP: [2620:10d:c091:180::1:126f] X-ClientProxiedBy: MWHPR10CA0066.namprd10.prod.outlook.com (10.169.238.28) To MWHPR15MB1325.namprd15.prod.outlook.com (10.175.3.139) X-MS-Office365-Filtering-Correlation-Id: 5ab1ac37-4f3e-4289-c180-08d41d548e01 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:MWHPR15MB1325; X-Microsoft-Exchange-Diagnostics: 1; MWHPR15MB1325; 3:NhaT/9yfaMR54Ppgrn4EyxvhNiZuvQb0YS5G0UL8JTPbNvR/xd9/BfwdpCnR98XnwGa19lwviq/f/fA39rPOOO6yicsCmsX+irIeDq/9mepACQlYdG3jASnBLTzWiculbbdI+QShMj2N9FUBFa6T9pzd8StGPwA6pnzRJoRJLWH4LpOFE2pK/k5rfuAgPCVqqBf5hyzqdlozIz5rJWQOj+1yxg6wzVh6bQEv95MgKsUu5wCczPeryJsSMQLxOoIlNzupTGD+5gGjiqND1etf1Q==; 25:Yb3HhshNLP8RCDTF1Jh7h1+bvXrb6NtGc2BiZnP3JhIUjXh1NOJbFVhlBYov208uHXSMyS9d1caficaNP0n5QMD3zMcYr4wQURl3phtImdln5XI4PbnmWb0MjfYtaaNDAvd3f1FM/ANJIZF8AMaFb5p7XTNYY+Gw5FysvOKlA0XiGXpZ3KqjArIC+RHxlrjIu7hYNX6bS5H/NHRtSWaBg0PHbv3dbGSTFCS1pkDky/Ywrnd44i2+MYFzfq7LSF9qJflirmwD2uWwRlPTtXtE4kIM/wOfMbCUAtWpN0dKUDywKh5R1PacFyL98SVko2uIOYfw5CLak57+zd01KrISSKY4yjg1B9aB316O9Hyn5A99U91pG9vFpS9HQfIu3bz6pEPBwMo63umeqkMa+5HCfN/ds5GiJhn+1KWYhN3au9Je/s0jsgAkFPIM423+tRiq X-Microsoft-Exchange-Diagnostics: 1; MWHPR15MB1325; 31:LZKHuEYB0G/hG8gOjtUAsy9R8o+KYiRRn5r2vG5KJWWIxmdYYsMnzjbMWV9W2slwZUYX8qkJ0pULOJ+jirustE+RmiHsMfkgYWFZoCX+VDPx/Wo1+18o7EC9jOP0kIYBIeQ/L9uEu+GYyl4kqy1Q090NaDYgkleURfZISIMqTkP27vuvcqqrslYUb+qOj8LrX/7dTe+Wjs0PtImqOkkY6Ckym+7xNJ9Enm6z1f1k7DcnzaZERDSBkbLpZz1xHYoJQqPjAzsL9gVVhnZq1nBw/6T3QH1YhDWOPGVHws6Z7S0=; 20:HhfniiYCvbhLCzWco6aOHTF3jmUt6P12SVcowNivLEKHz0W72RfuxSzek2JWb343Qa1StnZTFNuO2n+JsRln0LZQUBSuG4lqim++emss0Wc/5U2BmImT3GN+lrGJFlNItIzwnG7WFYObHsq+CI55QcLeSHUZu0q+Mv2ytKcORuxHhT3CvBWVgy5puGSO6zhRpUWeSQYefK7aykPuRvL6r9IuiqobOTrcF4IDf8aCWrQ5SF37NyJwjNwJlk9B4n7L X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6041248)(20161123555025)(20161123564025)(20161123562025)(20161123560025)(6072148); SRVR:MWHPR15MB1325; BCL:0; PCL:0; RULEID:; SRVR:MWHPR15MB1325; X-Microsoft-Exchange-Diagnostics: 1; MWHPR15MB1325; 4:5aCq8as1nahp6V8j89fUyXbRx17J0m2dBd+5OwbxBLoFXY7XUFD9ggZDfZHoPgKL7un8fsBKtuQoGYC4OL71MfiRC5Z8h+R3gHn7qncyDpkoO8Oe87JHKgd67Hkxwa5Rc9SXLC4pVwcNB6orfrpdg51mKvpCtfbIigrbE/+eFm6HTTUXN4NUN2JeNGgoR56a1zsQViByDYjuuZXcV0lPBmiOboUkSPxSZThXTnstPhf8a3jqJPywaQn59KHDyrnVnPmfxdtvWnmSM+wTQuqZBspFjRt9QtQkzpxfp3j64QY7jQy4DnlB79P7oY9GLmns60Vt9SoqK4T0nF5z6R1xUWbo4YUU9MVpw9uGanboU15tGrBD66gKBhXINFKm9snd+6/U6hdjQpPA9oAhsjE0r7ShvABaoZ5Sg8YjLONvlfCRlAcpNjVAGv4lomrsvX4xFVGhYPqIOtZ8+2gCXjSM6SFS74o1Nt4rorhlmubN9VM++msweta9i5JS0ldkWpYEp4Z0g1C2dWC9AHtZdWL4i4NmWxwGvJ2Pub9vkTWBJTR8cyFPh1HRrNJwT/oiBpR5psQXys5dPLRGDJ3WOebWxVkz3NjU74nHfVqEQNR/7Sg= X-Forefront-PRVS: 0147E151B5 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(7916002)(199003)(189002)(86362001)(6666003)(5660300001)(2906002)(189998001)(7846002)(107886002)(7736002)(305945005)(81166006)(101416001)(81156014)(5003940100001)(2201001)(8676002)(6116002)(733004)(6496003)(50466002)(39450400002)(6486002)(36756003)(5001770100001)(39850400001)(105586002)(48376002)(47776003)(39410400001)(106356001)(92566002)(38730400001)(39840400001)(39860400001)(33646002)(97736004)(42186005)(50226002)(68736007)(50986999)(76506005); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR15MB1325; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR15MB1325; 23:D/colk6fAI2RlJabepL409iK8SHwwFAmwOkp/ggKP?= =?us-ascii?Q?IFiei1GFa/DYk9GjCSoqsKUgQC+WbfsQjWu45+r8lVuQoiO50u7Cy+fi+/wA?= =?us-ascii?Q?F74DXON6CKgZLd3V9OhLGM3nj1eJ7H5IvgckA5sDvdlixnHuA8xMaUSN0mwp?= =?us-ascii?Q?vXoe4D+RLf931rLZ6ZQE2sSdKi8zimMzrQgaVHtB1NFd3p5xieXVxL+O0Tk6?= =?us-ascii?Q?36301iiQiSu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vNIdShM0v6GSjis2mIhhG?= =?us-ascii?Q?kT6Q9GLSU1oz8Jz5akNJ3pkY8906GGI?= X-Microsoft-Exchange-Diagnostics: 1; MWHPR15MB1325; 6:SpTjXR+6IqBBEk/aNGwFU+j/0Xp/3sRivFaxL/Yh+Q1cBomtajh+1hDzfYa132unNfdgzCLxwljah4ft9+BhHZYIA3gtv6fJOAdMg7lx1RnduVh9PgGQt8xwRS7SxXlRUr+iiWoCBwiPX3cHx/AUQN1RveWrnXlnCIpPPa+FLb7YWIpR2cS/Vg7z5Q6Olt1e24KG2XQUSwAQtB4jzl50RWgF7Kdas98fsn4/jc3Mu7D7GNoGT0KLBSdT2N5o3p1eo394P6jb/UuN/zvaqmk7B9P6ntKYl0pWvrY9mr7ymV45dskDhkzjpkKHsZ7ZHVLpcrK17Ru1FRWmeXvuXDQmIhlt2O0O/vK4YQIVb7/7cJleJ4gDRCDjMYif877tbOHYrpZnR7D4iuFXOdzbFBMIjKkOBIBvLFPILIr3sCp54GQ=; 5:Wtupn5/jmGAHexMCA2xp0o4oe2n3pKS0MjiS9KmA4EQiN6OhLNbKhwO5Sbbyg1iETYQKusZM6rUe8WeMEjtTqzGYqah5xCIEXWI9Fx9W0PrmP0owARrrf2Zy0Khar7uGai3S3pa1msBWyN8uGAMl+Q==; 24:lPmfYmtV7m3btY7d3b9RUepVNzWel+oJI5nYhrcybro2Avay7o2laPkQnzpjvIwg3s730x2RImzCTFxtrIb6MRzTP4jM0KebrKit3AHamFQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR15MB1325; 7:T5iY6YTGWOmONzAO/YrK+QK4NQ498qTZxSl9Os5AkfVuQSQqRtT4Khbol8kTq9bUBX9kXcAzvTZzNiESe8MyJl6K7tbtEOdGAO8k0gFPF+sUco5AhmHoP8eqiD7odxlITq2nIKyLYf67umUafIKOlwIYJy69CZfZ2n5zAaTrGno1JbWya5SGJCfw7wfgwtFban59osM2Xh4W3yvzSajf05HzUxh0dkfjfpzYOmH14jvGcyP5MKwtfOgmMrwfStBYSDYCB7UzsxnZtPnZjG+PFaR/Eoo8/xda2+EaXVWzqfbvj7Oj4hJIpLhvJzQuoM013hGDyCS/V/28RGAb7OwQ9KZ6+lO6qEloEDVjmqi4cTbbnDYe2k2cHgq63yZwWQMCpsG33l4vlXulnIpZ1W2UKjNhemJVTzYr9YOIs6P4ryrzifrSMGljPelLucQFNVFRQ7omN9N53fwkoVW0ET+Fmg==; 20:33nc+aUXMZIqhQzE/Irhi3LzIWPkNR+S0EYxdiQTVRUA5YlO2aVsW3s2Hh8LXxVVsImsKHM9jPbHZvCI6+tlq5oiJhzaRZguW3KM5Nsuo/Z+hx/uZ1F9caEtFXUbxkd2mSMGYy81e6XDWgFNNBSvLKz8Njx0pq0xwhs/wYRhFmU= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2016 21:20:35.3182 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR15MB1325 X-OriginatorOrg: fb.com X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-12-05_15:, , signatures=0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP While doing stress tests we noticed that we'd get a lot of dmesg spam if we suddenly disconnected teh nbd device out of band. Rate limite the messages in the io path in order to deal with this. Signed-off-by: Josef Bacik --- drivers/block/nbd.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index bc78cbb..0e6e52df 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -219,7 +219,7 @@ static int sock_xmit(struct nbd_device *nbd, int index, int send, void *buf, unsigned long pflags = current->flags; if (unlikely(!sock)) { - dev_err(disk_to_dev(nbd->disk), + dev_err_ratelimited(disk_to_dev(nbd->disk), "Attempted %s on closed socket in sock_xmit\n", (send ? "send" : "recv")); return -EINVAL; @@ -302,7 +302,7 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index) result = sock_xmit(nbd, index, 1, &request, sizeof(request), (type == NBD_CMD_WRITE) ? MSG_MORE : 0); if (result <= 0) { - dev_err(disk_to_dev(nbd->disk), + dev_err_ratelimited(disk_to_dev(nbd->disk), "Send control failed (result %d)\n", result); return -EIO; } @@ -501,14 +501,14 @@ static void nbd_handle_cmd(struct nbd_cmd *cmd, int index) struct nbd_sock *nsock; if (index >= nbd->num_connections) { - dev_err(disk_to_dev(nbd->disk), - "Attempted send on invalid socket\n"); + dev_err_ratelimited(disk_to_dev(nbd->disk), + "Attempted send on invalid socket\n"); goto error_out; } if (test_bit(NBD_DISCONNECTED, &nbd->runtime_flags)) { - dev_err(disk_to_dev(nbd->disk), - "Attempted send on closed socket\n"); + dev_err_ratelimited(disk_to_dev(nbd->disk), + "Attempted send on closed socket\n"); goto error_out; } @@ -519,8 +519,8 @@ static void nbd_handle_cmd(struct nbd_cmd *cmd, int index) if (req->cmd_type == REQ_TYPE_FS && rq_data_dir(req) == WRITE && (nbd->flags & NBD_FLAG_READ_ONLY)) { - dev_err(disk_to_dev(nbd->disk), - "Write on read-only\n"); + dev_err_ratelimited(disk_to_dev(nbd->disk), + "Write on read-only\n"); goto error_out; } @@ -530,13 +530,14 @@ static void nbd_handle_cmd(struct nbd_cmd *cmd, int index) mutex_lock(&nsock->tx_lock); if (unlikely(!nsock->sock)) { mutex_unlock(&nsock->tx_lock); - dev_err(disk_to_dev(nbd->disk), - "Attempted send on closed socket\n"); + dev_err_ratelimited(disk_to_dev(nbd->disk), + "Attempted send on closed socket\n"); goto error_out; } if (nbd_send_cmd(nbd, cmd, index) != 0) { - dev_err(disk_to_dev(nbd->disk), "Request send failed\n"); + dev_err_ratelimited(disk_to_dev(nbd->disk), + "Request send failed\n"); req->errors++; nbd_end_request(cmd); }