Message ID | 20200304082327.GA14236@dumbo (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
Series | hibernate: Allow uswsusp to write to swap | expand |
On Wed, Mar 04, 2020 at 09:23:27AM +0100, Domenico Andreoli wrote: > From: Domenico Andreoli <domenico.andreoli@linux.com> > > It turns out that there is one use case for programs being able to > write to swap devices, and that is the userspace hibernation code. You might want to start a separate thread for this... :) > Quick fix: disable the S_SWAPFILE check if hibernation is configured. > > Fixes: 1638045c3677 ("mm: set S_SWAPFILE on blockdev swap devices") Also, this should be Fixes: dc617f29dbe5 ("vfs: don't allow writes to swap files") since we still want to set S_SWAPFILE on active swap devices. > Reported-by: Domenico Andreoli <domenico.andreoli@linux.com> > Reported-by: Marian Klein <mkleinsoft@gmail.com> > Signed-off-by: Domenico Andreoli <domenico.andreoli@linux.com> > > --- > fs/block_dev.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > Index: b/fs/block_dev.c > =================================================================== > --- a/fs/block_dev.c > +++ b/fs/block_dev.c > @@ -2001,7 +2001,8 @@ ssize_t blkdev_write_iter(struct kiocb * > if (bdev_read_only(I_BDEV(bd_inode))) > return -EPERM; > > - if (IS_SWAPFILE(bd_inode)) > + /* uswsusp needs to write to the swap */ > + if (IS_SWAPFILE(bd_inode) && !IS_ENABLED(CONFIG_HIBERNATION)) ...&& hibernation_available() ? That way we can configure this dynamically. Thanks for taking this on, I'll go self-NAK the revert patch I sent yesterday. --D > return -ETXTBSY; > > if (!iov_iter_count(from))
Index: b/fs/block_dev.c =================================================================== --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -2001,7 +2001,8 @@ ssize_t blkdev_write_iter(struct kiocb * if (bdev_read_only(I_BDEV(bd_inode))) return -EPERM; - if (IS_SWAPFILE(bd_inode)) + /* uswsusp needs to write to the swap */ + if (IS_SWAPFILE(bd_inode) && !IS_ENABLED(CONFIG_HIBERNATION)) return -ETXTBSY; if (!iov_iter_count(from))