From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D62C4C3F2CE for ; Wed, 4 Mar 2020 16:31:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 93D0B21739 for ; Wed, 4 Mar 2020 16:31:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93D0B21739 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2F2C26B0007; Wed, 4 Mar 2020 11:31:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A4686B0008; Wed, 4 Mar 2020 11:31:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E0CF6B000A; Wed, 4 Mar 2020 11:31:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0195.hostedemail.com [216.40.44.195]) by kanga.kvack.org (Postfix) with ESMTP id 0442C6B0007 for ; Wed, 4 Mar 2020 11:31:22 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 9600E8248D52 for ; Wed, 4 Mar 2020 16:31:22 +0000 (UTC) X-FDA: 76558220004.02.wound64_462cb3911ee4b X-HE-Tag: wound64_462cb3911ee4b X-Filterd-Recvd-Size: 8263 Received: from mail-vk1-f195.google.com (mail-vk1-f195.google.com [209.85.221.195]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Wed, 4 Mar 2020 16:31:22 +0000 (UTC) Received: by mail-vk1-f195.google.com with SMTP id x62so725374vkg.11 for ; Wed, 04 Mar 2020 08:31:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eKDgSK419hboXbmWxmiGNCG/5vnCL3Y8sy0pPs5n07g=; b=nkoZKQmxA4LsaZYQDvGMljf23o3G3+NHI21xc+Ug78agQoOvlWM7E6lhnmBLuRca4F ZQfwh8vZfNBCxWMc6Nw5vumoynhAulWmhUW8nRXYTXH+64O2ctlHiXa8L7+8+NfyN/Py GB2j7IY3sGE3bY1PFcmLIC3AQb4OMIKEaJuvrvqYMt8xoMIdIDKz2S2yjrUkTgRXTrtV ahwC1zSWpCOpR6zlQKf+zyNflsINRs+rbG/zKm1QCGAf+TBcgWla6YK8KdW+YCqsD9qF DJm+8gWlyUiUYlyrsblkN0kbkWyoEfw8Qq2woaI0u6/PERgAdumYEg+L0tXt1JFqax/5 zXew== X-Gm-Message-State: ANhLgQ1FRV10ZR4xO/d9c3Zbx3UqCx2BeeBe0002Xhe76MmM3FvBJCS9 LDuWtN1kr6bNpN1awF49QL4CcG2y8vE4FYBkq1A= X-Google-Smtp-Source: ADFU+vvgapOqoYoZnWjJEkJ2OH5pd9zfk5cN4mTer1ukZPnd21U3T98C/45aH8YtNUR2PdsRJ4O6SJHeTht9jAOFkqw= X-Received: by 2002:a1f:5fca:: with SMTP id t193mr1958468vkb.102.1583339481511; Wed, 04 Mar 2020 08:31:21 -0800 (PST) MIME-Version: 1.0 References: <20200229170825.GX8045@magnolia> <20200229180716.GA31323@dumbo> <20200229183820.GA8037@magnolia> <20200229200200.GA10970@dumbo> <20200303190212.GC8037@magnolia> <9E4A0457-39B1-45E2-AEA2-22C730BF2C4F@gmail.com> <20200304011840.GD1752567@magnolia> <20200304082327.GA14236@dumbo> <20200304154526.GH8036@magnolia> In-Reply-To: <20200304154526.GH8036@magnolia> From: Domenico Andreoli Date: Wed, 4 Mar 2020 17:31:11 +0100 Message-ID: Subject: Re: [PATCH] hibernate: Allow uswsusp to write to swap To: "Darrick J. Wong" Cc: Domenico Andreoli , "Rafael J. Wysocki" , Linux PM , Linux Memory Management List , linux-fsdevel@vger.kernel.org, mkleinsoft@gmail.com, Christoph Hellwig , Andrew Morton , "Rafael J. Wysocki" , Len Brown , Pavel Machek Content-Type: multipart/alternative; boundary="0000000000005ab85805a009f3ba" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: --0000000000005ab85805a009f3ba Content-Type: text/plain; charset="UTF-8" On Wed, Mar 4, 2020 at 4:45 PM Darrick J. Wong wrote: > On Wed, Mar 04, 2020 at 09:23:27AM +0100, Domenico Andreoli wrote: > > From: Domenico Andreoli > > > > 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... :) > Right > 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") > Of course since we still want to set S_SWAPFILE on active swap devices. > > > Reported-by: Domenico Andreoli > > Reported-by: Marian Klein > > Signed-off-by: Domenico Andreoli > > > > --- > > 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. > Then it would just be "if (IS_SWAPFILE(bd_inode) && !hibernation_available())", right? Thanks for taking this on, I'll go self-NAK the revert patch I sent > yesterday. > Thanks, Dom --0000000000005ab85805a009f3ba Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Mar 4, 2020 at 4:45 PM Darrick J. Wong <darrick.wong@oracle.com>= wrote:
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... :)

Right

> Quick fix: disable the S_SWAPFILE check if hibernation is configured.<= br> >
> Fixes: 1638045c3677 ("mm: set S_SWAPFILE on blockdev swap devices= ")

Also, this should be

Fixes: dc617f29dbe5 ("vfs: don't allow writes to swap files")=

Of course

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>
>
> ---
>=C2=A0 fs/block_dev.c |=C2=A0 =C2=A0 3 ++-
>=C2=A0 1 file changed, 2 insertions(+), 1 deletion(-)
>
> Index: b/fs/block_dev.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -2001,7 +2001,8 @@ ssize_t blkdev_write_iter(struct kiocb *
>=C2=A0 =C2=A0 =C2=A0 =C2=A0if (bdev_read_only(I_BDEV(bd_inode)))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return -EPERM; >=C2=A0
> -=C2=A0 =C2=A0 =C2=A0if (IS_SWAPFILE(bd_inode))
> +=C2=A0 =C2=A0 =C2=A0/* uswsusp needs to write to the swap */
> +=C2=A0 =C2=A0 =C2=A0if (IS_SWAPFILE(bd_inode) && !IS_ENABLED(= CONFIG_HIBERNATION))

...&& hibernation_available() ?=C2=A0 That way we can configure thi= s
dynamically.

Then it would just be &quo= t;if (IS_SWAPFILE(bd_inode) &&=20 !hibernation_available())", right?

Thanks for taking this on, I'll go self-NAK the revert patch I sent
yesterday.
=C2=A0
Thanks,
Dom
<= /div>
--0000000000005ab85805a009f3ba--