Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp182841lqp; Wed, 22 May 2024 00:54:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXGf5mBhO8SrWt9Fzv36NWeh166CCaFV0bDYStRWaEUckLGBmutssznob9va23kRfdKl6nQwbj1Ao3s9wSalBOXAIw6GaleJ74JjrIz6w== X-Google-Smtp-Source: AGHT+IGGHoB+3wZybKo4MVG2KmJL17O5FJsz7bYMWbuGURyfYW+TMdclU70T+gdmxFNjGEG7GJL4 X-Received: by 2002:a17:902:ea0b:b0:1f2:fb89:1d3e with SMTP id d9443c01a7336-1f31c94eef9mr13387125ad.7.1716364457343; Wed, 22 May 2024 00:54:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716364457; cv=pass; d=google.com; s=arc-20160816; b=zhYPk3+14nMLmGVINOQHIYUam169nWgbLzgqUeZpPAQO1AEpwOiXCxEbp/PbNd8OE2 KYmD/bla9iHbBKYWCSGS5Re91FDpPzymAljv+UKSITGG3+ZPNW+zZ6UbGslDqvOb/xil XRRwEeKGwUuIW6WINglAVQOhfvs1WuLEfCRGTNba2ROjAXR3oIeqv3RScVDak6zlIWKk 43JWS6Y0lm05JkgbON6/A26q9M/Sy6X+Z50E/euOH5FwsUHC9DA3Z7W1k30mPcFTAYpz tmM/McOwaMkpJkru2mYE08KyAsmDnm3YzqCFE1DEY1Pi6Kicl38O+i3anQUpKlvar1Oi NOyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ATSJTIQ7YlfNHhI2J03NerUHdvI37i6ERHqni1M7vn4=; fh=5/CQjkakIdBXPSjYMrkL5A/mlBcJavF7822SPyatFxE=; b=FXtgRrcDKdbcy5/oyMcHGFvSXNNy/lmnH2bHXicZmk3T2VtZrD+uvp7tXBIDazKbUA IFzKPKNoJ1r0666ZanKXUT+MK6iE/oyDATTPR61kVw1HPTmV45AFWvJlsNbdNPj8LZBi PalLkCa/ho70mrwa0zTuMw4dk5X4kuwtqmAf7xBbpl8YtLFi92bj02K09CgyWhZUJ9LV WQi9YG1v/4hug4qM7qBjuGebi4A2vJAljSV/SlEAs8shlwZW1ZCD/0Vb7AcBr1FJTzEI 6CsCY72SZirfrkDfQsW2y4zNEkV6ii/XPsF7iHOBNha9JiDO8j9nJQxm067dkO49+5cA jIYQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sony.com header.s=s1jp header.b=CmV4swUx; arc=pass (i=1 spf=pass spfdomain=sony.com dkim=pass dkdomain=sony.com dmarc=pass fromdomain=sony.com); spf=pass (google.com: domain of linux-kernel+bounces-185884-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185884-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sony.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f30b223877si31890275ad.130.2024.05.22.00.54.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 00:54:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-185884-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@sony.com header.s=s1jp header.b=CmV4swUx; arc=pass (i=1 spf=pass spfdomain=sony.com dkim=pass dkdomain=sony.com dmarc=pass fromdomain=sony.com); spf=pass (google.com: domain of linux-kernel+bounces-185884-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185884-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sony.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id ECCFA282A92 for ; Wed, 22 May 2024 07:54:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AFE228062E; Wed, 22 May 2024 07:53:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="CmV4swUx" Received: from jpms-ob02.noc.sony.co.jp (jpms-ob02.noc.sony.co.jp [211.125.140.165]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FC5080025; Wed, 22 May 2024 07:53:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.125.140.165 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716364385; cv=none; b=kH2+3v54qm0fDZniCeMJUQvyOcY3w0mKR1r+A0FqkmwQIw314h5gwbplis65lH5ecsg6K/2pudP6dkiDcdwulhOTjRBqc02Udln4pe7GczJLA2TmWd2AMpInWOnzTMKSxkL3kP+6+M6VynjJCRApH4+U0S6OnOpNl0dG5em0S/g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716364385; c=relaxed/simple; bh=u/nje6kivX57y9Efk6JRMSDlSj6Fx4OLxIkreKTXcoY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NA0eexVsfFEmwDl9d2XOixoPK6iSaWmvPeQrzyw4Izotot3p/BnXslMbldeE+fIodQGwKpVw7YwkuZq/0+46EoCM0DRL3X4Gua3YcdAgARmce1oNeOpX8GBtJ073Z02nLli8RM49dh/YqQ/rGhZ1sgDIROybbTyQnXCXJ6NjCoc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com; spf=pass smtp.mailfrom=sony.com; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b=CmV4swUx; arc=none smtp.client-ip=211.125.140.165 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; s=s1jp; t=1716364384; x=1747900384; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ATSJTIQ7YlfNHhI2J03NerUHdvI37i6ERHqni1M7vn4=; b=CmV4swUxDU6eAPw5sx0gh/dW9eZuRbnPUkIcMSPf4vxeaktqcXm2TV3O +fRN8TZz6beWQzjwYsdWwZ0NqsiZKtlqecPjl1Kxx5A4SFrc+/dvZrBxn Fh0AfIbnqSGugxLB1nc5GQxFVxXfxrWvyuQ3sM0rggroSKvRJZP6IVIsH akd0nA1WbIjvNHJpNSwmWwYC/p9Vy7/ygwcfm4qh2M3yzuRdU49Mceioj BfU6Dj8s6ZaKkVJAJYF6CoE+Dlv5tsrpyD3DYT+yhX7Idqh+/jn5azoH9 S8JFvAEYmMU+QC0ZOE2L75k25A+jkpioomUCNVgDVYG0trtK/U2z84Kup A==; Received: from unknown (HELO jpmta-ob1.noc.sony.co.jp) ([IPv6:2001:cf8:0:6e7::6]) by jpms-ob02.noc.sony.co.jp with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2024 16:42:51 +0900 X-IronPort-AV: E=Sophos;i="6.08,179,1712588400"; d="scan'208";a="415026696" Received: from unknown (HELO OptiPlex-7080..) ([IPv6:2001:cf8:1:5f1:0:dddd:6fe5:f4d0]) by jpmta-ob1.noc.sony.co.jp with ESMTP; 22 May 2024 16:42:51 +0900 From: Sukrit Bhatnagar To: "Rafael J. Wysocki" , Pavel Machek , Christian Brauner , "Darrick J. Wong" , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-pm@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sukrit.Bhatnagar@sony.com Subject: [PATCH 1/2] iomap: swap: print warning for unaligned swapfile Date: Wed, 22 May 2024 16:46:57 +0900 Message-Id: <20240522074658.2420468-2-Sukrit.Bhatnagar@sony.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522074658.2420468-1-Sukrit.Bhatnagar@sony.com> References: <20240522074658.2420468-1-Sukrit.Bhatnagar@sony.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When creating a swapfile on a filesystem with block size less than the PAGE_SIZE, there is a possibility that the starting physical block is not page-aligned, which results in rounding up that value before setting it in the first swap extent. But now that the value is rounded up, we have lost the actual offset location of the first physical block. The starting physical block value is needed in hibernation when using a swapfile, i.e., the resume_offset. After we have written the snapshot pages, some values will be set in the swap header which is accessed using that offset location. However, it will not find the swap header if the offset value was rounded up and results in an error. The swapfile offset being unaligned should not fail the swapon activation as the swap extents will always have the alignment. Therefore, just print a warning if an unaligned swapfile is activated when hibernation is enabled. Signed-off-by: Sukrit Bhatnagar --- fs/iomap/swapfile.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/iomap/swapfile.c b/fs/iomap/swapfile.c index 5fc0ac36dee3..1f7b189089dd 100644 --- a/fs/iomap/swapfile.c +++ b/fs/iomap/swapfile.c @@ -49,6 +49,16 @@ static int iomap_swapfile_add_extent(struct iomap_swapfile_info *isi) next_ppage = ALIGN_DOWN(iomap->addr + iomap->length, PAGE_SIZE) >> PAGE_SHIFT; +#ifdef CONFIG_HIBERNATION + /* + * Print a warning if the starting physical block is not aligned + * to PAGE_SIZE (for filesystems using smaller block sizes). + * This will fail the hibernation suspend as we need to read + * the swap header later using the starting block offset. + */ + if (!iomap->offset && iomap->addr & PAGE_MASK) + pr_warn("swapon: starting physical offset not page-aligned\n"); +#endif /* Skip too-short physical extents. */ if (first_ppage >= next_ppage) return 0; -- 2.34.1