From owner-freebsd-scsi@FreeBSD.ORG Sun Sep 21 09:16:00 2014 Return-Path: Delivered-To: freebsd-scsi@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CB9FB5AB for ; Sun, 21 Sep 2014 09:16:00 +0000 (UTC) Received: from anubis.delphij.net (anubis.delphij.net [IPv6:2001:470:1:117::25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "anubis.delphij.net", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id AB455B8 for ; Sun, 21 Sep 2014 09:16:00 +0000 (UTC) Received: from delphij-macbook.local (unknown [106.120.42.90]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by anubis.delphij.net (Postfix) with ESMTPSA id C343F19DF9; Sun, 21 Sep 2014 02:15:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=delphij.net; s=anubis; t=1411290960; x=1411305360; bh=vQ0Brxx4ZQjQsTDefy/6IKruWkyHMMqMiDlneuT8SWA=; h=Date:From:Reply-To:To:Subject:References:In-Reply-To; b=dIfBQcpUZPJ1+LJCvRShWDlgcLFKE7NlmclwsFnoskz0+q42OVEd3W1SgtXKO7UNu UIEmIkb0BxWXVxJRAgln2kFNFXkCcPGmgei4bTrdQ/MgAkkBZh81V/wISYoTNiGCul rjYunFcUAeqegjceN4UFN2wVu7m/yLhqrPSa1Ho8= Message-ID: <541E974E.7060702@delphij.net> Date: Sun, 21 Sep 2014 17:15:58 +0800 From: Xin Li Reply-To: d@delphij.net Organization: The FreeBSD Project MIME-Version: 1.0 To: Xu Zhe , d@delphij.net, freebsd-scsi@freebsd.org, Alexander Motin Subject: Re: How to disable hard disk write cache? References: <541804B0.7070407@gmail.com> <54184484.1070304@delphij.net> <5418FA4A.1050707@gmail.com> In-Reply-To: <5418FA4A.1050707@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-scsi@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SCSI subsystem List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Sep 2014 09:16:01 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On 9/17/14 11:04 AM, Xu Zhe wrote: > My final goal is not to disable write cache. I just want to do a > simple test to see how would the IOPS drop when write cache > disabled (I suppose without disk write cache, the value should be > the same as IOPS of random read, both using O_DIRECT flag to avoid > system cache, etc.). > > Meanwhile, what I really want to know is that, how could I make > sure IO is persistent as long as I got reply from hard disk? Since > I suppose all file systems require this assumption to achieve self > consistency. You should get consistent I/O results assuming you are doing the right benchmark, which unfortunately not all benchmarks do. Doing benchmarks without the on-device caches is interesting but IMHO not very useful, because it's likely no practical application would do that. Traditionally, these write caches are disabled only when you really care about data durability; with modern technologies, now you can get affordable low latency and battery/supercapacitor backed device, for example most enterprise grade SSDs, and use that as your write-ahead journalling device to cover that gap. In order to get more consistent results, you may choose a running data set that is large enough to defeat the cache effect. The size can be chosen by doing a sequence of tests and gradually increase your running set size, and eventually you would find an "inflicting point" where performance would drop significantly. Please note that typical hard drive do not offer consistent latency when you operate on different areas of the drive, and the results could vary because a lot of factors. To do meaningful benchmarks, these factors also need to be considered. > I have googled about the "tagged command" but only found something > related to TCQ, which mainly talks about the queueing but not > anything related to cache sync. Any more hints? Hrm I don't have much thing off hand, but these are defined by the standards. Alexander knows much more than I do in this area. > I saw some pages that mentioned about SATA FUA command support on > Linux (Which I guess is what I am looking for): > > https://www.kernel.org/doc/Documentation/block/writeback_cache_control.txt > > However, I have not found useful information related to Freebsd. > :( Probably g_bio(9) but the documentation do not have much detail on driver implementation, and callers of the API expects the driver to do all the right things. This is if you want to implement a file system, where you would go. But back to your question, if you want to know e.g., "how to disable write cache on an AHCI connected drive", you would go to the individual driver's manual, e.g. ada(4). Cheers, -----BEGIN PGP SIGNATURE----- iQIcBAEBCgAGBQJUHpdOAAoJEJW2GBstM+nsRPwP/1FzatW89mmXIdGPYk9IZ+Bo Qdlqvtxy0MCZOJQvug3jUKkiKGxr3+7boo1juQCKgMBqfJzPPhwAef3pRDteuPV4 VGTItEYAKWDo8JXnEl07ChAyxYMiCikiTkplaikOOa5gfmPdyPc9/a0myJ9WQDGk v6D0flS6s4+ZSRolLAMvSRtzpIAnDUIrU4FjJX+D4Mygz1hrHoYigzic3AahCOIm PhQe1nW6cPOjJASknFSFs450cDrQZ2QeVfH2Kr+K49ULdX+dn7ot3etJ4Fw+EBUN m66yPpgjssj/LqXS3m7XLJJYOOBy5FAeBrVUKzGQ6FxkfoCG8+kkD7YsQ2CJZPkc ILLIshVSL35OchuuMJpG9BGcr2BaaUQ23D4d72nIDm+ktsXiLkyD1XbZm7Ze+bR6 aW2KT3t8dU8NhJi8iyoWMS3bksh6lC5k07g8nqAsUNI+vAlKsnbT3cJJuowzbNLc 5Ai6L2+qFIst97BhTWxlpyBWkJM4K2lzB3AhZyc0Y4uXYni4Uj2DPSrC8dxOrp36 rH3SPACSnRP2cyChWQ+vV3l/uNsWM9snqVFAXPrSjmdN0fzN2KzfxnUiK0PtaFyR DoZcwM590GWYianbmzHFPiVCrsqjS6y2z4GK1SVUEfa9VM2qahWUSHFNap1DC3W6 ab4I5sE2eO3BknRXpoMg =tb5a -----END PGP SIGNATURE-----