Skip to contentSkip to conversation

make balance_dirty_pages() and NFSv3/v4 talk to one another...

PATCH New Trond Myklebust 1 participant 1 message Apr 10, 2003

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 make balance_dirty_pages() and NFSv3/v4 talk to one another...

Hi Linus,

NFSv3 and v4 both have pages that can be in a state other than the
standard dirty/locked/writeback/clean. The case of 'unstable' writes means that a page may be in a 'clean' state as far as the VM is concerned (i.e. the page has been written to the server) but it may not yet have been fsync()ed to disk on the server itself.

The following patch sets up accounting of this extra state for the
benefit of the VM page reclaiming routines.

Cheers,
Trond

fs/nfs/write.c +11 -1
diff -u --recursive --new-file linux-2.5.67/fs/nfs/write.c linux-2.5.67-01-nr_dirty/fs/nfs/write.c
@@ -274,8 +274,14 @@
 	err = nfs_flush_file(inode, NULL, 0, 0, 0);
 	if (err < 0)
 		goto out;
-	if (is_sync)
+	if (wbc->sync_mode == WB_SYNC_HOLD)
+		goto out;
+	if (is_sync && wbc->sync_mode == WB_SYNC_ALL) {
 		err = nfs_wb_all(inode);
+	} else
+		nfs_commit_file(inode, NULL, 0, 0, 0);
+	/* Avoid races. Tell upstream we've done all we were told to do */
+	wbc->nr_to_write = 0;
 out:
 	return err;
 }
@@ -363,6 +369,7 @@
 	nfs_list_add_request(req, &nfsi->dirty);
 	nfsi->ndirty++;
 	spin_unlock(&nfs_wreq_lock);
+	inc_page_state(nr_dirty);
 	mark_inode_dirty(inode);
 }
 
@@ -390,6 +397,7 @@
 	nfs_list_add_request(req, &nfsi->commit);
 	nfsi->ncommit++;
 	spin_unlock(&nfs_wreq_lock);
+	inc_page_state(nr_unstable);
 	mark_inode_dirty(inode);
 }
 #endif
@@ -457,6 +465,7 @@
 	int	res;
 	res = nfs_scan_list(&nfsi->dirty, dst, file, idx_start, npages);
 	nfsi->ndirty -= res;
+	sub_page_state(nr_dirty,res);
 	if ((nfsi->ndirty == 0) != list_empty(&nfsi->dirty))
 		printk(KERN_ERR "NFS: desynchronized value of nfs_i.ndirty.\n");
 	return res;
@@ -481,6 +490,7 @@
 	int	res;
 	res = nfs_scan_list(&nfsi->commit, dst, file, idx_start, npages);
 	nfsi->ncommit -= res;
+	sub_page_state(nr_unstable,res);
 	if ((nfsi->ncommit == 0) != list_empty(&nfsi->commit))
 		printk(KERN_ERR "NFS: desynchronized value of nfs_i.ncommit.\n");
 	return res;
include/linux/page-flags.h +3 -0
diff -u --recursive --new-file linux-2.5.67/include/linux/page-flags.h linux-2.5.67-01-nr_dirty/include/linux/page-flags.h
@@ -75,6 +75,7 @@
 #define PG_reclaim		18	/* To be reclaimed asap */
 #define PG_compound		19	/* Part of a compound page */
 
+
 /*
  * Global page accounting.  One instance per CPU.  Only unsigned longs are
  * allowed.
@@ -82,6 +83,7 @@
 struct page_state {
 	unsigned long nr_dirty;		/* Dirty writeable pages */
 	unsigned long nr_writeback;	/* Pages under writeback */
+	unsigned long nr_unstable;	/* NFS unstable pages */
 	unsigned long nr_page_table_pages;/* Pages used for pagetables */
 	unsigned long nr_mapped;	/* mapped into pagetables */
 	unsigned long nr_slab;		/* In slab */
@@ -130,6 +132,7 @@
 
 #define inc_page_state(member)	mod_page_state(member, 1UL)
 #define dec_page_state(member)	mod_page_state(member, 0UL - 1)
+#define sub_page_state(member,delta) mod_page_state(member, 0UL - (delta))
 
 
 /*
mm/page_alloc.c +4 -1
diff -u --recursive --new-file linux-2.5.67/mm/page_alloc.c linux-2.5.67-01-nr_dirty/mm/page_alloc.c
@@ -936,11 +936,13 @@
 		K(nr_free_pages()),
 		K(nr_free_highpages()));
 
-	printk("Active:%lu inactive:%lu dirty:%lu writeback:%lu free:%u\n",
+	printk("Active:%lu inactive:%lu dirty:%lu writeback:%lu "
+		"unstable:%lu free:%u\n",
 		active,
 		inactive,
 		ps.nr_dirty,
 		ps.nr_writeback,
+		ps.nr_unstable,
 		nr_free_pages());
 
 	for_each_zone(zone) {
@@ -1431,6 +1433,7 @@
 static char *vmstat_text[] = {
 	"nr_dirty",
 	"nr_writeback",
+	"nr_unstable",
 	"nr_page_table_pages",
 	"nr_mapped",
 	"nr_slab",
mm/page-writeback.c +28 -14

80 lines not on this page · raw message