From: kernel test robot <lkp@intel.com>
To: Kent Overstreet <kent.overstreet@linux.dev>
Cc: oe-kbuild-all@lists.linux.dev,
Kent Overstreet <kent.overstreet@linux.dev>
Subject: [bcachefs:bcachefs-testing 87/94] fs/bcachefs/fsck.c:1812:39: sparse: sparse: cast to restricted __le32
Date: Sun, 11 Feb 2024 03:38:38 +0800 [thread overview]
Message-ID: <202402110322.zn654S7e-lkp@intel.com> (raw)
tree: https://evilpiepirate.org/git/bcachefs.git bcachefs-testing
head: bee7b5a4fa2135c9ec9d1c9424018ee494500bb5
commit: e4ed89728107b08a3899496f2a50d9d217c2e27d [87/94] bcachefs: bch_subvolume::fs_path_parent
config: x86_64-randconfig-123-20240210 (https://download.01.org/0day-ci/archive/20240211/202402110322.zn654S7e-lkp@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240211/202402110322.zn654S7e-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202402110322.zn654S7e-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
fs/bcachefs/fsck.c: note: in included file:
fs/bcachefs/bcachefs.h:1013:9: sparse: sparse: array of flexible structures
fs/bcachefs/fsck.c:1702:46: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] d_parent_subvol @@ got unsigned int [usertype] bi_parent_subvol @@
fs/bcachefs/fsck.c:1702:46: sparse: expected restricted __le32 [usertype] d_parent_subvol
fs/bcachefs/fsck.c:1702:46: sparse: got unsigned int [usertype] bi_parent_subvol
fs/bcachefs/fsck.c:1703:45: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] d_child_subvol @@ got unsigned int [usertype] bi_subvol @@
fs/bcachefs/fsck.c:1703:45: sparse: expected restricted __le32 [usertype] d_child_subvol
fs/bcachefs/fsck.c:1703:45: sparse: got unsigned int [usertype] bi_subvol
fs/bcachefs/fsck.c:1705:37: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le64 [usertype] d_inum @@ got unsigned long long [usertype] bi_inum @@
fs/bcachefs/fsck.c:1705:37: sparse: expected restricted __le64 [usertype] d_inum
fs/bcachefs/fsck.c:1705:37: sparse: got unsigned long long [usertype] bi_inum
>> fs/bcachefs/fsck.c:1812:39: sparse: sparse: cast to restricted __le32
>> fs/bcachefs/fsck.c:1812:37: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] fs_path_parent @@ got unsigned int [usertype] @@
fs/bcachefs/fsck.c:1812:37: sparse: expected restricted __le32 [usertype] fs_path_parent
fs/bcachefs/fsck.c:1812:37: sparse: got unsigned int [usertype]
vim +1812 fs/bcachefs/fsck.c
1671
1672 static int check_dirent_target(struct btree_trans *trans,
1673 struct btree_iter *iter,
1674 struct bkey_s_c_dirent d,
1675 struct bch_inode_unpacked *target,
1676 u32 target_snapshot)
1677 {
1678 struct bch_fs *c = trans->c;
1679 struct bkey_i_dirent *n;
1680 struct printbuf buf = PRINTBUF;
1681 int ret = 0;
1682
1683 ret = check_dirent_inode_dirent(trans, iter, d, target, target_snapshot);
1684 if (ret)
1685 goto err;
1686
1687 if (fsck_err_on(d.v->d_type != inode_d_type(target),
1688 c, dirent_d_type_wrong,
1689 "incorrect d_type: got %s, should be %s:\n%s",
1690 bch2_d_type_str(d.v->d_type),
1691 bch2_d_type_str(inode_d_type(target)),
1692 (printbuf_reset(&buf),
1693 bch2_bkey_val_to_text(&buf, c, d.s_c), buf.buf))) {
1694 n = bch2_trans_kmalloc(trans, bkey_bytes(d.k));
1695 ret = PTR_ERR_OR_ZERO(n);
1696 if (ret)
1697 goto err;
1698
1699 bkey_reassemble(&n->k_i, d.s_c);
1700 n->v.d_type = inode_d_type(target);
1701 if (n->v.d_type == DT_SUBVOL) {
> 1702 n->v.d_parent_subvol = target->bi_parent_subvol;
1703 n->v.d_child_subvol = target->bi_subvol;
1704 } else {
1705 n->v.d_inum = target->bi_inum;
1706 }
1707
1708 ret = bch2_trans_update(trans, iter, &n->k_i, 0);
1709 if (ret)
1710 goto err;
1711
1712 d = dirent_i_to_s_c(n);
1713 }
1714 err:
1715 fsck_err:
1716 printbuf_exit(&buf);
1717 bch_err_fn(c, ret);
1718 return ret;
1719 }
1720
1721 /* find a subvolume that's a descendent of @snapshot: */
1722 static int find_snapshot_subvol(struct btree_trans *trans, u32 snapshot, u32 *subvolid)
1723 {
1724 struct btree_iter iter;
1725 struct bkey_s_c k;
1726 int ret;
1727
1728 for_each_btree_key_norestart(trans, iter, BTREE_ID_subvolumes, POS_MIN, 0, k, ret) {
1729 if (k.k->type != KEY_TYPE_subvolume)
1730 continue;
1731
1732 struct bkey_s_c_subvolume s = bkey_s_c_to_subvolume(k);
1733 if (bch2_snapshot_is_ancestor(trans->c, le32_to_cpu(s.v->snapshot), snapshot)) {
1734 bch2_trans_iter_exit(trans, &iter);
1735 *subvolid = k.k->p.offset;
1736 goto found;
1737 }
1738 }
1739 if (!ret)
1740 ret = -ENOENT;
1741 found:
1742 bch2_trans_iter_exit(trans, &iter);
1743 return ret;
1744 }
1745
1746 static int check_dirent_to_subvol(struct btree_trans *trans, struct btree_iter *iter,
1747 struct bkey_s_c_dirent d)
1748 {
1749 struct bch_fs *c = trans->c;
1750 struct btree_iter subvol_iter = {};
1751 struct bch_inode_unpacked subvol_root;
1752 u32 parent_subvol = le32_to_cpu(d.v->d_parent_subvol);
1753 u32 target_subvol = le32_to_cpu(d.v->d_child_subvol);
1754 u32 parent_snapshot;
1755 u64 parent_inum;
1756 struct printbuf buf = PRINTBUF;
1757 int ret = 0;
1758
1759 ret = subvol_lookup(trans, parent_subvol, &parent_snapshot, &parent_inum);
1760 if (ret && !bch2_err_matches(ret, ENOENT))
1761 return ret;
1762
1763 if (fsck_err_on(ret, c, dirent_to_missing_parent_subvol,
1764 "dirent parent_subvol points to missing subvolume\n%s",
1765 (bch2_bkey_val_to_text(&buf, c, d.s_c), buf.buf)) ||
1766 fsck_err_on(!ret && !bch2_snapshot_is_ancestor(c, parent_snapshot, d.k->p.snapshot),
1767 c, dirent_not_visible_in_parent_subvol,
1768 "dirent not visible in parent_subvol (not an ancestor of subvol snap %u)\n%s",
1769 parent_snapshot,
1770 (bch2_bkey_val_to_text(&buf, c, d.s_c), buf.buf))) {
1771 u32 new_parent_subvol;
1772 ret = find_snapshot_subvol(trans, d.k->p.snapshot, &new_parent_subvol);
1773 if (ret)
1774 goto err;
1775
1776 struct bkey_i_dirent *new_dirent = bch2_bkey_make_mut_typed(trans, iter, &d.s_c, 0, dirent);
1777 ret = PTR_ERR_OR_ZERO(new_dirent);
1778 if (ret)
1779 goto err;
1780
1781 new_dirent->v.d_parent_subvol = cpu_to_le32(new_parent_subvol);
1782 }
1783
1784 struct bkey_s_c_subvolume s =
1785 bch2_bkey_get_iter_typed(trans, &subvol_iter,
1786 BTREE_ID_subvolumes, POS(0, target_subvol),
1787 0, subvolume);
1788 ret = bkey_err(s.s_c);
1789 if (ret && !bch2_err_matches(ret, ENOENT))
1790 return ret;
1791
1792 if (ret) {
1793 if (fsck_err(c, dirent_to_missing_subvol,
1794 "dirent points to missing subvolume\n%s",
1795 (bch2_bkey_val_to_text(&buf, c, d.s_c), buf.buf)))
1796 return __remove_dirent(trans, d.k->p);
1797 ret = 0;
1798 goto out;
1799 }
1800
1801 if (fsck_err_on(le32_to_cpu(s.v->fs_path_parent) != parent_subvol,
1802 c, subvol_fs_path_parent_wrong,
1803 "subvol with wrong fs_path_parent, should be be %u\n%s",
1804 parent_subvol,
1805 (bch2_bkey_val_to_text(&buf, c, s.s_c), buf.buf))) {
1806 struct bkey_i_subvolume *n =
1807 bch2_bkey_make_mut_typed(trans, &subvol_iter, &s.s_c, 0, subvolume);
1808 ret = PTR_ERR_OR_ZERO(n);
1809 if (ret)
1810 goto err;
1811
> 1812 n->v.fs_path_parent = le32_to_cpu(parent_subvol);
1813 }
1814
1815 u64 target_inum = le64_to_cpu(s.v->inode);
1816 u32 target_snapshot = le32_to_cpu(s.v->snapshot);
1817
1818 ret = lookup_inode(trans, target_inum, &subvol_root, &target_snapshot);
1819 if (ret && !bch2_err_matches(ret, ENOENT))
1820 return ret;
1821
1822 if (fsck_err_on(parent_subvol != subvol_root.bi_parent_subvol,
1823 c, inode_bi_parent_wrong,
1824 "subvol root %llu has wrong bi_parent_subvol: got %u, should be %u",
1825 target_inum,
1826 subvol_root.bi_parent_subvol, parent_subvol)) {
1827 subvol_root.bi_parent_subvol = parent_subvol;
1828 ret = __bch2_fsck_write_inode(trans, &subvol_root, target_snapshot);
1829 if (ret)
1830 return ret;
1831 }
1832
1833 ret = check_dirent_target(trans, iter, d, &subvol_root,
1834 target_snapshot);
1835 if (ret)
1836 return ret;
1837 out:
1838 err:
1839 fsck_err:
1840 bch2_trans_iter_exit(trans, &subvol_iter);
1841 printbuf_exit(&buf);
1842 return ret;
1843 }
1844
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
reply other threads:[~2024-02-10 19:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202402110322.zn654S7e-lkp@intel.com \
--to=lkp@intel.com \
--cc=kent.overstreet@linux.dev \
--cc=oe-kbuild-all@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.