From patchwork Tue Feb 9 16:21:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 8263781 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 03346BEEE5 for ; Tue, 9 Feb 2016 16:21:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 39E2D20270 for ; Tue, 9 Feb 2016 16:21:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F2E9720260 for ; Tue, 9 Feb 2016 16:21:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933010AbcBIQVh (ORCPT ); Tue, 9 Feb 2016 11:21:37 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:45207 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932624AbcBIQVf (ORCPT ); Tue, 9 Feb 2016 11:21:35 -0500 Received: from hch by bombadil.infradead.org with local (Exim 4.80.1 #2 (Red Hat Linux)) id 1aTB2k-0006kT-V9; Tue, 09 Feb 2016 16:21:34 +0000 Date: Tue, 9 Feb 2016 08:21:34 -0800 From: Christoph Hellwig To: linux-man@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH] update the sync.2 man page Message-ID: <20160209162134.GA18634@infradead.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Clarify the description a bit, and document the Linux data integrity guarantees. Signed-off-by: Christoph Hellwig --- 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 diff --git a/man2/sync.2 b/man2/sync.2 index 5e222cb..28a42c4 100644 --- a/man2/sync.2 +++ b/man2/sync.2 @@ -35,7 +35,7 @@ .\" .TH SYNC 2 2015-08-08 "Linux" "Linux Programmer's Manual" .SH NAME -sync, syncfs \- commit buffer cache to disk +sync, syncfs \- commit filesystem caches to disk .SH SYNOPSIS .B #include .sp @@ -64,8 +64,8 @@ _GNU_SOURCE .ad .SH DESCRIPTION .BR sync () -causes all buffered modifications to file metadata and data to be -written to the underlying filesystems. +causes all pending modifications to file system metadata and cached file +data to be written to the underlying filesystems. .BR syncfs () is like @@ -108,16 +108,21 @@ In glibc 2.2.1 and earlier, it was "int sync(void)", and .BR sync () always returned 0. -.SH BUGS + According to the standard specification (e.g., POSIX.1-2001), .BR sync () schedules the writes, but may return before the actual -writing is done. -However, since version 1.3.20 Linux does actually wait. -(This still does not guarantee data integrity: modern disks have -large caches.) +writing is done. However Linux waits for I/O completions, +and thus +.BR sync () +or +.BR syncfs () +provide the same guarantees as fsync called on every file in +the system or filesystem respectively. +.SH BUGS +Before version 1.3.20 Linux did not wait for I/O to complete +before returning. .SH SEE ALSO -.BR bdflush (2), .BR fdatasync (2), .BR fsync (2), .BR sync (1)