From patchwork Wed Mar 4 08:23:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Domenico Andreoli X-Patchwork-Id: 11419597 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F25F818B8 for ; Wed, 4 Mar 2020 08:26:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C057324654 for ; Wed, 4 Mar 2020 08:26:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EkGDq+M9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C057324654 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 01A196B0003; Wed, 4 Mar 2020 03:26:35 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F0CC36B0005; Wed, 4 Mar 2020 03:26:34 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DFB486B0006; Wed, 4 Mar 2020 03:26:34 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0177.hostedemail.com [216.40.44.177]) by kanga.kvack.org (Postfix) with ESMTP id C9FAE6B0003 for ; Wed, 4 Mar 2020 03:26:34 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 881C81CB23 for ; Wed, 4 Mar 2020 08:26:34 +0000 (UTC) X-FDA: 76556998308.22.yard49_395ea4bb5712e X-Spam-Summary: 2,0,0,40abe96f4cdb589b,d41d8cd98f00b204,cavokz@gmail.com,,RULES_HIT:41:355:379:800:960:973:988:989:1260:1277:1312:1313:1314:1345:1359:1437:1516:1518:1519:1535:1541:1593:1594:1595:1596:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3867:3868:3871:3872:3874:4321:5007:6261:6653:7514:7576:10004:10226:10400:11026:11658:11914:12043:12291:12297:12517:12519:12555:12679:12683:13069:13221:13229:13311:13357:13439:13870:13895:14096:14097:14181:14394:14721:21080:21444:21451:21627:21990:30012:30054:30064:30070,0,RBL:209.85.128.68:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: yard49_395ea4bb5712e X-Filterd-Recvd-Size: 5113 Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Wed, 4 Mar 2020 08:26:34 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id 6so891596wmi.5 for ; Wed, 04 Mar 2020 00:26:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:resent-from:resent-date:resent-message-id:resent-to:date :from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=cew+TTcIlK2By1bAt5CHCB+JbVcMMEPMguJwF68q6nc=; b=EkGDq+M902cBO3hGsFctGZEpXVHP36fXlc32Rl6xk16tnjw64LxLDxz/lFLgINWm/Z C/yaFDEEmhgPZrTbzxQxuWJgXybNi3qjCD8WeW/5tMCCcxizyM0H/RCPzPEfcPl+IQdU Pi75F8tVezaToHcvKCuiy5VrC+9NrUMxtsBwek7s2aVSzYwMEF74j3KcggLoFr1GQEyp eZgjsohxI6JBj1BXccjYALKFUFbBoxPWDTnvChlhwUa5Gk4mNW0cMXtbzKB54z/i5FYt Wo0h/9JXjsZ4dxpZJC+nkULdUwyZ5ZkJTmv3quOP6BIpWW6bMH7n1MF5GkATpZt/VgNr MQJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:resent-from:resent-date:resent-message-id :resent-to:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=cew+TTcIlK2By1bAt5CHCB+JbVcMMEPMguJwF68q6nc=; b=BRAL3GYybW3TXwRRVtNmQuK/ylBEO1sbTTiQFeiNFoLYnO8gK044fxTk07nSsTyZ+g rC7V8JLWxUkmjvjJ2IQoUimyaZuxF2GkE4k3HothV8raYwW5HBzl0HMd8p+Sd1wYYODV 0sZKGcUn1Y1MzKWuIEHgcslGLnHoKcX3bGKnMeP0U1yLSGcIobtioagT/AapnofOIJWs akeLiIMDCSMMYShOsXjRBf+T6PdGhptmCN3o1F21DF6rU4lY5WzX7QtLx/neXVQnwtR2 wYezNaQKrqvM4R/zLl0FdwGCLkqPZghVbj8/rAFi/3bBTQcy0GKB/3p5pivBqmYE1m1B uUMg== X-Gm-Message-State: ANhLgQ0jcsDmaExYFAej0pF8ybVibfVGGb+WTI8zgon+m9ttnuyQ8IkT CjUxxw+hiRGqXhOXYHVMkFg= X-Google-Smtp-Source: ADFU+vu7adAidQTk9w40n9EY1EUCejzXdBQ6wWbVxorNNvSm/fXI6OMtAlZDLhyHCq1lsHgvoY8Dxg== X-Received: by 2002:a1c:4c0c:: with SMTP id z12mr2387419wmf.63.1583310392885; Wed, 04 Mar 2020 00:26:32 -0800 (PST) Received: from dumbo ([83.137.6.114]) by smtp.gmail.com with ESMTPSA id j14sm38671237wrn.32.2020.03.04.00.26.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2020 00:26:32 -0800 (PST) Date: Wed, 4 Mar 2020 09:23:27 +0100 From: Domenico Andreoli To: "Darrick J. Wong" Cc: "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 Subject: [PATCH] hibernate: Allow uswsusp to write to swap Message-ID: <20200304082327.GA14236@dumbo> 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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200304011840.GD1752567@magnolia> User-Agent: Mutt/1.10.1 (2018-07-13) 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: 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. Quick fix: disable the S_SWAPFILE check if hibernation is configured. Fixes: 1638045c3677 ("mm: set S_SWAPFILE on blockdev 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)) return -ETXTBSY; if (!iov_iter_count(from))