Commit 9b4a6ba9 authored by Josef Bacik's avatar Josef Bacik Committed by Jens Axboe

nbd: use flags instead of bool

In preparation for some future changes, change a few of the state bools over to
normal bits to set/clear properly.
Signed-off-by: default avatarJosef Bacik <jbacik@fb.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent c2611898
...@@ -41,8 +41,12 @@ ...@@ -41,8 +41,12 @@
#include <linux/nbd.h> #include <linux/nbd.h>
#define NBD_TIMEDOUT 0
#define NBD_DISCONNECT_REQUESTED 1
struct nbd_device { struct nbd_device {
u32 flags; u32 flags;
unsigned long runtime_flags;
struct socket * sock; /* If == NULL, device is not ready, yet */ struct socket * sock; /* If == NULL, device is not ready, yet */
int magic; int magic;
...@@ -54,8 +58,6 @@ struct nbd_device { ...@@ -54,8 +58,6 @@ struct nbd_device {
int blksize; int blksize;
loff_t bytesize; loff_t bytesize;
int xmit_timeout; int xmit_timeout;
bool timedout;
bool disconnect; /* a disconnect has been requested by user */
struct timer_list timeout_timer; struct timer_list timeout_timer;
/* protects initialization and shutdown of the socket */ /* protects initialization and shutdown of the socket */
...@@ -192,7 +194,7 @@ static void nbd_xmit_timeout(unsigned long arg) ...@@ -192,7 +194,7 @@ static void nbd_xmit_timeout(unsigned long arg)
spin_lock_irqsave(&nbd->sock_lock, flags); spin_lock_irqsave(&nbd->sock_lock, flags);
nbd->timedout = true; set_bit(NBD_TIMEDOUT, &nbd->runtime_flags);
if (nbd->sock) { if (nbd->sock) {
sock = nbd->sock; sock = nbd->sock;
...@@ -562,8 +564,7 @@ static int nbd_set_socket(struct nbd_device *nbd, struct socket *sock) ...@@ -562,8 +564,7 @@ static int nbd_set_socket(struct nbd_device *nbd, struct socket *sock)
/* Reset all properties of an NBD device */ /* Reset all properties of an NBD device */
static void nbd_reset(struct nbd_device *nbd) static void nbd_reset(struct nbd_device *nbd)
{ {
nbd->disconnect = false; nbd->runtime_flags = 0;
nbd->timedout = false;
nbd->blksize = 1024; nbd->blksize = 1024;
nbd->bytesize = 0; nbd->bytesize = 0;
set_capacity(nbd->disk, 0); set_capacity(nbd->disk, 0);
...@@ -626,7 +627,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, ...@@ -626,7 +627,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
return -EINVAL; return -EINVAL;
} }
nbd->disconnect = true; set_bit(NBD_DISCONNECT_REQUESTED, &nbd->runtime_flags);
nbd_send_cmd(nbd, blk_mq_rq_to_pdu(sreq)); nbd_send_cmd(nbd, blk_mq_rq_to_pdu(sreq));
blk_mq_free_request(sreq); blk_mq_free_request(sreq);
...@@ -706,9 +707,10 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, ...@@ -706,9 +707,10 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
kill_bdev(bdev); kill_bdev(bdev);
nbd_bdev_reset(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; error = 0;
if (nbd->timedout) if (test_bit(NBD_TIMEDOUT, &nbd->runtime_flags))
error = -ETIMEDOUT; error = -ETIMEDOUT;
nbd_reset(nbd); nbd_reset(nbd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment