CC: [email protected] CC: [email protected] CC: "Darrick J. Wong" <[email protected]> CC: [email protected] TO: "Darrick J. Wong" <[email protected]>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git defrag-freespace head: eac62500d5481c286ef5fac0873d1707175312b6 commit: e17e75a18c97e1f807f4e82707349ffa38c94fa3 [309/310] xfs: fallocate free space into a file :::::: branch date: 34 hours ago :::::: commit date: 34 hours ago config: riscv-randconfig-c006-20210816 (attached as .config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project af7818093677dcb4c0840aef96bc029deb219e57) 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 riscv cross compiling tool for clang build # apt-get install binutils-riscv64-linux-gnu # https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git/commit/?id=e17e75a18c97e1f807f4e82707349ffa38c94fa3 git remote add djwong-xfs https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git git fetch --no-tags djwong-xfs defrag-freespace git checkout e17e75a18c97e1f807f4e82707349ffa38c94fa3 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <[email protected]> clang-analyzer warnings: (new ones prefixed by >>) include/linux/math.h:89:3: note: expanded from macro 'DIV_ROUND_CLOSEST' (((typeof(x))-1) > 0 || \ ^ drivers/hwmon/pmbus/zl6100.c:111:13: note: Left side of '||' is false mantissa = DIV_ROUND_CLOSEST(val, 1000); ^ include/linux/math.h:89:3: note: expanded from macro 'DIV_ROUND_CLOSEST' (((typeof(x))-1) > 0 || \ ^ drivers/hwmon/pmbus/zl6100.c:111:13: note: '__x' is > 0 mantissa = DIV_ROUND_CLOSEST(val, 1000); ^ include/linux/math.h:91:5: note: expanded from macro 'DIV_ROUND_CLOSEST' (((__x) > 0) == ((__d) > 0))) ? \ ^~~~~ drivers/hwmon/pmbus/zl6100.c:111:13: note: '?' condition is true mantissa = DIV_ROUND_CLOSEST(val, 1000); ^ include/linux/math.h:89:2: note: expanded from macro 'DIV_ROUND_CLOSEST' (((typeof(x))-1) > 0 || \ ^ drivers/hwmon/pmbus/zl6100.c:114:6: note: Assuming 'mantissa' is <= 1023 if (mantissa > 0x3ff) ^~~~~~~~~~~~~~~~ drivers/hwmon/pmbus/zl6100.c:114:2: note: Taking false branch if (mantissa > 0x3ff) ^ drivers/hwmon/pmbus/zl6100.c:118:6: note: 'negative' is false if (negative) ^~~~~~~~ drivers/hwmon/pmbus/zl6100.c:118:2: note: Taking false branch if (negative) ^ drivers/hwmon/pmbus/zl6100.c:122:41: note: The result of the left shift is undefined because the left operand is negative return (mantissa & 0x7ff) | ((exponent << 11) & 0xf800); ~~~~~~~~ ^ Suppressed 9 warnings (9 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/xfs/libxfs/xfs_attr_leaf.c:2248:29: warning: Value stored to 'drop_leaf' during its initialization is never read [clang-analyzer-deadcode.DeadStores] struct xfs_attr_leafblock *drop_leaf = drop_blk->bp->b_addr; ^~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ fs/xfs/libxfs/xfs_attr_leaf.c:2248:29: note: Value stored to 'drop_leaf' during its initialization is never read struct xfs_attr_leafblock *drop_leaf = drop_blk->bp->b_addr; ^~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ fs/xfs/libxfs/xfs_attr_leaf.c:2249:29: warning: Value stored to 'save_leaf' during its initialization is never read [clang-analyzer-deadcode.DeadStores] struct xfs_attr_leafblock *save_leaf = save_blk->bp->b_addr; ^~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ fs/xfs/libxfs/xfs_attr_leaf.c:2249:29: note: Value stored to 'save_leaf' during its initialization is never read struct xfs_attr_leafblock *save_leaf = save_blk->bp->b_addr; ^~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ Suppressed 10 warnings (10 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. 10 warnings generated. Suppressed 10 warnings (10 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. 9 warnings generated. Suppressed 9 warnings (9 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. 22 warnings generated. fs/xfs/libxfs/xfs_bmap.c:345:2: warning: Value stored to 'bno' is never read [clang-analyzer-deadcode.DeadStores] bno = NULLFSBLOCK; ^ fs/xfs/libxfs/xfs_bmap.c:345:2: note: Value stored to 'bno' is never read fs/xfs/libxfs/xfs_bmap.c:392:4: warning: Value stored to 'error' is never read [clang-analyzer-deadcode.DeadStores] error = -EFSCORRUPTED; ^ ~~~~~~~~~~~~~ fs/xfs/libxfs/xfs_bmap.c:392:4: note: Value stored to 'error' is never read error = -EFSCORRUPTED; ^ ~~~~~~~~~~~~~ fs/xfs/libxfs/xfs_bmap.c:445:4: warning: Value stored to 'bp_release' is never read [clang-analyzer-deadcode.DeadStores] bp_release = 0; ^ ~ fs/xfs/libxfs/xfs_bmap.c:445:4: note: Value stored to 'bp_release' is never read bp_release = 0; ^ ~ fs/xfs/libxfs/xfs_bmap.c:558:3: warning: Value stored to 'agno' is never read [clang-analyzer-deadcode.DeadStores] agno = 0; ^ ~ fs/xfs/libxfs/xfs_bmap.c:558:3: note: Value stored to 'agno' is never read agno = 0; ^ ~ fs/xfs/libxfs/xfs_bmap.c:559:3: warning: Value stored to 'agbno' is never read [clang-analyzer-deadcode.DeadStores] agbno = bno; ^ ~~~ fs/xfs/libxfs/xfs_bmap.c:559:3: note: Value stored to 'agbno' is never read agbno = bno; ^ ~~~ fs/xfs/libxfs/xfs_bmap.c:864:2: warning: Value stored to 'error' is never read [clang-analyzer-deadcode.DeadStores] error = 0; ^ ~ fs/xfs/libxfs/xfs_bmap.c:864:2: note: Value stored to 'error' is never read error = 0; ^ ~ fs/xfs/libxfs/xfs_bmap.c:5156:2: warning: Value stored to 'qfield' is never read [clang-analyzer-deadcode.DeadStores] qfield = 0; ^ ~ fs/xfs/libxfs/xfs_bmap.c:5156:2: note: Value stored to 'qfield' is never read qfield = 0; ^ ~ >> fs/xfs/libxfs/xfs_bmap.c:6580:23: warning: The left operand of '!=' is a >> garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult] if (irec.br_startoff != startoff || ~~~~~~~~~~~~~~~~ ^ fs/xfs/libxfs/xfs_bmap.c:6566:6: note: Assuming 'error' is 0 if (error) ^~~~~ fs/xfs/libxfs/xfs_bmap.c:6566:2: note: Taking false branch if (error) ^ fs/xfs/libxfs/xfs_bmap.c:6569:6: note: 'isrt' is false if (isrt) ^~~~ fs/xfs/libxfs/xfs_bmap.c:6569:2: note: Taking false branch if (isrt) ^ fs/xfs/libxfs/xfs_bmap.c:6576:10: note: Calling 'xfs_bmapi_read' error = xfs_bmapi_read(ip, startoff, len, &irec, &nimaps, 0); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/xfs/libxfs/xfs_bmap.c:3986:26: note: 'whichfork' is equal to 0 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); ^ fs/xfs/libxfs/xfs_inode_fork.h:98:3: note: expanded from macro 'XFS_IFORK_PTR' ((w) == XFS_DATA_FORK ? \ ^~~ fs/xfs/libxfs/xfs_bmap.c:3986:26: note: '?' condition is true struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); ^ fs/xfs/libxfs/xfs_inode_fork.h:98:3: note: expanded from macro 'XFS_IFORK_PTR' ((w) == XFS_DATA_FORK ? \ ^ fs/xfs/libxfs/xfs_bmap.c:3995:2: note: '?' condition is true ASSERT(*nmap >= 1); ^ fs/xfs/xfs_linux.h:210:3: note: expanded from macro 'ASSERT' (likely(expr) ? (void)0 : assfail(NULL, #expr, __FILE__, __LINE__)) ^ include/linux/compiler.h:77:20: note: expanded from macro 'likely' # define likely(x) __builtin_expect(!!(x), 1) ^ fs/xfs/libxfs/xfs_bmap.c:3996:2: note: '?' condition is true ASSERT(!(flags & ~(XFS_BMAPI_ATTRFORK | XFS_BMAPI_ENTIRE))); ^ fs/xfs/xfs_linux.h:210:3: note: expanded from macro 'ASSERT' (likely(expr) ? (void)0 : assfail(NULL, #expr, __FILE__, __LINE__)) ^ include/linux/compiler.h:77:20: note: expanded from macro 'likely' # define likely(x) __builtin_expect(!!(x), 1) ^ fs/xfs/libxfs/xfs_bmap.c:3997:2: note: Assuming the condition is false ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED|XFS_ILOCK_EXCL)); ^ fs/xfs/xfs_linux.h:210:3: note: expanded from macro 'ASSERT' (likely(expr) ? (void)0 : assfail(NULL, #expr, __FILE__, __LINE__)) ^~~~~~~~~~~~ include/linux/compiler.h:77:38: note: expanded from macro 'likely' # define likely(x) __builtin_expect(!!(x), 1) ^~~~ fs/xfs/libxfs/xfs_bmap.c:3997:2: note: '?' condition is true ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED|XFS_ILOCK_EXCL)); ^ fs/xfs/xfs_linux.h:210:3: note: expanded from macro 'ASSERT' (likely(expr) ? (void)0 : assfail(NULL, #expr, __FILE__, __LINE__)) ^ include/linux/compiler.h:77:20: note: expanded from macro 'likely' # define likely(x) __builtin_expect(!!(x), 1) ^ fs/xfs/libxfs/xfs_bmap.c:3999:20: note: 'ifp' is non-null if (WARN_ON_ONCE(!ifp)) ^ include/asm-generic/bug.h:104:25: note: expanded from macro 'WARN_ON_ONCE' int __ret_warn_on = !!(condition); \ ^~~~~~~~~ fs/xfs/libxfs/xfs_bmap.c:3999:6: note: Taking false branch if (WARN_ON_ONCE(!ifp)) ^ include/asm-generic/bug.h:105:2: note: expanded from macro 'WARN_ON_ONCE' if (unlikely(__ret_warn_on)) \ ^ fs/xfs/libxfs/xfs_bmap.c:3999:2: note: Taking false branch if (WARN_ON_ONCE(!ifp)) ^ fs/xfs/libxfs/xfs_bmap.c:4002:6: note: '?' condition is false if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) || ^ fs/xfs/xfs_linux.h:227:3: note: expanded from macro 'XFS_IS_CORRUPT' (unlikely(expr) ? xfs_corruption_error(#expr, XFS_ERRLEVEL_LOW, (mp), \ ^ include/linux/compiler.h:78:22: note: expanded from macro 'unlikely' # define unlikely(x) __builtin_expect(!!(x), 0) ^ fs/xfs/libxfs/xfs_bmap.c:4002:6: note: Left side of '||' is false if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) || ^ fs/xfs/xfs_linux.h:227:2: note: expanded from macro 'XFS_IS_CORRUPT' (unlikely(expr) ? xfs_corruption_error(#expr, XFS_ERRLEVEL_LOW, (mp), \ ^ fs/xfs/libxfs/xfs_bmap.c:4003:6: note: Left side of '||' is false XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) { ^ fs/xfs/xfs_error.h:47:3: note: expanded from macro 'XFS_TEST_ERROR' ((expr) || xfs_errortag_test((mp), #expr, __FILE__, __LINE__, (tag))) ^ fs/xfs/libxfs/xfs_bmap.c:4003:6: note: Assuming the condition is false XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) { ^ fs/xfs/xfs_error.h:47:13: note: expanded from macro 'XFS_TEST_ERROR' ((expr) || xfs_errortag_test((mp), #expr, __FILE__, __LINE__, (tag))) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/xfs/libxfs/xfs_bmap.c:4002:2: note: Taking false branch if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) || ^ fs/xfs/libxfs/xfs_bmap.c:4008:6: note: Assuming the condition is false if (XFS_FORCED_SHUTDOWN(mp)) ^ fs/xfs/xfs_mount.h:363:34: note: expanded from macro 'XFS_FORCED_SHUTDOWN' #define XFS_FORCED_SHUTDOWN(mp) ((mp)->m_flags & XFS_MOUNT_FS_SHUTDOWN) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/xfs/libxfs/xfs_bmap.c:4008:2: note: Taking false branch if (XFS_FORCED_SHUTDOWN(mp)) ^ fs/xfs/libxfs/xfs_bmap.c:4011:2: note: Loop condition is false. Exiting loop XFS_STATS_INC(mp, xs_blk_mapr); ^ fs/xfs/xfs_stats.h:165:2: note: expanded from macro 'XFS_STATS_INC' per_cpu_ptr(xfsstats.xs_stats, current_cpu())->s.v++; \ ^ include/linux/percpu-defs.h:235:2: note: expanded from macro 'per_cpu_ptr' __verify_pcpu_ptr(ptr); \ ^ include/linux/percpu-defs.h:217:37: note: expanded from macro '__verify_pcpu_ptr' #define __verify_pcpu_ptr(ptr) \ ^ fs/xfs/libxfs/xfs_bmap.c:4011:2: note: Loop condition is false. Exiting loop XFS_STATS_INC(mp, xs_blk_mapr); ^ fs/xfs/xfs_stats.h:166:2: note: expanded from macro 'XFS_STATS_INC' per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->s.v++; \ ^ include/linux/percpu-defs.h:235:2: note: expanded from macro 'per_cpu_ptr' __verify_pcpu_ptr(ptr); \ ^ include/linux/percpu-defs.h:217:37: note: expanded from macro '__verify_pcpu_ptr' #define __verify_pcpu_ptr(ptr) \ ^ fs/xfs/libxfs/xfs_bmap.c:4011:2: note: Loop condition is false. Exiting loop XFS_STATS_INC(mp, xs_blk_mapr); ^ fs/xfs/xfs_stats.h:163:34: note: expanded from macro 'XFS_STATS_INC' #define XFS_STATS_INC(mp, v) \ ^ fs/xfs/libxfs/xfs_bmap.c:4014:6: note: 'error' is 0 if (error) ^~~~~ fs/xfs/libxfs/xfs_bmap.c:4014:2: note: Taking false branch if (error) ^ fs/xfs/libxfs/xfs_bmap.c:4017:6: note: Assuming the condition is false if (!xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/xfs/libxfs/xfs_bmap.c:4017:2: note: Taking false branch if (!xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got)) ^ fs/xfs/libxfs/xfs_bmap.c:4022:9: note: Assuming 'bno' is >= 'end' while (bno < end && n < *nmap) { ^~~~~~~~~ fs/xfs/libxfs/xfs_bmap.c:4022:19: note: Left side of '&&' is false while (bno < end && n < *nmap) { ^ fs/xfs/libxfs/xfs_bmap.c:4053:2: note: Returning without writing to 'mval->br_startoff' return 0; ^ fs/xfs/libxfs/xfs_bmap.c:4053:2: note: Returning zero, which participates in a condition later return 0; ^~~~~~~~ fs/xfs/libxfs/xfs_bmap.c:6576:10: note: Returning from 'xfs_bmapi_read' error = xfs_bmapi_read(ip, startoff, len, &irec, &nimaps, 0); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/xfs/libxfs/xfs_bmap.c:6577:6: note: 'error' is 0 if (error) ^~~~~ fs/xfs/libxfs/xfs_bmap.c:6577:2: note: Taking false branch if (error) ^ fs/xfs/libxfs/xfs_bmap.c:6580:23: note: The left operand of '!=' is a garbage value if (irec.br_startoff != startoff || ~~~~~~~~~~~~~~~~ ^ >> fs/xfs/libxfs/xfs_bmap.c:6598:3: warning: Value stored to 'rtxlen_in' is >> never read [clang-analyzer-deadcode.DeadStores] rtxlen_in = len / mp->m_sb.sb_rextsize; ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/xfs/libxfs/xfs_bmap.c:6598:3: note: Value stored to 'rtxlen_in' is never read rtxlen_in = len / mp->m_sb.sb_rextsize; ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~ Suppressed 13 warnings (10 in non-user code, 3 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 7 warnings generated. Suppressed 7 warnings (7 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. 7 warnings generated. Suppressed 7 warnings (7 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. 5 warnings generated. Suppressed 5 warnings (5 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. 10 warnings generated. drivers/block/zram/zram_drv.c:1021:2: warning: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy] strcpy(zram->compressor, compressor); ^~~~~~ drivers/block/zram/zram_drv.c:1021:2: note: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 strcpy(zram->compressor, compressor); ^~~~~~ Suppressed 9 warnings (9 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. 9 warnings generated. drivers/block/null_blk/main.c:928:4: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores] ret = radix_tree_delete_item(&nullb->dev->data, ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/block/null_blk/main.c:928:4: note: Value stored to 'ret' is never read ret = radix_tree_delete_item(&nullb->dev->data, ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Suppressed 8 warnings (8 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. 9 warnings generated. Suppressed 9 warnings (9 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. 9 warnings generated. drivers/misc/eeprom/at25.c:460:44: warning: The left operand of '&' is a garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult] at25->nvmem_config.read_only = chip.flags & EE_READONLY; ~~~~~~~~~~ ^ drivers/misc/eeprom/at25.c:382:6: note: Assuming 'match' is non-null if (match && !strcmp(match->compatible, "cypress,fm25")) ^~~~~ drivers/misc/eeprom/at25.c:382:6: note: Left side of '&&' is true drivers/misc/eeprom/at25.c:382:2: note: Taking true branch if (match && !strcmp(match->compatible, "cypress,fm25")) ^ drivers/misc/eeprom/at25.c:386:6: note: Assuming field 'platform_data' is null if (!spi->dev.platform_data) { ^~~~~~~~~~~~~~~~~~~~~~~ drivers/misc/eeprom/at25.c:386:2: note: Taking true branch if (!spi->dev.platform_data) { ^ drivers/misc/eeprom/at25.c:387:8: note: 'is_fram' is true if (!is_fram) { ^~~~~~~ drivers/misc/eeprom/at25.c:387:3: note: Taking false branch if (!is_fram) { ^ drivers/misc/eeprom/at25.c:400:6: note: 'sr' is >= 0 if (sr < 0 || sr & AT25_SR_nRDY) { ^~ drivers/misc/eeprom/at25.c:400:6: note: Left side of '||' is false drivers/misc/eeprom/at25.c:400:16: note: Assuming the condition is false if (sr < 0 || sr & AT25_SR_nRDY) { ^~~~~~~~~~~~~~~~~ drivers/misc/eeprom/at25.c:400:2: note: Taking false branch if (sr < 0 || sr & AT25_SR_nRDY) { ^ drivers/misc/eeprom/at25.c:406:6: note: Assuming 'at25' is non-null if (!at25) ^~~~~ drivers/misc/eeprom/at25.c:406:2: note: Taking false branch if (!at25) ^ drivers/misc/eeprom/at25.c:409:2: note: Loop condition is false. Exiting loop mutex_init(&at25->lock); ^ include/linux/mutex.h:113:32: note: expanded from macro 'mutex_init' #define mutex_init(mutex) \ ^ drivers/misc/eeprom/at25.c:414:6: note: 'is_fram' is true if (is_fram) { ^~~~~~~ drivers/misc/eeprom/at25.c:414:2: note: Taking true branch if (is_fram) { ^ drivers/misc/eeprom/at25.c:417:7: note: Assuming the condition is false if (id[6] != 0xc2) { ^~~~~~~~~~~~~ drivers/misc/eeprom/at25.c:417:3: note: Taking false branch if (id[6] != 0xc2) { ^ drivers/misc/eeprom/at25.c:423:7: note: Assuming the condition is false if (id[7] < 0x21 || id[7] > 0x26) { ^~~~~~~~~~~~ drivers/misc/eeprom/at25.c:423:7: note: Left side of '||' is false drivers/misc/eeprom/at25.c:423:23: note: Assuming the condition is false if (id[7] < 0x21 || id[7] > 0x26) { vim +6580 fs/xfs/libxfs/xfs_bmap.c e17e75a18c97e1 Darrick J. Wong 2021-06-15 6541 e17e75a18c97e1 Darrick J. Wong 2021-06-15 6542 /* e17e75a18c97e1 Darrick J. Wong 2021-06-15 6543 * Given a file and a free physical extent, map it into the file at the same e17e75a18c97e1 Darrick J. Wong 2021-06-15 6544 * offset if the file were a sparse image of the physical device. Set @mval to e17e75a18c97e1 Darrick J. Wong 2021-06-15 6545 * whatever mapping we added to the file. e17e75a18c97e1 Darrick J. Wong 2021-06-15 6546 */ e17e75a18c97e1 Darrick J. Wong 2021-06-15 6547 int e17e75a18c97e1 Darrick J. Wong 2021-06-15 6548 xfs_bmapi_freesp( e17e75a18c97e1 Darrick J. Wong 2021-06-15 6549 struct xfs_trans **tpp, e17e75a18c97e1 Darrick J. Wong 2021-06-15 6550 struct xfs_inode *ip, e17e75a18c97e1 Darrick J. Wong 2021-06-15 6551 xfs_fsblock_t fsbno, e17e75a18c97e1 Darrick J. Wong 2021-06-15 6552 xfs_extlen_t len, e17e75a18c97e1 Darrick J. Wong 2021-06-15 6553 struct xfs_bmbt_irec *mval) e17e75a18c97e1 Darrick J. Wong 2021-06-15 6554 { e17e75a18c97e1 Darrick J. Wong 2021-06-15 6555 struct xfs_bmbt_irec irec; e17e75a18c97e1 Darrick J. Wong 2021-06-15 6556 struct xfs_mount *mp = ip->i_mount; e17e75a18c97e1 Darrick J. Wong 2021-06-15 6557 xfs_fileoff_t startoff; e17e75a18c97e1 Darrick J. Wong 2021-06-15 6558 bool isrt = XFS_IS_REALTIME_INODE(ip); e17e75a18c97e1 Darrick J. Wong 2021-06-15 6559 int nimaps; e17e75a18c97e1 Darrick J. Wong 2021-06-15 6560 int error; e17e75a18c97e1 Darrick J. Wong 2021-06-15 6561 e17e75a18c97e1 Darrick J. Wong 2021-06-15 6562 trace_xfs_bmapi_freesp(ip, fsbno, len); e17e75a18c97e1 Darrick J. Wong 2021-06-15 6563 e17e75a18c97e1 Darrick J. Wong 2021-06-15 6564 error = xfs_iext_count_may_overflow(ip, XFS_DATA_FORK, e17e75a18c97e1 Darrick J. Wong 2021-06-15 6565 XFS_IEXT_ADD_NOSPLIT_CNT); e17e75a18c97e1 Darrick J. Wong 2021-06-15 6566 if (error) e17e75a18c97e1 Darrick J. Wong 2021-06-15 6567 return error; e17e75a18c97e1 Darrick J. Wong 2021-06-15 6568 e17e75a18c97e1 Darrick J. Wong 2021-06-15 6569 if (isrt) e17e75a18c97e1 Darrick J. Wong 2021-06-15 6570 startoff = fsbno; e17e75a18c97e1 Darrick J. Wong 2021-06-15 6571 else e17e75a18c97e1 Darrick J. Wong 2021-06-15 6572 startoff = xfs_fsblock_to_fileoff(mp, fsbno); e17e75a18c97e1 Darrick J. Wong 2021-06-15 6573 e17e75a18c97e1 Darrick J. Wong 2021-06-15 6574 /* Make sure the entire range is a hole. */ e17e75a18c97e1 Darrick J. Wong 2021-06-15 6575 nimaps = 1; e17e75a18c97e1 Darrick J. Wong 2021-06-15 6576 error = xfs_bmapi_read(ip, startoff, len, &irec, &nimaps, 0); e17e75a18c97e1 Darrick J. Wong 2021-06-15 6577 if (error) e17e75a18c97e1 Darrick J. Wong 2021-06-15 6578 return error; e17e75a18c97e1 Darrick J. Wong 2021-06-15 6579 e17e75a18c97e1 Darrick J. Wong 2021-06-15 @6580 if (irec.br_startoff != startoff || e17e75a18c97e1 Darrick J. Wong 2021-06-15 6581 irec.br_startblock != HOLESTARTBLOCK || e17e75a18c97e1 Darrick J. Wong 2021-06-15 6582 irec.br_blockcount < len) e17e75a18c97e1 Darrick J. Wong 2021-06-15 6583 return -EINVAL; e17e75a18c97e1 Darrick J. Wong 2021-06-15 6584 e17e75a18c97e1 Darrick J. Wong 2021-06-15 6585 /* e17e75a18c97e1 Darrick J. Wong 2021-06-15 6586 * Allocate the physical extent. We should not have dropped the lock e17e75a18c97e1 Darrick J. Wong 2021-06-15 6587 * since the scan of the free space metadata, so this should work, e17e75a18c97e1 Darrick J. Wong 2021-06-15 6588 * though the length may be adjusted to play nicely with metadata space e17e75a18c97e1 Darrick J. Wong 2021-06-15 6589 * reservations. e17e75a18c97e1 Darrick J. Wong 2021-06-15 6590 */ e17e75a18c97e1 Darrick J. Wong 2021-06-15 6591 if (isrt) { e17e75a18c97e1 Darrick J. Wong 2021-06-15 6592 xfs_rtblock_t rtx_in, rtx_out; e17e75a18c97e1 Darrick J. Wong 2021-06-15 6593 xfs_extlen_t rtxlen_in, rtxlen_out; e17e75a18c97e1 Darrick J. Wong 2021-06-15 6594 uint32_t mod; e17e75a18c97e1 Darrick J. Wong 2021-06-15 6595 e17e75a18c97e1 Darrick J. Wong 2021-06-15 6596 rtx_in = div_u64_rem(fsbno, mp->m_sb.sb_rextsize, &mod); e17e75a18c97e1 Darrick J. Wong 2021-06-15 6597 ASSERT(mod == 0); e17e75a18c97e1 Darrick J. Wong 2021-06-15 @6598 rtxlen_in = len / mp->m_sb.sb_rextsize; --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/[email protected]
.config.gz
Description: application/gzip
_______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
