Skip to contentSkip to conversation

xfs: fix check for maximum allowable extent record file offset

PATCH New Brian Foster 1 participant 1 message Sep 30, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: fix check for maximum allowable extent record file offset

The maximum allowable file size on XFS is 2^63-1 (0x7fffffffffffffff). This value is unaligned with respect to typical order of 2 block sizes. Therefore, the maximum allowable block offset in a file is (2^63-1) / blocksize. xfs_repair calculates the max file offset as such in parse_sb_version().

However, if we write to the maximum byte offset of a file:

$ xfs_io -fc "pwrite `echo "2^63-1-1" | bc` 1" /mnt/file
wrote 1/1 bytes at offset 9223372036854775806
1.000000 bytes, 1 ops; 0.0000 sec (21.230 KiB/sec and 21739.1304 ops/sec)

... xfs_repair complains that the file contains an invalid extent (4k blocks):

...
inode 99 - extent offset too large - start 9, count 1, offset 2251799813685247
...

This occurs because xfs_repair uses a >= comparison against the start offset of the record. Byte offset 2251799813685247 is 2^63-4096, and thus is the maximum valid block offset in the file. Fix the comparison to complain only if the start offset of the record is greater than the maximum allowable start offset.

---

Hi all,

This allows xfstests test xfs/071 to pass without a post-test corruption (repair) failure.

Brian

 repair/dinode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
repair/dinode.c +1 -1
index 38a6562..f734a18 100644
@@ -667,7 +667,7 @@ _("inode %" PRIu64 " - bad extent overflows - start %" PRIu64 ", "
 					irec.br_startoff);
 				goto done;
 		}
-		if (irec.br_startoff >= fs_max_file_offset)  {
+		if (irec.br_startoff > fs_max_file_offset)  {
 			do_warn(
 _("inode %" PRIu64 " - extent offset too large - start %" PRIu64 ", "
   "count %" PRIu64 ", offset %" PRIu64 "\n"),
Signature · 6 lines
1.8.3.1

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