Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp14283022ybl; Mon, 30 Dec 2019 07:19:54 -0800 (PST) X-Google-Smtp-Source: APXvYqzpj/BP9SRzXhwwo5z3B6ROt011ePizwEoXKrg/P0aEGR3+XL9JsTsV+aHjdi3CSHivtLG4 X-Received: by 2002:a05:6808:30d:: with SMTP id i13mr5095648oie.144.1577719194114; Mon, 30 Dec 2019 07:19:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577719194; cv=none; d=google.com; s=arc-20160816; b=xRNGyEhtEOBWrsCfsU0Krbx37L31WLcAIkvLLXkC77uHyboUV0isz+GbIpVxSv3RsM kyVVQARS7fuPGvxIYPbZIAdYvt5U9ZWGKqXI60M1zEITUrhcEsb16QAcRAt5WAhwXb2E uSSpYsEYxsQhPKs55FqrGEqfbAth+lctCU/KVSdp9h27q7VmYw9Bd9FbGdgwF3Ct3vC5 AvI7OmDvHG9+vhQzE21Vysm14+AoQGqHvB68mGv/Ea1WB0KkV5VZzatMM7br+lv+UQpG p5IVk7sXh35JBDE18rwBFHwF8i/l56dikGruN0Drxn2l7+O8yzELvqxkov8MgELysg+r oo5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=1/aS83IsYUsM7y9dGvdwmrg0jwgR5Z3qzTZjZ/V//bA=; b=xgY+C5cZit8FZ/AC/aEbfvigo3uWi4RMQPj+a9iI5dmHorYBwHczfNQti+4O3s8Hun PKPpwvZYpiXsfa9k+KdKTT9pwvXD26kcH97jSHRw5IHcLvClXLcia7rXtQPZvY+AEhUx lAwQU90LEosCcdRR4eYwRSjWf/X8cRsFX5QlVyo/n6yZW+ya66Z/VLbIopijD8/8FyzH jzEktIzMZqad3f2wAbKDxRiEKaFHQKR1d7CdZO1reThwSwGI/duKtLKYE3DPcNlId4Fn IgfhT9eL1OTX+rnfoGEl0OPlyEndRJ7hn7pMHblzItHj56zwMMXkLZlLsf+I7XPtnTrx ISjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s68si22181826oih.275.2019.12.30.07.19.32; Mon, 30 Dec 2019 07:19:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727537AbfL3PTc (ORCPT + 99 others); Mon, 30 Dec 2019 10:19:32 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:48601 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727531AbfL3PTc (ORCPT ); Mon, 30 Dec 2019 10:19:32 -0500 Received: from callcc.thunk.org ([173.239.199.158]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id xBUFJNjL026470 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Dec 2019 10:19:25 -0500 Received: by callcc.thunk.org (Postfix, from userid 15806) id 0A78D420485; Mon, 30 Dec 2019 10:19:22 -0500 (EST) Date: Mon, 30 Dec 2019 10:19:21 -0500 From: "Theodore Y. Ts'o" To: Wang Shilong Cc: linux-ext4@vger.kernel.org, lixi@ddn.com, adilger@dilger.ca, dongyangli@ddn.com, Wang Shilong Subject: Re: [PATCH] e2fsprogs: fix to use inode i_blocks correctly Message-ID: <20191230151921.GA125106@mit.edu> References: <1577705766-20736-1-git-send-email-wangshilong1991@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1577705766-20736-1-git-send-email-wangshilong1991@gmail.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon, Dec 30, 2019 at 08:36:06PM +0900, Wang Shilong wrote: > blocks_from_inode() did not return wrong inode blocks, and > ext2fs_inode_i_blocks() is not taking EXT4_HUGE_FILE_FL into account > at all, while the some callers deal it correctly, some not. This patch > try to unify to handle it in ext2fs_inode_i_blocks() to return. > blocks(based on 512 bytes) I don't really want to change the functionality of ext2fs_inode_i_blocks(). First of all, it's in a shared library, so if there are any binaries which were expecting the old behavior, that could get surprising. Secondly, its name is confusing and so we're better off creating a new function ext2fs_get_stat_i_blocks() which makes it clear that we function is using units of 512 byte sectors, instead of either the file system block size, or the raw i_blocks value from the inode. Two other things about your patch. First of all, the filefrag command in debugfs was intended to print the number of file system blocks, so it was correct as written. Secondly, please note the blkcnt_t is a signed type (because the block iterator functions use negative values to indicate various kinds of metadata blocks), while blk64_t is an unsigned type. So using blkcnt_t as a temporary value and returning it in a function which has a return type of blk64_t will (righly) trigger compiler warnings. Here's the patch I've checked into the maint branch of e2fsprogs to address the issue you've identified. - Ted