* [ext4:dev 40/42] fs/jbd2/journal.c:1718 __jbd2_journal_erase() warn: maybe use && instead of &
@ 2021-06-07 10:24 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2021-06-06 20:44 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 9185 bytes --]
CC: kbuild-all(a)lists.01.org
CC: linux-ext4(a)vger.kernel.org
TO: Leah Rumancik <leah.rumancik@gmail.com>
CC: "Theodore Ts'o" <tytso@mit.edu>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
head: a492dedb708d287aac857c6799f6f364f3d914b3
commit: 84ed553af7e5c8f3f3de0160ba7eaabcab8b9f7b [40/42] ext4: add discard/zeroout flags to journal flush
:::::: branch date: 6 hours ago
:::::: commit date: 6 hours ago
config: arm-randconfig-m031-20210604 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
fs/jbd2/journal.c:1718 __jbd2_journal_erase() warn: maybe use && instead of &
vim +1718 fs/jbd2/journal.c
470decc613ab20 Dave Kleikamp 2006-10-11 1688
84ed553af7e5c8 Leah Rumancik 2021-05-18 1689 /**
84ed553af7e5c8 Leah Rumancik 2021-05-18 1690 * __jbd2_journal_erase() - Discard or zeroout journal blocks (excluding superblock)
84ed553af7e5c8 Leah Rumancik 2021-05-18 1691 * @journal: The journal to erase.
84ed553af7e5c8 Leah Rumancik 2021-05-18 1692 * @flags: A discard/zeroout request is sent for each physically contigous
84ed553af7e5c8 Leah Rumancik 2021-05-18 1693 * region of the journal. Either JBD2_JOURNAL_FLUSH_DISCARD or
84ed553af7e5c8 Leah Rumancik 2021-05-18 1694 * JBD2_JOURNAL_FLUSH_ZEROOUT must be set to determine which operation
84ed553af7e5c8 Leah Rumancik 2021-05-18 1695 * to perform.
84ed553af7e5c8 Leah Rumancik 2021-05-18 1696 *
84ed553af7e5c8 Leah Rumancik 2021-05-18 1697 * Note: JBD2_JOURNAL_FLUSH_ZEROOUT attempts to use hardware offload. Zeroes
84ed553af7e5c8 Leah Rumancik 2021-05-18 1698 * will be explicitly written if no hardware offload is available, see
84ed553af7e5c8 Leah Rumancik 2021-05-18 1699 * blkdev_issue_zeroout for more details.
84ed553af7e5c8 Leah Rumancik 2021-05-18 1700 */
84ed553af7e5c8 Leah Rumancik 2021-05-18 1701 static int __jbd2_journal_erase(journal_t *journal, unsigned int flags)
84ed553af7e5c8 Leah Rumancik 2021-05-18 1702 {
84ed553af7e5c8 Leah Rumancik 2021-05-18 1703 int err = 0;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1704 unsigned long block, log_offset; /* logical */
84ed553af7e5c8 Leah Rumancik 2021-05-18 1705 unsigned long long phys_block, block_start, block_stop; /* physical */
84ed553af7e5c8 Leah Rumancik 2021-05-18 1706 loff_t byte_start, byte_stop, byte_count;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1707 struct request_queue *q = bdev_get_queue(journal->j_dev);
84ed553af7e5c8 Leah Rumancik 2021-05-18 1708
84ed553af7e5c8 Leah Rumancik 2021-05-18 1709 /* flags must be set to either discard or zeroout */
84ed553af7e5c8 Leah Rumancik 2021-05-18 1710 if ((flags & ~JBD2_JOURNAL_FLUSH_VALID) || !flags ||
84ed553af7e5c8 Leah Rumancik 2021-05-18 1711 ((flags & JBD2_JOURNAL_FLUSH_DISCARD) &&
84ed553af7e5c8 Leah Rumancik 2021-05-18 1712 (flags & JBD2_JOURNAL_FLUSH_ZEROOUT)))
84ed553af7e5c8 Leah Rumancik 2021-05-18 1713 return -EINVAL;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1714
84ed553af7e5c8 Leah Rumancik 2021-05-18 1715 if (!q)
84ed553af7e5c8 Leah Rumancik 2021-05-18 1716 return -ENXIO;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1717
84ed553af7e5c8 Leah Rumancik 2021-05-18 @1718 if (JBD2_JOURNAL_FLUSH_DISCARD & !blk_queue_discard(q))
84ed553af7e5c8 Leah Rumancik 2021-05-18 1719 return -EOPNOTSUPP;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1720
84ed553af7e5c8 Leah Rumancik 2021-05-18 1721 /*
84ed553af7e5c8 Leah Rumancik 2021-05-18 1722 * lookup block mapping and issue discard/zeroout for each
84ed553af7e5c8 Leah Rumancik 2021-05-18 1723 * contiguous region
84ed553af7e5c8 Leah Rumancik 2021-05-18 1724 */
84ed553af7e5c8 Leah Rumancik 2021-05-18 1725 log_offset = be32_to_cpu(journal->j_superblock->s_first);
84ed553af7e5c8 Leah Rumancik 2021-05-18 1726 block_start = ~0ULL;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1727 for (block = log_offset; block < journal->j_total_len; block++) {
84ed553af7e5c8 Leah Rumancik 2021-05-18 1728 err = jbd2_journal_bmap(journal, block, &phys_block);
84ed553af7e5c8 Leah Rumancik 2021-05-18 1729 if (err) {
84ed553af7e5c8 Leah Rumancik 2021-05-18 1730 pr_err("JBD2: bad block at offset %lu", block);
84ed553af7e5c8 Leah Rumancik 2021-05-18 1731 return err;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1732 }
84ed553af7e5c8 Leah Rumancik 2021-05-18 1733
84ed553af7e5c8 Leah Rumancik 2021-05-18 1734 if (block_start == ~0ULL) {
84ed553af7e5c8 Leah Rumancik 2021-05-18 1735 block_start = phys_block;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1736 block_stop = block_start - 1;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1737 }
84ed553af7e5c8 Leah Rumancik 2021-05-18 1738
84ed553af7e5c8 Leah Rumancik 2021-05-18 1739 /*
84ed553af7e5c8 Leah Rumancik 2021-05-18 1740 * last block not contiguous with current block,
84ed553af7e5c8 Leah Rumancik 2021-05-18 1741 * process last contiguous region and return to this block on
84ed553af7e5c8 Leah Rumancik 2021-05-18 1742 * next loop
84ed553af7e5c8 Leah Rumancik 2021-05-18 1743 */
84ed553af7e5c8 Leah Rumancik 2021-05-18 1744 if (phys_block != block_stop + 1) {
84ed553af7e5c8 Leah Rumancik 2021-05-18 1745 block--;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1746 } else {
84ed553af7e5c8 Leah Rumancik 2021-05-18 1747 block_stop++;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1748 /*
84ed553af7e5c8 Leah Rumancik 2021-05-18 1749 * if this isn't the last block of journal,
84ed553af7e5c8 Leah Rumancik 2021-05-18 1750 * no need to process now because next block may also
84ed553af7e5c8 Leah Rumancik 2021-05-18 1751 * be part of this contiguous region
84ed553af7e5c8 Leah Rumancik 2021-05-18 1752 */
84ed553af7e5c8 Leah Rumancik 2021-05-18 1753 if (block != journal->j_total_len - 1)
84ed553af7e5c8 Leah Rumancik 2021-05-18 1754 continue;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1755 }
84ed553af7e5c8 Leah Rumancik 2021-05-18 1756
84ed553af7e5c8 Leah Rumancik 2021-05-18 1757 /*
84ed553af7e5c8 Leah Rumancik 2021-05-18 1758 * end of contiguous region or this is last block of journal,
84ed553af7e5c8 Leah Rumancik 2021-05-18 1759 * take care of the region
84ed553af7e5c8 Leah Rumancik 2021-05-18 1760 */
84ed553af7e5c8 Leah Rumancik 2021-05-18 1761 byte_start = block_start * journal->j_blocksize;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1762 byte_stop = block_stop * journal->j_blocksize;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1763 byte_count = (block_stop - block_start + 1) *
84ed553af7e5c8 Leah Rumancik 2021-05-18 1764 journal->j_blocksize;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1765
84ed553af7e5c8 Leah Rumancik 2021-05-18 1766 truncate_inode_pages_range(journal->j_dev->bd_inode->i_mapping,
84ed553af7e5c8 Leah Rumancik 2021-05-18 1767 byte_start, byte_stop);
84ed553af7e5c8 Leah Rumancik 2021-05-18 1768
84ed553af7e5c8 Leah Rumancik 2021-05-18 1769 if (flags & JBD2_JOURNAL_FLUSH_DISCARD) {
84ed553af7e5c8 Leah Rumancik 2021-05-18 1770 err = blkdev_issue_discard(journal->j_dev,
84ed553af7e5c8 Leah Rumancik 2021-05-18 1771 byte_start >> SECTOR_SHIFT,
84ed553af7e5c8 Leah Rumancik 2021-05-18 1772 byte_count >> SECTOR_SHIFT,
84ed553af7e5c8 Leah Rumancik 2021-05-18 1773 GFP_NOFS, 0);
84ed553af7e5c8 Leah Rumancik 2021-05-18 1774 } else if (flags & JBD2_JOURNAL_FLUSH_ZEROOUT) {
84ed553af7e5c8 Leah Rumancik 2021-05-18 1775 err = blkdev_issue_zeroout(journal->j_dev,
84ed553af7e5c8 Leah Rumancik 2021-05-18 1776 byte_start >> SECTOR_SHIFT,
84ed553af7e5c8 Leah Rumancik 2021-05-18 1777 byte_count >> SECTOR_SHIFT,
84ed553af7e5c8 Leah Rumancik 2021-05-18 1778 GFP_NOFS, 0);
84ed553af7e5c8 Leah Rumancik 2021-05-18 1779 }
84ed553af7e5c8 Leah Rumancik 2021-05-18 1780
84ed553af7e5c8 Leah Rumancik 2021-05-18 1781 if (unlikely(err != 0)) {
84ed553af7e5c8 Leah Rumancik 2021-05-18 1782 pr_err("JBD2: (error %d) unable to wipe journal at physical blocks %llu - %llu",
84ed553af7e5c8 Leah Rumancik 2021-05-18 1783 err, block_start, block_stop);
84ed553af7e5c8 Leah Rumancik 2021-05-18 1784 return err;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1785 }
84ed553af7e5c8 Leah Rumancik 2021-05-18 1786
84ed553af7e5c8 Leah Rumancik 2021-05-18 1787 /* reset start and stop after processing a region */
84ed553af7e5c8 Leah Rumancik 2021-05-18 1788 block_start = ~0ULL;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1789 }
84ed553af7e5c8 Leah Rumancik 2021-05-18 1790
84ed553af7e5c8 Leah Rumancik 2021-05-18 1791 return blkdev_issue_flush(journal->j_dev);
84ed553af7e5c8 Leah Rumancik 2021-05-18 1792 }
24bcc89c7e7c64 Jan Kara 2012-03-13 1793
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 40830 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ext4:dev 40/42] fs/jbd2/journal.c:1718 __jbd2_journal_erase() warn: maybe use && instead of &
@ 2021-06-07 10:24 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-06-07 10:24 UTC (permalink / raw)
To: kbuild, Leah Rumancik; +Cc: lkp, kbuild-all, linux-ext4, Theodore Ts'o
tree: https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
head: a492dedb708d287aac857c6799f6f364f3d914b3
commit: 84ed553af7e5c8f3f3de0160ba7eaabcab8b9f7b [40/42] ext4: add discard/zeroout flags to journal flush
config: arm-randconfig-m031-20210604 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
fs/jbd2/journal.c:1718 __jbd2_journal_erase() warn: maybe use && instead of &
vim +1718 fs/jbd2/journal.c
84ed553af7e5c8 Leah Rumancik 2021-05-18 1701 static int __jbd2_journal_erase(journal_t *journal, unsigned int flags)
84ed553af7e5c8 Leah Rumancik 2021-05-18 1702 {
84ed553af7e5c8 Leah Rumancik 2021-05-18 1703 int err = 0;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1704 unsigned long block, log_offset; /* logical */
84ed553af7e5c8 Leah Rumancik 2021-05-18 1705 unsigned long long phys_block, block_start, block_stop; /* physical */
84ed553af7e5c8 Leah Rumancik 2021-05-18 1706 loff_t byte_start, byte_stop, byte_count;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1707 struct request_queue *q = bdev_get_queue(journal->j_dev);
84ed553af7e5c8 Leah Rumancik 2021-05-18 1708
84ed553af7e5c8 Leah Rumancik 2021-05-18 1709 /* flags must be set to either discard or zeroout */
84ed553af7e5c8 Leah Rumancik 2021-05-18 1710 if ((flags & ~JBD2_JOURNAL_FLUSH_VALID) || !flags ||
84ed553af7e5c8 Leah Rumancik 2021-05-18 1711 ((flags & JBD2_JOURNAL_FLUSH_DISCARD) &&
84ed553af7e5c8 Leah Rumancik 2021-05-18 1712 (flags & JBD2_JOURNAL_FLUSH_ZEROOUT)))
84ed553af7e5c8 Leah Rumancik 2021-05-18 1713 return -EINVAL;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1714
84ed553af7e5c8 Leah Rumancik 2021-05-18 1715 if (!q)
84ed553af7e5c8 Leah Rumancik 2021-05-18 1716 return -ENXIO;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1717
84ed553af7e5c8 Leah Rumancik 2021-05-18 @1718 if (JBD2_JOURNAL_FLUSH_DISCARD & !blk_queue_discard(q))
JBD2_JOURNAL_FLUSH_DISCARD is 1 so this works, but probably && was
intended.
Using && should be a little bit faster. blk_queue_discard() is just a
wrapper around test_bit() so it doesn't have side effects.
84ed553af7e5c8 Leah Rumancik 2021-05-18 1719 return -EOPNOTSUPP;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1720
84ed553af7e5c8 Leah Rumancik 2021-05-18 1721 /*
84ed553af7e5c8 Leah Rumancik 2021-05-18 1722 * lookup block mapping and issue discard/zeroout for each
84ed553af7e5c8 Leah Rumancik 2021-05-18 1723 * contiguous region
84ed553af7e5c8 Leah Rumancik 2021-05-18 1724 */
84ed553af7e5c8 Leah Rumancik 2021-05-18 1725 log_offset = be32_to_cpu(journal->j_superblock->s_first);
84ed553af7e5c8 Leah Rumancik 2021-05-18 1726 block_start = ~0ULL;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1727 for (block = log_offset; block < journal->j_total_len; block++) {
84ed553af7e5c8 Leah Rumancik 2021-05-18 1728 err = jbd2_journal_bmap(journal, block, &phys_block);
84ed553af7e5c8 Leah Rumancik 2021-05-18 1729 if (err) {
84ed553af7e5c8 Leah Rumancik 2021-05-18 1730 pr_err("JBD2: bad block at offset %lu", block);
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ext4:dev 40/42] fs/jbd2/journal.c:1718 __jbd2_journal_erase() warn: maybe use && instead of &
@ 2021-06-07 10:24 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-06-07 10:24 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 3406 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
head: a492dedb708d287aac857c6799f6f364f3d914b3
commit: 84ed553af7e5c8f3f3de0160ba7eaabcab8b9f7b [40/42] ext4: add discard/zeroout flags to journal flush
config: arm-randconfig-m031-20210604 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
fs/jbd2/journal.c:1718 __jbd2_journal_erase() warn: maybe use && instead of &
vim +1718 fs/jbd2/journal.c
84ed553af7e5c8 Leah Rumancik 2021-05-18 1701 static int __jbd2_journal_erase(journal_t *journal, unsigned int flags)
84ed553af7e5c8 Leah Rumancik 2021-05-18 1702 {
84ed553af7e5c8 Leah Rumancik 2021-05-18 1703 int err = 0;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1704 unsigned long block, log_offset; /* logical */
84ed553af7e5c8 Leah Rumancik 2021-05-18 1705 unsigned long long phys_block, block_start, block_stop; /* physical */
84ed553af7e5c8 Leah Rumancik 2021-05-18 1706 loff_t byte_start, byte_stop, byte_count;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1707 struct request_queue *q = bdev_get_queue(journal->j_dev);
84ed553af7e5c8 Leah Rumancik 2021-05-18 1708
84ed553af7e5c8 Leah Rumancik 2021-05-18 1709 /* flags must be set to either discard or zeroout */
84ed553af7e5c8 Leah Rumancik 2021-05-18 1710 if ((flags & ~JBD2_JOURNAL_FLUSH_VALID) || !flags ||
84ed553af7e5c8 Leah Rumancik 2021-05-18 1711 ((flags & JBD2_JOURNAL_FLUSH_DISCARD) &&
84ed553af7e5c8 Leah Rumancik 2021-05-18 1712 (flags & JBD2_JOURNAL_FLUSH_ZEROOUT)))
84ed553af7e5c8 Leah Rumancik 2021-05-18 1713 return -EINVAL;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1714
84ed553af7e5c8 Leah Rumancik 2021-05-18 1715 if (!q)
84ed553af7e5c8 Leah Rumancik 2021-05-18 1716 return -ENXIO;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1717
84ed553af7e5c8 Leah Rumancik 2021-05-18 @1718 if (JBD2_JOURNAL_FLUSH_DISCARD & !blk_queue_discard(q))
JBD2_JOURNAL_FLUSH_DISCARD is 1 so this works, but probably && was
intended.
Using && should be a little bit faster. blk_queue_discard() is just a
wrapper around test_bit() so it doesn't have side effects.
84ed553af7e5c8 Leah Rumancik 2021-05-18 1719 return -EOPNOTSUPP;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1720
84ed553af7e5c8 Leah Rumancik 2021-05-18 1721 /*
84ed553af7e5c8 Leah Rumancik 2021-05-18 1722 * lookup block mapping and issue discard/zeroout for each
84ed553af7e5c8 Leah Rumancik 2021-05-18 1723 * contiguous region
84ed553af7e5c8 Leah Rumancik 2021-05-18 1724 */
84ed553af7e5c8 Leah Rumancik 2021-05-18 1725 log_offset = be32_to_cpu(journal->j_superblock->s_first);
84ed553af7e5c8 Leah Rumancik 2021-05-18 1726 block_start = ~0ULL;
84ed553af7e5c8 Leah Rumancik 2021-05-18 1727 for (block = log_offset; block < journal->j_total_len; block++) {
84ed553af7e5c8 Leah Rumancik 2021-05-18 1728 err = jbd2_journal_bmap(journal, block, &phys_block);
84ed553af7e5c8 Leah Rumancik 2021-05-18 1729 if (err) {
84ed553af7e5c8 Leah Rumancik 2021-05-18 1730 pr_err("JBD2: bad block at offset %lu", block);
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-06-07 10:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-06 20:44 [ext4:dev 40/42] fs/jbd2/journal.c:1718 __jbd2_journal_erase() warn: maybe use && instead of & kernel test robot
2021-06-07 10:24 ` Dan Carpenter
2021-06-07 10:24 ` Dan Carpenter
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.