From patchwork Thu Sep 8 21:12:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9322071 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 52EF360231 for ; Thu, 8 Sep 2016 21:13:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4319B299F5 for ; Thu, 8 Sep 2016 21:13:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 372DF299FB; Thu, 8 Sep 2016 21:13:17 +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 887A2299F5 for ; Thu, 8 Sep 2016 21:13:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757499AbcIHVNB (ORCPT ); Thu, 8 Sep 2016 17:13:01 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:42198 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755937AbcIHVMo (ORCPT ); Thu, 8 Sep 2016 17:12:44 -0400 Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u88LADIM005960; Thu, 8 Sep 2016 14:12:34 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=icRD5R1sA5WbSNOk5tyc7qkp9UVZlRjWOuglLL2QmCA=; b=Hzj6gZq4sL2U245uzoWpVP0+QJqVDnAhnMZqaC71Embv0faPc/6lrsTXF5wQIqXqdY1/ 1SWfK+vsaIIF4lHi1ly1Ai7H4Nj/iW5dHUJMcGUCE5GiRTjWr8P20OVtJJ2zP3huI2HV bVaeeMqSsIwBvRz/3mhREWirceNoGC6bO1M= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 25becg8cw3-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 08 Sep 2016 14:12:34 -0700 Received: from NAM03-DM3-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.24) with Microsoft SMTP Server (TLS) id 14.3.294.0; Thu, 8 Sep 2016 14:12:32 -0700 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=70dKQP1sB7SDbRNbkOISKjj6bAQDh7mCgLsMnbNqOjA=; b=QkIpGjwH9Y4B6iM53wFOhDWzHT+GAOeGB7pLbxOBisvCuqdAmgr8KdSwLQcyfCGEW5wUj86mwsoUcyzUH1gUKdjH32RKWCu7Hj6r22DDfzWKH5NaIT3EvEOEOyV5VTro7Rltr+bqlvrVrFikrM9Qb47K1WtCr2l4taKSzIEuK0k= Received: from localhost (2620:10d:c091:180::1:8c0f) by BN6PR15MB1316.namprd15.prod.outlook.com (10.172.206.142) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.609.9; Thu, 8 Sep 2016 21:12:29 +0000 From: Josef Bacik To: , , , , Subject: [PATCH 3/5] nbd: use flags instead of bool Date: Thu, 8 Sep 2016 17:12:08 -0400 Message-ID: <1473369130-22986-4-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1473369130-22986-1-git-send-email-jbacik@fb.com> References: <1473369130-22986-1-git-send-email-jbacik@fb.com> MIME-Version: 1.0 X-Originating-IP: [2620:10d:c091:180::1:8c0f] X-ClientProxiedBy: BN6PR19CA0047.namprd19.prod.outlook.com (10.173.148.161) To BN6PR15MB1316.namprd15.prod.outlook.com (10.172.206.142) X-MS-Office365-Filtering-Correlation-Id: dcb7b38b-62d1-477a-245a-08d3d82cd7d9 X-Microsoft-Exchange-Diagnostics: 1; BN6PR15MB1316; 2:tuknE2m5aPnIyKDA4/8G7AV5YHAYoCrmJl84eog3PjUI4SFMkzVNDYlRnV3oEDcOhdBWP0XY9q7TfAYe8D6CkP0FxH7Ag4nb6uVH65Xz+iUhV0wTwKkiPYtQeuGqkosUqZW2TZTjzdAejnKbYgsMPmo4EZg2ozN9LEYaUHbkZLX9WaP6ONd1B5lHyCFqxdpD; 3:dOZc6KkC0xMyhnxfcvOk7NWnPXP55nDTttPY9I/krCRmasJYcof5bjnC3v3vFTZGV24+6zeVm3Sl+kgwE/nLzTGcEGqAIvKBv+RQlbN6ulJ/ePNl1uCpbJvgW3Zd1EGE; 25:Y7pOYxtqmLIEECD1nao94KWpL/w16Af9vXcIT+k2hGoCRzp4QCcNvow2d3imJ12rrBG773BPfmxnADLmlmt/EX3wKP21fhqAIObntTwdPfnVdAXN1uvuFiLsZZ+e7HDOJpZrb1VRlNN7UW8Gca0oJSeA0FlNB+NH4McGmTzXhqvWG9pd2JwOI9xF5420n+d/QSBNpXmF2AwYyd+Bq3qY8L2loKOVptozm7PLcih2zQPLxtkfi0twXSy1LjrH4vZ4qpnwISo5rI8vbmpVMJ963tZovVSmzJk7onlC8MPKe+xAcCb323ZdOHGwlAXWyIDibt1Bc70bKsAaN5DKtbhCtLqLvacWoKiYgsmgbd36z8aNmJ2zPzzzlfZqc6iCABIXGqiHyLnXWDCg0jyhL1gk2uj1a2gPzfPa48mgQA/coPw= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN6PR15MB1316; X-LD-Processed: 8ae927fe-1255-47a7-a2af-5f3a069daaa2,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; BN6PR15MB1316; 31:uzzjZv7fNqRN3VOybTtB7Osjl5P41BaVx/N0TMKH7JQfz5EKzwqfaO0orMl5zml2ALtpTMvIx5+NsDB3lCsZN3mYPZ8mlUegNT9NaIYH2GRPx4wyFxZg/82h1f4GYhyHVcEX0Mt8Fg2pXpIvzdl4H8ATsN8j0d/UF1bSRLTLwmDepo0oLQsBaihSDeShqdC6mcUK2JYp/0actoMrSGKHQ1QbmMtrqmM5Rk6q9T+D+y4=; 20:UZtYezybMsW3xxD6yPvfdK3Mi0oNpyrjtJi4GCQfWrvw0LFBaM9W9ha/ssU+nPGx9h4XFtvwuz1wQ/3Jf/+2EkFPEgFlunz7w63czhOAazbceoLMdYxmx4e25DofTqisLOpnRYVzMI+ONeu6D54Kt7IMGuBjbOXtPinfzt2iBYY=; 4:9aiahn26ax0ya//OVY9MRS1klS+BlaB+DQnK+ACa9iyrCtMI+XACPNcgeKei69U2t/myQDJuzTNI0LNLG54FooKa0POUVFtJrDk52fLvOKOz78HYU45kmA7Hw/PZIbibEgjNlFvzjXRP8OI0MwHd6X34xPKKlzTk4OGjlrYl9w0DMHCK7afnUmJnVGUCnHW/rWYFMyk5bEvvKIPb+AAT1IbvYARpve7Um4xEVSjnE33YsM2GZqxVwkT1CVf1pdEdm7m3AaXyJkvHP8Eom2tVvUwRZfzKYnJubb0lEuu5Aa7FbRBHoPeiYb7DAmA6jwABQ6MXkuM4EVf7IgO09jsw6eA3N/9wzSkSS1SlhEGXBkXJYPm4uJVfEf6XL7zXL1IaCLwOdWii3Q4l8xiBvmlM0c2G4QveWbH7UK0TcM6pHYvDPVovuaMn2dgfQeF7IBh9 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001); SRVR:BN6PR15MB1316; BCL:0; PCL:0; RULEID:; SRVR:BN6PR15MB1316; X-Forefront-PRVS: 00594E8DBA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6069001)(6009001)(7916002)(199003)(189002)(106356001)(5003940100001)(97736004)(50986999)(47776003)(5001770100001)(76176999)(92566002)(107886002)(86362001)(76506005)(33646002)(2201001)(77096005)(2906002)(575784001)(101416001)(68736007)(189998001)(36756003)(229853001)(6116002)(586003)(105586002)(50466002)(48376002)(5660300001)(19580395003)(19580405001)(81156014)(50226002)(42186005)(305945005)(2950100001)(81166006)(8676002)(7846002)(7736002)(3826002); DIR:OUT; SFP:1102; SCL:1; SRVR:BN6PR15MB1316; 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; BN6PR15MB1316; 23:y0llVJm7Qxn+2Qhiz7jPWgti3d6/VdTsZ6iLFQ42i?= =?us-ascii?Q?HuxcFXL0kj26LTXUEORJoKA/VJscex+0a062ctlNHVyvVat6ljl8yMjkylN+?= =?us-ascii?Q?0l0WHFEbeGaLgFAgaLb9u2R/C+fMdI8X62WrNAPbK/uVx9NPxAMS16yJ37Ow?= =?us-ascii?Q?fFrJUD6i5LR2MN+P7v6uhCIDeyiQ7r31AKNZmirYMJnS5CIyHa3R+JmyOp09?= =?us-ascii?Q?KYcL2Ydwj/yYH6Dtde3unk9QXDoJWPjCG+sPaUPFg2erSzWqY+f1bvXLZdjU?= =?us-ascii?Q?lL7ATrkAGDBa/V2yv+NqLj+av6xdsMK+E0oPR61IobhxrNOM5egXPuPesb2d?= =?us-ascii?Q?tikpYtzG/R5ofK9OaZxHBVNa2Kpsd/hM8Kg1nF9vbS7k5JR5a4fXv9KFj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EKLNvdveF5shC4NCkCa6foQgBX+4mJEpAxPJh0Hyx1+QKxbqOyvvILLLz81NBu/YbbcOQta6wsMwuoNlEO1dAV1S7crjb6wJSvDtFHc9uTLLFgJc3gmne9DJP5yqqWa5RPTnZ7A53S6lLPvxUSBebnIRouVQl4K6AYJPnzl8smDJjx5M+pJxorxNoxJRzSdA=; 5:I3w1Quk6vK2I8i0a+6qrCfAdboRGEH9nkTJPqnHHJntdWoU3/2b23F6+ksugMKz220tdC8yRBTkIuxQASYQjSJDjllqJkKngTDg0wF5tAr7uVDHXHqZluxfvTToBuySAM0//PssEyL7/MrUyNFzh9w==; 24:q+wB43JDQ8RPYIKSwCVprs3tUNqqJVwqL5osjhoFqNsZ94U/HsOvygkwd5P+7D/Pk/Yyk+oCHFtURFKvwqnLl0IOXFCmce32ORUmpj/QzCY=; 7:6BvHU7lm6VNe4gh22rCggZdTxGTnVZWULnypQ5A0GitGYJ/2nZCvOMq+GofA1qGJrb+1aSQGip2DvMVVW+D3jKI44ac8750GTQKEpGCodSV7XqOMmnnxFu1Ru+SqK6yCbT9oJ0cKqEI5Cbr/IbQW1kB3F/T8owpzmkwUPsbNHPPH11QqR6bqaloSWGqApieifEy3wiTMEvUILffiZjJJYF0DwnRaybo38ZNvvpO23xjuMSZxSuJz2wYuOCVHFgLP SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR15MB1316; 20:jT2+B3jwUlVidE90vrh98+AW1vYDXH3OPPUH1mDQla6KAr8DMtmHqEj+Hd9pyK6BkdVCQHBQDPf46Cvq/8adRg+MjtjQl3KFz12KdF3gkRWBwfevDhUsiO/UFif2+gu8VOC7EMCaUbiC+V1MjjSz2W9KZAC36R10RfqBpOBKBa0= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2016 21:12:29.7741 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR15MB1316 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-09-08_10:, , 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 In preparation for some future changes, change a few of the state bools over to normal bits to set/clear properly. Signed-off-by: Josef Bacik --- drivers/block/nbd.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 4b7d0f3..cf855a1 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -41,8 +41,12 @@ #include +#define NBD_TIMEDOUT 0 +#define NBD_DISCONNECT_REQUESTED 1 + struct nbd_device { u32 flags; + unsigned long runtime_flags; struct socket * sock; /* If == NULL, device is not ready, yet */ int magic; @@ -54,8 +58,6 @@ struct nbd_device { int blksize; loff_t bytesize; int xmit_timeout; - bool timedout; - bool disconnect; /* a disconnect has been requested by user */ struct timer_list timeout_timer; /* protects initialization and shutdown of the socket */ @@ -192,7 +194,7 @@ static void nbd_xmit_timeout(unsigned long arg) spin_lock_irqsave(&nbd->sock_lock, flags); - nbd->timedout = true; + set_bit(NBD_TIMEDOUT, &nbd->runtime_flags); if (nbd->sock) { sock = nbd->sock; @@ -562,8 +564,7 @@ out: /* Reset all properties of an NBD device */ static void nbd_reset(struct nbd_device *nbd) { - nbd->disconnect = false; - nbd->timedout = false; + nbd->runtime_flags = 0; nbd->blksize = 1024; nbd->bytesize = 0; set_capacity(nbd->disk, 0); @@ -626,7 +627,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, return -EINVAL; } - nbd->disconnect = true; + set_bit(NBD_DISCONNECT_REQUESTED, &nbd->runtime_flags); nbd_send_cmd(nbd, blk_mq_rq_to_pdu(sreq)); blk_mq_free_request(sreq); @@ -706,9 +707,10 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, kill_bdev(bdev); nbd_bdev_reset(bdev); - if (nbd->disconnect) /* user requested, ignore socket errors */ + /* user requested, ignore socket errors */ + if (test_bit(NBD_DISCONNECT_REQUESTED, &nbd->runtime_flags)) error = 0; - if (nbd->timedout) + if (test_bit(NBD_TIMEDOUT, &nbd->runtime_flags)) error = -ETIMEDOUT; nbd_reset(nbd);