From patchwork Fri Dec 16 04:41:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 9486855 X-Mozilla-Keys: nonjunk Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on sandeen.net X-Spam-Level: X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM, RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.0 X-Spam-HP: BAYES_00=-1.9,HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_HI=-5,RCVD_IN_SORBS_SPAM=0.5,RP_MATCHES_RCVD=-0.1 X-Original-To: sandeen@sandeen.net Delivered-To: sandeen@sandeen.net Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by sandeen.net (Postfix) with ESMTP id 40CB592 for ; Thu, 15 Dec 2016 22:45:32 -0600 (CST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756966AbcLPEpf (ORCPT ); Thu, 15 Dec 2016 23:45:35 -0500 Received: from ipmail06.adl6.internode.on.net ([150.101.137.145]:63564 "EHLO ipmail06.adl6.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756943AbcLPEpe (ORCPT ); Thu, 15 Dec 2016 23:45:34 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2DNDgAtcFNYIAKzLHldGwEBAQMBAQEJAQEBgzcBAQEBAR9agQaGdYdMlCkIEgaBGASSe4QYIoV8AgICgglUAQIBAQEBAQIGAQEBAQEBOUWEaQZWFR4IGDE5AwcUGYhqqxiLS4Vzjz0FjwCLa4ZRilWECYxPSZFagVcTDoN9HIFxKjSIbAEBAQ Received: from ppp121-44-179-2.lns20.syd7.internode.on.net (HELO dastard) ([121.44.179.2]) by ipmail06.adl6.internode.on.net with ESMTP; 16 Dec 2016 15:11:19 +1030 Received: from discord.disaster.area ([192.168.1.111]) by dastard with esmtp (Exim 4.80) (envelope-from ) id 1cHkKb-00023o-T2 for linux-xfs@vger.kernel.org; Fri, 16 Dec 2016 15:41:17 +1100 Received: from dave by discord.disaster.area with local (Exim 4.88) (envelope-from ) id 1cHkKb-0005Zy-Ry for linux-xfs@vger.kernel.org; Fri, 16 Dec 2016 15:41:17 +1100 From: Dave Chinner To: linux-xfs@vger.kernel.org Subject: [PATCH 5/6] xfs_io: make various commands one-shot only Date: Fri, 16 Dec 2016 15:41:14 +1100 Message-Id: <20161216044115.21287-6-david@fromorbit.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161216044115.21287-1-david@fromorbit.com> References: <20161216044115.21287-1-david@fromorbit.com> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner It makes no sense to iterate the file table for some xfs_io commands. Some commands are already marked in this way, but lots of them are not and this leads to bad behaviour. For example, the open command will run until the process fd table is full and EMFILE is returned rather than just opening the specified file once. Signed-Off-By: Dave Chinner --- io/file.c | 2 +- io/freeze.c | 4 ++-- io/getrusage.c | 3 ++- io/imap.c | 2 +- io/inject.c | 2 +- io/link.c | 2 +- io/mmap.c | 3 ++- io/open.c | 7 ++++--- io/reflink.c | 4 ++-- io/resblks.c | 2 +- io/shutdown.c | 2 +- io/sync.c | 3 ++- 12 files changed, 20 insertions(+), 16 deletions(-) diff --git a/io/file.c b/io/file.c index 8e3f07122922..349b19cdc420 100644 --- a/io/file.c +++ b/io/file.c @@ -95,7 +95,7 @@ file_init(void) file_cmd.cfunc = file_f; file_cmd.argmin = 0; file_cmd.argmax = 1; - file_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK; + file_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK | CMD_FLAG_ONESHOT; file_cmd.oneline = _("set the current file"); print_cmd.name = "print"; diff --git a/io/freeze.c b/io/freeze.c index 3d0d2a4b5601..0305713d99e8 100644 --- a/io/freeze.c +++ b/io/freeze.c @@ -65,14 +65,14 @@ freeze_init(void) freeze_cmd.cfunc = freeze_f; freeze_cmd.argmin = 0; freeze_cmd.argmax = 0; - freeze_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK; + freeze_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK | CMD_FLAG_ONESHOT; freeze_cmd.oneline = _("freeze filesystem of current file"); thaw_cmd.name = "thaw"; thaw_cmd.cfunc = thaw_f; thaw_cmd.argmin = 0; thaw_cmd.argmax = 0; - thaw_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK; + thaw_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK | CMD_FLAG_ONESHOT; thaw_cmd.oneline = _("unfreeze filesystem of current file"); if (expert) { diff --git a/io/getrusage.c b/io/getrusage.c index bccf94cbc302..cf1f2afd19a8 100644 --- a/io/getrusage.c +++ b/io/getrusage.c @@ -113,7 +113,8 @@ getrusage_init(void) getrusage_cmd.argmin = 0; getrusage_cmd.argmax = -1; getrusage_cmd.cfunc = getrusage_f; - getrusage_cmd.flags = CMD_NOFILE_OK | CMD_NOMAP_OK | CMD_FOREIGN_OK; + getrusage_cmd.flags = CMD_NOFILE_OK | CMD_NOMAP_OK | + CMD_FOREIGN_OK | CMD_FLAG_ONESHOT; getrusage_cmd.oneline = _("report process resource usage"); if (expert) diff --git a/io/imap.c b/io/imap.c index 7123432f411f..f52238e0c450 100644 --- a/io/imap.c +++ b/io/imap.c @@ -72,7 +72,7 @@ imap_init(void) imap_cmd.argmin = 0; imap_cmd.argmax = 1; imap_cmd.args = _("[nentries]"); - imap_cmd.flags = CMD_NOMAP_OK; + imap_cmd.flags = CMD_NOMAP_OK | CMD_FLAG_ONESHOT; imap_cmd.oneline = _("inode map for filesystem of current file"); if (expert) diff --git a/io/inject.c b/io/inject.c index 5d5e4aef3dfc..25c70218a1ef 100644 --- a/io/inject.c +++ b/io/inject.c @@ -163,7 +163,7 @@ inject_init(void) inject_cmd.cfunc = inject_f; inject_cmd.argmin = 0; inject_cmd.argmax = -1; - inject_cmd.flags = CMD_NOMAP_OK; + inject_cmd.flags = CMD_NOMAP_OK | CMD_FLAG_ONESHOT; inject_cmd.args = _("[tag ...]"); inject_cmd.oneline = _("inject errors into a filesystem"); inject_cmd.help = inject_help; diff --git a/io/link.c b/io/link.c index ccf8e691bb1d..9b2e8a970942 100644 --- a/io/link.c +++ b/io/link.c @@ -59,7 +59,7 @@ flink_init(void) flink_cmd.cfunc = flink_f; flink_cmd.argmin = 1; flink_cmd.argmax = 1; - flink_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK; + flink_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK | CMD_FLAG_ONESHOT; flink_cmd.args = _("filename"); flink_cmd.oneline = _("link the open file descriptor to the supplied filename"); diff --git a/io/mmap.c b/io/mmap.c index dc188d0557cf..e2d8d5a92326 100644 --- a/io/mmap.c +++ b/io/mmap.c @@ -674,7 +674,8 @@ mmap_init(void) mmap_cmd.cfunc = mmap_f; mmap_cmd.argmin = 0; mmap_cmd.argmax = -1; - mmap_cmd.flags = CMD_NOMAP_OK | CMD_NOFILE_OK | CMD_FOREIGN_OK; + mmap_cmd.flags = CMD_NOMAP_OK | CMD_NOFILE_OK | + CMD_FOREIGN_OK | CMD_FLAG_ONESHOT; mmap_cmd.args = _("[N] | [-rwx] [-s size] [off len]"); mmap_cmd.oneline = _("mmap a range in the current file, show mappings"); diff --git a/io/open.c b/io/open.c index 722d0f9eacf5..a12f4a2ba528 100644 --- a/io/open.c +++ b/io/open.c @@ -918,7 +918,8 @@ open_init(void) open_cmd.cfunc = open_f; open_cmd.argmin = 0; open_cmd.argmax = -1; - open_cmd.flags = CMD_NOMAP_OK | CMD_NOFILE_OK | CMD_FOREIGN_OK; + open_cmd.flags = CMD_NOMAP_OK | CMD_NOFILE_OK | + CMD_FOREIGN_OK | CMD_FLAG_ONESHOT; open_cmd.args = _("[-acdrstxT] [-m mode] [path]"); open_cmd.oneline = _("open the file specified by path"); open_cmd.help = open_help; @@ -936,7 +937,7 @@ open_init(void) close_cmd.cfunc = close_f; close_cmd.argmin = 0; close_cmd.argmax = 0; - close_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK; + close_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK | CMD_FLAG_ONESHOT; close_cmd.oneline = _("close the current open file"); statfs_cmd.name = "statfs"; @@ -980,7 +981,7 @@ open_init(void) inode_cmd.args = _("[-nv] [num]"); inode_cmd.argmin = 0; inode_cmd.argmax = 3; - inode_cmd.flags = CMD_NOMAP_OK; + inode_cmd.flags = CMD_NOMAP_OK | CMD_FLAG_ONESHOT; inode_cmd.oneline = _("Query inode number usage in the filesystem"); inode_cmd.help = inode_help; diff --git a/io/reflink.c b/io/reflink.c index a09e82dca80a..a22b6b4a07e3 100644 --- a/io/reflink.c +++ b/io/reflink.c @@ -304,7 +304,7 @@ reflink_init(void) reflink_cmd.cfunc = reflink_f; reflink_cmd.argmin = 4; reflink_cmd.argmax = -1; - reflink_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK; + reflink_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK | CMD_FLAG_ONESHOT; reflink_cmd.args = _("infile src_off dst_off len"); reflink_cmd.oneline = @@ -318,7 +318,7 @@ _("infile src_off dst_off len"); dedupe_cmd.cfunc = dedupe_f; dedupe_cmd.argmin = 4; dedupe_cmd.argmax = -1; - dedupe_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK; + dedupe_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK | CMD_FLAG_ONESHOT; dedupe_cmd.args = _("infile src_off dst_off len"); dedupe_cmd.oneline = diff --git a/io/resblks.c b/io/resblks.c index 73318ae03fd2..06903f5bb748 100644 --- a/io/resblks.c +++ b/io/resblks.c @@ -61,7 +61,7 @@ resblks_init(void) resblks_cmd.cfunc = resblks_f; resblks_cmd.argmin = 0; resblks_cmd.argmax = 1; - resblks_cmd.flags = CMD_NOMAP_OK; + resblks_cmd.flags = CMD_NOMAP_OK | CMD_FLAG_ONESHOT; resblks_cmd.args = _("[blocks]"); resblks_cmd.oneline = _("get and/or set count of reserved filesystem blocks"); diff --git a/io/shutdown.c b/io/shutdown.c index d8507cc78af7..d9cd520d11e2 100644 --- a/io/shutdown.c +++ b/io/shutdown.c @@ -54,7 +54,7 @@ shutdown_init(void) shutdown_cmd.cfunc = shutdown_f; shutdown_cmd.argmin = 0; shutdown_cmd.argmax = 1; - shutdown_cmd.flags = CMD_NOMAP_OK; + shutdown_cmd.flags = CMD_NOMAP_OK | CMD_FLAG_ONESHOT; shutdown_cmd.args = _("[-f]"); shutdown_cmd.oneline = _("shuts down the filesystem where the current file resides"); diff --git a/io/sync.c b/io/sync.c index 28e3a15e0a96..c77263804a35 100644 --- a/io/sync.c +++ b/io/sync.c @@ -52,7 +52,8 @@ sync_init(void) { sync_cmd.name = "sync"; sync_cmd.cfunc = sync_f; - sync_cmd.flags = CMD_NOMAP_OK | CMD_NOFILE_OK | CMD_FOREIGN_OK; + sync_cmd.flags = CMD_NOMAP_OK | CMD_NOFILE_OK | + CMD_FOREIGN_OK | CMD_FLAG_ONESHOT; sync_cmd.oneline = _("calls sync(2) to flush all in-core filesystem state to disk");