From: Alex Bligh Subject: Re: Questions on block drivers, REQ_FLUSH and REQ_FUA Date: Wed, 25 May 2011 18:43:01 +0100 Message-ID: <2D8E6A46790AC2395383D82B@Ximines.local> References: <8E109506CAF2B94185C68859@nimrod.local> <20110524223220.GA379@redhat.com> <20110525085950.GC10146@htj.dyndns.org> Reply-To: Alex Bligh Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Vivek Goyal , linux-fsdevel@vger.kernel.org, Alex Bligh To: Tejun Heo Return-path: Received: from mail.avalus.com ([89.16.176.221]:39587 "EHLO mail.avalus.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752377Ab1EYRnF convert rfc822-to-8bit (ORCPT ); Wed, 25 May 2011 13:43:05 -0400 In-Reply-To: Content-Disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Tejun, --On 25 May 2011 18:43:14 +0200 Tejun Heo wrote: >> b) If I receive a flush command, and prior to completing that flush >> =C2=A0command, I receive subsequent write commands, I may execute >> =C2=A0(and, if I like, write, to disk) write commands received AFTER= that >> =C2=A0flush command. I presume if the subsequent write commands writ= e to >> =C2=A0blocks that I am meant to be flushing, I can just forget about >> =C2=A0the blocks I am meant to be flushing (because they would be >> =C2=A0overwritten) provided *something* overwritten what was there b= efore. > > The first half is correct. The latter half may be correct if there's > no intervening write but _please_ don't do that. If there's somethin= g > to be optimized there, it should be done in upper layers. It's > playing with fire. Thanks. My specific interest in playing with this particular fire is that my driver can only write very large collections of blocks together to the underlying media, and the write, whilst fast in bandwidth terms, is high latency. So, if I receive a flush request, I either have to block handling all writes to any block in the same collection as anything that has been written to since the last flush (which effective= ly means blocking all writes to the disk), or keep processing writes whilst I deal with the flush. On a small disk with frequent flushes, the flush might take several tens of milliseconds. On a large disk with infrequent flushes I might be looking at several seconds, and I am worried about upper layers timing out. > Hmm... For bio drivers, REQ_FLUSH and REQ_FUA are best explained > together. The followings are legal combinations. > > * No write data, REQ_FLUSH - doesn't have any ordering constraint > other than the inherent FLUSH requirement (previously completed WRITE= s > should be on the media on FLUSH completion). > > * Write data, REQ_FLUSH - FLUSH must be completed before write data i= s > issued. ie. write data must not be written to the media before all > previous writes are on the media. > > * Write data, REQ_FUA - Write should be completed before FLUSH is > issued - ie. the write data should be on platter along with previousl= y > completed writes on bio completion. > > * Write data, REQ_FLUSH | REQ_FUA - Write data must not be written to > the media before all previous writes are on the media && the write > data must be on the media on bio completion. This is usually > sequenced as FLUSH write FLUSH. > > Request based drivers only see REQ_FLUSH w/o write data and the only > rule it has to follow is that all writes it completed prior to > receiving FLUSH must be on the media on completion of FLUSH and being > smart about it might not be a good idea. Thanks once again. My driver is currently request-based. Is there any significant advantage converting it to be bio based? --=20 Alex Bligh -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html