Skip to contentSkip to conversation

libceph: fix broken data length assertions

PATCH In review Alex Elder 2 participants 2 messages Mar 30, 2013 – Mar 31, 2013 Ceph common code (libceph)

lore
Share & tools
lore

Alex Elder

author
#0 lore raw

PATCH 1/1 libceph: fix broken data length assertions

It's OK for the result of a read to come back with fewer bytes than were requested. So don't trigger a BUG() in that case when initializing the data cursor.

This resolves:

    http://tracker.ceph.com/issues/4598
---
 net/ceph/messenger.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/ceph/messenger.c +0 -0
index d4e46d8..24f3aba 100644
@@ -833,7 +833,7 @@ static void ceph_msg_data_pages_cursor_init(struct

ceph_msg_data *data,

BUG_ON(!data->pages);
BUG_ON(!data->length);
- BUG_ON(length != data->length);
+ BUG_ON(length > data->length); /* short reads are OK */

cursor->resid = length;
page_count = calc_pages_for(data->alignment, (u64)data->length);
@@ -905,7 +905,7 @@ static void ceph_msg_data_pagelist_cursor_init(struct ceph_msg_data *data,

pagelist = data->pagelist;
BUG_ON(!pagelist);
- BUG_ON(length != pagelist->length);
+ BUG_ON(length > pagelist->length); /* short reads are OK */

if (!length)
return; /* pagelist can be assigned but empty */

Signature · 1 line
1.7.9.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 45 lines · Alex Elder

It's OK for the result of a read to come back with fewer bytes than were requested. So don't trigger a BUG() in that case when initializing the data cursor.

This resolves:

    http://tracker.ceph.com/issues/4598
---
 net/ceph/messenger.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/ceph/messenger.c +1 -1
index d4e46d8..24f3aba 100644
@@ -833,7 +833,7 @@ static void ceph_msg_data_pages_cursor_init(struct
 ceph_msg_data *data,
 
 	BUG_ON(!data->pages);
 	BUG_ON(!data->length);
-	BUG_ON(length != data->length);
+	BUG_ON(length > data->length);	/* short reads are OK */
 
 	cursor->resid = length;
net/ceph/messenger.c +1 -1
 	page_count = calc_pages_for(data->alignment, (u64)data->length);
@@ -905,7 +905,7 @@ static void
 ceph_msg_data_pagelist_cursor_init(struct ceph_msg_data *data,
 
 	pagelist = data->pagelist;
 	BUG_ON(!pagelist);
-	BUG_ON(length != pagelist->length);
+	BUG_ON(length > pagelist->length);	/* short reads are OK */
 
 	if (!length)

return; /* pagelist can be assigned but empty */

Signature · 6 lines
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html