From patchwork Fri Sep 30 20:57:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 9485643 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=-2.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,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, 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 A4FF31431 for ; Fri, 30 Sep 2016 15:57:01 -0500 (CDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933278AbcI3U52 (ORCPT ); Fri, 30 Sep 2016 16:57:28 -0400 Received: from sandeen.net ([63.231.237.45]:57464 "EHLO sandeen.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932485AbcI3U52 (ORCPT ); Fri, 30 Sep 2016 16:57:28 -0400 Received: from Liberator.example.com (74-95-67-117-Minnesota.hfc.comcastbusiness.net [74.95.67.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by sandeen.net (Postfix) with ESMTPSA id F09891431; Fri, 30 Sep 2016 15:56:55 -0500 (CDT) Subject: [PATCH 5/5] xfs_io: fix inode command with "-n" for bogus inode To: Eric Sandeen , linux-xfs References: <9f126dc7-3b1e-a1ed-7f23-48410a76adc2@redhat.com> From: Eric Sandeen Message-ID: <26464bd7-f56c-733f-108d-13dca26ceb7c@sandeen.net> Date: Fri, 30 Sep 2016 15:57:28 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <9f126dc7-3b1e-a1ed-7f23-48410a76adc2@redhat.com> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org If we ask for the next allocated inode after a number for which no other inode exists, the bulkstat returns success, but with count == 0. If we ignore this fact, we print a garbage result from bstat.bs_ino in this case, so fix it. Signed-off-by: Eric Sandeen --- io/open.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/io/open.c b/io/open.c index 7d952a0..4279062 100644 --- a/io/open.c +++ b/io/open.c @@ -882,10 +882,16 @@ inode_f( exitcode = 1; return 0; } - } else if (ret_next) /* The next inode in use */ - result_ino = bstat.bs_ino; - else /* The inode we asked about */ + } else if (ret_next) { + /* The next inode in use, or 0 if none */ + if (*bulkreq.ocount) + result_ino = bstat.bs_ino; + else + result_ino = 0; + } else { + /* The inode we asked about */ result_ino = userino; + } } if (verbose && result_ino) {