Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1383518ybl; Tue, 3 Dec 2019 06:23:55 -0800 (PST) X-Google-Smtp-Source: APXvYqxc4eEv20F8iEV45PHni1djEM8YlY6ebSaL2JRkldR5pR+IobrUz1Z+T3Rh0TTH//898t4k X-Received: by 2002:a9d:7201:: with SMTP id u1mr3157370otj.181.1575383035245; Tue, 03 Dec 2019 06:23:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575383035; cv=none; d=google.com; s=arc-20160816; b=CaOtEA78wY+tnduswoBoYFJgfV+DjKJL+YGWH2PExr+vxy5Afy3WObyH2MPdq5WvvD IvIII/7PykdWegLVYIzym30eW+/TYBqOj1Phtlw+9zyqGEmqqfmq7Y23L1FfpG2yQv0F Uok0UnpyXcXYKROQ8rvrSJiu1aDY+96yZoTHKzEwhoRO3zV9ap8sIkVBjEsfaBAXug+d bPVN68GS+3DLYEYnpn1OAVLh90AIKhrgxAd6lUID+w1FM8zamN8knH3ZMtyMrHhaCrin nJktTF2H9NxqKep1F7hnOgHHJa15vjDg0y+In1JKbc8OLKhUNoPQ/ER6T4Mzpi6jTDTn K3ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=fcXOuwcw33mJtXr5YKKPNQ1Now297rjSRw36mEk4w+I=; b=M6KrbwrTVUsWOAQQnwcfbqGv+viug/Ti0P4ItisbOTjuwjVWfgsOd9CugXmgDjfV6T +9gjirrjPVJAhiRx6GLBUoGnlgBuwaei6LgElGKXw5j0JGXaThla6z0JW+2dAJ2nbaEz sYcdGOOzQ1ecwvBPTxmNhXiE6Ve9cW4bxfoIVCZV/C0C6G230SrYgNiFqdqMhaNqhSgF OUi3R1hAOReVVnyRokl5EV3AsxLWZ0ez9aUndY55pzMUdAWmEwOs3/sd9V1vu0z8wn3y RDbm0re8f2k/3QXuLYJO+ryJuv+yuWLZFFwECcuNOiOTwdk/uCcTNNYMDzzI8dmqojP2 k8yg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d13si1231691ote.242.2019.12.03.06.23.38; Tue, 03 Dec 2019 06:23:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726466AbfLCOWV (ORCPT + 99 others); Tue, 3 Dec 2019 09:22:21 -0500 Received: from mx2.suse.de ([195.135.220.15]:53726 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725957AbfLCOWV (ORCPT ); Tue, 3 Dec 2019 09:22:21 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 46EF3B9BF; Tue, 3 Dec 2019 14:22:19 +0000 (UTC) Subject: Re: [PATCH] bcache: add REQ_FUA to avoid data lost in writeback mode To: Eric Wheeler Cc: kungf , kent.overstreet@gmail.com, linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org References: <20191202102409.3980-1-wings.wyang@gmail.com> <785fe04f-f841-3083-66db-53fab7bc0577@suse.de> From: Coly Li Organization: SUSE Labs Message-ID: <1a728329-1b12-0ebf-21a4-058ef6f65ead@suse.de> Date: Tue, 3 Dec 2019 22:21:57 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/12/3 3:34 上午, Eric Wheeler wrote: > On Mon, 2 Dec 2019, Coly Li wrote: >> On 2019/12/2 6:24 下午, kungf wrote: >>> data may lost when in the follow scene of writeback mode: >>> 1. client write data1 to bcache >>> 2. client fdatasync >>> 3. bcache flush cache set and backing device >>> if now data1 was not writed back to backing, it was only guaranteed safe in cache. >>> 4.then cache writeback data1 to backing with only REQ_OP_WRITE >>> So data1 was not guaranteed in non-volatile storage, it may lost if power interruption  >>> >> >> Hi, >> >> Do you encounter such problem in real work load ? With bcache journal, I >> don't see the possibility of data lost with your description. >> >> Correct me if I am wrong. >> >> Coly Li > > If this does become necessary, then we should have a sysfs or superblock > flag to disable FUA for those with RAID BBUs. Hi Eric, I doubt it is necessary to add FUA tag for all writeback bios, it is unnecessary. If power failure happens after dirty data written to backing device and the bkey turns into clean, a following read request will go to cache device because the LBA can be indexed no matter it is dirty or clean. Unless the bkey is invalidated from the B+tree, read will always go to cache device firstly in writeback mode. If a power failure happens before the cached bkey turns from dirty to clean, just an extra writeback bio flushed from cache device to backing device with identical data. Comparing the FUA tag for all writeback bios (it will be really slow), the extra writeback IOs after a power failure is more acceptable to me. Coly Li > >>> Signed-off-by: kungf >>> --- >>> drivers/md/bcache/writeback.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c >>> index 4a40f9eadeaf..e5cecb60569e 100644 >>> --- a/drivers/md/bcache/writeback.c >>> +++ b/drivers/md/bcache/writeback.c >>> @@ -357,7 +357,7 @@ static void write_dirty(struct closure *cl) >>> */ >>> if (KEY_DIRTY(&w->key)) { >>> dirty_init(w); >>> - bio_set_op_attrs(&io->bio, REQ_OP_WRITE, 0); >>> + bio_set_op_attrs(&io->bio, REQ_OP_WRITE | REQ_FUA, 0); >>> io->bio.bi_iter.bi_sector = KEY_START(&w->key); >>> bio_set_dev(&io->bio, io->dc->bdev); >>> io->bio.bi_end_io = dirty_endio; >>> >>