* [djwong-xfs:vectorized-scrub 169/290] fs/xfs/xfs_exchrange.c:554:11-12: WARNING opportunity for max()
@ 2024-02-24 9:33 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2024-02-24 9:33 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: "Darrick J. Wong" <darrick.wong@oracle.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git vectorized-scrub
head: 99aa1a17c8c616e4c031f7b1b136867f3fcca633
commit: e7f0dcdd13caeaf3e4a002169d3c1080d949090b [169/290] xfs: bind together the front and back ends of the file range exchange code
:::::: branch date: 9 hours ago
:::::: commit date: 2 days ago
config: x86_64-randconfig-101-20240224 (https://download.01.org/0day-ci/archive/20240224/202402241758.of2kcBiC-lkp@intel.com/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
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>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202402241758.of2kcBiC-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> fs/xfs/xfs_exchrange.c:554:11-12: WARNING opportunity for max()
fs/xfs/xfs_exchrange.c:555:11-12: WARNING opportunity for max()
vim +554 fs/xfs/xfs_exchrange.c
e7f0dcdd13caea Darrick J. Wong 2024-01-09 516
e7f0dcdd13caea Darrick J. Wong 2024-01-09 517 /*
e7f0dcdd13caea Darrick J. Wong 2024-01-09 518 * Obtain a quota reservation to make sure we don't hit EDQUOT. We can skip
e7f0dcdd13caea Darrick J. Wong 2024-01-09 519 * this if quota enforcement is disabled or if both inodes' dquots are the
e7f0dcdd13caea Darrick J. Wong 2024-01-09 520 * same. The qretry structure must be initialized to zeroes before the first
e7f0dcdd13caea Darrick J. Wong 2024-01-09 521 * call to this function.
e7f0dcdd13caea Darrick J. Wong 2024-01-09 522 */
e7f0dcdd13caea Darrick J. Wong 2024-01-09 523 STATIC int
e7f0dcdd13caea Darrick J. Wong 2024-01-09 524 xfs_exchrange_reserve_quota(
e7f0dcdd13caea Darrick J. Wong 2024-01-09 525 struct xfs_trans *tp,
e7f0dcdd13caea Darrick J. Wong 2024-01-09 526 const struct xfs_exchmaps_req *req,
e7f0dcdd13caea Darrick J. Wong 2024-01-09 527 unsigned int *qretry)
e7f0dcdd13caea Darrick J. Wong 2024-01-09 528 {
e7f0dcdd13caea Darrick J. Wong 2024-01-09 529 int64_t ddelta, rdelta;
e7f0dcdd13caea Darrick J. Wong 2024-01-09 530 int ip1_error = 0;
e7f0dcdd13caea Darrick J. Wong 2024-01-09 531 int error;
e7f0dcdd13caea Darrick J. Wong 2024-01-09 532
e7f0dcdd13caea Darrick J. Wong 2024-01-09 533 /*
e7f0dcdd13caea Darrick J. Wong 2024-01-09 534 * Don't bother with a quota reservation if we're not enforcing them
e7f0dcdd13caea Darrick J. Wong 2024-01-09 535 * or the two inodes have the same dquots.
e7f0dcdd13caea Darrick J. Wong 2024-01-09 536 */
e7f0dcdd13caea Darrick J. Wong 2024-01-09 537 if (!XFS_IS_QUOTA_ON(tp->t_mountp) || req->ip1 == req->ip2 ||
e7f0dcdd13caea Darrick J. Wong 2024-01-09 538 (req->ip1->i_udquot == req->ip2->i_udquot &&
e7f0dcdd13caea Darrick J. Wong 2024-01-09 539 req->ip1->i_gdquot == req->ip2->i_gdquot &&
e7f0dcdd13caea Darrick J. Wong 2024-01-09 540 req->ip1->i_pdquot == req->ip2->i_pdquot))
e7f0dcdd13caea Darrick J. Wong 2024-01-09 541 return 0;
e7f0dcdd13caea Darrick J. Wong 2024-01-09 542
e7f0dcdd13caea Darrick J. Wong 2024-01-09 543 *qretry = 0;
e7f0dcdd13caea Darrick J. Wong 2024-01-09 544
e7f0dcdd13caea Darrick J. Wong 2024-01-09 545 /*
e7f0dcdd13caea Darrick J. Wong 2024-01-09 546 * For each file, compute the net gain in the number of regular blocks
e7f0dcdd13caea Darrick J. Wong 2024-01-09 547 * that will be mapped into that file and reserve that much quota. The
e7f0dcdd13caea Darrick J. Wong 2024-01-09 548 * quota counts must be able to absorb at least that much space.
e7f0dcdd13caea Darrick J. Wong 2024-01-09 549 */
e7f0dcdd13caea Darrick J. Wong 2024-01-09 550 ddelta = req->ip2_bcount - req->ip1_bcount;
e7f0dcdd13caea Darrick J. Wong 2024-01-09 551 rdelta = req->ip2_rtbcount - req->ip1_rtbcount;
e7f0dcdd13caea Darrick J. Wong 2024-01-09 552 if (ddelta > 0 || rdelta > 0) {
e7f0dcdd13caea Darrick J. Wong 2024-01-09 553 error = xfs_trans_reserve_quota_nblks(tp, req->ip1,
e7f0dcdd13caea Darrick J. Wong 2024-01-09 @554 ddelta > 0 ? ddelta : 0,
e7f0dcdd13caea Darrick J. Wong 2024-01-09 555 rdelta > 0 ? rdelta : 0,
e7f0dcdd13caea Darrick J. Wong 2024-01-09 556 false);
e7f0dcdd13caea Darrick J. Wong 2024-01-09 557 if (error == -EDQUOT || error == -ENOSPC) {
e7f0dcdd13caea Darrick J. Wong 2024-01-09 558 /*
e7f0dcdd13caea Darrick J. Wong 2024-01-09 559 * Save this error and see what happens if we try to
e7f0dcdd13caea Darrick J. Wong 2024-01-09 560 * reserve quota for ip2. Then report both.
e7f0dcdd13caea Darrick J. Wong 2024-01-09 561 */
e7f0dcdd13caea Darrick J. Wong 2024-01-09 562 *qretry |= QRETRY_IP1;
e7f0dcdd13caea Darrick J. Wong 2024-01-09 563 ip1_error = error;
e7f0dcdd13caea Darrick J. Wong 2024-01-09 564 error = 0;
e7f0dcdd13caea Darrick J. Wong 2024-01-09 565 }
e7f0dcdd13caea Darrick J. Wong 2024-01-09 566 if (error)
e7f0dcdd13caea Darrick J. Wong 2024-01-09 567 return error;
e7f0dcdd13caea Darrick J. Wong 2024-01-09 568 }
e7f0dcdd13caea Darrick J. Wong 2024-01-09 569 if (ddelta < 0 || rdelta < 0) {
e7f0dcdd13caea Darrick J. Wong 2024-01-09 570 error = xfs_trans_reserve_quota_nblks(tp, req->ip2,
e7f0dcdd13caea Darrick J. Wong 2024-01-09 571 ddelta < 0 ? -ddelta : 0,
e7f0dcdd13caea Darrick J. Wong 2024-01-09 572 rdelta < 0 ? -rdelta : 0,
e7f0dcdd13caea Darrick J. Wong 2024-01-09 573 false);
e7f0dcdd13caea Darrick J. Wong 2024-01-09 574 if (error == -EDQUOT || error == -ENOSPC)
e7f0dcdd13caea Darrick J. Wong 2024-01-09 575 *qretry |= QRETRY_IP2;
e7f0dcdd13caea Darrick J. Wong 2024-01-09 576 if (error)
e7f0dcdd13caea Darrick J. Wong 2024-01-09 577 return error;
e7f0dcdd13caea Darrick J. Wong 2024-01-09 578 }
e7f0dcdd13caea Darrick J. Wong 2024-01-09 579 if (ip1_error)
e7f0dcdd13caea Darrick J. Wong 2024-01-09 580 return ip1_error;
e7f0dcdd13caea Darrick J. Wong 2024-01-09 581
e7f0dcdd13caea Darrick J. Wong 2024-01-09 582 /*
e7f0dcdd13caea Darrick J. Wong 2024-01-09 583 * For each file, forcibly reserve the gross gain in mapped blocks so
e7f0dcdd13caea Darrick J. Wong 2024-01-09 584 * that we don't trip over any quota block reservation assertions.
e7f0dcdd13caea Darrick J. Wong 2024-01-09 585 * We must reserve the gross gain because the quota code subtracts from
e7f0dcdd13caea Darrick J. Wong 2024-01-09 586 * bcount the number of blocks that we unmap; it does not add that
e7f0dcdd13caea Darrick J. Wong 2024-01-09 587 * quantity back to the quota block reservation.
e7f0dcdd13caea Darrick J. Wong 2024-01-09 588 */
e7f0dcdd13caea Darrick J. Wong 2024-01-09 589 error = xfs_trans_reserve_quota_nblks(tp, req->ip1, req->ip1_bcount,
e7f0dcdd13caea Darrick J. Wong 2024-01-09 590 req->ip1_rtbcount, true);
e7f0dcdd13caea Darrick J. Wong 2024-01-09 591 if (error)
e7f0dcdd13caea Darrick J. Wong 2024-01-09 592 return error;
e7f0dcdd13caea Darrick J. Wong 2024-01-09 593
e7f0dcdd13caea Darrick J. Wong 2024-01-09 594 return xfs_trans_reserve_quota_nblks(tp, req->ip2, req->ip2_bcount,
e7f0dcdd13caea Darrick J. Wong 2024-01-09 595 req->ip2_rtbcount, true);
e7f0dcdd13caea Darrick J. Wong 2024-01-09 596 }
e7f0dcdd13caea Darrick J. Wong 2024-01-09 597
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-02-24 9:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-24 9:33 [djwong-xfs:vectorized-scrub 169/290] fs/xfs/xfs_exchrange.c:554:11-12: WARNING opportunity for max() kernel test robot
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.