From: Andrew Price Date: Thu, 26 Jan 2017 16:47:05 +0000 Subject: [Cluster-devel] [PATCH 2/5] mkfs.gfs2: Warn when device is misaligned In-Reply-To: <20170126164708.23807-1-anprice@redhat.com> References: <20170126164708.23807-1-anprice@redhat.com> Message-ID: <20170126164708.23807-3-anprice@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Normally one layer of the I/O stack will adjust for a non-zero alignment_offset value and expose it to upper layers as zero. If a misalignment is not accounted for, mkfs.gfs2 will see a non-zero alignment_offset and should report the misalignment to the user as it could harm performance. Signed-off-by: Andrew Price --- gfs2/mkfs/main_mkfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c index a2d2ba9..db83d1c 100644 --- a/gfs2/mkfs/main_mkfs.c +++ b/gfs2/mkfs/main_mkfs.c @@ -495,7 +495,11 @@ static unsigned choose_blocksize(struct mkfs_opts *opts) printf("optimal_io_size: %lu\n", dev->optimal_io_size); printf("physical_sector_size: %lu\n", dev->physical_sector_size); } - + if (dev->got_topol && dev->alignment_offset != 0) { + fprintf(stderr, + _("Warning: device is not properly aligned. This may harm performance.\n")); + dev->physical_sector_size = dev->logical_sector_size; + } if (!opts->got_bsize && dev->got_topol) { if (dev->optimal_io_size <= getpagesize() && dev->optimal_io_size >= dev->minimum_io_size) -- 2.9.3