All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] ext4: journal superblock modifications in ext4_statfs()
@ 2009-11-06 22:33 Eric Sandeen
  2009-11-07  0:26 ` Andreas Dilger
  0 siblings, 1 reply; 14+ messages in thread
From: Eric Sandeen @ 2009-11-06 22:33 UTC (permalink / raw)
  To: ext4 development

commit a71ce8c6c9bf269b192f352ea555217815cf027e updated
ext4_statfs() to update the on-disk superblock counters,
but modified this buffer directly without any journaling of
the change.  This is one of the accesses that was causing 
the crc errors in journal replay as seen in kernel.org 
bugzilla #14354.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---


diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 08370ae..b02daf6 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3605,6 +3605,8 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 	struct ext4_super_block *es = sbi->s_es;
 	u64 fsid;
+	handle_t *handle;
+	int err = 0;
 
 	if (test_opt(sb, MINIX_DF)) {
 		sbi->s_overhead_last = 0;
@@ -3650,20 +3652,33 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
 	buf->f_blocks = ext4_blocks_count(es) - sbi->s_overhead_last;
 	buf->f_bfree = percpu_counter_sum_positive(&sbi->s_freeblocks_counter) -
 		       percpu_counter_sum_positive(&sbi->s_dirtyblocks_counter);
-	ext4_free_blocks_count_set(es, buf->f_bfree);
 	buf->f_bavail = buf->f_bfree - ext4_r_blocks_count(es);
 	if (buf->f_bfree < ext4_r_blocks_count(es))
 		buf->f_bavail = 0;
 	buf->f_files = le32_to_cpu(es->s_inodes_count);
 	buf->f_ffree = percpu_counter_sum_positive(&sbi->s_freeinodes_counter);
-	es->s_free_inodes_count = cpu_to_le32(buf->f_ffree);
 	buf->f_namelen = EXT4_NAME_LEN;
 	fsid = le64_to_cpup((void *)es->s_uuid) ^
 	       le64_to_cpup((void *)es->s_uuid + sizeof(u64));
 	buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL;
 	buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
 
-	return 0;
+	handle = ext4_journal_start_sb(sb, 1);
+	if (IS_ERR(handle)) {
+		err = PTR_ERR(handle);
+		goto out;
+	}
+	err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh);
+	if (err)
+		goto journal_stop;
+	es->s_free_inodes_count = cpu_to_le32(buf->f_ffree);
+	ext4_free_blocks_count_set(es, buf->f_bfree);
+	err = ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh);
+
+journal_stop:
+	ext4_journal_stop(handle);
+out:
+	return err;
 }
 
 /* Helper function for writing quotas on sync - we need to start transaction


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2009-11-23 14:40 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-06 22:33 [PATCH 2/2] ext4: journal superblock modifications in ext4_statfs() Eric Sandeen
2009-11-07  0:26 ` Andreas Dilger
2009-11-07  1:08   ` Eric Sandeen
2009-11-08 21:48   ` Theodore Tso
2009-11-08 22:09     ` Eric Sandeen
2009-11-09 12:53       ` Theodore Tso
2009-11-09 17:55         ` Andreas Dilger
2009-11-09  4:41     ` Andreas Dilger
2009-11-15  3:29       ` Theodore Tso
2009-11-16 23:38         ` Andreas Dilger
2009-11-19 19:08           ` tytso
2009-11-23 11:57             ` Duane Griffin
2009-11-23 14:26               ` tytso
2009-11-23 14:40                 ` Duane Griffin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.