All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@dreamhost.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 2/2] rbd: convert to using flags field
Date: Tue, 28 Feb 2012 20:41:55 -0800	[thread overview]
Message-ID: <4F4DAC93.5090309@dreamhost.com> (raw)
In-Reply-To: <4F4DAC48.7060804@dreamhost.com>

To allow having more than just read-only as Boolean state associated
with an rbd_device, replace the "read_only" field with a more
general "flags" field.  The non-atomic versions of bit operations
are fine for our purposes.

Signed-off-by: Alex Elder <elder@dreamhost.com>
---
  drivers/block/rbd.c |   14 ++++++++++----
  1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index e7b443a..da38804 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -176,7 +176,8 @@ struct rbd_device {
  	char                    snap_name[RBD_MAX_SNAP_NAME_LEN];
  	u32 cur_snap;	/* index+1 of current snapshot within snap context
  			   0 - for the head */
-	int read_only;
+
+	unsigned long		flags;

  	struct list_head	node;

@@ -187,19 +188,24 @@ struct rbd_device {
  	struct device		dev;
  };

+/* Bit position definitions for the rbd_device->flags */
+enum {
+	RBD_DEV_FLAG_READ_ONLY,
+};
+
  static inline bool rbd_dev_is_readonly(struct rbd_device *rbd_dev)
  {
-	return rbd_dev->read_only;
+	return test_bit(RBD_DEV_FLAG_READ_ONLY, &rbd_dev->flags);
  }

  static inline void rbd_dev_set_readonly(struct rbd_device *rbd_dev)
  {
-	rbd_dev->read_only = true;
+	__set_bit(RBD_DEV_FLAG_READ_ONLY, &rbd_dev->flags);
  }

  static inline void rbd_dev_clear_readonly(struct rbd_device *rbd_dev)
  {
-	rbd_dev->read_only = false;
+	__clear_bit(RBD_DEV_FLAG_READ_ONLY, &rbd_dev->flags);
  }

  static DEFINE_MUTEX(ctl_mutex);	  /* Serialize 
open/close/setup/teardown */
-- 
1.7.5.4


      parent reply	other threads:[~2012-02-29  4:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-29  4:40 [PATCH 0/2] rbd: support additional Boolean rbd_dev flags Alex Elder
2012-02-29  4:41 ` [PATCH 1/2] rbd: define helpers for read_only flag Alex Elder
2012-02-29  4:41 ` Alex Elder [this message]

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=4F4DAC93.5090309@dreamhost.com \
    --to=elder@dreamhost.com \
    --cc=ceph-devel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.