From patchwork Mon Nov 23 12:56:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 7680941 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 82F4A9F54F for ; Mon, 23 Nov 2015 12:56:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B7A32206FC for ; Mon, 23 Nov 2015 12:56:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D5CBC206F9 for ; Mon, 23 Nov 2015 12:56:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753440AbbKWM42 (ORCPT ); Mon, 23 Nov 2015 07:56:28 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:22801 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753325AbbKWM40 (ORCPT ); Mon, 23 Nov 2015 07:56:26 -0500 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id tANCuNI0028777 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 23 Nov 2015 12:56:24 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id tANCuNA1008488 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 23 Nov 2015 12:56:23 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0122.oracle.com (8.13.8/8.13.8) with ESMTP id tANCuNhe025112; Mon, 23 Nov 2015 12:56:23 GMT Received: from arch2.sg.oracle.com (/10.186.101.159) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 23 Nov 2015 04:56:22 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH v2 3/5] btrfs-progs: kernel based default features for mkfs Date: Mon, 23 Nov 2015 20:56:16 +0800 Message-Id: <1448283378-10579-4-git-send-email-anand.jain@oracle.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1448283378-10579-1-git-send-email-anand.jain@oracle.com> References: <1448283378-10579-1-git-send-email-anand.jain@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Mkfs from latest btrfs-progs will enable latest default features, and if the kernel is down-rev and does not support a latest default feature then mount fails, as expected. This patch disables default features based on the running kernel. Signed-off-by: Anand Jain --- v2: Check if sysfs tells what features are supported mkfs.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mkfs.c b/mkfs.c index a5802f7..4f46ad9 100644 --- a/mkfs.c +++ b/mkfs.c @@ -1357,10 +1357,24 @@ int main(int ac, char **av) int dev_cnt = 0; int saved_optind; char fs_uuid[BTRFS_UUID_UNPARSED_SIZE] = { 0 }; - u64 features = BTRFS_MKFS_DEFAULT_FEATURES; + u64 features; struct mkfs_allocation allocation = { 0 }; struct btrfs_mkfs_config mkfs_cfg; + /* + * If kernel could tell supported features by sysfs then use it, + * if not, then set it by static kernel version, if the this also + * fails then default to the progs default, which is set as per + * BTRFS_MKFS_DEFAULT_FEATURES + */ + if (btrfs_features_allowed_by_sysfs(&features)) + features = btrfs_features_allowed_by_kernel(); + + if (features) + features &= BTRFS_MKFS_DEFAULT_FEATURES; + else + features = BTRFS_MKFS_DEFAULT_FEATURES; + while(1) { int c; static const struct option long_options[] = {