From: Josh Durgin <josh.durgin@inktank.com>
To: Alex Elder <elder@inktank.com>
Cc: ceph-devel@vger.kernel.org
Subject: Re: [PATCH 7/7] rbd: create rbd_refresh_header()
Date: Mon, 30 Jul 2012 14:33:25 -0700 [thread overview]
Message-ID: <5016FDA5.9090105@inktank.com> (raw)
In-Reply-To: <501195E7.2040104@inktank.com>
On 07/26/2012 12:09 PM, Alex Elder wrote:
> Create a simple helper that handles the common case of calling
> __rbd_refresh_header() while holding the ctl_mutex.
>
> Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
> ---
> drivers/block/rbd.c | 25 +++++++++++++++----------
> 1 file changed, 15 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 31be4ca..94d0745 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -240,7 +240,7 @@ static void rbd_put_dev(struct rbd_device *rbd_dev)
> put_device(&rbd_dev->dev);
> }
>
> -static int __rbd_refresh_header(struct rbd_device *rbd_dev, u64 *hver);
> +static int rbd_refresh_header(struct rbd_device *rbd_dev, u64 *hver);
>
> static int rbd_open(struct block_device *bdev, fmode_t mode)
> {
> @@ -1222,9 +1222,7 @@ static void rbd_watch_cb(u64 ver, u64 notify_id,
> u8 opcode, void *data)
>
> dout("rbd_watch_cb %s notify_id=%lld opcode=%d\n",
> rbd_dev->header_name, notify_id, (int) opcode);
> - mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
> - rc = __rbd_refresh_header(rbd_dev, &hver);
> - mutex_unlock(&ctl_mutex);
> + rc = rbd_refresh_header(rbd_dev, &hver);
> if (rc)
> pr_warning(RBD_DRV_NAME "%d got notification but failed to "
> " update snaps: %d\n", rbd_dev->major, rc);
> @@ -1746,6 +1744,17 @@ static int __rbd_refresh_header(struct rbd_device
> *rbd_dev, u64 *hver)
> return ret;
> }
>
> +static int rbd_refresh_header(struct rbd_device *rbd_dev, u64 *hver)
> +{
> + int ret;
> +
> + mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
> + ret = __rbd_refresh_header(rbd_dev, hver);
> + mutex_unlock(&ctl_mutex);
> +
> + return ret;
> +}
> +
> static int rbd_init_disk(struct rbd_device *rbd_dev)
> {
> struct gendisk *disk;
> @@ -1899,9 +1908,7 @@ static ssize_t rbd_image_refresh(struct device *dev,
> struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);
> int ret;
>
> - mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
> - ret = __rbd_refresh_header(rbd_dev, NULL);
> - mutex_unlock(&ctl_mutex);
> + ret = rbd_refresh_header(rbd_dev, NULL);
>
> return ret < 0 ? ret : size;
> }
> @@ -2191,9 +2198,7 @@ static int rbd_init_watch_dev(struct rbd_device
> *rbd_dev)
> do {
> ret = rbd_req_sync_watch(rbd_dev);
> if (ret == -ERANGE) {
> - mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
> - rc = __rbd_refresh_header(rbd_dev, NULL);
> - mutex_unlock(&ctl_mutex);
> + rc = rbd_refresh_header(rbd_dev, NULL);
> if (rc < 0)
> return rc;
> }
>
prev parent reply other threads:[~2012-07-30 21:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-26 19:01 [PATCH 0/7] rbd: more miscellaneous refactoring Alex Elder
2012-07-26 19:08 ` [PATCH 1/7] rbd: have __rbd_add_snap_dev() return a pointer Alex Elder
2012-07-30 20:42 ` Josh Durgin
2012-07-26 19:08 ` [PATCH 2/7] rbd: make rbd_create_rw_ops() " Alex Elder
2012-07-30 20:46 ` Josh Durgin
2012-07-26 19:08 ` [PATCH 3/7] rbd: pass null version pointer in add_snap() Alex Elder
2012-07-30 20:48 ` Josh Durgin
2012-07-26 19:08 ` [PATCH 4/7] rbd: always pass ops array to rbd_req_sync_op() Alex Elder
2012-07-30 20:51 ` Josh Durgin
2012-07-26 19:08 ` [PATCH 5/7] rbd: fixes in rbd_header_from_disk() Alex Elder
2012-07-30 21:23 ` Josh Durgin
2012-07-30 22:45 ` Alex Elder
2012-07-26 19:09 ` [PATCH 6/7] rbd: return obj version in __rbd_refresh_header() Alex Elder
2012-07-30 21:32 ` Josh Durgin
2012-07-26 19:09 ` [PATCH 7/7] rbd: create rbd_refresh_header() Alex Elder
2012-07-30 21:33 ` Josh Durgin [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=5016FDA5.9090105@inktank.com \
--to=josh.durgin@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox