Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp520005lqp; Wed, 22 May 2024 11:03:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUbGWesRd1uzFum38qQJYTvJut5dqi5GZYnQdo2fNi9wa5OnTXSb3Qm2FALy58kGpOBI2KcK5oNr5LdfdhhEp7UWeAfAMSzfL/jO+0jig== X-Google-Smtp-Source: AGHT+IEghrcfcyK+RIyRN/Gw5y69JQYlkLcnijuif3QtpEVWC4r+HCd9fO2MXwwflw8Qrobw8TgK X-Received: by 2002:a17:906:4a19:b0:a5d:1bbf:a960 with SMTP id a640c23a62f3a-a622807ab96mr212228166b.7.1716401007377; Wed, 22 May 2024 11:03:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716401007; cv=pass; d=google.com; s=arc-20160816; b=b5lUVkXEV1728KzIFtKqihStA1RLvGR6fv/KA5uQlgpQL4K9+c/2IzEpXdFLdOrPBn Jluc6eLb85qw84a6/9VzQoO+qdTF1Wm5KSViUxFooy4xqYYQYSWONqsjSJDlth2lHKid N2fDwZ8MEJitgyJiRem0kxvsTVOnfH1tifZpoW25AlUH9W+ox9VNqUYl3Cx27Ea8t2ht mX0ikVQis6LDjDFuULUpVIWbfmQkGH6psDqcI6iYKB+dkE4BLBIbetplXgKeB8r0PiUj MfhqIL3UQ53iSLtvB5Rpa7e0ZQ48PxMJ5JkydsuUOqPb+7z+dBQYuM6HOo7fm94g7nwl 0izw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=ltYsw3lTPaEfoY1IUhj66QjerZ2O7/nbPGruabs3hr4=; fh=iOHP0j4WcVoGgm/kdUjTGTDXbiSjnZfE8Q7MSHQckKQ=; b=m6JdrRZ2wyv4R7sjHwMAAusPh0mSqNyPokpb4NK4dSeaRl2DW9JF20Vb2NSlv5vqSa MJaGKTtqXHyOtNOyJI3uxOX+a+KdYyvPdkIQyOO1yhBF1Qkld3xqe6hC5S0GHGMXkoH+ AnwUzt6H4yyg3SqQmDaMuCMibQs3CpHT4XoZzNdIEHvEDVzjU7J39JOBf5lLSEg3az9O 1vhMuscV4q1umvozfEMukrWy5M/UgAZm0pmC6MXb6MzsiiGZFQgqHtbghKqWAgqrMiYX 0FgCzH0w5cicTIqRrNqNMI+A5Hs/iHbs3DfJmfwdePlN+KsTojrudGhIwxUfsdbNx+1j VXdg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eqnG3Bur; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-186585-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186585-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5d0367d8f6si681590666b.456.2024.05.22.11.03.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 11:03:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186585-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eqnG3Bur; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-186585-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186585-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 148281F22D2C for ; Wed, 22 May 2024 18:03:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B380145B2C; Wed, 22 May 2024 18:03:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eqnG3Bur" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 631FF182B9; Wed, 22 May 2024 18:03:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716400993; cv=none; b=DrByRj+AZIfFSSUuWMBU00OO1QxOrVpash5YWPiY9ni9ifVctxuVEz+YO9ZMA4YC92WjEDhUPrcbyhm6huph9yyHHt1a2cteUwbk9qADCfYvMBJfh4XFBMtr2BMP+oZnZoCIgYOGhvhn8WXeZhw5JXPtfaBvP/lPzGNx93VzoB8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716400993; c=relaxed/simple; bh=EgqUgI0H7TNae0QKJUbfzzMgFbTC81vHTSiEYGcj1Kc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=T3p1Df0swB4XkKeUOI8KMG7sDgB2WyNY9In7TbfSeBpyDwA/7HmV3RaJ1T+TI4Ev036UQRM6RYR1NprHzEfUhF6AjBo2PrUJ6JD7hA4DlZbqWgsg+DFGwzez1cJO/4grO0EggZoCOCIam0tnMN5PO0dHbt/kHxsDzn82oFi74E8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eqnG3Bur; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F17E8C4AF09; Wed, 22 May 2024 18:03:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716400993; bh=EgqUgI0H7TNae0QKJUbfzzMgFbTC81vHTSiEYGcj1Kc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=eqnG3BurugA8eP+sBdeowbE+tTl1ziDioTAU76vCtcnMRell+SQ6FCr0wmO56ZbyF 04BXP1XMFrNHmKIrorHpFHirI7Y8+eTSXKUpfM+ivhMr6ZIVSJMxan9pJ33UMWwLuz pRMurL9vRHaVw4lvUASCjD/KLQALbHF42X8Z4NWprQpZTuvBuTO9DY0fSST7idEF7S c7PSRjLHs/w4uOsQK2ImVFG1o1D0g9RrmSYjK3tdmYnnifuFPrTXidirpg4HI8syja TRAFUi8ts/h3esYVg+R10zYSnYf1TqAHyf4hfdgyoZszcPzTHfuk/WLvKXBx80xtwj 1lW5FYanDiNcA== Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2e1fa824504so65411741fa.0; Wed, 22 May 2024 11:03:12 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCX5syn8iZtyEwb+Ocr0CIqpotitMw+84IR1sLoV01S1mPzwoMUnhqdidQiCH9Kjf5XgXJ9fq2XT+ns4Z2JknPSkq1Wx9xR8L5DPQQIZcG0leOBfntPpxPx0LG9iqVVQ9mTMCX5KfO3Xhib1/2xK0QuWfz8yvscRzVUc0O9oe3XcpthkF5isvq4IF4ReblQgnuMHzU8C9KW4KDfrQ3XZaEGY X-Gm-Message-State: AOJu0YyijETD19m/3iL/jJ4Xl71X/WnpPxluAV5FWi8s4ZZX5FfmNPfA 0FZKxzvIH9uXaxqiXiYasuwyVaxQrpebRMw0/KLPXwS808UhtMphYpfcERSN3q5PXLyxbNQRew6 YxB3yguRZn4/KVraKmml/ANvLvg== X-Received: by 2002:a19:9143:0:b0:51d:1830:8380 with SMTP id 2adb3069b0e04-526bebb4d43mr1337039e87.8.1716400991593; Wed, 22 May 2024 11:03:11 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240522074658.2420468-1-Sukrit.Bhatnagar@sony.com> <20240522074658.2420468-2-Sukrit.Bhatnagar@sony.com> In-Reply-To: <20240522074658.2420468-2-Sukrit.Bhatnagar@sony.com> From: Chris Li Date: Wed, 22 May 2024 11:02:59 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] iomap: swap: print warning for unaligned swapfile To: Sukrit Bhatnagar Cc: "Rafael J. Wysocki" , Pavel Machek , Christian Brauner , "Darrick J. Wong" , Andrew Morton , linux-xfs@vger.kernel.org, linux-pm@vger.kernel.org, linux-fsdevel , linux-kernel , linux-mm Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Sukrit, It seems that you need the swap file block start address to read the swap file headers. This warning still requires the user to read the dmesg. The kernel still does not have the swapfile header at resume. In other words, it does not fix the issue. I don't know the suspend/resume code enough, will adding recording the physical start address of the swapfile in swap_info_struct help you address this problem? The suspend code can write that value to "somewhere* for resume to pick it up. Let's find a proper way to fix this issue rather than just warning on it. Chris On Wed, May 22, 2024 at 12:42=E2=80=AFAM Sukrit Bhatnagar wrote: > > 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_swap= file_info *isi) > next_ppage =3D 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-aligne= d\n"); > +#endif > /* Skip too-short physical extents. */ > if (first_ppage >=3D next_ppage) > return 0; > -- > 2.34.1 > >