From: Fernando Luis =?ISO-8859-1?Q?V=E1zquez?= Cao Subject: [PATCH 6/9] fsfreeze: move emergency thaw code to fs/super.c Date: Fri, 14 Sep 2012 15:51:15 +0900 Message-ID: <1347605475.6868.8.camel@nexus.lab.ntt.co.jp> References: <1347605006.6868.2.camel@nexus.lab.ntt.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: Josef Bacik , Eric Sandeen , Dave Chinner , Christoph Hellwig , Jan Kara , linux-fsdevel@vger.kernel.org, fernando@intellilink.co.jp To: Al Viro Return-path: Received: from tama50.ecl.ntt.co.jp ([129.60.39.147]:34540 "EHLO tama50.ecl.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751724Ab2INGvh (ORCPT ); Fri, 14 Sep 2012 02:51:37 -0400 In-Reply-To: <1347605006.6868.2.camel@nexus.lab.ntt.co.jp> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: It makes no sense having the emergency thaw code in fs/buffer.c when all of it's operations are one superblocks and the code it executes is all in fs/super.c. Move the code there and clean it up. Cc: Josef Bacik Cc: Eric Sandeen Cc: Christoph Hellwig Reviewed-by: Jan Kara Signed-off-by: Dave Chinner Signed-off-by: Fernando Luis Vazquez Cao --- diff -urNp linux-3.6-rc5-orig/fs/buffer.c linux-3.6-rc5/fs/buffer.c --- linux-3.6-rc5-orig/fs/buffer.c 2012-09-14 13:18:41.801042524 +0900 +++ linux-3.6-rc5/fs/buffer.c 2012-09-14 13:30:11.605062587 +0900 @@ -511,49 +511,6 @@ repeat: return err; } -static void do_thaw_one(struct super_block *sb, void *unused) -{ - int res; - - if (sb->s_bdev) { - char b[BDEVNAME_SIZE]; - printk(KERN_WARNING "Emergency Thaw on %s.\n", - bdevname(sb->s_bdev, b)); - } - - /* We were called from __iterate_supers with superblock lock taken - * so we do not need to do it here. */ - res = __thaw_super(sb); - if (!res) - deactivate_locked_super(sb); - else - up_write(&sb->s_umount); - return res; -} - -static void do_thaw_all(struct work_struct *work) -{ - iterate_supers_write(do_thaw_one, NULL); - kfree(work); - printk(KERN_WARNING "Emergency Thaw complete\n"); -} - -/** - * emergency_thaw_all -- forcibly thaw every frozen filesystem - * - * Used for emergency unfreeze of all filesystems via SysRq - */ -void emergency_thaw_all(void) -{ - struct work_struct *work; - - work = kmalloc(sizeof(*work), GFP_ATOMIC); - if (work) { - INIT_WORK(work, do_thaw_all); - schedule_work(work); - } -} - /** * sync_mapping_buffers - write out & wait upon a mapping's "associated" buffers * @mapping: the mapping which wants those buffers written diff -urNp linux-3.6-rc5-orig/fs/super.c linux-3.6-rc5/fs/super.c --- linux-3.6-rc5-orig/fs/super.c 2012-09-14 12:46:26.884872000 +0900 +++ linux-3.6-rc5/fs/super.c 2012-09-14 13:34:17.125068798 +0900 @@ -612,7 +612,7 @@ void iterate_supers_read(void (*f)(struc * the lock after the function return. See description of __iterate_supers * above for details. */ -void iterate_supers_write(void (*f)(struct super_block *, void *), void *arg) +static void iterate_supers_write(void (*f)(struct super_block *, void *), void *arg) { __iterate_supers(f, arg , true); } @@ -1446,7 +1446,7 @@ EXPORT_SYMBOL(freeze_super); * to protect the superblock by grabbing the s_umount semaphore in write mode * and release it again on return. See thaw_super() for an example. */ -int __thaw_super(struct super_block *sb) +static int __thaw_super(struct super_block *sb) { int error = 0; @@ -1493,3 +1493,46 @@ int thaw_super(struct super_block *sb) return res; } EXPORT_SYMBOL(thaw_super); + +static void do_thaw_one(struct super_block *sb, void *unused) +{ + int res; + + if (sb->s_bdev) { + char b[BDEVNAME_SIZE]; + printk(KERN_WARNING "Emergency Thaw on %s.\n", + bdevname(sb->s_bdev, b)); + } + + /* We were called from __iterate_supers with superblock lock taken + * so we do not need to do it here. */ + res = __thaw_super(sb); + if (!res) + deactivate_locked_super(sb); + else + up_write(&sb->s_umount); + return res; +} + +static void do_thaw_all(struct work_struct *work) +{ + iterate_supers_write(do_thaw_one, NULL); + kfree(work); + printk(KERN_WARNING "Emergency Thaw complete\n"); +} + +/** + * emergency_thaw_all -- forcibly thaw every frozen filesystem + * + * Used for emergency unfreeze of all filesystems via SysRq + */ +void emergency_thaw_all(void) +{ + struct work_struct *work; + + work = kmalloc(sizeof(*work), GFP_ATOMIC); + if (work) { + INIT_WORK(work, do_thaw_all); + schedule_work(work); + } +} diff -urNp linux-3.6-rc5-orig/include/linux/fs.h linux-3.6-rc5/include/linux/fs.h --- linux-3.6-rc5-orig/include/linux/fs.h 2012-09-14 12:46:26.884872000 +0900 +++ linux-3.6-rc5/include/linux/fs.h 2012-09-14 13:32:52.993064282 +0900 @@ -2082,7 +2082,6 @@ extern int user_statfs(const char __user extern int fd_statfs(int, struct kstatfs *); extern int vfs_ustat(dev_t, struct kstatfs *); extern int freeze_super(struct super_block *super); -extern int __thaw_super(struct super_block *super); extern int thaw_super(struct super_block *super); extern bool our_mnt(struct vfsmount *mnt); @@ -2686,7 +2685,6 @@ extern struct super_block *get_super_tha extern struct super_block *get_active_super(struct block_device *bdev); extern void drop_super(struct super_block *sb); extern void iterate_supers_read(void (*)(struct super_block *, void *), void *); -extern void iterate_supers_write(void (*)(struct super_block *, void *), void *); extern void iterate_supers_type(struct file_system_type *, void (*)(struct super_block *, void *), void *);