list_add_tail(&b->cleaning, &tc->cleaning);
}
- /* FIXME do I need a memory barrier. to ensure truncate
- * sees the not-list_empty, and we see i_size? */
+ /* We can race with truncate here, so need to check
+ * i_size again now that b->cleaning is non-empty.
+ * The thread doing the truncate will have to lock
+ * the page holding this block, which should be enough
+ * of a barrier so that if it sets i_size after now,
+ * it will see that b->cleaning is non-empty.
+ * We need to be sure that if it sets it before now,
+ * we get to see i_size.
+ * So I think a memory barrier is a good idea...
+ */
+ mb();
if (LAFSI(ino)->type == 0 ||
(LAFSI(ino)->type >= TypeBase &&