* [djwong-xfs:djwong-wtf 170/190] fs/xfs/libxfs/xfs_swapext.c:302:37: warning: suggest braces around empty body in an 'if' statement
@ 2020-06-22 21:16 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2020-06-22 21:16 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 7375 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git djwong-wtf
head: fb59bf80e08d73ce5299c6e245f1c9929da7624e
commit: d02481f2c48b34addcf4d0e528fcb5cae00e831d [170/190] xfs: create deferred log items for extent swapping
config: powerpc-randconfig-r004-20200622 (attached as .config)
compiler: powerpc64le-linux-gcc (GCC) 9.3.0
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
git checkout d02481f2c48b34addcf4d0e528fcb5cae00e831d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=powerpc
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>, old ones prefixed by <<):
fs/xfs/libxfs/xfs_swapext.c: In function 'xfs_swapext_finish_one':
>> fs/xfs/libxfs/xfs_swapext.c:302:37: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
302 | XFS_TRANS_DQ_BCOUNT, ip1_delta);
| ^
fs/xfs/libxfs/xfs_swapext.c:305:37: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
305 | XFS_TRANS_DQ_BCOUNT, ip2_delta);
| ^
vim +/if +302 fs/xfs/libxfs/xfs_swapext.c
204
205 /* Finish one extent swap, possibly log more. */
206 int
207 xfs_swapext_finish_one(
208 struct xfs_trans *tp,
209 struct xfs_swapext_intent *sxi)
210 {
211 struct xfs_bmbt_irec irec1, irec2;
212 int whichfork;
213 int nimaps;
214 int bmap_flags;
215 int error;
216
217 whichfork = (sxi->sxi_flags & XFS_SWAP_EXTENT_ATTR_FORK) ?
218 XFS_ATTR_FORK : XFS_DATA_FORK;
219 bmap_flags = xfs_bmapi_aflag(whichfork);
220
221 while (sxi->sxi_blockcount > 0) {
222 int64_t ip1_delta = 0, ip2_delta = 0;
223
224 /* Read extent from the first file */
225 nimaps = 1;
226 error = xfs_bmapi_read(sxi->sxi_ip1, sxi->sxi_startoff1,
227 sxi->sxi_blockcount, &irec1, &nimaps,
228 bmap_flags);
229 if (error)
230 return error;
231 if (nimaps != 1 ||
232 irec1.br_startblock == DELAYSTARTBLOCK ||
233 irec1.br_startoff != sxi->sxi_startoff1) {
234 /*
235 * We should never get no mapping or a delalloc extent
236 * or something that doesn't match what we asked for,
237 * since the caller flushed both inodes and we hold the
238 * ILOCKs for both inodes.
239 */
240 ASSERT(0);
241 return -EINVAL;
242 }
243
244 /* Read extent from the second file */
245 nimaps = 1;
246 error = xfs_bmapi_read(sxi->sxi_ip2, sxi->sxi_startoff2,
247 irec1.br_blockcount, &irec2, &nimaps,
248 bmap_flags);
249 if (error)
250 return error;
251 if (nimaps != 1 ||
252 irec2.br_startblock == DELAYSTARTBLOCK ||
253 irec2.br_startoff != sxi->sxi_startoff2) {
254 /*
255 * We should never get no mapping or a delalloc extent
256 * or something that doesn't match what we asked for,
257 * since the caller flushed both inodes and we hold the
258 * ILOCKs for both inodes.
259 */
260 ASSERT(0);
261 return -EINVAL;
262 }
263
264 /*
265 * We can only swap as many blocks as the smaller of the two
266 * extent maps.
267 */
268 irec1.br_blockcount = min(irec1.br_blockcount,
269 irec2.br_blockcount);
270
271 trace_xfs_swapext_extent1(sxi->sxi_ip1, &irec1);
272 trace_xfs_swapext_extent2(sxi->sxi_ip2, &irec2);
273
274 /*
275 * Two extents mapped to the same physical block must not have
276 * different states; that's filesystem corruption. Move on to
277 * the next extent if they're both holes or both the same
278 * physical extent.
279 */
280 if (irec1.br_startblock == irec2.br_startblock) {
281 if (irec1.br_state != irec2.br_state)
282 return -EFSCORRUPTED;
283
284 sxi->sxi_startoff1 += irec1.br_blockcount;
285 sxi->sxi_startoff2 += irec1.br_blockcount;
286 sxi->sxi_blockcount -= irec1.br_blockcount;
287 continue;
288 }
289
290 /* Update quota accounting. */
291 if (xfs_bmap_is_mapped_extent(&irec1)) {
292 ip1_delta -= irec1.br_blockcount;
293 ip2_delta += irec1.br_blockcount;
294 }
295 if (xfs_bmap_is_mapped_extent(&irec2)) {
296 ip1_delta += irec2.br_blockcount;
297 ip2_delta -= irec2.br_blockcount;
298 }
299
300 if (ip1_delta)
301 xfs_trans_mod_dquot_byino(tp, sxi->sxi_ip1,
> 302 XFS_TRANS_DQ_BCOUNT, ip1_delta);
303 if (ip2_delta)
304 xfs_trans_mod_dquot_byino(tp, sxi->sxi_ip2,
305 XFS_TRANS_DQ_BCOUNT, ip2_delta);
306
307 /* Remove both mappings. */
308 xfs_bmap_unmap_extent(tp, sxi->sxi_ip1, whichfork, &irec1);
309 xfs_bmap_unmap_extent(tp, sxi->sxi_ip2, whichfork, &irec2);
310
311 /*
312 * Re-add both mappings. We swap the file offsets between the
313 * two maps and add the opposite map, which has the effect of
314 * filling the logical offsets we just unmapped, but with with
315 * the physical mapping information swapped.
316 */
317 swap(irec1.br_startoff, irec2.br_startoff);
318 xfs_bmap_map_extent(tp, sxi->sxi_ip1, whichfork, &irec2);
319 xfs_bmap_map_extent(tp, sxi->sxi_ip2, whichfork, &irec1);
320
321 /* Make sure we're not mapping extents past EOF. */
322 if (whichfork == XFS_DATA_FORK) {
323 xfs_swapext_update_size(tp, sxi->sxi_ip1, &irec2,
324 sxi->sxi_isize1);
325 xfs_swapext_update_size(tp, sxi->sxi_ip2, &irec1,
326 sxi->sxi_isize2);
327 }
328
329 /*
330 * Advance our cursor and exit. The caller (either defer ops
331 * or log recovery) will log the SXD item, and if *blockcount
332 * is nonzero, it will log a new SXI item for the remainder
333 * and call us back.
334 */
335 sxi->sxi_startoff1 += irec1.br_blockcount;
336 sxi->sxi_startoff2 += irec1.br_blockcount;
337 sxi->sxi_blockcount -= irec1.br_blockcount;
338 break;
339 }
340
341 /*
342 * If we've reached the end of the remap operation and the caller
343 * wanted us to exchange the sizes, do that now.
344 */
345 if (sxi->sxi_blockcount == 0 &&
346 (sxi->sxi_flags & XFS_SWAP_EXTENT_SET_SIZES)) {
347 sxi->sxi_ip1->i_d.di_size = sxi->sxi_isize1;
348 sxi->sxi_ip2->i_d.di_size = sxi->sxi_isize2;
349 xfs_trans_log_inode(tp, sxi->sxi_ip1, XFS_ILOG_CORE);
350 xfs_trans_log_inode(tp, sxi->sxi_ip2, XFS_ILOG_CORE);
351 }
352
353 if (xfs_swapext_has_more_work(sxi))
354 trace_xfs_swapext_defer(tp->t_mountp, sxi);
355 return 0;
356 }
357
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 36810 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-06-22 21:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-22 21:16 [djwong-xfs:djwong-wtf 170/190] fs/xfs/libxfs/xfs_swapext.c:302:37: warning: suggest braces around empty body in an 'if' statement 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.