From patchwork Tue Dec 6 04:39:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 9462015 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EEFCE6074E for ; Tue, 6 Dec 2016 04:36:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA4E827BFC for ; Tue, 6 Dec 2016 04:36:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF3F5281AA; Tue, 6 Dec 2016 04:36:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F91A28159 for ; Tue, 6 Dec 2016 04:36:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751966AbcLFEgj (ORCPT ); Mon, 5 Dec 2016 23:36:39 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:36591 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751779AbcLFEgh (ORCPT ); Mon, 5 Dec 2016 23:36:37 -0500 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id uB64aY7Z027249 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 6 Dec 2016 04:36:34 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id uB64aYIN031719 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 6 Dec 2016 04:36:34 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id uB64aWx1022791; Tue, 6 Dec 2016 04:36:33 GMT Received: from localhost.localdomain (/157.49.83.61) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Dec 2016 20:36:31 -0800 From: Anand Jain To: dsterba@suse.cz Cc: linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs-progs: recursive defrag cleanup duplicate code Date: Tue, 6 Dec 2016 12:39:38 +0800 Message-Id: <20161206043938.3249-2-anand.jain@oracle.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20161206043938.3249-1-anand.jain@oracle.com> References: <20161206043938.3249-1-anand.jain@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Anand Jain --- cmds-filesystem.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/cmds-filesystem.c b/cmds-filesystem.c index 41623f3183a8..ecac37edf936 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -1136,21 +1136,13 @@ static int cmd_filesystem_defrag(int argc, char **argv) close_file_or_dir(fd, dirstream); continue; } - if (recursive) { - if (S_ISDIR(st.st_mode)) { - ret = nftw(argv[i], defrag_callback, 10, + if (recursive && S_ISDIR(st.st_mode)) { + ret = nftw(argv[i], defrag_callback, 10, FTW_MOUNT | FTW_PHYS); - if (ret == ENOTTY) - exit(1); - /* errors are handled in the callback */ - ret = 0; - } else { - if (defrag_global_verbose) - printf("%s\n", argv[i]); - ret = do_defrag(fd, defrag_global_fancy_ioctl, - &defrag_global_range); - e = errno; - } + if (ret == ENOTTY) + exit(1); + /* errors are handled in the callback */ + ret = 0; } else { if (defrag_global_verbose) printf("%s\n", argv[i]);