Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1414716ybl; Mon, 2 Dec 2019 03:11:44 -0800 (PST) X-Google-Smtp-Source: APXvYqx0ueBFxCUkNN6khkH5j2r3eGSn5Cq8dWjeHP0PAV7onFVlq1DFD1edQyQ6t1i0ou0kBNma X-Received: by 2002:a19:3f16:: with SMTP id m22mr39152352lfa.116.1575285104713; Mon, 02 Dec 2019 03:11:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575285104; cv=none; d=google.com; s=arc-20160816; b=HvRnxaYdz3sT3pYwZWUwn9aYGtsKPxCzyBh6fjz+bituhMZwikB3F2nTsfVrYU0cfB JapPgTeRtEnI2TeJdwdqAKEtvVx5S9f5rrJI1+P9Xv9Gmt9pagUJX63BI6es9s3nCYt1 +MMfcAm64UPVNV9+3tRxvnlTbTfMBMpNfA9dcco7mYMyo8qXRroGA5a14L5jpKzJxKqj +vKF5H6RnkmKM0CRbWEKva3kFX2tjM7MjGKj1k9TS/sqBw8uOzQUirImIS8xeLsq+Vi7 CbqiaDVgHiKzH0WS4PxobO7nONPcJ/OpToW3gTgu4lrfmuHzOUbGfmpWUxRZiIA88vTu oITg== 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=ZS0G3ho9oWrG3MpeLZGPg7hgdPBgWDCmMvxqZiJ6KJ4=; b=aLjOP2WOKR5NRHvB5Bm9PUDqz3qRYD2WCpjm0CdBlF6eMoK3GVdxjc8yZW4S6fSSsI b6RRwx6/NKmTgMOb8atRCjzxiBPhxnvdmKr8+NIvx6apJi2q7YTGHXUSN6Uer9aIBiHW TnXj/IXvj6bL37+EEmRW94C4kL59hE1tqr0xwR/Q0hPcqHdlzc0cPyM1WmLAKW54me+k +WzVFXZJb8XYKnIrLxCe1BurCtWh8b2pEl0r0DF7CDSOvU+YKHJA2jqBUqDMoMQxrelC k1yP4bSFj8xyay8IM6hB9Jxr8aYn+b2ZF0sKqiZ6aBfmAOcIJTIjXi0inDIub97a5xS1 6A7g== 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 z16si7955502edq.340.2019.12.02.03.11.20; Mon, 02 Dec 2019 03:11:44 -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 S1727469AbfLBLJN (ORCPT + 99 others); Mon, 2 Dec 2019 06:09:13 -0500 Received: from mx2.suse.de ([195.135.220.15]:54660 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726330AbfLBLJM (ORCPT ); Mon, 2 Dec 2019 06:09:12 -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 22851B2F8; Mon, 2 Dec 2019 11:09:11 +0000 (UTC) Subject: Re: [PATCH] bcache: add REQ_FUA to avoid data lost in writeback mode To: kungf Cc: kent.overstreet@gmail.com, linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org References: <20191202102409.3980-1-wings.wyang@gmail.com> From: Coly Li Organization: SUSE Labs Message-ID: <785fe04f-f841-3083-66db-53fab7bc0577@suse.de> Date: Mon, 2 Dec 2019 19:08:59 +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: <20191202102409.3980-1-wings.wyang@gmail.com> 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/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 > 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; >