Skip to content

Commit 6e5af8e

Browse files
committed
Merge patch series "Extend freeze support to suspend and hibernate"
Christian Brauner <[email protected]> says: Add the necessary infrastructure changes to support freezing for suspend and hibernate. This should all that's needed to wire up power. * patches from https://lore.kernel.org/r/[email protected]: super: add filesystem freezing helpers for suspend and hibernate gfs2: pass through holder from the VFS for freeze/thaw super: use common iterator (Part 2) super: use a common iterator (Part 1) super: skip dying superblocks early super: simplify user_get_super() super: remove pointless s_root checks Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
2 parents 0af2f6b + 1af3331 commit 6e5af8e

File tree

10 files changed

+291
-129
lines changed

10 files changed

+291
-129
lines changed

fs/f2fs/gc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,12 +2271,12 @@ int f2fs_resize_fs(struct file *filp, __u64 block_count)
22712271
if (err)
22722272
return err;
22732273

2274-
err = freeze_super(sbi->sb, FREEZE_HOLDER_USERSPACE);
2274+
err = freeze_super(sbi->sb, FREEZE_HOLDER_USERSPACE, NULL);
22752275
if (err)
22762276
return err;
22772277

22782278
if (f2fs_readonly(sbi->sb)) {
2279-
err = thaw_super(sbi->sb, FREEZE_HOLDER_USERSPACE);
2279+
err = thaw_super(sbi->sb, FREEZE_HOLDER_USERSPACE, NULL);
22802280
if (err)
22812281
return err;
22822282
return -EROFS;
@@ -2333,6 +2333,6 @@ int f2fs_resize_fs(struct file *filp, __u64 block_count)
23332333
out_err:
23342334
f2fs_up_write(&sbi->cp_global_sem);
23352335
f2fs_up_write(&sbi->gc_lock);
2336-
thaw_super(sbi->sb, FREEZE_HOLDER_USERSPACE);
2336+
thaw_super(sbi->sb, FREEZE_HOLDER_USERSPACE, NULL);
23372337
return err;
23382338
}

fs/gfs2/super.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -674,15 +674,15 @@ static int gfs2_sync_fs(struct super_block *sb, int wait)
674674
return sdp->sd_log_error;
675675
}
676676

677-
static int gfs2_do_thaw(struct gfs2_sbd *sdp)
677+
static int gfs2_do_thaw(struct gfs2_sbd *sdp, enum freeze_holder who, const void *freeze_owner)
678678
{
679679
struct super_block *sb = sdp->sd_vfs;
680680
int error;
681681

682682
error = gfs2_freeze_lock_shared(sdp);
683683
if (error)
684684
goto fail;
685-
error = thaw_super(sb, FREEZE_HOLDER_USERSPACE);
685+
error = thaw_super(sb, who, freeze_owner);
686686
if (!error)
687687
return 0;
688688

@@ -703,14 +703,14 @@ void gfs2_freeze_func(struct work_struct *work)
703703
if (test_bit(SDF_FROZEN, &sdp->sd_flags))
704704
goto freeze_failed;
705705

706-
error = freeze_super(sb, FREEZE_HOLDER_USERSPACE);
706+
error = freeze_super(sb, FREEZE_HOLDER_USERSPACE, NULL);
707707
if (error)
708708
goto freeze_failed;
709709

710710
gfs2_freeze_unlock(sdp);
711711
set_bit(SDF_FROZEN, &sdp->sd_flags);
712712

713-
error = gfs2_do_thaw(sdp);
713+
error = gfs2_do_thaw(sdp, FREEZE_HOLDER_USERSPACE, NULL);
714714
if (error)
715715
goto out;
716716

@@ -728,10 +728,13 @@ void gfs2_freeze_func(struct work_struct *work)
728728
/**
729729
* gfs2_freeze_super - prevent further writes to the filesystem
730730
* @sb: the VFS structure for the filesystem
731+
* @who: freeze flags
732+
* @freeze_owner: owner of the freeze
731733
*
732734
*/
733735

734-
static int gfs2_freeze_super(struct super_block *sb, enum freeze_holder who)
736+
static int gfs2_freeze_super(struct super_block *sb, enum freeze_holder who,
737+
const void *freeze_owner)
735738
{
736739
struct gfs2_sbd *sdp = sb->s_fs_info;
737740
int error;
@@ -744,7 +747,7 @@ static int gfs2_freeze_super(struct super_block *sb, enum freeze_holder who)
744747
}
745748

746749
for (;;) {
747-
error = freeze_super(sb, FREEZE_HOLDER_USERSPACE);
750+
error = freeze_super(sb, who, freeze_owner);
748751
if (error) {
749752
fs_info(sdp, "GFS2: couldn't freeze filesystem: %d\n",
750753
error);
@@ -758,7 +761,7 @@ static int gfs2_freeze_super(struct super_block *sb, enum freeze_holder who)
758761
break;
759762
}
760763

761-
error = gfs2_do_thaw(sdp);
764+
error = gfs2_do_thaw(sdp, who, freeze_owner);
762765
if (error)
763766
goto out;
764767

@@ -796,10 +799,13 @@ static int gfs2_freeze_fs(struct super_block *sb)
796799
/**
797800
* gfs2_thaw_super - reallow writes to the filesystem
798801
* @sb: the VFS structure for the filesystem
802+
* @who: freeze flags
803+
* @freeze_owner: owner of the freeze
799804
*
800805
*/
801806

802-
static int gfs2_thaw_super(struct super_block *sb, enum freeze_holder who)
807+
static int gfs2_thaw_super(struct super_block *sb, enum freeze_holder who,
808+
const void *freeze_owner)
803809
{
804810
struct gfs2_sbd *sdp = sb->s_fs_info;
805811
int error;
@@ -814,7 +820,7 @@ static int gfs2_thaw_super(struct super_block *sb, enum freeze_holder who)
814820
atomic_inc(&sb->s_active);
815821
gfs2_freeze_unlock(sdp);
816822

817-
error = gfs2_do_thaw(sdp);
823+
error = gfs2_do_thaw(sdp, who, freeze_owner);
818824

819825
if (!error) {
820826
clear_bit(SDF_FREEZE_INITIATOR, &sdp->sd_flags);

fs/gfs2/sys.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
174174

175175
switch (n) {
176176
case 0:
177-
error = thaw_super(sdp->sd_vfs, FREEZE_HOLDER_USERSPACE);
177+
error = thaw_super(sdp->sd_vfs, FREEZE_HOLDER_USERSPACE, NULL);
178178
break;
179179
case 1:
180-
error = freeze_super(sdp->sd_vfs, FREEZE_HOLDER_USERSPACE);
180+
error = freeze_super(sdp->sd_vfs, FREEZE_HOLDER_USERSPACE, NULL);
181181
break;
182182
default:
183183
return -EINVAL;

fs/ioctl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ static int ioctl_fsfreeze(struct file *filp)
396396

397397
/* Freeze */
398398
if (sb->s_op->freeze_super)
399-
return sb->s_op->freeze_super(sb, FREEZE_HOLDER_USERSPACE);
400-
return freeze_super(sb, FREEZE_HOLDER_USERSPACE);
399+
return sb->s_op->freeze_super(sb, FREEZE_HOLDER_USERSPACE, NULL);
400+
return freeze_super(sb, FREEZE_HOLDER_USERSPACE, NULL);
401401
}
402402

403403
static int ioctl_fsthaw(struct file *filp)
@@ -409,8 +409,8 @@ static int ioctl_fsthaw(struct file *filp)
409409

410410
/* Thaw */
411411
if (sb->s_op->thaw_super)
412-
return sb->s_op->thaw_super(sb, FREEZE_HOLDER_USERSPACE);
413-
return thaw_super(sb, FREEZE_HOLDER_USERSPACE);
412+
return sb->s_op->thaw_super(sb, FREEZE_HOLDER_USERSPACE, NULL);
413+
return thaw_super(sb, FREEZE_HOLDER_USERSPACE, NULL);
414414
}
415415

416416
static int ioctl_file_dedupe_range(struct file *file,

0 commit comments

Comments
 (0)