diff packages/fs/jffs2/current/src/gcthread.c @ 1443:cd7d2afbc7dd

Import latest JFFS2 code from David Woodhouse
author gthomas
date Thu, 11 Dec 2003 23:33:54 +0000
parents
children
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/packages/fs/jffs2/current/src/gcthread.c
@@ -0,0 +1,52 @@
+/*
+ * JFFS2 -- Journalling Flash File System, Version 2.
+ *
+ * Copyright (C) 2001-2003 Red Hat, Inc.
+ *
+ * Created by David Woodhouse <dwmw2@redhat.com>
+ *
+ * For licensing information, see the file 'LICENCE' in this directory.
+ *
+ * $Id: gcthread.c,v 1.1 2003/11/26 15:55:35 dwmw2 Exp $
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/jffs2.h>
+#include "nodelist.h"
+
+
+static void jffs2_garbage_collect_thread(struct jffs2_sb_info *c);
+
+void jffs2_garbage_collect_trigger(struct jffs2_sb_info *c)
+{
+	/* Wake up the thread */
+	(void)&jffs2_garbage_collect_thread;
+}
+
+void jffs2_start_garbage_collect_thread(struct jffs2_sb_info *c)
+{
+	/* Start the thread. Doesn't matter if it fails -- it's only an optimisation anyway */
+}
+
+void jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c)
+{
+	/* Stop the thread and wait for it if necessary */
+}
+
+
+static void jffs2_garbage_collect_thread(struct jffs2_sb_info *c)
+{
+#define this_thread_should_die() 0
+	while(!this_thread_should_die()) {
+		while(!jffs2_thread_should_wake(c)) {
+			/* Sleep.... */
+			continue;
+		}
+		if (jffs2_garbage_collect_pass(c) == -ENOSPC) {
+			printf("No space for garbage collection. Aborting JFFS2 GC thread\n");
+			break;
+		}
+	}
+}