[PATCH] xfs: fix check for maximum allowable extent record file offset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Signed-off-by: Brian Foster <bfoster@xxxxxxxxxx>
---

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(-)

diff --git a/repair/dinode.c b/repair/dinode.c
index 38a6562..f734a18 100644
--- a/repair/dinode.c
+++ b/repair/dinode.c
@@ -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"),
-- 
1.8.3.1

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs




[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux