* fs/xfs/xfs_exchrange.c:114:11-12: WARNING opportunity for max()
@ 2024-09-21 9:35 kernel test robot
0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2024-09-21 9:35 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: "Darrick J. Wong" <djwong@kernel.org>
CC: Christoph Hellwig <hch@lst.de>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 1868f9d0260e9afaf7c6436d14923ae12eaea465
commit: 42672471f938cdab2573f32ce23915b78f0578f4 xfs: bind together the front and back ends of the file range exchange code
date: 5 months ago
:::::: branch date: 7 hours ago
:::::: commit date: 5 months ago
config: arm-randconfig-r054-20240921 (https://download.01.org/0day-ci/archive/20240921/202409211740.jkumGG9V-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 14.1.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/202409211740.jkumGG9V-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> fs/xfs/xfs_exchrange.c:114:11-12: WARNING opportunity for max()
fs/xfs/xfs_exchrange.c:115:11-12: WARNING opportunity for max()
vim +114 fs/xfs/xfs_exchrange.c
42672471f938cd Darrick J. Wong 2024-04-15 76
42672471f938cd Darrick J. Wong 2024-04-15 77 /*
42672471f938cd Darrick J. Wong 2024-04-15 78 * Obtain a quota reservation to make sure we don't hit EDQUOT. We can skip
42672471f938cd Darrick J. Wong 2024-04-15 79 * this if quota enforcement is disabled or if both inodes' dquots are the
42672471f938cd Darrick J. Wong 2024-04-15 80 * same. The qretry structure must be initialized to zeroes before the first
42672471f938cd Darrick J. Wong 2024-04-15 81 * call to this function.
42672471f938cd Darrick J. Wong 2024-04-15 82 */
42672471f938cd Darrick J. Wong 2024-04-15 83 STATIC int
42672471f938cd Darrick J. Wong 2024-04-15 84 xfs_exchrange_reserve_quota(
42672471f938cd Darrick J. Wong 2024-04-15 85 struct xfs_trans *tp,
42672471f938cd Darrick J. Wong 2024-04-15 86 const struct xfs_exchmaps_req *req,
42672471f938cd Darrick J. Wong 2024-04-15 87 unsigned int *qretry)
42672471f938cd Darrick J. Wong 2024-04-15 88 {
42672471f938cd Darrick J. Wong 2024-04-15 89 int64_t ddelta, rdelta;
42672471f938cd Darrick J. Wong 2024-04-15 90 int ip1_error = 0;
42672471f938cd Darrick J. Wong 2024-04-15 91 int error;
42672471f938cd Darrick J. Wong 2024-04-15 92
42672471f938cd Darrick J. Wong 2024-04-15 93 /*
42672471f938cd Darrick J. Wong 2024-04-15 94 * Don't bother with a quota reservation if we're not enforcing them
42672471f938cd Darrick J. Wong 2024-04-15 95 * or the two inodes have the same dquots.
42672471f938cd Darrick J. Wong 2024-04-15 96 */
42672471f938cd Darrick J. Wong 2024-04-15 97 if (!XFS_IS_QUOTA_ON(tp->t_mountp) || req->ip1 == req->ip2 ||
42672471f938cd Darrick J. Wong 2024-04-15 98 (req->ip1->i_udquot == req->ip2->i_udquot &&
42672471f938cd Darrick J. Wong 2024-04-15 99 req->ip1->i_gdquot == req->ip2->i_gdquot &&
42672471f938cd Darrick J. Wong 2024-04-15 100 req->ip1->i_pdquot == req->ip2->i_pdquot))
42672471f938cd Darrick J. Wong 2024-04-15 101 return 0;
42672471f938cd Darrick J. Wong 2024-04-15 102
42672471f938cd Darrick J. Wong 2024-04-15 103 *qretry = 0;
42672471f938cd Darrick J. Wong 2024-04-15 104
42672471f938cd Darrick J. Wong 2024-04-15 105 /*
42672471f938cd Darrick J. Wong 2024-04-15 106 * For each file, compute the net gain in the number of regular blocks
42672471f938cd Darrick J. Wong 2024-04-15 107 * that will be mapped into that file and reserve that much quota. The
42672471f938cd Darrick J. Wong 2024-04-15 108 * quota counts must be able to absorb at least that much space.
42672471f938cd Darrick J. Wong 2024-04-15 109 */
42672471f938cd Darrick J. Wong 2024-04-15 110 ddelta = req->ip2_bcount - req->ip1_bcount;
42672471f938cd Darrick J. Wong 2024-04-15 111 rdelta = req->ip2_rtbcount - req->ip1_rtbcount;
42672471f938cd Darrick J. Wong 2024-04-15 112 if (ddelta > 0 || rdelta > 0) {
42672471f938cd Darrick J. Wong 2024-04-15 113 error = xfs_trans_reserve_quota_nblks(tp, req->ip1,
42672471f938cd Darrick J. Wong 2024-04-15 @114 ddelta > 0 ? ddelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 115 rdelta > 0 ? rdelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 116 false);
42672471f938cd Darrick J. Wong 2024-04-15 117 if (error == -EDQUOT || error == -ENOSPC) {
42672471f938cd Darrick J. Wong 2024-04-15 118 /*
42672471f938cd Darrick J. Wong 2024-04-15 119 * Save this error and see what happens if we try to
42672471f938cd Darrick J. Wong 2024-04-15 120 * reserve quota for ip2. Then report both.
42672471f938cd Darrick J. Wong 2024-04-15 121 */
42672471f938cd Darrick J. Wong 2024-04-15 122 *qretry |= QRETRY_IP1;
42672471f938cd Darrick J. Wong 2024-04-15 123 ip1_error = error;
42672471f938cd Darrick J. Wong 2024-04-15 124 error = 0;
42672471f938cd Darrick J. Wong 2024-04-15 125 }
42672471f938cd Darrick J. Wong 2024-04-15 126 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 127 return error;
42672471f938cd Darrick J. Wong 2024-04-15 128 }
42672471f938cd Darrick J. Wong 2024-04-15 129 if (ddelta < 0 || rdelta < 0) {
42672471f938cd Darrick J. Wong 2024-04-15 130 error = xfs_trans_reserve_quota_nblks(tp, req->ip2,
42672471f938cd Darrick J. Wong 2024-04-15 131 ddelta < 0 ? -ddelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 132 rdelta < 0 ? -rdelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 133 false);
42672471f938cd Darrick J. Wong 2024-04-15 134 if (error == -EDQUOT || error == -ENOSPC)
42672471f938cd Darrick J. Wong 2024-04-15 135 *qretry |= QRETRY_IP2;
42672471f938cd Darrick J. Wong 2024-04-15 136 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 137 return error;
42672471f938cd Darrick J. Wong 2024-04-15 138 }
42672471f938cd Darrick J. Wong 2024-04-15 139 if (ip1_error)
42672471f938cd Darrick J. Wong 2024-04-15 140 return ip1_error;
42672471f938cd Darrick J. Wong 2024-04-15 141
42672471f938cd Darrick J. Wong 2024-04-15 142 /*
42672471f938cd Darrick J. Wong 2024-04-15 143 * For each file, forcibly reserve the gross gain in mapped blocks so
42672471f938cd Darrick J. Wong 2024-04-15 144 * that we don't trip over any quota block reservation assertions.
42672471f938cd Darrick J. Wong 2024-04-15 145 * We must reserve the gross gain because the quota code subtracts from
42672471f938cd Darrick J. Wong 2024-04-15 146 * bcount the number of blocks that we unmap; it does not add that
42672471f938cd Darrick J. Wong 2024-04-15 147 * quantity back to the quota block reservation.
42672471f938cd Darrick J. Wong 2024-04-15 148 */
42672471f938cd Darrick J. Wong 2024-04-15 149 error = xfs_trans_reserve_quota_nblks(tp, req->ip1, req->ip1_bcount,
42672471f938cd Darrick J. Wong 2024-04-15 150 req->ip1_rtbcount, true);
42672471f938cd Darrick J. Wong 2024-04-15 151 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 152 return error;
42672471f938cd Darrick J. Wong 2024-04-15 153
42672471f938cd Darrick J. Wong 2024-04-15 154 return xfs_trans_reserve_quota_nblks(tp, req->ip2, req->ip2_bcount,
42672471f938cd Darrick J. Wong 2024-04-15 155 req->ip2_rtbcount, true);
42672471f938cd Darrick J. Wong 2024-04-15 156 }
42672471f938cd Darrick J. Wong 2024-04-15 157
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 8+ messages in thread
* fs/xfs/xfs_exchrange.c:114:11-12: WARNING opportunity for max()
@ 2024-10-30 20:34 kernel test robot
0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2024-10-30 20:34 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: "Darrick J. Wong" <djwong@kernel.org>
CC: Christoph Hellwig <hch@lst.de>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 4236f913808cebef1b9e078726a4e5d56064f7ad
commit: 42672471f938cdab2573f32ce23915b78f0578f4 xfs: bind together the front and back ends of the file range exchange code
date: 7 months ago
:::::: branch date: 2 hours ago
:::::: commit date: 7 months ago
config: alpha-randconfig-r064-20241031 (https://download.01.org/0day-ci/archive/20241031/202410310411.md7m3UAl-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 13.3.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/202410310411.md7m3UAl-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> fs/xfs/xfs_exchrange.c:114:11-12: WARNING opportunity for max()
fs/xfs/xfs_exchrange.c:115:11-12: WARNING opportunity for max()
vim +114 fs/xfs/xfs_exchrange.c
42672471f938cd Darrick J. Wong 2024-04-15 76
42672471f938cd Darrick J. Wong 2024-04-15 77 /*
42672471f938cd Darrick J. Wong 2024-04-15 78 * Obtain a quota reservation to make sure we don't hit EDQUOT. We can skip
42672471f938cd Darrick J. Wong 2024-04-15 79 * this if quota enforcement is disabled or if both inodes' dquots are the
42672471f938cd Darrick J. Wong 2024-04-15 80 * same. The qretry structure must be initialized to zeroes before the first
42672471f938cd Darrick J. Wong 2024-04-15 81 * call to this function.
42672471f938cd Darrick J. Wong 2024-04-15 82 */
42672471f938cd Darrick J. Wong 2024-04-15 83 STATIC int
42672471f938cd Darrick J. Wong 2024-04-15 84 xfs_exchrange_reserve_quota(
42672471f938cd Darrick J. Wong 2024-04-15 85 struct xfs_trans *tp,
42672471f938cd Darrick J. Wong 2024-04-15 86 const struct xfs_exchmaps_req *req,
42672471f938cd Darrick J. Wong 2024-04-15 87 unsigned int *qretry)
42672471f938cd Darrick J. Wong 2024-04-15 88 {
42672471f938cd Darrick J. Wong 2024-04-15 89 int64_t ddelta, rdelta;
42672471f938cd Darrick J. Wong 2024-04-15 90 int ip1_error = 0;
42672471f938cd Darrick J. Wong 2024-04-15 91 int error;
42672471f938cd Darrick J. Wong 2024-04-15 92
42672471f938cd Darrick J. Wong 2024-04-15 93 /*
42672471f938cd Darrick J. Wong 2024-04-15 94 * Don't bother with a quota reservation if we're not enforcing them
42672471f938cd Darrick J. Wong 2024-04-15 95 * or the two inodes have the same dquots.
42672471f938cd Darrick J. Wong 2024-04-15 96 */
42672471f938cd Darrick J. Wong 2024-04-15 97 if (!XFS_IS_QUOTA_ON(tp->t_mountp) || req->ip1 == req->ip2 ||
42672471f938cd Darrick J. Wong 2024-04-15 98 (req->ip1->i_udquot == req->ip2->i_udquot &&
42672471f938cd Darrick J. Wong 2024-04-15 99 req->ip1->i_gdquot == req->ip2->i_gdquot &&
42672471f938cd Darrick J. Wong 2024-04-15 100 req->ip1->i_pdquot == req->ip2->i_pdquot))
42672471f938cd Darrick J. Wong 2024-04-15 101 return 0;
42672471f938cd Darrick J. Wong 2024-04-15 102
42672471f938cd Darrick J. Wong 2024-04-15 103 *qretry = 0;
42672471f938cd Darrick J. Wong 2024-04-15 104
42672471f938cd Darrick J. Wong 2024-04-15 105 /*
42672471f938cd Darrick J. Wong 2024-04-15 106 * For each file, compute the net gain in the number of regular blocks
42672471f938cd Darrick J. Wong 2024-04-15 107 * that will be mapped into that file and reserve that much quota. The
42672471f938cd Darrick J. Wong 2024-04-15 108 * quota counts must be able to absorb at least that much space.
42672471f938cd Darrick J. Wong 2024-04-15 109 */
42672471f938cd Darrick J. Wong 2024-04-15 110 ddelta = req->ip2_bcount - req->ip1_bcount;
42672471f938cd Darrick J. Wong 2024-04-15 111 rdelta = req->ip2_rtbcount - req->ip1_rtbcount;
42672471f938cd Darrick J. Wong 2024-04-15 112 if (ddelta > 0 || rdelta > 0) {
42672471f938cd Darrick J. Wong 2024-04-15 113 error = xfs_trans_reserve_quota_nblks(tp, req->ip1,
42672471f938cd Darrick J. Wong 2024-04-15 @114 ddelta > 0 ? ddelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 115 rdelta > 0 ? rdelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 116 false);
42672471f938cd Darrick J. Wong 2024-04-15 117 if (error == -EDQUOT || error == -ENOSPC) {
42672471f938cd Darrick J. Wong 2024-04-15 118 /*
42672471f938cd Darrick J. Wong 2024-04-15 119 * Save this error and see what happens if we try to
42672471f938cd Darrick J. Wong 2024-04-15 120 * reserve quota for ip2. Then report both.
42672471f938cd Darrick J. Wong 2024-04-15 121 */
42672471f938cd Darrick J. Wong 2024-04-15 122 *qretry |= QRETRY_IP1;
42672471f938cd Darrick J. Wong 2024-04-15 123 ip1_error = error;
42672471f938cd Darrick J. Wong 2024-04-15 124 error = 0;
42672471f938cd Darrick J. Wong 2024-04-15 125 }
42672471f938cd Darrick J. Wong 2024-04-15 126 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 127 return error;
42672471f938cd Darrick J. Wong 2024-04-15 128 }
42672471f938cd Darrick J. Wong 2024-04-15 129 if (ddelta < 0 || rdelta < 0) {
42672471f938cd Darrick J. Wong 2024-04-15 130 error = xfs_trans_reserve_quota_nblks(tp, req->ip2,
42672471f938cd Darrick J. Wong 2024-04-15 131 ddelta < 0 ? -ddelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 132 rdelta < 0 ? -rdelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 133 false);
42672471f938cd Darrick J. Wong 2024-04-15 134 if (error == -EDQUOT || error == -ENOSPC)
42672471f938cd Darrick J. Wong 2024-04-15 135 *qretry |= QRETRY_IP2;
42672471f938cd Darrick J. Wong 2024-04-15 136 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 137 return error;
42672471f938cd Darrick J. Wong 2024-04-15 138 }
42672471f938cd Darrick J. Wong 2024-04-15 139 if (ip1_error)
42672471f938cd Darrick J. Wong 2024-04-15 140 return ip1_error;
42672471f938cd Darrick J. Wong 2024-04-15 141
42672471f938cd Darrick J. Wong 2024-04-15 142 /*
42672471f938cd Darrick J. Wong 2024-04-15 143 * For each file, forcibly reserve the gross gain in mapped blocks so
42672471f938cd Darrick J. Wong 2024-04-15 144 * that we don't trip over any quota block reservation assertions.
42672471f938cd Darrick J. Wong 2024-04-15 145 * We must reserve the gross gain because the quota code subtracts from
42672471f938cd Darrick J. Wong 2024-04-15 146 * bcount the number of blocks that we unmap; it does not add that
42672471f938cd Darrick J. Wong 2024-04-15 147 * quantity back to the quota block reservation.
42672471f938cd Darrick J. Wong 2024-04-15 148 */
42672471f938cd Darrick J. Wong 2024-04-15 149 error = xfs_trans_reserve_quota_nblks(tp, req->ip1, req->ip1_bcount,
42672471f938cd Darrick J. Wong 2024-04-15 150 req->ip1_rtbcount, true);
42672471f938cd Darrick J. Wong 2024-04-15 151 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 152 return error;
42672471f938cd Darrick J. Wong 2024-04-15 153
42672471f938cd Darrick J. Wong 2024-04-15 154 return xfs_trans_reserve_quota_nblks(tp, req->ip2, req->ip2_bcount,
42672471f938cd Darrick J. Wong 2024-04-15 155 req->ip2_rtbcount, true);
42672471f938cd Darrick J. Wong 2024-04-15 156 }
42672471f938cd Darrick J. Wong 2024-04-15 157
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 8+ messages in thread
* fs/xfs/xfs_exchrange.c:114:11-12: WARNING opportunity for max()
@ 2024-11-15 1:03 kernel test robot
0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2024-11-15 1:03 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: "Darrick J. Wong" <djwong@kernel.org>
CC: Christoph Hellwig <hch@lst.de>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: cfaaa7d010d1fc58f9717fcc8591201e741d2d49
commit: 42672471f938cdab2573f32ce23915b78f0578f4 xfs: bind together the front and back ends of the file range exchange code
date: 7 months ago
:::::: branch date: 7 hours ago
:::::: commit date: 7 months ago
config: x86_64-randconfig-104-20241115 (https://download.01.org/0day-ci/archive/20241115/202411150811.CWJ0dBZ7-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.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/202411150811.CWJ0dBZ7-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> fs/xfs/xfs_exchrange.c:114:11-12: WARNING opportunity for max()
fs/xfs/xfs_exchrange.c:115:11-12: WARNING opportunity for max()
vim +114 fs/xfs/xfs_exchrange.c
42672471f938cda Darrick J. Wong 2024-04-15 76
42672471f938cda Darrick J. Wong 2024-04-15 77 /*
42672471f938cda Darrick J. Wong 2024-04-15 78 * Obtain a quota reservation to make sure we don't hit EDQUOT. We can skip
42672471f938cda Darrick J. Wong 2024-04-15 79 * this if quota enforcement is disabled or if both inodes' dquots are the
42672471f938cda Darrick J. Wong 2024-04-15 80 * same. The qretry structure must be initialized to zeroes before the first
42672471f938cda Darrick J. Wong 2024-04-15 81 * call to this function.
42672471f938cda Darrick J. Wong 2024-04-15 82 */
42672471f938cda Darrick J. Wong 2024-04-15 83 STATIC int
42672471f938cda Darrick J. Wong 2024-04-15 84 xfs_exchrange_reserve_quota(
42672471f938cda Darrick J. Wong 2024-04-15 85 struct xfs_trans *tp,
42672471f938cda Darrick J. Wong 2024-04-15 86 const struct xfs_exchmaps_req *req,
42672471f938cda Darrick J. Wong 2024-04-15 87 unsigned int *qretry)
42672471f938cda Darrick J. Wong 2024-04-15 88 {
42672471f938cda Darrick J. Wong 2024-04-15 89 int64_t ddelta, rdelta;
42672471f938cda Darrick J. Wong 2024-04-15 90 int ip1_error = 0;
42672471f938cda Darrick J. Wong 2024-04-15 91 int error;
42672471f938cda Darrick J. Wong 2024-04-15 92
42672471f938cda Darrick J. Wong 2024-04-15 93 /*
42672471f938cda Darrick J. Wong 2024-04-15 94 * Don't bother with a quota reservation if we're not enforcing them
42672471f938cda Darrick J. Wong 2024-04-15 95 * or the two inodes have the same dquots.
42672471f938cda Darrick J. Wong 2024-04-15 96 */
42672471f938cda Darrick J. Wong 2024-04-15 97 if (!XFS_IS_QUOTA_ON(tp->t_mountp) || req->ip1 == req->ip2 ||
42672471f938cda Darrick J. Wong 2024-04-15 98 (req->ip1->i_udquot == req->ip2->i_udquot &&
42672471f938cda Darrick J. Wong 2024-04-15 99 req->ip1->i_gdquot == req->ip2->i_gdquot &&
42672471f938cda Darrick J. Wong 2024-04-15 100 req->ip1->i_pdquot == req->ip2->i_pdquot))
42672471f938cda Darrick J. Wong 2024-04-15 101 return 0;
42672471f938cda Darrick J. Wong 2024-04-15 102
42672471f938cda Darrick J. Wong 2024-04-15 103 *qretry = 0;
42672471f938cda Darrick J. Wong 2024-04-15 104
42672471f938cda Darrick J. Wong 2024-04-15 105 /*
42672471f938cda Darrick J. Wong 2024-04-15 106 * For each file, compute the net gain in the number of regular blocks
42672471f938cda Darrick J. Wong 2024-04-15 107 * that will be mapped into that file and reserve that much quota. The
42672471f938cda Darrick J. Wong 2024-04-15 108 * quota counts must be able to absorb at least that much space.
42672471f938cda Darrick J. Wong 2024-04-15 109 */
42672471f938cda Darrick J. Wong 2024-04-15 110 ddelta = req->ip2_bcount - req->ip1_bcount;
42672471f938cda Darrick J. Wong 2024-04-15 111 rdelta = req->ip2_rtbcount - req->ip1_rtbcount;
42672471f938cda Darrick J. Wong 2024-04-15 112 if (ddelta > 0 || rdelta > 0) {
42672471f938cda Darrick J. Wong 2024-04-15 113 error = xfs_trans_reserve_quota_nblks(tp, req->ip1,
42672471f938cda Darrick J. Wong 2024-04-15 @114 ddelta > 0 ? ddelta : 0,
42672471f938cda Darrick J. Wong 2024-04-15 115 rdelta > 0 ? rdelta : 0,
42672471f938cda Darrick J. Wong 2024-04-15 116 false);
42672471f938cda Darrick J. Wong 2024-04-15 117 if (error == -EDQUOT || error == -ENOSPC) {
42672471f938cda Darrick J. Wong 2024-04-15 118 /*
42672471f938cda Darrick J. Wong 2024-04-15 119 * Save this error and see what happens if we try to
42672471f938cda Darrick J. Wong 2024-04-15 120 * reserve quota for ip2. Then report both.
42672471f938cda Darrick J. Wong 2024-04-15 121 */
42672471f938cda Darrick J. Wong 2024-04-15 122 *qretry |= QRETRY_IP1;
42672471f938cda Darrick J. Wong 2024-04-15 123 ip1_error = error;
42672471f938cda Darrick J. Wong 2024-04-15 124 error = 0;
42672471f938cda Darrick J. Wong 2024-04-15 125 }
42672471f938cda Darrick J. Wong 2024-04-15 126 if (error)
42672471f938cda Darrick J. Wong 2024-04-15 127 return error;
42672471f938cda Darrick J. Wong 2024-04-15 128 }
42672471f938cda Darrick J. Wong 2024-04-15 129 if (ddelta < 0 || rdelta < 0) {
42672471f938cda Darrick J. Wong 2024-04-15 130 error = xfs_trans_reserve_quota_nblks(tp, req->ip2,
42672471f938cda Darrick J. Wong 2024-04-15 131 ddelta < 0 ? -ddelta : 0,
42672471f938cda Darrick J. Wong 2024-04-15 132 rdelta < 0 ? -rdelta : 0,
42672471f938cda Darrick J. Wong 2024-04-15 133 false);
42672471f938cda Darrick J. Wong 2024-04-15 134 if (error == -EDQUOT || error == -ENOSPC)
42672471f938cda Darrick J. Wong 2024-04-15 135 *qretry |= QRETRY_IP2;
42672471f938cda Darrick J. Wong 2024-04-15 136 if (error)
42672471f938cda Darrick J. Wong 2024-04-15 137 return error;
42672471f938cda Darrick J. Wong 2024-04-15 138 }
42672471f938cda Darrick J. Wong 2024-04-15 139 if (ip1_error)
42672471f938cda Darrick J. Wong 2024-04-15 140 return ip1_error;
42672471f938cda Darrick J. Wong 2024-04-15 141
42672471f938cda Darrick J. Wong 2024-04-15 142 /*
42672471f938cda Darrick J. Wong 2024-04-15 143 * For each file, forcibly reserve the gross gain in mapped blocks so
42672471f938cda Darrick J. Wong 2024-04-15 144 * that we don't trip over any quota block reservation assertions.
42672471f938cda Darrick J. Wong 2024-04-15 145 * We must reserve the gross gain because the quota code subtracts from
42672471f938cda Darrick J. Wong 2024-04-15 146 * bcount the number of blocks that we unmap; it does not add that
42672471f938cda Darrick J. Wong 2024-04-15 147 * quantity back to the quota block reservation.
42672471f938cda Darrick J. Wong 2024-04-15 148 */
42672471f938cda Darrick J. Wong 2024-04-15 149 error = xfs_trans_reserve_quota_nblks(tp, req->ip1, req->ip1_bcount,
42672471f938cda Darrick J. Wong 2024-04-15 150 req->ip1_rtbcount, true);
42672471f938cda Darrick J. Wong 2024-04-15 151 if (error)
42672471f938cda Darrick J. Wong 2024-04-15 152 return error;
42672471f938cda Darrick J. Wong 2024-04-15 153
42672471f938cda Darrick J. Wong 2024-04-15 154 return xfs_trans_reserve_quota_nblks(tp, req->ip2, req->ip2_bcount,
42672471f938cda Darrick J. Wong 2024-04-15 155 req->ip2_rtbcount, true);
42672471f938cda Darrick J. Wong 2024-04-15 156 }
42672471f938cda Darrick J. Wong 2024-04-15 157
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 8+ messages in thread
* fs/xfs/xfs_exchrange.c:114:11-12: WARNING opportunity for max()
@ 2024-11-15 4:23 kernel test robot
0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2024-11-15 4:23 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: "Darrick J. Wong" <djwong@kernel.org>
CC: Christoph Hellwig <hch@lst.de>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: cfaaa7d010d1fc58f9717fcc8591201e741d2d49
commit: 42672471f938cdab2573f32ce23915b78f0578f4 xfs: bind together the front and back ends of the file range exchange code
date: 7 months ago
:::::: branch date: 10 hours ago
:::::: commit date: 7 months ago
config: x86_64-randconfig-104-20241115 (https://download.01.org/0day-ci/archive/20241115/202411151212.6qyPV9of-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.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/202411151212.6qyPV9of-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> fs/xfs/xfs_exchrange.c:114:11-12: WARNING opportunity for max()
fs/xfs/xfs_exchrange.c:115:11-12: WARNING opportunity for max()
vim +114 fs/xfs/xfs_exchrange.c
42672471f938cd Darrick J. Wong 2024-04-15 76
42672471f938cd Darrick J. Wong 2024-04-15 77 /*
42672471f938cd Darrick J. Wong 2024-04-15 78 * Obtain a quota reservation to make sure we don't hit EDQUOT. We can skip
42672471f938cd Darrick J. Wong 2024-04-15 79 * this if quota enforcement is disabled or if both inodes' dquots are the
42672471f938cd Darrick J. Wong 2024-04-15 80 * same. The qretry structure must be initialized to zeroes before the first
42672471f938cd Darrick J. Wong 2024-04-15 81 * call to this function.
42672471f938cd Darrick J. Wong 2024-04-15 82 */
42672471f938cd Darrick J. Wong 2024-04-15 83 STATIC int
42672471f938cd Darrick J. Wong 2024-04-15 84 xfs_exchrange_reserve_quota(
42672471f938cd Darrick J. Wong 2024-04-15 85 struct xfs_trans *tp,
42672471f938cd Darrick J. Wong 2024-04-15 86 const struct xfs_exchmaps_req *req,
42672471f938cd Darrick J. Wong 2024-04-15 87 unsigned int *qretry)
42672471f938cd Darrick J. Wong 2024-04-15 88 {
42672471f938cd Darrick J. Wong 2024-04-15 89 int64_t ddelta, rdelta;
42672471f938cd Darrick J. Wong 2024-04-15 90 int ip1_error = 0;
42672471f938cd Darrick J. Wong 2024-04-15 91 int error;
42672471f938cd Darrick J. Wong 2024-04-15 92
42672471f938cd Darrick J. Wong 2024-04-15 93 /*
42672471f938cd Darrick J. Wong 2024-04-15 94 * Don't bother with a quota reservation if we're not enforcing them
42672471f938cd Darrick J. Wong 2024-04-15 95 * or the two inodes have the same dquots.
42672471f938cd Darrick J. Wong 2024-04-15 96 */
42672471f938cd Darrick J. Wong 2024-04-15 97 if (!XFS_IS_QUOTA_ON(tp->t_mountp) || req->ip1 == req->ip2 ||
42672471f938cd Darrick J. Wong 2024-04-15 98 (req->ip1->i_udquot == req->ip2->i_udquot &&
42672471f938cd Darrick J. Wong 2024-04-15 99 req->ip1->i_gdquot == req->ip2->i_gdquot &&
42672471f938cd Darrick J. Wong 2024-04-15 100 req->ip1->i_pdquot == req->ip2->i_pdquot))
42672471f938cd Darrick J. Wong 2024-04-15 101 return 0;
42672471f938cd Darrick J. Wong 2024-04-15 102
42672471f938cd Darrick J. Wong 2024-04-15 103 *qretry = 0;
42672471f938cd Darrick J. Wong 2024-04-15 104
42672471f938cd Darrick J. Wong 2024-04-15 105 /*
42672471f938cd Darrick J. Wong 2024-04-15 106 * For each file, compute the net gain in the number of regular blocks
42672471f938cd Darrick J. Wong 2024-04-15 107 * that will be mapped into that file and reserve that much quota. The
42672471f938cd Darrick J. Wong 2024-04-15 108 * quota counts must be able to absorb at least that much space.
42672471f938cd Darrick J. Wong 2024-04-15 109 */
42672471f938cd Darrick J. Wong 2024-04-15 110 ddelta = req->ip2_bcount - req->ip1_bcount;
42672471f938cd Darrick J. Wong 2024-04-15 111 rdelta = req->ip2_rtbcount - req->ip1_rtbcount;
42672471f938cd Darrick J. Wong 2024-04-15 112 if (ddelta > 0 || rdelta > 0) {
42672471f938cd Darrick J. Wong 2024-04-15 113 error = xfs_trans_reserve_quota_nblks(tp, req->ip1,
42672471f938cd Darrick J. Wong 2024-04-15 @114 ddelta > 0 ? ddelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 115 rdelta > 0 ? rdelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 116 false);
42672471f938cd Darrick J. Wong 2024-04-15 117 if (error == -EDQUOT || error == -ENOSPC) {
42672471f938cd Darrick J. Wong 2024-04-15 118 /*
42672471f938cd Darrick J. Wong 2024-04-15 119 * Save this error and see what happens if we try to
42672471f938cd Darrick J. Wong 2024-04-15 120 * reserve quota for ip2. Then report both.
42672471f938cd Darrick J. Wong 2024-04-15 121 */
42672471f938cd Darrick J. Wong 2024-04-15 122 *qretry |= QRETRY_IP1;
42672471f938cd Darrick J. Wong 2024-04-15 123 ip1_error = error;
42672471f938cd Darrick J. Wong 2024-04-15 124 error = 0;
42672471f938cd Darrick J. Wong 2024-04-15 125 }
42672471f938cd Darrick J. Wong 2024-04-15 126 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 127 return error;
42672471f938cd Darrick J. Wong 2024-04-15 128 }
42672471f938cd Darrick J. Wong 2024-04-15 129 if (ddelta < 0 || rdelta < 0) {
42672471f938cd Darrick J. Wong 2024-04-15 130 error = xfs_trans_reserve_quota_nblks(tp, req->ip2,
42672471f938cd Darrick J. Wong 2024-04-15 131 ddelta < 0 ? -ddelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 132 rdelta < 0 ? -rdelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 133 false);
42672471f938cd Darrick J. Wong 2024-04-15 134 if (error == -EDQUOT || error == -ENOSPC)
42672471f938cd Darrick J. Wong 2024-04-15 135 *qretry |= QRETRY_IP2;
42672471f938cd Darrick J. Wong 2024-04-15 136 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 137 return error;
42672471f938cd Darrick J. Wong 2024-04-15 138 }
42672471f938cd Darrick J. Wong 2024-04-15 139 if (ip1_error)
42672471f938cd Darrick J. Wong 2024-04-15 140 return ip1_error;
42672471f938cd Darrick J. Wong 2024-04-15 141
42672471f938cd Darrick J. Wong 2024-04-15 142 /*
42672471f938cd Darrick J. Wong 2024-04-15 143 * For each file, forcibly reserve the gross gain in mapped blocks so
42672471f938cd Darrick J. Wong 2024-04-15 144 * that we don't trip over any quota block reservation assertions.
42672471f938cd Darrick J. Wong 2024-04-15 145 * We must reserve the gross gain because the quota code subtracts from
42672471f938cd Darrick J. Wong 2024-04-15 146 * bcount the number of blocks that we unmap; it does not add that
42672471f938cd Darrick J. Wong 2024-04-15 147 * quantity back to the quota block reservation.
42672471f938cd Darrick J. Wong 2024-04-15 148 */
42672471f938cd Darrick J. Wong 2024-04-15 149 error = xfs_trans_reserve_quota_nblks(tp, req->ip1, req->ip1_bcount,
42672471f938cd Darrick J. Wong 2024-04-15 150 req->ip1_rtbcount, true);
42672471f938cd Darrick J. Wong 2024-04-15 151 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 152 return error;
42672471f938cd Darrick J. Wong 2024-04-15 153
42672471f938cd Darrick J. Wong 2024-04-15 154 return xfs_trans_reserve_quota_nblks(tp, req->ip2, req->ip2_bcount,
42672471f938cd Darrick J. Wong 2024-04-15 155 req->ip2_rtbcount, true);
42672471f938cd Darrick J. Wong 2024-04-15 156 }
42672471f938cd Darrick J. Wong 2024-04-15 157
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 8+ messages in thread
* fs/xfs/xfs_exchrange.c:114:11-12: WARNING opportunity for max()
@ 2024-11-21 7:12 kernel test robot
0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2024-11-21 7:12 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: "Darrick J. Wong" <djwong@kernel.org>
CC: Christoph Hellwig <hch@lst.de>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 43fb83c17ba2d63dfb798f0be7453ed55ca3f9c2
commit: 42672471f938cdab2573f32ce23915b78f0578f4 xfs: bind together the front and back ends of the file range exchange code
date: 7 months ago
:::::: branch date: 7 hours ago
:::::: commit date: 7 months ago
config: x86_64-randconfig-104-20241115 (https://download.01.org/0day-ci/archive/20241121/202411211500.WbW2jbuy-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.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/202411211500.WbW2jbuy-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> fs/xfs/xfs_exchrange.c:114:11-12: WARNING opportunity for max()
fs/xfs/xfs_exchrange.c:115:11-12: WARNING opportunity for max()
vim +114 fs/xfs/xfs_exchrange.c
42672471f938cd Darrick J. Wong 2024-04-15 76
42672471f938cd Darrick J. Wong 2024-04-15 77 /*
42672471f938cd Darrick J. Wong 2024-04-15 78 * Obtain a quota reservation to make sure we don't hit EDQUOT. We can skip
42672471f938cd Darrick J. Wong 2024-04-15 79 * this if quota enforcement is disabled or if both inodes' dquots are the
42672471f938cd Darrick J. Wong 2024-04-15 80 * same. The qretry structure must be initialized to zeroes before the first
42672471f938cd Darrick J. Wong 2024-04-15 81 * call to this function.
42672471f938cd Darrick J. Wong 2024-04-15 82 */
42672471f938cd Darrick J. Wong 2024-04-15 83 STATIC int
42672471f938cd Darrick J. Wong 2024-04-15 84 xfs_exchrange_reserve_quota(
42672471f938cd Darrick J. Wong 2024-04-15 85 struct xfs_trans *tp,
42672471f938cd Darrick J. Wong 2024-04-15 86 const struct xfs_exchmaps_req *req,
42672471f938cd Darrick J. Wong 2024-04-15 87 unsigned int *qretry)
42672471f938cd Darrick J. Wong 2024-04-15 88 {
42672471f938cd Darrick J. Wong 2024-04-15 89 int64_t ddelta, rdelta;
42672471f938cd Darrick J. Wong 2024-04-15 90 int ip1_error = 0;
42672471f938cd Darrick J. Wong 2024-04-15 91 int error;
42672471f938cd Darrick J. Wong 2024-04-15 92
42672471f938cd Darrick J. Wong 2024-04-15 93 /*
42672471f938cd Darrick J. Wong 2024-04-15 94 * Don't bother with a quota reservation if we're not enforcing them
42672471f938cd Darrick J. Wong 2024-04-15 95 * or the two inodes have the same dquots.
42672471f938cd Darrick J. Wong 2024-04-15 96 */
42672471f938cd Darrick J. Wong 2024-04-15 97 if (!XFS_IS_QUOTA_ON(tp->t_mountp) || req->ip1 == req->ip2 ||
42672471f938cd Darrick J. Wong 2024-04-15 98 (req->ip1->i_udquot == req->ip2->i_udquot &&
42672471f938cd Darrick J. Wong 2024-04-15 99 req->ip1->i_gdquot == req->ip2->i_gdquot &&
42672471f938cd Darrick J. Wong 2024-04-15 100 req->ip1->i_pdquot == req->ip2->i_pdquot))
42672471f938cd Darrick J. Wong 2024-04-15 101 return 0;
42672471f938cd Darrick J. Wong 2024-04-15 102
42672471f938cd Darrick J. Wong 2024-04-15 103 *qretry = 0;
42672471f938cd Darrick J. Wong 2024-04-15 104
42672471f938cd Darrick J. Wong 2024-04-15 105 /*
42672471f938cd Darrick J. Wong 2024-04-15 106 * For each file, compute the net gain in the number of regular blocks
42672471f938cd Darrick J. Wong 2024-04-15 107 * that will be mapped into that file and reserve that much quota. The
42672471f938cd Darrick J. Wong 2024-04-15 108 * quota counts must be able to absorb at least that much space.
42672471f938cd Darrick J. Wong 2024-04-15 109 */
42672471f938cd Darrick J. Wong 2024-04-15 110 ddelta = req->ip2_bcount - req->ip1_bcount;
42672471f938cd Darrick J. Wong 2024-04-15 111 rdelta = req->ip2_rtbcount - req->ip1_rtbcount;
42672471f938cd Darrick J. Wong 2024-04-15 112 if (ddelta > 0 || rdelta > 0) {
42672471f938cd Darrick J. Wong 2024-04-15 113 error = xfs_trans_reserve_quota_nblks(tp, req->ip1,
42672471f938cd Darrick J. Wong 2024-04-15 @114 ddelta > 0 ? ddelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 115 rdelta > 0 ? rdelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 116 false);
42672471f938cd Darrick J. Wong 2024-04-15 117 if (error == -EDQUOT || error == -ENOSPC) {
42672471f938cd Darrick J. Wong 2024-04-15 118 /*
42672471f938cd Darrick J. Wong 2024-04-15 119 * Save this error and see what happens if we try to
42672471f938cd Darrick J. Wong 2024-04-15 120 * reserve quota for ip2. Then report both.
42672471f938cd Darrick J. Wong 2024-04-15 121 */
42672471f938cd Darrick J. Wong 2024-04-15 122 *qretry |= QRETRY_IP1;
42672471f938cd Darrick J. Wong 2024-04-15 123 ip1_error = error;
42672471f938cd Darrick J. Wong 2024-04-15 124 error = 0;
42672471f938cd Darrick J. Wong 2024-04-15 125 }
42672471f938cd Darrick J. Wong 2024-04-15 126 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 127 return error;
42672471f938cd Darrick J. Wong 2024-04-15 128 }
42672471f938cd Darrick J. Wong 2024-04-15 129 if (ddelta < 0 || rdelta < 0) {
42672471f938cd Darrick J. Wong 2024-04-15 130 error = xfs_trans_reserve_quota_nblks(tp, req->ip2,
42672471f938cd Darrick J. Wong 2024-04-15 131 ddelta < 0 ? -ddelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 132 rdelta < 0 ? -rdelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 133 false);
42672471f938cd Darrick J. Wong 2024-04-15 134 if (error == -EDQUOT || error == -ENOSPC)
42672471f938cd Darrick J. Wong 2024-04-15 135 *qretry |= QRETRY_IP2;
42672471f938cd Darrick J. Wong 2024-04-15 136 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 137 return error;
42672471f938cd Darrick J. Wong 2024-04-15 138 }
42672471f938cd Darrick J. Wong 2024-04-15 139 if (ip1_error)
42672471f938cd Darrick J. Wong 2024-04-15 140 return ip1_error;
42672471f938cd Darrick J. Wong 2024-04-15 141
42672471f938cd Darrick J. Wong 2024-04-15 142 /*
42672471f938cd Darrick J. Wong 2024-04-15 143 * For each file, forcibly reserve the gross gain in mapped blocks so
42672471f938cd Darrick J. Wong 2024-04-15 144 * that we don't trip over any quota block reservation assertions.
42672471f938cd Darrick J. Wong 2024-04-15 145 * We must reserve the gross gain because the quota code subtracts from
42672471f938cd Darrick J. Wong 2024-04-15 146 * bcount the number of blocks that we unmap; it does not add that
42672471f938cd Darrick J. Wong 2024-04-15 147 * quantity back to the quota block reservation.
42672471f938cd Darrick J. Wong 2024-04-15 148 */
42672471f938cd Darrick J. Wong 2024-04-15 149 error = xfs_trans_reserve_quota_nblks(tp, req->ip1, req->ip1_bcount,
42672471f938cd Darrick J. Wong 2024-04-15 150 req->ip1_rtbcount, true);
42672471f938cd Darrick J. Wong 2024-04-15 151 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 152 return error;
42672471f938cd Darrick J. Wong 2024-04-15 153
42672471f938cd Darrick J. Wong 2024-04-15 154 return xfs_trans_reserve_quota_nblks(tp, req->ip2, req->ip2_bcount,
42672471f938cd Darrick J. Wong 2024-04-15 155 req->ip2_rtbcount, true);
42672471f938cd Darrick J. Wong 2024-04-15 156 }
42672471f938cd Darrick J. Wong 2024-04-15 157
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 8+ messages in thread
* fs/xfs/xfs_exchrange.c:114:11-12: WARNING opportunity for max()
@ 2024-11-21 23:59 kernel test robot
0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2024-11-21 23:59 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: "Darrick J. Wong" <djwong@kernel.org>
CC: Christoph Hellwig <hch@lst.de>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 341d041daae52cd5f014f68c1c7d9039db818fca
commit: 42672471f938cdab2573f32ce23915b78f0578f4 xfs: bind together the front and back ends of the file range exchange code
date: 7 months ago
:::::: branch date: 3 hours ago
:::::: commit date: 7 months ago
config: x86_64-randconfig-104-20241115 (https://download.01.org/0day-ci/archive/20241122/202411220747.KII4wqun-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.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/202411220747.KII4wqun-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> fs/xfs/xfs_exchrange.c:114:11-12: WARNING opportunity for max()
fs/xfs/xfs_exchrange.c:115:11-12: WARNING opportunity for max()
vim +114 fs/xfs/xfs_exchrange.c
42672471f938cd Darrick J. Wong 2024-04-15 76
42672471f938cd Darrick J. Wong 2024-04-15 77 /*
42672471f938cd Darrick J. Wong 2024-04-15 78 * Obtain a quota reservation to make sure we don't hit EDQUOT. We can skip
42672471f938cd Darrick J. Wong 2024-04-15 79 * this if quota enforcement is disabled or if both inodes' dquots are the
42672471f938cd Darrick J. Wong 2024-04-15 80 * same. The qretry structure must be initialized to zeroes before the first
42672471f938cd Darrick J. Wong 2024-04-15 81 * call to this function.
42672471f938cd Darrick J. Wong 2024-04-15 82 */
42672471f938cd Darrick J. Wong 2024-04-15 83 STATIC int
42672471f938cd Darrick J. Wong 2024-04-15 84 xfs_exchrange_reserve_quota(
42672471f938cd Darrick J. Wong 2024-04-15 85 struct xfs_trans *tp,
42672471f938cd Darrick J. Wong 2024-04-15 86 const struct xfs_exchmaps_req *req,
42672471f938cd Darrick J. Wong 2024-04-15 87 unsigned int *qretry)
42672471f938cd Darrick J. Wong 2024-04-15 88 {
42672471f938cd Darrick J. Wong 2024-04-15 89 int64_t ddelta, rdelta;
42672471f938cd Darrick J. Wong 2024-04-15 90 int ip1_error = 0;
42672471f938cd Darrick J. Wong 2024-04-15 91 int error;
42672471f938cd Darrick J. Wong 2024-04-15 92
42672471f938cd Darrick J. Wong 2024-04-15 93 /*
42672471f938cd Darrick J. Wong 2024-04-15 94 * Don't bother with a quota reservation if we're not enforcing them
42672471f938cd Darrick J. Wong 2024-04-15 95 * or the two inodes have the same dquots.
42672471f938cd Darrick J. Wong 2024-04-15 96 */
42672471f938cd Darrick J. Wong 2024-04-15 97 if (!XFS_IS_QUOTA_ON(tp->t_mountp) || req->ip1 == req->ip2 ||
42672471f938cd Darrick J. Wong 2024-04-15 98 (req->ip1->i_udquot == req->ip2->i_udquot &&
42672471f938cd Darrick J. Wong 2024-04-15 99 req->ip1->i_gdquot == req->ip2->i_gdquot &&
42672471f938cd Darrick J. Wong 2024-04-15 100 req->ip1->i_pdquot == req->ip2->i_pdquot))
42672471f938cd Darrick J. Wong 2024-04-15 101 return 0;
42672471f938cd Darrick J. Wong 2024-04-15 102
42672471f938cd Darrick J. Wong 2024-04-15 103 *qretry = 0;
42672471f938cd Darrick J. Wong 2024-04-15 104
42672471f938cd Darrick J. Wong 2024-04-15 105 /*
42672471f938cd Darrick J. Wong 2024-04-15 106 * For each file, compute the net gain in the number of regular blocks
42672471f938cd Darrick J. Wong 2024-04-15 107 * that will be mapped into that file and reserve that much quota. The
42672471f938cd Darrick J. Wong 2024-04-15 108 * quota counts must be able to absorb at least that much space.
42672471f938cd Darrick J. Wong 2024-04-15 109 */
42672471f938cd Darrick J. Wong 2024-04-15 110 ddelta = req->ip2_bcount - req->ip1_bcount;
42672471f938cd Darrick J. Wong 2024-04-15 111 rdelta = req->ip2_rtbcount - req->ip1_rtbcount;
42672471f938cd Darrick J. Wong 2024-04-15 112 if (ddelta > 0 || rdelta > 0) {
42672471f938cd Darrick J. Wong 2024-04-15 113 error = xfs_trans_reserve_quota_nblks(tp, req->ip1,
42672471f938cd Darrick J. Wong 2024-04-15 @114 ddelta > 0 ? ddelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 115 rdelta > 0 ? rdelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 116 false);
42672471f938cd Darrick J. Wong 2024-04-15 117 if (error == -EDQUOT || error == -ENOSPC) {
42672471f938cd Darrick J. Wong 2024-04-15 118 /*
42672471f938cd Darrick J. Wong 2024-04-15 119 * Save this error and see what happens if we try to
42672471f938cd Darrick J. Wong 2024-04-15 120 * reserve quota for ip2. Then report both.
42672471f938cd Darrick J. Wong 2024-04-15 121 */
42672471f938cd Darrick J. Wong 2024-04-15 122 *qretry |= QRETRY_IP1;
42672471f938cd Darrick J. Wong 2024-04-15 123 ip1_error = error;
42672471f938cd Darrick J. Wong 2024-04-15 124 error = 0;
42672471f938cd Darrick J. Wong 2024-04-15 125 }
42672471f938cd Darrick J. Wong 2024-04-15 126 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 127 return error;
42672471f938cd Darrick J. Wong 2024-04-15 128 }
42672471f938cd Darrick J. Wong 2024-04-15 129 if (ddelta < 0 || rdelta < 0) {
42672471f938cd Darrick J. Wong 2024-04-15 130 error = xfs_trans_reserve_quota_nblks(tp, req->ip2,
42672471f938cd Darrick J. Wong 2024-04-15 131 ddelta < 0 ? -ddelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 132 rdelta < 0 ? -rdelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 133 false);
42672471f938cd Darrick J. Wong 2024-04-15 134 if (error == -EDQUOT || error == -ENOSPC)
42672471f938cd Darrick J. Wong 2024-04-15 135 *qretry |= QRETRY_IP2;
42672471f938cd Darrick J. Wong 2024-04-15 136 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 137 return error;
42672471f938cd Darrick J. Wong 2024-04-15 138 }
42672471f938cd Darrick J. Wong 2024-04-15 139 if (ip1_error)
42672471f938cd Darrick J. Wong 2024-04-15 140 return ip1_error;
42672471f938cd Darrick J. Wong 2024-04-15 141
42672471f938cd Darrick J. Wong 2024-04-15 142 /*
42672471f938cd Darrick J. Wong 2024-04-15 143 * For each file, forcibly reserve the gross gain in mapped blocks so
42672471f938cd Darrick J. Wong 2024-04-15 144 * that we don't trip over any quota block reservation assertions.
42672471f938cd Darrick J. Wong 2024-04-15 145 * We must reserve the gross gain because the quota code subtracts from
42672471f938cd Darrick J. Wong 2024-04-15 146 * bcount the number of blocks that we unmap; it does not add that
42672471f938cd Darrick J. Wong 2024-04-15 147 * quantity back to the quota block reservation.
42672471f938cd Darrick J. Wong 2024-04-15 148 */
42672471f938cd Darrick J. Wong 2024-04-15 149 error = xfs_trans_reserve_quota_nblks(tp, req->ip1, req->ip1_bcount,
42672471f938cd Darrick J. Wong 2024-04-15 150 req->ip1_rtbcount, true);
42672471f938cd Darrick J. Wong 2024-04-15 151 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 152 return error;
42672471f938cd Darrick J. Wong 2024-04-15 153
42672471f938cd Darrick J. Wong 2024-04-15 154 return xfs_trans_reserve_quota_nblks(tp, req->ip2, req->ip2_bcount,
42672471f938cd Darrick J. Wong 2024-04-15 155 req->ip2_rtbcount, true);
42672471f938cd Darrick J. Wong 2024-04-15 156 }
42672471f938cd Darrick J. Wong 2024-04-15 157
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 8+ messages in thread
* fs/xfs/xfs_exchrange.c:114:11-12: WARNING opportunity for max()
@ 2024-12-05 8:21 kernel test robot
0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2024-12-05 8:21 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: "Darrick J. Wong" <djwong@kernel.org>
CC: Christoph Hellwig <hch@lst.de>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: feffde684ac29a3b7aec82d2df850fbdbdee55e4
commit: 42672471f938cdab2573f32ce23915b78f0578f4 xfs: bind together the front and back ends of the file range exchange code
date: 8 months ago
:::::: branch date: 2 days ago
:::::: commit date: 8 months ago
config: x86_64-randconfig-104-20241115 (https://download.01.org/0day-ci/archive/20241205/202412051820.tfmP0eAc-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.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/202412051820.tfmP0eAc-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> fs/xfs/xfs_exchrange.c:114:11-12: WARNING opportunity for max()
fs/xfs/xfs_exchrange.c:115:11-12: WARNING opportunity for max()
vim +114 fs/xfs/xfs_exchrange.c
42672471f938cd Darrick J. Wong 2024-04-15 76
42672471f938cd Darrick J. Wong 2024-04-15 77 /*
42672471f938cd Darrick J. Wong 2024-04-15 78 * Obtain a quota reservation to make sure we don't hit EDQUOT. We can skip
42672471f938cd Darrick J. Wong 2024-04-15 79 * this if quota enforcement is disabled or if both inodes' dquots are the
42672471f938cd Darrick J. Wong 2024-04-15 80 * same. The qretry structure must be initialized to zeroes before the first
42672471f938cd Darrick J. Wong 2024-04-15 81 * call to this function.
42672471f938cd Darrick J. Wong 2024-04-15 82 */
42672471f938cd Darrick J. Wong 2024-04-15 83 STATIC int
42672471f938cd Darrick J. Wong 2024-04-15 84 xfs_exchrange_reserve_quota(
42672471f938cd Darrick J. Wong 2024-04-15 85 struct xfs_trans *tp,
42672471f938cd Darrick J. Wong 2024-04-15 86 const struct xfs_exchmaps_req *req,
42672471f938cd Darrick J. Wong 2024-04-15 87 unsigned int *qretry)
42672471f938cd Darrick J. Wong 2024-04-15 88 {
42672471f938cd Darrick J. Wong 2024-04-15 89 int64_t ddelta, rdelta;
42672471f938cd Darrick J. Wong 2024-04-15 90 int ip1_error = 0;
42672471f938cd Darrick J. Wong 2024-04-15 91 int error;
42672471f938cd Darrick J. Wong 2024-04-15 92
42672471f938cd Darrick J. Wong 2024-04-15 93 /*
42672471f938cd Darrick J. Wong 2024-04-15 94 * Don't bother with a quota reservation if we're not enforcing them
42672471f938cd Darrick J. Wong 2024-04-15 95 * or the two inodes have the same dquots.
42672471f938cd Darrick J. Wong 2024-04-15 96 */
42672471f938cd Darrick J. Wong 2024-04-15 97 if (!XFS_IS_QUOTA_ON(tp->t_mountp) || req->ip1 == req->ip2 ||
42672471f938cd Darrick J. Wong 2024-04-15 98 (req->ip1->i_udquot == req->ip2->i_udquot &&
42672471f938cd Darrick J. Wong 2024-04-15 99 req->ip1->i_gdquot == req->ip2->i_gdquot &&
42672471f938cd Darrick J. Wong 2024-04-15 100 req->ip1->i_pdquot == req->ip2->i_pdquot))
42672471f938cd Darrick J. Wong 2024-04-15 101 return 0;
42672471f938cd Darrick J. Wong 2024-04-15 102
42672471f938cd Darrick J. Wong 2024-04-15 103 *qretry = 0;
42672471f938cd Darrick J. Wong 2024-04-15 104
42672471f938cd Darrick J. Wong 2024-04-15 105 /*
42672471f938cd Darrick J. Wong 2024-04-15 106 * For each file, compute the net gain in the number of regular blocks
42672471f938cd Darrick J. Wong 2024-04-15 107 * that will be mapped into that file and reserve that much quota. The
42672471f938cd Darrick J. Wong 2024-04-15 108 * quota counts must be able to absorb at least that much space.
42672471f938cd Darrick J. Wong 2024-04-15 109 */
42672471f938cd Darrick J. Wong 2024-04-15 110 ddelta = req->ip2_bcount - req->ip1_bcount;
42672471f938cd Darrick J. Wong 2024-04-15 111 rdelta = req->ip2_rtbcount - req->ip1_rtbcount;
42672471f938cd Darrick J. Wong 2024-04-15 112 if (ddelta > 0 || rdelta > 0) {
42672471f938cd Darrick J. Wong 2024-04-15 113 error = xfs_trans_reserve_quota_nblks(tp, req->ip1,
42672471f938cd Darrick J. Wong 2024-04-15 @114 ddelta > 0 ? ddelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 115 rdelta > 0 ? rdelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 116 false);
42672471f938cd Darrick J. Wong 2024-04-15 117 if (error == -EDQUOT || error == -ENOSPC) {
42672471f938cd Darrick J. Wong 2024-04-15 118 /*
42672471f938cd Darrick J. Wong 2024-04-15 119 * Save this error and see what happens if we try to
42672471f938cd Darrick J. Wong 2024-04-15 120 * reserve quota for ip2. Then report both.
42672471f938cd Darrick J. Wong 2024-04-15 121 */
42672471f938cd Darrick J. Wong 2024-04-15 122 *qretry |= QRETRY_IP1;
42672471f938cd Darrick J. Wong 2024-04-15 123 ip1_error = error;
42672471f938cd Darrick J. Wong 2024-04-15 124 error = 0;
42672471f938cd Darrick J. Wong 2024-04-15 125 }
42672471f938cd Darrick J. Wong 2024-04-15 126 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 127 return error;
42672471f938cd Darrick J. Wong 2024-04-15 128 }
42672471f938cd Darrick J. Wong 2024-04-15 129 if (ddelta < 0 || rdelta < 0) {
42672471f938cd Darrick J. Wong 2024-04-15 130 error = xfs_trans_reserve_quota_nblks(tp, req->ip2,
42672471f938cd Darrick J. Wong 2024-04-15 131 ddelta < 0 ? -ddelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 132 rdelta < 0 ? -rdelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 133 false);
42672471f938cd Darrick J. Wong 2024-04-15 134 if (error == -EDQUOT || error == -ENOSPC)
42672471f938cd Darrick J. Wong 2024-04-15 135 *qretry |= QRETRY_IP2;
42672471f938cd Darrick J. Wong 2024-04-15 136 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 137 return error;
42672471f938cd Darrick J. Wong 2024-04-15 138 }
42672471f938cd Darrick J. Wong 2024-04-15 139 if (ip1_error)
42672471f938cd Darrick J. Wong 2024-04-15 140 return ip1_error;
42672471f938cd Darrick J. Wong 2024-04-15 141
42672471f938cd Darrick J. Wong 2024-04-15 142 /*
42672471f938cd Darrick J. Wong 2024-04-15 143 * For each file, forcibly reserve the gross gain in mapped blocks so
42672471f938cd Darrick J. Wong 2024-04-15 144 * that we don't trip over any quota block reservation assertions.
42672471f938cd Darrick J. Wong 2024-04-15 145 * We must reserve the gross gain because the quota code subtracts from
42672471f938cd Darrick J. Wong 2024-04-15 146 * bcount the number of blocks that we unmap; it does not add that
42672471f938cd Darrick J. Wong 2024-04-15 147 * quantity back to the quota block reservation.
42672471f938cd Darrick J. Wong 2024-04-15 148 */
42672471f938cd Darrick J. Wong 2024-04-15 149 error = xfs_trans_reserve_quota_nblks(tp, req->ip1, req->ip1_bcount,
42672471f938cd Darrick J. Wong 2024-04-15 150 req->ip1_rtbcount, true);
42672471f938cd Darrick J. Wong 2024-04-15 151 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 152 return error;
42672471f938cd Darrick J. Wong 2024-04-15 153
42672471f938cd Darrick J. Wong 2024-04-15 154 return xfs_trans_reserve_quota_nblks(tp, req->ip2, req->ip2_bcount,
42672471f938cd Darrick J. Wong 2024-04-15 155 req->ip2_rtbcount, true);
42672471f938cd Darrick J. Wong 2024-04-15 156 }
42672471f938cd Darrick J. Wong 2024-04-15 157
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 8+ messages in thread
* fs/xfs/xfs_exchrange.c:114:11-12: WARNING opportunity for max()
@ 2024-12-14 7:37 kernel test robot
0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2024-12-14 7:37 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: "Darrick J. Wong" <djwong@kernel.org>
CC: Christoph Hellwig <hch@lst.de>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: a446e965a188ee8f745859e63ce046fe98577d45
commit: 42672471f938cdab2573f32ce23915b78f0578f4 xfs: bind together the front and back ends of the file range exchange code
date: 8 months ago
:::::: branch date: 6 hours ago
:::::: commit date: 8 months ago
config: csky-randconfig-r053-20241214 (https://download.01.org/0day-ci/archive/20241214/202412141541.LHLhngdU-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 14.2.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/202412141541.LHLhngdU-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> fs/xfs/xfs_exchrange.c:114:11-12: WARNING opportunity for max()
fs/xfs/xfs_exchrange.c:115:11-12: WARNING opportunity for max()
vim +114 fs/xfs/xfs_exchrange.c
42672471f938cd Darrick J. Wong 2024-04-15 76
42672471f938cd Darrick J. Wong 2024-04-15 77 /*
42672471f938cd Darrick J. Wong 2024-04-15 78 * Obtain a quota reservation to make sure we don't hit EDQUOT. We can skip
42672471f938cd Darrick J. Wong 2024-04-15 79 * this if quota enforcement is disabled or if both inodes' dquots are the
42672471f938cd Darrick J. Wong 2024-04-15 80 * same. The qretry structure must be initialized to zeroes before the first
42672471f938cd Darrick J. Wong 2024-04-15 81 * call to this function.
42672471f938cd Darrick J. Wong 2024-04-15 82 */
42672471f938cd Darrick J. Wong 2024-04-15 83 STATIC int
42672471f938cd Darrick J. Wong 2024-04-15 84 xfs_exchrange_reserve_quota(
42672471f938cd Darrick J. Wong 2024-04-15 85 struct xfs_trans *tp,
42672471f938cd Darrick J. Wong 2024-04-15 86 const struct xfs_exchmaps_req *req,
42672471f938cd Darrick J. Wong 2024-04-15 87 unsigned int *qretry)
42672471f938cd Darrick J. Wong 2024-04-15 88 {
42672471f938cd Darrick J. Wong 2024-04-15 89 int64_t ddelta, rdelta;
42672471f938cd Darrick J. Wong 2024-04-15 90 int ip1_error = 0;
42672471f938cd Darrick J. Wong 2024-04-15 91 int error;
42672471f938cd Darrick J. Wong 2024-04-15 92
42672471f938cd Darrick J. Wong 2024-04-15 93 /*
42672471f938cd Darrick J. Wong 2024-04-15 94 * Don't bother with a quota reservation if we're not enforcing them
42672471f938cd Darrick J. Wong 2024-04-15 95 * or the two inodes have the same dquots.
42672471f938cd Darrick J. Wong 2024-04-15 96 */
42672471f938cd Darrick J. Wong 2024-04-15 97 if (!XFS_IS_QUOTA_ON(tp->t_mountp) || req->ip1 == req->ip2 ||
42672471f938cd Darrick J. Wong 2024-04-15 98 (req->ip1->i_udquot == req->ip2->i_udquot &&
42672471f938cd Darrick J. Wong 2024-04-15 99 req->ip1->i_gdquot == req->ip2->i_gdquot &&
42672471f938cd Darrick J. Wong 2024-04-15 100 req->ip1->i_pdquot == req->ip2->i_pdquot))
42672471f938cd Darrick J. Wong 2024-04-15 101 return 0;
42672471f938cd Darrick J. Wong 2024-04-15 102
42672471f938cd Darrick J. Wong 2024-04-15 103 *qretry = 0;
42672471f938cd Darrick J. Wong 2024-04-15 104
42672471f938cd Darrick J. Wong 2024-04-15 105 /*
42672471f938cd Darrick J. Wong 2024-04-15 106 * For each file, compute the net gain in the number of regular blocks
42672471f938cd Darrick J. Wong 2024-04-15 107 * that will be mapped into that file and reserve that much quota. The
42672471f938cd Darrick J. Wong 2024-04-15 108 * quota counts must be able to absorb at least that much space.
42672471f938cd Darrick J. Wong 2024-04-15 109 */
42672471f938cd Darrick J. Wong 2024-04-15 110 ddelta = req->ip2_bcount - req->ip1_bcount;
42672471f938cd Darrick J. Wong 2024-04-15 111 rdelta = req->ip2_rtbcount - req->ip1_rtbcount;
42672471f938cd Darrick J. Wong 2024-04-15 112 if (ddelta > 0 || rdelta > 0) {
42672471f938cd Darrick J. Wong 2024-04-15 113 error = xfs_trans_reserve_quota_nblks(tp, req->ip1,
42672471f938cd Darrick J. Wong 2024-04-15 @114 ddelta > 0 ? ddelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 115 rdelta > 0 ? rdelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 116 false);
42672471f938cd Darrick J. Wong 2024-04-15 117 if (error == -EDQUOT || error == -ENOSPC) {
42672471f938cd Darrick J. Wong 2024-04-15 118 /*
42672471f938cd Darrick J. Wong 2024-04-15 119 * Save this error and see what happens if we try to
42672471f938cd Darrick J. Wong 2024-04-15 120 * reserve quota for ip2. Then report both.
42672471f938cd Darrick J. Wong 2024-04-15 121 */
42672471f938cd Darrick J. Wong 2024-04-15 122 *qretry |= QRETRY_IP1;
42672471f938cd Darrick J. Wong 2024-04-15 123 ip1_error = error;
42672471f938cd Darrick J. Wong 2024-04-15 124 error = 0;
42672471f938cd Darrick J. Wong 2024-04-15 125 }
42672471f938cd Darrick J. Wong 2024-04-15 126 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 127 return error;
42672471f938cd Darrick J. Wong 2024-04-15 128 }
42672471f938cd Darrick J. Wong 2024-04-15 129 if (ddelta < 0 || rdelta < 0) {
42672471f938cd Darrick J. Wong 2024-04-15 130 error = xfs_trans_reserve_quota_nblks(tp, req->ip2,
42672471f938cd Darrick J. Wong 2024-04-15 131 ddelta < 0 ? -ddelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 132 rdelta < 0 ? -rdelta : 0,
42672471f938cd Darrick J. Wong 2024-04-15 133 false);
42672471f938cd Darrick J. Wong 2024-04-15 134 if (error == -EDQUOT || error == -ENOSPC)
42672471f938cd Darrick J. Wong 2024-04-15 135 *qretry |= QRETRY_IP2;
42672471f938cd Darrick J. Wong 2024-04-15 136 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 137 return error;
42672471f938cd Darrick J. Wong 2024-04-15 138 }
42672471f938cd Darrick J. Wong 2024-04-15 139 if (ip1_error)
42672471f938cd Darrick J. Wong 2024-04-15 140 return ip1_error;
42672471f938cd Darrick J. Wong 2024-04-15 141
42672471f938cd Darrick J. Wong 2024-04-15 142 /*
42672471f938cd Darrick J. Wong 2024-04-15 143 * For each file, forcibly reserve the gross gain in mapped blocks so
42672471f938cd Darrick J. Wong 2024-04-15 144 * that we don't trip over any quota block reservation assertions.
42672471f938cd Darrick J. Wong 2024-04-15 145 * We must reserve the gross gain because the quota code subtracts from
42672471f938cd Darrick J. Wong 2024-04-15 146 * bcount the number of blocks that we unmap; it does not add that
42672471f938cd Darrick J. Wong 2024-04-15 147 * quantity back to the quota block reservation.
42672471f938cd Darrick J. Wong 2024-04-15 148 */
42672471f938cd Darrick J. Wong 2024-04-15 149 error = xfs_trans_reserve_quota_nblks(tp, req->ip1, req->ip1_bcount,
42672471f938cd Darrick J. Wong 2024-04-15 150 req->ip1_rtbcount, true);
42672471f938cd Darrick J. Wong 2024-04-15 151 if (error)
42672471f938cd Darrick J. Wong 2024-04-15 152 return error;
42672471f938cd Darrick J. Wong 2024-04-15 153
42672471f938cd Darrick J. Wong 2024-04-15 154 return xfs_trans_reserve_quota_nblks(tp, req->ip2, req->ip2_bcount,
42672471f938cd Darrick J. Wong 2024-04-15 155 req->ip2_rtbcount, true);
42672471f938cd Darrick J. Wong 2024-04-15 156 }
42672471f938cd Darrick J. Wong 2024-04-15 157
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-12-14 7:37 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-05 8:21 fs/xfs/xfs_exchrange.c:114:11-12: WARNING opportunity for max() kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2024-12-14 7:37 kernel test robot
2024-11-21 23:59 kernel test robot
2024-11-21 7:12 kernel test robot
2024-11-15 4:23 kernel test robot
2024-11-15 1:03 kernel test robot
2024-10-30 20:34 kernel test robot
2024-09-21 9:35 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.