From patchwork Wed May 18 07:48:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Kumar X-Patchwork-Id: 12853279 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 228C5C433FE for ; Wed, 18 May 2022 07:49:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B54956B007B; Wed, 18 May 2022 03:49:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B04716B007D; Wed, 18 May 2022 03:49:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9CBEF6B007E; Wed, 18 May 2022 03:49:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8F9956B007B for ; Wed, 18 May 2022 03:49:27 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6E58B280 for ; Wed, 18 May 2022 07:49:27 +0000 (UTC) X-FDA: 79478088774.23.83A1CA4 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by imf08.hostedemail.com (Postfix) with ESMTP id 488A51600BE for ; Wed, 18 May 2022 07:49:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1652860166; x=1684396166; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=2p+D/WdtUzo7ZNUrDbOnD9yJq+2AeopkckDysa1nz80=; b=tQCfcPvOz6bnrV7muXGxEVPBWt6WJvrrfLTOEre3u2lkQ8TkOCcAx2t7 XiPj5NJhPPDSdAuaysQOrwJlpYhFBcyE6zrOytBeO5iUKxnCE400PPXo/ yNShTkQSMcSyekk99XrTz2cqTZQFozC8BfhqwJiwcvL9mT0Qeq/09ywMk 0=; Received: from unknown (HELO ironmsg01-sd.qualcomm.com) ([10.53.140.141]) by alexa-out-sd-02.qualcomm.com with ESMTP; 18 May 2022 00:49:25 -0700 X-QCInternal: smtphost Received: from unknown (HELO nasanex01a.na.qualcomm.com) ([10.52.223.231]) by ironmsg01-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2022 00:49:25 -0700 Received: from blr-ubuntu-185.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 18 May 2022 00:49:17 -0700 From: Vivek Kumar To: , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , Vivek Kumar , Prasanna Kumar Subject: [RFC 3/6] block: gendisk: Add a new genhd capability flag Date: Wed, 18 May 2022 13:18:38 +0530 Message-ID: <1652860121-24092-4-git-send-email-quic_vivekuma@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1652860121-24092-1-git-send-email-quic_vivekuma@quicinc.com> References: <1652860121-24092-1-git-send-email-quic_vivekuma@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01a.na.qualcomm.com (10.52.223.231) X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 488A51600BE X-Stat-Signature: 3jhcenz4wuu1qkkg1j1hdgeeciadu4om X-Rspam-User: Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcdkim header.b=tQCfcPvO; spf=pass (imf08.hostedemail.com: domain of quic_vivekuma@quicinc.com designates 199.106.114.39 as permitted sender) smtp.mailfrom=quic_vivekuma@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com X-HE-Tag: 1652860149-404235 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: Add a new genhd capability flag to serialize offsets for swap partition. This flag is enabled for the gendisk of the block device which will be used for saving the snapshot of the hibernation image, based on a kernel parameter "noswap_randomize". Serializing offset in swap partition helps in improving hibernation resume time from bootloader. Signed-off-by: Vivek Kumar Signed-off-by: Prasanna Kumar --- include/linux/blkdev.h | 1 + kernel/power/swap.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 1b24c1f..be094e7 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -92,6 +92,7 @@ enum { GENHD_FL_REMOVABLE = 1 << 0, GENHD_FL_HIDDEN = 1 << 1, GENHD_FL_NO_PART = 1 << 2, + GENHD_FL_NO_RANDOMIZE = 1 << 3, }; enum { diff --git a/kernel/power/swap.c b/kernel/power/swap.c index 8d5c811..0a40eda 100644 --- a/kernel/power/swap.c +++ b/kernel/power/swap.c @@ -1526,6 +1526,9 @@ int swsusp_check(void) FMODE_READ | FMODE_EXCL, &holder); if (!IS_ERR(hib_resume_bdev)) { set_blocksize(hib_resume_bdev, PAGE_SIZE); + if (noswap_randomize) + hib_resume_bdev->bd_disk->flags |= + GENHD_FL_NO_RANDOMIZE; clear_page(swsusp_header); error = hib_submit_io(REQ_OP_READ, 0, swsusp_resume_block,