Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5188194imu; Tue, 29 Jan 2019 14:31:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN7PsT8asQ05ACLZJqB7C+HK1O4nIsyueuN9uAQBriIdsOOCgWetVLqGpOiNtehk51TYlTTB X-Received: by 2002:a17:902:aa8c:: with SMTP id d12mr28300192plr.25.1548801080304; Tue, 29 Jan 2019 14:31:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548801080; cv=none; d=google.com; s=arc-20160816; b=zdqxiIKtxrqqTrN2kN5qT5Lt5FNvaDc051opO7gvtuKgzMzfqxVtlaM53Wz8YdUN1i B5z8rauuZSyc2uHONtFe3OPpSdElxe4NCp9rMdUWfWG8AyG/x9PkGfuqYfeR53RU3Eh1 JRfiJL5h02HRfKapGaaG045W0jP69lbc4DBpC8YPoB+Jk9t24hjmotX4ZTfeC+WUatkT tupocBOdyQVYEN0MFaKLW5E5x8yTO1GXVgFWxb/nMeTG+zS4/krZcjtPVkr2NZMGddT9 tQPTalO5SXolDSNMdudX/Ul4bi97vrC5lPcWjTHp7ykWDWn0j80l+wJvX682x6f5fQJX k7Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=aps5FwIxeziueABcCIULWl0lThwSnZ/ind67Z6EFwOA=; b=u5gAl7DpjlkHXYRsmjiBEVe1hDoaLlV7OkT3ewLY5E7h48cTWI1NcO4ntaNIf1btDh GsZyoEiscESN5g55kIAy1wyPfwIX3W/uWfDgSo8NnBO72LQ/sYX2wTf651vlVJr7lYUc l5irRCrC/5hk+KnjujMFstPFk1PCEweV4/xGSS+M4Rxqri/SEv33RovnUc+FIKGe6z5Z ape9WwSCPudMoGPgTM5XZHSRswWO/FAsGfsILJ1Q1zv5HFKtyswlHoj6YyFGh9T9Wfmd NKwSCpB3KBg1FB0FEOeuQspySgRM2ZpiR+13P3BPh/uhs1UuqGq+h9gl+v7VEC/AVqZG EszQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@osandov-com.20150623.gappssmtp.com header.s=20150623 header.b=0evcYAP7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 c26si36404417pgm.210.2019.01.29.14.31.04; Tue, 29 Jan 2019 14:31:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@osandov-com.20150623.gappssmtp.com header.s=20150623 header.b=0evcYAP7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729665AbfA2Wa4 (ORCPT + 99 others); Tue, 29 Jan 2019 17:30:56 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:42979 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727545AbfA2Wa4 (ORCPT ); Tue, 29 Jan 2019 17:30:56 -0500 Received: by mail-pg1-f195.google.com with SMTP id d72so9383897pga.9 for ; Tue, 29 Jan 2019 14:30:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=aps5FwIxeziueABcCIULWl0lThwSnZ/ind67Z6EFwOA=; b=0evcYAP7KpRODQF21JXMK9uzho9mL6Xq4e6RoZ6tHVfjgsY9vncictzJ1HOJrjfh07 PLf+UZQaHdNW+Iut+ZhH7wl0IFRuSCnnePSZ2AgHfAIScT70IlrXj6MNmQOziCyQBhcF Q/A6WEOgSGTWz5U8nx12B1YgZLZMEEHaIMTGZholcfebxugTZu9yKxa3BeBilmkK8uNH 8IZ4bmeB4hSWGantCixnsuSC8lx/ZN+g2dKZdyBkuR0H0lofNF8kqjVP9Jgx/hGiGUl2 V+tpNRoMpdnCAXRer6qISqqX2rFisEAQB5hRDVkSeWiYMssR3MbJlFNMbXrVS9BUMCZ5 MNLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=aps5FwIxeziueABcCIULWl0lThwSnZ/ind67Z6EFwOA=; b=TyEfv9lvhm/jrQaJMDC9KUt5ooaqWEYe+WCUIZNPSNZZx5ASTVEafdUHo18nP1YiDy avZUkvzf0P2zofKRuTHge/YfSyNn6/5OD9Q3+BaCu/NCjk196r0wln6FaCRjJtvjal+n 3jDkShP1Utf7uDPqO4bY9W41zm6b4gJ4zkJfVc4vySSw/n+XJP94BONN0CE7II/tdxTw hVrbs5PzQn9O9zXgS1xVXdzRY3kfuK9tFfTgSSQuevGkbvK1tYDaXQWzxJA7SXxGkb9W 2hs37cLfS7bsqje+lHVTkU7JKuRuDWrLvgwNiiVMZFYj2c4BQx3qvDFb/QD4pIF+5Waa CYqw== X-Gm-Message-State: AJcUukcuFSzUEsv50uS2iZNQebypGOeWNSKSXE7fjV9B2LwkwJjCG1/Z /HZm9vSirQestZ/JBnwC953ASw== X-Received: by 2002:a62:a510:: with SMTP id v16mr27847160pfm.18.1548801054736; Tue, 29 Jan 2019 14:30:54 -0800 (PST) Received: from vader ([2620:10d:c090:200::7:d948]) by smtp.gmail.com with ESMTPSA id y6sm42802694pfl.187.2019.01.29.14.30.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Jan 2019 14:30:53 -0800 (PST) Date: Tue, 29 Jan 2019 14:30:53 -0800 From: Omar Sandoval To: Dennis Zhou Cc: David Sterba , Josef Bacik , Chris Mason , Nick Terrell , kernel-team@fb.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 01/11] btrfs: add macros for compression type and level Message-ID: <20190129223053.GB22926@vader> References: <20190128212437.11597-1-dennis@kernel.org> <20190128212437.11597-2-dennis@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190128212437.11597-2-dennis@kernel.org> User-Agent: Mutt/1.11.2 (2019-01-07) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 28, 2019 at 04:24:27PM -0500, Dennis Zhou wrote: > It is very easy to miss places that rely on a certain bitshifting for > decyphering the type_level overloading. Make macros handle this instead. > > Signed-off-by: Dennis Zhou > --- > fs/btrfs/compression.c | 2 +- > fs/btrfs/compression.h | 3 +++ > fs/btrfs/zlib.c | 2 +- > 3 files changed, 5 insertions(+), 2 deletions(-) > > diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c > index 548057630b69..586f95ac0aea 100644 > --- a/fs/btrfs/compression.c > +++ b/fs/btrfs/compression.c > @@ -1036,9 +1036,9 @@ int btrfs_compress_pages(unsigned int type_level, struct address_space *mapping, > unsigned long *total_in, > unsigned long *total_out) > { > + int type = BTRFS_COMPRESS_TYPE(type_level); > struct list_head *workspace; > int ret; > - int type = type_level & 0xF; > > workspace = find_workspace(type); > > diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h > index ddda9b80bf20..69a9197dadc3 100644 > --- a/fs/btrfs/compression.h > +++ b/fs/btrfs/compression.h > @@ -25,6 +25,9 @@ > > #define BTRFS_ZLIB_DEFAULT_LEVEL 3 > > +#define BTRFS_COMPRESS_TYPE(type_level) (type_level & 0xF) > +#define BTRFS_COMPRESS_LEVEL(type_level) ((type_level & 0xF0) >> 4) Nit: these can be inline functions rather than macros. > struct compressed_bio { > /* number of bios pending for this compressed extent */ > refcount_t pending_bios; > diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c > index 970ff3e35bb3..1480b3eee306 100644 > --- a/fs/btrfs/zlib.c > +++ b/fs/btrfs/zlib.c > @@ -393,7 +393,7 @@ static int zlib_decompress(struct list_head *ws, unsigned char *data_in, > static void zlib_set_level(struct list_head *ws, unsigned int type) > { > struct workspace *workspace = list_entry(ws, struct workspace, list); > - unsigned level = (type & 0xF0) >> 4; > + unsigned int level = BTRFS_COMPRESS_LEVEL(type); > > if (level > 9) > level = 9; > -- > 2.17.1 >