From unknown Sat Aug 16 18:16:50 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#19681 <19681@debbugs.gnu.org> To: bug#19681 <19681@debbugs.gnu.org> Subject: Status: [PATCH] sync: use syncfs(2) if any argument is specified Reply-To: bug#19681 <19681@debbugs.gnu.org> Date: Sun, 17 Aug 2025 01:16:50 +0000 retitle 19681 [PATCH] sync: use syncfs(2) if any argument is specified reassign 19681 coreutils submitter 19681 Giuseppe Scrivano severity 19681 normal tag 19681 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 24 22:05:22 2015 Received: (at submit) by debbugs.gnu.org; 25 Jan 2015 03:05:22 +0000 Received: from localhost ([127.0.0.1]:55526 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFDVp-0002v4-8M for submit@debbugs.gnu.org; Sat, 24 Jan 2015 22:05:22 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52453) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFBNs-0006mO-DF for submit@debbugs.gnu.org; Sat, 24 Jan 2015 19:49:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YFBNl-0002lk-Vl for submit@debbugs.gnu.org; Sat, 24 Jan 2015 19:48:54 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: * X-Spam-Status: No, score=1.7 required=5.0 tests=BAYES_20,URIBL_BLACK autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:50546) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFBNl-0002lg-Sk for submit@debbugs.gnu.org; Sat, 24 Jan 2015 19:48:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFBNk-0005pp-IM for bug-coreutils@gnu.org; Sat, 24 Jan 2015 19:48:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YFBNh-0002lR-Bb for bug-coreutils@gnu.org; Sat, 24 Jan 2015 19:48:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45329) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFBNh-0002lN-4S for bug-coreutils@gnu.org; Sat, 24 Jan 2015 19:48:49 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0P0mlwT014240 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Sat, 24 Jan 2015 19:48:47 -0500 Received: from localhost.localdomain (vpn1-5-163.ams2.redhat.com [10.36.5.163]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0P0mjag004161 for ; Sat, 24 Jan 2015 19:48:46 -0500 From: Giuseppe Scrivano To: bug-coreutils@gnu.org Subject: [PATCH] sync: use syncfs(2) if any argument is specified Date: Sun, 25 Jan 2015 01:48:32 +0100 Message-Id: <1422146912-30962-1-git-send-email-gscrivan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -3.3 (---) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sat, 24 Jan 2015 22:05:18 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) * configure.ac: Check if syncfs(2) is available. * NEWS: Mention the new feature. * doc/coreutils.texi (sync invocation): Document the new feature. * src/sync.c (usage): Describe that arguments are now accepted. (main): Use syncfs(2) to flush buffers for the file system which contain the specified arguments. Silently fallback to sync(2) on errors. --- NEWS | 3 +++ configure.ac | 2 ++ doc/coreutils.texi | 7 ++++++- src/sync.c | 31 +++++++++++++++++++++++++++++-- 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index e0a2893..42bd02f 100644 --- a/NEWS +++ b/NEWS @@ -48,6 +48,9 @@ GNU coreutils NEWS -*- outline -*- split accepts a new --separator option to select a record separator character other than the default newline character. + sync accepts arguments, and if any is specified use syncfs(2) to + flush the buffers for the file systems which cointain these paths. + ** Changes in behavior df no longer suppresses separate exports of the same remote device, as diff --git a/configure.ac b/configure.ac index 3918f43..8fcfec9 100644 --- a/configure.ac +++ b/configure.ac @@ -328,6 +328,8 @@ if test $ac_cv_func_syslog = no; then done fi +AC_CHECK_FUNCS([syncfs]) + AC_CACHE_CHECK([for 3-argument setpriority function], [utils_cv_func_setpriority], [AC_LINK_IFELSE( diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 5a3c31a..6cc7414 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -12053,6 +12053,10 @@ crashes, data may be lost or the file system corrupted as a result. The @command{sync} command ensures everything in memory is written to disk. +If any argument is specified and the system supports the synfcs(2) +syscall, then only the file systems containing these paths will be +synchronized. If multiple paths point to the same file system, the +syncfs(2) syscall will be invoked for each one of them. Any arguments are ignored, except for a lone @option{--help} or @option{--version} (@pxref{Common options}). @@ -12081,7 +12085,8 @@ If a @var{file} is larger than the specified size, the extra data is lost. If a @var{file} is shorter, it is extended and the extended part (or hole) reads as zero bytes. -The program accepts the following options. Also see @ref{Common options}. +The only options are a lone @option{--help} or @option{--version}. +@xref{Common options}. @table @samp diff --git a/src/sync.c b/src/sync.c index e9f4d7e..940836e 100644 --- a/src/sync.c +++ b/src/sync.c @@ -37,10 +37,13 @@ usage (int status) emit_try_help (); else { - printf (_("Usage: %s [OPTION]\n"), program_name); + printf (_("Usage: %s [OPTION] [PATH]...\n"), program_name); fputs (_("\ Force changed blocks to disk, update the super block.\n\ \n\ +If one or more file paths are specified, update only the\n\ +file-systems which contain those files.\n\ +\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); @@ -65,9 +68,33 @@ main (int argc, char **argv) if (getopt_long (argc, argv, "", NULL, NULL) != -1) usage (EXIT_FAILURE); +#if HAVE_SYNCFS + /* If arguments are specified, use syncfs on any of them. + On any error, silently fallback to sync. */ if (optind < argc) - error (0, 0, _("ignoring all arguments")); + { + while (optind < argc) + { + int fd = open (argv[optind], O_RDONLY); + if (fd < 0) + goto sync; + + if (syncfs (fd) < 0) + { + close (fd); + goto sync; + } + + if (close (fd) < 0) + goto sync; + + optind++; + } + return EXIT_SUCCESS; + } +#endif +sync: sync (); return EXIT_SUCCESS; } -- 2.1.0 From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 24 22:42:12 2015 Received: (at 19681) by debbugs.gnu.org; 25 Jan 2015 03:42:12 +0000 Received: from localhost ([127.0.0.1]:55542 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFE5T-00059O-Ug for submit@debbugs.gnu.org; Sat, 24 Jan 2015 22:42:12 -0500 Received: from mail2.vodafone.ie ([213.233.128.44]:32205) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFE5Q-00058r-13 for 19681@debbugs.gnu.org; Sat, 24 Jan 2015 22:42:09 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnYFACllxFRtTtkF/2dsb2JhbABagwZSWcYzhXkCgQ9DAQEBAQF9hA0BBTIBVgsNAQoJFg8JAwIBAgFFBgEMCAEBFogWAcM/jhIMII9/hCkFkjmGazaEf4U/hjMigX8fgVA+MYJCAQEB Received: from unknown (HELO localhost.localdomain) ([109.78.217.5]) by mail2.vodafone.ie with ESMTP; 25 Jan 2015 03:42:01 +0000 Message-ID: <54C46608.1030409@draigBrady.com> Date: Sun, 25 Jan 2015 03:42:00 +0000 From: =?windows-1252?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Giuseppe Scrivano , 19681@debbugs.gnu.org Subject: Re: bug#19681: [PATCH] sync: use syncfs(2) if any argument is specified References: <1422146912-30962-1-git-send-email-gscrivan@redhat.com> In-Reply-To: <1422146912-30962-1-git-send-email-gscrivan@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19681 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) thanks I like it! Tweaks below... On 25/01/15 00:48, Giuseppe Scrivano wrote: > * configure.ac: Check if syncfs(2) is available. > * NEWS: Mention the new feature. > * doc/coreutils.texi (sync invocation): Document the new feature. > * src/sync.c (usage): Describe that arguments are now accepted. > (main): Use syncfs(2) to flush buffers for the file system which > contain the specified arguments. Silently fallback to sync(2) on > errors. > --- > NEWS | 3 +++ > configure.ac | 2 ++ > doc/coreutils.texi | 7 ++++++- > src/sync.c | 31 +++++++++++++++++++++++++++++-- > 4 files changed, 40 insertions(+), 3 deletions(-) > > diff --git a/NEWS b/NEWS > index e0a2893..42bd02f 100644 > --- a/NEWS > +++ b/NEWS > @@ -48,6 +48,9 @@ GNU coreutils NEWS -*- outline -*- > split accepts a new --separator option to select a record separator character > other than the default newline character. > > + sync accepts arguments, and if any is specified use syncfs(2) to > + flush the buffers for the file systems which cointain these paths. sync no longer ignores arguments, and now uses syncfs(2) to sync the file systems associated with each specified path. > + > ** Changes in behavior > > df no longer suppresses separate exports of the same remote device, as > diff --git a/configure.ac b/configure.ac > index 3918f43..8fcfec9 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -328,6 +328,8 @@ if test $ac_cv_func_syslog = no; then > done > fi > > +AC_CHECK_FUNCS([syncfs]) > + > AC_CACHE_CHECK([for 3-argument setpriority function], > [utils_cv_func_setpriority], > [AC_LINK_IFELSE( > diff --git a/doc/coreutils.texi b/doc/coreutils.texi > index 5a3c31a..6cc7414 100644 > --- a/doc/coreutils.texi > +++ b/doc/coreutils.texi > @@ -12053,6 +12053,10 @@ crashes, data may be lost or the file system corrupted as a > result. The @command{sync} command ensures everything in memory > is written to disk. > > +If any argument is specified and the system supports the synfcs(2) > +syscall, then only the file systems containing these paths will be > +synchronized. If multiple paths point to the same file system, the > +syncfs(2) syscall will be invoked for each one of them. > Any arguments are ignored, except for a lone @option{--help} or > @option{--version} (@pxref{Common options}). > > @@ -12081,7 +12085,8 @@ If a @var{file} is larger than the specified size, the extra data is lost. > If a @var{file} is shorter, it is extended and the extended part (or hole) > reads as zero bytes. > > -The program accepts the following options. Also see @ref{Common options}. > +The only options are a lone @option{--help} or @option{--version}. > +@xref{Common options}. > > @table @samp > > diff --git a/src/sync.c b/src/sync.c > index e9f4d7e..940836e 100644 > --- a/src/sync.c > +++ b/src/sync.c > @@ -37,10 +37,13 @@ usage (int status) > emit_try_help (); > else > { > - printf (_("Usage: %s [OPTION]\n"), program_name); > + printf (_("Usage: %s [OPTION] [PATH]...\n"), program_name); > fputs (_("\ > Force changed blocks to disk, update the super block.\n\ > \n\ > +If one or more file paths are specified, update only the\n\ > +file-systems which contain those files.\n\ > +\n\ > "), stdout); > fputs (HELP_OPTION_DESCRIPTION, stdout); > fputs (VERSION_OPTION_DESCRIPTION, stdout); > @@ -65,9 +68,33 @@ main (int argc, char **argv) > if (getopt_long (argc, argv, "", NULL, NULL) != -1) > usage (EXIT_FAILURE); > > +#if HAVE_SYNCFS > + /* If arguments are specified, use syncfs on any of them. > + On any error, silently fallback to sync. */ > if (optind < argc) > - error (0, 0, _("ignoring all arguments")); The warning above should be moved down to the sync: case rather than removing it. > + { > + while (optind < argc) > + { > + int fd = open (argv[optind], O_RDONLY); > + if (fd < 0) > + goto sync; > + > + if (syncfs (fd) < 0) > + { > + close (fd); > + goto sync; > + } > + > + if (close (fd) < 0) > + goto sync; > + > + optind++; > + } > + return EXIT_SUCCESS; > + } > +#endif > > +sync: > sync (); > return EXIT_SUCCESS; > } > thanks! Pįdraig From debbugs-submit-bounces@debbugs.gnu.org Sun Jan 25 08:03:23 2015 Received: (at 19681) by debbugs.gnu.org; 25 Jan 2015 13:03:23 +0000 Received: from localhost ([127.0.0.1]:55639 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFMqY-0002tz-1e for submit@debbugs.gnu.org; Sun, 25 Jan 2015 08:03:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40876) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFMqW-0002tr-3x for 19681@debbugs.gnu.org; Sun, 25 Jan 2015 08:03:21 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0PD3I99010484 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 25 Jan 2015 08:03:19 -0500 Received: from localhost.localdomain (vpn1-4-153.ams2.redhat.com [10.36.4.153]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0PD3HKH027477; Sun, 25 Jan 2015 08:03:17 -0500 From: Giuseppe Scrivano To: P@draigbrady.com Subject: [PATCH] sync: use syncfs(2) if any argument is specified Date: Sun, 25 Jan 2015 14:03:04 +0100 Message-Id: <1422190984-18157-1-git-send-email-gscrivan@redhat.com> In-Reply-To: <54C46608.1030409@draigBrady.com> References: <54C46608.1030409@draigBrady.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 19681 Cc: 19681@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) * configure.ac: Check if syncfs(2) is available. * NEWS: Mention the new feature. * doc/coreutils.texi (sync invocation): Document the new feature. * src/sync.c (usage): Describe that arguments are now accepted. (main): Use syncfs(2) to flush buffers for the file system which contain the specified arguments. Silently fallback to sync(2) on errors. --- I've amended the suggested fixes in this version. NEWS | 3 +++ configure.ac | 2 ++ doc/coreutils.texi | 7 ++++++- src/sync.c | 37 +++++++++++++++++++++++++++++++++++-- 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index e0a2893..611fde6 100644 --- a/NEWS +++ b/NEWS @@ -48,6 +48,9 @@ GNU coreutils NEWS -*- outline -*- split accepts a new --separator option to select a record separator character other than the default newline character. + sync no longer ignores arguments, and now uses syncfs(2) to sync + the file systems associated with each specified path. + ** Changes in behavior df no longer suppresses separate exports of the same remote device, as diff --git a/configure.ac b/configure.ac index 3918f43..8fcfec9 100644 --- a/configure.ac +++ b/configure.ac @@ -328,6 +328,8 @@ if test $ac_cv_func_syslog = no; then done fi +AC_CHECK_FUNCS([syncfs]) + AC_CACHE_CHECK([for 3-argument setpriority function], [utils_cv_func_setpriority], [AC_LINK_IFELSE( diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 5a3c31a..6cc7414 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -12053,6 +12053,10 @@ crashes, data may be lost or the file system corrupted as a result. The @command{sync} command ensures everything in memory is written to disk. +If any argument is specified and the system supports the synfcs(2) +syscall, then only the file systems containing these paths will be +synchronized. If multiple paths point to the same file system, the +syncfs(2) syscall will be invoked for each one of them. Any arguments are ignored, except for a lone @option{--help} or @option{--version} (@pxref{Common options}). @@ -12081,7 +12085,8 @@ If a @var{file} is larger than the specified size, the extra data is lost. If a @var{file} is shorter, it is extended and the extended part (or hole) reads as zero bytes. -The program accepts the following options. Also see @ref{Common options}. +The only options are a lone @option{--help} or @option{--version}. +@xref{Common options}. @table @samp diff --git a/src/sync.c b/src/sync.c index e9f4d7e..c160e54 100644 --- a/src/sync.c +++ b/src/sync.c @@ -37,10 +37,13 @@ usage (int status) emit_try_help (); else { - printf (_("Usage: %s [OPTION]\n"), program_name); + printf (_("Usage: %s [OPTION] [PATH]...\n"), program_name); fputs (_("\ Force changed blocks to disk, update the super block.\n\ \n\ +If one or more file paths are specified, update only the\n\ +file-systems which contain those files.\n\ +\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); @@ -52,6 +55,7 @@ Force changed blocks to disk, update the super block.\n\ int main (int argc, char **argv) { + bool args_specified; initialize_main (&argc, &argv); set_program_name (argv[0]); setlocale (LC_ALL, ""); @@ -65,7 +69,36 @@ main (int argc, char **argv) if (getopt_long (argc, argv, "", NULL, NULL) != -1) usage (EXIT_FAILURE); - if (optind < argc) + args_specified = optind < argc; + +#if HAVE_SYNCFS + /* If arguments are specified, use syncfs on each of them. + On any error, silently fallback to sync. */ + if (args_specified) + { + while (optind < argc) + { + int fd = open (argv[optind], O_RDONLY); + if (fd < 0) + goto sync; + + if (syncfs (fd) < 0) + { + close (fd); + goto sync; + } + + if (close (fd) < 0) + goto sync; + + optind++; + } + return EXIT_SUCCESS; + } +#endif + +sync: + if (args_specified) error (0, 0, _("ignoring all arguments")); sync (); -- 2.1.0 From debbugs-submit-bounces@debbugs.gnu.org Sun Jan 25 08:14:01 2015 Received: (at 19681) by debbugs.gnu.org; 25 Jan 2015 13:14:01 +0000 Received: from localhost ([127.0.0.1]:55644 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFN0q-00038s-Su for submit@debbugs.gnu.org; Sun, 25 Jan 2015 08:14:01 -0500 Received: from mail1.vodafone.ie ([213.233.128.43]:26618) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFN0o-00038e-Uy for 19681@debbugs.gnu.org; Sun, 25 Jan 2015 08:13:59 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AncFAPfqxFRtTk7f/2dsb2JhbABagwZSWYEixRCFeQKBD0MBAQEBAX2EDAEBAQMBMgFGBQsLDQEKCRYPCQMCAQIBRQYNAQcBAYggDAHDX44WAQEBBwEBAQEej3gHhCkBBJI5hms2hH+FP4YzIoNuPjGCQgEBAQ Received: from unknown (HELO localhost.localdomain) ([109.78.78.223]) by mail1.vodafone.ie with ESMTP; 25 Jan 2015 13:13:52 +0000 Message-ID: <54C4EC0F.6010208@draigBrady.com> Date: Sun, 25 Jan 2015 13:13:51 +0000 From: =?windows-1252?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Giuseppe Scrivano Subject: Re: bug#19681: [PATCH] sync: use syncfs(2) if any argument is specified References: <54C46608.1030409@draigBrady.com> <1422190984-18157-1-git-send-email-gscrivan@redhat.com> In-Reply-To: <1422190984-18157-1-git-send-email-gscrivan@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19681 Cc: 19681@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 25/01/15 13:03, Giuseppe Scrivano wrote: > diff --git a/configure.ac b/configure.ac > +AC_CHECK_FUNCS([syncfs]) > + I might move this to one of the other config time files. > diff --git a/src/sync.c b/src/sync.c > @@ -37,10 +37,13 @@ usage (int status) > +If one or more file paths are specified, update only the\n\ > +file-systems which contain those files.\n\ s/file-systems/file systems/ I'll tweak as above before pushing. thanks! Pįdraig. From debbugs-submit-bounces@debbugs.gnu.org Sun Jan 25 10:38:53 2015 Received: (at 19681) by debbugs.gnu.org; 25 Jan 2015 15:38:53 +0000 Received: from localhost ([127.0.0.1]:55961 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFPH3-0006iE-C9 for submit@debbugs.gnu.org; Sun, 25 Jan 2015 10:38:53 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]:55032) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFPH0-0006hn-43 for 19681@debbugs.gnu.org; Sun, 25 Jan 2015 10:38:50 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id DDCFEA6004D; Sun, 25 Jan 2015 07:38:43 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Wfmd+eISlRLA; Sun, 25 Jan 2015 07:38:43 -0800 (PST) Received: from [192.168.1.9] (pool-173-55-11-52.lsanca.fios.verizon.net [173.55.11.52]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 9987DA60016; Sun, 25 Jan 2015 07:38:43 -0800 (PST) Message-ID: <54C50E03.3010106@cs.ucla.edu> Date: Sun, 25 Jan 2015 07:38:43 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= , Giuseppe Scrivano Subject: Re: bug#19681: [PATCH] sync: use syncfs(2) if any argument is specified References: <54C46608.1030409@draigBrady.com> <1422190984-18157-1-git-send-email-gscrivan@redhat.com> <54C4EC0F.6010208@draigBrady.com> In-Reply-To: <54C4EC0F.6010208@draigBrady.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 19681 Cc: 19681@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) If we're adding this sort of option, shouldn't we also give users the ability to invoke fsync and fdatasync on a single file, as opposed to syncfs on an entire file system? From debbugs-submit-bounces@debbugs.gnu.org Sun Jan 25 12:19:38 2015 Received: (at 19681) by debbugs.gnu.org; 25 Jan 2015 17:19:38 +0000 Received: from localhost ([127.0.0.1]:56135 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFQqX-0004Kd-Av for submit@debbugs.gnu.org; Sun, 25 Jan 2015 12:19:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52830) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFQqU-0004KE-Dh for 19681@debbugs.gnu.org; Sun, 25 Jan 2015 12:19:35 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0PHJMos014945 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 25 Jan 2015 12:19:22 -0500 Received: from foobarbaz (vpn1-4-153.ams2.redhat.com [10.36.4.153]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0PHJJo3029682 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Sun, 25 Jan 2015 12:19:20 -0500 From: Giuseppe Scrivano To: Paul Eggert Subject: Re: bug#19681: [PATCH] sync: use syncfs(2) if any argument is specified References: <54C46608.1030409@draigBrady.com> <1422190984-18157-1-git-send-email-gscrivan@redhat.com> <54C4EC0F.6010208@draigBrady.com> <54C50E03.3010106@cs.ucla.edu> Date: Sun, 25 Jan 2015 18:19:18 +0100 In-Reply-To: <54C50E03.3010106@cs.ucla.edu> (Paul Eggert's message of "Sun, 25 Jan 2015 07:38:43 -0800") Message-ID: <87egqiye09.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 19681 Cc: =?utf-8?Q?P=C3=A1draig?= Brady , 19681@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Paul Eggert writes: > If we're adding this sort of option, shouldn't we also give users the > ability to invoke fsync and fdatasync on a single file, as opposed to > syncfs on an entire file system? Good point. Should we instead add something like --file-system and --data-only, respectively for syncfs and fdatasync and use fsync if no option is specified? Giuseppe From debbugs-submit-bounces@debbugs.gnu.org Sun Jan 25 12:28:43 2015 Received: (at 19681) by debbugs.gnu.org; 25 Jan 2015 17:28:43 +0000 Received: from localhost ([127.0.0.1]:56139 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFQzK-0004jw-Vm for submit@debbugs.gnu.org; Sun, 25 Jan 2015 12:28:43 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]:58356) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFQzJ-0004jb-LQ for 19681@debbugs.gnu.org; Sun, 25 Jan 2015 12:28:41 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id F1B9239E8014; Sun, 25 Jan 2015 09:28:35 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OjX9xMEcuKFM; Sun, 25 Jan 2015 09:28:35 -0800 (PST) Received: from [192.168.1.9] (pool-173-55-11-52.lsanca.fios.verizon.net [173.55.11.52]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 9EFF439E8013; Sun, 25 Jan 2015 09:28:35 -0800 (PST) Message-ID: <54C527C2.9050702@cs.ucla.edu> Date: Sun, 25 Jan 2015 09:28:34 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Giuseppe Scrivano Subject: Re: bug#19681: [PATCH] sync: use syncfs(2) if any argument is specified References: <54C46608.1030409@draigBrady.com> <1422190984-18157-1-git-send-email-gscrivan@redhat.com> <54C4EC0F.6010208@draigBrady.com> <54C50E03.3010106@cs.ucla.edu> <87egqiye09.fsf@redhat.com> In-Reply-To: <87egqiye09.fsf@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 19681 Cc: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= , 19681@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Giuseppe Scrivano wrote: > Should we instead add something like --file-system and > --data-only, respectively for syncfs and fdatasync and use fsync if no > option is specified? Yes, thanks, that sounds reasonable. I suggest --data rather than --data-only, as fdatasync is allowed to synchronize metadata and "--data-only" implies otherwise. From debbugs-submit-bounces@debbugs.gnu.org Sun Jan 25 12:41:26 2015 Received: (at 19681) by debbugs.gnu.org; 25 Jan 2015 17:41:26 +0000 Received: from localhost ([127.0.0.1]:56143 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFRBc-0005Lf-HF for submit@debbugs.gnu.org; Sun, 25 Jan 2015 12:41:25 -0500 Received: from mail1.vodafone.ie ([213.233.128.43]:43834) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFRBY-0005LA-Pi for 19681@debbugs.gnu.org; Sun, 25 Jan 2015 12:41:22 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApkFAF4pxVRtTk7f/2dsb2JhbABaDoJ4UoNZwzWFdQKBDkMBAQEBAX2EDQEFIw8BRhALDQsCAgUhAgIPAkYGAQwBBwEBiCwBvXOFaY4eAQEBAQYBAQEBAR2BIY5XB4JogUEFkjmMIItyIoMxPT6CcwEBAQ Received: from unknown (HELO localhost.localdomain) ([109.78.78.223]) by mail1.vodafone.ie with ESMTP; 25 Jan 2015 17:41:12 +0000 Message-ID: <54C52AB8.20301@draigBrady.com> Date: Sun, 25 Jan 2015 17:41:12 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Paul Eggert , Giuseppe Scrivano Subject: Re: bug#19681: [PATCH] sync: use syncfs(2) if any argument is specified References: <54C46608.1030409@draigBrady.com> <1422190984-18157-1-git-send-email-gscrivan@redhat.com> <54C4EC0F.6010208@draigBrady.com> <54C50E03.3010106@cs.ucla.edu> In-Reply-To: <54C50E03.3010106@cs.ucla.edu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19681 Cc: 19681@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 25/01/15 15:38, Paul Eggert wrote: > If we're adding this sort of option, shouldn't we also give users the ability to > invoke fsync and fdatasync on a single file, as opposed to syncfs on an entire > file system? Yes good point on also integrating per file syncing. Per file syncing is already supported by dd, but would be a natural fit to sync(1). BTW I grepped my internal notes on sync and noticed http://lwn.net/Articles/433384/ which details syncfs() and also suggests `sync file...` as an interface. So we have: fdatasync < fsync < syncfs < sync referring to:: file data, file data + metadata, file system, all file systems You'd need an option to distinguish between file and file system. The option could refer to _what_ to sync, or what _method_ to use to sync. An advantage of specifying the method is they're well understood and described elsewhere: --mode={fdatasync, fsync, syncfs, sync} The first two would give an error without arguments, the last would give an error with arguments. The alternative _what_ interface might look like: --what={data, file-system} or split out to separate options like: -d,--data, -f,--file-system An advantage of specifying what to sync is that it's a bit more general, avoiding specifying implementation methods. Also the options would not imply needing or not needing to specify files. I'd be incline to go with the _what_ interface above. thanks, PĆ”draig From debbugs-submit-bounces@debbugs.gnu.org Sun Jan 25 13:06:09 2015 Received: (at 19681) by debbugs.gnu.org; 25 Jan 2015 18:06:09 +0000 Received: from localhost ([127.0.0.1]:56194 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFRZY-0000qo-QZ for submit@debbugs.gnu.org; Sun, 25 Jan 2015 13:06:09 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:63114) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFRZW-0000q7-6w for 19681@debbugs.gnu.org; Sun, 25 Jan 2015 13:06:06 -0500 Received: from [192.168.1.10] ([84.175.81.114]) by mrelayeu.kundenserver.de (mreue103) with ESMTPSA (Nemesis) id 0MQ8It-1YK6Wp0P6x-005HAz; Sun, 25 Jan 2015 19:05:44 +0100 Message-ID: <54C53076.4060803@bernhard-voelker.de> Date: Sun, 25 Jan 2015 19:05:42 +0100 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= , Paul Eggert , Giuseppe Scrivano Subject: Re: bug#19681: [PATCH] sync: use syncfs(2) if any argument is specified References: <54C46608.1030409@draigBrady.com> <1422190984-18157-1-git-send-email-gscrivan@redhat.com> <54C4EC0F.6010208@draigBrady.com> <54C50E03.3010106@cs.ucla.edu> <54C52AB8.20301@draigBrady.com> In-Reply-To: <54C52AB8.20301@draigBrady.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:K2LVInp5Kk2cSkT6z3jWYyzFVc7JZ2Nu+JYxCV9cJj+GW1Z/GSm swS3mLW999VXJ0dZhI5h4QCsx1vniK1r1SA7gOhloK5qzN8wR1bnFTPGo/54YhV92aW1GZH PXONrOIWPrsITBDcbsdwf5EvTWhTXCfsuDHKlekwgKB86TYI8iT/ebu+CvSAUzBlix/KTtB nQSbKRm7wQQXs4j+zs48w== X-UI-Out-Filterresults: notjunk:1; X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19681 Cc: 19681@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 01/25/2015 06:41 PM, PĆ”draig Brady wrote: > So we have: fdatasync < fsync < syncfs < sync > referring to:: file data, file data + metadata, file system, all file systems > [...] > I'd be incline to go with the _what_ interface above. Either way, I think it's important to document sync is falling back to the bigger hammer if the smaller failed. ... or shouldn't do sync this? Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Sun Jan 25 13:32:44 2015 Received: (at 19681) by debbugs.gnu.org; 25 Jan 2015 18:32:44 +0000 Received: from localhost ([127.0.0.1]:56198 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFRzH-000226-CX for submit@debbugs.gnu.org; Sun, 25 Jan 2015 13:32:43 -0500 Received: from mail1.vodafone.ie ([213.233.128.43]:17024) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFRzE-00021g-Jn for 19681@debbugs.gnu.org; Sun, 25 Jan 2015 13:32:41 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApkFAHE2xVRtTk7f/2dsb2JhbABaDoJ4hCvGW4JPAoEPQwEBAQEBfYQNAQUjBAsBRhALDQEKAgIFFgsCAgkDAgECAUUGAQwBBwEBiCwBvXaFaY4bAQEBAQYBAQEBAR2BIY5XB4JogUEFlAiKUYtyIoMxPT6CcwEBAQ Received: from unknown (HELO localhost.localdomain) ([109.78.78.223]) by mail1.vodafone.ie with ESMTP; 25 Jan 2015 18:32:30 +0000 Message-ID: <54C536BD.8000802@draigBrady.com> Date: Sun, 25 Jan 2015 18:32:29 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Bernhard Voelker , Paul Eggert , Giuseppe Scrivano Subject: Re: bug#19681: [PATCH] sync: use syncfs(2) if any argument is specified References: <54C46608.1030409@draigBrady.com> <1422190984-18157-1-git-send-email-gscrivan@redhat.com> <54C4EC0F.6010208@draigBrady.com> <54C50E03.3010106@cs.ucla.edu> <54C52AB8.20301@draigBrady.com> <54C53076.4060803@bernhard-voelker.de> In-Reply-To: <54C53076.4060803@bernhard-voelker.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19681 Cc: 19681@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 25/01/15 18:05, Bernhard Voelker wrote: > On 01/25/2015 06:41 PM, PĆ”draig Brady wrote: >> So we have: fdatasync < fsync < syncfs < sync >> referring to:: file data, file data + metadata, file system, all file systems > >> [...] > >> I'd be incline to go with the _what_ interface above. > > Either way, I think it's important to document sync is falling back > to the bigger hammer if the smaller failed. > ... or shouldn't do sync this? It should fall back where possible. Now there is a difference between the file and file system(s) interfaces in that the former can return EIO error for example, while the latter are specified to always return success. You wouldn't fall back to a syncfs() if an fsync() gave an EIO for example. Also gnulib guarantees that fsync() and fdatasync() are available, so I wouldn't fallback from file -> file system interfaces, nor between file interfaces. There is an edge case with fsync("fifo") for example where EINVAL is given, though again since there is no data in the file system associated with that, I wouldn't bother falling back to a file system interface. As for documenting the fall back, that's one of the reasons I suggested keeping the warning if syncfs() is not supported, which should be enough direct feedback about the extra syncing happening. cheers, PĆ”draig. From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 26 03:36:24 2015 Received: (at 19681) by debbugs.gnu.org; 26 Jan 2015 08:36:24 +0000 Received: from localhost ([127.0.0.1]:56572 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFf9k-0003Qy-Cv for submit@debbugs.gnu.org; Mon, 26 Jan 2015 03:36:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38752) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFf9h-0003Qj-Ed for 19681@debbugs.gnu.org; Mon, 26 Jan 2015 03:36:22 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0Q8a9UX016064 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Jan 2015 03:36:10 -0500 Received: from foobarbaz (vpn1-6-34.ams2.redhat.com [10.36.6.34]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0Q8a6ii003956 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Mon, 26 Jan 2015 03:36:07 -0500 From: Giuseppe Scrivano To: =?utf-8?Q?P=C3=A1draig?= Brady Subject: Re: bug#19681: [PATCH] sync: use syncfs(2) if any argument is specified References: <54C46608.1030409@draigBrady.com> <1422190984-18157-1-git-send-email-gscrivan@redhat.com> <54C4EC0F.6010208@draigBrady.com> <54C50E03.3010106@cs.ucla.edu> <54C52AB8.20301@draigBrady.com> <54C53076.4060803@bernhard-voelker.de> <54C536BD.8000802@draigBrady.com> Date: Mon, 26 Jan 2015 09:36:05 +0100 In-Reply-To: <54C536BD.8000802@draigBrady.com> (=?utf-8?Q?=22P=C3=A1draig?= Brady"'s message of "Sun, 25 Jan 2015 18:32:29 +0000") Message-ID: <877fwax7ka.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 19681 Cc: Bernhard Voelker , 19681@debbugs.gnu.org, Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) P=C3=A1draig Brady writes: > On 25/01/15 18:05, Bernhard Voelker wrote: >> On 01/25/2015 06:41 PM, P=C3=A1draig Brady wrote: >>> So we have: fdatasync < fsync < syncfs < sync >>> referring to:: file data, file data + metadata, file system, all file s= ystems >>=20 >>> [...] >>=20 >>> I'd be incline to go with the _what_ interface above. >>=20 >> Either way, I think it's important to document sync is falling back >> to the bigger hammer if the smaller failed. >> ... or shouldn't do sync this? > > It should fall back where possible. > > Now there is a difference between the file and file system(s) interfaces > in that the former can return EIO error for example, while the latter > are specified to always return success. You wouldn't fall back to > a syncfs() if an fsync() gave an EIO for example. Also gnulib > guarantees that fsync() and fdatasync() are available, so I wouldn't > fallback from file -> file system interfaces, nor between file interfaces. one risk here is when multiple arguments are specified and the fsync will return EIO more than once, we will fallback to syncfs multiple times. Couldn't in this case a single sync be a better choice? Regards, Giuseppe From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 26 06:12:01 2015 Received: (at 19681) by debbugs.gnu.org; 26 Jan 2015 11:12:02 +0000 Received: from localhost ([127.0.0.1]:56619 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFhaL-0007D4-6t for submit@debbugs.gnu.org; Mon, 26 Jan 2015 06:12:01 -0500 Received: from mail4.vodafone.ie ([213.233.128.170]:28245) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFhaJ-0007Cq-ET for 19681@debbugs.gnu.org; Mon, 26 Jan 2015 06:12:00 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtoFAIIgxlRtTt7D/2dsb2JhbABagwaBK4MAyTACgRRDAQEBAQF9hA0BBSMECwFGEAsNAQoCAgUWCwICCQMCAQIBRQYNAQUCAQGILAG+KoVpjkABAQEHAQEBAQEdgSGOVweCaIFBBZQIilGLciKDbj4xgkIBAQE Received: from unknown (HELO localhost.localdomain) ([109.78.222.195]) by mail3.vodafone.ie with ESMTP; 26 Jan 2015 11:11:52 +0000 Message-ID: <54C620F8.7070304@draigBrady.com> Date: Mon, 26 Jan 2015 11:11:52 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Giuseppe Scrivano Subject: Re: bug#19681: [PATCH] sync: use syncfs(2) if any argument is specified References: <54C46608.1030409@draigBrady.com> <1422190984-18157-1-git-send-email-gscrivan@redhat.com> <54C4EC0F.6010208@draigBrady.com> <54C50E03.3010106@cs.ucla.edu> <54C52AB8.20301@draigBrady.com> <54C53076.4060803@bernhard-voelker.de> <54C536BD.8000802@draigBrady.com> <877fwax7ka.fsf@redhat.com> In-Reply-To: <877fwax7ka.fsf@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19681 Cc: Bernhard Voelker , 19681@debbugs.gnu.org, Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 26/01/15 08:36, Giuseppe Scrivano wrote: > PĆ”draig Brady writes: > >> On 25/01/15 18:05, Bernhard Voelker wrote: >>> On 01/25/2015 06:41 PM, PĆ”draig Brady wrote: >>>> So we have: fdatasync < fsync < syncfs < sync >>>> referring to:: file data, file data + metadata, file system, all file systems >>> >>>> [...] >>> >>>> I'd be incline to go with the _what_ interface above. >>> >>> Either way, I think it's important to document sync is falling back >>> to the bigger hammer if the smaller failed. >>> ... or shouldn't do sync this? >> >> It should fall back where possible. >> >> Now there is a difference between the file and file system(s) interfaces >> in that the former can return EIO error for example, while the latter >> are specified to always return success. You wouldn't fall back to >> a syncfs() if an fsync() gave an EIO for example. Also gnulib >> guarantees that fsync() and fdatasync() are available, so I wouldn't >> fallback from file -> file system interfaces, nor between file interfaces. > > one risk here is when multiple arguments are specified and the fsync > will return EIO more than once, we will fallback to syncfs multiple > times. Couldn't in this case a single sync be a better choice? I was saying we shouldn't fall back from fsync() to syncfs(). Just process each argument. Diagnose any errors and EXIT_FAILURE if there was any error? PĆ”draig. From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 26 11:02:57 2015 Received: (at 19681) by debbugs.gnu.org; 26 Jan 2015 16:02:57 +0000 Received: from localhost ([127.0.0.1]:57199 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFm7t-0007Cv-Bq for submit@debbugs.gnu.org; Mon, 26 Jan 2015 11:02:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40497) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFm7q-0007Cm-Bl for 19681@debbugs.gnu.org; Mon, 26 Jan 2015 11:02:55 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0QG2pCH024942 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for <19681@debbugs.gnu.org>; Mon, 26 Jan 2015 11:02:52 -0500 Received: from [10.3.113.144] (ovpn-113-144.phx2.redhat.com [10.3.113.144]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0QG2pVt017643; Mon, 26 Jan 2015 11:02:51 -0500 Message-ID: <54C6652A.30809@redhat.com> Date: Mon, 26 Jan 2015 09:02:50 -0700 From: Eric Blake Organization: Red Hat, Inc. User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Giuseppe Scrivano , 19681@debbugs.gnu.org Subject: Re: bug#19681: [PATCH] sync: use syncfs(2) if any argument is specified References: <1422146912-30962-1-git-send-email-gscrivan@redhat.com> In-Reply-To: <1422146912-30962-1-git-send-email-gscrivan@redhat.com> OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="qa72wwqwukBNRCtmINTE7i0rNludJUWfL" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 19681 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --qa72wwqwukBNRCtmINTE7i0rNludJUWfL Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01/24/2015 05:48 PM, Giuseppe Scrivano wrote: > * configure.ac: Check if syncfs(2) is available. > * NEWS: Mention the new feature. > * doc/coreutils.texi (sync invocation): Document the new feature. > * src/sync.c (usage): Describe that arguments are now accepted. > (main): Use syncfs(2) to flush buffers for the file system which > contain the specified arguments. Silently fallback to sync(2) on > errors. > --- > @@ -65,9 +68,33 @@ main (int argc, char **argv) > if (getopt_long (argc, argv, "", NULL, NULL) !=3D -1) > usage (EXIT_FAILURE); > =20 > +#if HAVE_SYNCFS > + /* If arguments are specified, use syncfs on any of them. > + On any error, silently fallback to sync. */ > if (optind < argc) > - error (0, 0, _("ignoring all arguments")); > + { > + while (optind < argc) > + { > + int fd =3D open (argv[optind], O_RDONLY); > + if (fd < 0) > + goto sync; > + > + if (syncfs (fd) < 0) > + { > + close (fd); > + goto sync; > + } > + > + if (close (fd) < 0) > + goto sync; > + > + optind++; > + } > + return EXIT_SUCCESS; > + } > +#endif > =20 > +sync: This label is unused if !HAVE_SYNCFS. I suggest moving it inside the #if= =2E --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --qa72wwqwukBNRCtmINTE7i0rNludJUWfL Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJUxmUqAAoJEKeha0olJ0NqbBMIAIl2EUjc4o0nO9vLFRsVM8jz EYrZ59Ehi9+k7A+v8ZO+DxJQA3NAT4O8/Zs2rSRWU59zxAMKiIqDDAgjbbGio4mA xGrTqIP+r8cln2Hdqlj3IUMnCdN/gy7AQ2VLZw9mWy3Ve9FxtvdMjDXs7vzarPYX Y1KKSTIxfxVJEDefXZGSj+bLcad7pLZh5wS54KOaz3VNY+gDALCrdf6eqd8UKY8+ VGheQZSmSKYs3CYuqFiRD5yN+BJGiyE3jG7VDpR/FI/NMpb2hEj57/EDBHdKQXIO 6Awrp01RdhrIvZhBiKrE5XBcciAk9ghX3hvtfX+GRMxjPg5szC9puEIz0Okzg1g= =Mxdm -----END PGP SIGNATURE----- --qa72wwqwukBNRCtmINTE7i0rNludJUWfL-- From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 26 16:27:57 2015 Received: (at 19681) by debbugs.gnu.org; 26 Jan 2015 21:27:57 +0000 Received: from localhost ([127.0.0.1]:57356 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFrCN-0007W5-VX for submit@debbugs.gnu.org; Mon, 26 Jan 2015 16:27:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36901) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFrCL-0007Vw-Ba for 19681@debbugs.gnu.org; Mon, 26 Jan 2015 16:27:54 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0QLRang020986 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Jan 2015 16:27:37 -0500 Received: from foobarbaz (vpn1-6-34.ams2.redhat.com [10.36.6.34]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0QLRVXR025428 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Mon, 26 Jan 2015 16:27:33 -0500 From: Giuseppe Scrivano To: =?utf-8?Q?P=C3=A1draig?= Brady Subject: Re: bug#19681: [PATCH] sync: use syncfs(2) if any argument is specified References: <54C46608.1030409@draigBrady.com> <1422190984-18157-1-git-send-email-gscrivan@redhat.com> <54C4EC0F.6010208@draigBrady.com> <54C50E03.3010106@cs.ucla.edu> <54C52AB8.20301@draigBrady.com> <54C53076.4060803@bernhard-voelker.de> <54C536BD.8000802@draigBrady.com> <877fwax7ka.fsf@redhat.com> <54C620F8.7070304@draigBrady.com> Date: Mon, 26 Jan 2015 22:27:31 +0100 In-Reply-To: <54C620F8.7070304@draigBrady.com> (=?utf-8?Q?=22P=C3=A1draig?= Brady"'s message of "Mon, 26 Jan 2015 11:11:52 +0000") Message-ID: <87fvaxuta4.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 19681 Cc: Bernhard Voelker , Eric Blake , 19681@debbugs.gnu.org, Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) P=C3=A1draig Brady writes: > On 26/01/15 08:36, Giuseppe Scrivano wrote: >> P=C3=A1draig Brady writes: >>=20 >>> On 25/01/15 18:05, Bernhard Voelker wrote: >>>> On 01/25/2015 06:41 PM, P=C3=A1draig Brady wrote: >>>>> So we have: fdatasync < fsync < syncfs < sync >>>>> referring to:: file data, file data + metadata, file system, all file= systems >>>> >>>>> [...] >>>> >>>>> I'd be incline to go with the _what_ interface above. >>>> >>>> Either way, I think it's important to document sync is falling back >>>> to the bigger hammer if the smaller failed. >>>> ... or shouldn't do sync this? >>> >>> It should fall back where possible. >>> >>> Now there is a difference between the file and file system(s) interfaces >>> in that the former can return EIO error for example, while the latter >>> are specified to always return success. You wouldn't fall back to >>> a syncfs() if an fsync() gave an EIO for example. Also gnulib >>> guarantees that fsync() and fdatasync() are available, so I wouldn't >>> fallback from file -> file system interfaces, nor between file interfac= es. >>=20 >> one risk here is when multiple arguments are specified and the fsync >> will return EIO more than once, we will fallback to syncfs multiple >> times. Couldn't in this case a single sync be a better choice? > > I was saying we shouldn't fall back from fsync() to syncfs(). > Just process each argument. Diagnose any errors and EXIT_FAILURE > if there was any error? sorry for misunderstanding that. I've worked out a new version that includes these suggestions, also since now the user can explicitly ask for the sync mechanism to use, I agree with you and we should raise an error if something goes wrong. Since sync is completely different now, I took the freedom to add myself to the AUTHORS, feel free to drop this part if you disagree. Regards, Giuseppe >From 0dbc5ce9c78bc97ec5a678803270767ad9980618 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Sun, 25 Jan 2015 01:33:45 +0100 Subject: [PATCH] sync: add support for fsync(2), fdatasync(2) and syncfs(2) * AUTHORS: Add myself to sync's authors. * NEWS: Mention the new feature. * m4/jm-macros.m4 (coreutils_MACROS): Check for syncfs. * doc/coreutils.texi (sync invocation): Document the new feature. * src/sync.c: Include "quote.h". (AUTHORS): Include myself. (MODE_FILE, MODE_FILE_DATA, MODE_FILE_SYSTEM): New enum values. (long_options): Define. (usage): Describe that arguments are now accepted. (main): Add arguments parsing and add support for fsync(2), fdatasync(2) and syncfs(2). --- AUTHORS | 2 +- NEWS | 3 ++ doc/coreutils.texi | 20 ++++++++- m4/jm-macros.m4 | 1 + src/sync.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++++= ---- 5 files changed, 131 insertions(+), 11 deletions(-) diff --git a/AUTHORS b/AUTHORS index 0296830..64c11d7 100644 --- a/AUTHORS +++ b/AUTHORS @@ -83,7 +83,7 @@ stat: Michael Meskes stdbuf: P=C3=A1draig Brady stty: David MacKenzie sum: Kayvan Aghaiepour, David MacKenzie -sync: Jim Meyering +sync: Jim Meyering, Giuseppe Scrivano tac: Jay Lepreau, David MacKenzie tail: Paul Rubin, David MacKenzie, Ian Lance Taylor, Jim Meyering tee: Mike Parker, Richard M. Stallman, David MacKenzie diff --git a/NEWS b/NEWS index e0a2893..3d4190b 100644 --- a/NEWS +++ b/NEWS @@ -48,6 +48,9 @@ GNU coreutils NEWS -*-= outline -*- split accepts a new --separator option to select a record separator char= acter other than the default newline character. =20 + sync no longer ignores arguments and it uses fsync(2), fdatasync(2) + and syncfs(2) synchronization in addition to sync(2). + ** Changes in behavior =20 df no longer suppresses separate exports of the same remote device, as diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 5a3c31a..c99b8ed 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -12053,8 +12053,24 @@ crashes, data may be lost or the file system corru= pted as a result. The @command{sync} command ensures everything in memory is written to disk. =20 -Any arguments are ignored, except for a lone @option{--help} or -@option{--version} (@pxref{Common options}). +If any argument is specified then only the specified paths will be +synchronized. It uses internally the syscall fsync(2) on each of them. + +If at least one path is specified, it is possible to change the +synchronization policy with the following options. Also see +@ref{Common options}. + +@table @samp +@item --data +@opindex --data +Do not synchronize the file metadata unless it is required to maintain +data integrity. It uses the syscall fdatasync(2). + +@item --file-system +@opindex --file-system +Synchronize all the I/O waiting for the file system that contains the path. +It uses the syscall syncfs(2). +@end table =20 @exitstatus =20 diff --git a/m4/jm-macros.m4 b/m4/jm-macros.m4 index 58fdd97..79f124b 100644 --- a/m4/jm-macros.m4 +++ b/m4/jm-macros.m4 @@ -89,6 +89,7 @@ AC_DEFUN([coreutils_MACROS], sethostname siginterrupt sync + syncfs sysctl sysinfo tcgetpgrp diff --git a/src/sync.c b/src/sync.c index e9f4d7e..4a15d75 100644 --- a/src/sync.c +++ b/src/sync.c @@ -23,12 +23,30 @@ =20 #include "system.h" #include "error.h" -#include "long-options.h" +#include "quote.h" =20 /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "sync" =20 -#define AUTHORS proper_name ("Jim Meyering") +#define AUTHORS \ + proper_name ("Jim Meyering"), \ + proper_name ("Giuseppe Scrivano") + +enum +{ + MODE_FILE, + MODE_FILE_DATA, + MODE_FILE_SYSTEM +}; + +static struct option const long_options[] =3D +{ + {"data", no_argument, NULL, MODE_FILE_DATA}, + {"file-system", no_argument, NULL, MODE_FILE_SYSTEM}, + {GETOPT_HELP_OPTION_DECL}, + {GETOPT_VERSION_OPTION_DECL}, + {NULL, 0, NULL, 0} +}; =20 void usage (int status) @@ -37,11 +55,21 @@ usage (int status) emit_try_help (); else { - printf (_("Usage: %s [OPTION]\n"), program_name); + printf (_("Usage: %s [OPTION] [PATH]...\n"), program_name); fputs (_("\ Force changed blocks to disk, update the super block.\n\ \n\ +If one or more file paths are specified, sync only them,\n\ +use --data and --file-system to change the default behavior\n\ +\n\ +"), stdout); + + fputs (_("\ + --file-system sync the file systems that contain the path\n\ + --data flush the metadata only if needed later for\n\ + data retrieval to be correctly handled\n\ "), stdout); + fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); emit_ancillary_info (PROGRAM_NAME); @@ -52,6 +80,11 @@ Force changed blocks to disk, update the super block.\n\ int main (int argc, char **argv) { + bool args_specified; + int c; + int mode =3D MODE_FILE; + int (*sync_func)(int) =3D NULL; + initialize_main (&argc, &argv); set_program_name (argv[0]); setlocale (LC_ALL, ""); @@ -60,12 +93,79 @@ main (int argc, char **argv) =20 atexit (close_stdout); =20 - parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, Version, - usage, AUTHORS, (char const *) NULL); - if (getopt_long (argc, argv, "", NULL, NULL) !=3D -1) - usage (EXIT_FAILURE); + while ((c =3D getopt_long (argc, argv, "", long_options, NULL)) + !=3D -1) + { + switch (c) + { + case MODE_FILE_DATA: + mode =3D MODE_FILE_DATA; + break; + + case MODE_FILE_SYSTEM: + mode =3D MODE_FILE_SYSTEM; + break; + + case_GETOPT_HELP_CHAR; + + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + + default: + usage (EXIT_FAILURE); + } + } + + args_specified =3D optind < argc; + + if (! args_specified) + goto sync; + + if (!args_specified && mode !=3D MODE_FILE) + error (EXIT_FAILURE, errno, _("mode specified without any argument")); + + switch (mode) + { + case MODE_FILE_DATA: + sync_func =3D fdatasync; + break; + + case MODE_FILE: + sync_func =3D fsync; + break; +#if HAVE_SYNCFS + /* On systems where syncfs is not available, fallback to sync. */ + case MODE_FILE_SYSTEM: + sync_func =3D syncfs; + break; +#endif + default: + goto sync; + } + + while (optind < argc) + { + int fd =3D open (argv[optind], O_RDONLY); + if (fd < 0) + { + error (EXIT_FAILURE, errno, _("cannot open %s for reading"), + quote (argv[optind])); + } + + if (sync_func (fd) < 0) + error (EXIT_FAILURE, errno, _("syncing error")); + + if (close (fd) < 0) + { + error (EXIT_FAILURE, errno, _("failed to close %s"), + quote (argv[optind])); + } + + optind++; + } + return EXIT_SUCCESS; =20 - if (optind < argc) +sync: + if (args_specified) error (0, 0, _("ignoring all arguments")); =20 sync (); --=20 2.1.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 26 18:19:45 2015 Received: (at 19681) by debbugs.gnu.org; 26 Jan 2015 23:19:45 +0000 Received: from localhost ([127.0.0.1]:57393 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFswa-0001ow-HZ for submit@debbugs.gnu.org; Mon, 26 Jan 2015 18:19:45 -0500 Received: from mail6.vodafone.ie ([213.233.128.184]:41776) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFswX-0001oh-Nb for 19681@debbugs.gnu.org; Mon, 26 Jan 2015 18:19:43 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtwFADTLxlRtTt7D/2dsb2JhbABagwaBK4MAyTUCgRpDAQEBAQF9hAwBAQEDASMECwFGBQsLDQEDAwECAQICBRYLAgIJAwIBAgE9CAYNAQUCAQEWiAoMAb9NhWmOfgEBAQcBAQEBAQEBG4EhjiQzB4JogUEFlAiFHIU1hT+GMyKDbj4xgQQkgRoBAQE Received: from unknown (HELO localhost.localdomain) ([109.78.222.195]) by mail3.vodafone.ie with ESMTP; 26 Jan 2015 23:19:34 +0000 Message-ID: <54C6CB86.5000101@draigBrady.com> Date: Mon, 26 Jan 2015 23:19:34 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Giuseppe Scrivano Subject: Re: bug#19681: [PATCH] sync: use syncfs(2) if any argument is specified References: <54C46608.1030409@draigBrady.com> <1422190984-18157-1-git-send-email-gscrivan@redhat.com> <54C4EC0F.6010208@draigBrady.com> <54C50E03.3010106@cs.ucla.edu> <54C52AB8.20301@draigBrady.com> <54C53076.4060803@bernhard-voelker.de> <54C536BD.8000802@draigBrady.com> <877fwax7ka.fsf@redhat.com> <54C620F8.7070304@draigBrady.com> <87fvaxuta4.fsf@redhat.com> In-Reply-To: <87fvaxuta4.fsf@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19681 Cc: Bernhard Voelker , Eric Blake , 19681@debbugs.gnu.org, Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 26/01/15 21:27, Giuseppe Scrivano wrote: > PĆ”draig Brady writes: > >> On 26/01/15 08:36, Giuseppe Scrivano wrote: >>> PĆ”draig Brady writes: >>> >>>> On 25/01/15 18:05, Bernhard Voelker wrote: >>>>> On 01/25/2015 06:41 PM, PĆ”draig Brady wrote: >>>>>> So we have: fdatasync < fsync < syncfs < sync >>>>>> referring to:: file data, file data + metadata, file system, all file systems >>>>> >>>>>> [...] >>>>> >>>>>> I'd be incline to go with the _what_ interface above. >>>>> >>>>> Either way, I think it's important to document sync is falling back >>>>> to the bigger hammer if the smaller failed. >>>>> ... or shouldn't do sync this? >>>> >>>> It should fall back where possible. >>>> >>>> Now there is a difference between the file and file system(s) interfaces >>>> in that the former can return EIO error for example, while the latter >>>> are specified to always return success. You wouldn't fall back to >>>> a syncfs() if an fsync() gave an EIO for example. Also gnulib >>>> guarantees that fsync() and fdatasync() are available, so I wouldn't >>>> fallback from file -> file system interfaces, nor between file interfaces. >>> >>> one risk here is when multiple arguments are specified and the fsync >>> will return EIO more than once, we will fallback to syncfs multiple >>> times. Couldn't in this case a single sync be a better choice? >> >> I was saying we shouldn't fall back from fsync() to syncfs(). >> Just process each argument. Diagnose any errors and EXIT_FAILURE >> if there was any error? > > sorry for misunderstanding that. > > I've worked out a new version that includes these suggestions, also > since now the user can explicitly ask for the sync mechanism to use, I > agree with you and we should raise an error if something goes wrong. > > Since sync is completely different now, I took the freedom to add myself > to the AUTHORS, feel free to drop this part if you disagree. > > Regards, > Giuseppe > > > >>>From 0dbc5ce9c78bc97ec5a678803270767ad9980618 Mon Sep 17 00:00:00 2001 > From: Giuseppe Scrivano > Date: Sun, 25 Jan 2015 01:33:45 +0100 > Subject: [PATCH] sync: add support for fsync(2), fdatasync(2) and syncfs(2) > > * AUTHORS: Add myself to sync's authors. > * NEWS: Mention the new feature. > * m4/jm-macros.m4 (coreutils_MACROS): Check for syncfs. > * doc/coreutils.texi (sync invocation): Document the new feature. > * src/sync.c: Include "quote.h". > (AUTHORS): Include myself. > (MODE_FILE, MODE_FILE_DATA, MODE_FILE_SYSTEM): New enum values. > (long_options): Define. > (usage): Describe that arguments are now accepted. > (main): Add arguments parsing and add support for fsync(2), > fdatasync(2) and syncfs(2). > --- > AUTHORS | 2 +- > NEWS | 3 ++ > doc/coreutils.texi | 20 ++++++++- > m4/jm-macros.m4 | 1 + > src/sync.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++++---- > 5 files changed, 131 insertions(+), 11 deletions(-) > > diff --git a/AUTHORS b/AUTHORS > index 0296830..64c11d7 100644 > --- a/AUTHORS > +++ b/AUTHORS > @@ -83,7 +83,7 @@ stat: Michael Meskes > stdbuf: PĆ”draig Brady > stty: David MacKenzie > sum: Kayvan Aghaiepour, David MacKenzie > -sync: Jim Meyering > +sync: Jim Meyering, Giuseppe Scrivano > tac: Jay Lepreau, David MacKenzie > tail: Paul Rubin, David MacKenzie, Ian Lance Taylor, Jim Meyering > tee: Mike Parker, Richard M. Stallman, David MacKenzie > diff --git a/NEWS b/NEWS > index e0a2893..3d4190b 100644 > --- a/NEWS > +++ b/NEWS > @@ -48,6 +48,9 @@ GNU coreutils NEWS -*- outline -*- > split accepts a new --separator option to select a record separator character > other than the default newline character. > > + sync no longer ignores arguments and it uses fsync(2), fdatasync(2) > + and syncfs(2) synchronization in addition to sync(2). sync no longer ignores arguments, and syncs each specified file, or with the --file-system option, the file systems associated with each specified file. > ** Changes in behavior > > df no longer suppresses separate exports of the same remote device, as > diff --git a/doc/coreutils.texi b/doc/coreutils.texi > index 5a3c31a..c99b8ed 100644 > --- a/doc/coreutils.texi > +++ b/doc/coreutils.texi > @@ -12053,8 +12053,24 @@ crashes, data may be lost or the file system corrupted as a > result. The @command{sync} command ensures everything in memory > is written to disk. > > -Any arguments are ignored, except for a lone @option{--help} or > -@option{--version} (@pxref{Common options}). > +If any argument is specified then only the specified paths will be s/paths/files/. paths is a bit ambiguous, while files implies dirs too. > +synchronized. It uses internally the syscall fsync(2) on each of them. > + > +If at least one path is specified, it is possible to change the > +synchronization policy with the following options. Also see > +@ref{Common options}. > + > +@table @samp > +@item --data > +@opindex --data > +Do not synchronize the file metadata unless it is required to maintain > +data integrity. It uses the syscall fdatasync(2). > + > +@item --file-system > +@opindex --file-system > +Synchronize all the I/O waiting for the file system that contains the path. s/file system/file systems/ s/path/file/ > +It uses the syscall syncfs(2). > +@end table > > @exitstatus > > diff --git a/m4/jm-macros.m4 b/m4/jm-macros.m4 > index 58fdd97..79f124b 100644 > --- a/m4/jm-macros.m4 > +++ b/m4/jm-macros.m4 > @@ -89,6 +89,7 @@ AC_DEFUN([coreutils_MACROS], > sethostname > siginterrupt > sync > + syncfs > sysctl > sysinfo > tcgetpgrp > diff --git a/src/sync.c b/src/sync.c > index e9f4d7e..4a15d75 100644 > --- a/src/sync.c > +++ b/src/sync.c > @@ -23,12 +23,30 @@ > > #include "system.h" > #include "error.h" > -#include "long-options.h" > +#include "quote.h" > > /* The official name of this program (e.g., no 'g' prefix). */ > #define PROGRAM_NAME "sync" > > -#define AUTHORS proper_name ("Jim Meyering") > +#define AUTHORS \ > + proper_name ("Jim Meyering"), \ > + proper_name ("Giuseppe Scrivano") > + > +enum > +{ > + MODE_FILE, > + MODE_FILE_DATA, > + MODE_FILE_SYSTEM > +}; > + > +static struct option const long_options[] = > +{ > + {"data", no_argument, NULL, MODE_FILE_DATA}, > + {"file-system", no_argument, NULL, MODE_FILE_SYSTEM}, > + {GETOPT_HELP_OPTION_DECL}, > + {GETOPT_VERSION_OPTION_DECL}, > + {NULL, 0, NULL, 0} > +}; > > void > usage (int status) > @@ -37,11 +55,21 @@ usage (int status) > emit_try_help (); > else > { > - printf (_("Usage: %s [OPTION]\n"), program_name); > + printf (_("Usage: %s [OPTION] [PATH]...\n"), program_name); > fputs (_("\ > Force changed blocks to disk, update the super block.\n\ > \n\ > +If one or more file paths are specified, sync only them,\n\ > +use --data and --file-system to change the default behavior\n\ > +\n\ > +"), stdout); > + > + fputs (_("\ > + --file-system sync the file systems that contain the path\n\ > + --data flush the metadata only if needed later for\n\ s/flush/sync/ as flush has ambiguous connotations with discard rather than drain. > + data retrieval to be correctly handled\n\ > "), stdout); > + > fputs (HELP_OPTION_DESCRIPTION, stdout); > fputs (VERSION_OPTION_DESCRIPTION, stdout); > emit_ancillary_info (PROGRAM_NAME); > @@ -52,6 +80,11 @@ Force changed blocks to disk, update the super block.\n\ > int > main (int argc, char **argv) > { > + bool args_specified; > + int c; > + int mode = MODE_FILE; > + int (*sync_func)(int) = NULL; This assumes these are never function like macros. Probably OK, but it would be better to avoid that assumption about external functions. > + > initialize_main (&argc, &argv); > set_program_name (argv[0]); > setlocale (LC_ALL, ""); > @@ -60,12 +93,79 @@ main (int argc, char **argv) > > atexit (close_stdout); > > - parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, Version, > - usage, AUTHORS, (char const *) NULL); > - if (getopt_long (argc, argv, "", NULL, NULL) != -1) > - usage (EXIT_FAILURE); > + while ((c = getopt_long (argc, argv, "", long_options, NULL)) > + != -1) > + { > + switch (c) > + { > + case MODE_FILE_DATA: > + mode = MODE_FILE_DATA; > + break; > + > + case MODE_FILE_SYSTEM: > + mode = MODE_FILE_SYSTEM; > + break; > + > + case_GETOPT_HELP_CHAR; > + > + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); > + > + default: > + usage (EXIT_FAILURE); > + } > + } > + > + args_specified = optind < argc; > + > + if (! args_specified) > + goto sync; > + > + if (!args_specified && mode != MODE_FILE) > + error (EXIT_FAILURE, errno, _("mode specified without any argument")); That's a big aggressive. I'd allow --file-system with no args, as then --file-system means to sync the specified or all file systems. Requiring arguments with --data probably make sense. Another validation worth applying is to disallow --data with --file-system as they're invalid to specify together. > + > + switch (mode) > + { > + case MODE_FILE_DATA: > + sync_func = fdatasync; > + break; > + > + case MODE_FILE: > + sync_func = fsync; > + break; > +#if HAVE_SYNCFS > + /* On systems where syncfs is not available, fallback to sync. */ > + case MODE_FILE_SYSTEM: > + sync_func = syncfs; > + break; > +#endif > + default: > + goto sync; > + } > + I'd probably put the following loop body in a sync_arg() function returning a bool. > + while (optind < argc) > + { > + int fd = open (argv[optind], O_RDONLY); > + if (fd < 0) > + { > + error (EXIT_FAILURE, errno, _("cannot open %s for reading"), > + quote (argv[optind])); > + } > + > + if (sync_func (fd) < 0) > + error (EXIT_FAILURE, errno, _("syncing error")); > + > + if (close (fd) < 0) > + { > + error (EXIT_FAILURE, errno, _("failed to close %s"), > + quote (argv[optind])); > + } > + > + optind++; > + } It's probably better to register the failure and try subsequent arguments, as then it's ambiguous as to what is sync'd if you only get the warning about the first failure. > + return EXIT_SUCCESS; > > - if (optind < argc) There aren't any deep nestings here, so things could probably be reworked easily to avoid the goto. > +sync: > + if (args_specified) > error (0, 0, _("ignoring all arguments")); > > sync (); It's probably worth adding references to syncfs(2), fsync(2), and fdatasync(2) to man/sync.x thanks! PĆ”draig. From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 27 05:49:03 2015 Received: (at 19681) by debbugs.gnu.org; 27 Jan 2015 10:49:03 +0000 Received: from localhost ([127.0.0.1]:57524 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YG3he-0001vp-2U for submit@debbugs.gnu.org; Tue, 27 Jan 2015 05:49:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57584) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YG3ha-0001vR-Aa for 19681@debbugs.gnu.org; Tue, 27 Jan 2015 05:48:59 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0RAmmfj028919 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 27 Jan 2015 05:48:48 -0500 Received: from foobarbaz (vpn1-6-88.ams2.redhat.com [10.36.6.88]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0RAmiOK021040 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Tue, 27 Jan 2015 05:48:46 -0500 From: Giuseppe Scrivano To: =?utf-8?Q?P=C3=A1draig?= Brady Subject: Re: bug#19681: [PATCH] sync: use syncfs(2) if any argument is specified References: <54C46608.1030409@draigBrady.com> <1422190984-18157-1-git-send-email-gscrivan@redhat.com> <54C4EC0F.6010208@draigBrady.com> <54C50E03.3010106@cs.ucla.edu> <54C52AB8.20301@draigBrady.com> <54C53076.4060803@bernhard-voelker.de> <54C536BD.8000802@draigBrady.com> <877fwax7ka.fsf@redhat.com> <54C620F8.7070304@draigBrady.com> <87fvaxuta4.fsf@redhat.com> <54C6CB86.5000101@draigBrady.com> Date: Tue, 27 Jan 2015 11:48:44 +0100 In-Reply-To: <54C6CB86.5000101@draigBrady.com> (=?utf-8?Q?=22P=C3=A1draig?= Brady"'s message of "Mon, 26 Jan 2015 23:19:34 +0000") Message-ID: <871tmgv6r7.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 19681 Cc: Bernhard Voelker , Eric Blake , 19681@debbugs.gnu.org, Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) P=C3=A1draig Brady writes: > thanks! > P=C3=A1draig. Thanks for the review, I've amended the changes you suggested: >From b2babc9838b52892e2cdc46bc4590fa852daa0eb Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Sun, 25 Jan 2015 01:33:45 +0100 Subject: [PATCH] sync: add support for fsync(2), fdatasync(2) and syncfs(2) * AUTHORS: Add myself to sync's authors. * NEWS: Mention the new feature. * m4/jm-macros.m4 (coreutils_MACROS): Check for syncfs. * man/sync.x: Add references to syncfs, fsync and fdatasync. * doc/coreutils.texi (sync invocation): Document the new feature. * src/sync.c: Include "quote.h". (AUTHORS): Include myself. (MODE_FILE, MODE_DATA, MODE_FILE_SYSTEM, MODE_SYNC): New enum values. (long_options): Define. (sync_arg): New function. (usage): Describe that arguments are now accepted. (main): Add arguments parsing and add support for fsync(2), fdatasync(2) and syncfs(2). --- AUTHORS | 2 +- NEWS | 3 + doc/coreutils.texi | 20 ++++++- m4/jm-macros.m4 | 1 + man/sync.x | 2 +- src/sync.c | 157 +++++++++++++++++++++++++++++++++++++++++++++++++= ---- 6 files changed, 170 insertions(+), 15 deletions(-) diff --git a/AUTHORS b/AUTHORS index 0296830..64c11d7 100644 --- a/AUTHORS +++ b/AUTHORS @@ -83,7 +83,7 @@ stat: Michael Meskes stdbuf: P=C3=A1draig Brady stty: David MacKenzie sum: Kayvan Aghaiepour, David MacKenzie -sync: Jim Meyering +sync: Jim Meyering, Giuseppe Scrivano tac: Jay Lepreau, David MacKenzie tail: Paul Rubin, David MacKenzie, Ian Lance Taylor, Jim Meyering tee: Mike Parker, Richard M. Stallman, David MacKenzie diff --git a/NEWS b/NEWS index e0a2893..3d4190b 100644 --- a/NEWS +++ b/NEWS @@ -48,6 +48,9 @@ GNU coreutils NEWS -*-= outline -*- split accepts a new --separator option to select a record separator char= acter other than the default newline character. =20 + sync no longer ignores arguments and it uses fsync(2), fdatasync(2) + and syncfs(2) synchronization in addition to sync(2). + ** Changes in behavior =20 df no longer suppresses separate exports of the same remote device, as diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 5a3c31a..a1e664b 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -12053,8 +12053,24 @@ crashes, data may be lost or the file system corru= pted as a result. The @command{sync} command ensures everything in memory is written to disk. =20 -Any arguments are ignored, except for a lone @option{--help} or -@option{--version} (@pxref{Common options}). +If any argument is specified then only the specified files will be +synchronized. It uses internally the syscall fsync(2) on each of them. + +If at least one file is specified, it is possible to change the +synchronization policy with the following options. Also see +@ref{Common options}. + +@table @samp +@item --data +@opindex --data +Do not synchronize the file metadata unless it is required to maintain +data integrity. It uses the syscall fdatasync(2). + +@item --file-system +@opindex --file-system +Synchronize all the I/O waiting for the file systems that contain the file. +It uses the syscall syncfs(2). +@end table =20 @exitstatus =20 diff --git a/m4/jm-macros.m4 b/m4/jm-macros.m4 index 58fdd97..79f124b 100644 --- a/m4/jm-macros.m4 +++ b/m4/jm-macros.m4 @@ -89,6 +89,7 @@ AC_DEFUN([coreutils_MACROS], sethostname siginterrupt sync + syncfs sysctl sysinfo tcgetpgrp diff --git a/man/sync.x b/man/sync.x index 7947bb7..6ced07e 100644 --- a/man/sync.x +++ b/man/sync.x @@ -3,4 +3,4 @@ sync \- flush file system buffers [DESCRIPTION] .\" Add any additional description here [SEE ALSO] -sync(2) +fdatasync(2), fsync(2), sync(2), syncfs(2) diff --git a/src/sync.c b/src/sync.c index e9f4d7e..6c4d571 100644 --- a/src/sync.c +++ b/src/sync.c @@ -23,12 +23,31 @@ =20 #include "system.h" #include "error.h" -#include "long-options.h" +#include "quote.h" =20 /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "sync" =20 -#define AUTHORS proper_name ("Jim Meyering") +#define AUTHORS \ + proper_name ("Jim Meyering"), \ + proper_name ("Giuseppe Scrivano") + +enum +{ + MODE_FILE, + MODE_DATA, + MODE_FILE_SYSTEM, + MODE_SYNC +}; + +static struct option const long_options[] =3D +{ + {"data", no_argument, NULL, MODE_DATA}, + {"file-system", no_argument, NULL, MODE_FILE_SYSTEM}, + {GETOPT_HELP_OPTION_DECL}, + {GETOPT_VERSION_OPTION_DECL}, + {NULL, 0, NULL, 0} +}; =20 void usage (int status) @@ -37,11 +56,21 @@ usage (int status) emit_try_help (); else { - printf (_("Usage: %s [OPTION]\n"), program_name); + printf (_("Usage: %s [OPTION] [PATH]...\n"), program_name); fputs (_("\ Force changed blocks to disk, update the super block.\n\ \n\ +If one or more file paths are specified, sync only them,\n\ +use --data and --file-system to change the default behavior\n\ +\n\ "), stdout); + + fputs (_("\ + --file-system sync the file systems that contain the path\n\ + --data flush the metadata only if needed later for\n\ + data retrieval to be correctly handled\n\ +"), stdout); + fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); emit_ancillary_info (PROGRAM_NAME); @@ -49,9 +78,61 @@ Force changed blocks to disk, update the super block.\n\ exit (status); } =20 +static bool +sync_arg (int mode, char *file) +{ + int ret =3D -1; + int fd =3D open (file, O_RDONLY); + if (fd < 0) + { + error (0, errno, _("cannot open %s for reading"), quote (file)); + return false; + } + + switch (mode) + { + case MODE_FILE: + ret =3D fsync (fd); + break; + + case MODE_DATA: + ret =3D fdatasync (fd); + break; + +#if HAVE_SYNCFS + case MODE_FILE_SYSTEM: + ret =3D syncfs (fd); + break; +#endif + + default: + error (EXIT_FAILURE, errno, _("invalid mode specified")); + break; + } + + if (ret < 0) + { + error (0, errno, _("syncing error")); + return false; + } + + if (close (fd) < 0) + { + error (0, errno, _("failed to close %s"), quote (file)); + return false; + } + + return true; +} + int main (int argc, char **argv) { + bool args_specified; + int c, ret; + bool arg_data =3D false, arg_file_system =3D false; + int mode; + initialize_main (&argc, &argv); set_program_name (argv[0]); setlocale (LC_ALL, ""); @@ -60,14 +141,68 @@ main (int argc, char **argv) =20 atexit (close_stdout); =20 - parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, Version, - usage, AUTHORS, (char const *) NULL); - if (getopt_long (argc, argv, "", NULL, NULL) !=3D -1) - usage (EXIT_FAILURE); + while ((c =3D getopt_long (argc, argv, "", long_options, NULL)) + !=3D -1) + { + switch (c) + { + case MODE_DATA: + arg_data =3D true; + break; + + case MODE_FILE_SYSTEM: + arg_file_system =3D true; + break; + + case_GETOPT_HELP_CHAR; + + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + + default: + usage (EXIT_FAILURE); + } + } + + args_specified =3D optind < argc; + + if (arg_data && arg_file_system) + { + error (EXIT_FAILURE, errno, + _("cannot specify both --data and --file-system")); + } + + if (!args_specified && arg_data) + error (EXIT_FAILURE, errno, _("--data needs at least one argument")); + + if (arg_data) + mode =3D MODE_DATA; + else if (! arg_file_system) + { + mode =3D args_specified ? MODE_FILE : MODE_SYNC; + } + else + { + /* On systems where syncfs is not available, or if no args are speci= fied, + fallback to sync. */ + if (HAVE_SYNCFS && args_specified) + mode =3D MODE_FILE_SYSTEM; + else + { + mode =3D MODE_SYNC; + } + } =20 - if (optind < argc) - error (0, 0, _("ignoring all arguments")); + if (mode =3D=3D MODE_SYNC) + { + sync (); + return EXIT_SUCCESS; + } =20 - sync (); - return EXIT_SUCCESS; + ret =3D EXIT_SUCCESS; + for (; optind < argc; optind++) + { + if (! sync_arg (mode, argv[optind])) + ret =3D EXIT_FAILURE; + } + return ret; } --=20 2.1.0 From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 27 09:58:58 2015 Received: (at 19681) by debbugs.gnu.org; 27 Jan 2015 14:58:58 +0000 Received: from localhost ([127.0.0.1]:58085 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YG7bU-0001CY-Qd for submit@debbugs.gnu.org; Tue, 27 Jan 2015 09:58:57 -0500 Received: from mail1.vodafone.ie ([213.233.128.43]:49664) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YG7bQ-0001C6-NV for 19681@debbugs.gnu.org; Tue, 27 Jan 2015 09:58:55 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: At0FAEinx1RtTdKd/2dsb2JhbABagwZSWYMAw1eFdQKBJUMBAQEBAX2EDAEBAQQjJDIQCw0BAwMBAgEJIQICDwI+CAYNAQUCAQEFEYgWAb9PhRZTjwsBAQEBAQUBAQEBAQEBAQEZjyAPOBEHCYJfgUEFjk2BdIEpT4ZrNoR/hT9AgjaDPSKDbj4xgQIBH4EgAQEB Received: from unknown (HELO localhost.localdomain) ([109.77.210.157]) by mail1.vodafone.ie with ESMTP; 27 Jan 2015 14:58:45 +0000 Message-ID: <54C7A7A4.30501@draigBrady.com> Date: Tue, 27 Jan 2015 14:58:44 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Giuseppe Scrivano Subject: Re: bug#19681: [PATCH] sync: use syncfs(2) if any argument is specified References: <54C46608.1030409@draigBrady.com> <1422190984-18157-1-git-send-email-gscrivan@redhat.com> <54C4EC0F.6010208@draigBrady.com> <54C50E03.3010106@cs.ucla.edu> <54C52AB8.20301@draigBrady.com> <54C53076.4060803@bernhard-voelker.de> <54C536BD.8000802@draigBrady.com> <877fwax7ka.fsf@redhat.com> <54C620F8.7070304@draigBrady.com> <87fvaxuta4.fsf@redhat.com> <54C6CB86.5000101@draigBrady.com> <871tmgv6r7.fsf@redhat.com> In-Reply-To: <871tmgv6r7.fsf@redhat.com> Content-Type: multipart/mixed; boundary="------------030909060906090307090403" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19681 Cc: 19681@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------030909060906090307090403 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 27/01/15 10:48, Giuseppe Scrivano wrote: > PĆ”draig Brady writes: > >> thanks! >> PĆ”draig. > > Thanks for the review, I've amended the changes you suggested: There were a few problems: - Compile failure without HAVE_SYNCFS (defined) - Various errors() used errno where undefined - A file that failed to sync was not identified - File descriptors were leaked on failure to sync - The command would block if presented with a fifo - Write only files ere not supported - Various references to "paths" rather than "files" - The info docs for --file-system were a bit terse - No tests I've fixed up those issues in the attached, which I'll push soon. thanks, PĆ”draig. --------------030909060906090307090403 Content-Type: text/x-patch; name="sync-args.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="sync-args.patch" >From 12c6f0fd7f44133a2af8950c69b2bfa46ea5d3a4 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Sun, 25 Jan 2015 01:33:45 +0100 Subject: [PATCH] sync: support syncing specified arguments * AUTHORS: Add myself to sync's authors. * NEWS: Mention the new feature. * m4/jm-macros.m4 (coreutils_MACROS): Check for syncfs(). * man/sync.x: Add references to syncfs, fsync and fdatasync. * doc/coreutils.texi (sync invocation): Document the new feature. * src/sync.c: Include "quote.h". (AUTHORS): Include myself. (MODE_FILE, MODE_DATA, MODE_FILE_SYSTEM, MODE_SYNC): New enum values. (long_options): Define. (sync_arg): New function. (usage): Describe that arguments are now accepted. (main): Add arguments parsing and add support for fsync(2), fdatasync(2) and syncfs(2). --- AUTHORS | 2 +- NEWS | 3 + doc/coreutils.texi | 34 +++++++++-- m4/jm-macros.m4 | 1 + man/sync.x | 2 +- src/sync.c | 169 +++++++++++++++++++++++++++++++++++++++++++++++++---- tests/local.mk | 1 + tests/misc/sync.sh | 43 ++++++++++++++ 8 files changed, 236 insertions(+), 19 deletions(-) create mode 100755 tests/misc/sync.sh diff --git a/AUTHORS b/AUTHORS index 0296830..64c11d7 100644 --- a/AUTHORS +++ b/AUTHORS @@ -83,7 +83,7 @@ stat: Michael Meskes stdbuf: PĆ”draig Brady stty: David MacKenzie sum: Kayvan Aghaiepour, David MacKenzie -sync: Jim Meyering +sync: Jim Meyering, Giuseppe Scrivano tac: Jay Lepreau, David MacKenzie tail: Paul Rubin, David MacKenzie, Ian Lance Taylor, Jim Meyering tee: Mike Parker, Richard M. Stallman, David MacKenzie diff --git a/NEWS b/NEWS index 73314d7..b3641ca 100644 --- a/NEWS +++ b/NEWS @@ -51,6 +51,9 @@ GNU coreutils NEWS -*- outline -*- stty allows setting the "extproc" option where supported, which is a useful setting with high latency links. + sync no longer ignores arguments, and syncs each specified file, or with the + --file-system option, the file systems associated with each specified file. + ** Changes in behavior df no longer suppresses separate exports of the same remote device, as diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 4a15939..7e62bde 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -12043,18 +12043,40 @@ with @env{TZ}, libc, The GNU C Library Reference Manual}. @command{sync} writes any data buffered in memory out to disk. This can include (but is not limited to) modified superblocks, modified inodes, and delayed reads and writes. This must be implemented by the kernel; -The @command{sync} program does nothing but exercise the @code{sync} system -call. +The @command{sync} program does nothing but exercise the @code{sync}, +@code{syncfs}, @code{fsync}, and @code{fdatasync} system calls. @cindex crashes and corruption The kernel keeps data in memory to avoid doing (relatively slow) disk reads and writes. This improves performance, but if the computer crashes, data may be lost or the file system corrupted as a -result. The @command{sync} command ensures everything in memory -is written to disk. +result. The @command{sync} command instructs the kernel to write +data in memory to persistent storage. -Any arguments are ignored, except for a lone @option{--help} or -@option{--version} (@pxref{Common options}). +If any argument is specified then only those files will be +synchronized using the fsync(2) syscall by default. + +If at least one file is specified, it is possible to change the +synchronization method with the following options. Also see +@ref{Common options}. + +@table @samp +@item --data +@opindex --data +Use fdatasync(2) to sync only the data for the file, +and any metadata required to maintain file system consistency. + +@item --file-system +@opindex --file-system +Synchronize all the I/O waiting for the file systems that contain the file, +using the syscall syncfs(2). Note you would usually @emph{not} specify +this option if passing a device node like @samp{/dev/sda} for example, +as that would sync the containing file system rather than the referenced one. +Note also that depending on the system, passing individual device nodes or files +may have different sync characteristics than using no arguments. +I.E. arguments passed to fsync(2) may provide greater guarantees through +write barriers, than a global sync(2) used when no arguments are provided. +@end table @exitstatus diff --git a/m4/jm-macros.m4 b/m4/jm-macros.m4 index 58fdd97..79f124b 100644 --- a/m4/jm-macros.m4 +++ b/m4/jm-macros.m4 @@ -89,6 +89,7 @@ AC_DEFUN([coreutils_MACROS], sethostname siginterrupt sync + syncfs sysctl sysinfo tcgetpgrp diff --git a/man/sync.x b/man/sync.x index 7947bb7..6ced07e 100644 --- a/man/sync.x +++ b/man/sync.x @@ -3,4 +3,4 @@ sync \- flush file system buffers [DESCRIPTION] .\" Add any additional description here [SEE ALSO] -sync(2) +fdatasync(2), fsync(2), sync(2), syncfs(2) diff --git a/src/sync.c b/src/sync.c index e9f4d7e..80d1403 100644 --- a/src/sync.c +++ b/src/sync.c @@ -17,18 +17,42 @@ /* Written by Jim Meyering */ #include +#include #include #include #include #include "system.h" #include "error.h" -#include "long-options.h" +#include "quote.h" /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "sync" -#define AUTHORS proper_name ("Jim Meyering") +#define AUTHORS \ + proper_name ("Jim Meyering"), \ + proper_name ("Giuseppe Scrivano") + +#ifndef HAVE_SYNCFS +# define HAVE_SYNCFS 0 +#endif + +enum sync_mode +{ + MODE_FILE, + MODE_DATA, + MODE_FILE_SYSTEM, + MODE_SYNC +}; + +static struct option const long_options[] = +{ + {"data", no_argument, NULL, MODE_DATA}, + {"file-system", no_argument, NULL, MODE_FILE_SYSTEM}, + {GETOPT_HELP_OPTION_DECL}, + {GETOPT_VERSION_OPTION_DECL}, + {NULL, 0, NULL, 0} +}; void usage (int status) @@ -37,11 +61,20 @@ usage (int status) emit_try_help (); else { - printf (_("Usage: %s [OPTION]\n"), program_name); + printf (_("Usage: %s [OPTION] [FILE]...\n"), program_name); fputs (_("\ Force changed blocks to disk, update the super block.\n\ \n\ +If one or more file paths are specified, sync only them,\n\ +use --data and --file-system to change the default behavior\n\ +\n\ "), stdout); + + fputs (_("\ + --file-system sync the file systems that contain the files\n\ + --data only sync data for files, no unneeded metadata\n\ +"), stdout); + fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); emit_ancillary_info (PROGRAM_NAME); @@ -49,9 +82,82 @@ Force changed blocks to disk, update the super block.\n\ exit (status); } +/* Sync the specified FILE, or file systems associated with FILE. + Return 1 on success. */ + +static bool +sync_arg (enum sync_mode mode, char const *file) +{ + bool ret = true; + int fd; + + /* Note O_PATH is not currently supported with the sync routines. */ + if ((fd = open (file, O_RDONLY | O_NONBLOCK)) < 0 + && (fd = open (file, O_WRONLY | O_NONBLOCK)) < 0) + { + error (0, errno, _("error opening %s"), quote (file)); + return false; + } + + /* We used O_NONBLOCK above to not hang with fifos, + so reset that here. */ + int fdflags; + if ((fdflags = fcntl (fd, F_GETFL)) == -1 + || fcntl (fd, F_SETFL, fdflags & ~O_NONBLOCK) < 0) + { + error (0, errno, _("couldn't reset non-blocking mode %s"), quote (file)); + ret = false; + } + + if (ret == true) + { + int sync_status; + + switch (mode) + { + case MODE_DATA: + sync_status = fdatasync (fd); + break; + + case MODE_FILE: + sync_status = fsync (fd); + break; + +#if HAVE_SYNCFS + case MODE_FILE_SYSTEM: + sync_status = syncfs (fd); + break; +#endif + + default: + assert ("invalid sync_mode"); + } + + if (sync_status < 0) + { + error (0, errno, _("error syncing %s"), quote (file)); + ret = false; + } + } + + if (close (fd) < 0) + { + error (0, errno, _("failed to close %s"), quote (file)); + ret = false; + } + + return ret; +} + int main (int argc, char **argv) { + int c; + bool args_specified; + bool arg_data = false, arg_file_system = false; + enum sync_mode mode; + bool ok = true; + initialize_main (&argc, &argv); set_program_name (argv[0]); setlocale (LC_ALL, ""); @@ -60,14 +166,55 @@ main (int argc, char **argv) atexit (close_stdout); - parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, Version, - usage, AUTHORS, (char const *) NULL); - if (getopt_long (argc, argv, "", NULL, NULL) != -1) - usage (EXIT_FAILURE); + while ((c = getopt_long (argc, argv, "", long_options, NULL)) + != -1) + { + switch (c) + { + case MODE_DATA: + arg_data = true; + break; + + case MODE_FILE_SYSTEM: + arg_file_system = true; + break; + + case_GETOPT_HELP_CHAR; + + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - if (optind < argc) - error (0, 0, _("ignoring all arguments")); + default: + usage (EXIT_FAILURE); + } + } + + args_specified = optind < argc; + + if (arg_data && arg_file_system) + { + error (EXIT_FAILURE, 0, + _("cannot specify both --data and --file-system")); + } + + if (!args_specified && arg_data) + error (EXIT_FAILURE, 0, _("--data needs at least one argument")); + + if (! args_specified || (arg_file_system && ! HAVE_SYNCFS)) + mode = MODE_SYNC; + else if (arg_file_system) + mode = MODE_FILE_SYSTEM; + else if (! arg_data) + mode = MODE_FILE; + else + mode = MODE_DATA; + + if (mode == MODE_SYNC) + sync (); + else + { + for (; optind < argc; optind++) + ok &= sync_arg (mode, argv[optind]); + } - sync (); - return EXIT_SUCCESS; + return ok ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/local.mk b/tests/local.mk index 5dcbd55..bfa447c 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -375,6 +375,7 @@ all_tests = \ tests/misc/stty-row-col.sh \ tests/misc/sum.pl \ tests/misc/sum-sysv.sh \ + tests/misc/sync.sh \ tests/misc/tac.pl \ tests/misc/tac-continue.sh \ tests/misc/tac-2-nonseekable.sh \ diff --git a/tests/misc/sync.sh b/tests/misc/sync.sh new file mode 100755 index 0000000..8b0caf4 --- /dev/null +++ b/tests/misc/sync.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# Test various sync(1) operations + +# Copyright (C) 2015 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ sync + +touch file + +# fdatasync+syncfs is nonsensical +returns_ 1 sync --data --file-system || fail=1 + +# fdatasync needs an operand +returns_ 1 sync --data || fail=1 + +# Test syncing of file (fsync) (little side effects) +sync file || fail=1 + +# Ensure multiple args are processed and diagnosed +returns_ 1 sync file nofile || fail=1 + +if test "$fail" != '1'; then + # Ensure a fifo doesn't block + mkfifo_or_skip_ fifo + timeout 10 sync fifo + test $? = 124 && fail=1 +fi + +Exit $fail -- 2.1.0 --------------030909060906090307090403-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 28 03:18:13 2015 Received: (at 19681) by debbugs.gnu.org; 28 Jan 2015 08:18:13 +0000 Received: from localhost ([127.0.0.1]:58434 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YGNpF-0001zz-6f for submit@debbugs.gnu.org; Wed, 28 Jan 2015 03:18:13 -0500 Received: from mout.kundenserver.de ([212.227.17.24]:49259) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YGNpD-0001zm-Ew for 19681@debbugs.gnu.org; Wed, 28 Jan 2015 03:18:12 -0500 Received: from [192.168.1.10] ([84.175.81.114]) by mrelayeu.kundenserver.de (mreue101) with ESMTPSA (Nemesis) id 0Lb1mj-1Xnwop0k3t-00kfqz; Wed, 28 Jan 2015 09:17:58 +0100 Message-ID: <54C89B33.8040201@bernhard-voelker.de> Date: Wed, 28 Jan 2015 09:17:55 +0100 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= , Giuseppe Scrivano Subject: Re: bug#19681: [PATCH] sync: use syncfs(2) if any argument is specified References: <54C46608.1030409@draigBrady.com> <1422190984-18157-1-git-send-email-gscrivan@redhat.com> <54C4EC0F.6010208@draigBrady.com> <54C50E03.3010106@cs.ucla.edu> <54C52AB8.20301@draigBrady.com> <54C53076.4060803@bernhard-voelker.de> <54C536BD.8000802@draigBrady.com> <877fwax7ka.fsf@redhat.com> <54C620F8.7070304@draigBrady.com> <87fvaxuta4.fsf@redhat.com> <54C6CB86.5000101@draigBrady.com> <871tmgv6r7.fsf@redhat.com> <54C7A7A4.30501@draigBrady.com> In-Reply-To: <54C7A7A4.30501@draigBrady.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:xLs8gcNiYpzipxyv0SZAwuTV3//QTiev/v97zTdKAyXjAzVHrUq E423zkMgK9c/CftSaA6WugwPoQYVXaoEEoh4YW3vJujKSGgjVX6ReZXwr1MeFKWjnv/vfH6 8zfiEdMHnH7pmwTOE0UmvYhJ8TqhPwbnK86fQaRq567UwciDNqWqSd4sEZyGgnvHyGJB0zv igZFLGTdPqqIrwykil5Gw== X-UI-Out-Filterresults: notjunk:1; X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19681 Cc: 19681@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 01/27/2015 03:58 PM, PĆ”draig Brady wrote: > From 12c6f0fd7f44133a2af8950c69b2bfa46ea5d3a4 Mon Sep 17 00:00:00 2001 > From: Giuseppe Scrivano > Date: Sun, 25 Jan 2015 01:33:45 +0100 > Subject: [PATCH] sync: support syncing specified arguments > --- a/doc/coreutils.texi > +++ b/doc/coreutils.texi > @@ -12043,18 +12043,40 @@ with @env{TZ}, libc, The GNU C Library Reference Manual}. > @command{sync} writes any data buffered in memory out to disk. This can > include (but is not limited to) modified superblocks, modified inodes, > and delayed reads and writes. This must be implemented by the kernel; > -The @command{sync} program does nothing but exercise the @code{sync} system > -call. > +The @command{sync} program does nothing but exercise the @code{sync}, > +@code{syncfs}, @code{fsync}, and @code{fdatasync} system calls. I think sync's info page now deserves a "Synopsis" line ... as the command now takes more than just --help/--version. Maybe the first line of 'man sync' sync - flush file system buffers and 'info sync' "synchronize memory and disk" (in the parent table), and "sync data on disk with memory" (sync invocation) should be harmonized, too? > diff --git a/src/sync.c b/src/sync.c > index e9f4d7e..80d1403 100644 > --- a/src/sync.c > +++ b/src/sync.c > @@ -37,11 +61,20 @@ usage (int status) > emit_try_help (); > else > { > - printf (_("Usage: %s [OPTION]\n"), program_name); > + printf (_("Usage: %s [OPTION] [FILE]...\n"), program_name); > fputs (_("\ > Force changed blocks to disk, update the super block.\n\ > \n\ > +If one or more file paths are specified, sync only them,\n\ > +use --data and --file-system to change the default behavior\n\ > +\n\ > "), stdout); > + > + fputs (_("\ > + --file-system sync the file systems that contain the files\n\ > + --data only sync data for files, no unneeded metadata\n\ > +"), stdout); > + '--d' should go before '--f'. And shouldn't we also be more translator-friendly, and split the 2 options into 2 fputs calls? The rest of the patch including the test almost LGTM: when running against a non-accessible directory, then the correct error diagnostic ("permission denied") is eclipsed by a non-descriptive diagnostic: $ src/sync --file /tmp /root src/sync: error opening ā€˜/root’: Is a directory strace output of the above: open("/root", O_RDONLY|O_NONBLOCK) = -1 EACCES (Permission denied) open("/root", O_WRONLY|O_NONBLOCK) = -1 EISDIR (Is a directory) Please note that syncfs() for the /tmp argument succeeded correctly. For completeness, here is the correct case with a good error diagnostic for an inaccessible file: $ src/sync --file /root/.bashrc src/sync: error opening ā€˜/root/.bashrc’: Permission denied Thanks & have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 28 05:20:12 2015 Received: (at 19681) by debbugs.gnu.org; 28 Jan 2015 10:20:12 +0000 Received: from localhost ([127.0.0.1]:58498 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YGPjG-0004zt-Tt for submit@debbugs.gnu.org; Wed, 28 Jan 2015 05:20:12 -0500 Received: from mail1.vodafone.ie ([213.233.128.43]:12968) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YGPjC-0004zG-LS for 19681@debbugs.gnu.org; Wed, 28 Jan 2015 05:20:09 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhgKAOi2yFRtTRd4/2dsb2JhbABagwZSWYMAww2FcgECAoEXQwEBAQEBfYQMAQEBAwEjVgULCw0BAwMBAgEJFgsCAgkDAgECAT0IBgEMAQUCAQEFEYgKDAG/dYVpjzcBAQEBAQEBAwEBAQEBAQEBAQEBF48gDzgMBQcJgl+BQQWNDYFAgXSBKU+GazaEf4U/QII2gz0ig24+MYECAR+BIAEBAQ Received: from unknown (HELO localhost.localdomain) ([109.77.23.120]) by mail1.vodafone.ie with ESMTP; 28 Jan 2015 10:19:59 +0000 Message-ID: <54C8B7CF.9060307@draigBrady.com> Date: Wed, 28 Jan 2015 10:19:59 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Bernhard Voelker , Giuseppe Scrivano Subject: Re: bug#19681: [PATCH] sync: use syncfs(2) if any argument is specified References: <54C46608.1030409@draigBrady.com> <1422190984-18157-1-git-send-email-gscrivan@redhat.com> <54C4EC0F.6010208@draigBrady.com> <54C50E03.3010106@cs.ucla.edu> <54C52AB8.20301@draigBrady.com> <54C53076.4060803@bernhard-voelker.de> <54C536BD.8000802@draigBrady.com> <877fwax7ka.fsf@redhat.com> <54C620F8.7070304@draigBrady.com> <87fvaxuta4.fsf@redhat.com> <54C6CB86.5000101@draigBrady.com> <871tmgv6r7.fsf@redhat.com> <54C7A7A4.30501@draigBrady.com> <54C89B33.8040201@bernhard-voelker.de> In-Reply-To: <54C89B33.8040201@bernhard-voelker.de> Content-Type: multipart/mixed; boundary="------------000307010203040204080106" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19681 Cc: 19681@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------000307010203040204080106 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 28/01/15 08:17, Bernhard Voelker wrote: > On 01/27/2015 03:58 PM, PĆ”draig Brady wrote: >> From 12c6f0fd7f44133a2af8950c69b2bfa46ea5d3a4 Mon Sep 17 00:00:00 2001 >> From: Giuseppe Scrivano >> Date: Sun, 25 Jan 2015 01:33:45 +0100 >> Subject: [PATCH] sync: support syncing specified arguments > >> --- a/doc/coreutils.texi >> +++ b/doc/coreutils.texi >> @@ -12043,18 +12043,40 @@ with @env{TZ}, libc, The GNU C Library Reference Manual}. >> @command{sync} writes any data buffered in memory out to disk. This can >> include (but is not limited to) modified superblocks, modified inodes, >> and delayed reads and writes. This must be implemented by the kernel; >> -The @command{sync} program does nothing but exercise the @code{sync} system >> -call. >> +The @command{sync} program does nothing but exercise the @code{sync}, >> +@code{syncfs}, @code{fsync}, and @code{fdatasync} system calls. > > I think sync's info page now deserves a "Synopsis" line ... as the command > now takes more than just --help/--version. Done. > Maybe the first line of 'man sync' > > sync - flush file system buffers > > and 'info sync' > > "synchronize memory and disk" (in the parent table), and > "sync data on disk with memory" (sync invocation) > > should be harmonized, too? Good point. I went with this summary everywhere: "Synchronize cached writes to persistent storage" >> diff --git a/src/sync.c b/src/sync.c >> index e9f4d7e..80d1403 100644 >> --- a/src/sync.c >> +++ b/src/sync.c > >> @@ -37,11 +61,20 @@ usage (int status) >> emit_try_help (); >> else >> { >> - printf (_("Usage: %s [OPTION]\n"), program_name); >> + printf (_("Usage: %s [OPTION] [FILE]...\n"), program_name); >> fputs (_("\ >> Force changed blocks to disk, update the super block.\n\ >> \n\ >> +If one or more file paths are specified, sync only them,\n\ >> +use --data and --file-system to change the default behavior\n\ >> +\n\ >> "), stdout); >> + >> + fputs (_("\ >> + --file-system sync the file systems that contain the files\n\ >> + --data only sync data for files, no unneeded metadata\n\ >> +"), stdout); >> + > > '--d' should go before '--f'. > > And shouldn't we also be more translator-friendly, and split the > 2 options into 2 fputs calls? Good point. also the spacing was off. Also I added short options to to align with -f, --file-system in stat(1). If this ever was to be standardised, or used in other systems short options would be used, so we might as well give some precedence here to ease compat. > The rest of the patch including the test almost LGTM: > when running against a non-accessible directory, then the correct error > diagnostic ("permission denied") is eclipsed by a non-descriptive > diagnostic: > > $ src/sync --file /tmp /root > src/sync: error opening ā€˜/root’: Is a directory > > strace output of the above: > > open("/root", O_RDONLY|O_NONBLOCK) = -1 EACCES (Permission denied) > open("/root", O_WRONLY|O_NONBLOCK) = -1 EISDIR (Is a directory) Good catch! I've gone with always reporting the first errno. thanks again for the excellent review. Latest is attached. PĆ”draig. --------------000307010203040204080106 Content-Type: text/x-patch; name="sync-args.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="sync-args.patch" =46rom 2caa949db1fc16d1bdcf547d65001a0e430a2b27 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Sun, 25 Jan 2015 01:33:45 +0100 Subject: [PATCH] sync: support syncing specified arguments * m4/jm-macros.m4 (coreutils_MACROS): Check for syncfs(). * man/sync.x: Add references to syncfs, fsync and fdatasync. * doc/coreutils.texi (sync invocation): Document the new feature. * src/sync.c: Include "quote.h". (AUTHORS): Include myself. (MODE_FILE, MODE_DATA, MODE_FILE_SYSTEM, MODE_SYNC): New enum values. (long_options): Define. (sync_arg): New function. (usage): Describe that arguments are now accepted. (main): Add arguments parsing and add support for fsync(2), fdatasync(2) and syncfs(2). * tests/misc/sync.sh: New (and only) test for sync. * tests/local.mk: Reference the new test. * AUTHORS: Add myself to sync's authors. * NEWS: Mention the new feature. --- AUTHORS | 2 +- NEWS | 3 + doc/coreutils.texi | 52 +++++++++++++--- m4/jm-macros.m4 | 1 + man/sync.x | 4 +- src/sync.c | 177 +++++++++++++++++++++++++++++++++++++++++++++++= ++---- tests/local.mk | 1 + tests/misc/sync.sh | 43 +++++++++++++ 8 files changed, 258 insertions(+), 25 deletions(-) create mode 100755 tests/misc/sync.sh diff --git a/AUTHORS b/AUTHORS index 0296830..64c11d7 100644 --- a/AUTHORS +++ b/AUTHORS @@ -83,7 +83,7 @@ stat: Michael Meskes stdbuf: P=C3=A1draig Brady stty: David MacKenzie sum: Kayvan Aghaiepour, David MacKenzie -sync: Jim Meyering +sync: Jim Meyering, Giuseppe Scrivano tac: Jay Lepreau, David MacKenzie tail: Paul Rubin, David MacKenzie, Ian Lance Taylor, Jim Meyering tee: Mike Parker, Richard M. Stallman, David MacKenzie diff --git a/NEWS b/NEWS index 73314d7..b3641ca 100644 --- a/NEWS +++ b/NEWS @@ -51,6 +51,9 @@ GNU coreutils NEWS -= *- outline -*- stty allows setting the "extproc" option where supported, which is a useful setting with high latency links. =20 + sync no longer ignores arguments, and syncs each specified file, or wi= th the + --file-system option, the file systems associated with each specified = file. + ** Changes in behavior =20 df no longer suppresses separate exports of the same remote device, as= diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 4a15939..99c7df3 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -114,7 +114,7 @@ * stdbuf: (coreutils)stdbuf invocation. Modify stdio buffering. * stty: (coreutils)stty invocation. Print/change terminal se= ttings. * sum: (coreutils)sum invocation. Print traditional checks= um. -* sync: (coreutils)sync invocation. Synchronize memory and d= isk. +* sync: (coreutils)sync invocation. Synchronize memory to di= sk. * tac: (coreutils)tac invocation. Reverse files. * tail: (coreutils)tail invocation. Output the last part of = files. * tee: (coreutils)tee invocation. Redirect to multiple fil= es. @@ -346,7 +346,7 @@ Disk usage * df invocation:: Report file system disk space usage * du invocation:: Estimate file space usage * stat invocation:: Report file or file system status -* sync invocation:: Synchronize data on disk with memory +* sync invocation:: Synchronize cached writes to persistent= storage * truncate invocation:: Shrink or extend the size of a file =20 Printing text @@ -11191,7 +11191,7 @@ file status information, and write buffers to dis= k. * df invocation:: Report file system disk space usage. * du invocation:: Estimate file space usage. * stat invocation:: Report file or file system status. -* sync invocation:: Synchronize memory and disk. +* sync invocation:: Synchronize cached writes to persistent = storage. * truncate invocation:: Shrink or extend the size of a file. @end menu =20 @@ -12033,28 +12033,60 @@ with @env{TZ}, libc, The GNU C Library Referenc= e Manual}. =20 =20 @node sync invocation -@section @command{sync}: Synchronize data on disk with memory +@section @command{sync}: Synchronize cached writes to persistent storage= =20 @pindex sync @cindex synchronize disk and memory +@cindex Synchronize cached writes to persistent storage + +@command{sync} synchronizes in memory files or file systems to persisten= t +storage. Synopsis: + +@example +sync [@var{option}] [@var{file}]@dots{} +@end example =20 @cindex superblock, writing @cindex inodes, written buffered @command{sync} writes any data buffered in memory out to disk. This can= include (but is not limited to) modified superblocks, modified inodes, and delayed reads and writes. This must be implemented by the kernel; -The @command{sync} program does nothing but exercise the @code{sync} sys= tem -call. +The @command{sync} program does nothing but exercise the @code{sync}, +@code{syncfs}, @code{fsync}, and @code{fdatasync} system calls. =20 @cindex crashes and corruption The kernel keeps data in memory to avoid doing (relatively slow) disk reads and writes. This improves performance, but if the computer crashes, data may be lost or the file system corrupted as a -result. The @command{sync} command ensures everything in memory -is written to disk. +result. The @command{sync} command instructs the kernel to write +data in memory to persistent storage. =20 -Any arguments are ignored, except for a lone @option{--help} or -@option{--version} (@pxref{Common options}). +If any argument is specified then only those files will be +synchronized using the fsync(2) syscall by default. + +If at least one file is specified, it is possible to change the +synchronization method with the following options. Also see +@ref{Common options}. + +@table @samp +@item -d +@itemx --data +@opindex --data +Use fdatasync(2) to sync only the data for the file, +and any metadata required to maintain file system consistency. + +@item -f +@itemx --file-system +@opindex --file-system +Synchronize all the I/O waiting for the file systems that contain the fi= le, +using the syscall syncfs(2). Note you would usually @emph{not} specify +this option if passing a device node like @samp{/dev/sda} for example, +as that would sync the containing file system rather than the referenced= one. +Note also that depending on the system, passing individual device nodes = or files +may have different sync characteristics than using no arguments. +I.E. arguments passed to fsync(2) may provide greater guarantees through= +write barriers, than a global sync(2) used when no arguments are provide= d. +@end table =20 @exitstatus =20 diff --git a/m4/jm-macros.m4 b/m4/jm-macros.m4 index 58fdd97..79f124b 100644 --- a/m4/jm-macros.m4 +++ b/m4/jm-macros.m4 @@ -89,6 +89,7 @@ AC_DEFUN([coreutils_MACROS], sethostname siginterrupt sync + syncfs sysctl sysinfo tcgetpgrp diff --git a/man/sync.x b/man/sync.x index 7947bb7..79fee22 100644 --- a/man/sync.x +++ b/man/sync.x @@ -1,6 +1,6 @@ [NAME] -sync \- flush file system buffers +sync \- Synchronize cached writes to persistent storage [DESCRIPTION] .\" Add any additional description here [SEE ALSO] -sync(2) +fdatasync(2), fsync(2), sync(2), syncfs(2) diff --git a/src/sync.c b/src/sync.c index e9f4d7e..0b2b178 100644 --- a/src/sync.c +++ b/src/sync.c @@ -17,18 +17,42 @@ /* Written by Jim Meyering */ =20 #include +#include #include #include #include =20 #include "system.h" #include "error.h" -#include "long-options.h" +#include "quote.h" =20 /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "sync" =20 -#define AUTHORS proper_name ("Jim Meyering") +#define AUTHORS \ + proper_name ("Jim Meyering"), \ + proper_name ("Giuseppe Scrivano") + +#ifndef HAVE_SYNCFS +# define HAVE_SYNCFS 0 +#endif + +enum sync_mode +{ + MODE_FILE, + MODE_DATA, + MODE_FILE_SYSTEM, + MODE_SYNC +}; + +static struct option const long_options[] =3D +{ + {"data", no_argument, NULL, MODE_DATA}, + {"file-system", no_argument, NULL, MODE_FILE_SYSTEM}, + {GETOPT_HELP_OPTION_DECL}, + {GETOPT_VERSION_OPTION_DECL}, + {NULL, 0, NULL, 0} +}; =20 void usage (int status) @@ -37,11 +61,22 @@ usage (int status) emit_try_help (); else { - printf (_("Usage: %s [OPTION]\n"), program_name); + printf (_("Usage: %s [OPTION] [FILE]...\n"), program_name); fputs (_("\ -Force changed blocks to disk, update the super block.\n\ +Synchronize cached writes to persistent storage\n\ +\n\ +If one or more files are specified, sync only them,\n\ +or their containing file systems.\n\ \n\ "), stdout); + + fputs (_("\ + -d, --data sync only file data, no unneeded metadata\n\ +"), stdout); + fputs (_("\ + -f, --file-system sync the file systems that contain the files\n\= +"), stdout); + fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); emit_ancillary_info (PROGRAM_NAME); @@ -49,9 +84,86 @@ Force changed blocks to disk, update the super block.\= n\ exit (status); } =20 +/* Sync the specified FILE, or file systems associated with FILE. + Return 1 on success. */ + +static bool +sync_arg (enum sync_mode mode, char const *file) +{ + bool ret =3D true; + int fd; + + /* Note O_PATH might be supported with syncfs(), + though as of Linux 3.18 is not. */ + if ((fd =3D open (file, O_RDONLY | O_NONBLOCK)) < 0) + { + /* Use the O_RDONLY errno, which is significant + with directories for example. */ + int rd_errno =3D errno; + if ((fd =3D open (file, O_WRONLY | O_NONBLOCK)) < 0) + error (0, rd_errno, _("error opening %s"), quote (file)); + return false; + } + + /* We used O_NONBLOCK above to not hang with fifos, + so reset that here. */ + int fdflags; + if ((fdflags =3D fcntl (fd, F_GETFL)) =3D=3D -1 + || fcntl (fd, F_SETFL, fdflags & ~O_NONBLOCK) < 0) + { + error (0, errno, _("couldn't reset non-blocking mode %s"), quote (= file)); + ret =3D false; + } + + if (ret =3D=3D true) + { + int sync_status; + + switch (mode) + { + case MODE_DATA: + sync_status =3D fdatasync (fd); + break; + + case MODE_FILE: + sync_status =3D fsync (fd); + break; + +#if HAVE_SYNCFS + case MODE_FILE_SYSTEM: + sync_status =3D syncfs (fd); + break; +#endif + + default: + assert ("invalid sync_mode"); + } + + if (sync_status < 0) + { + error (0, errno, _("error syncing %s"), quote (file)); + ret =3D false; + } + } + + if (close (fd) < 0) + { + error (0, errno, _("failed to close %s"), quote (file)); + ret =3D false; + } + + return ret; +} + int main (int argc, char **argv) { + int c; + bool args_specified; + bool arg_data =3D false, arg_file_system =3D false; + enum sync_mode mode; + bool ok =3D true; + initialize_main (&argc, &argv); set_program_name (argv[0]); setlocale (LC_ALL, ""); @@ -60,14 +172,55 @@ main (int argc, char **argv) =20 atexit (close_stdout); =20 - parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, Version, - usage, AUTHORS, (char const *) NULL); - if (getopt_long (argc, argv, "", NULL, NULL) !=3D -1) - usage (EXIT_FAILURE); + while ((c =3D getopt_long (argc, argv, "", long_options, NULL)) + !=3D -1) + { + switch (c) + { + case MODE_DATA: + arg_data =3D true; + break; + + case MODE_FILE_SYSTEM: + arg_file_system =3D true; + break; + + case_GETOPT_HELP_CHAR; + + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); =20 - if (optind < argc) - error (0, 0, _("ignoring all arguments")); + default: + usage (EXIT_FAILURE); + } + } + + args_specified =3D optind < argc; + + if (arg_data && arg_file_system) + { + error (EXIT_FAILURE, 0, + _("cannot specify both --data and --file-system")); + } + + if (!args_specified && arg_data) + error (EXIT_FAILURE, 0, _("--data needs at least one argument")); + + if (! args_specified || (arg_file_system && ! HAVE_SYNCFS)) + mode =3D MODE_SYNC; + else if (arg_file_system) + mode =3D MODE_FILE_SYSTEM; + else if (! arg_data) + mode =3D MODE_FILE; + else + mode =3D MODE_DATA; + + if (mode =3D=3D MODE_SYNC) + sync (); + else + { + for (; optind < argc; optind++) + ok &=3D sync_arg (mode, argv[optind]); + } =20 - sync (); - return EXIT_SUCCESS; + return ok ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/local.mk b/tests/local.mk index 5dcbd55..bfa447c 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -375,6 +375,7 @@ all_tests =3D \ tests/misc/stty-row-col.sh \ tests/misc/sum.pl \ tests/misc/sum-sysv.sh \ + tests/misc/sync.sh \ tests/misc/tac.pl \ tests/misc/tac-continue.sh \ tests/misc/tac-2-nonseekable.sh \ diff --git a/tests/misc/sync.sh b/tests/misc/sync.sh new file mode 100755 index 0000000..8b0caf4 --- /dev/null +++ b/tests/misc/sync.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# Test various sync(1) operations + +# Copyright (C) 2015 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=3D.}/tests/init.sh"; path_prepend_ ./src +print_ver_ sync + +touch file + +# fdatasync+syncfs is nonsensical +returns_ 1 sync --data --file-system || fail=3D1 + +# fdatasync needs an operand +returns_ 1 sync --data || fail=3D1 + +# Test syncing of file (fsync) (little side effects) +sync file || fail=3D1 + +# Ensure multiple args are processed and diagnosed +returns_ 1 sync file nofile || fail=3D1 + +if test "$fail" !=3D '1'; then + # Ensure a fifo doesn't block + mkfifo_or_skip_ fifo + timeout 10 sync fifo + test $? =3D 124 && fail=3D1 +fi + +Exit $fail --=20 2.1.0 --------------000307010203040204080106-- From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 10 12:12:07 2018 Received: (at 19681) by debbugs.gnu.org; 10 Oct 2018 16:12:07 +0000 Received: from localhost ([127.0.0.1]:43743 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gAH5j-00037o-Gs for submit@debbugs.gnu.org; Wed, 10 Oct 2018 12:12:07 -0400 Received: from mail-pl1-f181.google.com ([209.85.214.181]:42106) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gAH5h-00037E-2Q; Wed, 10 Oct 2018 12:12:05 -0400 Received: by mail-pl1-f181.google.com with SMTP id c8-v6so2755681plo.9; Wed, 10 Oct 2018 09:12:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:message-id:date:user-agent:mime-version:content-language :content-transfer-encoding; bh=kxTsRDO+yiyYS1xcgQE2YG+JvmM9oVgFZ9HqQT99OFU=; b=cptzypn7uXXMB6hZqWe72V4TqOj3Vb7n4U8GDNJXYNj0J8h3rI5LEVTIqTiQYeYfTt cjKTQ7xZmjlj31ho44vNXdpucf55cNsr5o9U4QfGR0D6HfRG+hYMRyqBSbUwKDQ9LK7o aJX7hG2bKE5dedkhTaFpaPsJJFTG2oB05nck2gf0UtMYpixmi2IslxZ+DCv9Slci0die h4Hgp5NO4XojQoUq2xdF+rpK5xJMFmQVQLa7Ri+oTzQLRnZgoGYaOBIlo8iRCvnC6WDI ACfc3c0FdG8nyKgG7GTJJr1649vu5fkRBtvMi4c+MKwue1YcnxCLXM7s3JZG4JsoHaBh s7/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=kxTsRDO+yiyYS1xcgQE2YG+JvmM9oVgFZ9HqQT99OFU=; b=HikmEsFDzhIqlNP2WpU/ftfB2te9fkna7E3Cc06aBj/ZTxU3ZJv1Qm7+vRCmAadwRg NhLHHGRSBDlrL/ZiwvIf+8bSQuDyhIqeN1K5eQCLvl/56b0JkeMHKq27csWFJJqe8oeU zL2vIHC9SezaujcBQ/FdiiNtPPLQWbWFrz8+p7caD5OkguAdzOfFUyGZ1BZJXOun4eln slqV+tQ6dm/LHwa7A/Z+VlDiFnwrQdZC2tdfcw3Carrys+wPfat5s2+xuqVJIeXCq8/2 sJ73aPVeoNykOnrJAZAbSDEXTFZ0fbPya/HNJBEGXUpQS0S5xygw4VDGhKZb1P4MCNYB uyQg== X-Gm-Message-State: ABuFfohoTuTzZ0PSSo4b/PYB/o6MenAB8j05Aw9asoUJz4yb6acHwWXv aafiCmayogEjAB3/oI+nRcQDIc5O36k= X-Google-Smtp-Source: ACcGV637HmZ9FQnlsJEH0Ngpg33+bSFVXs/YWv1hN+czY5N5Lgbz/1jrAqoBEndHFXKj6Sqnq6njpw== X-Received: by 2002:a17:902:a585:: with SMTP id az5-v6mr210240plb.197.1539187918724; Wed, 10 Oct 2018 09:11:58 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id r22-v6sm64694224pfd.174.2018.10.10.09.11.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 09:11:57 -0700 (PDT) To: 19681@debbugs.gnu.org From: Assaf Gordon Message-ID: Date: Wed, 10 Oct 2018 10:11:56 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: close 19681 stop Pushed at https://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=8b2bf5295f353016d4f5e6a2317d55b6a8e7fd00 closing. [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.214.181 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.214.181 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (assafgordon[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 1.8 MISSING_SUBJECT Missing Subject: header 0.2 NO_SUBJECT Extra score for no subject X-Debbugs-Envelope-To: 19681 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) close 19681 stop Pushed at https://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=8b2bf5295f353016d4f5e6a2317d55b6a8e7fd00 closing. From unknown Sat Aug 16 18:16:50 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 08 Nov 2018 12:24:07 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator