linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs: avoid swapon failure by giving a warning first
@ 2021-05-11 21:43 Jaegeuk Kim
  2021-05-12  1:28 ` [f2fs-dev] " Chao Yu
  2021-05-12  4:00 ` [PATCH v2] " Jaegeuk Kim
  0 siblings, 2 replies; 5+ messages in thread
From: Jaegeuk Kim @ 2021-05-11 21:43 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim, kernel test robot

The final solution can be migrating blocks to form a section-aligned file
internally. Meanwhile, let's ask users to do that when preparing the swap
file initially like:
1) create()
2) ioctl(F2FS_IOC_SET_PIN_FILE)
3) fallocate()

Reported-by: kernel test robot <oliver.sang@intel.com>
Fixes: 36e4d95891ed ("f2fs: check if swapfile is section-alligned")
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/data.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 33e56ae84e35..041f2d9ec972 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -3833,9 +3833,13 @@ static int f2fs_is_file_aligned(struct inode *inode)
 
 		if ((pblock - main_blkaddr) & (blocks_per_sec - 1) ||
 			nr_pblocks & (blocks_per_sec - 1)) {
-			f2fs_err(sbi, "Swapfile does not align to section");
-			ret = -EINVAL;
-			goto out;
+			if (f2fs_is_pinned_file(inode)) {
+				f2fs_err(sbi, "Swapfile does not align to section");
+				ret = -EINVAL;
+				goto out;
+			}
+			f2fs_warn(sbi, "Swapfile does not align to section: \n"
+				"\t1) creat(), 2) ioctl(F2FS_IOC_SET_PIN_FILE), 3) fallocate()");
 		}
 
 		cur_lblock += nr_pblocks;
-- 
2.31.1.607.g51e8a6a459-goog


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-12 10:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11 21:43 [PATCH] f2fs: avoid swapon failure by giving a warning first Jaegeuk Kim
2021-05-12  1:28 ` [f2fs-dev] " Chao Yu
2021-05-12  3:10   ` Chao Yu
2021-05-12  4:00 ` [PATCH v2] " Jaegeuk Kim
2021-05-12 10:13   ` [f2fs-dev] " Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).