From: Jan Kara <jack@suse.cz>
To: linux-fsdevel@vger.kernel.org
Cc: Al Viro <viro@ZenIV.linux.org.uk>,
dchinner@redhat.com, Jan Kara <jack@suse.cz>
Subject: [PATCH 25/27] ext2: Implement freezing
Date: Sat, 2 Jun 2012 00:30:39 +0200 [thread overview]
Message-ID: <1338589841-9568-26-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1338589841-9568-1-git-send-email-jack@suse.cz>
The only missing piece to make freezing work reliably with ext2 is to
stop iput() of unlinked inode from deleting the inode on frozen filesystem.
So add a necessary protection to ext2_evict_inode().
We also provide appropriate ->freeze_fs and ->unfreeze_fs functions.
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ext2/inode.c | 5 ++++-
fs/ext2/super.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 1 deletions(-)
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 264d315..6363ac6 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -79,6 +79,7 @@ void ext2_evict_inode(struct inode * inode)
truncate_inode_pages(&inode->i_data, 0);
if (want_delete) {
+ sb_start_intwrite(inode->i_sb);
/* set dtime */
EXT2_I(inode)->i_dtime = get_seconds();
mark_inode_dirty(inode);
@@ -98,8 +99,10 @@ void ext2_evict_inode(struct inode * inode)
if (unlikely(rsv))
kfree(rsv);
- if (want_delete)
+ if (want_delete) {
ext2_free_inode(inode);
+ sb_end_intwrite(inode->i_sb);
+ }
}
typedef struct {
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index b3621cb..25232c1 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -42,6 +42,8 @@ static void ext2_sync_super(struct super_block *sb,
static int ext2_remount (struct super_block * sb, int * flags, char * data);
static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf);
static int ext2_sync_fs(struct super_block *sb, int wait);
+static int ext2_freeze(struct super_block *sb);
+static int ext2_unfreeze(struct super_block *sb);
void ext2_error(struct super_block *sb, const char *function,
const char *fmt, ...)
@@ -305,6 +307,8 @@ static const struct super_operations ext2_sops = {
.evict_inode = ext2_evict_inode,
.put_super = ext2_put_super,
.sync_fs = ext2_sync_fs,
+ .freeze_fs = ext2_freeze,
+ .unfreeze_fs = ext2_unfreeze,
.statfs = ext2_statfs,
.remount_fs = ext2_remount,
.show_options = ext2_show_options,
@@ -1194,6 +1198,35 @@ static int ext2_sync_fs(struct super_block *sb, int wait)
return 0;
}
+static int ext2_freeze(struct super_block *sb)
+{
+ struct ext2_sb_info *sbi = EXT2_SB(sb);
+
+ /*
+ * Open but unlinked files present? Keep EXT2_VALID_FS flag cleared
+ * because we have unattached inodes and thus filesystem is not fully
+ * consistent.
+ */
+ if (atomic_long_read(&sb->s_remove_count)) {
+ ext2_sync_fs(sb, 1);
+ return 0;
+ }
+ /* Set EXT2_FS_VALID flag */
+ spin_lock(&sbi->s_lock);
+ sbi->s_es->s_state = cpu_to_le16(sbi->s_mount_state);
+ spin_unlock(&sbi->s_lock);
+ ext2_sync_super(sb, sbi->s_es, 1);
+
+ return 0;
+}
+
+static int ext2_unfreeze(struct super_block *sb)
+{
+ /* Just write sb to clear EXT2_VALID_FS flag */
+ ext2_write_super(sb);
+
+ return 0;
+}
void ext2_write_super(struct super_block *sb)
{
--
1.7.1
next prev parent reply other threads:[~2012-06-01 22:31 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-01 22:30 [PATCH 00/27 v6] Fix filesystem freezing deadlocks Jan Kara
2012-06-01 22:30 ` [PATCH 01/27] fb_defio: Push file_update_time() into fb_deferred_io_mkwrite() Jan Kara
2012-06-01 22:30 ` [PATCH 02/27] fs: Push file_update_time() into __block_page_mkwrite() Jan Kara
2012-06-01 22:30 ` [PATCH 03/27] ceph: Push file_update_time() into ceph_page_mkwrite() Jan Kara
2012-06-01 22:30 ` [PATCH 04/27] 9p: Push file_update_time() into v9fs_vm_page_mkwrite() Jan Kara
2012-06-01 22:30 ` [PATCH 05/27] gfs2: Push file_update_time() into gfs2_page_mkwrite() Jan Kara
2012-06-01 22:30 ` [PATCH 06/27] sysfs: Push file_update_time() into bin_page_mkwrite() Jan Kara
2012-06-01 22:30 ` [PATCH 07/27] mm: Update file times from fault path only if .page_mkwrite is not set Jan Kara
2012-06-01 22:30 ` [PATCH 08/27] mm: Make default vm_ops provide ->page_mkwrite handler Jan Kara
2012-06-01 22:30 ` [PATCH 09/27] fs: Push mnt_want_write() outside of i_mutex Jan Kara
2012-06-01 22:30 ` [PATCH 10/27] fat: " Jan Kara
2012-06-01 22:30 ` [PATCH 11/27] btrfs: " Jan Kara
2012-06-01 22:30 ` [PATCH 12/27] nfsd: " Jan Kara
2012-06-01 22:30 ` [PATCH 13/27] fs: Improve filesystem freezing handling Jan Kara
2012-06-01 22:30 ` [PATCH 14/27] fs: Add freezing handling to mnt_want_write() / mnt_drop_write() Jan Kara
2012-06-06 8:04 ` Dave Chinner
2012-06-06 15:16 ` Jan Kara
2012-06-01 22:30 ` [PATCH 15/27] fs: Skip atime update on frozen filesystem Jan Kara
2012-06-01 22:30 ` [PATCH 16/27] fs: Protect write paths by sb_start_write - sb_end_write Jan Kara
2012-06-01 22:30 ` [PATCH 17/27] ext4: Convert to new freezing mechanism Jan Kara
2012-06-11 3:13 ` Ted Ts'o
2012-06-01 22:30 ` [PATCH 18/27] xfs: Convert to new freezing code Jan Kara
2012-06-05 4:15 ` Dave Chinner
2012-06-05 8:43 ` Jan Kara
2012-06-01 22:30 ` [PATCH 19/27] ocfs2: Convert to new freezing mechanism Jan Kara
2012-06-01 22:30 ` [PATCH 20/27] gfs2: " Jan Kara
2012-06-01 22:30 ` [PATCH 21/27] fuse: " Jan Kara
2012-06-01 22:30 ` [PATCH 22/27] ntfs: " Jan Kara
2012-06-01 22:30 ` [PATCH 24/27] btrfs: " Jan Kara
2012-06-01 22:30 ` Jan Kara [this message]
2012-06-01 22:30 ` [PATCH 26/27] fs: Remove old " Jan Kara
2012-06-01 22:30 ` [PATCH 27/27] Documentation: Correct s_umount state for freeze_fs/unfreeze_fs Jan Kara
[not found] ` <1338589841-9568-1-git-send-email-jack-AlSwsSmVLrQ@public.gmane.org>
2012-06-01 22:30 ` [PATCH 23/27] nilfs2: Convert to new freezing mechanism Jan Kara
2012-06-09 6:29 ` [PATCH 00/27 v6] Fix filesystem freezing deadlocks Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1338589841-9568-26-git-send-email-jack@suse.cz \
--to=jack@suse.cz \
--cc=dchinner@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).