struct datablock *b0 = NULL;
int blocks = PAGE_SIZE >> ino->i_blkbits;
int i;
+ int rv = 0;
dprintk("WRITEPAGE %lu\n", page->index);
for (i = 0 ; i < blocks; i++) {
struct datablock *b = lafs_get_block(ino, i, page, GFP_KERNEL,
if (i == 0)
b0 = getdref(b, MKREF(writepage0));
+ /* We need to check PinPending, otherwise we must be called
+ * to flush out a page that is currently part of a transaction.
+ */
if (test_bit(B_Dirty, &b->b.flags)) {
- lafs_iolock_written(&b->b);
- lafs_cluster_allocate(&b->b, 0);
+ if (test_bit(B_PinPending, &b->b.flags))
+ rv = AOP_WRITEPAGE_ACTIVATE;
+ else {
+ lafs_iolock_written(&b->b);
+ lafs_cluster_allocate(&b->b, 0);
+ }
}
putdref(b, MKREF(writepage));
}
- if (b0) {
- set_page_writeback(page);
- set_bit(B_HaveWriteback, &b0->b.flags);
- lafs_iocheck_writeback(b0, 0);
+ if (rv == 0) {
+ if (b0) {
+ set_page_writeback(page);
+ set_bit(B_HaveWriteback, &b0->b.flags);
+ lafs_iocheck_writeback(b0, 0);
+ }
+ unlock_page(page);
}
- unlock_page(page); /* FIXME this must not happen before
- the writes complete! */
if (!b0)
return 0;
putdref(b0, MKREF(writepage0));
- if (wbc->for_writepages && LAFSI(ino)->depth == 0) {
+ if (rv == 0 && wbc->for_writepages && LAFSI(ino)->depth == 0) {
/* We really want the data to be safe soon, not just
* the page to be clean.
* so write the inode.
*/
struct datablock *b = lafs_inode_dblock(ino, 0,
MKREF(writepageflush));
- lafs_iolock_written(&b->b);
- lafs_cluster_allocate(&b->b, 0);
+ if (test_bit(B_Dirty, &b->b.flags)) {
+ lafs_iolock_written(&b->b);
+ lafs_cluster_allocate(&b->b, 0);
+ }
putdref(b, MKREF(writepageflush));
}
// FIXME need to make sure a cluster_flush happens some time!!! if (wbc->sync_mode != WB_SYNC_NONE)
lafs_cluster_flush(fs, 0);
dprintk("WRITEPAGE flush\n");
- return 0;
+ return rv;
}
static void lafs_sync_page(struct page *page)