From f2b2242081314ee4385f3b49d92b0adff8324d80 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 21 Mar 2012 18:14:30 +0200 Subject: ext2: write superblock only once on unmount Currently on unmount if we are mounted R/W, we first write the superblock to the media if it is dirty, and then write it again, which is not optimal. This patch makes ext2 write the superblock on unmount less times. Signed-off-by: Artem Bityutskiy Signed-off-by: Jan Kara --- fs/ext2/super.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'fs/ext2/super.c') diff --git a/fs/ext2/super.c b/fs/ext2/super.c index e1025c7a437..12a7916cfa9 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -130,9 +130,6 @@ static void ext2_put_super (struct super_block * sb) dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); - if (sb->s_dirt) - ext2_write_super(sb); - ext2_xattr_put_super(sb); if (!(sb->s_flags & MS_RDONLY)) { struct ext2_super_block *es = sbi->s_es; -- cgit v1.2.3-18-g5258 From b838ec2232b764a4903707e212c62f681b32cd51 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Sat, 31 Mar 2012 14:22:10 +0200 Subject: ext2: Remove s_dirt handling Places which modify superblock feature / state fields mark the superblock buffer dirty so it is written out by flusher thread. Thus there's no need to set s_dirt there. The only other fields changing in the superblock are the numbers of free blocks, free inodes and s_wtime. There's no real need to write (or even compute) these periodically. Free blocks / inodes counters are recomputed on every mount from group counters anyway and value of s_wtime is only informational and imprecise anyway. So it should be enough to write these opportunistically on mount, remount, umount, and sync_fs times. Signed-off-by: Jan Kara --- fs/ext2/super.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'fs/ext2/super.c') diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 12a7916cfa9..a43f9adcc81 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -1158,7 +1158,6 @@ static void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es, mark_buffer_dirty(EXT2_SB(sb)->s_sbh); if (wait) sync_dirty_buffer(EXT2_SB(sb)->s_sbh); - sb->s_dirt = 0; } /* @@ -1191,8 +1190,6 @@ void ext2_write_super(struct super_block *sb) { if (!(sb->s_flags & MS_RDONLY)) ext2_sync_fs(sb, 1); - else - sb->s_dirt = 0; } static int ext2_remount (struct super_block * sb, int * flags, char * data) -- cgit v1.2.3-18-g5258 From f72cf5e223a28d3b3ea7dc9e40464fd534e359e8 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Tue, 3 Apr 2012 12:49:18 +0300 Subject: ext2: do not register write_super within VFS Jan Kara removed 'sb->s_dirt' VFS flag references, so we do not need to register the ext2 'ext2_write_super()' method in the VFS superblock operations, because 'sb->s_dirt' won't be ever set to 1 and VFS won't ever call '->write_super()' anyway. Thus, remove the method. Tested using xfstests. Signed-off-by: Artem Bityutskiy Signed-off-by: Jan Kara --- fs/ext2/super.c | 1 - 1 file changed, 1 deletion(-) (limited to 'fs/ext2/super.c') diff --git a/fs/ext2/super.c b/fs/ext2/super.c index a43f9adcc81..e0e8f45e9a7 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -302,7 +302,6 @@ static const struct super_operations ext2_sops = { .write_inode = ext2_write_inode, .evict_inode = ext2_evict_inode, .put_super = ext2_put_super, - .write_super = ext2_write_super, .sync_fs = ext2_sync_fs, .statfs = ext2_statfs, .remount_fs = ext2_remount, -- cgit v1.2.3-18-g5258 From e2a3fde75079efeb22cf1e5098d5689b664bf1d5 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Wed, 25 Apr 2012 21:29:42 +0200 Subject: ext2: Remove i_mutex use from ext2_quota_write() We don't need i_mutex in ext2_quota_write() because writes to quota file are serialized by dqio_mutex anyway. Changes to quota files outside of quota code are forbidded and enforced by NOATIME and IMMUTABLE bits. Signed-off-by: Jan Kara --- fs/ext2/super.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'fs/ext2/super.c') diff --git a/fs/ext2/super.c b/fs/ext2/super.c index e0e8f45e9a7..7c1207c0e0c 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -1434,7 +1434,6 @@ static ssize_t ext2_quota_write(struct super_block *sb, int type, struct buffer_head tmp_bh; struct buffer_head *bh; - mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA); while (towrite > 0) { tocopy = sb->s_blocksize - offset < towrite ? sb->s_blocksize - offset : towrite; @@ -1464,16 +1463,13 @@ static ssize_t ext2_quota_write(struct super_block *sb, int type, blk++; } out: - if (len == towrite) { - mutex_unlock(&inode->i_mutex); + if (len == towrite) return err; - } if (inode->i_size < off+len-towrite) i_size_write(inode, off+len-towrite); inode->i_version++; inode->i_mtime = inode->i_ctime = CURRENT_TIME; mark_inode_dirty(inode); - mutex_unlock(&inode->i_mutex); return len - towrite; } -- cgit v1.2.3-18-g5258 From aa9e939d5296edb7d188e18892775b9938fd2923 Mon Sep 17 00:00:00 2001 From: Wang Sheng-Hui Date: Tue, 15 May 2012 07:56:06 +0800 Subject: ext2: remove the redundant comment for ext2_export_ops The comment is outdated and isn't particularly informative anyway - NULL meaning the default behavior is very common in kernel. And we really set about half of entries. So remove the whole comment for ext2_export_ops. Signed-off-by: Wang Sheng-Hui Signed-off-by: Jan Kara --- fs/ext2/super.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'fs/ext2/super.c') diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 7c1207c0e0c..c21f67f8854 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -352,11 +352,6 @@ static struct dentry *ext2_fh_to_parent(struct super_block *sb, struct fid *fid, ext2_nfs_get_inode); } -/* Yes, most of these are left as NULL!! - * A NULL value implies the default, which works with ext2-like file - * systems, but can be improved upon. - * Currently only get_parent is required. - */ static const struct export_operations ext2_export_ops = { .fh_to_dentry = ext2_fh_to_dentry, .fh_to_parent = ext2_fh_to_parent, -- cgit v1.2.3-18-g5258