[Ocfs2-commits] mfasheh commits r2302 - trunk/fs/ocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Fri May 20 17:02:34 CDT 2005
Author: mfasheh
Signed-off-by: manish
Date: 2005-05-20 17:02:32 -0500 (Fri, 20 May 2005)
New Revision: 2302
Modified:
trunk/fs/ocfs2/alloc.c
trunk/fs/ocfs2/alloc.h
trunk/fs/ocfs2/ocfs.h
trunk/fs/ocfs2/super.c
Log:
* add automatic flushing of the truncate log.
* do a truncate log flush in ocfs2_sync_fs
Signed-off-by: manish
Modified: trunk/fs/ocfs2/alloc.c
===================================================================
--- trunk/fs/ocfs2/alloc.c 2005-05-20 19:49:44 UTC (rev 2301)
+++ trunk/fs/ocfs2/alloc.c 2005-05-20 22:02:32 UTC (rev 2302)
@@ -1034,7 +1034,7 @@
}
/* Expects you to already be holding tl_inode->i_sem */
-static int ocfs2_flush_truncate_log(ocfs_super *osb)
+static int __ocfs2_flush_truncate_log(ocfs_super *osb)
{
int status;
unsigned int num_to_flush;
@@ -1111,6 +1111,47 @@
return status;
}
+int ocfs2_flush_truncate_log(ocfs_super *osb)
+{
+ int status;
+ struct inode *tl_inode = osb->osb_tl_inode;
+
+ down(&tl_inode->i_sem);
+ status = __ocfs2_flush_truncate_log(osb);
+ up(&tl_inode->i_sem);
+
+ return status;
+}
+
+static void ocfs2_truncate_log_worker(void *data)
+{
+ int status;
+ ocfs_super *osb = data;
+
+ mlog_entry();
+
+ status = ocfs2_flush_truncate_log(osb);
+ if (status < 0)
+ mlog_errno(status);
+
+ mlog_exit(status);
+}
+
+#define OCFS2_TRUNCATE_LOG_FLUSH_INTERVAL (2 * HZ)
+void ocfs2_schedule_truncate_log_flush(ocfs_super *osb,
+ int cancel)
+{
+ if (osb->osb_tl_inode) {
+ /* We want to push off log flushes while truncates are
+ * still running. */
+ if (cancel)
+ cancel_delayed_work(&osb->osb_truncate_log_wq);
+
+ schedule_delayed_work(&osb->osb_truncate_log_wq,
+ OCFS2_TRUNCATE_LOG_FLUSH_INTERVAL);
+ }
+}
+
static int ocfs2_get_truncate_log_info(ocfs_super *osb,
int slot_num,
struct inode **tl_inode,
@@ -1239,7 +1280,7 @@
down(&tl_inode->i_sem);
for(i = 0; i < num_recs; i++) {
if (ocfs2_truncate_log_needs_flush(osb)) {
- status = ocfs2_flush_truncate_log(osb);
+ status = __ocfs2_flush_truncate_log(osb);
if (status < 0) {
mlog_errno(status);
goto bail_up;
@@ -1281,20 +1322,18 @@
mlog_entry();
- if (!tl_inode)
- return;
+ if (tl_inode) {
+ cancel_delayed_work(&osb->osb_truncate_log_wq);
+ flush_scheduled_work();
- down(&tl_inode->i_sem);
+ status = ocfs2_flush_truncate_log(osb);
+ if (status < 0)
+ mlog_errno(status);
- status = ocfs2_flush_truncate_log(osb);
- if (status)
- mlog_errno(status);
+ brelse(osb->osb_tl_bh);
+ iput(osb->osb_tl_inode);
+ }
- up(&tl_inode->i_sem);
-
- brelse(osb->osb_tl_bh);
- iput(osb->osb_tl_inode);
-
mlog_exit_void();
}
@@ -1316,8 +1355,9 @@
/* ocfs2_truncate_log_shutdown keys on the existence of
* osb->osb_tl_inode so we don't set any of the osb variables
* until we're sure all is well. */
+ INIT_WORK(&osb->osb_truncate_log_wq, ocfs2_truncate_log_worker, osb);
+ osb->osb_tl_bh = tl_bh;
osb->osb_tl_inode = tl_inode;
- osb->osb_tl_bh = tl_bh;
mlog_exit(status);
return status;
@@ -1697,7 +1737,7 @@
* record is free for use. If there isn't any, we flush to get
* an empty truncate log. */
if (ocfs2_truncate_log_needs_flush(osb)) {
- status = ocfs2_flush_truncate_log(osb);
+ status = __ocfs2_flush_truncate_log(osb);
if (status < 0) {
mlog_errno(status);
goto bail;
@@ -1745,6 +1785,8 @@
bail:
up_write(&OCFS_I(inode)->ip_alloc_sem);
+ ocfs2_schedule_truncate_log_flush(osb, 1);
+
if (tl_sem)
up(&tl_inode->i_sem);
Modified: trunk/fs/ocfs2/alloc.h
===================================================================
--- trunk/fs/ocfs2/alloc.h 2005-05-20 19:49:44 UTC (rev 2301)
+++ trunk/fs/ocfs2/alloc.h 2005-05-20 22:02:32 UTC (rev 2302)
@@ -53,6 +53,9 @@
int ocfs2_truncate_log_init(ocfs_super *osb);
void ocfs2_truncate_log_shutdown(ocfs_super *osb);
+void ocfs2_schedule_truncate_log_flush(ocfs_super *osb,
+ int cancel);
+int ocfs2_flush_truncate_log(ocfs_super *osb);
int ocfs2_begin_truncate_log_recovery(ocfs_super *osb,
int slot_num,
ocfs2_dinode **tl_copy);
Modified: trunk/fs/ocfs2/ocfs.h
===================================================================
--- trunk/fs/ocfs2/ocfs.h 2005-05-20 19:49:44 UTC (rev 2301)
+++ trunk/fs/ocfs2/ocfs.h 2005-05-20 22:02:32 UTC (rev 2302)
@@ -412,6 +412,7 @@
/* Truncate log info */
struct inode *osb_tl_inode;
struct buffer_head *osb_tl_bh;
+ struct work_struct osb_truncate_log_wq;
};
#define NAMEI_RA_CHUNKS 2
Modified: trunk/fs/ocfs2/super.c
===================================================================
--- trunk/fs/ocfs2/super.c 2005-05-20 19:49:44 UTC (rev 2301)
+++ trunk/fs/ocfs2/super.c 2005-05-20 22:02:32 UTC (rev 2302)
@@ -89,7 +89,7 @@
static int ocfs_statfs(struct super_block *sb, struct kstatfs *buf);
-static int ocfs_sync_fs(struct super_block *sb, int wait);
+static int ocfs2_sync_fs(struct super_block *sb, int wait);
static int ocfs_init_global_system_inodes(ocfs_super *osb);
static int ocfs_init_local_system_inodes(ocfs_super *osb);
@@ -108,7 +108,7 @@
.statfs = ocfs_statfs,
.clear_inode = ocfs_clear_inode,
.delete_inode = ocfs_delete_inode,
- .sync_fs = ocfs_sync_fs,
+ .sync_fs = ocfs2_sync_fs,
.write_super = ocfs_write_super,
.put_super = ocfs_put_super,
@@ -141,11 +141,22 @@
sb->s_dirt = 0;
}
-static int ocfs_sync_fs(struct super_block *sb, int wait)
+static int ocfs2_sync_fs(struct super_block *sb, int wait)
{
+ int status = 0;
tid_t target;
+ ocfs_super *osb = OCFS2_SB(sb);
sb->s_dirt = 0;
+
+ if (wait) {
+ status = ocfs2_flush_truncate_log(osb);
+ if (status < 0)
+ mlog_errno(status);
+ } else {
+ ocfs2_schedule_truncate_log_flush(osb, 0);
+ }
+
if (journal_start_commit(OCFS2_SB(sb)->journal->j_journal, &target)) {
if (wait)
log_wait_commit(OCFS2_SB(sb)->journal->j_journal,
More information about the Ocfs2-commits
mailing list