From patchwork Thu Aug 24 11:47:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 9919879 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 51F2A60353 for ; Thu, 24 Aug 2017 11:48:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CBC028BA7 for ; Thu, 24 Aug 2017 11:48:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41FE528BDB; Thu, 24 Aug 2017 11:48:01 +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 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 EEA1028BA7 for ; Thu, 24 Aug 2017 11:48:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751462AbdHXLr7 (ORCPT ); Thu, 24 Aug 2017 07:47:59 -0400 Received: from mx2.suse.de ([195.135.220.15]:35480 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751270AbdHXLr6 (ORCPT ); Thu, 24 Aug 2017 07:47:58 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CDA67AC7F; Thu, 24 Aug 2017 11:47:56 +0000 (UTC) From: Nikolay Borisov To: linux-xfs@vger.kernel.org Cc: sandeen@redhat.com, Nikolay Borisov Subject: [PATCH 3/6] fiemap: Eliminate num_extents Date: Thu, 24 Aug 2017 14:47:49 +0300 Message-Id: <1503575272-28263-4-git-send-email-nborisov@suse.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503575272-28263-1-git-send-email-nborisov@suse.com> References: <1503575272-28263-1-git-send-email-nborisov@suse.com> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fiemap has this rather convoluted logic to calculate the number of extents to query. This introduces needless complexity with no real benefit. Remove num_extents and instead hardcode the number of extents we query for in a single go to 32. No functional changes Signed-off-by: Nikolay Borisov --- io/fiemap.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/io/fiemap.c b/io/fiemap.c index d284248e4fe1..a31db790c86d 100644 --- a/io/fiemap.c +++ b/io/fiemap.c @@ -23,6 +23,8 @@ #include "init.h" #include "io.h" +#define EXTENT_BATCH 32 + static cmdinfo_t fiemap_cmd; static int max_extents = 0; @@ -195,7 +197,6 @@ fiemap_f( char **argv) { struct fiemap *fiemap; - int num_extents = 32; int last = 0; int lflag = 0; int vflag = 0; @@ -231,10 +232,8 @@ fiemap_f( } } - if (max_extents) - num_extents = min(num_extents, max_extents); map_size = sizeof(struct fiemap) + - (num_extents * sizeof(struct fiemap_extent)); + (EXTENT_BATCH * sizeof(struct fiemap_extent)); fiemap = malloc(map_size); if (!fiemap) { fprintf(stderr, _("%s: malloc of %d bytes failed.\n"), @@ -246,15 +245,12 @@ fiemap_f( printf("%s:\n", file->name); while (!last && ((cur_extent + 1) != max_extents)) { - if (max_extents) - num_extents = min(num_extents, - max_extents - (cur_extent + 1)); memset(fiemap, 0, map_size); fiemap->fm_flags = fiemap_flags; fiemap->fm_start = last_logical; fiemap->fm_length = -1LL; - fiemap->fm_extent_count = num_extents; + fiemap->fm_extent_count = EXTENT_BATCH; ret = ioctl(file->fd, FS_IOC_FIEMAP, (unsigned long)fiemap); if (ret < 0) {