Skip to contentSkip to conversation

libceph: make ceph_msg->bio_seg be unsigned

PATCH In review Alex Elder 2 participants 2 messages Feb 25, 2013 – Feb 26, 2013 Ceph common code (libceph)

lore
Share & tools
lore

Alex Elder

author
#0 lore raw

PATCH 1/1 libceph: make ceph_msg->bio_seg be unsigned

The bio_seg field is used by the ceph messenger in iterating through a bio. It should never have a negative value, so make it an unsigned.

Change variables used to hold bio_seg values to all be unsigned as well. Change two variable names in init_bio_iter() to match the convention used everywhere else.

---
 include/linux/ceph/messenger.h |    2 +-
 net/ceph/messenger.c           |   16 +++++++++-------
 2 files changed, 10 insertions(+), 8 deletions(-)
include/linux/ceph/messenger.h +1 -1
index 60903e0..8297288 100644
@@ -86,7 +86,7 @@ struct ceph_msg {
 #ifdef CONFIG_BLOCK
 	struct bio  *bio;		/* instead of pages/pagelist */
 	struct bio  *bio_iter;		/* bio iterator */
-	int bio_seg;			/* current bio segment */
+	unsigned int bio_seg;		/* current bio segment */
 #endif /* CONFIG_BLOCK */
 	struct ceph_pagelist *trail;	/* the trailing part of the data */
 	bool front_is_vmalloc;
net/ceph/messenger.c +0 -0
index 2c0669f..c06f940 100644
@@ -697,18 +697,19 @@ static void con_out_kvec_add(struct

ceph_connection *con,
}

#ifdef CONFIG_BLOCK
-static void init_bio_iter(struct bio *bio, struct bio **iter, int *seg) +static void init_bio_iter(struct bio *bio, struct bio **bio_iter,
+ unsigned int *bio_seg)
{
if (!bio) {
- *iter = NULL;
- *seg = 0;
+ *bio_iter = NULL;
+ *bio_seg = 0;
return;
}
- *iter = bio;
- *seg = bio->bi_idx;
+ *bio_iter = bio;
+ *bio_seg = (unsigned int) bio->bi_idx;
}

-static void iter_bio_next(struct bio **bio_iter, int *seg) +static void iter_bio_next(struct bio **bio_iter, unsigned int *seg)
{
if (*bio_iter == NULL)
return;
@@ -1818,7 +1819,8 @@ static int read_partial_message_pages(struct ceph_connection *con,

#ifdef CONFIG_BLOCK
static int read_partial_message_bio(struct ceph_connection *con,

-				    struct bio **bio_iter, int *bio_seg,
+				    struct bio **bio_iter,
+				    unsigned int *bio_seg,

unsigned int data_len, bool do_datacrc)
{
struct bio_vec *bv = bio_iovec_idx(*bio_iter, *bio_seg);

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

The bio_seg field is used by the ceph messenger in iterating through a bio. It should never have a negative value, so make it an unsigned.

Change variables used to hold bio_seg values to all be unsigned as well. Change two variable names in init_bio_iter() to match the convention used everywhere else.

---
  include/linux/ceph/messenger.h |    2 +-
  net/ceph/messenger.c           |   16 +++++++++-------
  2 files changed, 10 insertions(+), 8 deletions(-)
include/linux/ceph/messenger.h +1 -1
index 60903e0..8297288 100644
@@ -86,7 +86,7 @@ struct ceph_msg {
  #ifdef CONFIG_BLOCK
  	struct bio  *bio;		/* instead of pages/pagelist */
  	struct bio  *bio_iter;		/* bio iterator */
-	int bio_seg;			/* current bio segment */
+	unsigned int bio_seg;		/* current bio segment */
  #endif /* CONFIG_BLOCK */
  	struct ceph_pagelist *trail;	/* the trailing part of the data */
  	bool front_is_vmalloc;
net/ceph/messenger.c +7 -6
index 2c0669f..c06f940 100644
@@ -697,18 +697,19 @@ static void con_out_kvec_add(struct
 ceph_connection *con,
  }
 
  #ifdef CONFIG_BLOCK
-static void init_bio_iter(struct bio *bio, struct bio **iter, int *seg)
+static void init_bio_iter(struct bio *bio, struct bio **bio_iter,
+			unsigned int *bio_seg)
  {
  	if (!bio) {
-		*iter = NULL;
-		*seg = 0;
+		*bio_iter = NULL;
+		*bio_seg = 0;
  		return;
  	}
-	*iter = bio;
-	*seg = bio->bi_idx;
+	*bio_iter = bio;
+	*bio_seg = (unsigned int) bio->bi_idx;
  }
 
-static void iter_bio_next(struct bio **bio_iter, int *seg)
+static void iter_bio_next(struct bio **bio_iter, unsigned int *seg)
  {
  	if (*bio_iter == NULL)

return;

net/ceph/messenger.c +2 -1
@@ -1818,7 +1819,8 @@ static int read_partial_message_pages(struct
 ceph_connection *con,
 
  #ifdef CONFIG_BLOCK
  static int read_partial_message_bio(struct ceph_connection *con,
-				    struct bio **bio_iter, int *bio_seg,
+				    struct bio **bio_iter,
+				    unsigned int *bio_seg,
  				    unsigned int data_len, bool do_datacrc)
  {
  	struct bio_vec *bv = bio_iovec_idx(*bio_iter, *bio_seg);