Re: [PATCH] only irq-safe atomic ops

From: Andrew Morton (akpm@zip.com.au)
Date: Mon Feb 25 2002 - 14:42:21 EST


Stephen Lord wrote:
>
> Yep, bio just made it easier to get larger requests.
>

Which promptly go kersplat when you feed them into
submit_bio():

     BUG_ON(bio_sectors(bio) > q->max_sectors);

Given that I'm hand-rolling a monster bio, I need to know
when to wrap it up and send it off, to avoid creating a bio
which is larger than the target device will accept. I'm currently
using the below patch. Am I right that this is missing API
functionality, or did I miss something?

Also, I could not find a way of querying the size of the vector
at *bi_io_vec. This is also information which would be helpful
when building large scatter/gather lists.

--- 2.5.5/drivers/block/ll_rw_blk.c~mpio-10-biobits Mon Feb 25 00:28:21 2002
+++ 2.5.5-akpm/drivers/block/ll_rw_blk.c Mon Feb 25 00:28:21 2002
@@ -1350,6 +1350,28 @@ static void end_bio_bh_io_sync(struct bi
 }
 
 /**
+ * bio_max_bytes: return the maximum number of bytes which can be
+ * placed in a single bio for a particular device.
+ *
+ * @dev: the device's kdev_t
+ *
+ * Each device has a maximum permissible queue size, and bios may
+ * not cover more data than that.
+ *
+ * Returns -ve on error.
+ */
+int bio_max_bytes(kdev_t dev)
+{
+ request_queue_t *q;
+ int ret = -1;
+
+ q = blk_get_queue(dev);
+ if (q)
+ ret = (q->max_sectors << 9);
+ return ret;
+}
+
+/**
  * submit_bio: submit a bio to the block device layer for I/O
  * @rw: whether to %READ or %WRITE, or maybe to %READA (read ahead)
  * @bio: The &struct bio which describes the I/O
--- 2.5.5/include/linux/bio.h~mpio-10-biobits Mon Feb 25 00:28:21 2002
+++ 2.5.5-akpm/include/linux/bio.h Mon Feb 25 00:28:21 2002
@@ -204,5 +204,6 @@ extern struct bio *bio_copy(struct bio *
 extern inline void bio_init(struct bio *);
 
 extern int bio_ioctl(kdev_t, unsigned int, unsigned long);
+extern int bio_max_bytes(kdev_t dev);
 
 #endif /* __LINUX_BIO_H */

-
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Feb 28 2002 - 21:00:17 EST