Re: [PATCH] ext4: fix decoding of raw_inode timestamps

From: Jeff Layton
Date: Thu Jul 13 2023 - 06:48:25 EST


On Wed, 2023-07-12 at 17:25 -0400, Theodore Ts'o wrote:
> On Wed, Jul 12, 2023 at 02:09:59PM -0400, Jeff Layton wrote:
> >
> > No, I haven't. I'm running fstests on it now. Is there a quickstart for
> > running those tests?
>
> At the top level kernel sources:
>
> ./tools/testing/kunit/kunit.py run --kunitconfig ./fs/ext4/.kunitconfig
>
> You should get:
>
> [17:23:09] Starting KUnit Kernel (1/1)...
> [17:23:09] ============================================================
> [17:23:09] =============== ext4_inode_test (1 subtest) ================
> [17:23:09] ============= inode_test_xtimestamp_decoding ==============
> [17:23:09] [PASSED] 1901-12-13 Lower bound of 32bit < 0 timestamp, no extra bits
> [17:23:09] [PASSED] 1969-12-31 Upper bound of 32bit < 0 timestamp, no extra bits
> [17:23:09] [PASSED] 1970-01-01 Lower bound of 32bit >=0 timestamp, no extra bits
> [17:23:09] [PASSED] 2038-01-19 Upper bound of 32bit >=0 timestamp, no extra bits
> [17:23:09] [PASSED] 2038-01-19 Lower bound of 32bit <0 timestamp, lo extra sec bit on
> [17:23:09] [PASSED] 2106-02-07 Upper bound of 32bit <0 timestamp, lo extra sec bit on
> [17:23:09] [PASSED] 2106-02-07 Lower bound of 32bit >=0 timestamp, lo extra sec bit on
> [17:23:09] [PASSED] 2174-02-25 Upper bound of 32bit >=0 timestamp, lo extra sec bit on
> [17:23:09] [PASSED] 2174-02-25 Lower bound of 32bit <0 timestamp, hi extra sec bit on
> [17:23:09] [PASSED] 2242-03-16 Upper bound of 32bit <0 timestamp, hi extra sec bit on
> [17:23:09] [PASSED] 2242-03-16 Lower bound of 32bit >=0 timestamp, hi extra sec bit on
> [17:23:09] [PASSED] 2310-04-04 Upper bound of 32bit >=0 timestamp, hi extra sec bit on
> [17:23:09] [PASSED] 2310-04-04 Upper bound of 32bit>=0 timestamp, hi extra sec bit 1. 1 ns
> [17:23:09] [PASSED] 2378-04-22 Lower bound of 32bit>= timestamp. Extra sec bits 1. Max ns
> [17:23:09] [PASSED] 2378-04-22 Lower bound of 32bit >=0 timestamp. All extra sec bits on
> [17:23:09] [PASSED] 2446-05-10 Upper bound of 32bit >=0 timestamp. All extra sec bits on
> [17:23:09] ========= [PASSED] inode_test_xtimestamp_decoding ==========
> [17:23:09] ================= [PASSED] ext4_inode_test =================
> [17:23:09] ============================================================
> [17:23:09] Testing complete. Ran 16 tests: passed: 16
> [17:23:09] Elapsed time: 1.943s total, 0.001s configuring, 1.777s building, 0.123s running
>
> - Ted

Thanks Ted,

The above output is what I get with the fix in place. Without this
patch, I get:

$ make ARCH=um O=.kunit --jobs=16
[06:46:35] Starting KUnit Kernel (1/1)...
[06:46:35] ============================================================
[06:46:35] =============== ext4_inode_test (1 subtest) ================
[06:46:35] ============= inode_test_xtimestamp_decoding ==============
[06:46:35] # inode_test_xtimestamp_decoding: EXPECTATION FAILED at fs/ext4/inode-test.c:252
[06:46:35] Expected test_param->expected.tv_sec == timestamp.tv_sec, but
[06:46:35] test_param->expected.tv_sec == -2147483648 (0xffffffff80000000)
[06:46:35] timestamp.tv_sec == 2147483648 (0x80000000)
[06:46:35] 1901-12-13 Lower bound of 32bit < 0 timestamp, no extra bits: msb:1 lower_bound:1 extra_bits: 0
[06:46:35] [FAILED] 1901-12-13 Lower bound of 32bit < 0 timestamp, no extra bits
[06:46:35] # inode_test_xtimestamp_decoding: EXPECTATION FAILED at fs/ext4/inode-test.c:252
[06:46:35] Expected test_param->expected.tv_sec == timestamp.tv_sec, but
[06:46:35] test_param->expected.tv_sec == -1 (0xffffffffffffffff)
[06:46:35] timestamp.tv_sec == 4294967295 (0xffffffff)
[06:46:35] 1969-12-31 Upper bound of 32bit < 0 timestamp, no extra bits: msb:1 lower_bound:0 extra_bits: 0
[06:46:35] [FAILED] 1969-12-31 Upper bound of 32bit < 0 timestamp, no extra bits
[06:46:35] [FAILED] 1970-01-01 Lower bound of 32bit >=0 timestamp, no extra bits
[06:46:35] [FAILED] 2038-01-19 Upper bound of 32bit >=0 timestamp, no extra bits
[06:46:35] # inode_test_xtimestamp_decoding: EXPECTATION FAILED at fs/ext4/inode-test.c:252
[06:46:35] Expected test_param->expected.tv_sec == timestamp.tv_sec, but
[06:46:35] test_param->expected.tv_sec == 2147483648 (0x80000000)
[06:46:35] timestamp.tv_sec == 6442450944 (0x180000000)
[06:46:35] 2038-01-19 Lower bound of 32bit <0 timestamp, lo extra sec bit on: msb:1 lower_bound:1 extra_bits: 1
[06:46:35] [FAILED] 2038-01-19 Lower bound of 32bit <0 timestamp, lo extra sec bit on
[06:46:35] # inode_test_xtimestamp_decoding: EXPECTATION FAILED at fs/ext4/inode-test.c:252
[06:46:35] Expected test_param->expected.tv_sec == timestamp.tv_sec, but
[06:46:35] test_param->expected.tv_sec == 4294967295 (0xffffffff)
[06:46:35] timestamp.tv_sec == 8589934591 (0x1ffffffff)
[06:46:35] 2106-02-07 Upper bound of 32bit <0 timestamp, lo extra sec bit on: msb:1 lower_bound:0 extra_bits: 1
[06:46:35] [FAILED] 2106-02-07 Upper bound of 32bit <0 timestamp, lo extra sec bit on
[06:46:35] [FAILED] 2106-02-07 Lower bound of 32bit >=0 timestamp, lo extra sec bit on
[06:46:35] [FAILED] 2174-02-25 Upper bound of 32bit >=0 timestamp, lo extra sec bit on
[06:46:35] # inode_test_xtimestamp_decoding: EXPECTATION FAILED at fs/ext4/inode-test.c:252
[06:46:35] Expected test_param->expected.tv_sec == timestamp.tv_sec, but
[06:46:35] test_param->expected.tv_sec == 6442450944 (0x180000000)
[06:46:35] timestamp.tv_sec == 10737418240 (0x280000000)
[06:46:35] 2174-02-25 Lower bound of 32bit <0 timestamp, hi extra sec bit on: msb:1 lower_bound:1 extra_bits: 2
[06:46:35] [FAILED] 2174-02-25 Lower bound of 32bit <0 timestamp, hi extra sec bit on
[06:46:35] # inode_test_xtimestamp_decoding: EXPECTATION FAILED at fs/ext4/inode-test.c:252
[06:46:35] Expected test_param->expected.tv_sec == timestamp.tv_sec, but
[06:46:35] test_param->expected.tv_sec == 8589934591 (0x1ffffffff)
[06:46:35] timestamp.tv_sec == 12884901887 (0x2ffffffff)
[06:46:35] 2242-03-16 Upper bound of 32bit <0 timestamp, hi extra sec bit on: msb:1 lower_bound:0 extra_bits: 2
[06:46:35] [FAILED] 2242-03-16 Upper bound of 32bit <0 timestamp, hi extra sec bit on
[06:46:35] [FAILED] 2242-03-16 Lower bound of 32bit >=0 timestamp, hi extra sec bit on
[06:46:35] [FAILED] 2310-04-04 Upper bound of 32bit >=0 timestamp, hi extra sec bit on
[06:46:35] [FAILED] 2310-04-04 Upper bound of 32bit>=0 timestamp, hi extra sec bit 1. 1 ns
[06:46:35] [FAILED] 2378-04-22 Lower bound of 32bit>= timestamp. Extra sec bits 1. Max ns
[06:46:35] [FAILED] 2378-04-22 Lower bound of 32bit >=0 timestamp. All extra sec bits on
[06:46:35] [FAILED] 2446-05-10 Upper bound of 32bit >=0 timestamp. All extra sec bits on
[06:46:35] # inode_test_xtimestamp_decoding: pass:0 fail:16 skip:0 total:16
[06:46:35] ========= [FAILED] inode_test_xtimestamp_decoding ==========
[06:46:35] # Totals: pass:0 fail:16 skip:0 total:16
[06:46:35] ================= [FAILED] ext4_inode_test =================
[06:46:35] ============================================================
[06:46:35] Testing complete. Ran 16 tests: failed: 16
[06:46:35] Elapsed time: 14.549s total, 0.002s configuring, 14.229s building, 0.275s running


Cheers,
--
Jeff Layton <jlayton@xxxxxxxxxx>