From: Eric Sandeen <sandeen@redhat.com>
To: xfs-oss <xfs@oss.sgi.com>
Cc: Boris Ranto <branto@redhat.com>
Subject: [PATCH] mkfs.xfs: don't increase agblocks past maximum
Date: Mon, 19 Sep 2011 16:45:06 -0500 [thread overview]
Message-ID: <4E77B7E2.6020805@redhat.com> (raw)
RH QA discovered this bug:
Steps to Reproduce:
1. Create 4 TB - 1 B partition
dd if=/dev/zero of=x.img bs=1 count=0 seek=4398046511103
2. Create xfs fs with 512 B block size on the partition
mkfs.xfs -b size=512 xfs.img
Actual results:
Agsize is computed incorrectly resulting in fs creation fail:
agsize (2147483648b) too big, maximum is 2147483647 blocks
This is due to the "rounding up" at the very end of the calculations;
there may be other places to alleviate the problem, but it seems
most obvious to simply skip the rounding up if it would create too
many blocks in the AG. Worst case, we lose 1 block per AG.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 5b3b9a7..856a261 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -658,7 +659,9 @@ calc_default_ag_geometry(
* last bit of the filesystem. The same principle applies
* to the AG count, so we don't lose the last AG!
*/
- blocks = (dblocks >> shift) + ((dblocks & xfs_mask32lo(shift)) != 0);
+ blocks = (dblocks >> shift);
+ if (blocks < XFS_AG_MAX_BLOCKS(blocklog))
+ blocks += ((dblocks & xfs_mask32lo(shift)) != 0);
done:
*agsize = blocks;
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next reply other threads:[~2011-09-19 21:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-19 21:45 Eric Sandeen [this message]
2011-09-20 20:00 ` [PATCH] mkfs.xfs: don't increase agblocks past maximum Alex Elder
2011-09-20 20:03 ` Eric Sandeen
2011-09-20 20:04 ` Alex Elder
2011-09-20 20:30 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E77B7E2.6020805@redhat.com \
--to=sandeen@redhat.com \
--cc=branto@redhat.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox