From patchwork Thu Sep 3 19:44:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 7118791 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 35F13BEEC1 for ; Thu, 3 Sep 2015 19:45:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 54A3E207CD for ; Thu, 3 Sep 2015 19:44:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6F23B207CA for ; Thu, 3 Sep 2015 19:44:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756844AbbICTol (ORCPT ); Thu, 3 Sep 2015 15:44:41 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:32895 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756509AbbICToj (ORCPT ); Thu, 3 Sep 2015 15:44:39 -0400 Received: by pacex6 with SMTP id ex6so20916pac.0 for ; Thu, 03 Sep 2015 12:44:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=GFVxyJb8Ulha+BfqxUK3gS8duWJSJJUd7XKWrT8BK6M=; b=flIPbvE4PgpTKQZQITsgbYkVGnvELzBoDS1QmS7u7+wlclZDCvwg55jN3+5CdjWgkQ zsf+lPAYSv4Qq3t2LF5SXRzNy08Buso2//Ige8/48NTNNSg//yHXWYrS3KNZTHL47whl 3bI/3MXWIKTg1mCEbmIUUAeGSHUn+nGcGR58msD/3ynqBXBhxhC1LJPpwMPhG05vCNE4 TNtkMHNZo2BKan2oNq15vnhz2sLYC/UwGkwHsU5NKWcwJ7fELWevhjOkkBMmkG6qGP6b P+v1ZmIhrKZFMPqwnDpw7H0UjbuPpbSLtcH9x4ktG5l2Wolk1oj1gzrv6NcRflQq+/jE kxiw== X-Gm-Message-State: ALoCoQkoybDzlwWIWjjEkSXnc79D+QfJ7A63aRqSRHlJlOhy38EfWS9eE1AYGCN0Q9vczHNMkgjo X-Received: by 10.66.219.102 with SMTP id pn6mr71172668pac.80.1441309478847; Thu, 03 Sep 2015 12:44:38 -0700 (PDT) Received: from huxley.thefacebook.com ([199.201.64.133]) by smtp.gmail.com with ESMTPSA id y9sm14682638pdp.17.2015.09.03.12.44.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Sep 2015 12:44:38 -0700 (PDT) From: Omar Sandoval X-Google-Original-From: Omar Sandoval To: linux-btrfs@vger.kernel.org Cc: Omar Sandoval Subject: [PATCH v2 3/9] Btrfs: add helpers for read-only compat bits Date: Thu, 3 Sep 2015 12:44:21 -0700 Message-Id: <499ed35312e2bb8f12e6931b3f8a8c675561dd96.1441309178.git.osandov@fb.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We're finally going to add one of these for the free space tree, so let's add the same nice helpers that we have for the incompat bits. Reviewed-by: Josef Bacik Signed-off-by: Omar Sandoval --- fs/btrfs/ctree.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index aac314e14188..10388ac041b6 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -4113,6 +4113,40 @@ static inline int __btrfs_fs_incompat(struct btrfs_fs_info *fs_info, u64 flag) return !!(btrfs_super_incompat_flags(disk_super) & flag); } +#define btrfs_set_fs_compat_ro(__fs_info, opt) \ + __btrfs_set_fs_compat_ro((__fs_info), BTRFS_FEATURE_COMPAT_RO_##opt) + +static inline void __btrfs_set_fs_compat_ro(struct btrfs_fs_info *fs_info, + u64 flag) +{ + struct btrfs_super_block *disk_super; + u64 features; + + disk_super = fs_info->super_copy; + features = btrfs_super_compat_ro_flags(disk_super); + if (!(features & flag)) { + spin_lock(&fs_info->super_lock); + features = btrfs_super_compat_ro_flags(disk_super); + if (!(features & flag)) { + features |= flag; + btrfs_set_super_compat_ro_flags(disk_super, features); + btrfs_info(fs_info, "setting %llu ro feature flag", + flag); + } + spin_unlock(&fs_info->super_lock); + } +} + +#define btrfs_fs_compat_ro(fs_info, opt) \ + __btrfs_fs_compat_ro((fs_info), BTRFS_FEATURE_COMPAT_RO_##opt) + +static inline int __btrfs_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag) +{ + struct btrfs_super_block *disk_super; + disk_super = fs_info->super_copy; + return !!(btrfs_super_compat_ro_flags(disk_super) & flag); +} + /* * Call btrfs_abort_transaction as early as possible when an error condition is * detected, that way the exact line number is reported.