From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dxUjd-0005PZ-Id for barebox@lists.infradead.org; Thu, 28 Sep 2017 09:04:04 +0000 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Thu, 28 Sep 2017 11:03:29 +0200 Message-Id: <20170928090329.28006-4-u.kleine-koenig@pengutronix.de> In-Reply-To: <20170928090329.28006-1-u.kleine-koenig@pengutronix.de> References: <20170928090329.28006-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH v2 3/3] state: storage: direct: skip writing meta data if this makes data fit To: barebox@lists.infradead.org V2hlbiBhIGRpcmVjdCBidWNrZXQgaXMgcmVhZCBpdCBoYW5kbGVzIG1pc3NpbmcgbWV0YSBkYXRh IGp1c3QgZmluZSBmb3IKY29tcGF0aWJpbGl0eSByZWFzb25zLiBUaGlzIGFsbG93cyB0byBza2lw IHdyaXRpbmcgbWV0YSBkYXRhIGlmIHRoYXQKbWFrZXMgdGhlIGRhdGEgc21hbGwgZW5vdWdoIHRv IGZpdCBpbiB0aGUgYnVja2V0IHRvIGJlIHdyaXR0ZW4uCgpUaGUgbW90aXZhdGlvbiBmb3IgdGhp cyBjaGFuZ2UgaXMgdGhhdCB0aGUgc3RvcmFnZSBmb3JtYXQgaW4KcHJlLW1haW5saW5lIHN0YXRl IGRpZG4ndCB1c2UgbWV0YSBkYXRhIGFuZCBzb21lIG1hY2hpbmVzIHN0aWxsIGhhdmUgdG8Kc3Rp Y2sgdG8gdGhpcyBmb3JtYXQuIEZvciB0aGVzZSB0aGUgc3RyaWRl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