Commit c0cd10db authored by Alex Elder's avatar Alex Elder Committed by Sage Weil

rbd: use rbd_warn(), not WARN_ON()

Change some calls to WARN_ON() so they use rbd_warn() instead, so we
get consistent messaging.  A few remain but they can probably just
go away eventually.
Signed-off-by: default avatarAlex Elder <elder@inktank.com>
Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
parent 500d0c0f
...@@ -777,7 +777,6 @@ static int rbd_header_from_disk(struct rbd_image_header *header, ...@@ -777,7 +777,6 @@ static int rbd_header_from_disk(struct rbd_image_header *header,
header->snap_sizes[i] = header->snap_sizes[i] =
le64_to_cpu(ondisk->snaps[i].image_size); le64_to_cpu(ondisk->snaps[i].image_size);
} else { } else {
WARN_ON(ondisk->snap_names_len);
header->snap_names = NULL; header->snap_names = NULL;
header->snap_sizes = NULL; header->snap_sizes = NULL;
} }
...@@ -2755,8 +2754,11 @@ static void rbd_request_fn(struct request_queue *q) ...@@ -2755,8 +2754,11 @@ static void rbd_request_fn(struct request_queue *q)
} }
result = -EINVAL; result = -EINVAL;
if (WARN_ON(offset && length > U64_MAX - offset + 1)) if (offset && length > U64_MAX - offset + 1) {
rbd_warn(rbd_dev, "bad request range (%llu~%llu)\n",
offset, length);
goto end_request; /* Shouldn't happen */ goto end_request; /* Shouldn't happen */
}
result = -ENOMEM; result = -ENOMEM;
img_request = rbd_img_request_create(rbd_dev, offset, length, img_request = rbd_img_request_create(rbd_dev, offset, length,
...@@ -2955,7 +2957,7 @@ rbd_dev_v1_header_read(struct rbd_device *rbd_dev, u64 *version) ...@@ -2955,7 +2957,7 @@ rbd_dev_v1_header_read(struct rbd_device *rbd_dev, u64 *version)
0, size, ondisk, version); 0, size, ondisk, version);
if (ret < 0) if (ret < 0)
goto out_err; goto out_err;
if (WARN_ON((size_t) ret < size)) { if ((size_t)ret < size) {
ret = -ENXIO; ret = -ENXIO;
rbd_warn(rbd_dev, "short header read (want %zd got %d)", rbd_warn(rbd_dev, "short header read (want %zd got %d)",
size, ret); size, ret);
...@@ -3057,7 +3059,8 @@ static int rbd_dev_v1_refresh(struct rbd_device *rbd_dev, u64 *hver) ...@@ -3057,7 +3059,8 @@ static int rbd_dev_v1_refresh(struct rbd_device *rbd_dev, u64 *hver)
rbd_dev->header.snap_names = h.snap_names; rbd_dev->header.snap_names = h.snap_names;
rbd_dev->header.snap_sizes = h.snap_sizes; rbd_dev->header.snap_sizes = h.snap_sizes;
/* Free the extra copy of the object prefix */ /* Free the extra copy of the object prefix */
WARN_ON(strcmp(rbd_dev->header.object_prefix, h.object_prefix)); if (strcmp(rbd_dev->header.object_prefix, h.object_prefix))
rbd_warn(rbd_dev, "object prefix changed (ignoring)");
kfree(h.object_prefix); kfree(h.object_prefix);
ret = rbd_dev_snaps_update(rbd_dev); ret = rbd_dev_snaps_update(rbd_dev);
...@@ -3627,8 +3630,11 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev) ...@@ -3627,8 +3630,11 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev)
/* The ceph file layout needs to fit pool id in 32 bits */ /* The ceph file layout needs to fit pool id in 32 bits */
ret = -EIO; ret = -EIO;
if (WARN_ON(parent_spec->pool_id > (u64)U32_MAX)) if (parent_spec->pool_id > (u64)U32_MAX) {
rbd_warn(NULL, "parent pool id too large (%llu > %u)\n",
(unsigned long long)parent_spec->pool_id, U32_MAX);
goto out_err; goto out_err;
}
image_id = ceph_extract_encoded_string(&p, end, NULL, GFP_KERNEL); image_id = ceph_extract_encoded_string(&p, end, NULL, GFP_KERNEL);
if (IS_ERR(image_id)) { if (IS_ERR(image_id)) {
...@@ -4864,11 +4870,13 @@ static ssize_t rbd_add(struct bus_type *bus, ...@@ -4864,11 +4870,13 @@ static ssize_t rbd_add(struct bus_type *bus,
rc = ceph_pg_poolid_by_name(osdc->osdmap, spec->pool_name); rc = ceph_pg_poolid_by_name(osdc->osdmap, spec->pool_name);
if (rc < 0) if (rc < 0)
goto err_out_client; goto err_out_client;
spec->pool_id = (u64) rc; spec->pool_id = (u64)rc;
/* The ceph file layout needs to fit pool id in 32 bits */ /* The ceph file layout needs to fit pool id in 32 bits */
if (WARN_ON(spec->pool_id > (u64) U32_MAX)) { if (spec->pool_id > (u64)U32_MAX) {
rbd_warn(NULL, "pool id too large (%llu > %u)\n",
(unsigned long long)spec->pool_id, U32_MAX);
rc = -EIO; rc = -EIO;
goto err_out_client; goto err_out_client;
} }
...@@ -4902,7 +4910,7 @@ static ssize_t rbd_add(struct bus_type *bus, ...@@ -4902,7 +4910,7 @@ static ssize_t rbd_add(struct bus_type *bus,
dout("Error adding device %s\n", buf); dout("Error adding device %s\n", buf);
return (ssize_t) rc; return (ssize_t)rc;
} }
static struct rbd_device *__rbd_get_dev(unsigned long dev_id) static struct rbd_device *__rbd_get_dev(unsigned long dev_id)
......
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