From patchwork Tue Jul 10 06:05:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10516109 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 2763B601D4 for ; Tue, 10 Jul 2018 06:05:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1544228B24 for ; Tue, 10 Jul 2018 06:05:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 09BC128C0E; Tue, 10 Jul 2018 06:05:43 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 8708E28B24 for ; Tue, 10 Jul 2018 06:05:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751015AbeGJGFl (ORCPT ); Tue, 10 Jul 2018 02:05:41 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58186 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750985AbeGJGFj (ORCPT ); Tue, 10 Jul 2018 02:05:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=jIAmJTdLuu9dDYsvXzAZG/miPZ0N7I4UpwIQHuCrLpM=; b=Zd91Pym58QcN+kYPscCQbUWOg KV3Ft3oGPONUD3uoRx7AM3khEabVqyMT7kMqFbckxZCmDZBOLeF9IuIUleJlq4iJYxo1wSkGC7js3 NHggfejukOkE0zNVJp1KqOhUK8Fl3H7uyPamTq96fdHlzGaykZshZPolqhVwsg+5QeuR55az9adbQ blvH5xDkeEeBr6AI8r5KGeEpRW76j+oCJSdQxhBBd+H98wRwYaGYC+W2vj+RizL04h0T8ayAdnGz3 4nB2fyxXlLXCgOVfrFCTuPprkpCryPYyp920MZr9yjVDbfEu3S8xjsVPau6bHl4+fk4Sw9HZ96QXP FQmGbYZsA==; Received: from 213-225-34-75.nat.highway.a1.net ([213.225.34.75] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fclmM-000560-IP for linux-xfs@vger.kernel.org; Tue, 10 Jul 2018 06:05:39 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 1/6] xfs: remove if_real_bytes Date: Tue, 10 Jul 2018 08:05:23 +0200 Message-Id: <20180710060528.4071-2-hch@lst.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180710060528.4071-1-hch@lst.de> References: <20180710060528.4071-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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 The field is only used for asserts, and to track if we really need to do realloc when growing the inode fork data. But the krealloc function already performs this check internally, so there is no need to keep track of the real allocation size. This will free space in the inode fork for keeping a sequence counter of changes to the extent list. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_inode_fork.c | 19 ++++--------------- fs/xfs/libxfs/xfs_inode_fork.h | 1 - fs/xfs/xfs_inode.c | 3 +-- fs/xfs/xfs_inode_item.c | 4 ---- 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c index 183ec0cb8921..dee85b0f8846 100644 --- a/fs/xfs/libxfs/xfs_inode_fork.c +++ b/fs/xfs/libxfs/xfs_inode_fork.c @@ -158,7 +158,6 @@ xfs_init_local_fork( } ifp->if_bytes = size; - ifp->if_real_bytes = real_size; ifp->if_flags &= ~(XFS_IFEXTENTS | XFS_IFBROOT); ifp->if_flags |= XFS_IFINLINE; } @@ -226,7 +225,6 @@ xfs_iformat_extents( return -EFSCORRUPTED; } - ifp->if_real_bytes = 0; ifp->if_bytes = 0; ifp->if_u1.if_root = NULL; ifp->if_height = 0; @@ -317,7 +315,6 @@ xfs_iformat_btree( ifp->if_flags &= ~XFS_IFEXTENTS; ifp->if_flags |= XFS_IFBROOT; - ifp->if_real_bytes = 0; ifp->if_bytes = 0; ifp->if_u1.if_root = NULL; ifp->if_height = 0; @@ -501,7 +498,6 @@ xfs_idata_realloc( */ real_size = roundup(new_size, 4); if (ifp->if_u1.if_data == NULL) { - ASSERT(ifp->if_real_bytes == 0); ifp->if_u1.if_data = kmem_alloc(real_size, KM_SLEEP | KM_NOFS); } else { @@ -509,15 +505,12 @@ xfs_idata_realloc( * Only do the realloc if the underlying size * is really changing. */ - if (ifp->if_real_bytes != real_size) { - ifp->if_u1.if_data = - kmem_realloc(ifp->if_u1.if_data, - real_size, - KM_SLEEP | KM_NOFS); - } + ifp->if_u1.if_data = + kmem_realloc(ifp->if_u1.if_data, + real_size, + KM_SLEEP | KM_NOFS); } } - ifp->if_real_bytes = real_size; ifp->if_bytes = new_size; ASSERT(ifp->if_bytes <= XFS_IFORK_SIZE(ip, whichfork)); } @@ -543,17 +536,13 @@ xfs_idestroy_fork( */ if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) { if (ifp->if_u1.if_data != NULL) { - ASSERT(ifp->if_real_bytes != 0); kmem_free(ifp->if_u1.if_data); ifp->if_u1.if_data = NULL; - ifp->if_real_bytes = 0; } } else if ((ifp->if_flags & XFS_IFEXTENTS) && ifp->if_height) { xfs_iext_destroy(ifp); } - ASSERT(ifp->if_real_bytes == 0); - if (whichfork == XFS_ATTR_FORK) { kmem_zone_free(xfs_ifork_zone, ip->i_afp); ip->i_afp = NULL; diff --git a/fs/xfs/libxfs/xfs_inode_fork.h b/fs/xfs/libxfs/xfs_inode_fork.h index 781b1603df5e..46242052aad0 100644 --- a/fs/xfs/libxfs/xfs_inode_fork.h +++ b/fs/xfs/libxfs/xfs_inode_fork.h @@ -14,7 +14,6 @@ struct xfs_dinode; */ typedef struct xfs_ifork { int if_bytes; /* bytes in if_u1 */ - int if_real_bytes; /* bytes allocated in if_u1 */ struct xfs_btree_block *if_broot; /* file's incore btree root */ short if_broot_bytes; /* bytes allocated for root */ unsigned char if_flags; /* per-fork flags */ diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 5df4de666cc1..b6da446ae946 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -927,7 +927,7 @@ xfs_ialloc( case S_IFLNK: ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS; ip->i_df.if_flags = XFS_IFEXTENTS; - ip->i_df.if_bytes = ip->i_df.if_real_bytes = 0; + ip->i_df.if_bytes = 0; ip->i_df.if_u1.if_root = NULL; break; default: @@ -1877,7 +1877,6 @@ xfs_inactive( * to clean up here. */ if (VFS_I(ip)->i_mode == 0) { - ASSERT(ip->i_df.if_real_bytes == 0); ASSERT(ip->i_df.if_broot_bytes == 0); return; } diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index 2389c34c172d..fa1c4fe2ffbf 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c @@ -194,8 +194,6 @@ xfs_inode_item_format_data_fork( * to be there by xfs_idata_realloc(). */ data_bytes = roundup(ip->i_df.if_bytes, 4); - ASSERT(ip->i_df.if_real_bytes == 0 || - ip->i_df.if_real_bytes >= data_bytes); ASSERT(ip->i_df.if_u1.if_data != NULL); ASSERT(ip->i_d.di_size > 0); xlog_copy_iovec(lv, vecp, XLOG_REG_TYPE_ILOCAL, @@ -280,8 +278,6 @@ xfs_inode_item_format_attr_fork( * to be there by xfs_idata_realloc(). */ data_bytes = roundup(ip->i_afp->if_bytes, 4); - ASSERT(ip->i_afp->if_real_bytes == 0 || - ip->i_afp->if_real_bytes >= data_bytes); ASSERT(ip->i_afp->if_u1.if_data != NULL); xlog_copy_iovec(lv, vecp, XLOG_REG_TYPE_IATTR_LOCAL, ip->i_afp->if_u1.if_data,