public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Michael L. Semon" <mlsemon35@gmail.com>
To: Brian Foster <bfoster@redhat.com>
Cc: "xfs@oss.sgi.com" <xfs@oss.sgi.com>
Subject: Re: [RFC] xfs: remedy small writes during wrapped-log recovery
Date: Tue, 13 Jan 2015 09:23:11 -0500	[thread overview]
Message-ID: <54B52A4F.5070504@gmail.com> (raw)
In-Reply-To: <20150112153022.GB25944@bfoster.bfoster>

On 01/12/15 10:30, Brian Foster wrote:
> On Fri, Jan 09, 2015 at 03:02:53PM -0500, Michael L. Semon wrote:
>> Hi!  I like this patch and am confident with it on x86.  However,
>> a) it has no x86_64 coverage; and b) xfstests xfs/306 in particular
>> emits more of this output:
>>
>>     buffer_io_error: nnnn callbacks suppressed
>>
>> Might someone evaluate this patch or the intent of the patch?
>>
>> The intent:
>>
>> For XFS filesystems that don't change much, such as the /boot and
>> alternate / partitions here, mount times were about 17s instead of
>> 0.4s while the log is in a wrapped state, write caches off.  This 
>> patch fixes the issue on v4- and v5-superblock XFS filesystems.
>>
>> xfs_repair can solve this issue short-term and also cut wrapped-log 
>> mount time in half short-term for v5 file systems.  Don't know if 
>> that's a mkfs.xfs issue or just coincidence.
>>
>> A bisect still needs to be done to determine when the slow mount 
>> behavior started.  It could very well be that somebody fixed the 
>> buffer_io_error messages that I saw long ago, and the solution made 
>> some mounts here rather miserable.
>>
>> Thanks!
>>
>> Michael
>>
>> The patch:
>>
>> xlog_write_log_records() has an algorithm to "Greedily allocate a
>> buffer big enough...," starting with ffs(blocks), adding two sensible
>> checks, and then feeding it to a loop with checks of its own.
>>
>> However, when blocks is an odd number, the number that becomes nbblks
>> to the xlog_bwrite() function ends up being 2 (1 << 1).  The most
>> obvious effect is that when the log wraps, a write of two odd-sized
>> log regions on an 8-GB XFS filesystem will take around 2049 calls 
>> to xlog_bwrite() instead of the "two separate I/Os" suggested in
>> xlog_clear_stale_blocks().
>>
>> Fix this by changing the ffs(blocks) to fls(blocks).
>>
>> There is a similar ffs(blocks) check in xlog_find_verify_cycle().
>> This was not investigated.
>>
>> Signed-off-by: Michael L. Semon <mlsemon35@gmail.com>
>> ---
>>  fs/xfs/xfs_log_recover.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
>> index a5a945f..13381eb 100644
>> --- a/fs/xfs/xfs_log_recover.c
>> +++ b/fs/xfs/xfs_log_recover.c
>> @@ -1242,7 +1242,7 @@ xlog_write_log_records(
>>  	 * a smaller size.  We need to be able to write at least a
>>  	 * log sector, or we're out of luck.
>>  	 */
>> -	bufblks = 1 << ffs(blocks);
>> +	bufblks = 1 << fls(blocks);
> 
> Interesting, it does seem like there is a bug here. Thanks for the
> test code to help reproduce.
> 
> The fix seems reasonable to me, but I'm also wondering if there is at
> least one other bug in this code. In the middle of that loop, we have
> the following:
> 
> 	...
> 
> 	/* We may need to do a read at the end to fill in part of
>  	* the buffer in the final sector not covered by the write.
>  	* If this is the same sector as the above read, skip it.
>  	*/
> 	ealign = round_down(end_block, sectbb);
> 	if (j == 0 && (start_block + endcount > ealign)) {
> 		offset = bp->b_addr + BBTOB(ealign - start_block);
> 		error = xlog_bread_offset(log, ealign, sectbb,
> 						bp, offset);
> 		...
> 	}
> 	...
> 
> ... but how have we really confirmed whether the end sector is
> equivalent to the first sector? It looks to me that we operate at basic
> block granularity but log I/O is managed at log sector alignment. So if
> the start basic block is not sector aligned, we read in the first sector
> and add records at the associated buffer offset. Similar if the end
> block is not sector aligned. If the buffer size spans multiple sectors
> and the start and end are not aligned, it looks like we could skip the
> read of the final sector.

> Perhaps I'm missing some context as to why this wouldn't occur..? It
> also seems strange that the offset calculation above uses start_block as
> the baseline start block value of the buffer, but the pre-loop balign
> code suggests the buffer might not be aligned to start_block...
> 
> Brian

I'm currently stumped on getting this code to fire.  For that matter, all 
blk_no and nbblks numbers are coming in to xlog_bwrite() neatly pre-
rounded, so the rounding functions in there don't change anything.  In 
all, an unsuccessful testing effort on my part.

Maybe the "env MKFS_OPTIONS='-m crc=1,finobt=1 -s size=4096' ./check -g 
auto" xfstests run will cough something up.  It will be waiting at home, 
at the end of the day.

Should I use fdisk on a spare disk and deliberately misalign the 
partitions?  Otherwise, there's a struggle to find misalignments, and 
my idea bucket was not very full, anyway ;-)

Thanks!

Michael

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

  reply	other threads:[~2015-01-13 14:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-09 20:02 [RFC] xfs: remedy small writes during wrapped-log recovery Michael L. Semon
2015-01-12  1:04 ` Michael L. Semon
2015-01-12 15:30 ` Brian Foster
2015-01-13 14:23   ` Michael L. Semon [this message]
2015-01-13 17:11     ` Brian Foster

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=54B52A4F.5070504@gmail.com \
    --to=mlsemon35@gmail.com \
    --cc=bfoster@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