Message ID | 20250327140613.25178-3-James.Bottomley@HansenPartnership.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | vfs freeze/thaw on suspend/resume | expand |
On Thu 27-03-25 10:06:11, James Bottomley wrote: > If a write happens on a frozen filesystem, the s_writers.rw_sem gets > stuck in TASK_UNINTERRUPTIBLE and inhibits suspending or hibernating > the system. Since we want to freeze filesystems first then tasks, we > need this condition not to inhibit suspend/hibernate, which means the > wait has to have the TASK_FREEZABLE flag as well. Use the freezable > version of percpu-rwsem to ensure this. > > Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> Looks good. Feel free to add: Reviewed-by: Jan Kara <jack@suse.cz> Honza > --- > include/linux/fs.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/include/linux/fs.h b/include/linux/fs.h > index dd84d1c3b8af..cbbb704eff74 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -1782,7 +1782,8 @@ static inline void __sb_end_write(struct super_block *sb, int level) > > static inline void __sb_start_write(struct super_block *sb, int level) > { > - percpu_down_read(sb->s_writers.rw_sem + level - 1); > + percpu_down_read_freezable(sb->s_writers.rw_sem + level - 1, > + level == SB_FREEZE_WRITE); > } > > static inline bool __sb_start_write_trylock(struct super_block *sb, int level) > -- > 2.43.0 >
diff --git a/include/linux/fs.h b/include/linux/fs.h index dd84d1c3b8af..cbbb704eff74 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1782,7 +1782,8 @@ static inline void __sb_end_write(struct super_block *sb, int level) static inline void __sb_start_write(struct super_block *sb, int level) { - percpu_down_read(sb->s_writers.rw_sem + level - 1); + percpu_down_read_freezable(sb->s_writers.rw_sem + level - 1, + level == SB_FREEZE_WRITE); } static inline bool __sb_start_write_trylock(struct super_block *sb, int level)
If a write happens on a frozen filesystem, the s_writers.rw_sem gets stuck in TASK_UNINTERRUPTIBLE and inhibits suspending or hibernating the system. Since we want to freeze filesystems first then tasks, we need this condition not to inhibit suspend/hibernate, which means the wait has to have the TASK_FREEZABLE flag as well. Use the freezable version of percpu-rwsem to ensure this. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> --- include/linux/fs.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)