From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8A78C433F5 for ; Tue, 19 Apr 2022 15:02:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350579AbiDSPFd (ORCPT ); Tue, 19 Apr 2022 11:05:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347789AbiDSPFc (ORCPT ); Tue, 19 Apr 2022 11:05:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58BA52DD4A for ; Tue, 19 Apr 2022 08:02:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EA17A615BA for ; Tue, 19 Apr 2022 15:02:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0876C385A7; Tue, 19 Apr 2022 15:02:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650380568; bh=2O/9wBKMA78Y5AbCI5M7UzLx/Sb0v4cSt1VGyQI0YaQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CTc7AQ/97Hn7PLpJHT635XIko/GmZce2dko7RfAMYKAQJYriHRdgQlYjOZQJy/7Ar sdzkl+JvGfksTlUMSPB7LscHbK5Aolh7zZH0n6HXcPKuoDoMUz9yTcSBJ9BurF+RS2 rVvKc4iHYrmB0Z3emxeJKuL0V2DLB2PIZxUJnSeWwfumMiTCBiC3URzhDQdIhVZLfT 2LNW19CKGMTiushuzm6wXbsJNQT+wd++xVbBFhPNrHhf3phnuWGCWAq4xu6s3v9NW6 7u0XnlRbVH/Z3S0RAWHovCZj2H8f4ToQR03RxAttCHicYvr8p1irn9e5tsHl72snvV Va35RksYlBXvQ== Date: Tue, 19 Apr 2022 16:02:45 +0100 From: Filipe Manana To: Chung-Chiang Cheng Cc: dsterba@suse.com, josef@toxicpanda.com, clm@fb.com, linux-btrfs@vger.kernel.org, shepjeng@gmail.com, kernel@cccheng.net Subject: Re: [PATCH 1/2] btrfs: export a helper for compression hard check Message-ID: References: <20220415080406.234967-1-cccheng@synology.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220415080406.234967-1-cccheng@synology.com> Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On Fri, Apr 15, 2022 at 04:04:05PM +0800, Chung-Chiang Cheng wrote: > inode_can_compress will be used outside of inode.c to check the > availability of setting compression flag by xattr. This patch moves > this function as an internal helper and renames it to > btrfs_inode_can_compress. Btw, the idea was to export the function in a patch following the bug fix patch. That would imply temporarily duplicating the validation logic in the bug fix patch, and then the followup patch would export inode_can_compress() and make inode.c and props.c use it. That makes the backport to stable easier. Alternatively, IMO, since it's such a short and trivial change, both patches could be combined in a single patch. Not everyone might agree with that however. Either way, I'm fine with it, thanks. Reviewed-by: Filipe Manana > > Signed-off-by: Chung-Chiang Cheng > --- > fs/btrfs/btrfs_inode.h | 11 +++++++++++ > fs/btrfs/inode.c | 15 ++------------- > 2 files changed, 13 insertions(+), 13 deletions(-) > > diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h > index 47e72d72f7d0..32131a5d321b 100644 > --- a/fs/btrfs/btrfs_inode.h > +++ b/fs/btrfs/btrfs_inode.h > @@ -384,6 +384,17 @@ static inline bool btrfs_inode_in_log(struct btrfs_inode *inode, u64 generation) > return ret; > } > > +/* > + * Check if the inode has flags compatible with compression > + */ > +static inline bool btrfs_inode_can_compress(const struct btrfs_inode *inode) > +{ > + if (inode->flags & BTRFS_INODE_NODATACOW || > + inode->flags & BTRFS_INODE_NODATASUM) > + return false; > + return true; > +} > + > struct btrfs_dio_private { > struct inode *inode; > > diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c > index 17d5557f98ec..99725e5508f9 100644 > --- a/fs/btrfs/inode.c > +++ b/fs/btrfs/inode.c > @@ -480,17 +480,6 @@ static noinline int add_async_extent(struct async_chunk *cow, > return 0; > } > > -/* > - * Check if the inode has flags compatible with compression > - */ > -static inline bool inode_can_compress(struct btrfs_inode *inode) > -{ > - if (inode->flags & BTRFS_INODE_NODATACOW || > - inode->flags & BTRFS_INODE_NODATASUM) > - return false; > - return true; > -} > - > /* > * Check if the inode needs to be submitted to compression, based on mount > * options, defragmentation, properties or heuristics. > @@ -500,7 +489,7 @@ static inline int inode_need_compress(struct btrfs_inode *inode, u64 start, > { > struct btrfs_fs_info *fs_info = inode->root->fs_info; > > - if (!inode_can_compress(inode)) { > + if (!btrfs_inode_can_compress(inode)) { > WARN(IS_ENABLED(CONFIG_BTRFS_DEBUG), > KERN_ERR "BTRFS: unexpected compression for ino %llu\n", > btrfs_ino(inode)); > @@ -2020,7 +2009,7 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page > (zoned && btrfs_is_data_reloc_root(inode->root))); > ret = run_delalloc_nocow(inode, locked_page, start, end, > page_started, nr_written); > - } else if (!inode_can_compress(inode) || > + } else if (!btrfs_inode_can_compress(inode) || > !inode_need_compress(inode, start, end)) { > if (zoned) > ret = run_delalloc_zoned(inode, locked_page, start, end, > -- > 2.34.1 >