]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - buffer_tree.c
Fix doxygen reference to struct writer.
[paraslash.git] / buffer_tree.c
index 4aeb790a6e3c6e8efe9a841e4b12fbe331f360f9..45650a241d65efb3858ecbea737002e7725ffb10 100644 (file)
@@ -159,6 +159,35 @@ size_t btr_pool_get_buffer(struct btr_pool *btrp, char **result)
        return btr_pool_available(btrp);
 }
 
+/**
+ * Get references to buffers pointing to free space of the buffer pool area.
+ *
+ * \param btrp The buffer pool.
+ * \param iov The scatter array.
+ *
+ * \return Zero if the buffer pool is full, one if the free space of the buffer
+ * pool area is available as a single contiguous buffer, two if the free space
+ * consists of two buffers. If this function returns the value n, then n
+ * elements of \a iov are initialized.
+ */
+int btr_pool_get_buffers(struct btr_pool *btrp, struct iovec iov[2])
+{
+       size_t sz, unused;
+       char *buf;
+
+       sz = btr_pool_get_buffer(btrp, &buf);
+       if (sz == 0)
+               return 0;
+       iov[0].iov_len = sz;
+       iov[0].iov_base = buf;
+       unused = btr_pool_unused(btrp);
+       if (sz == unused)
+               return 1;
+       iov[1].iov_len = unused - sz;
+       iov[1].iov_base = btrp->area_start;
+       return 2;
+}
+
 /**
  * Mark a part of the buffer pool area as allocated.
  *
@@ -727,12 +756,15 @@ void btr_splice_out_node(struct btr_node *btrn)
        assert(list_empty(&btrn->children));
 }
 
-/*
- * Return the size of the largest input queue.
+/**
+ * Return number of queued output bytes of a buffer tree node.
+ *
+ * \param btrn The node whose output queue size should be computed.
  *
- * Iterates over all children of the given node.
+ * This function iterates over all children of the given node and returns the
+ * size of the largest input queue.
  */
-static size_t btr_bytes_pending(struct btr_node *btrn)
+size_t btr_get_output_queue_size(struct btr_node *btrn)
 {
        size_t max_size = 0;
        struct btr_node *ch;
@@ -1074,7 +1106,7 @@ int btr_node_status(struct btr_node *btrn, size_t min_iqs,
        if (type != BTR_NT_LEAF) {
                if (btr_no_children(btrn))
                        return -E_BTR_NO_CHILD;
-               if (btr_bytes_pending(btrn) > BTRN_MAX_PENDING)
+               if (btr_get_output_queue_size(btrn) > BTRN_MAX_PENDING)
                        return 0;
        }
        if (type != BTR_NT_ROOT) {