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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CD60C25B78 for ; Wed, 22 May 2024 18:03:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D3A576B0089; Wed, 22 May 2024 14:03:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE91D6B008A; Wed, 22 May 2024 14:03:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD7B76B008C; Wed, 22 May 2024 14:03:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A00136B0089 for ; Wed, 22 May 2024 14:03:20 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 47C8AA333F for ; Wed, 22 May 2024 18:03:20 +0000 (UTC) X-FDA: 82146803760.24.335390D Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf16.hostedemail.com (Postfix) with ESMTP id 8C67318002D for ; Wed, 22 May 2024 18:03:17 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HA92OLUi; spf=pass (imf16.hostedemail.com: domain of chrisl@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=chrisl@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716400998; a=rsa-sha256; cv=none; b=y+5bQyiXwKoXwvuXpFKCOY4jrW6GNfjkvbwN27DS1yiKFRYAcVMIXaKYQ9Rc/tCimzDOVz xke7ykMM9kKZn8aq8hh8kwwp2dKhbZnh5UkgZV8SnPecEMmQXCyX4iCTGg0gyUOp6bFvEJ L4q83Y4CFOpfwYimW+LjuyFpWd+wQUM= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HA92OLUi; spf=pass (imf16.hostedemail.com: domain of chrisl@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=chrisl@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716400998; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ltYsw3lTPaEfoY1IUhj66QjerZ2O7/nbPGruabs3hr4=; b=QvXoVdbmsiM8vjB+1WvkyRbYNJxSHZxCG8YDG2RqTDvhAeD7ldwvFf4eur/4TJDzhe9c5g Ghe1iv2vyZasfEaBmBKXsWYB7Ap9s6bEpp1eqXcmjWPNkDhruA/YBVwPZRls6tyRwSgSlR XoLLHR9Yu7se4k2tsWXCMTLenaq0alo= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 13E9BCE1271 for ; Wed, 22 May 2024 18:03:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8CE3C4AF07 for ; 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=1716400992; bh=EgqUgI0H7TNae0QKJUbfzzMgFbTC81vHTSiEYGcj1Kc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=HA92OLUiC9qilFKaiAJ7oiZs3Zc40xq8i1CsV9clcGrRRVghldtMdZqvQmdmeyb+Q gv4k9GfFqZC85NPwz5SzhqTFVyyvmMy49Eu9SnSivVXrunoMSkUm9E1ja5VMSYWitv 1Ipo1lyVEYswmOQuLCC2Gewz0gQ3Kkiy3eO4zYnwxq+kGnmQSrZk26wLk2ZJFRIHB4 odzYs37e8ykmdQ3UlNZ3lAZNb/D/0EgfX+pp9qZKFcCPPhkRsbnOgoR1KZVVjIXhhp stw9c920/QfsTuaO42z3o0fVeEbjyNeqYF5OTWBu9MRUw1CKzdT+MmV6fslv0W2Kzq xM/GPajH7/fcw== Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-51f174e316eso6345740e87.0 for ; Wed, 22 May 2024 11:03:12 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCUktn67Sh9P5bvmm6nDfLzNFm1BqK2rjlciXY/KxtWkQ8yXfZTqw0PIYSmswR0j4KHLWumViw8YF1l+QrklmQS4e+w= X-Gm-Message-State: AOJu0YyE4BfqmBijcGXUzRS8WALSUqVTOSxGSBxDn/zYZjwChqIefXOt vwFyN4zsZwi81HT1MdLR8EJvn++CpNaMkydwdMqJlOgYvga8i+dVgXq5FP7d5t7LwCyuOJ4vVff RMSZgk+5qKsutq7mIgm8jC937Vg== X-Google-Smtp-Source: AGHT+IHwAu69YuO1Nh3RQD2Pvp4YaJq25imcdHx3Dm0uO3K69AKZ/92diCIr1s9eL3l/QWkXG2g3XsBaE4fqA9npTO0= 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) 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 X-Rspamd-Queue-Id: 8C67318002D X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: erya5dibfd7u9bszgkj1gd5sgrotmdds X-HE-Tag: 1716400997-397875 X-HE-Meta: U2FsdGVkX1/0TsklniFfOreoVguEDWM55n3QPdRL8hqgQxK/r5E5XtYmRoD5zjFuYE7Qvi1W3WoYmLpiky5h4PXAbQOwx5kjdvCuyV5OFuy4xmlyCMOM7if/MvSrLYMfDI0W8WajC5GOLj605o9CVlvXmmPGpu/8jhXOtBkS1tVYwAlxOaxLvqoR/4aMJep1IQUoopX0QsaaUj14mkNvrnfR+uNFidmx2MI1/U4uGh3X/m+5NnUKjKtzY2efio8EUYYafHOcwT/+Y90LEOdZ1pMNzDYjm1R001nRZ2xJB/TALfc0zEwpSRTUhnD8PZAyR8HI7dfRUjYQmTlUJJo+ch3yVRe1TaOY5VIWo6kFe7n+6ze4RGALsFhfNN0fXn/ZZXFWKVyowrdosG/et9wjOwc3gx5sfpfX3gUSq5xSTFFo29M77v8AUDwMZCtXf0dXIu0qSHFhsaZ7wGi3Ozgp5HygrTwV0MfCpuJ01AoRtDYx8meszoFyTjjdsevT7AtwSJRWzAVfN5ajT8Z7kgeJhAx5re+vKKVS84SdPceDGpmQRkvglrXk7fMnGZErKp+2YOAJ0tmWXlPceyGFoknip3GOtR5TAsIvwI2moTeSq1p+ztfH+Zwp6zNlDhKOWWgDAbgd5ceLIF5lcAxOWqt3qz5ADvinqzEIVOY+T7r6x/TDJ3CElM+s34XU7BWQmpT/ZZcctiMfQwjZlj4fMCPuCt4CpU/M/eetCCEvyFd4RcWDPgcREt8fW5dSx0qqSPPDRcHV3fS0CIRvbf+sGEmU1VciVf2o+EzYUkmZuzo1eVz1LMvM4BMnjacB2Wz60oYXG4irG4P12hEhdfA8oQw+DjdsMbhX7AOs7NHBf68N5ZjE/klk7VsSCg/6DFBtwzsjbLwFL2oH9zJm2fkh+JpjzXgpRCiLvKFrAw4yqfT6y9iAMfsKLcPqs6mFsob9//5CIS+zi2hDw8gJw/aMm6Z Eovq/2SC tMK1FaQFFFy09GyI+f467+f9Tvdyy5t/jK9KXGHNfeIgJHMd9sXrtcqw3xjmBHflu4Uz+OqwnUngh34OBre3J6ssszR7kRDQYai4mUnej8FE+oGDUkD+V7AYOGc1vKplyY0yzbTFRQDKjEBvVy+MlPZQBIjKpFqM9WBDaUxLq7ey8wrC31z0EbWk2PHf47xFTCTvgrUcNYEnvhlVyWUblA+fJwRIuAhHgS7uE9LJ6Q+Zm+sVfc7EOT8XJV/tjRpJaHPich03YFS4jNCWtxJCXpW4WkA== 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: List-Subscribe: List-Unsubscribe: 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 > >