From: Dan Mick <dan.mick@inktank.com>
To: Alex Elder <elder@inktank.com>
Cc: "ceph-devel@vger.kernel.org" <ceph-devel@vger.kernel.org>
Subject: Re: [PATCH 1/2] rbd: define flags field, use it for exists flag
Date: Tue, 15 Jan 2013 13:00:23 -0800 [thread overview]
Message-ID: <50F5C367.4080000@inktank.com> (raw)
In-Reply-To: <50F4538B.4010106@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
On 01/14/2013 10:50 AM, Alex Elder wrote:
> Define a new rbd device flags field, manipulated using atomic bit
> operations. Replace the use of the current "exists" flag with a
> bit in this new "flags" field.
>
> Signed-off-by: Alex Elder <elder@inktank.com>
> ---
> drivers/block/rbd.c | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 02002b1..9eb1631 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -232,7 +232,7 @@ struct rbd_device {
> spinlock_t lock; /* queue lock */
>
> struct rbd_image_header header;
> - atomic_t exists;
> + unsigned long flags;
> struct rbd_spec *spec;
>
> char *header_name;
> @@ -260,6 +260,12 @@ struct rbd_device {
> unsigned long open_count;
> };
>
> +/* Flag bits for rbd_dev->flags */
> +
> +enum rbd_dev_flags {
> + rbd_dev_flag_exists, /* mapped snapshot has not been deleted */
> +};
> +
> static DEFINE_MUTEX(ctl_mutex); /* Serialize open/close/setup/teardown */
>
> static LIST_HEAD(rbd_dev_list); /* devices */
> @@ -756,7 +762,8 @@ static int rbd_dev_set_mapping(struct rbd_device
> *rbd_dev)
> goto done;
> rbd_dev->mapping.read_only = true;
> }
> - atomic_set(&rbd_dev->exists, 1);
> + set_bit(rbd_dev_flag_exists, &rbd_dev->flags);
> +
> done:
> return ret;
> }
> @@ -1654,7 +1661,7 @@ static void rbd_rq_fn(struct request_queue *q)
> snapc = ceph_get_snap_context(rbd_dev->header.snapc);
> up_read(&rbd_dev->header_rwsem);
> rbd_assert(snapc != NULL);
> - } else if (!atomic_read(&rbd_dev->exists)) {
> + } else if (!test_bit(rbd_dev_flag_exists, &rbd_dev->flags)) {
> rbd_assert(rbd_dev->spec->snap_id != CEPH_NOSNAP);
> dout("request for non-existent snapshot");
> result = -ENXIO;
> @@ -2270,7 +2277,7 @@ struct rbd_device *rbd_dev_create(struct
> rbd_client *rbdc,
> return NULL;
>
> spin_lock_init(&rbd_dev->lock);
> - atomic_set(&rbd_dev->exists, 0);
> + rbd_dev->flags = 0;
> INIT_LIST_HEAD(&rbd_dev->node);
> INIT_LIST_HEAD(&rbd_dev->snaps);
> init_rwsem(&rbd_dev->header_rwsem);
> @@ -2902,7 +2909,7 @@ static int rbd_dev_snaps_update(struct rbd_device
> *rbd_dev)
> /* Existing snapshot not in the new snap context */
>
> if (rbd_dev->spec->snap_id == snap->id)
> - atomic_set(&rbd_dev->exists, 0);
> + set_bit(rbd_dev_flag_exists, &rbd_dev->flags);
> rbd_remove_snap_dev(snap);
> dout("%ssnap id %llu has been removed\n",
> rbd_dev->spec->snap_id == snap->id ?
>
next prev parent reply other threads:[~2013-01-15 21:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-14 18:50 [PATCH 0/2] rbd: prevent open of image being unmapped Alex Elder
2013-01-14 18:50 ` [PATCH 1/2] rbd: define flags field, use it for exists flag Alex Elder
2013-01-14 20:32 ` Dan Mick
2013-01-14 21:23 ` Alex Elder
2013-01-15 6:09 ` Dan Mick
2013-01-16 1:08 ` Josh Durgin
2013-01-17 23:16 ` Alex Elder
2013-01-15 21:00 ` Dan Mick [this message]
2013-01-14 18:51 ` [PATCH 2/2] rbd: prevent open for image being removed Alex Elder
-- strict thread matches above, loose matches on Subject: below --
2013-01-28 22:08 [PATCH 0/2] rbd: manage racing opens/removes Alex Elder
2013-01-28 22:09 ` [PATCH 1/2] rbd: define flags field, use it for exists flag Alex Elder
2013-01-30 19:45 ` Josh Durgin
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=50F5C367.4080000@inktank.com \
--to=dan.mick@inktank.com \
--cc=ceph-devel@vger.kernel.org \
--cc=elder@inktank.com \
/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.