Subject: afs/fs/cachefs super.c,1.39,1.40 journal.c,1.44,1.45

From: [email-masked]
Date: Mon, 15 Sep 2003 19:00:22 +0100

Update of /home/cvs/afs/fs/cachefs
In directory phoenix.infradead.org:/tmp/cvs-serv1999/fs/cachefs

Modified Files:
	super.c journal.c 
Log Message:
add sync_fs() support

Index: super.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/super.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- super.c	15 Sep 2003 13:53:25 -0000	1.39
+++ super.c	15 Sep 2003 18:00:19 -0000	1.40
@@ -36,6 +36,7 @@
 static int cachefs_fill_super(struct super_block *sb, void *_data, int silent);
 static int cachefs_initialise_blockdev(struct cachefs_super *super);
 static int cachefs_statfs(struct super_block *sb, struct kstatfs *buf);
+static int cachefs_sync_fs(struct super_block *sb, int wait);
 static void cachefs_write_super(struct super_block *sb);
 static void cachefs_put_super(struct super_block *sb);
 
@@ -51,6 +52,7 @@
 	.statfs		= cachefs_statfs,
 	.alloc_inode	= cachefs_alloc_inode,
 	.write_inode	= cachefs_write_inode,
+	.sync_fs	= cachefs_sync_fs,
 	.destroy_inode	= cachefs_destroy_inode,
 	.clear_inode	= cachefs_clear_inode,
 	.write_super	= cachefs_write_super,
@@ -688,6 +690,24 @@
 
 	return 0;
 } /* end cachefs_statfs() */
+
+/*****************************************************************************/
+/*
+ * synchronise the filesystem to disc
+ */
+static int cachefs_sync_fs(struct super_block *sb, int wait)
+{
+	struct cachefs_super *super = sb->s_fs_info;
+
+	_enter(",%d", wait);
+
+	cachefs_trans_sync(super,
+			   wait ? CACHEFS_TRANS_SYNC_WAIT_FOR_ACK :
+			   CACHEFS_TRANS_SYNC_NOWAIT);
+
+	_leave(" = 0");
+	return 0;
+} /* end cachefs_sync_fs() */
 
 /*****************************************************************************/
 /*

Index: journal.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/journal.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- journal.c	15 Sep 2003 13:53:25 -0000	1.44
+++ journal.c	15 Sep 2003 18:00:19 -0000	1.45
@@ -653,6 +653,9 @@
 	 * out */
 	down_write(&super->batch_ctrl_sem);
 
+	if (list_empty(&super->ujnl_commitq))
+		goto nothing_to_do;
+
 	BUG_ON(!list_empty(&super->ujnl_markq));
 
 	list_for_each_entry(trans, &super->ujnl_commitq, sblink) {
@@ -736,11 +739,18 @@
 		cachefs_trans_put(trans);
 	}
 
+ done:
 	up(&super->batch_sem);
 
 	wake_up_all(&super->batch_sync_wq);
 
 	_leave("");
+	return;
+
+ nothing_to_do:
+	up(&super->batch_uj_sem);
+	up_write(&super->batch_ctrl_sem);
+	goto done;
 } /* end cachefs_trans_batch_write() */
 
 /*****************************************************************************/
@@ -1413,14 +1423,15 @@
 
 	DECLARE_WAITQUEUE(myself, current);
 
-	kenter("{batch=%hd},%d", super->ujnl_batch, wait);
+	_enter("{batch=%hd ser=%hu},%d",
+	       super->ujnl_batch, super->ujnl_serial, wait);
 
 	/* if we're not supposed to wait, just induce consideration of a batch
 	 * write */
 	if (wait == CACHEFS_TRANS_SYNC_NOWAIT) {
 		set_bit(CACHEFS_SUPER_BATCH_TIMER, &super->flags);
 		wake_up_all(&super->batch_timer_wq);
-		kleave("");
+		_leave("");
 		return;
 	}
 
@@ -1428,7 +1439,7 @@
 	 * sync ends */
 	down_write(&super->batch_ctrl_sem);
 
-	if (super->ujnl_serial == 0) {
+	if (list_empty(&super->ujnl_commitq)) {
 		/* no pending transactions */
 		up_write(&super->batch_ctrl_sem);
 	}
@@ -1455,7 +1466,8 @@
 		set_current_state(TASK_RUNNING);
 	}
 
-	/* now we have to wait for any currently active batch write */
+	/* now we have to wait for any currently active batch write to
+	 * (partially) complete */
 	if (wait == CACHEFS_TRANS_SYNC_WAIT_FOR_MARK) {
 		down(&super->batch_uj_sem);
 		up(&super->batch_uj_sem);
@@ -1465,5 +1477,5 @@
 		up(&super->batch_sem);
 	}
 
-	kleave("");
+	_leave("");
 } /* end cachefs_trans_sync() */