[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <202108150616.qdFLurea-lkp@intel.com>
Date: Sun, 15 Aug 2021 06:38:55 +0800
From: kernel test robot <lkp@...el.com>
To: Yangtao Li <frank.li@...o.com>, jaegeuk@...nel.org, chao@...nel.org
Cc: clang-built-linux@...glegroups.com, kbuild-all@...ts.01.org,
linux-f2fs-devel@...ts.sourceforge.net,
linux-kernel@...r.kernel.org,
Fengnan Chang <changfengnan@...o.com>,
Yangtao Li <frank.li@...o.com>
Subject: Re: [PATCH v2] f2fs: Don't create discard thread when device not
support realtime discard
Hi Yangtao,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on f2fs/dev-test]
[also build test WARNING on next-20210813]
[cannot apply to v5.14-rc5]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Yangtao-Li/f2fs-Don-t-create-discard-thread-when-device-not-support-realtime-discard/20210813-181309
base: https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
config: x86_64-randconfig-c001-20210813 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 62df4df41c939205b2dc0a2a3bfb75b8c1ed74fa)
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
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/409d152775702fc2af3b9d97d01fe8240ba6da7b
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Yangtao-Li/f2fs-Don-t-create-discard-thread-when-device-not-support-realtime-discard/20210813-181309
git checkout 409d152775702fc2af3b9d97d01fe8240ba6da7b
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
clang-analyzer warnings: (new ones prefixed by >>)
^
net/ipv6/raw.c:936:2: note: Taking true branch
if (ipc6.dontfrag < 0)
^
net/ipv6/raw.c:939:6: note: Assuming the condition is false
if (msg->msg_flags&MSG_CONFIRM)
^~~~~~~~~~~~~~~~~~~~~~~~~~
net/ipv6/raw.c:939:2: note: Taking false branch
if (msg->msg_flags&MSG_CONFIRM)
^
net/ipv6/raw.c:943:6: note: 'hdrincl' is 0
if (hdrincl)
^~~~~~~
net/ipv6/raw.c:943:2: note: Taking false branch
if (hdrincl)
^
net/ipv6/raw.c:953:7: note: Assuming 'err' is 0
if (err)
^~~
net/ipv6/raw.c:953:3: note: Taking false branch
if (err)
^
net/ipv6/raw.c:955:12: note: Assuming the condition is true
else if (!(msg->msg_flags & MSG_MORE))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
net/ipv6/raw.c:955:8: note: Taking true branch
else if (!(msg->msg_flags & MSG_MORE))
^
net/ipv6/raw.c:956:10: note: Calling 'rawv6_push_pending_frames'
err = rawv6_push_pending_frames(sk, &fl6, rp);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
net/ipv6/raw.c:550:6: note: Assuming field 'checksum' is not equal to 0
if (!rp->checksum)
^~~~~~~~~~~~~
net/ipv6/raw.c:550:2: note: Taking false branch
if (!rp->checksum)
^
net/ipv6/raw.c:553:8: note: Calling 'skb_peek'
skb = skb_peek(&sk->sk_write_queue);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/skbuff.h:1803:6: note: Assuming 'skb' is not equal to 'list_'
if (skb == (struct sk_buff *)list_)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/skbuff.h:1803:2: note: Taking false branch
if (skb == (struct sk_buff *)list_)
^
include/linux/skbuff.h:1805:2: note: Returning pointer (loaded from 'skb'), which participates in a condition later
return skb;
^~~~~~~~~~
net/ipv6/raw.c:553:8: note: Returning from 'skb_peek'
skb = skb_peek(&sk->sk_write_queue);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
net/ipv6/raw.c:554:6: note: Assuming 'skb' is non-null
if (!skb)
^~~~
net/ipv6/raw.c:554:2: note: Taking false branch
if (!skb)
^
net/ipv6/raw.c:559:6: note: Assuming the condition is false
if (offset >= total_len - 1) {
^~~~~~~~~~~~~~~~~~~~~~~
net/ipv6/raw.c:559:2: note: Taking false branch
if (offset >= total_len - 1) {
^
net/ipv6/raw.c:566:6: note: Assuming the condition is false
if (skb_queue_len(&sk->sk_write_queue) == 1) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
net/ipv6/raw.c:566:2: note: Taking false branch
if (skb_queue_len(&sk->sk_write_queue) == 1) {
^
net/ipv6/raw.c:572:3: note: 'csum_skb' initialized to a null pointer value
struct sk_buff *csum_skb = NULL;
^~~~~~~~~~~~~~~~~~~~~~~~
net/ipv6/raw.c:575:3: note: Loop condition is false. Execution continues on line 590
skb_queue_walk(&sk->sk_write_queue, skb) {
^
include/linux/skbuff.h:3532:3: note: expanded from macro 'skb_queue_walk'
for (skb = (queue)->next; \
^
net/ipv6/raw.c:590:3: note: Null pointer value stored to 'skb'
skb = csum_skb;
^~~~~~~~~~~~~~
net/ipv6/raw.c:593:33: note: Passing null pointer value via 1st parameter 'skb'
offset += skb_transport_offset(skb);
^~~
net/ipv6/raw.c:593:12: note: Calling 'skb_transport_offset'
offset += skb_transport_offset(skb);
^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/skbuff.h:2633:30: note: Passing null pointer value via 1st parameter 'skb'
return skb_transport_header(skb) - skb->data;
^~~
include/linux/skbuff.h:2633:9: note: Calling 'skb_transport_header'
return skb_transport_header(skb) - skb->data;
^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/skbuff.h:2527:9: note: Access to field 'head' results in a dereference of a null pointer (loaded from variable 'skb')
return skb->head + skb->transport_header;
^~~
Suppressed 12 warnings (12 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
12 warnings generated.
>> fs/f2fs/segment.c:2139:8: warning: Value stored to 'dev' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
dev_t dev = sbi->sb->s_bdev->bd_dev;
^~~ ~~~~~~~~~~~~~~~~~~~~~~~
fs/f2fs/segment.c:2139:8: note: Value stored to 'dev' during its initialization is never read
dev_t dev = sbi->sb->s_bdev->bd_dev;
^~~ ~~~~~~~~~~~~~~~~~~~~~~~
>> fs/f2fs/segment.c:2144:3: warning: Value stored to 'dcc' is never read [clang-analyzer-deadcode.DeadStores]
dcc = SM_I(sbi)->dcc_info;
^ ~~~~~~~~~~~~~~~~~~~
fs/f2fs/segment.c:2144:3: note: Value stored to 'dcc' is never read
dcc = SM_I(sbi)->dcc_info;
^ ~~~~~~~~~~~~~~~~~~~
include/linux/math64.h:28:24: warning: Division by zero [clang-analyzer-core.DivideZero]
*remainder = dividend % divisor;
^
fs/f2fs/segment.c:5185:39: note: Calling 'F2FS_RAW_SUPER'
struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
^~~~~~~~~~~~~~~~~~~
fs/f2fs/f2fs.h:1947:2: note: Returning without writing to 'sbi->segs_per_sec'
return (struct f2fs_super_block *)(sbi->raw_super);
^
fs/f2fs/segment.c:5185:39: note: Returning from 'F2FS_RAW_SUPER'
struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
^~~~~~~~~~~~~~~~~~~
fs/f2fs/segment.c:5186:33: note: Calling 'F2FS_CKPT'
struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
^~~~~~~~~~~~~~
fs/f2fs/f2fs.h:1952:2: note: Returning without writing to 'sbi->segs_per_sec'
return (struct f2fs_checkpoint *)(sbi->ckpt);
^
fs/f2fs/segment.c:5186:33: note: Returning from 'F2FS_CKPT'
struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
^~~~~~~~~~~~~~
fs/f2fs/segment.c:5190:12: note: Calling 'f2fs_kzalloc'
sm_info = f2fs_kzalloc(sbi, sizeof(struct f2fs_sm_info), GFP_KERNEL);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/f2fs/f2fs.h:3227:9: note: Calling 'f2fs_kmalloc'
return f2fs_kmalloc(sbi, size, flags | __GFP_ZERO);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/f2fs/f2fs.h:3216:6: note: Calling 'time_to_inject'
if (time_to_inject(sbi, FAULT_KMALLOC)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/f2fs/f2fs.h:1813:6: note: Assuming field 'inject_rate' is not equal to 0
if (!ffi->inject_rate)
^~~~~~~~~~~~~~~~~
fs/f2fs/f2fs.h:1813:2: note: Taking false branch
if (!ffi->inject_rate)
^
fs/f2fs/f2fs.h:1816:6: note: Assuming the condition is false
if (!IS_FAULT_SET(ffi, type))
^~~~~~~~~~~~~~~~~~~~~~~~
fs/f2fs/f2fs.h:1816:2: note: Taking false branch
if (!IS_FAULT_SET(ffi, type))
^
fs/f2fs/f2fs.h:1820:6: note: Assuming the condition is false
if (atomic_read(&ffi->inject_ops) >= ffi->inject_rate) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/f2fs/f2fs.h:1820:2: note: Taking false branch
if (atomic_read(&ffi->inject_ops) >= ffi->inject_rate) {
^
fs/f2fs/f2fs.h:1824:2: note: Returning without writing to 'sbi->segs_per_sec'
return false;
^
fs/f2fs/f2fs.h:3216:6: note: Returning from 'time_to_inject'
if (time_to_inject(sbi, FAULT_KMALLOC)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/f2fs/f2fs.h:3216:2: note: Taking false branch
if (time_to_inject(sbi, FAULT_KMALLOC)) {
^
fs/f2fs/f2fs.h:3221:2: note: Returning without writing to 'sbi->segs_per_sec'
return kmalloc(size, flags);
^
fs/f2fs/f2fs.h:3227:9: note: Returning from 'f2fs_kmalloc'
return f2fs_kmalloc(sbi, size, flags | __GFP_ZERO);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/f2fs/f2fs.h:3227:2: note: Returning without writing to 'sbi->segs_per_sec'
return f2fs_kmalloc(sbi, size, flags | __GFP_ZERO);
^
fs/f2fs/segment.c:5190:12: note: Returning from 'f2fs_kzalloc'
sm_info = f2fs_kzalloc(sbi, sizeof(struct f2fs_sm_info), GFP_KERNEL);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/f2fs/segment.c:5191:6: note: Assuming 'sm_info' is non-null
if (!sm_info)
^~~~~~~~
fs/f2fs/segment.c:5191:2: note: Taking false branch
if (!sm_info)
^
fs/f2fs/segment.c:5205:6: note: Assuming field 'rec_prefree_segments' is <= DEF_MAX_RECLAIM_PREFREE_SEGMENTS
if (sm_info->rec_prefree_segments > DEF_MAX_RECLAIM_PREFREE_SEGMENTS)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/f2fs/segment.c:5205:2: note: Taking false branch
if (sm_info->rec_prefree_segments > DEF_MAX_RECLAIM_PREFREE_SEGMENTS)
^
fs/f2fs/segment.c:5208:7: note: Calling 'f2fs_lfs_mode'
if (!f2fs_lfs_mode(sbi))
^~~~~~~~~~~~~~~~~~
fs/f2fs/f2fs.h:4412:9: note: Assuming field 'fs_mode' is not equal to FS_MODE_LFS
return F2FS_OPTION(sbi).fs_mode == FS_MODE_LFS;
^
fs/f2fs/f2fs.h:105:26: note: expanded from macro 'F2FS_OPTION'
#define F2FS_OPTION(sbi) ((sbi)->mount_opt)
^
fs/f2fs/f2fs.h:4412:2: note: Returning without writing to 'sbi->segs_per_sec'
return F2FS_OPTION(sbi).fs_mode == FS_MODE_LFS;
^
fs/f2fs/segment.c:5208:7: note: Returning from 'f2fs_lfs_mode'
if (!f2fs_lfs_mode(sbi))
vim +/dev +2139 fs/f2fs/segment.c
351df4b2011573 Jaegeuk Kim 2012-11-02 2008
4d57b86dd86404 Chao Yu 2018-05-30 2009 void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi,
4d57b86dd86404 Chao Yu 2018-05-30 2010 struct cp_control *cpc)
351df4b2011573 Jaegeuk Kim 2012-11-02 2011 {
969d1b180d987c Chao Yu 2017-08-07 2012 struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
969d1b180d987c Chao Yu 2017-08-07 2013 struct list_head *head = &dcc->entry_list;
2d7b822ad9daf0 Chao Yu 2014-03-29 2014 struct discard_entry *entry, *this;
351df4b2011573 Jaegeuk Kim 2012-11-02 2015 struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
29e59c14ae5c21 Changman Lee 2013-11-11 2016 unsigned long *prefree_map = dirty_i->dirty_segmap[PRE];
29e59c14ae5c21 Changman Lee 2013-11-11 2017 unsigned int start = 0, end = -1;
36abef4e796d38 Jaegeuk Kim 2016-06-03 2018 unsigned int secno, start_segno;
c473f1a9658b6c Chao Yu 2017-04-27 2019 bool force = (cpc->reason & CP_DISCARD);
4f993264fe2965 Chao Yu 2021-08-03 2020 bool section_alignment = F2FS_OPTION(sbi).discard_unit ==
4f993264fe2965 Chao Yu 2021-08-03 2021 DISCARD_UNIT_SECTION;
4f993264fe2965 Chao Yu 2021-08-03 2022
4f993264fe2965 Chao Yu 2021-08-03 2023 if (f2fs_lfs_mode(sbi) && __is_large_section(sbi))
4f993264fe2965 Chao Yu 2021-08-03 2024 section_alignment = true;
351df4b2011573 Jaegeuk Kim 2012-11-02 2025
351df4b2011573 Jaegeuk Kim 2012-11-02 2026 mutex_lock(&dirty_i->seglist_lock);
29e59c14ae5c21 Changman Lee 2013-11-11 2027
351df4b2011573 Jaegeuk Kim 2012-11-02 2028 while (1) {
29e59c14ae5c21 Changman Lee 2013-11-11 2029 int i;
ad6672bbc52772 Yunlong Song 2018-07-19 2030
4f993264fe2965 Chao Yu 2021-08-03 2031 if (section_alignment && end != -1)
ad6672bbc52772 Yunlong Song 2018-07-19 2032 end--;
7cd8558baa4e45 Jaegeuk Kim 2014-09-23 2033 start = find_next_bit(prefree_map, MAIN_SEGS(sbi), end + 1);
7cd8558baa4e45 Jaegeuk Kim 2014-09-23 2034 if (start >= MAIN_SEGS(sbi))
351df4b2011573 Jaegeuk Kim 2012-11-02 2035 break;
7cd8558baa4e45 Jaegeuk Kim 2014-09-23 2036 end = find_next_zero_bit(prefree_map, MAIN_SEGS(sbi),
7cd8558baa4e45 Jaegeuk Kim 2014-09-23 2037 start + 1);
29e59c14ae5c21 Changman Lee 2013-11-11 2038
4f993264fe2965 Chao Yu 2021-08-03 2039 if (section_alignment) {
ad6672bbc52772 Yunlong Song 2018-07-19 2040 start = rounddown(start, sbi->segs_per_sec);
ad6672bbc52772 Yunlong Song 2018-07-19 2041 end = roundup(end, sbi->segs_per_sec);
ad6672bbc52772 Yunlong Song 2018-07-19 2042 }
29e59c14ae5c21 Changman Lee 2013-11-11 2043
ad6672bbc52772 Yunlong Song 2018-07-19 2044 for (i = start; i < end; i++) {
ad6672bbc52772 Yunlong Song 2018-07-19 2045 if (test_and_clear_bit(i, prefree_map))
ad6672bbc52772 Yunlong Song 2018-07-19 2046 dirty_i->nr_dirty[PRE]--;
ad6672bbc52772 Yunlong Song 2018-07-19 2047 }
351df4b2011573 Jaegeuk Kim 2012-11-02 2048
7d20c8abb2edcf Chao Yu 2018-09-04 2049 if (!f2fs_realtime_discard_enable(sbi))
650d3c4e56e1e9 Yunlei He 2016-12-22 2050 continue;
650d3c4e56e1e9 Yunlei He 2016-12-22 2051
650d3c4e56e1e9 Yunlei He 2016-12-22 2052 if (force && start >= cpc->trim_start &&
650d3c4e56e1e9 Yunlei He 2016-12-22 2053 (end - 1) <= cpc->trim_end)
29e59c14ae5c21 Changman Lee 2013-11-11 2054 continue;
351df4b2011573 Jaegeuk Kim 2012-11-02 2055
b0332a0f957ca8 Chao Yu 2020-02-14 2056 if (!f2fs_lfs_mode(sbi) || !__is_large_section(sbi)) {
37208879108644 Jaegeuk Kim 2013-11-12 2057 f2fs_issue_discard(sbi, START_BLOCK(sbi, start),
37208879108644 Jaegeuk Kim 2013-11-12 2058 (end - start) << sbi->log_blocks_per_seg);
36abef4e796d38 Jaegeuk Kim 2016-06-03 2059 continue;
36abef4e796d38 Jaegeuk Kim 2016-06-03 2060 }
36abef4e796d38 Jaegeuk Kim 2016-06-03 2061 next:
4ddb1a4d4dc206 Jaegeuk Kim 2017-04-07 2062 secno = GET_SEC_FROM_SEG(sbi, start);
4ddb1a4d4dc206 Jaegeuk Kim 2017-04-07 2063 start_segno = GET_SEG_FROM_SEC(sbi, secno);
36abef4e796d38 Jaegeuk Kim 2016-06-03 2064 if (!IS_CURSEC(sbi, secno) &&
302bd34882b1e2 Jaegeuk Kim 2017-04-07 2065 !get_valid_blocks(sbi, start, true))
36abef4e796d38 Jaegeuk Kim 2016-06-03 2066 f2fs_issue_discard(sbi, START_BLOCK(sbi, start_segno),
36abef4e796d38 Jaegeuk Kim 2016-06-03 2067 sbi->segs_per_sec << sbi->log_blocks_per_seg);
36abef4e796d38 Jaegeuk Kim 2016-06-03 2068
36abef4e796d38 Jaegeuk Kim 2016-06-03 2069 start = start_segno + sbi->segs_per_sec;
36abef4e796d38 Jaegeuk Kim 2016-06-03 2070 if (start < end)
36abef4e796d38 Jaegeuk Kim 2016-06-03 2071 goto next;
8b107f5b97772c Jaegeuk Kim 2017-02-27 2072 else
8b107f5b97772c Jaegeuk Kim 2017-02-27 2073 end = start - 1;
351df4b2011573 Jaegeuk Kim 2012-11-02 2074 }
351df4b2011573 Jaegeuk Kim 2012-11-02 2075 mutex_unlock(&dirty_i->seglist_lock);
b29555505d81e4 Jaegeuk Kim 2013-11-12 2076
4f993264fe2965 Chao Yu 2021-08-03 2077 if (!f2fs_block_unit_discard(sbi))
4f993264fe2965 Chao Yu 2021-08-03 2078 goto wakeup;
4f993264fe2965 Chao Yu 2021-08-03 2079
b29555505d81e4 Jaegeuk Kim 2013-11-12 2080 /* send small discards */
2d7b822ad9daf0 Chao Yu 2014-03-29 2081 list_for_each_entry_safe(entry, this, head, list) {
a7eeb823854c4a Chao Yu 2017-03-28 2082 unsigned int cur_pos = 0, next_pos, len, total_len = 0;
a7eeb823854c4a Chao Yu 2017-03-28 2083 bool is_valid = test_bit_le(0, entry->discard_map);
a7eeb823854c4a Chao Yu 2017-03-28 2084
a7eeb823854c4a Chao Yu 2017-03-28 2085 find_next:
a7eeb823854c4a Chao Yu 2017-03-28 2086 if (is_valid) {
a7eeb823854c4a Chao Yu 2017-03-28 2087 next_pos = find_next_zero_bit_le(entry->discard_map,
a7eeb823854c4a Chao Yu 2017-03-28 2088 sbi->blocks_per_seg, cur_pos);
a7eeb823854c4a Chao Yu 2017-03-28 2089 len = next_pos - cur_pos;
a7eeb823854c4a Chao Yu 2017-03-28 2090
7beb01f74415c5 Chao Yu 2018-10-24 2091 if (f2fs_sb_has_blkzoned(sbi) ||
acfd2810c75b06 Damien Le Moal 2017-05-26 2092 (force && len < cpc->trim_minlen))
836b5a6356ac49 Jaegeuk Kim 2015-04-30 2093 goto skip;
a7eeb823854c4a Chao Yu 2017-03-28 2094
a7eeb823854c4a Chao Yu 2017-03-28 2095 f2fs_issue_discard(sbi, entry->start_blkaddr + cur_pos,
a7eeb823854c4a Chao Yu 2017-03-28 2096 len);
a7eeb823854c4a Chao Yu 2017-03-28 2097 total_len += len;
a7eeb823854c4a Chao Yu 2017-03-28 2098 } else {
a7eeb823854c4a Chao Yu 2017-03-28 2099 next_pos = find_next_bit_le(entry->discard_map,
a7eeb823854c4a Chao Yu 2017-03-28 2100 sbi->blocks_per_seg, cur_pos);
a7eeb823854c4a Chao Yu 2017-03-28 2101 }
836b5a6356ac49 Jaegeuk Kim 2015-04-30 2102 skip:
a7eeb823854c4a Chao Yu 2017-03-28 2103 cur_pos = next_pos;
a7eeb823854c4a Chao Yu 2017-03-28 2104 is_valid = !is_valid;
a7eeb823854c4a Chao Yu 2017-03-28 2105
a7eeb823854c4a Chao Yu 2017-03-28 2106 if (cur_pos < sbi->blocks_per_seg)
a7eeb823854c4a Chao Yu 2017-03-28 2107 goto find_next;
a7eeb823854c4a Chao Yu 2017-03-28 2108
af8ff65bb85df3 Chao Yu 2018-04-25 2109 release_discard_addr(entry);
969d1b180d987c Chao Yu 2017-08-07 2110 dcc->nr_discards -= total_len;
b29555505d81e4 Jaegeuk Kim 2013-11-12 2111 }
34e159da418be4 Chao Yu 2017-04-25 2112
4f993264fe2965 Chao Yu 2021-08-03 2113 wakeup:
01983c715ad0e7 Jaegeuk Kim 2017-08-22 2114 wake_up_discard_thread(sbi, false);
351df4b2011573 Jaegeuk Kim 2012-11-02 2115 }
409d152775702f Fengnan Chang 2021-08-13 2116 int f2fs_start_discard_thread(struct f2fs_sb_info *sbi)
409d152775702f Fengnan Chang 2021-08-13 2117 {
409d152775702f Fengnan Chang 2021-08-13 2118 dev_t dev = sbi->sb->s_bdev->bd_dev;
409d152775702f Fengnan Chang 2021-08-13 2119 struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
409d152775702f Fengnan Chang 2021-08-13 2120 int err = 0;
351df4b2011573 Jaegeuk Kim 2012-11-02 2121
409d152775702f Fengnan Chang 2021-08-13 2122 if (!dcc)
409d152775702f Fengnan Chang 2021-08-13 2123 return -EINVAL;
409d152775702f Fengnan Chang 2021-08-13 2124 if (!f2fs_realtime_discard_enable(sbi))
409d152775702f Fengnan Chang 2021-08-13 2125 return 0;
409d152775702f Fengnan Chang 2021-08-13 2126
409d152775702f Fengnan Chang 2021-08-13 2127 dcc->f2fs_issue_discard = kthread_run(issue_discard_thread, sbi,
409d152775702f Fengnan Chang 2021-08-13 2128 "f2fs_discard-%u:%u", MAJOR(dev), MINOR(dev));
409d152775702f Fengnan Chang 2021-08-13 2129 if (IS_ERR(dcc->f2fs_issue_discard)) {
409d152775702f Fengnan Chang 2021-08-13 2130 err = PTR_ERR(dcc->f2fs_issue_discard);
409d152775702f Fengnan Chang 2021-08-13 2131 kfree(dcc);
409d152775702f Fengnan Chang 2021-08-13 2132 SM_I(sbi)->dcc_info = NULL;
409d152775702f Fengnan Chang 2021-08-13 2133 return err;
409d152775702f Fengnan Chang 2021-08-13 2134 }
409d152775702f Fengnan Chang 2021-08-13 2135 return err;
409d152775702f Fengnan Chang 2021-08-13 2136 }
8ed59745520863 Jaegeuk Kim 2017-01-29 2137 static int create_discard_cmd_control(struct f2fs_sb_info *sbi)
0b54fb8458199d Jaegeuk Kim 2017-01-11 2138 {
1546996348b33d Jaegeuk Kim 2017-01-09 @2139 dev_t dev = sbi->sb->s_bdev->bd_dev;
0b54fb8458199d Jaegeuk Kim 2017-01-11 2140 struct discard_cmd_control *dcc;
ba48a33ef6faa5 Chao Yu 2017-04-15 2141 int err = 0, i;
0b54fb8458199d Jaegeuk Kim 2017-01-11 2142
0b54fb8458199d Jaegeuk Kim 2017-01-11 2143 if (SM_I(sbi)->dcc_info) {
0b54fb8458199d Jaegeuk Kim 2017-01-11 @2144 dcc = SM_I(sbi)->dcc_info;
0b54fb8458199d Jaegeuk Kim 2017-01-11 2145 goto init_thread;
0b54fb8458199d Jaegeuk Kim 2017-01-11 2146 }
0b54fb8458199d Jaegeuk Kim 2017-01-11 2147
acbf054d537d7e Chao Yu 2017-11-30 2148 dcc = f2fs_kzalloc(sbi, sizeof(struct discard_cmd_control), GFP_KERNEL);
0b54fb8458199d Jaegeuk Kim 2017-01-11 2149 if (!dcc)
0b54fb8458199d Jaegeuk Kim 2017-01-11 2150 return -ENOMEM;
0b54fb8458199d Jaegeuk Kim 2017-01-11 2151
969d1b180d987c Chao Yu 2017-08-07 2152 dcc->discard_granularity = DEFAULT_DISCARD_GRANULARITY;
4f993264fe2965 Chao Yu 2021-08-03 2153 if (F2FS_OPTION(sbi).discard_unit == DISCARD_UNIT_SEGMENT)
4f993264fe2965 Chao Yu 2021-08-03 2154 dcc->discard_granularity = sbi->blocks_per_seg;
4f993264fe2965 Chao Yu 2021-08-03 2155 else if (F2FS_OPTION(sbi).discard_unit == DISCARD_UNIT_SECTION)
4f993264fe2965 Chao Yu 2021-08-03 2156 dcc->discard_granularity = BLKS_PER_SEC(sbi);
4f993264fe2965 Chao Yu 2021-08-03 2157
46f84c2c058784 Chao Yu 2017-04-15 2158 INIT_LIST_HEAD(&dcc->entry_list);
78997b569f5625 Chao Yu 2017-10-04 2159 for (i = 0; i < MAX_PLIST_NUM; i++)
ba48a33ef6faa5 Chao Yu 2017-04-15 2160 INIT_LIST_HEAD(&dcc->pend_list[i]);
46f84c2c058784 Chao Yu 2017-04-15 2161 INIT_LIST_HEAD(&dcc->wait_list);
8412663d177d95 Chao Yu 2017-10-04 2162 INIT_LIST_HEAD(&dcc->fstrim_list);
1546996348b33d Jaegeuk Kim 2017-01-09 2163 mutex_init(&dcc->cmd_lock);
8b8dd65f72ccbf Chao Yu 2017-03-25 2164 atomic_set(&dcc->issued_discard, 0);
72691af6dbd719 Jaegeuk Kim 2018-12-13 2165 atomic_set(&dcc->queued_discard, 0);
5f32366a29b48b Chao Yu 2017-03-25 2166 atomic_set(&dcc->discard_cmd_cnt, 0);
0b54fb8458199d Jaegeuk Kim 2017-01-11 2167 dcc->nr_discards = 0;
d618ebaf0aa83d Chao Yu 2017-04-25 2168 dcc->max_discards = MAIN_SEGS(sbi) << sbi->log_blocks_per_seg;
d84d1cbdec6b5d Chao Yu 2017-04-18 2169 dcc->undiscard_blks = 0;
20ee4382322cd9 Chao Yu 2018-07-08 2170 dcc->next_pos = 0;
4dada3fd7025e9 Chao Yu 2018-10-04 2171 dcc->root = RB_ROOT_CACHED;
67fce70ba341f7 Chao Yu 2018-06-22 2172 dcc->rbtree_check = false;
0b54fb8458199d Jaegeuk Kim 2017-01-11 2173
1546996348b33d Jaegeuk Kim 2017-01-09 2174 init_waitqueue_head(&dcc->discard_wait_queue);
0b54fb8458199d Jaegeuk Kim 2017-01-11 2175 SM_I(sbi)->dcc_info = dcc;
0b54fb8458199d Jaegeuk Kim 2017-01-11 2176 init_thread:
409d152775702f Fengnan Chang 2021-08-13 2177 err = f2fs_start_discard_thread(sbi);
1546996348b33d Jaegeuk Kim 2017-01-09 2178
0b54fb8458199d Jaegeuk Kim 2017-01-11 2179 return err;
0b54fb8458199d Jaegeuk Kim 2017-01-11 2180 }
0b54fb8458199d Jaegeuk Kim 2017-01-11 2181
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Download attachment ".config.gz" of type "application/gzip" (37988 bytes)
Powered by blists - more mailing lists