Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7316029imu; Thu, 31 Jan 2019 08:19:29 -0800 (PST) X-Google-Smtp-Source: ALg8bN7HBnpwfX2EanGbjNoMRMk+n5qJKi3hSPu31T+Kyc2DJbEMe7V7Qmd+rgrgFW7lEi4waINL X-Received: by 2002:a62:3541:: with SMTP id c62mr35195848pfa.19.1548951569115; Thu, 31 Jan 2019 08:19:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548951569; cv=none; d=google.com; s=arc-20160816; b=unNHNlAWg2HZwQIoRobvCykHolvS8gqYrTTHw5Nf0TI8Q7Vy/gF4fC8vE3iPCLJgZ+ v9EUh7TFTyY2jOREJaQmrFjP5arKzye0zWvrJvksxX/IowNQbnL6g7LsRuPDjnLLvtZi 05CbyWaXPHcJZYMb7yPMiS/WHNd+LJ52cUEBxKtL+OJpUnB61AerWajlckEAmHKk8TEp eKUt4Rdwof4xjWPhxO38BxwlsO2IkaoiJS91UOL5dq9SZNOr6NQOkxUWoI25Pi+SHor9 m2XvHwRbFQI/vMv5EgJituBYX7/7kxt+H1NPhJnr34f1fhlogoJIa9Ic7fyA0QMJZzRN 4OWg== 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; bh=XkwLXcoRkVmgZPav9GtqCHyR/6Nz/q92jkOChgvBD2k=; b=aEAqA3rOnsxT22BJ8RWguyzwWeUy/VkXgvfEmItaRGzrj7fcTyZk5IFrXIXIx2SsTs jkt91yvL8F3dz2EVMqtVaHMWOoUpmBu2glOIVontDXkIQfMnL6pv7/CVog7D0ZKmiN7r LN+uBNiWeoPrfr5HwaaodaebqVMUPGURY/SDp9rBC7dhm6RzYDYDqhxX43muAXadaeK1 IvAKFxjx5lXv4+ZG45FtlCxphg/J2UI7I9wIt6CVzvPpa4UlTDpKaBTgLKHt5pS5ZN1j Lz8GDd1z85KjPuPdeq+sr5dPQAQgnePzHK4t9kVoxLMucv1kfMi73Y1kbyOjVn24/yvc 6dvw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h9si5060793plb.180.2019.01.31.08.19.14; Thu, 31 Jan 2019 08:19:29 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388317AbfAaQR2 (ORCPT + 99 others); Thu, 31 Jan 2019 11:17:28 -0500 Received: from mail-yw1-f68.google.com ([209.85.161.68]:42672 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388155AbfAaQR2 (ORCPT ); Thu, 31 Jan 2019 11:17:28 -0500 Received: by mail-yw1-f68.google.com with SMTP id x2so1471783ywc.9; Thu, 31 Jan 2019 08:17:27 -0800 (PST) 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=XkwLXcoRkVmgZPav9GtqCHyR/6Nz/q92jkOChgvBD2k=; b=L3iLjIbVbwFRaHukD53iUWOTuEaiUyVjOJ6r7gMQzQ+kv4ePOgfR846Iwfxgtpq5av AUIm4Y01r+A2jj4fe37uLSlq6uslp9SpY6q0dRxKlsXMC77H1PsJQwncd4cw97QENRCn bTQTVXKswZ+lB/MgAmwkIHWWuyHa6TyjYji1EaAi0C+dnYH25VJsh4aVWJeMKYG4Am/D wuXIDYqmBC+Oxs385isSo11A9rsjhMdTkWNabkxdJ9orkUT/bv8ceBZCIkb7EWhtgo3p 0yeY849XHoHhQLJdmM8Naze9sCXNnoJ62OqQ8qq48Ko2pI67h19lOkwlO33NfeVn3gA1 5nuQ== X-Gm-Message-State: AJcUukeKplxDxO8AG/PkUcJ8qTNfyEXV6sc7M1P//3tDFncn+iXgHbvQ uy8C0SpjT33/o47Jn7zYECk= X-Received: by 2002:a81:d303:: with SMTP id y3mr34241577ywi.502.1548951447420; Thu, 31 Jan 2019 08:17:27 -0800 (PST) Received: from dennisz-mbp ([2620:10d:c091:200::6:84c2]) by smtp.gmail.com with ESMTPSA id o14sm3425503ywo.52.2019.01.31.08.17.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 08:17:26 -0800 (PST) Date: Thu, 31 Jan 2019 11:17:24 -0500 From: Dennis Zhou To: David Sterba Cc: Dennis Zhou , David Sterba , Josef Bacik , Chris Mason , Omar Sandoval , 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: <20190131161724.GA93554@dennisz-mbp> References: <20190128212437.11597-1-dennis@kernel.org> <20190128212437.11597-2-dennis@kernel.org> <20190131160010.GK2900@twin.jikos.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190131160010.GK2900@twin.jikos.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 31, 2019 at 05:00:10PM +0100, David Sterba wrote: > 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. > > This encoding was a simple way to introduce the combined type and level > for zlib and it could certainly be improved. Either we'll use helpers > like you suggest or add a new structure that contains type and level as > members. That way we'd see where the level still matters and where the > just the type is ok. > > I haven't checked how much intrusive this would be, so that's for later > consideration. Some indirection can be removed for the .set_level > callbacks as it does not necessarily need to be a function so I'm > expecting that the code around that would be touched anyway. The only user of type_level is btrfs_compress_pages(). I do make an extra call to .set_level() there just to be safe, but that can be taken out as it should be correctly set from when we mounted. I envisioned .set_level() to be called when setting the compression level of the mount. This can be used in the same place if we were to add per-file compression levels too. I mention later, but an important part of .set_level() is to repurpose the meaning of 0 from meaning use the default to meaning use any workspace available. Thanks, Dennis