Re: [PATCH] additional bio list helpers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----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-----
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@xxxxxxxxxx>

===================================================================
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;
--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel

[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux