All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Bryn M. Reeves" <breeves@redhat.com>
To: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Cc: dm-devel@redhat.com, mauelshagen@redhat.com
Subject: Re: [PATCH] additional bio list helpers
Date: Wed, 07 Feb 2007 11:26:14 +0000	[thread overview]
Message-ID: <45C9B756.4090408@redhat.com> (raw)
In-Reply-To: <20070206.160524.39151213.k-ueda@ct.jp.nec.com>

[-- Attachment #1: Type: text/plain, Size: 1263 bytes --]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Kiyoshi,

Kiyoshi Ueda wrote:
> This one breaks the bio_list if bl2 is a empty list.
> Probably missed to add like below?
> -----------------------------------
> +	if (bio_list_empty(bl2))
> +		return;
> -----------------------------------

Quite right - fixed, thanks!

> I think that bl->tail is always NULL when bl->head is NULL,
> unless the bio_list is corrupted.  So no need to check bl->tail.

This was actually already changed in my git copy, but I forgot to
re-generate the patch before posting - apologies!

> I think that this check in not needed because it is covered
> by bio_for_each() below.

Agreed!

> I think that bio_list_join() is same as existing bio_list_merge_head().

Also agreed - thanks for catching these. This one also isn't used by
dm-loop anyway.

Revised patch attached - this time just including the changes actually
needed by the dm-loop patch:

bio_list_empty
bio_for_each
bio_list_nr
bio_list_merge_init

Kind regards,

Bryn.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFFybdW6YSQoMYUY94RAgZxAKChuSEQAP0zs+f9/yzjCf92beTkJQCdEQBq
oxBR+Xsj1V6Fj4r9ec3sPZ0=
=nIAj
-----END PGP SIGNATURE-----

[-- Attachment #2: dm-bio-list-helpers.patch --]
[-- Type: text/x-patch, Size: 1467 bytes --]

Add additional bio list helpers to dm-bio-list.h:

bio_list_empty
bio_for_each
bio_list_nr
bio_list_merge_init

These are used by dm-loop for manipulating lists of bios to be
resubmitted by the fs I/O code.

Signed-off-by: Bryn Reeves <breeves@redhat.com>

===================================================================
diff --git a/drivers/md/dm-bio-list.h b/drivers/md/dm-bio-list.h
index da43496..6db7644 100644
--- a/drivers/md/dm-bio-list.h
+++ b/drivers/md/dm-bio-list.h
@@ -14,11 +14,31 @@ struct bio_list {
 	struct bio *tail;
 };
 
+static inline int  bio_list_empty(struct bio_list *bl)
+{
+	return bl->head == NULL;
+}
+
+#define BIO_LIST_HEAD(bl)	struct bio_list bl = { NULL, NULL }
+
 static inline void bio_list_init(struct bio_list *bl)
 {
 	bl->head = bl->tail = NULL;
 }
 
+#define bio_for_each(bio, bl) \
+	for (bio = (bl)->head; bio; bio = bio->bi_next)
+
+static inline int bio_list_nr(struct bio_list *bl)
+{
+	int i=0;
+	struct bio *bio;
+
+	bio_for_each(bio, bl)
+		i++;
+	return i;
+}
+
 static inline void bio_list_add(struct bio_list *bl, struct bio *bio)
 {
 	bio->bi_next = NULL;
@@ -58,6 +78,13 @@ static inline void bio_list_merge_head(struct bio_list *bl,
 	bl->head = bl2->head;
 }
 
+static inline void bio_list_merge_init(struct bio_list *bl,
+				       struct bio_list *bl2)
+{
+	bio_list_merge(bl, bl2);
+	bio_list_init(bl2);
+}
+
 static inline struct bio *bio_list_pop(struct bio_list *bl)
 {
 	struct bio *bio = bl->head;

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



      reply	other threads:[~2007-02-07 11:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-06 11:00 [PATCH] additional bio list helpers Bryn M. Reeves
2007-02-06 21:05 ` Kiyoshi Ueda
2007-02-07 11:26   ` Bryn M. Reeves [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=45C9B756.4090408@redhat.com \
    --to=breeves@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=k-ueda@ct.jp.nec.com \
    --cc=mauelshagen@redhat.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.