From patchwork Tue Sep 1 19:01:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 7106481 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DE6AA9F372 for ; Tue, 1 Sep 2015 19:02:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E50642060C for ; Tue, 1 Sep 2015 19:02:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 098DA20609 for ; Tue, 1 Sep 2015 19:02:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753495AbbIATCF (ORCPT ); Tue, 1 Sep 2015 15:02:05 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:32945 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750889AbbIATCE (ORCPT ); Tue, 1 Sep 2015 15:02:04 -0400 Received: by padan5 with SMTP id an5so4698633pad.0 for ; Tue, 01 Sep 2015 12:02:04 -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=DTHlH3soFPF8u+ne2ahzGDRjxCeJ7RyZvPFIeBwisDk=; b=ACN7SJQbd9LgK5/xB/8BvrHlhk180wMqU/g54oUtRXA7Tgr8S2x2DhVplnCz4Bp6Ey ca7bfUAjm0Pm8eBOhx4AVEIgUAjF6UdBp3jNJmMRwy4c9KZGqIwc6bknh81wI3uHwO8G pBIG9PAkigA1Y2DO5t/pPYZMbsXGOZVhcF8YMf4ANZrzdzLhfAgBOPozhGCOwUXUbnaS Aabhh/QEkuWGeE5vIaD/lZ8t7ugzp6jz8hL58unvHygEMHORFXPcGxriE/DPfMxyaPam nlgFTebPPqdke2+B+QwKsrbIqKuWGNOChPbRwz7cB9LGCgq5VAt8oSWZ7FZlDAxvVaeM F1TQ== X-Gm-Message-State: ALoCoQlgWmixrkGbrqnufHcHl/jdwQTZXQ1PcGQra/8ySLFpnqDnSaWvsyCZ9BpgnJNtJsFfjwSr X-Received: by 10.68.192.225 with SMTP id hj1mr49713384pbc.67.1441134118478; Tue, 01 Sep 2015 12:01:58 -0700 (PDT) Received: from huxley.thefacebook.com ([2620:10d:c090:200::4:58ae]) by smtp.gmail.com with ESMTPSA id cy10sm19029394pdb.13.2015.09.01.12.01.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Sep 2015 12:01:57 -0700 (PDT) From: Omar Sandoval To: linux-btrfs@vger.kernel.org Cc: Omar Sandoval Subject: [PATCH 2/6] Btrfs: add helpers for read-only compat bits Date: Tue, 1 Sep 2015 12:01:37 -0700 Message-Id: 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 From: Omar Sandoval 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. Signed-off-by: Omar Sandoval Reviewed-by: Josef Bacik --- 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.