commit 1e079023130ede43ad6b4f00954604550235fe9d
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date: Sun Mar 18 17:23:31 2007 -0400
cleanup ic only if free blocks/inodes below certain %
wake_up_sioa now makes sure sioa resumes before calling thread
diff --git a/fs/unionfs/odf.c b/fs/unionfs/odf.c
index c186c21..d6d2770 100644
--- a/fs/unionfs/odf.c
+++ b/fs/unionfs/odf.c
@@ -68,7 +68,7 @@ struct odf_sb_info* odf_read_super(char *options)
}
sioa->cleanup.odf = osi;
osi->cleanup = sioa;
- run_sioa(sioa, __odf_cleanup_w, __odf_cleanup_d, ODF_RC_TIMEOUT);
+ run_sioa(sioa, __odf_cleanup_w, __odf_cleanup_d, ODF_CL_TIMEOUT);
osi->mnt = nd.mnt;
mntget(osi->mnt);
@@ -1191,16 +1191,26 @@ void __odf_cleanup_w(void *args)
struct cleanup_args *cl = &sioa_args->cleanup;
struct odf_dentry_info *odi_rc, *odi_ic;
struct kstatfs stat;
-
- /* FIXME: only cleanup ic if certain % of space used */
- /* XXX: what about when only no free inodes left but lots of space? */
- vfs_statfs(cl->odf->odi_sb->dentry, &stat);
+ int cleanup = 0;
+ int err = 0;
odi_ic = cl->odf->odi_ic;
odf_lock(odi_ic);
- unionfs_force_rmdir(cl->odf->mnt, odi_ic->dentry,
FRMV_NOTPARENT|FRMV_LEAF);
- odf_unlock(odi_ic);
+ vfs_statfs(cl->odf->odi_sb->dentry, &stat);
+ if (stat.f_bavail * 100 < stat.f_blocks * ODF_CL_PCNT_B) {
+ cleanup = 1;
+ printk("cleanup thread: free blocks below critical size\n");
+ }
+ else if (stat.f_ffree * 100 < stat.f_ffree * ODF_CL_PCNT_I) {
+ cleanup = 1;
+ printk("cleanup thread: free inodes below critical size\n");
+ }
+ if (cleanup)
+ err = unionfs_force_rmdir(cl->odf->mnt, odi_ic->dentry,
FRMV_NOTPARENT|FRMV_LEAF);
+ BUG_ON(err); /* temporary */
+ odf_unlock(odi_ic);
+
odi_rc = cl->odf->odi_rc;
odf_lock(odi_rc);
unionfs_force_rmdir(cl->odf->mnt, odi_rc->dentry, FRMV_NOTPARENT);
diff --git a/fs/unionfs/odf.h b/fs/unionfs/odf.h
index f994a7d..445169e 100644
--- a/fs/unionfs/odf.h
+++ b/fs/unionfs/odf.h
@@ -41,7 +41,9 @@
#define ODF_DIRENT_MAGIC 0x0DFD1300
/* Reclaim thread timeout */
-#define ODF_RC_TIMEOUT 10000
+#define ODF_CL_TIMEOUT 10000
+#define ODF_CL_PCNT_I 25 /* cleanup ic when % of free inodes goes below this
val */
+#define ODF_CL_PCNT_B 30 /* cleanup ic when % of free blocks goes below this
val */
#define ODF_CONTENT "content"
#define ODF_CONTENT_LEN 7
diff --git a/fs/unionfs/sioq.c b/fs/unionfs/sioq.c
index 8f23c1d..e6c8b40 100644
--- a/fs/unionfs/sioq.c
+++ b/fs/unionfs/sioq.c
@@ -65,7 +65,9 @@ int __run_sioa(void *args)
do {
sioa_args->work(args);
current->state = TASK_INTERRUPTIBLE;
+ mutex_lock(&sioa_args->sleep_lock);
schedule_timeout(sioa_args->timeout);
+ mutex_unlock(&sioa_args->sleep_lock);
} while (!sioa_args->done(args));
complete(&sioa_args->comp);
return 0;
@@ -81,6 +83,7 @@ void run_sioa(struct sioa_args *args, void (*work) (void*),
int (*done) (void*), signed long timeout)
{
init_completion(&args->comp);
+ mutex_init(&args->sleep_lock);
args->process = NULL;
args->timeout = timeout;
args->work = work;
diff --git a/fs/unionfs/sioq.h b/fs/unionfs/sioq.h
index cfc0ba4..f6cac22 100644
--- a/fs/unionfs/sioq.h
+++ b/fs/unionfs/sioq.h
@@ -58,6 +58,7 @@ struct sioa_args {
signed long timeout;
void (*work) (void*);
int (*done) (void*);
+ struct mutex sleep_lock;
union {
struct cleanup_args cleanup;
@@ -68,9 +69,13 @@ extern int __init init_sioq(void);
extern __exit void stop_sioq(void);
extern void run_sioq(work_func_t func, struct sioq_args *args);
extern void run_sioa(struct sioa_args *args, void (*work) (void*), int (*done)
(void*), signed long timeout);
+
+/* wakes up the process and makes sure it resumes before we do */
static inline void wake_up_sioa(struct sioa_args *args)
{
wake_up_process(args->process);
+ mutex_lock(&args->sleep_lock);
+ mutex_unlock(&args->sleep_lock);
}
static inline void wait_for_sioa(struct sioa_args *args)
{
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs