tree:
https://github.com/zen-kernel/zen-kernel 5.15/zen-sauce
head: 81ba2917231b206b7b6b9b160e456c5452c4f62e
commit: b67c5033547771052515687e96adf98858ea0de6 [5/28] ZEN: Unrestrict
CONFIG_OPTIMIZE_FOR_PERFORMANCE_O3
config: h8300-randconfig-r025-20211114 (attached as .config)
compiler: h8300-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O
~/bin/make.cross
chmod +x ~/bin/make.cross
#
https://github.com/zen-kernel/zen-kernel/commit/b67c5033547771052515687e9...
git remote add zen
https://github.com/zen-kernel/zen-kernel
git fetch --no-tags zen 5.15/zen-sauce
git checkout b67c5033547771052515687e96adf98858ea0de6
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=h8300
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
fs/ntfs3/fslog.c: In function 'last_log_lsn':
> fs/ntfs3/fslog.c:2247:1: warning: the frame size of 1068 bytes is
larger than 1024 bytes [-Wframe-larger-than=]
2247 | }
| ^
--
crypto/nhpoly1305.c: In function 'crypto_nhpoly1305_update':
> crypto/nhpoly1305.c:195:1: warning: the frame size of 1032 bytes
is larger than 1024 bytes [-Wframe-larger-than=]
195 | }
| ^
vim +2247 fs/ntfs3/fslog.c
b46acd6a6a627d Konstantin Komarov 2021-08-13 1595
b46acd6a6a627d Konstantin Komarov 2021-08-13 1596 /*
b46acd6a6a627d Konstantin Komarov 2021-08-13 1597 * last_log_lsn
b46acd6a6a627d Konstantin Komarov 2021-08-13 1598 *
e8b8e97f91b80f Kari Argillander 2021-08-03 1599 * Walks through the log pages for a
file, searching for the
e8b8e97f91b80f Kari Argillander 2021-08-03 1600 * last log page written to the file.
b46acd6a6a627d Konstantin Komarov 2021-08-13 1601 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 1602 static int last_log_lsn(struct
ntfs_log *log)
b46acd6a6a627d Konstantin Komarov 2021-08-13 1603 {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1604 int err;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1605 bool usa_error = false;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1606 bool replace_page = false;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1607 bool reuse_page = log->l_flags
& NTFSLOG_REUSE_TAIL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1608 bool wrapped_file, wrapped;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1609
b46acd6a6a627d Konstantin Komarov 2021-08-13 1610 u32 page_cnt = 1, page_pos = 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1611 u32 page_off = 0, page_off1 = 0,
saved_off = 0;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1612 u32 final_off, second_off,
final_off_prev = 0, second_off_prev = 0;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1613 u32 first_file_off = 0,
second_file_off = 0;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1614 u32 part_io_count = 0;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1615 u32 tails = 0;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1616 u32 this_off, curpage_off,
nextpage_off, remain_pages;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1617
b46acd6a6a627d Konstantin Komarov 2021-08-13 1618 u64 expected_seq, seq_base = 0,
lsn_base = 0;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1619 u64 best_lsn, best_lsn1, best_lsn2;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1620 u64 lsn_cur, lsn1, lsn2;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1621 u64 last_ok_lsn = reuse_page ?
log->last_lsn : 0;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1622
b46acd6a6a627d Konstantin Komarov 2021-08-13 1623 u16 cur_pos, best_page_pos;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1624
b46acd6a6a627d Konstantin Komarov 2021-08-13 1625 struct RECORD_PAGE_HDR *page = NULL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1626 struct RECORD_PAGE_HDR *tst_page =
NULL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1627 struct RECORD_PAGE_HDR *first_tail =
NULL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1628 struct RECORD_PAGE_HDR *second_tail =
NULL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1629 struct RECORD_PAGE_HDR *tail_page =
NULL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1630 struct RECORD_PAGE_HDR
*second_tail_prev = NULL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1631 struct RECORD_PAGE_HDR
*first_tail_prev = NULL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1632 struct RECORD_PAGE_HDR *page_bufs =
NULL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1633 struct RECORD_PAGE_HDR *best_page;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1634
b46acd6a6a627d Konstantin Komarov 2021-08-13 1635 if (log->major_ver >= 2) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1636 final_off = 0x02 *
log->page_size;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1637 second_off = 0x12 *
log->page_size;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1638
b46acd6a6a627d Konstantin Komarov 2021-08-13 1639 // 0x10 == 0x12 - 0x2
195c52bdd5d5ec Kari Argillander 2021-08-24 1640 page_bufs =
kmalloc(log->page_size * 0x10, GFP_NOFS);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1641 if (!page_bufs)
b46acd6a6a627d Konstantin Komarov 2021-08-13 1642 return -ENOMEM;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1643 } else {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1644 second_off = log->first_page -
log->page_size;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1645 final_off = second_off -
log->page_size;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1646 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1647
b46acd6a6a627d Konstantin Komarov 2021-08-13 1648 next_tail:
e8b8e97f91b80f Kari Argillander 2021-08-03 1649 /* Read second tail page (at pos
3/0x12000). */
b46acd6a6a627d Konstantin Komarov 2021-08-13 1650 if (read_log_page(log, second_off,
&second_tail, &usa_error) ||
b46acd6a6a627d Konstantin Komarov 2021-08-13 1651 usa_error ||
second_tail->rhdr.sign != NTFS_RCRD_SIGNATURE) {
195c52bdd5d5ec Kari Argillander 2021-08-24 1652 kfree(second_tail);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1653 second_tail = NULL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1654 second_file_off = 0;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1655 lsn2 = 0;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1656 } else {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1657 second_file_off = hdr_file_off(log,
second_tail);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1658 lsn2 =
le64_to_cpu(second_tail->record_hdr.last_end_lsn);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1659 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1660
e8b8e97f91b80f Kari Argillander 2021-08-03 1661 /* Read first tail page (at pos
2/0x2000). */
b46acd6a6a627d Konstantin Komarov 2021-08-13 1662 if (read_log_page(log, final_off,
&first_tail, &usa_error) ||
b46acd6a6a627d Konstantin Komarov 2021-08-13 1663 usa_error ||
first_tail->rhdr.sign != NTFS_RCRD_SIGNATURE) {
195c52bdd5d5ec Kari Argillander 2021-08-24 1664 kfree(first_tail);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1665 first_tail = NULL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1666 first_file_off = 0;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1667 lsn1 = 0;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1668 } else {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1669 first_file_off = hdr_file_off(log,
first_tail);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1670 lsn1 =
le64_to_cpu(first_tail->record_hdr.last_end_lsn);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1671 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1672
b46acd6a6a627d Konstantin Komarov 2021-08-13 1673 if (log->major_ver < 2) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1674 int best_page;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1675
b46acd6a6a627d Konstantin Komarov 2021-08-13 1676 first_tail_prev = first_tail;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1677 final_off_prev = first_file_off;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1678 second_tail_prev = second_tail;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1679 second_off_prev = second_file_off;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1680 tails = 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1681
b46acd6a6a627d Konstantin Komarov 2021-08-13 1682 if (!first_tail &&
!second_tail)
b46acd6a6a627d Konstantin Komarov 2021-08-13 1683 goto tail_read;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1684
b46acd6a6a627d Konstantin Komarov 2021-08-13 1685 if (first_tail &&
second_tail)
b46acd6a6a627d Konstantin Komarov 2021-08-13 1686 best_page = lsn1 < lsn2 ? 1 :
0;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1687 else if (first_tail)
b46acd6a6a627d Konstantin Komarov 2021-08-13 1688 best_page = 0;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1689 else
b46acd6a6a627d Konstantin Komarov 2021-08-13 1690 best_page = 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1691
b46acd6a6a627d Konstantin Komarov 2021-08-13 1692 page_off = best_page ?
second_file_off : first_file_off;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1693 seq_base = (best_page ? lsn2 : lsn1)
>> log->file_data_bits;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1694 goto tail_read;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1695 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1696
b46acd6a6a627d Konstantin Komarov 2021-08-13 1697 best_lsn1 = first_tail ?
base_lsn(log, first_tail, first_file_off) : 0;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1698 best_lsn2 =
b46acd6a6a627d Konstantin Komarov 2021-08-13 1699 second_tail ? base_lsn(log,
second_tail, second_file_off) : 0;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1700
b46acd6a6a627d Konstantin Komarov 2021-08-13 1701 if (first_tail &&
second_tail) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1702 if (best_lsn1 > best_lsn2) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1703 best_lsn = best_lsn1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1704 best_page = first_tail;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1705 this_off = first_file_off;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1706 } else {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1707 best_lsn = best_lsn2;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1708 best_page = second_tail;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1709 this_off = second_file_off;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1710 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1711 } else if (first_tail) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1712 best_lsn = best_lsn1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1713 best_page = first_tail;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1714 this_off = first_file_off;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1715 } else if (second_tail) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1716 best_lsn = best_lsn2;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1717 best_page = second_tail;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1718 this_off = second_file_off;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1719 } else {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1720 goto tail_read;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1721 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1722
b46acd6a6a627d Konstantin Komarov 2021-08-13 1723 best_page_pos =
le16_to_cpu(best_page->page_pos);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1724
b46acd6a6a627d Konstantin Komarov 2021-08-13 1725 if (!tails) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1726 if (best_page_pos == page_pos) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1727 seq_base = best_lsn >>
log->file_data_bits;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1728 saved_off = page_off =
le32_to_cpu(best_page->file_off);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1729 lsn_base = best_lsn;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1730
b46acd6a6a627d Konstantin Komarov 2021-08-13 1731 memmove(page_bufs, best_page,
log->page_size);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1732
b46acd6a6a627d Konstantin Komarov 2021-08-13 1733 page_cnt =
le16_to_cpu(best_page->page_count);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1734 if (page_cnt > 1)
b46acd6a6a627d Konstantin Komarov 2021-08-13 1735 page_pos += 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1736
b46acd6a6a627d Konstantin Komarov 2021-08-13 1737 tails = 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1738 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1739 } else if (seq_base == (best_lsn
>> log->file_data_bits) &&
b46acd6a6a627d Konstantin Komarov 2021-08-13 1740 saved_off + log->page_size ==
this_off &&
b46acd6a6a627d Konstantin Komarov 2021-08-13 1741 lsn_base < best_lsn
&&
b46acd6a6a627d Konstantin Komarov 2021-08-13 1742 (page_pos != page_cnt ||
best_page_pos == page_pos ||
b46acd6a6a627d Konstantin Komarov 2021-08-13 1743 best_page_pos == 1) &&
b46acd6a6a627d Konstantin Komarov 2021-08-13 1744 (page_pos >= page_cnt ||
best_page_pos == page_pos)) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1745 u16 bppc =
le16_to_cpu(best_page->page_count);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1746
b46acd6a6a627d Konstantin Komarov 2021-08-13 1747 saved_off += log->page_size;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1748 lsn_base = best_lsn;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1749
b46acd6a6a627d Konstantin Komarov 2021-08-13 1750 memmove(Add2Ptr(page_bufs, tails *
log->page_size), best_page,
b46acd6a6a627d Konstantin Komarov 2021-08-13 1751 log->page_size);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1752
b46acd6a6a627d Konstantin Komarov 2021-08-13 1753 tails += 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1754
b46acd6a6a627d Konstantin Komarov 2021-08-13 1755 if (best_page_pos != bppc) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1756 page_cnt = bppc;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1757 page_pos = best_page_pos;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1758
b46acd6a6a627d Konstantin Komarov 2021-08-13 1759 if (page_cnt > 1)
b46acd6a6a627d Konstantin Komarov 2021-08-13 1760 page_pos += 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1761 } else {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1762 page_pos = page_cnt = 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1763 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1764 } else {
195c52bdd5d5ec Kari Argillander 2021-08-24 1765 kfree(first_tail);
195c52bdd5d5ec Kari Argillander 2021-08-24 1766 kfree(second_tail);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1767 goto tail_read;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1768 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1769
195c52bdd5d5ec Kari Argillander 2021-08-24 1770 kfree(first_tail_prev);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1771 first_tail_prev = first_tail;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1772 final_off_prev = first_file_off;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1773 first_tail = NULL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1774
195c52bdd5d5ec Kari Argillander 2021-08-24 1775 kfree(second_tail_prev);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1776 second_tail_prev = second_tail;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1777 second_off_prev = second_file_off;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1778 second_tail = NULL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1779
b46acd6a6a627d Konstantin Komarov 2021-08-13 1780 final_off += log->page_size;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1781 second_off += log->page_size;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1782
b46acd6a6a627d Konstantin Komarov 2021-08-13 1783 if (tails < 0x10)
b46acd6a6a627d Konstantin Komarov 2021-08-13 1784 goto next_tail;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1785 tail_read:
b46acd6a6a627d Konstantin Komarov 2021-08-13 1786 first_tail = first_tail_prev;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1787 final_off = final_off_prev;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1788
b46acd6a6a627d Konstantin Komarov 2021-08-13 1789 second_tail = second_tail_prev;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1790 second_off = second_off_prev;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1791
b46acd6a6a627d Konstantin Komarov 2021-08-13 1792 page_cnt = page_pos = 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1793
b46acd6a6a627d Konstantin Komarov 2021-08-13 1794 curpage_off = seq_base ==
log->seq_num ? min(log->next_page, page_off)
b46acd6a6a627d Konstantin Komarov 2021-08-13 1795 : log->next_page;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1796
b46acd6a6a627d Konstantin Komarov 2021-08-13 1797 wrapped_file =
b46acd6a6a627d Konstantin Komarov 2021-08-13 1798 curpage_off == log->first_page
&&
b46acd6a6a627d Konstantin Komarov 2021-08-13 1799 !(log->l_flags &
(NTFSLOG_NO_LAST_LSN | NTFSLOG_REUSE_TAIL));
b46acd6a6a627d Konstantin Komarov 2021-08-13 1800
b46acd6a6a627d Konstantin Komarov 2021-08-13 1801 expected_seq = wrapped_file ?
(log->seq_num + 1) : log->seq_num;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1802
b46acd6a6a627d Konstantin Komarov 2021-08-13 1803 nextpage_off = curpage_off;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1804
b46acd6a6a627d Konstantin Komarov 2021-08-13 1805 next_page:
b46acd6a6a627d Konstantin Komarov 2021-08-13 1806 tail_page = NULL;
e8b8e97f91b80f Kari Argillander 2021-08-03 1807 /* Read the next log page. */
b46acd6a6a627d Konstantin Komarov 2021-08-13 1808 err = read_log_page(log, curpage_off,
&page, &usa_error);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1809
e8b8e97f91b80f Kari Argillander 2021-08-03 1810 /* Compute the next log page offset
the file. */
b46acd6a6a627d Konstantin Komarov 2021-08-13 1811 nextpage_off = next_page_off(log,
curpage_off);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1812 wrapped = nextpage_off ==
log->first_page;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1813
b46acd6a6a627d Konstantin Komarov 2021-08-13 1814 if (tails > 1) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1815 struct RECORD_PAGE_HDR *cur_page =
b46acd6a6a627d Konstantin Komarov 2021-08-13 1816 Add2Ptr(page_bufs, curpage_off -
page_off);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1817
b46acd6a6a627d Konstantin Komarov 2021-08-13 1818 if (curpage_off == saved_off) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1819 tail_page = cur_page;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1820 goto use_tail_page;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1821 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1822
b46acd6a6a627d Konstantin Komarov 2021-08-13 1823 if (page_off > curpage_off ||
curpage_off >= saved_off)
b46acd6a6a627d Konstantin Komarov 2021-08-13 1824 goto use_tail_page;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1825
b46acd6a6a627d Konstantin Komarov 2021-08-13 1826 if (page_off1)
b46acd6a6a627d Konstantin Komarov 2021-08-13 1827 goto use_cur_page;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1828
b46acd6a6a627d Konstantin Komarov 2021-08-13 1829 if (!err && !usa_error
&&
b46acd6a6a627d Konstantin Komarov 2021-08-13 1830 page->rhdr.sign ==
NTFS_RCRD_SIGNATURE &&
b46acd6a6a627d Konstantin Komarov 2021-08-13 1831 cur_page->rhdr.lsn ==
page->rhdr.lsn &&
b46acd6a6a627d Konstantin Komarov 2021-08-13 1832
cur_page->record_hdr.next_record_off ==
b46acd6a6a627d Konstantin Komarov 2021-08-13 1833
page->record_hdr.next_record_off &&
b46acd6a6a627d Konstantin Komarov 2021-08-13 1834 ((page_pos == page_cnt
&&
b46acd6a6a627d Konstantin Komarov 2021-08-13 1835 le16_to_cpu(page->page_pos)
== 1) ||
b46acd6a6a627d Konstantin Komarov 2021-08-13 1836 (page_pos != page_cnt
&&
b46acd6a6a627d Konstantin Komarov 2021-08-13 1837 le16_to_cpu(page->page_pos)
== page_pos + 1 &&
b46acd6a6a627d Konstantin Komarov 2021-08-13 1838
le16_to_cpu(page->page_count) == page_cnt))) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1839 cur_page = NULL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1840 goto use_tail_page;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1841 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1842
b46acd6a6a627d Konstantin Komarov 2021-08-13 1843 page_off1 = page_off;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1844
b46acd6a6a627d Konstantin Komarov 2021-08-13 1845 use_cur_page:
b46acd6a6a627d Konstantin Komarov 2021-08-13 1846
b46acd6a6a627d Konstantin Komarov 2021-08-13 1847 lsn_cur =
le64_to_cpu(cur_page->rhdr.lsn);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1848
b46acd6a6a627d Konstantin Komarov 2021-08-13 1849 if (last_ok_lsn !=
b46acd6a6a627d Konstantin Komarov 2021-08-13 1850
le64_to_cpu(cur_page->record_hdr.last_end_lsn) &&
b46acd6a6a627d Konstantin Komarov 2021-08-13 1851 ((lsn_cur >>
log->file_data_bits) +
b46acd6a6a627d Konstantin Komarov 2021-08-13 1852 ((curpage_off <
b46acd6a6a627d Konstantin Komarov 2021-08-13 1853 (lsn_to_vbo(log, lsn_cur)
& ~log->page_mask))
b46acd6a6a627d Konstantin Komarov 2021-08-13 1854 ? 1
b46acd6a6a627d Konstantin Komarov 2021-08-13 1855 : 0)) != expected_seq) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1856 goto check_tail;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1857 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1858
b46acd6a6a627d Konstantin Komarov 2021-08-13 1859 if (!is_log_record_end(cur_page)) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1860 tail_page = NULL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1861 last_ok_lsn = lsn_cur;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1862 goto next_page_1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1863 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1864
b46acd6a6a627d Konstantin Komarov 2021-08-13 1865 log->seq_num = expected_seq;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1866 log->l_flags &=
~NTFSLOG_NO_LAST_LSN;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1867 log->last_lsn =
le64_to_cpu(cur_page->record_hdr.last_end_lsn);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1868 log->ra->current_lsn =
cur_page->record_hdr.last_end_lsn;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1869
b46acd6a6a627d Konstantin Komarov 2021-08-13 1870 if (log->record_header_len <=
b46acd6a6a627d Konstantin Komarov 2021-08-13 1871 log->page_size -
b46acd6a6a627d Konstantin Komarov 2021-08-13 1872
le16_to_cpu(cur_page->record_hdr.next_record_off)) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1873 log->l_flags |=
NTFSLOG_REUSE_TAIL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1874 log->next_page = curpage_off;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1875 } else {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1876 log->l_flags &=
~NTFSLOG_REUSE_TAIL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1877 log->next_page = nextpage_off;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1878 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1879
b46acd6a6a627d Konstantin Komarov 2021-08-13 1880 if (wrapped_file)
b46acd6a6a627d Konstantin Komarov 2021-08-13 1881 log->l_flags |=
NTFSLOG_WRAPPED;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1882
b46acd6a6a627d Konstantin Komarov 2021-08-13 1883 last_ok_lsn =
le64_to_cpu(cur_page->record_hdr.last_end_lsn);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1884 goto next_page_1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1885 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1886
b46acd6a6a627d Konstantin Komarov 2021-08-13 1887 /*
b46acd6a6a627d Konstantin Komarov 2021-08-13 1888 * If we are at the expected first
page of a transfer check to see
e8b8e97f91b80f Kari Argillander 2021-08-03 1889 * if either tail copy is at this
offset.
b46acd6a6a627d Konstantin Komarov 2021-08-13 1890 * If this page is the last page of a
transfer, check if we wrote
e8b8e97f91b80f Kari Argillander 2021-08-03 1891 * a subsequent tail copy.
b46acd6a6a627d Konstantin Komarov 2021-08-13 1892 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 1893 if (page_cnt == page_pos || page_cnt
== page_pos + 1) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1894 /*
b46acd6a6a627d Konstantin Komarov 2021-08-13 1895 * Check if the offset matches
either the first or second
e8b8e97f91b80f Kari Argillander 2021-08-03 1896 * tail copy. It is possible it will
match both.
b46acd6a6a627d Konstantin Komarov 2021-08-13 1897 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 1898 if (curpage_off == final_off)
b46acd6a6a627d Konstantin Komarov 2021-08-13 1899 tail_page = first_tail;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1900
b46acd6a6a627d Konstantin Komarov 2021-08-13 1901 /*
b46acd6a6a627d Konstantin Komarov 2021-08-13 1902 * If we already matched on the
first page then
b46acd6a6a627d Konstantin Komarov 2021-08-13 1903 * check the ending lsn's.
b46acd6a6a627d Konstantin Komarov 2021-08-13 1904 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 1905 if (curpage_off == second_off) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1906 if (!tail_page ||
b46acd6a6a627d Konstantin Komarov 2021-08-13 1907 (second_tail &&
b46acd6a6a627d Konstantin Komarov 2021-08-13 1908
le64_to_cpu(second_tail->record_hdr.last_end_lsn) >
b46acd6a6a627d Konstantin Komarov 2021-08-13 1909
le64_to_cpu(first_tail->record_hdr
b46acd6a6a627d Konstantin Komarov 2021-08-13 1910 .last_end_lsn))) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1911 tail_page = second_tail;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1912 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1913 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1914 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1915
b46acd6a6a627d Konstantin Komarov 2021-08-13 1916 use_tail_page:
b46acd6a6a627d Konstantin Komarov 2021-08-13 1917 if (tail_page) {
e8b8e97f91b80f Kari Argillander 2021-08-03 1918 /* We have a candidate for a tail
copy. */
b46acd6a6a627d Konstantin Komarov 2021-08-13 1919 lsn_cur =
le64_to_cpu(tail_page->record_hdr.last_end_lsn);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1920
b46acd6a6a627d Konstantin Komarov 2021-08-13 1921 if (last_ok_lsn < lsn_cur) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1922 /*
b46acd6a6a627d Konstantin Komarov 2021-08-13 1923 * If the sequence number is not
expected,
e8b8e97f91b80f Kari Argillander 2021-08-03 1924 * then don't use the tail
copy.
b46acd6a6a627d Konstantin Komarov 2021-08-13 1925 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 1926 if (expected_seq != (lsn_cur
>> log->file_data_bits))
b46acd6a6a627d Konstantin Komarov 2021-08-13 1927 tail_page = NULL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1928 } else if (last_ok_lsn > lsn_cur)
{
b46acd6a6a627d Konstantin Komarov 2021-08-13 1929 /*
b46acd6a6a627d Konstantin Komarov 2021-08-13 1930 * If the last lsn is greater than
the one on
e8b8e97f91b80f Kari Argillander 2021-08-03 1931 * this page then forget this
tail.
b46acd6a6a627d Konstantin Komarov 2021-08-13 1932 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 1933 tail_page = NULL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1934 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1935 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1936
e8b8e97f91b80f Kari Argillander 2021-08-03 1937 /*
e8b8e97f91b80f Kari Argillander 2021-08-03 1938 *If we have an error on the current
page,
e8b8e97f91b80f Kari Argillander 2021-08-03 1939 * we will break of this loop.
e8b8e97f91b80f Kari Argillander 2021-08-03 1940 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 1941 if (err || usa_error)
b46acd6a6a627d Konstantin Komarov 2021-08-13 1942 goto check_tail;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1943
b46acd6a6a627d Konstantin Komarov 2021-08-13 1944 /*
b46acd6a6a627d Konstantin Komarov 2021-08-13 1945 * Done if the last lsn on this page
doesn't match the previous known
e8b8e97f91b80f Kari Argillander 2021-08-03 1946 * last lsn or the sequence number is
not expected.
b46acd6a6a627d Konstantin Komarov 2021-08-13 1947 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 1948 lsn_cur =
le64_to_cpu(page->rhdr.lsn);
b46acd6a6a627d Konstantin Komarov 2021-08-13 1949 if (last_ok_lsn != lsn_cur
&&
b46acd6a6a627d Konstantin Komarov 2021-08-13 1950 expected_seq != (lsn_cur >>
log->file_data_bits)) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1951 goto check_tail;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1952 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1953
b46acd6a6a627d Konstantin Komarov 2021-08-13 1954 /*
e8b8e97f91b80f Kari Argillander 2021-08-03 1955 * Check that the page position and
page count values are correct.
b46acd6a6a627d Konstantin Komarov 2021-08-13 1956 * If this is the first page of a
transfer the position must be 1
e8b8e97f91b80f Kari Argillander 2021-08-03 1957 * and the count will be unknown.
b46acd6a6a627d Konstantin Komarov 2021-08-13 1958 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 1959 if (page_cnt == page_pos) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1960 if (page->page_pos !=
cpu_to_le16(1) &&
b46acd6a6a627d Konstantin Komarov 2021-08-13 1961 (!reuse_page ||
page->page_pos != page->page_count)) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1962 /*
b46acd6a6a627d Konstantin Komarov 2021-08-13 1963 * If the current page is the first
page we are
b46acd6a6a627d Konstantin Komarov 2021-08-13 1964 * looking at and we are reusing
this page then
b46acd6a6a627d Konstantin Komarov 2021-08-13 1965 * it can be either the first or
last page of a
b46acd6a6a627d Konstantin Komarov 2021-08-13 1966 * transfer. Otherwise it can only
be the first.
b46acd6a6a627d Konstantin Komarov 2021-08-13 1967 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 1968 goto check_tail;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1969 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1970 } else if
(le16_to_cpu(page->page_count) != page_cnt ||
b46acd6a6a627d Konstantin Komarov 2021-08-13 1971 le16_to_cpu(page->page_pos) !=
page_pos + 1) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1972 /*
b46acd6a6a627d Konstantin Komarov 2021-08-13 1973 * The page position better be 1
more than the last page
e8b8e97f91b80f Kari Argillander 2021-08-03 1974 * position and the page count
better match.
b46acd6a6a627d Konstantin Komarov 2021-08-13 1975 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 1976 goto check_tail;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1977 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1978
b46acd6a6a627d Konstantin Komarov 2021-08-13 1979 /*
b46acd6a6a627d Konstantin Komarov 2021-08-13 1980 * We have a valid page the file and
may have a valid page
e8b8e97f91b80f Kari Argillander 2021-08-03 1981 * the tail copy area.
b46acd6a6a627d Konstantin Komarov 2021-08-13 1982 * If the tail page was written after
the page the file then
e8b8e97f91b80f Kari Argillander 2021-08-03 1983 * break of the loop.
b46acd6a6a627d Konstantin Komarov 2021-08-13 1984 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 1985 if (tail_page &&
b46acd6a6a627d Konstantin Komarov 2021-08-13 1986
le64_to_cpu(tail_page->record_hdr.last_end_lsn) > lsn_cur) {
e8b8e97f91b80f Kari Argillander 2021-08-03 1987 /* Remember if we will replace the
page. */
b46acd6a6a627d Konstantin Komarov 2021-08-13 1988 replace_page = true;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1989 goto check_tail;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1990 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 1991
b46acd6a6a627d Konstantin Komarov 2021-08-13 1992 tail_page = NULL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 1993
b46acd6a6a627d Konstantin Komarov 2021-08-13 1994 if (is_log_record_end(page)) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 1995 /*
b46acd6a6a627d Konstantin Komarov 2021-08-13 1996 * Since we have read this page we
know the sequence number
e8b8e97f91b80f Kari Argillander 2021-08-03 1997 * is the same as our expected
value.
b46acd6a6a627d Konstantin Komarov 2021-08-13 1998 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 1999 log->seq_num = expected_seq;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2000 log->last_lsn =
le64_to_cpu(page->record_hdr.last_end_lsn);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2001 log->ra->current_lsn =
page->record_hdr.last_end_lsn;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2002 log->l_flags &=
~NTFSLOG_NO_LAST_LSN;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2003
b46acd6a6a627d Konstantin Komarov 2021-08-13 2004 /*
b46acd6a6a627d Konstantin Komarov 2021-08-13 2005 * If there is room on this page for
another header then
e8b8e97f91b80f Kari Argillander 2021-08-03 2006 * remember we want to reuse the
page.
b46acd6a6a627d Konstantin Komarov 2021-08-13 2007 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 2008 if (log->record_header_len <=
b46acd6a6a627d Konstantin Komarov 2021-08-13 2009 log->page_size -
b46acd6a6a627d Konstantin Komarov 2021-08-13 2010
le16_to_cpu(page->record_hdr.next_record_off)) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2011 log->l_flags |=
NTFSLOG_REUSE_TAIL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2012 log->next_page = curpage_off;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2013 } else {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2014 log->l_flags &=
~NTFSLOG_REUSE_TAIL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2015 log->next_page = nextpage_off;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2016 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 2017
e8b8e97f91b80f Kari Argillander 2021-08-03 2018 /* Remember if we wrapped the log
file. */
b46acd6a6a627d Konstantin Komarov 2021-08-13 2019 if (wrapped_file)
b46acd6a6a627d Konstantin Komarov 2021-08-13 2020 log->l_flags |=
NTFSLOG_WRAPPED;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2021 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 2022
b46acd6a6a627d Konstantin Komarov 2021-08-13 2023 /*
b46acd6a6a627d Konstantin Komarov 2021-08-13 2024 * Remember the last page count and
position.
e8b8e97f91b80f Kari Argillander 2021-08-03 2025 * Also remember the last known lsn.
b46acd6a6a627d Konstantin Komarov 2021-08-13 2026 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 2027 page_cnt =
le16_to_cpu(page->page_count);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2028 page_pos =
le16_to_cpu(page->page_pos);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2029 last_ok_lsn =
le64_to_cpu(page->rhdr.lsn);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2030
b46acd6a6a627d Konstantin Komarov 2021-08-13 2031 next_page_1:
b46acd6a6a627d Konstantin Komarov 2021-08-13 2032
b46acd6a6a627d Konstantin Komarov 2021-08-13 2033 if (wrapped) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2034 expected_seq += 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2035 wrapped_file = 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2036 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 2037
b46acd6a6a627d Konstantin Komarov 2021-08-13 2038 curpage_off = nextpage_off;
195c52bdd5d5ec Kari Argillander 2021-08-24 2039 kfree(page);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2040 page = NULL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2041 reuse_page = 0;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2042 goto next_page;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2043
b46acd6a6a627d Konstantin Komarov 2021-08-13 2044 check_tail:
b46acd6a6a627d Konstantin Komarov 2021-08-13 2045 if (tail_page) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2046 log->seq_num = expected_seq;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2047 log->last_lsn =
le64_to_cpu(tail_page->record_hdr.last_end_lsn);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2048 log->ra->current_lsn =
tail_page->record_hdr.last_end_lsn;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2049 log->l_flags &=
~NTFSLOG_NO_LAST_LSN;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2050
b46acd6a6a627d Konstantin Komarov 2021-08-13 2051 if (log->page_size -
b46acd6a6a627d Konstantin Komarov 2021-08-13 2052 le16_to_cpu(
b46acd6a6a627d Konstantin Komarov 2021-08-13 2053
tail_page->record_hdr.next_record_off) >=
b46acd6a6a627d Konstantin Komarov 2021-08-13 2054 log->record_header_len) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2055 log->l_flags |=
NTFSLOG_REUSE_TAIL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2056 log->next_page = curpage_off;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2057 } else {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2058 log->l_flags &=
~NTFSLOG_REUSE_TAIL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2059 log->next_page = nextpage_off;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2060 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 2061
b46acd6a6a627d Konstantin Komarov 2021-08-13 2062 if (wrapped)
b46acd6a6a627d Konstantin Komarov 2021-08-13 2063 log->l_flags |=
NTFSLOG_WRAPPED;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2064 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 2065
e8b8e97f91b80f Kari Argillander 2021-08-03 2066 /* Remember that the partial IO will
start at the next page. */
b46acd6a6a627d Konstantin Komarov 2021-08-13 2067 second_off = nextpage_off;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2068
b46acd6a6a627d Konstantin Komarov 2021-08-13 2069 /*
b46acd6a6a627d Konstantin Komarov 2021-08-13 2070 * If the next page is the first page
of the file then update
e8b8e97f91b80f Kari Argillander 2021-08-03 2071 * the sequence number for log
records which begon the next page.
b46acd6a6a627d Konstantin Komarov 2021-08-13 2072 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 2073 if (wrapped)
b46acd6a6a627d Konstantin Komarov 2021-08-13 2074 expected_seq += 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2075
b46acd6a6a627d Konstantin Komarov 2021-08-13 2076 /*
b46acd6a6a627d Konstantin Komarov 2021-08-13 2077 * If we have a tail copy or are
performing single page I/O we can
e8b8e97f91b80f Kari Argillander 2021-08-03 2078 * immediately look at the next
page.
b46acd6a6a627d Konstantin Komarov 2021-08-13 2079 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 2080 if (replace_page ||
(log->ra->flags & RESTART_SINGLE_PAGE_IO)) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2081 page_cnt = 2;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2082 page_pos = 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2083 goto check_valid;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2084 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 2085
b46acd6a6a627d Konstantin Komarov 2021-08-13 2086 if (page_pos != page_cnt)
b46acd6a6a627d Konstantin Komarov 2021-08-13 2087 goto check_valid;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2088 /*
b46acd6a6a627d Konstantin Komarov 2021-08-13 2089 * If the next page causes us to wrap
to the beginning of the log
b46acd6a6a627d Konstantin Komarov 2021-08-13 2090 * file then we know which page to
check next.
b46acd6a6a627d Konstantin Komarov 2021-08-13 2091 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 2092 if (wrapped) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2093 page_cnt = 2;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2094 page_pos = 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2095 goto check_valid;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2096 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 2097
b46acd6a6a627d Konstantin Komarov 2021-08-13 2098 cur_pos = 2;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2099
b46acd6a6a627d Konstantin Komarov 2021-08-13 2100 next_test_page:
195c52bdd5d5ec Kari Argillander 2021-08-24 2101 kfree(tst_page);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2102 tst_page = NULL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2103
e8b8e97f91b80f Kari Argillander 2021-08-03 2104 /* Walk through the file, reading log
pages. */
b46acd6a6a627d Konstantin Komarov 2021-08-13 2105 err = read_log_page(log,
nextpage_off, &tst_page, &usa_error);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2106
b46acd6a6a627d Konstantin Komarov 2021-08-13 2107 /*
b46acd6a6a627d Konstantin Komarov 2021-08-13 2108 * If we get a USA error then assume
that we correctly found
e8b8e97f91b80f Kari Argillander 2021-08-03 2109 * the end of the original transfer.
b46acd6a6a627d Konstantin Komarov 2021-08-13 2110 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 2111 if (usa_error)
b46acd6a6a627d Konstantin Komarov 2021-08-13 2112 goto file_is_valid;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2113
b46acd6a6a627d Konstantin Komarov 2021-08-13 2114 /*
b46acd6a6a627d Konstantin Komarov 2021-08-13 2115 * If we were able to read the page,
we examine it to see if it
e8b8e97f91b80f Kari Argillander 2021-08-03 2116 * is the same or different Io
block.
b46acd6a6a627d Konstantin Komarov 2021-08-13 2117 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 2118 if (err)
b46acd6a6a627d Konstantin Komarov 2021-08-13 2119 goto next_test_page_1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2120
b46acd6a6a627d Konstantin Komarov 2021-08-13 2121 if
(le16_to_cpu(tst_page->page_pos) == cur_pos &&
b46acd6a6a627d Konstantin Komarov 2021-08-13 2122 check_subseq_log_page(log,
tst_page, nextpage_off, expected_seq)) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2123 page_cnt =
le16_to_cpu(tst_page->page_count) + 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2124 page_pos =
le16_to_cpu(tst_page->page_pos);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2125 goto check_valid;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2126 } else {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2127 goto file_is_valid;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2128 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 2129
b46acd6a6a627d Konstantin Komarov 2021-08-13 2130 next_test_page_1:
b46acd6a6a627d Konstantin Komarov 2021-08-13 2131
b46acd6a6a627d Konstantin Komarov 2021-08-13 2132 nextpage_off = next_page_off(log,
curpage_off);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2133 wrapped = nextpage_off ==
log->first_page;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2134
b46acd6a6a627d Konstantin Komarov 2021-08-13 2135 if (wrapped) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2136 expected_seq += 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2137 page_cnt = 2;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2138 page_pos = 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2139 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 2140
b46acd6a6a627d Konstantin Komarov 2021-08-13 2141 cur_pos += 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2142 part_io_count += 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2143 if (!wrapped)
b46acd6a6a627d Konstantin Komarov 2021-08-13 2144 goto next_test_page;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2145
b46acd6a6a627d Konstantin Komarov 2021-08-13 2146 check_valid:
e8b8e97f91b80f Kari Argillander 2021-08-03 2147 /* Skip over the remaining pages this
transfer. */
b46acd6a6a627d Konstantin Komarov 2021-08-13 2148 remain_pages = page_cnt - page_pos -
1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2149 part_io_count += remain_pages;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2150
b46acd6a6a627d Konstantin Komarov 2021-08-13 2151 while (remain_pages--) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2152 nextpage_off = next_page_off(log,
curpage_off);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2153 wrapped = nextpage_off ==
log->first_page;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2154
b46acd6a6a627d Konstantin Komarov 2021-08-13 2155 if (wrapped)
b46acd6a6a627d Konstantin Komarov 2021-08-13 2156 expected_seq += 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2157 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 2158
e8b8e97f91b80f Kari Argillander 2021-08-03 2159 /* Call our routine to check this log
page. */
195c52bdd5d5ec Kari Argillander 2021-08-24 2160 kfree(tst_page);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2161 tst_page = NULL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2162
b46acd6a6a627d Konstantin Komarov 2021-08-13 2163 err = read_log_page(log,
nextpage_off, &tst_page, &usa_error);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2164 if (!err && !usa_error
&&
b46acd6a6a627d Konstantin Komarov 2021-08-13 2165 check_subseq_log_page(log,
tst_page, nextpage_off, expected_seq)) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2166 err = -EINVAL;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2167 goto out;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2168 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 2169
b46acd6a6a627d Konstantin Komarov 2021-08-13 2170 file_is_valid:
b46acd6a6a627d Konstantin Komarov 2021-08-13 2171
e8b8e97f91b80f Kari Argillander 2021-08-03 2172 /* We have a valid file. */
b46acd6a6a627d Konstantin Komarov 2021-08-13 2173 if (page_off1 || tail_page) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2174 struct RECORD_PAGE_HDR *tmp_page;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2175
b46acd6a6a627d Konstantin Komarov 2021-08-13 2176 if
(sb_rdonly(log->ni->mi.sbi->sb)) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2177 err = -EROFS;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2178 goto out;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2179 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 2180
b46acd6a6a627d Konstantin Komarov 2021-08-13 2181 if (page_off1) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2182 tmp_page = Add2Ptr(page_bufs,
page_off1 - page_off);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2183 tails -= (page_off1 - page_off) /
log->page_size;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2184 if (!tail_page)
b46acd6a6a627d Konstantin Komarov 2021-08-13 2185 tails -= 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2186 } else {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2187 tmp_page = tail_page;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2188 tails = 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2189 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 2190
b46acd6a6a627d Konstantin Komarov 2021-08-13 2191 while (tails--) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2192 u64 off = hdr_file_off(log,
tmp_page);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2193
b46acd6a6a627d Konstantin Komarov 2021-08-13 2194 if (!page) {
195c52bdd5d5ec Kari Argillander 2021-08-24 2195 page = kmalloc(log->page_size,
GFP_NOFS);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2196 if (!page)
b46acd6a6a627d Konstantin Komarov 2021-08-13 2197 return -ENOMEM;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2198 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 2199
b46acd6a6a627d Konstantin Komarov 2021-08-13 2200 /*
b46acd6a6a627d Konstantin Komarov 2021-08-13 2201 * Correct page and copy the data
from this page
e8b8e97f91b80f Kari Argillander 2021-08-03 2202 * into it and flush it to disk.
b46acd6a6a627d Konstantin Komarov 2021-08-13 2203 */
b46acd6a6a627d Konstantin Komarov 2021-08-13 2204 memcpy(page, tmp_page,
log->page_size);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2205
e8b8e97f91b80f Kari Argillander 2021-08-03 2206 /* Fill last flushed lsn value
flush the page. */
b46acd6a6a627d Konstantin Komarov 2021-08-13 2207 if (log->major_ver < 2)
b46acd6a6a627d Konstantin Komarov 2021-08-13 2208 page->rhdr.lsn =
page->record_hdr.last_end_lsn;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2209 else
b46acd6a6a627d Konstantin Komarov 2021-08-13 2210 page->file_off = 0;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2211
b46acd6a6a627d Konstantin Komarov 2021-08-13 2212 page->page_pos =
page->page_count = cpu_to_le16(1);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2213
b46acd6a6a627d Konstantin Komarov 2021-08-13 2214
ntfs_fix_pre_write(&page->rhdr, log->page_size);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2215
b46acd6a6a627d Konstantin Komarov 2021-08-13 2216 err =
ntfs_sb_write_run(log->ni->mi.sbi,
b46acd6a6a627d Konstantin Komarov 2021-08-13 2217 &log->ni->file.run,
off, page,
6354467245ff8d Konstantin Komarov 2021-09-09 2218 log->page_size, 0);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2219
b46acd6a6a627d Konstantin Komarov 2021-08-13 2220 if (err)
b46acd6a6a627d Konstantin Komarov 2021-08-13 2221 goto out;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2222
b46acd6a6a627d Konstantin Komarov 2021-08-13 2223 if (part_io_count &&
second_off == off) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2224 second_off += log->page_size;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2225 part_io_count -= 1;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2226 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 2227
b46acd6a6a627d Konstantin Komarov 2021-08-13 2228 tmp_page = Add2Ptr(tmp_page,
log->page_size);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2229 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 2230 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 2231
b46acd6a6a627d Konstantin Komarov 2021-08-13 2232 if (part_io_count) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2233 if
(sb_rdonly(log->ni->mi.sbi->sb)) {
b46acd6a6a627d Konstantin Komarov 2021-08-13 2234 err = -EROFS;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2235 goto out;
b46acd6a6a627d Konstantin Komarov 2021-08-13 2236 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 2237 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 2238
b46acd6a6a627d Konstantin Komarov 2021-08-13 2239 out:
195c52bdd5d5ec Kari Argillander 2021-08-24 2240 kfree(second_tail);
195c52bdd5d5ec Kari Argillander 2021-08-24 2241 kfree(first_tail);
195c52bdd5d5ec Kari Argillander 2021-08-24 2242 kfree(page);
195c52bdd5d5ec Kari Argillander 2021-08-24 2243 kfree(tst_page);
195c52bdd5d5ec Kari Argillander 2021-08-24 2244 kfree(page_bufs);
b46acd6a6a627d Konstantin Komarov 2021-08-13 2245
b46acd6a6a627d Konstantin Komarov 2021-08-13 2246 return err;
b46acd6a6a627d Konstantin Komarov 2021-08-13 @2247 }
b46acd6a6a627d Konstantin Komarov 2021-08-13 2248
:::::: The code at line 2247 was first introduced by commit
:::::: b46acd6a6a627d876898e1c84d3f84902264b445 fs/ntfs3: Add NTFS journal
:::::: TO: Konstantin Komarov <almaz.alexandrovich(a)paragon-software.com>
:::::: CC: Konstantin Komarov <almaz.alexandrovich(a)paragon-software.com>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org