xfs
[Top] [All Lists]

[PATCH 1/7] XFS: track dirty inodes ourselves

To: xfs@xxxxxxxxxxx
Subject: [PATCH 1/7] XFS: track dirty inodes ourselves
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Thu, 14 Aug 2008 17:14:37 +1000
Cc: Dave Chinner <david@xxxxxxxxxxxxx>
In-reply-to: <1218698083-11226-1-git-send-email-david@xxxxxxxxxxxxx>
References: <1218698083-11226-1-git-send-email-david@xxxxxxxxxxxxx>
Sender: xfs-bounce@xxxxxxxxxxx
Allow XFS to track dirty inodes itself. Initially, we effectively
re-implement __mark_inode_dirty() to put the inode on the superblock
dirty list. This allows us to start using unhashed linux inodes and
still allow pdflush to write out dirty inodes - __mark_inode_dirty()
specificaly avoids putting unhashed inodes on the superblock dirty
list.

Signed-off-by: Dave Chinner <david@xxxxxxxxxxxxx>
---
 fs/xfs/linux-2.6/xfs_super.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 6268b35..a432f1d 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -889,6 +889,32 @@ xfs_fs_inode_init_once(
 }
 
 /*
+ * The inode has been marked dirty at the VFS. because we are using unhashed
+ * inodes now, we have to move the inode to the sb->s_dirty_list ourselves as
+ * the caller will not do it for unhashed inodes.
+ *
+ * The use of the inode_lock is purely a temporary step to make this code work
+ * safely. Ultimately XFS will track all the dirty inode state internally in
+ * the radix trees, so this lock will disappear.
+ */
+STATIC void
+xfs_fs_dirty_inode(
+       struct inode    *inode)
+{
+       extern spinlock_t inode_lock;
+
+       if (inode->i_state & I_DIRTY)
+               return;
+
+       spin_lock(&inode_lock);
+       if (!(inode->i_state & I_DIRTY)) {
+               inode->dirtied_when = jiffies;
+               list_move(&inode->i_list, &inode->i_sb->s_dirty);
+       }
+       spin_unlock(&inode_lock);
+}
+
+/*
  * Attempt to flush the inode, this will actually fail
  * if the inode is pinned, but we dirty the inode again
  * at the point when it is unpinned after a log write,
@@ -1690,6 +1716,7 @@ xfs_fs_get_sb(
 static struct super_operations xfs_super_operations = {
        .alloc_inode            = xfs_fs_alloc_inode,
        .destroy_inode          = xfs_fs_destroy_inode,
+       .dirty_inode            = xfs_fs_dirty_inode,
        .write_inode            = xfs_fs_write_inode,
        .clear_inode            = xfs_fs_clear_inode,
        .put_super              = xfs_fs_put_super,
-- 
1.5.6


<Prev in Thread] Current Thread [Next in Thread>