Commit Graph

22 Commits

Author SHA1 Message Date
Paul Lawrence
4cd58cdda0 ANDROID: Incremental fs: Set credentials before reading/writing
Use same selinux scheme as incfs v2
Fix memory leak.

Bug: 174692664
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I6058ddad9d43ba01b2eabd7d3c576f2cc9b42292
Git-commit: d3b8915e6f
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2021-06-30 12:11:41 -07:00
Paul Lawrence
db0a5eca91 ANDROID: Incremental fs: Fix four error-path bugs
Test: incfs_test passes
Bug: 158242405
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ib53e867fb2681489f720f6255354c1bce1d33997
(cherry picked from commit 60bc6eaf985358638af7f0602a7aece907ae8207)
Git-commit: 484c5f495628bd4e22a2c7dd08d2cb43d70606c3
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2020-06-28 10:16:27 -07:00
Paul Lawrence
31ee9d8fb7 ANDROID: Incremental fs: Cache successful hash calculations
Bug: 155996534
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ic508e6fa07c90decb29e07647dd3b0fc4d243ce8
(cherry picked from commit 21e6d932da379416bab8ea8d78f14525e7bf564d)
Git-commit: 3585748a58362588795792778878c2f6e340d670
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2020-06-28 10:16:26 -07:00
Paul Lawrence
5409507f89 Revert "ANDROID: Incremental fs: Avoid continually recalculating hashes"
This reverts commit ab185e45f637ba0b0239268f1130890c8837981d.

This change used the PageChecked flag to mark the Merkle tree as
checked. However, f2fs uses this internally. This caused file system
hangs on devices after installs.

Test: incfs_test passes, installs no longer hang
Bug: 157589629
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I980a700d65eb4f4a77434715d61dda4b8e80658c
Git-commit: e2ca3e718475d1c9f5f33bfe00b85c85d92a141b
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2020-06-28 10:16:26 -07:00
Yurii Zubrytskyi
9e7d58e0a8 ANDROID: Incremental fs: wake up log pollers less often
Waking up the waiters accounts for 80+% of the total logging
time, and about 40% of overall read_single_page() with no
signature verification. By throttling it to once every 16ms
we get back all read performance, reduce the waiter's CPU
usage and still leave it enough time to pull the logs out.

Bug: 155996534
Test: adb install megacity.apk & dd from the installed apk

Signed-off-by: Yurii Zubrytskyi <zyy@google.com>
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I4a118dc226d7ca318cf099ba3e239f0120bb23c2
Git-commit: 66e2580207
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2020-06-28 10:16:26 -07:00
Paul Lawrence
c368bec884 ANDROID: Incremental fs: Avoid continually recalculating hashes
With a verified file (use incfs_perf to create a verified file), throughput
measured using dd after dropping caches increases from 200M/s to 290M/s

Test: incfs_test passes
Bug: 155996534
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I7abb5ad92e4167f82f3452acc9db322fec8307dd
Git-commit: adb33b84e3
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2020-06-28 10:16:25 -07:00
Paul Lawrence
3f85b643be ANDROID: Incremental fs: Use simple compression in log buffer
Bug: 154342202
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ibcc641dd92596018c9f10b5bc7bd0db2642a80c7
(cherry picked from commit b6b4a3a404ccd9c62347e27c4fc7883d776c2cbb)
Git-commit: 9d7386aae2
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2020-06-28 10:16:24 -07:00
Paul Lawrence
67b3fcb242 ANDROID: Incremental fs: Fix compound page usercopy crash
Bug: 153560805
Test: incfs_test passes on qemu and Pixel 4
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I1b55341e4e4247a74f3f539b9d190fef0ca409b8
Git-commit: 580b23c95a
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2020-06-28 10:16:23 -07:00
Yurii Zubrytskyi
46c1f3f598 ANDROID: Incremental fs: make remount log buffer change atomic
Read log buffer can have multiple threads doing any of these
operations simultaneously:
- Polling for changes
- Reading log records
- Adding new log records
- Updating log buffer size, or enabling/disabling it completely

As we don't control the userspace, and it turns out that they
all currently originate from different processes, code needs to
be safe against parallel access to a read buffer and a request
for reallocating it.

This CL add an r/w spinlock to protect the buffer and its size.
Each remount takes the write lock, while everything else takes
a read lock. Remount makes sure it doesn't take too long by
preallocating and precalculating all updates, while other
operations don't care much about their critical section size -
they all can still run together.

Bug: 152633648
Test: manual remount + reading
Signed-off-by: Yurii Zubrytskyi <zyy@google.com>
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I7271b4cb89f1ae2cbee6e5b073758f344c4ba66a
Git-commit: 5e6feacb2a
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2020-06-28 10:16:23 -07:00
Paul Lawrence
aae486b462 ANDROID: Incremental fs: Optimize get_filled_block
This led to a 20x speed improvement on QEMU. 512 is somewhat
arbitrary - most of the gains are already there reading 64 records
at a time, but since the record size is 10 bytes, 512 is just over
a page and seems a good choice.

Bug: 153170997
Test: incfs_test passes. Adding logging to incfs_get_filled_blocks
	to measure performance shows a 20x improvement
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ifb2da77cfd8c9d653c7047ba1eb7f39d795fa1c2
Git-commit: 5128381d88
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2020-06-28 10:16:22 -07:00
Paul Lawrence
5663542e52 ANDROID: Incremental fs: Fix mislabeled __user ptrs
Found by sparse

Bug: 153174547
Test: make C=2 fs/incfs/incrementalfs.ko no errors, incfs_test pass
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I9ff4f4f35975fe09936724488b96cd8bdeeb719e
Git-commit: 23f5b7c508
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2020-06-28 10:16:22 -07:00
Paul Lawrence
fce326fdbb ANDROID: Incremental fs: Fix remount
Bug: 153017385
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I13f3a3c91d746d725e0e21b1e2bcfe0a64a13716
Git-commit: ae41ea981b
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2020-06-28 10:16:21 -07:00
Paul Lawrence
4117130bf9 ANDROID: Incremental fs: Protect get_fill_block, and add a field
Since INCFS_IOC_GET_FILLED_BLOCKS potentially leaks information about usage
patterns, and is only useful to someone filling the file, best protect it in
the same way as INCFS_IOC_FILL_BLOCKS.

Add useful field data_block_out as well

Test: incfs_test passes
Bug: 152983639
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I126a8cf711e56592479093e9aadbfd0e7f700752
Git-commit: e251cfe620
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2020-06-28 10:16:21 -07:00
Paul Lawrence
0bc5d8c16e ANDROID: Incremental fs: Fix crash polling 0 size read_log
When read log is 0 sized, we still need to init the wait queue to avoid
kernel panics if someone does decide to poll on the read log.

Test: Added test for this condition, incfs_test crashes
	With fix, incfs_test doesn't crash
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Bug: 152909243
Change-Id: Ic3250523bb7ddb1839f8e95852c17103e5ffb782
Git-commit: 759d52ee9e
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2020-06-28 10:16:21 -07:00
Yurii Zubrytskyi
cbad8026de ANDROID: Incremental fs: get_filled_blocks: better index_out
When returning incomplete results index_out has to be usable to
call the function again and resume from the same location. This
means that if the output buffer was too small the function needs
to check for that when encountering the _beginning_ of a next
output range, not the end of it. Otherwise resuming from the
end of the range that didn't fit into the buffer would cause
the call to never return that range

+ Make the backing file header flags update thread safe

Bug: 152691988
Test: libincfs-test, incfs_test passes
Signed-off-by: Yurii Zubrytskyi <zyy@google.com>
Change-Id: I351156beba0b74e1942a39117279d3fcdb5e0c78
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Git-commit: 21b6d8c954
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2020-06-28 10:16:20 -07:00
Paul Lawrence
c38495f0d8 ANDROID: Incremental fs: Add INCFS_IOC_GET_FILLED_BLOCKS
Test: incfs_test passes
Bug: 151240628
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I66d0ba1911adc5d68ed404585222e6a81a7eb94f
(cherry picked from commit 8d963bb24076b60cb2de0f2d49deaff1d52e8270)
Git-commit: 05cf04f60a
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2020-06-28 10:16:20 -07:00
Paul Lawrence
27681b2b59 ANDROID: Incremental fs: Fix two typos
Test: incfs_test passes
Bug: 151240628
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I627e683b562329fd57aedc8393e22449ff09ee1f
(cherry picked from commit 06c715e275dc65e720759cfeacb4120289e2a306)
Git-commit: f2e257e60e
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2020-06-28 10:16:20 -07:00
Paul Lawrence
183696eacf ANDROID: Incremental fs: Remove signature checks from kernel
Test: selftests pass
Bug: 133435829
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ia7e69b1b0176202da4b418ea815b370cbdacd5c2
Git-commit: 73e7d65693
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2020-06-28 10:16:19 -07:00
Paul Lawrence
6659adcabb ANDROID: Incremental fs: Make fill block an ioctl
Filling blocks is not equivalent to writing a file, since they are
constrained by the root hash. selinux policy may wish to treat them
differently, for instance.

Test: incfs_test passes
Bug: 138149732
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ic369b84b92547b1cfefe422bd881c4e466090aed
Git-commit: 70539f7cfd
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2020-06-28 10:16:18 -07:00
Paul Lawrence
b50d9aa3f3 ANDROID: Incremental fs: Support xattrs
To make selinux work, add xattr support. This is a bit clunky -
it seems like it would be better for the log and pending read
functionality to be ioctls rather than this mixture of real
and virtual files.

Bug: 133435829
Change-Id: I56579fabe2ae7efb88f0344553948dc9573299aa
Signed-off-by: Paul Lawrence <paullawrence@google.com>
2020-02-20 15:28:48 +00:00
Paul Lawrence
13ef21876f ANDROID: Fixing incremental fs style issues
Removed WARN_ONs
Removed compatibilty code
Fixed tab issue

Bug: 133435829
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I8a9e9ead48a65fd09c2d01d22f65d9a352f118e2
2020-01-30 11:25:57 -08:00
Eugene Zemtsov
040942fc50 ANDROID: Initial commit of Incremental FS
Fully working incremental fs filesystem

Signed-off-by: Eugene Zemtsov <ezemtsov@google.com>
Signed-off-by: Paul Lawrence <paullawrence@google.com>

Bug: 133435829
Change-Id: I14741a61ce7891a0f9054e70f026917712cbef78
2020-01-30 11:25:11 -08:00