From patchwork Fri May 4 17:27:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 156972 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1B584B6FAC for ; Sat, 5 May 2012 03:28:18 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SQMH1-0006QX-69; Fri, 04 May 2012 17:26:31 +0000 Received: from mga02.intel.com ([134.134.136.20]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SQMGp-0006NT-Ej for linux-mtd@lists.infradead.org; Fri, 04 May 2012 17:26:20 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 04 May 2012 10:26:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.67,351,1309762800"; d="scan'208";a="140179751" Received: from blue.fi.intel.com (HELO np.fi.intel.com) ([10.237.72.50]) by orsmga002.jf.intel.com with ESMTP; 04 May 2012 10:26:17 -0700 From: Artem Bityutskiy To: David Woodhouse , MTD Maling List Subject: [PATCH 2/2] jffs2: get rid of jffs2_sync_super Date: Fri, 4 May 2012 20:27:08 +0300 Message-Id: <1336152428-24242-3-git-send-email-dedekind1@gmail.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1336152428-24242-1-git-send-email-dedekind1@gmail.com> References: <1336152428-24242-1-git-send-email-dedekind1@gmail.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [134.134.136.20 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (dedekind1[at]gmail.com) 0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is CUSTOM_MED 0.8 SPF_NEUTRAL SPF: sender does not match SPF record (neutral) 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (dedekind1[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.9 NML_ADSP_CUSTOM_MED ADSP custom_med hit, and not from a mailing list Cc: Artem Bityutskiy , Linux Kernel Maling List X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Artem Bityutskiy Currently JFFS2 file-system maps the VFS "superblock" abstraction to the write-buffer. Namely, it uses VFS services to synchronize the write-buffer periodically. The whole "superblock write-out" VFS infrastructure is served by the 'sync_supers()' kernel thread, which wakes up every 5 (by default) seconds and writes out all dirty superblock using the '->write_super()' call-back. But the problem with this thread is that it wastes power by waking up the system every 5 seconds no matter what. So we want to kill it completely and thus, we need to make file-systems to stop using the '->write_super' VFS service, and then remove it together with the kernel thread. This patch switches the JFFS2 write-buffer management from '->write_super()'/'->s_dirt' to 'wbuf_inode'/'->write_inode'. Instead of setting the 's_dirt' flag, we just mark the special 'wbuf_inode' inode as dirty and let VFS invoke the '->write_inode' call-back when needed, where we synchronize the write-buffer. Signed-off-by: Artem Bityutskiy --- fs/jffs2/fs.c | 18 ++++++++++++++++++ fs/jffs2/os-linux.h | 3 ++- fs/jffs2/super.c | 22 +--------------------- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index 94016a9..c6aacbb 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c @@ -228,6 +228,24 @@ int jffs2_statfs(struct dentry *dentry, struct kstatfs *buf) return 0; } +int jffs2_write_inode(struct inode *inode, struct writeback_control *wbc) +{ + struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb); + + /* + * JFFS2 is synchronous file-system, and the only the fake write-buffer + * inode is allowed to be writen-out asynchronously - we use this to do + * delayed write-buffer synchronization. + */ + BUG_ON(inode != c->wbuf_inode); + + if (!(inode->i_sb->s_flags & MS_RDONLY)) { + jffs2_dbg(1, "%s()\n", __func__); + jffs2_flush_wbuf_gc(c, 0); + } + + return 0; +} void jffs2_evict_inode (struct inode *inode) { diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h index 6f28cc5..ab97e88 100644 --- a/fs/jffs2/os-linux.h +++ b/fs/jffs2/os-linux.h @@ -144,7 +144,7 @@ void jffs2_nor_wbuf_flash_cleanup(struct jffs2_sb_info *c); static inline void jffs2_dirty_trigger(struct jffs2_sb_info *c) { - OFNI_BS_2SFFJ(c)->s_dirt = 1; + __mark_inode_dirty(c->wbuf_inode, I_DIRTY_SYNC); } /* background.c */ @@ -173,6 +173,7 @@ extern const struct inode_operations jffs2_symlink_inode_operations; int jffs2_setattr (struct dentry *, struct iattr *); int jffs2_do_setattr (struct inode *, struct iattr *); struct inode *jffs2_iget(struct super_block *, unsigned long); +int jffs2_write_inode(struct inode *inode, struct writeback_control *wbc); void jffs2_evict_inode (struct inode *); void jffs2_dirty_inode(struct inode *inode, int flags); struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index a180409..0b4e632 100644 --- a/fs/jffs2/super.c +++ b/fs/jffs2/super.c @@ -63,21 +63,6 @@ static void jffs2_i_init_once(void *foo) inode_init_once(&f->vfs_inode); } -static void jffs2_write_super(struct super_block *sb) -{ - struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); - - lock_super(sb); - sb->s_dirt = 0; - - if (!(sb->s_flags & MS_RDONLY)) { - jffs2_dbg(1, "%s()\n", __func__); - jffs2_flush_wbuf_gc(c, 0); - } - - unlock_super(sb); -} - static const char *jffs2_compr_name(unsigned int compr) { switch (compr) { @@ -113,8 +98,6 @@ static int jffs2_sync_fs(struct super_block *sb, int wait) { struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); - jffs2_write_super(sb); - mutex_lock(&c->alloc_sem); jffs2_flush_wbuf_pad(c); mutex_unlock(&c->alloc_sem); @@ -249,9 +232,9 @@ static int jffs2_remount_fs(struct super_block *sb, int *flags, char *data) static const struct super_operations jffs2_super_operations = { .alloc_inode = jffs2_alloc_inode, + .write_inode = jffs2_write_inode, .destroy_inode =jffs2_destroy_inode, .put_super = jffs2_put_super, - .write_super = jffs2_write_super, .statfs = jffs2_statfs, .remount_fs = jffs2_remount_fs, .evict_inode = jffs2_evict_inode, @@ -319,9 +302,6 @@ static void jffs2_put_super (struct super_block *sb) jffs2_dbg(2, "%s()\n", __func__); - if (sb->s_dirt) - jffs2_write_super(sb); - mutex_lock(&c->alloc_sem); jffs2_flush_wbuf_pad(c); mutex_unlock(&c->alloc_sem);