From patchwork Mon Sep 4 17:45:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 9937483 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A7777603F9 for ; Mon, 4 Sep 2017 17:46:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9205B287E8 for ; Mon, 4 Sep 2017 17:46:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8701F287F2; Mon, 4 Sep 2017 17:46:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BFB0287F5 for ; Mon, 4 Sep 2017 17:46:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753912AbdIDRpk (ORCPT ); Mon, 4 Sep 2017 13:45:40 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:26522 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753885AbdIDRpk (ORCPT ); Mon, 4 Sep 2017 13:45:40 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v84Hjb7g020928 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 Sep 2017 17:45:37 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v84Hjas6011199 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 Sep 2017 17:45:37 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v84HjaXu021754; Mon, 4 Sep 2017 17:45:36 GMT Received: from localhost (/73.25.142.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 04 Sep 2017 10:45:36 -0700 Date: Mon, 4 Sep 2017 10:45:35 -0700 From: "Darrick J. Wong" To: Eric Sandeen Cc: xfs Subject: [PATCH v2 2/2] mkfs: pass a custom cowextsize into the created filesystem Message-ID: <20170904174535.GI4671@magnolia> References: <20170901164035.GF3775@magnolia> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170901164035.GF3775@magnolia> User-Agent: Mutt/1.5.24 (2015-08-30) X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Create a -d option to mkfs.xfs that enables administrators to set the CoW extent size hint on the created files. Signed-off-by: Darrick J. Wong --- v2: port flags2diflags from the kernel --- libxfs/util.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++-- man/man8/mkfs.xfs.8 | 7 ++++++ mkfs/xfs_mkfs.c | 20 ++++++++++++++++ 3 files changed, 89 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/libxfs/util.c b/libxfs/util.c index 0e2f29e..b600594 100644 --- a/libxfs/util.c +++ b/libxfs/util.c @@ -175,6 +175,64 @@ libxfs_trans_ichgtime( } } +STATIC uint16_t +xfs_flags2diflags( + struct xfs_inode *ip, + unsigned int xflags) +{ + /* can't set PREALLOC this way, just preserve it */ + uint16_t di_flags = + (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC); + + if (xflags & FS_XFLAG_IMMUTABLE) + di_flags |= XFS_DIFLAG_IMMUTABLE; + if (xflags & FS_XFLAG_APPEND) + di_flags |= XFS_DIFLAG_APPEND; + if (xflags & FS_XFLAG_SYNC) + di_flags |= XFS_DIFLAG_SYNC; + if (xflags & FS_XFLAG_NOATIME) + di_flags |= XFS_DIFLAG_NOATIME; + if (xflags & FS_XFLAG_NODUMP) + di_flags |= XFS_DIFLAG_NODUMP; + if (xflags & FS_XFLAG_NODEFRAG) + di_flags |= XFS_DIFLAG_NODEFRAG; + if (xflags & FS_XFLAG_FILESTREAM) + di_flags |= XFS_DIFLAG_FILESTREAM; + if (S_ISDIR(VFS_I(ip)->i_mode)) { + if (xflags & FS_XFLAG_RTINHERIT) + di_flags |= XFS_DIFLAG_RTINHERIT; + if (xflags & FS_XFLAG_NOSYMLINKS) + di_flags |= XFS_DIFLAG_NOSYMLINKS; + if (xflags & FS_XFLAG_EXTSZINHERIT) + di_flags |= XFS_DIFLAG_EXTSZINHERIT; + if (xflags & FS_XFLAG_PROJINHERIT) + di_flags |= XFS_DIFLAG_PROJINHERIT; + } else if (S_ISREG(VFS_I(ip)->i_mode)) { + if (xflags & FS_XFLAG_REALTIME) + di_flags |= XFS_DIFLAG_REALTIME; + if (xflags & FS_XFLAG_EXTSIZE) + di_flags |= XFS_DIFLAG_EXTSIZE; + } + + return di_flags; +} + +STATIC uint64_t +xfs_flags2diflags2( + struct xfs_inode *ip, + unsigned int xflags) +{ + uint64_t di_flags2 = + (ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK); + + if (xflags & FS_XFLAG_DAX) + di_flags2 |= XFS_DIFLAG2_DAX; + if (xflags & FS_XFLAG_COWEXTSIZE) + di_flags2 |= XFS_DIFLAG2_COWEXTSIZE; + + return di_flags2; +} + /* * Allocate an inode on disk and return a copy of its in-core version. * Set mode, nlink, and rdev appropriately within the inode. @@ -254,15 +312,17 @@ libxfs_ialloc( ip->i_d.di_extsize = pip ? 0 : fsx->fsx_extsize; ip->i_d.di_dmevmask = 0; ip->i_d.di_dmstate = 0; - ip->i_d.di_flags = pip ? 0 : fsx->fsx_xflags; + ip->i_d.di_flags = pip ? 0 : xfs_flags2diflags(ip, fsx->fsx_xflags); if (ip->i_d.di_version == 3) { ASSERT(ip->i_d.di_ino == ino); ASSERT(uuid_equal(&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid)); VFS_I(ip)->i_version = 1; - ip->i_d.di_flags2 = 0; + ip->i_d.di_flags2 = pip ? 0 : xfs_flags2diflags2(ip, + fsx->fsx_xflags); ip->i_d.di_crtime.t_sec = (int32_t)VFS_I(ip)->i_mtime.tv_sec; ip->i_d.di_crtime.t_nsec = (int32_t)VFS_I(ip)->i_mtime.tv_nsec; + ip->i_d.di_cowextsize = pip ? 0 : fsx->fsx_cowextsize; } flags = XFS_ILOG_CORE; diff --git a/man/man8/mkfs.xfs.8 b/man/man8/mkfs.xfs.8 index 33831c9..bbbe1c5 100644 --- a/man/man8/mkfs.xfs.8 +++ b/man/man8/mkfs.xfs.8 @@ -279,6 +279,13 @@ and .B agsize suboptions are mutually exclusive. .TP +.BI cowextsize= value +Set the copy-on-write extent size hint on all inodes created by +.BR mkfs.xfs "." +The value must be provided in units of filesystem blocks. +If the value is zero, the default value (currently 32 blocks) will be used. +Directories will pass on this hint to newly created children. +.TP .BI name= value This can be used to specify the name of the special file containing the filesystem. In this case, the log section must be specified as diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 024cb02..ea0a317 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -187,6 +187,8 @@ struct opt_params dopts = { "projinherit", #define D_EXTSZINHERIT 14 "extszinherit", +#define D_COWEXTSIZE 15 + "cowextsize", NULL }, .subopt_params = { @@ -303,6 +305,12 @@ struct opt_params dopts = { .maxval = UINT_MAX, .defaultval = SUBOPT_NEEDS_VAL, }, + { .index = D_COWEXTSIZE, + .conflicts = { LAST_CONFLICT }, + .minval = 0, + .maxval = UINT_MAX, + .defaultval = SUBOPT_NEEDS_VAL, + }, }, }; @@ -1638,6 +1646,13 @@ main( fsx.fsx_xflags |= XFS_DIFLAG_EXTSZINHERIT; break; + case D_COWEXTSIZE: + fsx.fsx_cowextsize = getnum(value, + &dopts, + D_COWEXTSIZE); + fsx.fsx_xflags |= + FS_XFLAG_COWEXTSIZE; + break; default: unknown('d', value); } @@ -2142,6 +2157,11 @@ _("reflink not supported without CRC support\n")); sb_feat.reflink = false; } + if ((fsx.fsx_xflags & FS_XFLAG_COWEXTSIZE) && !sb_feat.reflink) { + fprintf(stderr, +_("cowextsize not supported without reflink support\n")); + usage(); + } if (nsflag || nlflag) { if (dirblocksize < blocksize ||