if (test_and_set_bit(B_Writeback, &b->flags))
LAFS_BUG(1, b);
lafs_iounlock_block(b);
- /* insert into list ensuring there is enough space
- * in cluster head
- */
+
getref(b, MKREF(cluster)); /* we soon own a reference in the list */
- while (!err && wc->remaining < 2) {
- // printk("Call flush - remaining = %d\n", wc->remaining);
- if (wc->slhead.b == NULL)
- err = new_segment(fs, cnum);
- else
- cluster_flush(fs, cnum);
- }
- if (err) {
- /* No cleaner segments - this will have to go
- * out with a checkpoint.
- * Block is still 'dirty' - just clear writeback flag.
- */
- lafs_writeback_done(b);
- putref(b, MKREF(cluster));
- mutex_unlock(&wc->lock);
- return -ENOSPC;
- }
do {
int avail;
/* see how much room is in cluster.
if (used < 0) {
/* won't fit */
// printk("Wont fit - used = %d\n", used);
- cluster_flush(fs, cnum);
+ if (wc->slhead.b == NULL) {
+ err = new_segment(fs, cnum);
+ if (err) {
+ /* No cleaner segments - this will have to go
+ * out with a checkpoint.
+ * Block is still 'dirty' - just clear
+ * writeback flag.
+ */
+ lafs_writeback_done(b);
+ putref(b, MKREF(cluster));
+ mutex_unlock(&wc->lock);
+ return -ENOSPC;
+ }
+ } else
+ cluster_flush(fs, cnum);
} else
lafs_io_wake(b);
} while (used < 0);