Skip to contentSkip to conversation

libxfs: remove never-read "offset" assignment in readbufr_map & writebufr

PATCH In review Eric Sandeen 2 participants 2 messages Apr 9, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxfs: remove never-read "offset" assignment in readbufr_map & writebufr

libxfs_readbufr_map() & libxfs_writebufr() iterate over bp->b_map[] and read each chunk. The loops start out correctly, getting the offset from bm_bn and the length from bm_len. After the IO it correctly advances the target buffer pointer by len, but then inexplicably advances "offset" by len as well. The whole point of this exercise is to handle discontiguous ranges - marching offset along by length of IO done is incorrect.

Thankfully offset is immediately reset to the proper value again at the top of the loop for the next range, so this is harmless, other than being confusing.

---

libxfs/rdwr.c +0 -2
index 9887423..7208a2f 100644
@@ -758,7 +758,6 @@ libxfs_readbufr_map(struct xfs_buftarg *btp, struct xfs_buf *bp, int flags)
 			break;
 		}
 		buf += len;
-		offset += len;
 	}
 
 	if (!error)
@@ -878,7 +877,6 @@ libxfs_writebufr(xfs_buf_t *bp)
 				break;
 			}
 			buf += len;
-			offset += len;
 		}
 	}
 

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Eric Sandeen

libxfs_readbufr_map()& libxfs_writebufr() iterate over bp->b_map[] and read each chunk. The loops start out correctly, getting the offset from bm_bn and the length from bm_len. After the IO it correctly advances the target buffer pointer by len, but then inexplicably advances "offset" by len as well. The whole point of this exercise is to handle discontiguous ranges - marching offset along by length of IO done is incorrect.

Quoted 5 lines

Thankfully offset is immediately reset to the proper value again at the top of the loop for the next range, so this is harmless, other than being confusing.

Looks good.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs