From: Miao Xie <miaox@cn.fujitsu.com>
To: dsterba@suse.cz
Cc: Linux Btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH 05/11] Btrfs: protect fs_info->alloc_start
Date: Mon, 14 Jan 2013 16:04:59 +0800 [thread overview]
Message-ID: <50F3BC2B.2010407@cn.fujitsu.com> (raw)
In-Reply-To: <20130110171040.GG20089@twin.jikos.cz>
On Thu, 10 Jan 2013 18:10:40 +0100, David Sterba wrote:
> On Thu, Jan 10, 2013 at 08:48:00PM +0800, Miao Xie wrote:
>> fs_info->alloc_start was not protected strictly, it might be changed while
>> we were accessing it. This patch fixes this problem by using two locks to
>> protect it (fs_info->chunk_mutex and sb->s_umount). On the read side, we
>> just need get one of these two locks, and on the write side, we must lock
>> all of them.
>
> Can you please describe how this can theoretically cause any problems?
>
> Out of curiosity I've been running this command on a 60G ssd disk for a while
>
> for i in `seq 1 10000|shuf`;do
> mount -o remount,alloc_start=$(($i*1024*1024)) /mnt/sdc;done
> #sleep 0 / 1 / 5
> done
>
> together with one of my favourite stresstests (heavy writes, subvolume
> activity).
>
> There are two direct users of fs_info->alloc_start:
>
> * statfs via btrfs_calc_avail_data_space
> * find_free_dev_extent
>
> 960 search_start = max(root->fs_info->alloc_start, 1024ull * 1024);
>
> as remount calls sync, there is a very tiny window where an allocation could
> get the old value of alloc_start just between sync and do_remount. Theoretical
> and without any visible effect.
->alloc_start is a 64bits variant, on the 32bits machine, we have to load it
by two instructions.
Assuming -> alloc_start is 0x00010000 at the beginning, then we remount and
set ->alloc_start to 0x00000100
Task0 Task1
load low 32 bits
set high 32 bits
load high 32 bits
set low 32 bits
Task1 will get 0.
Thanks
Miao
>
> My NAK for this patch.
>
> david
>
next prev parent reply other threads:[~2013-01-14 8:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-10 12:48 [PATCH 05/11] Btrfs: protect fs_info->alloc_start Miao Xie
2013-01-10 17:10 ` David Sterba
2013-01-14 8:04 ` Miao Xie [this message]
2013-01-16 12:43 ` David Sterba
2013-01-17 4:13 ` Miao Xie
2013-01-20 13:11 ` Alex Lyakas
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=50F3BC2B.2010407@cn.fujitsu.com \
--to=miaox@cn.fujitsu.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.