From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F1681E130F for ; Wed, 30 Oct 2024 20:35:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320537; cv=none; b=UBM3NTMcO5fmq6cCVhjwpiGnjMvrKeLcnOiDF0FvBRjMxMC+E/00wDumerla4n7nInxtIdp7QEzmSzpVO0SowYoY9RpUJfcNhSk/2PxEfpkDmz9/UZGQaqEF7piZdBekcJlCZW1tkbBOfx5tPHOCqtodYy3ypCVAJTE94vN3nYY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320537; c=relaxed/simple; bh=f6hT99Pg8gLT01zDVuvsRioNqahAxV+ag+9bUsxwRd8=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=O/6lx8LWVBx3Vqg8Dd1viwFWtQifSP9LUELMZmpIjrg5UZnxwwUjvc8kAmo+H6dhjHCOjyyuwyK9HUd31w6dk3JrsSQ+mqE4CCytoC18LdFeJA2QhkWkrOTmzLMLV/tLlZwdbDYupLMpc6Ssr1YeGdc5lE89kEVHDU9tK/TCFIQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=YTUkWaST; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YTUkWaST" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730320534; x=1761856534; h=date:from:to:cc:subject:message-id:mime-version; bh=f6hT99Pg8gLT01zDVuvsRioNqahAxV+ag+9bUsxwRd8=; b=YTUkWaSTMBmLWz/5WN5tx3C2vhk+4lSCRtXFhqgDMWxW8OZj+5WDQ643 NXZ3/82i1KmBYdvPPKrI53zGZKmNse0BSXaNBlVayiqh+5rVc4xnSARHe iHo0SGq3bSqMvt36O1wi29K9CzmJCwz67kcsYjCe9NHrflq6rhMwGkILV BptE9de2zJBK/ra4ijpXPvsb2ymlPCHH3IHFdrKM1w2OdT0GTQT94/82V Z6ZsVZw78WKHnisBAXqJUJo5Np2iSzan0U7l/hcZbzmaIjTjFHj/+XEDW x6xQrs0Xng4pB47J6TnPXDS+vx3Jxx3miL0DARikbISAYrRtyGqijrzlv w==; X-CSE-ConnectionGUID: Dk3p7Kj8QS6+/GL0V38kAA== X-CSE-MsgGUID: I0jInUYxSRqirc0BDoGDEA== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="47504641" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="47504641" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2024 13:35:34 -0700 X-CSE-ConnectionGUID: TFdoWYxyTieGOakxmZHozA== X-CSE-MsgGUID: XULxHePhTfmO+pr/0h3y7g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,245,1725346800"; d="scan'208";a="82588676" Received: from lkp-server01.sh.intel.com (HELO a48cf1aa22e8) ([10.239.97.150]) by orviesa006.jf.intel.com with ESMTP; 30 Oct 2024 13:35:32 -0700 Received: from kbuild by a48cf1aa22e8 with local (Exim 4.96) (envelope-from ) id 1t6FPe-000fHk-27; Wed, 30 Oct 2024 20:35:30 +0000 Date: Thu, 31 Oct 2024 04:34:37 +0800 From: kernel test robot To: oe-kbuild@lists.linux.dev Cc: lkp@intel.com, Julia Lawall Subject: fs/xfs/xfs_exchrange.c:114:11-12: WARNING opportunity for max() Message-ID: <202410310411.md7m3UAl-lkp@intel.com> Precedence: bulk X-Mailing-List: oe-kbuild@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline BCC: lkp@intel.com CC: oe-kbuild-all@lists.linux.dev CC: linux-kernel@vger.kernel.org TO: "Darrick J. Wong" CC: Christoph Hellwig 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 | Reported-by: Julia Lawall | 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