summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorMateusz Guzik <mguzik@redhat.com>2017-10-03 12:17:41 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2018-03-19 02:21:40 -0400
commit08fdc8a0138afaf324296a342f32ad26ec465e43 (patch)
treee645f0525576eec37e4eb892aa654f97df9b3b83 /fs
parentfa7c1d5080f6e7dc4428210b6eac60271f899908 (diff)
buffer.c: call thaw_super during emergency thaw
There are 2 distinct freezing mechanisms - one operates on block devices and another one directly on super blocks. Both end up with the same result, but thaw of only one of these does not thaw the other. In particular fsfreeze --freeze uses the ioctl variant going to the super block. Since prior to this patch emergency thaw was not doing a relevant thaw, filesystems frozen with this method remained unaffected. The patch is a hack which adds blind unfreezing. In order to keep the super block write-locked the whole time the code is shuffled around and the newly introduced __iterate_supers is employed. Signed-off-by: Mateusz Guzik <mguzik@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/buffer.c25
-rw-r--r--fs/super.c44
2 files changed, 43 insertions, 26 deletions
diff --git a/fs/buffer.c b/fs/buffer.c
index 170df856bdb9..37ea00b265d0 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -523,35 +523,12 @@ repeat:
523 return err; 523 return err;
524} 524}
525 525
526static void do_thaw_one(struct super_block *sb, void *unused) 526void emergency_thaw_bdev(struct super_block *sb)
527{ 527{
528 while (sb->s_bdev && !thaw_bdev(sb->s_bdev, sb)) 528 while (sb->s_bdev && !thaw_bdev(sb->s_bdev, sb))
529 printk(KERN_WARNING "Emergency Thaw on %pg\n", sb->s_bdev); 529 printk(KERN_WARNING "Emergency Thaw on %pg\n", sb->s_bdev);
530} 530}
531 531
532static void do_thaw_all(struct work_struct *work)
533{
534 iterate_supers(do_thaw_one, NULL);
535 kfree(work);
536 printk(KERN_WARNING "Emergency Thaw complete\n");
537}
538
539/**
540 * emergency_thaw_all -- forcibly thaw every frozen filesystem
541 *
542 * Used for emergency unfreeze of all filesystems via SysRq
543 */
544void emergency_thaw_all(void)
545{
546 struct work_struct *work;
547
548 work = kmalloc(sizeof(*work), GFP_ATOMIC);
549 if (work) {
550 INIT_WORK(work, do_thaw_all);
551 schedule_work(work);
552 }
553}
554
555/** 532/**
556 * sync_mapping_buffers - write out & wait upon a mapping's "associated" buffers 533 * sync_mapping_buffers - write out & wait upon a mapping's "associated" buffers
557 * @mapping: the mapping which wants those buffers written 534 * @mapping: the mapping which wants those buffers written
diff --git a/fs/super.c b/fs/super.c
index fd9c02f543eb..83c5c8a60f5f 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -36,6 +36,7 @@
36#include <linux/user_namespace.h> 36#include <linux/user_namespace.h>
37#include "internal.h" 37#include "internal.h"
38 38
39static int thaw_super_locked(struct super_block *sb);
39 40
40static LIST_HEAD(super_blocks); 41static LIST_HEAD(super_blocks);
41static DEFINE_SPINLOCK(sb_lock); 42static DEFINE_SPINLOCK(sb_lock);
@@ -934,6 +935,40 @@ void emergency_remount(void)
934 } 935 }
935} 936}
936 937
938static void do_thaw_all_callback(struct super_block *sb)
939{
940 down_write(&sb->s_umount);
941 if (sb->s_root && sb->s_flags & MS_BORN) {
942 emergency_thaw_bdev(sb);
943 thaw_super_locked(sb);
944 } else {
945 up_write(&sb->s_umount);
946 }
947}
948
949static void do_thaw_all(struct work_struct *work)
950{
951 __iterate_supers(do_thaw_all_callback);
952 kfree(work);
953 printk(KERN_WARNING "Emergency Thaw complete\n");
954}
955
956/**
957 * emergency_thaw_all -- forcibly thaw every frozen filesystem
958 *
959 * Used for emergency unfreeze of all filesystems via SysRq
960 */
961void emergency_thaw_all(void)
962{
963 struct work_struct *work;
964
965 work = kmalloc(sizeof(*work), GFP_ATOMIC);
966 if (work) {
967 INIT_WORK(work, do_thaw_all);
968 schedule_work(work);
969 }
970}
971
937/* 972/*
938 * Unnamed block devices are dummy devices used by virtual 973 * Unnamed block devices are dummy devices used by virtual
939 * filesystems which don't use real block-devices. -- jrs 974 * filesystems which don't use real block-devices. -- jrs
@@ -1503,11 +1538,10 @@ EXPORT_SYMBOL(freeze_super);
1503 * 1538 *
1504 * Unlocks the filesystem and marks it writeable again after freeze_super(). 1539 * Unlocks the filesystem and marks it writeable again after freeze_super().
1505 */ 1540 */
1506int thaw_super(struct super_block *sb) 1541static int thaw_super_locked(struct super_block *sb)
1507{ 1542{
1508 int error; 1543 int error;
1509 1544
1510 down_write(&sb->s_umount);
1511 if (sb->s_writers.frozen != SB_FREEZE_COMPLETE) { 1545 if (sb->s_writers.frozen != SB_FREEZE_COMPLETE) {
1512 up_write(&sb->s_umount); 1546 up_write(&sb->s_umount);
1513 return -EINVAL; 1547 return -EINVAL;
@@ -1538,4 +1572,10 @@ out:
1538 deactivate_locked_super(sb); 1572 deactivate_locked_super(sb);
1539 return 0; 1573 return 0;
1540} 1574}
1575
1576int thaw_super(struct super_block *sb)
1577{
1578 down_write(&sb->s_umount);
1579 return thaw_super_locked(sb);
1580}
1541EXPORT_SYMBOL(thaw_super); 1581EXPORT_SYMBOL(thaw_super);