<div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 12, 2018 at 8:56 PM, Jan Stancek <span dir="ltr"><<a href="mailto:jstancek@redhat.com" target="_blank">jstancek@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5"><br>
----- Original Message -----<br>
> Testcase include swapon(8) fails on mainline kernel-v4.17+ as:<br>
> swapon01 1 TFAIL : swapon01.c:47: Failed to turn on swapfile:<br>
> TEST_ERRNO=EINVAL(22): Invalid argument<br>
> swapon02 4 TFAIL : swapon02.c:91: swapon(2) failed to produce<br>
> expected error: 16, errno: EBUSY and got 22.<br>
> swapon03 1 TFAIL : swapon03.c:243: Failed to setup swaps<br>
> swapoff01 1 TBROK : swapoff01.c:64: Failed to turn on the swap file,<br>
> skipping test iteration<br>
> <br>
> And dmesg shows that:<br>
> [ 128.698981] swapon: file is not committed<br>
> <br>
> The error located in IOMAP_F_DIRTY(linux/fs/iomap.<wbr>c) checking, which means<br>
> this swapfile have uncommitted metadata in caches. After adding sync() to<br>
> the end of all mkswap opertaion, these errors were gone.<br>
> <br>
> linux/fs/iomap.c:<br>
> static loff_t iomap_swapfile_activate_actor(<br>
> struct inode *inode,<br>
> loff_t pos,<br>
> loff_t count,<br>
> void *data,<br>
> struct iomap *iomap)<br>
> {<br>
> struct iomap_swapfile_info *isi = data;<br>
> int error;<br>
> ...<br>
> <br>
> /* No uncommitted metadata or shared blocks. */<br>
> if (iomap->flags & IOMAP_F_DIRTY) {<br>
> pr_err("swapon: file is not committed\n");<br>
> return -EINVAL;<br>
> }<br>
> ...<br>
> }<br>
> }<br>
> Signed-off-by: Li Wang <<a href="mailto:liwang@redhat.com">liwang@redhat.com</a>><br>
> ---<br>
> <br>
> Notes:<br>
> The new changes about swapfile activation function were merged in<br>
> kernel-4.17<br>
> recently, so we didn't hit this failures before.<br>
<br>
</div></div>Comment/code in mkswap, that has been present for years:<br>
/*<br>
* A subsequent swapon() will fail if the signature<br>
* is not actually on disk. (This is a kernel bug.)<br>
* The fsync() in close_fd() will take care of writing.<br>
*/<br>
<br>
I'm assuming your mkswap is recent enough. Any idea why fsync()<br>
in mkswap is no longer enough?<br></blockquote><div><br><br><div class="gmail_default" style="font-size:small">Good catch, Jan. It sounds like a mkswap/fsync issue.<br><br>Both of my mkswap failed to sync that, let me re-check it later.<br><br># rpm -qf /usr/sbin/mkswap<br>util-linux-2.23.2-43.el7.x86_64<br><br># rpm -qf /usr/sbin/mkswap <br>util-linux-2.23.2-52.el7.x86_64<br><br></div><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Regards,<br>
Jan<br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br>
> <br>
> testcases/kernel/syscalls/<wbr>swapoff/swapoff01.c | 2 ++<br>
> testcases/kernel/syscalls/<wbr>swapoff/swapoff02.c | 2 ++<br>
> testcases/kernel/syscalls/<wbr>swapon/libswapon.c | 2 ++<br>
> 3 files changed, 6 insertions(+)<br>
> <br>
> diff --git a/testcases/kernel/syscalls/<wbr>swapoff/swapoff01.c<br>
> b/testcases/kernel/syscalls/<wbr>swapoff/swapoff01.c<br>
> index a63e661..b587b0d 100644<br>
> --- a/testcases/kernel/syscalls/<wbr>swapoff/swapoff01.c<br>
> +++ b/testcases/kernel/syscalls/<wbr>swapoff/swapoff01.c<br>
> @@ -105,6 +105,8 @@ static void setup(void)<br>
> <br>
> if (system("mkswap swapfile01 > tmpfile 2>&1") != 0)<br>
> tst_brkm(TBROK, cleanup, "Failed to make swapfile");<br>
> +<br>
> + sync();<br>
> }<br>
> <br>
> static void cleanup(void)<br>
> diff --git a/testcases/kernel/syscalls/<wbr>swapoff/swapoff02.c<br>
> b/testcases/kernel/syscalls/<wbr>swapoff/swapoff02.c<br>
> index b5c6312..d8c5889 100644<br>
> --- a/testcases/kernel/syscalls/<wbr>swapoff/swapoff02.c<br>
> +++ b/testcases/kernel/syscalls/<wbr>swapoff/swapoff02.c<br>
> @@ -154,6 +154,8 @@ static void setup(void)<br>
> <br>
> if (tst_fill_file("./swapfile01", 0x00, 1024, 1))<br>
> tst_brkm(TBROK, cleanup, "Failed to create swapfile");<br>
> +<br>
> + sync();<br>
> }<br>
> <br>
> static void cleanup(void)<br>
> diff --git a/testcases/kernel/syscalls/<wbr>swapon/libswapon.c<br>
> b/testcases/kernel/syscalls/<wbr>swapon/libswapon.c<br>
> index cf6a988..49fa5ed 100644<br>
> --- a/testcases/kernel/syscalls/<wbr>swapon/libswapon.c<br>
> +++ b/testcases/kernel/syscalls/<wbr>swapon/libswapon.c<br>
> @@ -46,4 +46,6 @@ void make_swapfile(void (cleanup)(void), const char<br>
> *swapfile)<br>
> argv[2] = NULL;<br>
> <br>
> tst_run_cmd(cleanup, argv, "/dev/null", "/dev/null", 0);<br>
> +<br>
> + sync();<br>
> }<br>
> --<br>
> 1.9.3<br>
> <br>
> <br>
> --<br>
> Mailing list info: <a href="https://lists.linux.it/listinfo/ltp" rel="noreferrer" target="_blank">https://lists.linux.it/<wbr>listinfo/ltp</a><br>
> <br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div>
</div></div>