From: Josef Bacik <jbacik@fb.com>
To: <linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<kernel-team@fb.com>, <mpa@pengutronix.de>,
<nbd-general@lists.sourceforge.net>
Subject: [PATCH 3/5] nbd: use flags instead of bool
Date: Thu, 8 Sep 2016 17:12:08 -0400 [thread overview]
Message-ID: <1473369130-22986-4-git-send-email-jbacik@fb.com> (raw)
In-Reply-To: <1473369130-22986-1-git-send-email-jbacik@fb.com>
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 <jbacik@fb.com>
---
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 <linux/nbd.h>
+#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);
--
2.8.0.rc2
next prev parent reply other threads:[~2016-09-08 21:13 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-08 21:12 [RESEND][PATCH 0/5] nbd improvements Josef Bacik
2016-09-08 21:12 ` [PATCH 1/5] nbd: convert to blkmq Josef Bacik
2016-09-08 21:12 ` [PATCH 2/5] nbd: don't shutdown sock with irq's disabled Josef Bacik
2016-09-08 21:12 ` Josef Bacik [this message]
2016-09-09 1:20 ` [PATCH 3/5] nbd: use flags instead of bool Joe Perches
2016-09-09 13:55 ` Jens Axboe
2016-09-09 16:04 ` Joe Perches
2016-09-09 16:11 ` Jens Axboe
2016-09-09 16:15 ` Joe Perches
2016-09-09 16:20 ` Jens Axboe
2016-09-08 21:12 ` [PATCH 4/5] nbd: allow block mq to deal with timeouts Josef Bacik
2016-09-08 21:12 ` [PATCH 5/5] nbd: add multi-connection support Josef Bacik
2016-09-10 7:43 ` Christoph Hellwig
2016-09-12 13:11 ` Josef Bacik
2016-09-09 20:02 ` [Nbd] [RESEND][PATCH 0/5] nbd improvements Wouter Verhelst
2016-09-09 20:36 ` Josef Bacik
2016-09-09 20:55 ` Wouter Verhelst
2016-09-09 23:00 ` Josef Bacik
2016-09-09 23:37 ` Jens Axboe
2016-09-15 10:49 ` Wouter Verhelst
2016-09-15 11:09 ` Alex Bligh
2016-09-15 11:29 ` Wouter Verhelst
2016-09-15 11:40 ` Christoph Hellwig
2016-09-15 11:46 ` Alex Bligh
2016-09-15 11:52 ` Christoph Hellwig
2016-09-15 12:01 ` Wouter Verhelst
2016-09-15 12:20 ` Christoph Hellwig
2016-09-15 12:26 ` Wouter Verhelst
2016-09-15 12:27 ` Christoph Hellwig
2016-09-15 12:04 ` Alex Bligh
2016-09-15 11:39 ` Christoph Hellwig
2016-09-15 13:34 ` Eric Blake
2016-09-15 14:07 ` Paolo Bonzini
2016-09-15 15:23 ` Alex Bligh
2016-09-15 21:10 ` Paolo Bonzini
2016-09-15 15:25 ` Alex Bligh
2016-09-15 11:38 ` Christoph Hellwig
2016-09-15 11:43 ` Alex Bligh
2016-09-15 11:46 ` Christoph Hellwig
2016-09-15 11:56 ` Alex Bligh
2016-09-15 11:55 ` Wouter Verhelst
2016-09-15 12:01 ` Christoph Hellwig
2016-09-15 12:11 ` Alex Bligh
2016-09-15 12:18 ` Christoph Hellwig
2016-09-15 12:28 ` Alex Bligh
2016-09-15 12:21 ` Wouter Verhelst
2016-09-15 12:23 ` Christoph Hellwig
2016-09-15 12:33 ` Alex Bligh
2016-09-15 12:36 ` Christoph Hellwig
2016-09-15 12:39 ` Alex Bligh
2016-09-15 12:41 ` Christoph Hellwig
2016-09-15 12:44 ` Alex Bligh
2016-09-15 13:17 ` Wouter Verhelst
2016-09-15 13:57 ` Josef Bacik
2016-09-15 15:17 ` Alex Bligh
2016-09-15 16:08 ` Alex Bligh
2016-09-15 16:27 ` Wouter Verhelst
2016-09-15 16:42 ` Alex Bligh
2016-09-15 19:02 ` Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1473369130-22986-4-git-send-email-jbacik@fb.com \
--to=jbacik@fb.com \
--cc=kernel-team@fb.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mpa@pengutronix.de \
--cc=nbd-general@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome