From patchwork Mon Aug 17 22:58:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11719601 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 17F04722 for ; Mon, 17 Aug 2020 23:01:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F25F920709 for ; Mon, 17 Aug 2020 23:01:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="KvgD7Kw7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726870AbgHQXBJ (ORCPT ); Mon, 17 Aug 2020 19:01:09 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:42124 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728239AbgHQXBE (ORCPT ); Mon, 17 Aug 2020 19:01:04 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMurMV136090; Mon, 17 Aug 2020 23:01:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=+A77UEr30xuu2QvGIc+rnlnj+ZkE4JZoDmNFQK0cYOk=; b=KvgD7Kw7pJklgwc33n38L8PCHcZmAiNbfMhM7LytBCgPHzvzck5BUQM5K2klZEhBAroT m8TsxH9CzNskQRUTvXH2rUqJi3FUjWmy6i4ZI5Sj4VbJ4cIWB+RNPVqNt7Ny/3l/KFcF H5U01rVKl5XEnQHTvYoAqAH4ry99nmjqugdxul/wQPufZo5Rlf7ZJzpQKgmryJ1bUHOB rZubf+nAyOvPPawpqaktd9U0XgNXsOuLTY7n2CdFtlz8QlBi6BwUCpirLr6OcjcOi45A Kl/w7hTDU55Xw4/6VbPRN7lIjh3RIS7bv73LkJ/6tUEM4Hg8CNsPRLOWGgKwo835nPr6 Ow== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 32x8bn1g5x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Aug 2020 23:01:02 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMw9j2084770; Mon, 17 Aug 2020 22:59:02 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 32xsfr598c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Aug 2020 22:59:01 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07HMx0Jc014074; Mon, 17 Aug 2020 22:59:00 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Aug 2020 15:59:00 -0700 Subject: [PATCH 01/18] libxfs: create a real struct timespec64 From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 17 Aug 2020 15:58:59 -0700 Message-ID: <159770513983.3958786.6208814640295936803.stgit@magnolia> In-Reply-To: <159770513155.3958786.16108819726679724438.stgit@magnolia> References: <159770513155.3958786.16108819726679724438.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 spamscore=0 suspectscore=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 clxscore=1015 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Create a real struct timespec64 that supports 64-bit seconds counts. The C library struct timespec doesn't support this on 32-bit architectures and we cannot lose the upper bits in the incore inode. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- include/libxfs.h | 1 - include/xfs_inode.h | 22 +++++++++++----------- libxfs/libxfs_api_defs.h | 7 +++++++ libxfs/libxfs_priv.h | 2 -- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/include/libxfs.h b/include/libxfs.h index b9370139becc..2667d3b77084 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -41,7 +41,6 @@ struct iomap; #define __round_mask(x, y) ((__typeof__(x))((y)-1)) #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) #define unlikely(x) (x) -#define timespec64 timespec /* * This mirrors the kernel include for xfs_buf.h - it's implicitly included in diff --git a/include/xfs_inode.h b/include/xfs_inode.h index 588d8c7258f4..12676cb30bf2 100644 --- a/include/xfs_inode.h +++ b/include/xfs_inode.h @@ -31,17 +31,17 @@ struct xfs_inode_log_item; * metadata. */ struct inode { - mode_t i_mode; - uint32_t i_uid; - uint32_t i_gid; - uint32_t i_nlink; - xfs_dev_t i_rdev; /* This actually holds xfs_dev_t */ - unsigned long i_state; /* Not actually used in userspace */ - uint32_t i_generation; - uint64_t i_version; - struct timespec i_atime; - struct timespec i_mtime; - struct timespec i_ctime; + mode_t i_mode; + uint32_t i_uid; + uint32_t i_gid; + uint32_t i_nlink; + xfs_dev_t i_rdev; /* This actually holds xfs_dev_t */ + unsigned long i_state; /* Not actually used in userspace */ + uint32_t i_generation; + uint64_t i_version; + struct timespec64 i_atime; + struct timespec64 i_mtime; + struct timespec64 i_ctime; }; static inline uint32_t i_uid_read(struct inode *inode) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index a3eef04db419..99bc5b936da7 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -7,6 +7,13 @@ #ifndef __LIBXFS_API_DEFS_H__ #define __LIBXFS_API_DEFS_H__ +typedef long long int time64_t; + +struct timespec64 { + time64_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; + /* * This file defines all the kernel based functions we expose to userspace * via the libxfs_* namespace. This is kept in a separate header file so diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index eb485e7375b1..808b78180b06 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -64,8 +64,6 @@ extern kmem_zone_t *xfs_buf_zone; extern kmem_zone_t *xfs_inode_zone; extern kmem_zone_t *xfs_trans_zone; -#define timespec64 timespec - /* fake up iomap, (not) used in xfs_bmap.[ch] */ #define IOMAP_F_SHARED 0x04 #define xfs_bmbt_to_iomap(a, b, c, d) ((void) 0) From patchwork Mon Aug 17 22:59:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11719553 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F33C1618 for ; Mon, 17 Aug 2020 22:59:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DBAD32072D for ; Mon, 17 Aug 2020 22:59:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="OjZYP7w2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728083AbgHQW7O (ORCPT ); Mon, 17 Aug 2020 18:59:14 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:52056 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727966AbgHQW7K (ORCPT ); Mon, 17 Aug 2020 18:59:10 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMvu3o052952; Mon, 17 Aug 2020 22:59:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=5/vhehjIWMNnKaMyo8ThWFz415yix7tfO2/Olnh/8k8=; b=OjZYP7w2DVFR4b93R4P3fS6RVgDJ8vkGnDkRtqaEsULvE5eSUumgkwsJursOhYojltG+ ILekVLt5jM7OjLk9sxEus2r24Zmih21+J78cT/9rEkt3OqupuE9kmKEmWvj0pz9hWkW2 KRC56swdjtL1YatqoZ4D6w/Vmdn6969YApZMHtHMOlCyhM1cYudsL4OzyxAjtKpnFAah ynFujkn5gmDie+y4Mc3NgM3+erYqEGZRKTpTUc7fFdFJ91Oec1OhjvKres6kXdvfZR6P /ZHBHTWMsEE4Qqqw54b9foDzMk2DuOUE3lkEPDtcNAB8dJvuiNzlASToUHdDf1zEmmHg ag== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 32x7nm9jqs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Aug 2020 22:59:08 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMwAXU084875; Mon, 17 Aug 2020 22:59:08 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 32xsfr59as-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Aug 2020 22:59:07 +0000 Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07HMx7VW025401; Mon, 17 Aug 2020 22:59:07 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Aug 2020 15:59:06 -0700 Subject: [PATCH 02/18] xfs: explicitly define inode timestamp range From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 17 Aug 2020 15:59:06 -0700 Message-ID: <159770514598.3958786.15730645159608118691.stgit@magnolia> In-Reply-To: <159770513155.3958786.16108819726679724438.stgit@magnolia> References: <159770513155.3958786.16108819726679724438.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 spamscore=0 suspectscore=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 impostorscore=0 priorityscore=1501 adultscore=0 mlxscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 phishscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Formally define the inode timestamp ranges that existing filesystems support, and switch the vfs timetamp ranges to use it. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- libxfs/libxfs_api_defs.h | 4 ++++ libxfs/xfs_format.h | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 99bc5b936da7..4ee02473df0d 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -14,6 +14,10 @@ struct timespec64 { long tv_nsec; /* nanoseconds */ }; +#define U32_MAX ((uint32_t)~0U) +#define S32_MAX ((int32_t)(U32_MAX >> 1)) +#define S32_MIN ((int32_t)(-S32_MAX - 1)) + /* * This file defines all the kernel based functions we expose to userspace * via the libxfs_* namespace. This is kept in a separate header file so diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index 88cbcb7950c3..f2a851e49ec3 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -849,11 +849,30 @@ struct xfs_agfl { ASSERT(xfs_daddr_to_agno(mp, d) == \ xfs_daddr_to_agno(mp, (d) + (len) - 1))) +/* + * XFS Timestamps + * ============== + * + * Inode timestamps consist of signed 32-bit counters for seconds and + * nanoseconds; time zero is the Unix epoch, Jan 1 00:00:00 UTC 1970. + */ typedef struct xfs_timestamp { __be32 t_sec; /* timestamp seconds */ __be32 t_nsec; /* timestamp nanoseconds */ } xfs_timestamp_t; +/* + * Smallest possible timestamp with traditional timestamps, which is + * Dec 13 20:45:52 UTC 1901. + */ +#define XFS_INO_TIME_MIN ((int64_t)S32_MIN) + +/* + * Largest possible timestamp with traditional timestamps, which is + * Jan 19 03:14:07 UTC 2038. + */ +#define XFS_INO_TIME_MAX ((int64_t)S32_MAX) + /* * On-disk inode structure. * From patchwork Mon Aug 17 22:59:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11719611 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C4E611744 for ; Mon, 17 Aug 2020 23:01:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC5B8204EC for ; Mon, 17 Aug 2020 23:01:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="FfRaOAoN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728251AbgHQXBT (ORCPT ); Mon, 17 Aug 2020 19:01:19 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:36622 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728018AbgHQXBS (ORCPT ); Mon, 17 Aug 2020 19:01:18 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMxESG164988; Mon, 17 Aug 2020 23:01:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=b4vwkEuaV4D3zkuYzvKAvj7hDUnCsH3w7+JlKo2FZEE=; b=FfRaOAoNFB7mLU7HzhYuqiGtbL8RJClsZmDZ/cLuthpme8nO+mjKyUIwZx6DIz1RZoso Yu1WxNjZZFEeNyNCD+MWSr5436ZW8cP6JxOXHP10QRegV63DGGs3CoUWtuoUbuoAnrfN sjmVSg3UlmYkZhZvk7z8dkpSh7GQxs4xwWQdzOmySFM+8yJUcwPw1G57pyCdf/JjkR6k dL7gLRLtyoRNkOhuYAFzTncItn9JfQ+1gP03mC3B91tzG9f6z+BjXSkzIIsAqaObsD9L CfH3OBm3tN28yHIbRsY3P/YiBq8SsYPzoZJcn8yOxdjq2qRuQcfpbDyaeNi2THMyvpiZ Jw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 32x74r1n2q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Aug 2020 23:01:16 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMw81b139087; Mon, 17 Aug 2020 22:59:15 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 32xs9m9ywb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Aug 2020 22:59:15 +0000 Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07HMxEMq017896; Mon, 17 Aug 2020 22:59:14 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Aug 2020 15:59:14 -0700 Subject: [PATCH 03/18] xfs: refactor quota expiration timer modification From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 17 Aug 2020 15:59:12 -0700 Message-ID: <159770515211.3958786.7094290347539609121.stgit@magnolia> In-Reply-To: <159770513155.3958786.16108819726679724438.stgit@magnolia> References: <159770513155.3958786.16108819726679724438.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 adultscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=999 priorityscore=1501 phishscore=0 spamscore=0 mlxscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Define explicit limits on the range of quota grace period expiration timeouts and refactor the code that modifies the timeouts into helpers that clamp the values appropriately. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- libxfs/xfs_format.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index f2a851e49ec3..829eb1e035a5 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -1198,6 +1198,28 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) #define XFS_DQTYPE_ANY (XFS_DQTYPE_REC_MASK) +/* + * XFS Quota Timers + * ================ + * + * Quota grace period expiration timers are an unsigned 32-bit seconds counter; + * time zero is the Unix epoch, Jan 1 00:00:01 UTC 1970. An expiration value + * of zero means that the quota limit has not been reached, and therefore no + * expiration has been set. + */ + +/* + * Smallest possible quota expiration with traditional timestamps, which is + * Jan 1 00:00:01 UTC 1970. + */ +#define XFS_DQ_TIMEOUT_MIN ((int64_t)1) + +/* + * Largest possible quota expiration with traditional timestamps, which is + * Feb 7 06:28:15 UTC 2106. + */ +#define XFS_DQ_TIMEOUT_MAX ((int64_t)U32_MAX) + /* * This is the main portion of the on-disk representation of quota information * for a user. We pad this with some more expansion room to construct the on From patchwork Mon Aug 17 22:59:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11719557 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F0106722 for ; Mon, 17 Aug 2020 22:59:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D89892072D for ; Mon, 17 Aug 2020 22:59:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="hFqswaFq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727896AbgHQW7Y (ORCPT ); Mon, 17 Aug 2020 18:59:24 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:52180 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727874AbgHQW7X (ORCPT ); Mon, 17 Aug 2020 18:59:23 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMvetj050132; Mon, 17 Aug 2020 22:59:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=UBfUoAELtb46bUNUuLIK4DmaGHrmeZIjSKU4svr1uvI=; b=hFqswaFqA6y30VfolUfT0auL3esnhvRO8aUaBFcVa81WzACw+LNzwSM4aps78FqXS5VM JDfbqmuTa96fiiI731OyFNhcp9b8B91sC+4mCFDTud8bJBmIuQyQ2f/3ZxJWHuCSDZlp 86d4UJWTaWdf0JAbwb/2NcMWJCpZdmhxSOEV8LTPSJc4Ec4Ai/v2UaqpB25vdSd54Flz JOHw0V+ASzkPUgVVi9Hz7x+Pv5D3JFxAyrSRwEoiUjhztSmvnIPAZLD6FK1vLl2TtVz+ DmT6RUNV1ANU79GJfuNe4N15gYFmNOaqf9rUeSqyhG1WXbORRuiV3QeXhpQ2x4bNGIYo Mw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 32x7nm9jrd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Aug 2020 22:59:21 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMvjXg113897; Mon, 17 Aug 2020 22:59:21 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 32xsm18qtw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Aug 2020 22:59:20 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07HMxKv1014548; Mon, 17 Aug 2020 22:59:20 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Aug 2020 15:59:20 -0700 Subject: [PATCH 04/18] xfs: refactor default quota grace period setting code From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 17 Aug 2020 15:59:19 -0700 Message-ID: <159770515944.3958786.9980493388979059788.stgit@magnolia> In-Reply-To: <159770513155.3958786.16108819726679724438.stgit@magnolia> References: <159770513155.3958786.16108819726679724438.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 malwarescore=0 mlxscore=0 phishscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 impostorscore=0 priorityscore=1501 adultscore=0 mlxscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 phishscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Refactor the code that sets the default quota grace period into a helper function so that we can override the ondisk behavior later. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- libxfs/xfs_format.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index 829eb1e035a5..a60d4ed40946 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -1206,6 +1206,11 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) * time zero is the Unix epoch, Jan 1 00:00:01 UTC 1970. An expiration value * of zero means that the quota limit has not been reached, and therefore no * expiration has been set. + * + * The grace period for each quota type is stored in the root dquot (id = 0) + * and is applied to a non-root dquot when it exceeds the soft or hard limits. + * The length of quota grace periods are unsigned 32-bit quantities measured in + * units of seconds. A value of zero means to use the default period. */ /* @@ -1220,6 +1225,14 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) */ #define XFS_DQ_TIMEOUT_MAX ((int64_t)U32_MAX) +/* + * Default quota grace periods, ranging from zero (use the compiled defaults) + * to ~136 years. These are applied to a non-root dquot that has exceeded + * either limit. + */ +#define XFS_DQ_GRACE_MIN ((int64_t)0) +#define XFS_DQ_GRACE_MAX ((int64_t)U32_MAX) + /* * This is the main portion of the on-disk representation of quota information * for a user. We pad this with some more expansion room to construct the on From patchwork Mon Aug 17 22:59:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11719559 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3F372722 for ; Mon, 17 Aug 2020 22:59:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 21E8F2063A for ; Mon, 17 Aug 2020 22:59:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="F/MW0uLC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728070AbgHQW7e (ORCPT ); Mon, 17 Aug 2020 18:59:34 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:35648 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726399AbgHQW7b (ORCPT ); Mon, 17 Aug 2020 18:59:31 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMwA1h164159; Mon, 17 Aug 2020 22:59:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=KsVoNlKSsyBwR9+p8lqVgAQa91borSkza/R1bP1Ze9E=; b=F/MW0uLCy9u0aBJPl2t3NMrK2rAAB/KMqlkVmVQTmUDoJNsBztr9PniFqIsTqjhGqsUw t5C2gSq2imRX2mQiXacG4+SWIxBZD+cbBKJ+TayRngpMXnPHYM/jaYWEUx/fk486suxu Y7ab5xC6gV9U6DcthIilGKW5TEoACachZ7UGzyv+4Fypi6333dOLzfe2pDqrT2Zl9Jib 0LATijIg6opfOagGZkVcDBVIpMoaLND4Ia3osVxnR9F166Lv+FlzzKBkZ/DTnK9xTbQs r5yyumLPccWj4EVc52WBLd1J+fxNksOIOInSs0kZTEnmOp2EQkU1LuhGCDzw8MqLHPvZ ng== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 32x74r1mu0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Aug 2020 22:59:28 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMvjCr113883; Mon, 17 Aug 2020 22:59:27 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 32xsm18r0y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Aug 2020 22:59:27 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07HMxQ9D017349; Mon, 17 Aug 2020 22:59:26 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Aug 2020 15:59:26 -0700 Subject: [PATCH 05/18] xfs: remove xfs_timestamp_t From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 17 Aug 2020 15:59:25 -0700 Message-ID: <159770516555.3958786.9705266272309911121.stgit@magnolia> In-Reply-To: <159770513155.3958786.16108819726679724438.stgit@magnolia> References: <159770513155.3958786.16108819726679724438.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 malwarescore=0 mlxscore=0 phishscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=999 priorityscore=1501 phishscore=0 spamscore=0 mlxscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Kill this old typedef. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- db/field.c | 2 +- db/inode.c | 2 +- libxfs/xfs_format.h | 12 ++++++------ libxfs/xfs_log_format.h | 12 ++++++------ 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/db/field.c b/db/field.c index aa0154d82eb7..0f41be636db4 100644 --- a/db/field.c +++ b/db/field.c @@ -350,7 +350,7 @@ const ftattr_t ftattrtab[] = { { FLDT_TIME, "time", fp_time, NULL, SI(bitsz(int32_t)), FTARG_SIGNED, NULL, NULL }, { FLDT_TIMESTAMP, "timestamp", NULL, (char *)timestamp_flds, - SI(bitsz(xfs_timestamp_t)), 0, NULL, timestamp_flds }, + SI(bitsz(struct xfs_timestamp)), 0, NULL, timestamp_flds }, { FLDT_UINT1, "uint1", fp_num, "%u", SI(1), 0, NULL, NULL }, { FLDT_UINT16D, "uint16d", fp_num, "%u", SI(bitsz(uint16_t)), 0, NULL, NULL }, diff --git a/db/inode.c b/db/inode.c index f13150c96aa9..dfaf12816d75 100644 --- a/db/inode.c +++ b/db/inode.c @@ -179,7 +179,7 @@ const field_t inode_v3_flds[] = { }; -#define TOFF(f) bitize(offsetof(xfs_timestamp_t, t_ ## f)) +#define TOFF(f) bitize(offsetof(struct xfs_timestamp, t_ ## f)) const field_t timestamp_flds[] = { { "sec", FLDT_TIME, OI(TOFF(sec)), C1, 0, TYP_NONE }, { "nsec", FLDT_NSEC, OI(TOFF(nsec)), C1, 0, TYP_NONE }, diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index a60d4ed40946..d11adbbd1808 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -856,10 +856,10 @@ struct xfs_agfl { * Inode timestamps consist of signed 32-bit counters for seconds and * nanoseconds; time zero is the Unix epoch, Jan 1 00:00:00 UTC 1970. */ -typedef struct xfs_timestamp { +struct xfs_timestamp { __be32 t_sec; /* timestamp seconds */ __be32 t_nsec; /* timestamp nanoseconds */ -} xfs_timestamp_t; +}; /* * Smallest possible timestamp with traditional timestamps, which is @@ -904,9 +904,9 @@ typedef struct xfs_dinode { __be16 di_projid_hi; /* higher part owner's project id */ __u8 di_pad[6]; /* unused, zeroed space */ __be16 di_flushiter; /* incremented on flush */ - xfs_timestamp_t di_atime; /* time last accessed */ - xfs_timestamp_t di_mtime; /* time last modified */ - xfs_timestamp_t di_ctime; /* time created/inode modified */ + struct xfs_timestamp di_atime; /* time last accessed */ + struct xfs_timestamp di_mtime; /* time last modified */ + struct xfs_timestamp di_ctime; /* time created/inode modified */ __be64 di_size; /* number of bytes in file */ __be64 di_nblocks; /* # of direct & btree blocks used */ __be32 di_extsize; /* basic/minimum extent size for file */ @@ -931,7 +931,7 @@ typedef struct xfs_dinode { __u8 di_pad2[12]; /* more padding for future expansion */ /* fields only written to during inode creation */ - xfs_timestamp_t di_crtime; /* time created */ + struct xfs_timestamp di_crtime; /* time created */ __be64 di_ino; /* inode number */ uuid_t di_uuid; /* UUID of the filesystem */ diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h index e3400c9c71cd..f2fac9bea66d 100644 --- a/libxfs/xfs_log_format.h +++ b/libxfs/xfs_log_format.h @@ -368,10 +368,10 @@ static inline int xfs_ilog_fdata(int w) * directly mirrors the xfs_dinode structure as it must contain all the same * information. */ -typedef struct xfs_ictimestamp { +struct xfs_ictimestamp { int32_t t_sec; /* timestamp seconds */ int32_t t_nsec; /* timestamp nanoseconds */ -} xfs_ictimestamp_t; +}; /* * Define the format of the inode core that is logged. This structure must be @@ -390,9 +390,9 @@ struct xfs_log_dinode { uint16_t di_projid_hi; /* higher part of owner's project id */ uint8_t di_pad[6]; /* unused, zeroed space */ uint16_t di_flushiter; /* incremented on flush */ - xfs_ictimestamp_t di_atime; /* time last accessed */ - xfs_ictimestamp_t di_mtime; /* time last modified */ - xfs_ictimestamp_t di_ctime; /* time created/inode modified */ + struct xfs_ictimestamp di_atime; /* time last accessed */ + struct xfs_ictimestamp di_mtime; /* time last modified */ + struct xfs_ictimestamp di_ctime; /* time created/inode modified */ xfs_fsize_t di_size; /* number of bytes in file */ xfs_rfsblock_t di_nblocks; /* # of direct & btree blocks used */ xfs_extlen_t di_extsize; /* basic/minimum extent size for file */ @@ -417,7 +417,7 @@ struct xfs_log_dinode { uint8_t di_pad2[12]; /* more padding for future expansion */ /* fields only written to during inode creation */ - xfs_ictimestamp_t di_crtime; /* time created */ + struct xfs_ictimestamp di_crtime; /* time created */ xfs_ino_t di_ino; /* inode number */ uuid_t di_uuid; /* UUID of the filesystem */ From patchwork Mon Aug 17 22:59:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11719561 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 993C9722 for ; Mon, 17 Aug 2020 22:59:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 805642065D for ; Mon, 17 Aug 2020 22:59:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="qURD4QQS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727966AbgHQW7i (ORCPT ); Mon, 17 Aug 2020 18:59:38 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:41100 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726655AbgHQW7h (ORCPT ); Mon, 17 Aug 2020 18:59:37 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMv0n3136174; Mon, 17 Aug 2020 22:59:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=nJy57IJnWrX3kGi8xpg1nUFzT9TclqgAeJCOwYgaGqI=; b=qURD4QQShRzqvpgWpmZhHUJoWcnMU5evZDzveudce5O2j0R4D/TZrGwbnmJUeUY1DTSV qOV6dShnT3syHz3Ksg90H2HWU1xL8nu1jGHdrb2gyga0rJmS5izP+0CoYz4AhPKT0ssK xfm2yhgxgpcVU6dNxduCl2AwnK0Ftblq3i2iEUwXoLFRwakew4wvf1C0/vofXjuxw9gt i9LfwOu11euRUVrF1f+k1DYavhgPtsLXzucjGx/VCz9ZQMvWuTqN2T7yRTVN65rkiy/L lLpEK+NBzsOnoGlEd1ZzN3reQ5WAqJPXqPBpg1jPgVxgzwdD0IJw9FQU6KWezxsAqeu7 6A== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 32x8bn1g0s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Aug 2020 22:59:34 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMw7YL138955; Mon, 17 Aug 2020 22:59:34 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 32xs9ma019-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Aug 2020 22:59:34 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07HMxWNw017365; Mon, 17 Aug 2020 22:59:33 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Aug 2020 15:59:32 -0700 Subject: [PATCH 06/18] xfs: move xfs_log_dinode_to_disk to the log code From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 17 Aug 2020 15:59:31 -0700 Message-ID: <159770517167.3958786.5317029593308865611.stgit@magnolia> In-Reply-To: <159770513155.3958786.16108819726679724438.stgit@magnolia> References: <159770513155.3958786.16108819726679724438.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 adultscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 clxscore=1015 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Move this function to xfs_inode_item.c to match the encoding function that's already there. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- libxfs/xfs_inode_buf.c | 52 ------------------------------------------------ libxfs/xfs_inode_buf.h | 2 -- 2 files changed, 54 deletions(-) diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index 110f249df98c..ecb9abd82a3e 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -311,58 +311,6 @@ xfs_inode_to_disk( } } -void -xfs_log_dinode_to_disk( - struct xfs_log_dinode *from, - struct xfs_dinode *to) -{ - to->di_magic = cpu_to_be16(from->di_magic); - to->di_mode = cpu_to_be16(from->di_mode); - to->di_version = from->di_version; - to->di_format = from->di_format; - to->di_onlink = 0; - to->di_uid = cpu_to_be32(from->di_uid); - to->di_gid = cpu_to_be32(from->di_gid); - to->di_nlink = cpu_to_be32(from->di_nlink); - to->di_projid_lo = cpu_to_be16(from->di_projid_lo); - to->di_projid_hi = cpu_to_be16(from->di_projid_hi); - memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad)); - - to->di_atime.t_sec = cpu_to_be32(from->di_atime.t_sec); - to->di_atime.t_nsec = cpu_to_be32(from->di_atime.t_nsec); - to->di_mtime.t_sec = cpu_to_be32(from->di_mtime.t_sec); - to->di_mtime.t_nsec = cpu_to_be32(from->di_mtime.t_nsec); - to->di_ctime.t_sec = cpu_to_be32(from->di_ctime.t_sec); - to->di_ctime.t_nsec = cpu_to_be32(from->di_ctime.t_nsec); - - to->di_size = cpu_to_be64(from->di_size); - to->di_nblocks = cpu_to_be64(from->di_nblocks); - to->di_extsize = cpu_to_be32(from->di_extsize); - to->di_nextents = cpu_to_be32(from->di_nextents); - to->di_anextents = cpu_to_be16(from->di_anextents); - to->di_forkoff = from->di_forkoff; - to->di_aformat = from->di_aformat; - to->di_dmevmask = cpu_to_be32(from->di_dmevmask); - to->di_dmstate = cpu_to_be16(from->di_dmstate); - to->di_flags = cpu_to_be16(from->di_flags); - to->di_gen = cpu_to_be32(from->di_gen); - - if (from->di_version == 3) { - to->di_changecount = cpu_to_be64(from->di_changecount); - to->di_crtime.t_sec = cpu_to_be32(from->di_crtime.t_sec); - to->di_crtime.t_nsec = cpu_to_be32(from->di_crtime.t_nsec); - to->di_flags2 = cpu_to_be64(from->di_flags2); - to->di_cowextsize = cpu_to_be32(from->di_cowextsize); - to->di_ino = cpu_to_be64(from->di_ino); - to->di_lsn = cpu_to_be64(from->di_lsn); - memcpy(to->di_pad2, from->di_pad2, sizeof(to->di_pad2)); - uuid_copy(&to->di_uuid, &from->di_uuid); - to->di_flushiter = 0; - } else { - to->di_flushiter = cpu_to_be16(from->di_flushiter); - } -} - static xfs_failaddr_t xfs_dinode_verify_fork( struct xfs_dinode *dip, diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h index 6b08b9d060c2..89f7bea8efd6 100644 --- a/libxfs/xfs_inode_buf.h +++ b/libxfs/xfs_inode_buf.h @@ -49,8 +49,6 @@ void xfs_dinode_calc_crc(struct xfs_mount *, struct xfs_dinode *); void xfs_inode_to_disk(struct xfs_inode *ip, struct xfs_dinode *to, xfs_lsn_t lsn); int xfs_inode_from_disk(struct xfs_inode *ip, struct xfs_dinode *from); -void xfs_log_dinode_to_disk(struct xfs_log_dinode *from, - struct xfs_dinode *to); xfs_failaddr_t xfs_dinode_verify(struct xfs_mount *mp, xfs_ino_t ino, struct xfs_dinode *dip); From patchwork Mon Aug 17 22:59:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11719565 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2F497722 for ; Mon, 17 Aug 2020 22:59:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 16AC12063A for ; Mon, 17 Aug 2020 22:59:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="a54o/VR2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728100AbgHQW7n (ORCPT ); Mon, 17 Aug 2020 18:59:43 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:52318 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728081AbgHQW7m (ORCPT ); Mon, 17 Aug 2020 18:59:42 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMvu3s052952; Mon, 17 Aug 2020 22:59:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=r30fz7G7K05P5NWToFQcuw5JOLHx2Qe9qsPAqc6+x+w=; b=a54o/VR2lDuq4/x7dE3guvsDJ9h21PMTPKs5oSwFh6aJ/LVStC4JE1Pt/09F3SDEY6BK kznoftrCnDkLXoFAEDG9qtOuI8FOiAcJBiKOU4HGYavkERNTeX9e5KSXwwe3D+Pcov+F VXfUKC8vTX9mUAtG+PKB3RKcSNNnwnq36mVb7FW2gCT+Ba4lsl3fHQn36HLYeUjob4EF 6nyhR0UJf2x9HEmAjtJkOabrrXpirIJq0t+FnMTw+ADR60qjBeq25rfjVzlft/o7zk+3 dvm/r0wLt61jXidlLPk0qY67iFleG6CSaPyVJd1WEuh6o2fljgxWseMcW+uFZ0GWnrwj CA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 32x7nm9js7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Aug 2020 22:59:40 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMwtKM113566; Mon, 17 Aug 2020 22:59:39 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 32xsmwgh18-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Aug 2020 22:59:39 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07HMxdEn017478; Mon, 17 Aug 2020 22:59:39 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Aug 2020 15:59:38 -0700 Subject: [PATCH 07/18] xfs: refactor inode timestamp coding From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 17 Aug 2020 15:59:37 -0700 Message-ID: <159770517786.3958786.15888272976594846679.stgit@magnolia> In-Reply-To: <159770513155.3958786.16108819726679724438.stgit@magnolia> References: <159770513155.3958786.16108819726679724438.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 bulkscore=0 mlxlogscore=988 phishscore=0 mlxscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 impostorscore=0 priorityscore=1501 adultscore=0 mlxscore=0 mlxlogscore=982 lowpriorityscore=0 bulkscore=0 phishscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Refactor inode timestamp encoding and decoding into helper functions so that we can add extra behaviors in subsequent patches. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- libxfs/xfs_inode_buf.c | 42 ++++++++++++++++++++++++++---------------- libxfs/xfs_inode_buf.h | 5 +++++ 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index ecb9abd82a3e..9f7309f9a576 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -158,6 +158,15 @@ xfs_imap_to_bp( return 0; } +void +xfs_inode_from_disk_timestamp( + struct timespec64 *tv, + const struct xfs_timestamp *ts) +{ + tv->tv_sec = (int)be32_to_cpu(ts->t_sec); + tv->tv_nsec = (int)be32_to_cpu(ts->t_nsec); +} + int xfs_inode_from_disk( struct xfs_inode *ip, @@ -212,12 +221,9 @@ xfs_inode_from_disk( * a time before epoch is converted to a time long after epoch * on 64 bit systems. */ - inode->i_atime.tv_sec = (int)be32_to_cpu(from->di_atime.t_sec); - inode->i_atime.tv_nsec = (int)be32_to_cpu(from->di_atime.t_nsec); - inode->i_mtime.tv_sec = (int)be32_to_cpu(from->di_mtime.t_sec); - inode->i_mtime.tv_nsec = (int)be32_to_cpu(from->di_mtime.t_nsec); - inode->i_ctime.tv_sec = (int)be32_to_cpu(from->di_ctime.t_sec); - inode->i_ctime.tv_nsec = (int)be32_to_cpu(from->di_ctime.t_nsec); + xfs_inode_from_disk_timestamp(&inode->i_atime, &from->di_atime); + xfs_inode_from_disk_timestamp(&inode->i_mtime, &from->di_mtime); + xfs_inode_from_disk_timestamp(&inode->i_ctime, &from->di_ctime); to->di_size = be64_to_cpu(from->di_size); to->di_nblocks = be64_to_cpu(from->di_nblocks); @@ -230,8 +236,7 @@ xfs_inode_from_disk( if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) { inode_set_iversion_queried(inode, be64_to_cpu(from->di_changecount)); - to->di_crtime.tv_sec = be32_to_cpu(from->di_crtime.t_sec); - to->di_crtime.tv_nsec = be32_to_cpu(from->di_crtime.t_nsec); + xfs_inode_from_disk_timestamp(&to->di_crtime, &from->di_crtime); to->di_flags2 = be64_to_cpu(from->di_flags2); to->di_cowextsize = be32_to_cpu(from->di_cowextsize); } @@ -253,6 +258,15 @@ xfs_inode_from_disk( return error; } +void +xfs_inode_to_disk_timestamp( + struct xfs_timestamp *ts, + const struct timespec64 *tv) +{ + ts->t_sec = cpu_to_be32(tv->tv_sec); + ts->t_nsec = cpu_to_be32(tv->tv_nsec); +} + void xfs_inode_to_disk( struct xfs_inode *ip, @@ -272,12 +286,9 @@ xfs_inode_to_disk( to->di_projid_hi = cpu_to_be16(from->di_projid >> 16); memset(to->di_pad, 0, sizeof(to->di_pad)); - to->di_atime.t_sec = cpu_to_be32(inode->i_atime.tv_sec); - to->di_atime.t_nsec = cpu_to_be32(inode->i_atime.tv_nsec); - to->di_mtime.t_sec = cpu_to_be32(inode->i_mtime.tv_sec); - to->di_mtime.t_nsec = cpu_to_be32(inode->i_mtime.tv_nsec); - to->di_ctime.t_sec = cpu_to_be32(inode->i_ctime.tv_sec); - to->di_ctime.t_nsec = cpu_to_be32(inode->i_ctime.tv_nsec); + xfs_inode_to_disk_timestamp(&to->di_atime, &inode->i_atime); + xfs_inode_to_disk_timestamp(&to->di_mtime, &inode->i_mtime); + xfs_inode_to_disk_timestamp(&to->di_ctime, &inode->i_ctime); to->di_nlink = cpu_to_be32(inode->i_nlink); to->di_gen = cpu_to_be32(inode->i_generation); to->di_mode = cpu_to_be16(inode->i_mode); @@ -296,8 +307,7 @@ xfs_inode_to_disk( if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) { to->di_version = 3; to->di_changecount = cpu_to_be64(inode_peek_iversion(inode)); - to->di_crtime.t_sec = cpu_to_be32(from->di_crtime.tv_sec); - to->di_crtime.t_nsec = cpu_to_be32(from->di_crtime.tv_nsec); + xfs_inode_to_disk_timestamp(&to->di_crtime, &from->di_crtime); to->di_flags2 = cpu_to_be64(from->di_flags2); to->di_cowextsize = cpu_to_be32(from->di_cowextsize); to->di_ino = cpu_to_be64(ip->i_ino); diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h index 89f7bea8efd6..9c63f3f932d7 100644 --- a/libxfs/xfs_inode_buf.h +++ b/libxfs/xfs_inode_buf.h @@ -58,4 +58,9 @@ xfs_failaddr_t xfs_inode_validate_cowextsize(struct xfs_mount *mp, uint32_t cowextsize, uint16_t mode, uint16_t flags, uint64_t flags2); +void xfs_inode_from_disk_timestamp(struct timespec64 *tv, + const struct xfs_timestamp *ts); +void xfs_inode_to_disk_timestamp(struct xfs_timestamp *ts, + const struct timespec64 *tv); + #endif /* __XFS_INODE_BUF_H__ */ From patchwork Mon Aug 17 22:59:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11719567 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EEB67618 for ; Mon, 17 Aug 2020 22:59:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D0E3B2078D for ; Mon, 17 Aug 2020 22:59:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="YT0XoQLv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728021AbgHQW7w (ORCPT ); Mon, 17 Aug 2020 18:59:52 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:35746 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728108AbgHQW7s (ORCPT ); Mon, 17 Aug 2020 18:59:48 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMwA4a164165; Mon, 17 Aug 2020 22:59:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=grGKzAlqDDiYZbhGvGU9PinkXTKZtgu01DloLBU35XY=; b=YT0XoQLvWnQHOe/VqzuE7dU/4R+p9hBPuqzkYA3iJWgAqBXaU2XtHACxN/fZrBpGkxH0 AjLPZUQkAGhPBZ9cPMW2SKmwZso5BVJ6NVxMUPEei5H/wb3fPMfOLoY3RVwLkfvQchRD NkKdrN00fGSmFYpxzptan71/+FjyL0SVUz+muQzGwkdHME6kKkq8RSwvAo+BNGNYl1jw a4peUyLkImEauPSeg9+gVtndQJCcZ22CC3Fn3T9cpuoG6x4fma/6Ew9PXDRVOMspNoXW 5OHpUe+DfOINzTfrDd6CAnmN+ueQo/IkRQRUemwvO9QWiYtfaDJ/NwkO+jrnwT8e1tLq WA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 32x74r1mug-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Aug 2020 22:59:46 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMwtKN113566; Mon, 17 Aug 2020 22:59:46 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 32xsmwgh24-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Aug 2020 22:59:45 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07HMxjxK025655; Mon, 17 Aug 2020 22:59:45 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Aug 2020 15:59:44 -0700 Subject: [PATCH 08/18] xfs: convert struct xfs_timestamp to union From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 17 Aug 2020 15:59:43 -0700 Message-ID: <159770518396.3958786.953688801201393844.stgit@magnolia> In-Reply-To: <159770513155.3958786.16108819726679724438.stgit@magnolia> References: <159770513155.3958786.16108819726679724438.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=999 priorityscore=1501 phishscore=0 spamscore=0 mlxscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Convert the xfs_timestamp struct to a union so that we can overload it in the next patch. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- db/field.c | 2 +- db/inode.c | 2 +- libxfs/xfs_format.h | 16 +++++++++------- libxfs/xfs_inode_buf.c | 4 ++-- libxfs/xfs_inode_buf.h | 4 ++-- libxfs/xfs_log_format.h | 16 +++++++++------- repair/dinode.c | 2 +- 7 files changed, 25 insertions(+), 21 deletions(-) diff --git a/db/field.c b/db/field.c index 0f41be636db4..cf3002c730e6 100644 --- a/db/field.c +++ b/db/field.c @@ -350,7 +350,7 @@ const ftattr_t ftattrtab[] = { { FLDT_TIME, "time", fp_time, NULL, SI(bitsz(int32_t)), FTARG_SIGNED, NULL, NULL }, { FLDT_TIMESTAMP, "timestamp", NULL, (char *)timestamp_flds, - SI(bitsz(struct xfs_timestamp)), 0, NULL, timestamp_flds }, + SI(bitsz(union xfs_timestamp)), 0, NULL, timestamp_flds }, { FLDT_UINT1, "uint1", fp_num, "%u", SI(1), 0, NULL, NULL }, { FLDT_UINT16D, "uint16d", fp_num, "%u", SI(bitsz(uint16_t)), 0, NULL, NULL }, diff --git a/db/inode.c b/db/inode.c index dfaf12816d75..25112bb5e4d8 100644 --- a/db/inode.c +++ b/db/inode.c @@ -179,7 +179,7 @@ const field_t inode_v3_flds[] = { }; -#define TOFF(f) bitize(offsetof(struct xfs_timestamp, t_ ## f)) +#define TOFF(f) bitize(offsetof(union xfs_timestamp, t_ ## f)) const field_t timestamp_flds[] = { { "sec", FLDT_TIME, OI(TOFF(sec)), C1, 0, TYP_NONE }, { "nsec", FLDT_NSEC, OI(TOFF(nsec)), C1, 0, TYP_NONE }, diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index d11adbbd1808..5403d3412cb6 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -856,9 +856,11 @@ struct xfs_agfl { * Inode timestamps consist of signed 32-bit counters for seconds and * nanoseconds; time zero is the Unix epoch, Jan 1 00:00:00 UTC 1970. */ -struct xfs_timestamp { - __be32 t_sec; /* timestamp seconds */ - __be32 t_nsec; /* timestamp nanoseconds */ +union xfs_timestamp { + struct { + __be32 t_sec; /* timestamp seconds */ + __be32 t_nsec; /* timestamp nanoseconds */ + }; }; /* @@ -904,9 +906,9 @@ typedef struct xfs_dinode { __be16 di_projid_hi; /* higher part owner's project id */ __u8 di_pad[6]; /* unused, zeroed space */ __be16 di_flushiter; /* incremented on flush */ - struct xfs_timestamp di_atime; /* time last accessed */ - struct xfs_timestamp di_mtime; /* time last modified */ - struct xfs_timestamp di_ctime; /* time created/inode modified */ + union xfs_timestamp di_atime; /* time last accessed */ + union xfs_timestamp di_mtime; /* time last modified */ + union xfs_timestamp di_ctime; /* time created/inode modified */ __be64 di_size; /* number of bytes in file */ __be64 di_nblocks; /* # of direct & btree blocks used */ __be32 di_extsize; /* basic/minimum extent size for file */ @@ -931,7 +933,7 @@ typedef struct xfs_dinode { __u8 di_pad2[12]; /* more padding for future expansion */ /* fields only written to during inode creation */ - struct xfs_timestamp di_crtime; /* time created */ + union xfs_timestamp di_crtime; /* time created */ __be64 di_ino; /* inode number */ uuid_t di_uuid; /* UUID of the filesystem */ diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index 9f7309f9a576..a6c44ca6f2ad 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -161,7 +161,7 @@ xfs_imap_to_bp( void xfs_inode_from_disk_timestamp( struct timespec64 *tv, - const struct xfs_timestamp *ts) + const union xfs_timestamp *ts) { tv->tv_sec = (int)be32_to_cpu(ts->t_sec); tv->tv_nsec = (int)be32_to_cpu(ts->t_nsec); @@ -260,7 +260,7 @@ xfs_inode_from_disk( void xfs_inode_to_disk_timestamp( - struct xfs_timestamp *ts, + union xfs_timestamp *ts, const struct timespec64 *tv) { ts->t_sec = cpu_to_be32(tv->tv_sec); diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h index 9c63f3f932d7..f6160033fcbd 100644 --- a/libxfs/xfs_inode_buf.h +++ b/libxfs/xfs_inode_buf.h @@ -59,8 +59,8 @@ xfs_failaddr_t xfs_inode_validate_cowextsize(struct xfs_mount *mp, uint64_t flags2); void xfs_inode_from_disk_timestamp(struct timespec64 *tv, - const struct xfs_timestamp *ts); -void xfs_inode_to_disk_timestamp(struct xfs_timestamp *ts, + const union xfs_timestamp *ts); +void xfs_inode_to_disk_timestamp(union xfs_timestamp *ts, const struct timespec64 *tv); #endif /* __XFS_INODE_BUF_H__ */ diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h index f2fac9bea66d..17c83d29998c 100644 --- a/libxfs/xfs_log_format.h +++ b/libxfs/xfs_log_format.h @@ -368,9 +368,11 @@ static inline int xfs_ilog_fdata(int w) * directly mirrors the xfs_dinode structure as it must contain all the same * information. */ -struct xfs_ictimestamp { - int32_t t_sec; /* timestamp seconds */ - int32_t t_nsec; /* timestamp nanoseconds */ +union xfs_ictimestamp { + struct { + int32_t t_sec; /* timestamp seconds */ + int32_t t_nsec; /* timestamp nanoseconds */ + }; }; /* @@ -390,9 +392,9 @@ struct xfs_log_dinode { uint16_t di_projid_hi; /* higher part of owner's project id */ uint8_t di_pad[6]; /* unused, zeroed space */ uint16_t di_flushiter; /* incremented on flush */ - struct xfs_ictimestamp di_atime; /* time last accessed */ - struct xfs_ictimestamp di_mtime; /* time last modified */ - struct xfs_ictimestamp di_ctime; /* time created/inode modified */ + union xfs_ictimestamp di_atime; /* time last accessed */ + union xfs_ictimestamp di_mtime; /* time last modified */ + union xfs_ictimestamp di_ctime; /* time created/inode modified */ xfs_fsize_t di_size; /* number of bytes in file */ xfs_rfsblock_t di_nblocks; /* # of direct & btree blocks used */ xfs_extlen_t di_extsize; /* basic/minimum extent size for file */ @@ -417,7 +419,7 @@ struct xfs_log_dinode { uint8_t di_pad2[12]; /* more padding for future expansion */ /* fields only written to during inode creation */ - struct xfs_ictimestamp di_crtime; /* time created */ + union xfs_ictimestamp di_crtime; /* time created */ xfs_ino_t di_ino; /* inode number */ uuid_t di_uuid; /* UUID of the filesystem */ diff --git a/repair/dinode.c b/repair/dinode.c index 957a2698b09e..c5f2248b2b9a 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -2169,7 +2169,7 @@ static void check_nsec( const char *name, xfs_ino_t lino, - struct xfs_timestamp *t, + union xfs_timestamp *t, int *dirty) { if (be32_to_cpu(t->t_nsec) < 1000000000) From patchwork Mon Aug 17 22:59:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11719613 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B785E739 for ; Mon, 17 Aug 2020 23:01:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F80420674 for ; Mon, 17 Aug 2020 23:01:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="DIzQy8/V" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726171AbgHQXBz (ORCPT ); Mon, 17 Aug 2020 19:01:55 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:42526 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726613AbgHQXBy (ORCPT ); Mon, 17 Aug 2020 19:01:54 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMv9PF136201; Mon, 17 Aug 2020 23:01:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=2UCY3ZQitWE+qiZlRbjx1QvdkSw4DYINPMPobk5Dmis=; b=DIzQy8/VVsr36DcZ6kApk3bJ9AfbRKtuBKW16UAaQMOPxuRIQjBjM/tTGKvQ9qD0G8qR 79fvPb8J45iJCHu1X9GD3yhhd2W9Yq35sTSlf4NVhS6yHQgzjEViu1QzS0nFhGEmKnqx 07ozVfjeVDKymfzpWT5hpDtVhShNe3SbKFkhdzjGXhYB771BQH2e4sPaUS/rCIxRXtIi bYfWdSVQgpXVfIX5xwpzexWWJeMoNpjWw8x1za9Rwis7PIo06farWspFfjlYdNX9WOC/ eniBHsB5hL9V96SR57eBntw+yYPJjJ2zEw09OeDppFdTalHkTPEFepruLCAFHBhEVzvZ Eg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 32x8bn1g9y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Aug 2020 23:01:52 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMw8J6139080; Mon, 17 Aug 2020 22:59:51 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 32xs9ma04n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Aug 2020 22:59:51 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07HMxpdH025674; Mon, 17 Aug 2020 22:59:51 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Aug 2020 15:59:50 -0700 Subject: [PATCH 09/18] libxfs: refactor NSEC_PER_SEC From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 17 Aug 2020 15:59:50 -0700 Message-ID: <159770519011.3958786.9102828204613614956.stgit@magnolia> In-Reply-To: <159770513155.3958786.16108819726679724438.stgit@magnolia> References: <159770513155.3958786.16108819726679724438.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 adultscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 suspectscore=9 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 suspectscore=9 adultscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 clxscore=1015 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Clean up all the open-coded and duplicate definitions of time unit conversion factors. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- include/platform_defs.h.in | 3 +++ repair/dinode.c | 2 +- scrub/common.c | 2 -- scrub/progress.c | 1 - 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/platform_defs.h.in b/include/platform_defs.h.in index 1f7ceafb1fbc..a11b58719380 100644 --- a/include/platform_defs.h.in +++ b/include/platform_defs.h.in @@ -80,4 +80,7 @@ typedef unsigned short umode_t; extern int platform_nproc(void); +#define NSEC_PER_SEC (1000000000ULL) +#define NSEC_PER_USEC (1000ULL) + #endif /* __XFS_PLATFORM_DEFS_H__ */ diff --git a/repair/dinode.c b/repair/dinode.c index c5f2248b2b9a..0bee3c3d988e 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -2172,7 +2172,7 @@ check_nsec( union xfs_timestamp *t, int *dirty) { - if (be32_to_cpu(t->t_nsec) < 1000000000) + if (be32_to_cpu(t->t_nsec) < NSEC_PER_SEC) return; do_warn( diff --git a/scrub/common.c b/scrub/common.c index 261f575a0c9b..70efaf04c648 100644 --- a/scrub/common.c +++ b/scrub/common.c @@ -294,8 +294,6 @@ scrub_nproc_workqueue( * Sleep for 100us * however many -b we got past the initial one. * This is an (albeit clumsy) way to throttle scrub activity. */ -#define NSEC_PER_SEC 1000000000ULL -#define NSEC_PER_USEC 1000ULL void background_sleep(void) { diff --git a/scrub/progress.c b/scrub/progress.c index d8130ca5f93c..15247b7c6d1b 100644 --- a/scrub/progress.c +++ b/scrub/progress.c @@ -110,7 +110,6 @@ progress_report( fflush(pt.fp); } -#define NSEC_PER_SEC (1000000000) static void * progress_report_thread(void *arg) { From patchwork Mon Aug 17 22:59:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11719615 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 78112722 for ; Mon, 17 Aug 2020 23:02:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5826C20674 for ; Mon, 17 Aug 2020 23:02:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="VsHYDfuV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726539AbgHQXCF (ORCPT ); Mon, 17 Aug 2020 19:02:05 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:53756 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726220AbgHQXCD (ORCPT ); Mon, 17 Aug 2020 19:02:03 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMvc7O050127; Mon, 17 Aug 2020 23:01:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=q+TZOCaHdHGBuE2Io6ZeNkiQ5TVFFLBao+1pFw5uPj4=; b=VsHYDfuVkW/wnHswEhPnsZOOKxJ9wXOz2DDclQCP6bjUYeaelbvz+5ifwBbErJ+yN9Zn 4uq9RkC7uF8w7Sqf8kMj4FqIKxt2DsqbNWWBV2ruzj/f4W4crU7wEizjN4qY4enCXCyF 3K4QQL+jvR+m4iqpjkpRjN7/vrrbbJL0MoJV0zuiGy5cpGMtAXJXUBIcfwpSN+QTaW47 OOvzntpK5fhIoEDPa0YXJJN+St9fOO5QiUYXxH3vFMjSxHTZTfAfK1Re5h6kdXkSrqOm V7qtgoWzUHCWjKQUemLpMOLuPy3lexOZPqevtSHiZJkXcY/qZY/DAQl2wbqiTMTXibom Fg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 32x7nm9k29-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Aug 2020 23:01:59 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMw9Q6084679; Mon, 17 Aug 2020 22:59:58 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 32xsfr59wd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Aug 2020 22:59:58 +0000 Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07HMxvVr015020; Mon, 17 Aug 2020 22:59:57 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Aug 2020 15:59:57 -0700 Subject: [PATCH 10/18] xfs: widen ondisk timestamps to deal with y2038 problem From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 17 Aug 2020 15:59:56 -0700 Message-ID: <159770519622.3958786.16858432845716831168.stgit@magnolia> In-Reply-To: <159770513155.3958786.16108819726679724438.stgit@magnolia> References: <159770513155.3958786.16108819726679724438.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 spamscore=0 suspectscore=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 impostorscore=0 priorityscore=1501 adultscore=0 mlxscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 phishscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Redesign the ondisk timestamps to be a simple unsigned 64-bit counter of nanoseconds since 14 Dec 1901 (i.e. the minimum time in the 32-bit unix time epoch). This enables us to handle dates up to 2486, which solves the y2038 problem. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- libfrog/fsgeom.c | 6 +++-- libxfs/util.c | 10 ++++++--- libxfs/xfs_format.h | 38 ++++++++++++++++++++++++++++++++- libxfs/xfs_fs.h | 1 + libxfs/xfs_inode_buf.c | 54 ++++++++++++++++++++++++++++++++++++++++------- libxfs/xfs_inode_buf.h | 8 +++---- libxfs/xfs_log_format.h | 3 +++ libxfs/xfs_sb.c | 2 ++ repair/dinode.c | 12 ++++++---- 9 files changed, 111 insertions(+), 23 deletions(-) diff --git a/libfrog/fsgeom.c b/libfrog/fsgeom.c index bd93924ea795..14507668e41b 100644 --- a/libfrog/fsgeom.c +++ b/libfrog/fsgeom.c @@ -28,6 +28,7 @@ xfs_report_geom( int spinodes; int rmapbt_enabled; int reflink_enabled; + int bigtime_enabled; isint = geo->logstart > 0; lazycount = geo->flags & XFS_FSOP_GEOM_FLAGS_LAZYSB ? 1 : 0; @@ -43,12 +44,13 @@ xfs_report_geom( spinodes = geo->flags & XFS_FSOP_GEOM_FLAGS_SPINODES ? 1 : 0; rmapbt_enabled = geo->flags & XFS_FSOP_GEOM_FLAGS_RMAPBT ? 1 : 0; reflink_enabled = geo->flags & XFS_FSOP_GEOM_FLAGS_REFLINK ? 1 : 0; + bigtime_enabled = geo->flags & XFS_FSOP_GEOM_FLAGS_BIGTIME ? 1 : 0; printf(_( "meta-data=%-22s isize=%-6d agcount=%u, agsize=%u blks\n" " =%-22s sectsz=%-5u attr=%u, projid32bit=%u\n" " =%-22s crc=%-8u finobt=%u, sparse=%u, rmapbt=%u\n" -" =%-22s reflink=%u\n" +" =%-22s reflink=%-4u bigtime=%u\n" "data =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n" " =%-22s sunit=%-6u swidth=%u blks\n" "naming =version %-14u bsize=%-6u ascii-ci=%d, ftype=%d\n" @@ -58,7 +60,7 @@ xfs_report_geom( mntpoint, geo->inodesize, geo->agcount, geo->agblocks, "", geo->sectsize, attrversion, projid32bit, "", crcs_enabled, finobt_enabled, spinodes, rmapbt_enabled, - "", reflink_enabled, + "", reflink_enabled, bigtime_enabled, "", geo->blocksize, (unsigned long long)geo->datablocks, geo->imaxpct, "", geo->sunit, geo->swidth, diff --git a/libxfs/util.c b/libxfs/util.c index 6670fcdfa1d0..eceb6dc29a3b 100644 --- a/libxfs/util.c +++ b/libxfs/util.c @@ -197,7 +197,8 @@ xfs_flags2diflags2( unsigned int xflags) { uint64_t di_flags2 = - (ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK); + (ip->i_d.di_flags2 & (XFS_DIFLAG2_REFLINK | + XFS_DIFLAG2_BIGTIME)); if (xflags & FS_XFLAG_DAX) di_flags2 |= XFS_DIFLAG2_DAX; @@ -279,8 +280,9 @@ libxfs_ialloc( VFS_I(ip)->i_version = 1; ip->i_d.di_flags2 = pip ? 0 : xfs_flags2diflags2(ip, fsx->fsx_xflags); - ip->i_d.di_crtime.tv_sec = (int32_t)VFS_I(ip)->i_mtime.tv_sec; - ip->i_d.di_crtime.tv_nsec = (int32_t)VFS_I(ip)->i_mtime.tv_nsec; + if (xfs_sb_version_hasbigtime(&ip->i_mount->m_sb)) + ip->i_d.di_flags2 |= XFS_DIFLAG2_BIGTIME; + ip->i_d.di_crtime = VFS_I(ip)->i_mtime; ip->i_d.di_cowextsize = pip ? 0 : fsx->fsx_cowextsize; } @@ -375,6 +377,8 @@ libxfs_iflush_int( } ASSERT(ip->i_df.if_nextents+ip->i_afp->if_nextents <= ip->i_d.di_nblocks); ASSERT(ip->i_d.di_forkoff <= mp->m_sb.sb_inodesize); + ASSERT(!(ip->i_d.di_flags2 & XFS_DIFLAG2_BIGTIME) && + xfs_sb_version_hasbigtime(&mp->m_sb)); /* bump the change count on v3 inodes */ if (xfs_sb_version_has_v3inode(&mp->m_sb)) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index 5403d3412cb6..67303e517260 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -467,6 +467,7 @@ xfs_sb_has_ro_compat_feature( #define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */ #define XFS_SB_FEAT_INCOMPAT_SPINODES (1 << 1) /* sparse inode chunks */ #define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2) /* metadata UUID */ +#define XFS_SB_FEAT_INCOMPAT_BIGTIME (1 << 3) /* large timestamps */ #define XFS_SB_FEAT_INCOMPAT_ALL \ (XFS_SB_FEAT_INCOMPAT_FTYPE| \ XFS_SB_FEAT_INCOMPAT_SPINODES| \ @@ -565,6 +566,12 @@ static inline bool xfs_sb_version_hasreflink(struct xfs_sb *sbp) (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_REFLINK); } +static inline bool xfs_sb_version_hasbigtime(struct xfs_sb *sbp) +{ + return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && + (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_BIGTIME); +} + /* * Inode btree block counter. We record the number of inobt and finobt blocks * in the AGI header so that we can skip the finobt walk at mount time when @@ -855,12 +862,18 @@ struct xfs_agfl { * * Inode timestamps consist of signed 32-bit counters for seconds and * nanoseconds; time zero is the Unix epoch, Jan 1 00:00:00 UTC 1970. + * + * When bigtime is enabled, timestamps become an unsigned 64-bit nanoseconds + * counter. Time zero is the start of the classic timestamp range. */ union xfs_timestamp { struct { __be32 t_sec; /* timestamp seconds */ __be32 t_nsec; /* timestamp nanoseconds */ }; + + /* Nanoseconds since the bigtime epoch. */ + __be64 t_bigtime; }; /* @@ -875,6 +888,25 @@ union xfs_timestamp { */ #define XFS_INO_TIME_MAX ((int64_t)S32_MAX) +/* + * Number of seconds between the start of the bigtime timestamp range and the + * start of the Unix epoch. + */ +#define XFS_INO_BIGTIME_EPOCH (-XFS_INO_TIME_MIN) + +/* + * Smallest possible timestamp with big timestamps, which is + * Dec 13 20:45:52 UTC 1901. + */ +#define XFS_INO_BIGTIME_MIN (XFS_INO_TIME_MIN) + +/* + * Largest possible timestamp with big timestamps, which is + * Jul 2 20:20:25 UTC 2486. + */ +#define XFS_INO_BIGTIME_MAX ((int64_t)((-1ULL / NSEC_PER_SEC) - \ + XFS_INO_BIGTIME_EPOCH)) + /* * On-disk inode structure. * @@ -1101,12 +1133,16 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) #define XFS_DIFLAG2_DAX_BIT 0 /* use DAX for this inode */ #define XFS_DIFLAG2_REFLINK_BIT 1 /* file's blocks may be shared */ #define XFS_DIFLAG2_COWEXTSIZE_BIT 2 /* copy on write extent size hint */ +#define XFS_DIFLAG2_BIGTIME_BIT 3 /* big timestamps */ + #define XFS_DIFLAG2_DAX (1 << XFS_DIFLAG2_DAX_BIT) #define XFS_DIFLAG2_REFLINK (1 << XFS_DIFLAG2_REFLINK_BIT) #define XFS_DIFLAG2_COWEXTSIZE (1 << XFS_DIFLAG2_COWEXTSIZE_BIT) +#define XFS_DIFLAG2_BIGTIME (1 << XFS_DIFLAG2_BIGTIME_BIT) #define XFS_DIFLAG2_ANY \ - (XFS_DIFLAG2_DAX | XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE) + (XFS_DIFLAG2_DAX | XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE | \ + XFS_DIFLAG2_BIGTIME) /* * Inode number format: diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h index dc2543dd5955..69f998666569 100644 --- a/libxfs/xfs_fs.h +++ b/libxfs/xfs_fs.h @@ -249,6 +249,7 @@ typedef struct xfs_fsop_resblks { #define XFS_FSOP_GEOM_FLAGS_SPINODES (1 << 18) /* sparse inode chunks */ #define XFS_FSOP_GEOM_FLAGS_RMAPBT (1 << 19) /* reverse mapping btree */ #define XFS_FSOP_GEOM_FLAGS_REFLINK (1 << 20) /* files can share blocks */ +#define XFS_FSOP_GEOM_FLAGS_BIGTIME (1 << 21) /* 64-bit nsec timestamps */ /* * Minimum and maximum sizes need for growth checks. diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index a6c44ca6f2ad..2fb668c07b70 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -158,11 +158,25 @@ xfs_imap_to_bp( return 0; } +/* Convert an ondisk timestamp into the 64-bit safe incore format. */ void xfs_inode_from_disk_timestamp( + struct xfs_dinode *dip, struct timespec64 *tv, const union xfs_timestamp *ts) { + if (dip->di_version >= 3 && + (dip->di_flags2 & cpu_to_be64(XFS_DIFLAG2_BIGTIME))) { + uint64_t t = be64_to_cpu(ts->t_bigtime); + uint64_t s; + uint32_t n; + + s = div_u64_rem(t, NSEC_PER_SEC, &n); + tv->tv_sec = s - XFS_INO_BIGTIME_EPOCH; + tv->tv_nsec = n; + return; + } + tv->tv_sec = (int)be32_to_cpu(ts->t_sec); tv->tv_nsec = (int)be32_to_cpu(ts->t_nsec); } @@ -221,9 +235,9 @@ xfs_inode_from_disk( * a time before epoch is converted to a time long after epoch * on 64 bit systems. */ - xfs_inode_from_disk_timestamp(&inode->i_atime, &from->di_atime); - xfs_inode_from_disk_timestamp(&inode->i_mtime, &from->di_mtime); - xfs_inode_from_disk_timestamp(&inode->i_ctime, &from->di_ctime); + xfs_inode_from_disk_timestamp(from, &inode->i_atime, &from->di_atime); + xfs_inode_from_disk_timestamp(from, &inode->i_mtime, &from->di_mtime); + xfs_inode_from_disk_timestamp(from, &inode->i_ctime, &from->di_ctime); to->di_size = be64_to_cpu(from->di_size); to->di_nblocks = be64_to_cpu(from->di_nblocks); @@ -236,9 +250,17 @@ xfs_inode_from_disk( if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) { inode_set_iversion_queried(inode, be64_to_cpu(from->di_changecount)); - xfs_inode_from_disk_timestamp(&to->di_crtime, &from->di_crtime); + xfs_inode_from_disk_timestamp(from, &to->di_crtime, + &from->di_crtime); to->di_flags2 = be64_to_cpu(from->di_flags2); to->di_cowextsize = be32_to_cpu(from->di_cowextsize); + /* + * Set the bigtime flag incore so that we automatically convert + * this inode's ondisk timestamps to bigtime format the next + * time we write the inode core to disk. + */ + if (xfs_sb_version_hasbigtime(&ip->i_mount->m_sb)) + to->di_flags2 |= XFS_DIFLAG2_BIGTIME; } error = xfs_iformat_data_fork(ip, from); @@ -260,9 +282,19 @@ xfs_inode_from_disk( void xfs_inode_to_disk_timestamp( + struct xfs_icdinode *from, union xfs_timestamp *ts, const struct timespec64 *tv) { + if (from->di_flags2 & XFS_DIFLAG2_BIGTIME) { + uint64_t t; + + t = (uint64_t)(tv->tv_sec + XFS_INO_BIGTIME_EPOCH); + t *= NSEC_PER_SEC; + ts->t_bigtime = cpu_to_be64(t + tv->tv_nsec); + return; + } + ts->t_sec = cpu_to_be32(tv->tv_sec); ts->t_nsec = cpu_to_be32(tv->tv_nsec); } @@ -286,9 +318,9 @@ xfs_inode_to_disk( to->di_projid_hi = cpu_to_be16(from->di_projid >> 16); memset(to->di_pad, 0, sizeof(to->di_pad)); - xfs_inode_to_disk_timestamp(&to->di_atime, &inode->i_atime); - xfs_inode_to_disk_timestamp(&to->di_mtime, &inode->i_mtime); - xfs_inode_to_disk_timestamp(&to->di_ctime, &inode->i_ctime); + xfs_inode_to_disk_timestamp(from, &to->di_atime, &inode->i_atime); + xfs_inode_to_disk_timestamp(from, &to->di_mtime, &inode->i_mtime); + xfs_inode_to_disk_timestamp(from, &to->di_ctime, &inode->i_ctime); to->di_nlink = cpu_to_be32(inode->i_nlink); to->di_gen = cpu_to_be32(inode->i_generation); to->di_mode = cpu_to_be16(inode->i_mode); @@ -307,7 +339,8 @@ xfs_inode_to_disk( if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) { to->di_version = 3; to->di_changecount = cpu_to_be64(inode_peek_iversion(inode)); - xfs_inode_to_disk_timestamp(&to->di_crtime, &from->di_crtime); + xfs_inode_to_disk_timestamp(from, &to->di_crtime, + &from->di_crtime); to->di_flags2 = cpu_to_be64(from->di_flags2); to->di_cowextsize = cpu_to_be32(from->di_cowextsize); to->di_ino = cpu_to_be64(ip->i_ino); @@ -527,6 +560,11 @@ xfs_dinode_verify( if (fa) return fa; + /* bigtime iflag can only happen on bigtime filesystems */ + if ((flags2 & (XFS_DIFLAG2_BIGTIME)) && + !xfs_sb_version_hasbigtime(&mp->m_sb)) + return __this_address; + return NULL; } diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h index f6160033fcbd..3b25e43eafa1 100644 --- a/libxfs/xfs_inode_buf.h +++ b/libxfs/xfs_inode_buf.h @@ -58,9 +58,9 @@ xfs_failaddr_t xfs_inode_validate_cowextsize(struct xfs_mount *mp, uint32_t cowextsize, uint16_t mode, uint16_t flags, uint64_t flags2); -void xfs_inode_from_disk_timestamp(struct timespec64 *tv, - const union xfs_timestamp *ts); -void xfs_inode_to_disk_timestamp(union xfs_timestamp *ts, - const struct timespec64 *tv); +void xfs_inode_from_disk_timestamp(struct xfs_dinode *dip, + struct timespec64 *tv, const union xfs_timestamp *ts); +void xfs_inode_to_disk_timestamp(struct xfs_icdinode *from, + union xfs_timestamp *ts, const struct timespec64 *tv); #endif /* __XFS_INODE_BUF_H__ */ diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h index 17c83d29998c..569721f7f9e5 100644 --- a/libxfs/xfs_log_format.h +++ b/libxfs/xfs_log_format.h @@ -373,6 +373,9 @@ union xfs_ictimestamp { int32_t t_sec; /* timestamp seconds */ int32_t t_nsec; /* timestamp nanoseconds */ }; + + /* Nanoseconds since the bigtime epoch. */ + uint64_t t_bigtime; }; /* diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index 0eb16305e221..001b88865b0a 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -1143,6 +1143,8 @@ xfs_fs_geometry( geo->flags |= XFS_FSOP_GEOM_FLAGS_RMAPBT; if (xfs_sb_version_hasreflink(sbp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_REFLINK; + if (xfs_sb_version_hasbigtime(sbp)) + geo->flags |= XFS_FSOP_GEOM_FLAGS_BIGTIME; if (xfs_sb_version_hassector(sbp)) geo->logsectsize = sbp->sb_logsectsize; else diff --git a/repair/dinode.c b/repair/dinode.c index 0bee3c3d988e..ad2f672d8703 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -2169,10 +2169,12 @@ static void check_nsec( const char *name, xfs_ino_t lino, + struct xfs_dinode *dip, union xfs_timestamp *t, int *dirty) { - if (be32_to_cpu(t->t_nsec) < NSEC_PER_SEC) + if ((dip->di_flags2 & be64_to_cpu(XFS_DIFLAG2_BIGTIME)) || + be32_to_cpu(t->t_nsec) < NSEC_PER_SEC) return; do_warn( @@ -2726,11 +2728,11 @@ _("Bad CoW extent size %u on inode %" PRIu64 ", "), } /* nsec fields cannot be larger than 1 billion */ - check_nsec("atime", lino, &dino->di_atime, dirty); - check_nsec("mtime", lino, &dino->di_mtime, dirty); - check_nsec("ctime", lino, &dino->di_ctime, dirty); + check_nsec("atime", lino, dino, &dino->di_atime, dirty); + check_nsec("mtime", lino, dino, &dino->di_mtime, dirty); + check_nsec("ctime", lino, dino, &dino->di_ctime, dirty); if (dino->di_version >= 3) - check_nsec("crtime", lino, &dino->di_crtime, dirty); + check_nsec("crtime", lino, dino, &dino->di_crtime, dirty); /* * general size/consistency checks: From patchwork Mon Aug 17 23:00:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11719571 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2CA08722 for ; Mon, 17 Aug 2020 23:00:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 14A6F20674 for ; Mon, 17 Aug 2020 23:00:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="nsgwvE4j" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728189AbgHQXAJ (ORCPT ); Mon, 17 Aug 2020 19:00:09 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:52676 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728170AbgHQXAH (ORCPT ); Mon, 17 Aug 2020 19:00:07 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMvRNO050046; Mon, 17 Aug 2020 23:00:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=ddI/P455nkzGpADtDsn4CHbTgO5aV7pfYsexjEQY8r4=; b=nsgwvE4jmwz0+eYxseCFBz52GHEe7Q/OYzBp+UdAiehL3ZKIrJTumnFQ7qoosB22UZin TIZZ5I/M+4tcWywI+WZBkxmcOwvWJXEKlqbfY4Sd9WYrEscYwawPojTd49v+CVJwKmP9 JH6k8LXGiUhw2wvWLCqZPMDPL9cYecb/0Zls1FNcRUALMtfsEbDx9PsgcnBJ+fxMN2U2 zS36xp5sk/ATvzo8u+aSMPDWXGVKn1c6bAg4RQ6wDX2m1Hv/Y4gSD/9g8VnIYAnoeX+y 6O5QIqjV73Xtmispik7ivfk9hVqJoJQk0W/DJ96qRb6a206N9ltWki59UD/AHN6uAXm/ 0w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 32x7nm9ju7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Aug 2020 23:00:05 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMwtal113620; Mon, 17 Aug 2020 23:00:05 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 32xsmwghjr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Aug 2020 23:00:05 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07HN04ot018305; Mon, 17 Aug 2020 23:00:04 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Aug 2020 16:00:04 -0700 Subject: [PATCH 11/18] xfs: refactor quota timestamp coding From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 17 Aug 2020 16:00:02 -0700 Message-ID: <159770520255.3958786.18344458914688900638.stgit@magnolia> In-Reply-To: <159770513155.3958786.16108819726679724438.stgit@magnolia> References: <159770513155.3958786.16108819726679724438.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 impostorscore=0 priorityscore=1501 adultscore=0 mlxscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 phishscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Refactor quota timestamp encoding and decoding into helper functions so that we can add extra behavior in the next patch. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- libxfs/xfs_dquot_buf.c | 20 ++++++++++++++++++++ libxfs/xfs_quota_defs.h | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/libxfs/xfs_dquot_buf.c b/libxfs/xfs_dquot_buf.c index b5adb840d015..847b9ba5280c 100644 --- a/libxfs/xfs_dquot_buf.c +++ b/libxfs/xfs_dquot_buf.c @@ -286,3 +286,23 @@ const struct xfs_buf_ops xfs_dquot_buf_ra_ops = { .verify_read = xfs_dquot_buf_readahead_verify, .verify_write = xfs_dquot_buf_write_verify, }; + +/* Convert an on-disk timer value into an incore timer value. */ +void +xfs_dquot_from_disk_timestamp( + struct xfs_disk_dquot *ddq, + time64_t *timer, + __be32 dtimer) +{ + *timer = be32_to_cpu(dtimer); +} + +/* Convert an incore timer value into an on-disk timer value. */ +void +xfs_dquot_to_disk_timestamp( + struct xfs_dquot *dqp, + __be32 *dtimer, + time64_t timer) +{ + *dtimer = cpu_to_be32(timer); +} diff --git a/libxfs/xfs_quota_defs.h b/libxfs/xfs_quota_defs.h index 076bdc7037ee..b524059faab5 100644 --- a/libxfs/xfs_quota_defs.h +++ b/libxfs/xfs_quota_defs.h @@ -143,4 +143,10 @@ extern int xfs_calc_dquots_per_chunk(unsigned int nbblks); extern void xfs_dqblk_repair(struct xfs_mount *mp, struct xfs_dqblk *dqb, xfs_dqid_t id, xfs_dqtype_t type); +struct xfs_dquot; +void xfs_dquot_from_disk_timestamp(struct xfs_disk_dquot *ddq, + time64_t *timer, __be32 dtimer); +void xfs_dquot_to_disk_timestamp(struct xfs_dquot *ddq, + __be32 *dtimer, time64_t timer); + #endif /* __XFS_QUOTA_H__ */ From patchwork Mon Aug 17 23:00:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11719573 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 08B6D739 for ; Mon, 17 Aug 2020 23:00:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DEFC420674 for ; Mon, 17 Aug 2020 23:00:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="NoMU92oq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726329AbgHQXAS (ORCPT ); Mon, 17 Aug 2020 19:00:18 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:36052 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728193AbgHQXAQ (ORCPT ); Mon, 17 Aug 2020 19:00:16 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMwHcp164206; Mon, 17 Aug 2020 23:00:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=LqMlinSHFiu5CYOVFtsQetd8guINBh/Q2eLnjKO01oA=; b=NoMU92oqZCU7TYRlM8GVDVhAZrHSKNfGhWCBZXH+5TPjEos4fnXcwAj5CFH2wn6tH8t0 hpxY5KSjsYcejxY0nvXfLzLz01069gMvm0ZWFb1ihHkzu4/DXnIajF936jI/YQKxc6rP S4uS9+BaVRe/639/2/aiRUY8iPxC40C3D1xPtuUJpKaOY28zHocgzms904QiKLLxCDDd 6u/iy72PoF2vZ6KZO4SMiL+lFGF/Jtbga/LQj/N0/vYNhd3JVCpGYQIlKN6/rgXKdMU5 H8el6iIy2xx5NavFp4X9zxun3U3MOAx7WDK5MzKAFWqD6XuoIOUx/S984182qznCKCuR Lw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 32x74r1mwk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Aug 2020 23:00:13 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMvsbf114192; Mon, 17 Aug 2020 23:00:12 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 32xsm18smn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Aug 2020 23:00:12 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07HN0BZN017750; Mon, 17 Aug 2020 23:00:11 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Aug 2020 16:00:10 -0700 Subject: [PATCH 12/18] xfs: enable bigtime for quota timers From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 17 Aug 2020 16:00:09 -0700 Message-ID: <159770520929.3958786.2869468837745844258.stgit@magnolia> In-Reply-To: <159770513155.3958786.16108819726679724438.stgit@magnolia> References: <159770513155.3958786.16108819726679724438.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 malwarescore=0 mlxscore=0 phishscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=999 priorityscore=1501 phishscore=0 spamscore=0 mlxscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Enable the bigtime feature for quota timers. We decrease the accuracy of the timers to ~4s in exchange for being able to set timers up to the bigtime maximum. Signed-off-by: Darrick J. Wong --- include/xfs_mount.h | 5 +++++ libxfs/xfs_dquot_buf.c | 40 ++++++++++++++++++++++++++++++++++++++++ libxfs/xfs_format.h | 26 +++++++++++++++++++++++++- libxfs/xfs_quota_defs.h | 3 ++- 4 files changed, 72 insertions(+), 2 deletions(-) diff --git a/include/xfs_mount.h b/include/xfs_mount.h index 20c8bfaf4fa8..be74a922b7a1 100644 --- a/include/xfs_mount.h +++ b/include/xfs_mount.h @@ -184,4 +184,9 @@ extern xfs_mount_t *libxfs_mount (xfs_mount_t *, xfs_sb_t *, int libxfs_umount(struct xfs_mount *mp); extern void libxfs_rtmount_destroy (xfs_mount_t *); +/* Dummy xfs_dquot so that libxfs compiles. */ +struct xfs_dquot { + int q_type; +}; + #endif /* __XFS_MOUNT_H__ */ diff --git a/libxfs/xfs_dquot_buf.c b/libxfs/xfs_dquot_buf.c index 847b9ba5280c..e5938ef649f0 100644 --- a/libxfs/xfs_dquot_buf.c +++ b/libxfs/xfs_dquot_buf.c @@ -67,6 +67,13 @@ xfs_dquot_verify( ddq_type != XFS_DQTYPE_GROUP) return __this_address; + if ((ddq->d_type & XFS_DQTYPE_BIGTIME) && + !xfs_sb_version_hasbigtime(&mp->m_sb)) + return __this_address; + + if ((ddq->d_type & XFS_DQTYPE_BIGTIME) && !ddq->d_id) + return __this_address; + if (id != -1 && id != be32_to_cpu(ddq->d_id)) return __this_address; @@ -294,6 +301,20 @@ xfs_dquot_from_disk_timestamp( time64_t *timer, __be32 dtimer) { + /* Zero always means zero, regardless of encoding. */ + if (!dtimer) { + *timer = 0; + return; + } + + if (ddq->d_type & XFS_DQTYPE_BIGTIME) { + uint64_t t; + + t = be32_to_cpu(dtimer); + *timer = t << XFS_DQ_BIGTIME_SHIFT; + return; + } + *timer = be32_to_cpu(dtimer); } @@ -304,5 +325,24 @@ xfs_dquot_to_disk_timestamp( __be32 *dtimer, time64_t timer) { + /* Zero always means zero, regardless of encoding. */ + if (!timer) { + *dtimer = cpu_to_be32(0); + return; + } + + if (dqp->q_type & XFS_DQTYPE_BIGTIME) { + uint64_t t = timer; + + /* + * Round the end of the grace period up to the nearest bigtime + * interval that we support, to give users the most time to fix + * the problems. + */ + t = roundup_64(t, 1U << XFS_DQ_BIGTIME_SHIFT); + *dtimer = cpu_to_be32(t >> XFS_DQ_BIGTIME_SHIFT); + return; + } + *dtimer = cpu_to_be32(timer); } diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index 67303e517260..87c86a6dfb91 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -1228,13 +1228,15 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) #define XFS_DQTYPE_USER 0x01 /* user dquot record */ #define XFS_DQTYPE_PROJ 0x02 /* project dquot record */ #define XFS_DQTYPE_GROUP 0x04 /* group dquot record */ +#define XFS_DQTYPE_BIGTIME 0x08 /* large expiry timestamps */ /* bitmask to determine if this is a user/group/project dquot */ #define XFS_DQTYPE_REC_MASK (XFS_DQTYPE_USER | \ XFS_DQTYPE_PROJ | \ XFS_DQTYPE_GROUP) -#define XFS_DQTYPE_ANY (XFS_DQTYPE_REC_MASK) +#define XFS_DQTYPE_ANY (XFS_DQTYPE_REC_MASK | \ + XFS_DQTYPE_BIGTIME) /* * XFS Quota Timers @@ -1271,6 +1273,28 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) #define XFS_DQ_GRACE_MIN ((int64_t)0) #define XFS_DQ_GRACE_MAX ((int64_t)U32_MAX) +/* + * When bigtime is enabled, we trade a few bits of precision to expand the + * expiration timeout range to match that of big inode timestamps. The grace + * periods stored in dquot 0 are not shifted, since they record an interval, + * not a timestamp. + */ +#define XFS_DQ_BIGTIME_SHIFT (2) + +/* + * Smallest possible quota expiration with big timestamps, which is + * Jan 1 00:00:01 UTC 1970. + */ +#define XFS_DQ_BIGTIMEOUT_MIN (XFS_DQ_TIMEOUT_MIN) + +/* + * Largest supported quota expiration with traditional timestamps, which is + * the largest bigtime inode timestamp, or Jul 2 20:20:25 UTC 2486. The field + * is large enough that it's possible to fit expirations up to 2514, but we + * want to keep the maximum timestamp in sync. + */ +#define XFS_DQ_BIGTIMEOUT_MAX (XFS_INO_BIGTIME_MAX) + /* * This is the main portion of the on-disk representation of quota information * for a user. We pad this with some more expansion room to construct the on diff --git a/libxfs/xfs_quota_defs.h b/libxfs/xfs_quota_defs.h index b524059faab5..b9a47eae684b 100644 --- a/libxfs/xfs_quota_defs.h +++ b/libxfs/xfs_quota_defs.h @@ -23,7 +23,8 @@ typedef uint8_t xfs_dqtype_t; #define XFS_DQTYPE_STRINGS \ { XFS_DQTYPE_USER, "USER" }, \ { XFS_DQTYPE_PROJ, "PROJ" }, \ - { XFS_DQTYPE_GROUP, "GROUP" } + { XFS_DQTYPE_GROUP, "GROUP" }, \ + { XFS_DQTYPE_BIGTIME, "BIGTIME" } /* * flags for q_flags field in the dquot. From patchwork Mon Aug 17 23:00:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11719575 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 81B0D722 for ; Mon, 17 Aug 2020 23:00:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A4A52063A for ; Mon, 17 Aug 2020 23:00:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ftlbfykz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728204AbgHQXAV (ORCPT ); Mon, 17 Aug 2020 19:00:21 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:52810 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728193AbgHQXAU (ORCPT ); Mon, 17 Aug 2020 19:00:20 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMvP8B050030; Mon, 17 Aug 2020 23:00:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=9fsRYLp6vgAkjzauIn/XlK6inpTu9yTp5JAIiA64B1g=; b=ftlbfykzQYf+CLf1x7yNwgPDV5g85UQP0SxaJRW8VDlDyaODPr5JLw2u8rac4SKE5gFV +riALoIl4WYMcLLKoPFG1OJfZGh3V5j6qofa2R//DDlF+j3jgilfjjBHfp/xZm7ltpKc +trIcUu6hwmb8sUS4zsIUURz/E8S65pxtsxk5OtQmL8f+GB5EhYJJgwBal273q1VPMh+ PWZHcktVdV2g88YfKezvomenEJWVypmacZQAuUAvz4pn7W65c4+FjHiz4UBAUN067DD8 BFtBUJiS1jfBi32wETIlLhGzmLpxD4EMPojZMZLzKOGCpjid3q6uwGNfBuTiveIzd1tQ dA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 32x7nm9juv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Aug 2020 23:00:18 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMw9DY084724; Mon, 17 Aug 2020 23:00:18 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 32xsfr5arq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Aug 2020 23:00:17 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07HN0Hwj017779; Mon, 17 Aug 2020 23:00:17 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Aug 2020 16:00:16 -0700 Subject: [PATCH 13/18] xfs: enable big timestamps From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 17 Aug 2020 16:00:16 -0700 Message-ID: <159770521602.3958786.7715509326251625669.stgit@magnolia> In-Reply-To: <159770513155.3958786.16108819726679724438.stgit@magnolia> References: <159770513155.3958786.16108819726679724438.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 spamscore=0 suspectscore=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 impostorscore=0 priorityscore=1501 adultscore=0 mlxscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 phishscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Enable the big timestamp feature. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- libxfs/xfs_format.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index 87c86a6dfb91..9e90270452b9 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -471,7 +471,8 @@ xfs_sb_has_ro_compat_feature( #define XFS_SB_FEAT_INCOMPAT_ALL \ (XFS_SB_FEAT_INCOMPAT_FTYPE| \ XFS_SB_FEAT_INCOMPAT_SPINODES| \ - XFS_SB_FEAT_INCOMPAT_META_UUID) + XFS_SB_FEAT_INCOMPAT_META_UUID| \ + XFS_SB_FEAT_INCOMPAT_BIGTIME) #define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL static inline bool From patchwork Mon Aug 17 23:00:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11719577 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12BDB739 for ; Mon, 17 Aug 2020 23:00:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E3689204EC for ; Mon, 17 Aug 2020 23:00:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="T5g/fH3a" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726624AbgHQXAc (ORCPT ); Mon, 17 Aug 2020 19:00:32 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:41712 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726575AbgHQXA1 (ORCPT ); Mon, 17 Aug 2020 19:00:27 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMwJTF148426; Mon, 17 Aug 2020 23:00:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=wpwnSpYFpo/+VcA1AcyccffYkBwIaBExY2vEe97kTlY=; b=T5g/fH3aBcQfxOBN8hm9gARYiJZGpMzfAc7lHg2OgwggaplL73tbxi/hx3VzU9LTIG8x dFu/KoJjWiqm98lSXcTdlhRnqY8+sSs9zePtdtj91+m/SWMaCVahmMhPw91RarW0AvCA QzrGoXqEYWRRpfdj/h7fPxpowXxRxwjD8wP2qQHXWJVPA4OXc2dpI5yaatxTwOqoJgrS N2wMlgA5O20Q79t6PYf08dwrqUUQbMK+HN6n+OBvHwY2O/SCHv2yNHYEBVwVKhsYsa7N e5f7FWtDPN4RXMEcr+cx84MA+5x3GSTpH2fswEAR4kcwauAvXKdCsv2YqFj9cBb/a85O 4A== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 32x8bn1g3y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Aug 2020 23:00:24 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMvjQj113983; Mon, 17 Aug 2020 23:00:23 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 32xsm18t3m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Aug 2020 23:00:23 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07HN0NPh015334; Mon, 17 Aug 2020 23:00:23 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Aug 2020 16:00:23 -0700 Subject: [PATCH 14/18] xfs_db: report bigtime format timestamps From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 17 Aug 2020 16:00:22 -0700 Message-ID: <159770522219.3958786.9075094123951100725.stgit@magnolia> In-Reply-To: <159770513155.3958786.16108819726679724438.stgit@magnolia> References: <159770513155.3958786.16108819726679724438.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 malwarescore=0 mlxscore=0 phishscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 clxscore=1015 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Report the large format timestamps. Signed-off-by: Darrick J. Wong --- db/dquot.c | 31 +++++++++++- db/field.c | 6 ++ db/field.h | 3 + db/fprint.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++ db/fprint.h | 6 ++ db/inode.c | 28 ++++++++++- db/sb.c | 2 + libxfs/libxfs_api_defs.h | 3 + 8 files changed, 194 insertions(+), 5 deletions(-) diff --git a/db/dquot.c b/db/dquot.c index edfcb0ca0744..30f4e6523c39 100644 --- a/db/dquot.c +++ b/db/dquot.c @@ -44,6 +44,22 @@ const field_t dqblk_flds[] = { { NULL } }; +static int +dquot_timestamp_count( + void *obj, + int startoff) +{ + return xfs_sb_version_hasbigtime(&mp->m_sb) ? 0 : 1; +} + +static int +dquot_bigtimestamp_count( + void *obj, + int startoff) +{ + return xfs_sb_version_hasbigtime(&mp->m_sb) ? 1 : 0; +} + #define DOFF(f) bitize(offsetof(struct xfs_disk_dquot, d_ ## f)) const field_t disk_dquot_flds[] = { { "magic", FLDT_UINT16X, OI(DOFF(magic)), C1, 0, TYP_NONE }, @@ -60,8 +76,14 @@ const field_t disk_dquot_flds[] = { TYP_NONE }, { "bcount", FLDT_QCNT, OI(DOFF(bcount)), C1, 0, TYP_NONE }, { "icount", FLDT_QCNT, OI(DOFF(icount)), C1, 0, TYP_NONE }, - { "itimer", FLDT_INT32D, OI(DOFF(itimer)), C1, 0, TYP_NONE }, - { "btimer", FLDT_INT32D, OI(DOFF(btimer)), C1, 0, TYP_NONE }, + { "itimer", FLDT_INT32D, OI(DOFF(itimer)), dquot_timestamp_count, + FLD_COUNT, TYP_NONE }, + { "btimer", FLDT_INT32D, OI(DOFF(btimer)), dquot_timestamp_count, + FLD_COUNT, TYP_NONE }, + { "itimer", FLDT_BTQTIMER, OI(DOFF(itimer)), dquot_bigtimestamp_count, + FLD_COUNT, TYP_NONE }, + { "btimer", FLDT_BTQTIMER, OI(DOFF(btimer)), dquot_bigtimestamp_count, + FLD_COUNT, TYP_NONE }, { "iwarns", FLDT_QWARNCNT, OI(DOFF(iwarns)), C1, 0, TYP_NONE }, { "bwarns", FLDT_QWARNCNT, OI(DOFF(bwarns)), C1, 0, TYP_NONE }, { "pad0", FLDT_UINT32X, OI(DOFF(pad0)), C1, FLD_SKIPALL, TYP_NONE }, @@ -70,7 +92,10 @@ const field_t disk_dquot_flds[] = { { "rtb_softlimit", FLDT_QCNT, OI(DOFF(rtb_softlimit)), C1, 0, TYP_NONE }, { "rtbcount", FLDT_QCNT, OI(DOFF(rtbcount)), C1, 0, TYP_NONE }, - { "rtbtimer", FLDT_INT32D, OI(DOFF(rtbtimer)), C1, 0, TYP_NONE }, + { "rtbtimer", FLDT_INT32D, OI(DOFF(rtbtimer)), dquot_timestamp_count, + FLD_COUNT, TYP_NONE }, + { "rtbtimer", FLDT_BTQTIMER, OI(DOFF(rtbtimer)), + dquot_bigtimestamp_count, FLD_COUNT, TYP_NONE }, { "rtbwarns", FLDT_QWARNCNT, OI(DOFF(rtbwarns)), C1, 0, TYP_NONE }, { "pad", FLDT_UINT16X, OI(DOFF(pad)), C1, FLD_SKIPALL, TYP_NONE }, { NULL } diff --git a/db/field.c b/db/field.c index cf3002c730e6..fad17b1f082e 100644 --- a/db/field.c +++ b/db/field.c @@ -351,6 +351,12 @@ const ftattr_t ftattrtab[] = { NULL, NULL }, { FLDT_TIMESTAMP, "timestamp", NULL, (char *)timestamp_flds, SI(bitsz(union xfs_timestamp)), 0, NULL, timestamp_flds }, + { FLDT_BTSEC, "btsec", fp_btsec, NULL, SI(bitsz(uint64_t)), 0, NULL, + NULL }, + { FLDT_BTNSEC, "btnsec", fp_btnsec, NULL, SI(bitsz(uint64_t)), 0, NULL, + NULL }, + { FLDT_BTQTIMER, "btqtimer", fp_btqtimer, NULL, SI(bitsz(uint32_t)), 0, + NULL, NULL }, { FLDT_UINT1, "uint1", fp_num, "%u", SI(1), 0, NULL, NULL }, { FLDT_UINT16D, "uint16d", fp_num, "%u", SI(bitsz(uint16_t)), 0, NULL, NULL }, diff --git a/db/field.h b/db/field.h index 15065373de39..0d27cd085b13 100644 --- a/db/field.h +++ b/db/field.h @@ -170,6 +170,9 @@ typedef enum fldt { FLDT_TIME, FLDT_TIMESTAMP, + FLDT_BTSEC, + FLDT_BTNSEC, + FLDT_BTQTIMER, FLDT_UINT1, FLDT_UINT16D, FLDT_UINT16O, diff --git a/db/fprint.c b/db/fprint.c index c9d07e1bca7e..3a4f839b355d 100644 --- a/db/fprint.c +++ b/db/fprint.c @@ -19,6 +19,7 @@ #include "sig.h" #include "malloc.h" #include "io.h" +#include "init.h" int fp_charns( @@ -145,6 +146,125 @@ fp_time( return 1; } +static void +fp_timespec64( + struct timespec64 *ts) +{ + BUILD_BUG_ON(sizeof(long) != sizeof(time_t)); + + if (ts->tv_sec > LONG_MAX || ts->tv_sec < LONG_MIN) { + dbprintf("%lld", (long long)ts->tv_sec); + } else { + time_t tt = ts->tv_sec; + char *c; + + c = ctime(&tt); + dbprintf("%24.24s", c); + } +} + +int +fp_btsec( + void *obj, + int bit, + int count, + char *fmtstr, + int size, + int arg, + int base, + int array) +{ + struct timespec64 ts; + union xfs_timestamp *xts; + int bitpos; + int i; + + ASSERT(bitoffs(bit) == 0); + for (i = 0, bitpos = bit; + i < count && !seenint(); + i++, bitpos += size) { + if (array) + dbprintf("%d:", i + base); + xts = obj + byteize(bitpos); + libxfs_inode_from_disk_timestamp(obj, &ts, xts); + fp_timespec64(&ts); + if (i < count - 1) + dbprintf(" "); + } + return 1; +} + +int +fp_btnsec( + void *obj, + int bit, + int count, + char *fmtstr, + int size, + int arg, + int base, + int array) +{ + struct timespec64 ts; + union xfs_timestamp *xts; + int bitpos; + int i; + + ASSERT(bitoffs(bit) == 0); + for (i = 0, bitpos = bit; + i < count && !seenint(); + i++, bitpos += size) { + if (array) + dbprintf("%d:", i + base); + xts = obj + byteize(bitpos); + libxfs_inode_from_disk_timestamp(obj, &ts, xts); + dbprintf("%u", ts.tv_nsec); + if (i < count - 1) + dbprintf(" "); + } + return 1; +} + +int +fp_btqtimer( + void *obj, + int bit, + int count, + char *fmtstr, + int size, + int arg, + int base, + int array) +{ + struct timespec64 ts = { 0 }; + struct xfs_disk_dquot *ddq = obj; + __be32 *t; + int bitpos; + int i; + + ASSERT(bitoffs(bit) == 0); + for (i = 0, bitpos = bit; + i < count && !seenint(); + i++, bitpos += size) { + if (array) + dbprintf("%d:", i + base); + t = obj + byteize(bitpos); + libxfs_dquot_from_disk_timestamp(ddq, &ts.tv_sec, *t); + + /* + * Display the raw value if it's the default grace expiration + * period (root dquot) or if the quota has not expired. + */ + if (ddq->d_id == 0 || ts.tv_sec == 0) + dbprintf("%llu", (unsigned long long)ts.tv_sec); + else + fp_timespec64(&ts); + if (i < count - 1) + dbprintf(" "); + } + return 1; +} + /*ARGSUSED*/ int fp_uuid( diff --git a/db/fprint.h b/db/fprint.h index c958dca0ed92..a33dcd11248d 100644 --- a/db/fprint.h +++ b/db/fprint.h @@ -15,6 +15,12 @@ extern int fp_sarray(void *obj, int bit, int count, char *fmtstr, int size, int arg, int base, int array); extern int fp_time(void *obj, int bit, int count, char *fmtstr, int size, int arg, int base, int array); +extern int fp_btsec(void *obj, int bit, int count, char *fmtstr, int size, + int arg, int base, int array); +extern int fp_btnsec(void *obj, int bit, int count, char *fmtstr, int size, + int arg, int base, int array); +extern int fp_btqtimer(void *obj, int bit, int count, char *fmtstr, + int size, int arg, int base, int array); extern int fp_uuid(void *obj, int bit, int count, char *fmtstr, int size, int arg, int base, int array); extern int fp_crc(void *obj, int bit, int count, char *fmtstr, int size, diff --git a/db/inode.c b/db/inode.c index 25112bb5e4d8..5fbfd4ddb5f5 100644 --- a/db/inode.c +++ b/db/inode.c @@ -175,14 +175,38 @@ const field_t inode_v3_flds[] = { { "dax", FLDT_UINT1, OI(COFF(flags2) + bitsz(uint64_t) - XFS_DIFLAG2_DAX_BIT - 1), C1, 0, TYP_NONE }, + { "bigtime", FLDT_UINT1, + OI(COFF(flags2) + bitsz(uint64_t) - XFS_DIFLAG2_BIGTIME_BIT - 1), C1, + 0, TYP_NONE }, { NULL } }; +static int +inode_timestamp_count( + void *obj, + int startoff) +{ + return xfs_sb_version_hasbigtime(&mp->m_sb) ? 0 : 1; +} + +static int +inode_bigtimestamp_count( + void *obj, + int startoff) +{ + return xfs_sb_version_hasbigtime(&mp->m_sb) ? 1 : 0; +} #define TOFF(f) bitize(offsetof(union xfs_timestamp, t_ ## f)) const field_t timestamp_flds[] = { - { "sec", FLDT_TIME, OI(TOFF(sec)), C1, 0, TYP_NONE }, - { "nsec", FLDT_NSEC, OI(TOFF(nsec)), C1, 0, TYP_NONE }, + { "sec", FLDT_TIME, OI(TOFF(sec)), inode_timestamp_count, FLD_COUNT, + TYP_NONE }, + { "nsec", FLDT_NSEC, OI(TOFF(nsec)), inode_timestamp_count, FLD_COUNT, + TYP_NONE }, + { "sec", FLDT_BTSEC, OI(TOFF(bigtime)), inode_bigtimestamp_count, + FLD_COUNT, TYP_NONE }, + { "nsec", FLDT_BTNSEC, OI(TOFF(bigtime)), inode_bigtimestamp_count, + FLD_COUNT, TYP_NONE }, { NULL } }; diff --git a/db/sb.c b/db/sb.c index 33d9f7df49bb..c68bb9a958e7 100644 --- a/db/sb.c +++ b/db/sb.c @@ -727,6 +727,8 @@ version_string( strcat(s, ",REFLINK"); if (xfs_sb_version_hasinobtcounts(sbp)) strcat(s, ",INOBTCNT"); + if (xfs_sb_version_hasbigtime(sbp)) + strcat(s, ",BIGTIME"); return s; } diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 4ee02473df0d..b83dc48a4802 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -116,6 +116,7 @@ struct timespec64 { #define xfs_dir_replace libxfs_dir_replace #define xfs_dqblk_repair libxfs_dqblk_repair +#define xfs_dquot_from_disk_timestamp libxfs_dquot_from_disk_timestamp #define xfs_dquot_verify libxfs_dquot_verify #define xfs_finobt_calc_reserves libxfs_finobt_calc_reserves @@ -137,7 +138,9 @@ struct timespec64 { #define xfs_inobt_maxrecs libxfs_inobt_maxrecs #define xfs_inobt_stage_cursor libxfs_inobt_stage_cursor #define xfs_inode_from_disk libxfs_inode_from_disk +#define xfs_inode_from_disk_timestamp libxfs_inode_from_disk_timestamp #define xfs_inode_to_disk libxfs_inode_to_disk +#define xfs_inode_to_disk_timestamp libxfs_inode_to_disk_timestamp #define xfs_inode_validate_cowextsize libxfs_inode_validate_cowextsize #define xfs_inode_validate_extsize libxfs_inode_validate_extsize From patchwork Mon Aug 17 23:00:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11719579 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1AE36722 for ; Mon, 17 Aug 2020 23:00:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F294E20674 for ; Mon, 17 Aug 2020 23:00:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="AUHNorEO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726727AbgHQXAg (ORCPT ); Mon, 17 Aug 2020 19:00:36 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:52924 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726653AbgHQXAe (ORCPT ); Mon, 17 Aug 2020 19:00:34 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMvbxW050119; Mon, 17 Aug 2020 23:00:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=X5sWABW6pmCKbb5bhb6PC5fTyixPHtTwwRolz0x8Ha8=; b=AUHNorEOtVamCm94gL2I+1owJTiPURRonoPNlSHeQaV1SdNfTBZuVSjNzL40VurqVolS bFtQLODt6RFK7msqr6voFpK4tgFPDv+3ungKXysaF9MqRHbjCZqhcpfDngW2zBhKUdqm V1gQyW3GrzGDNha6lZs6oJSDELzThBWgD5NcQ0ZhDmawhUq38DJ3L7Xzl3dOFAx5B4en voFzsb4g2g8etyb58jZ3JRFtK+8L+KrrPN4l2z0fUkk7HxU3MFV/3IsMuyDitpTb0K74 QXFK1AePMt14P30rZVIOoLhpD7KUiziQpx531LduB27lHZrYDT/bH2bMCI+zj+v+pMqy 1Q== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 32x7nm9jvb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Aug 2020 23:00:32 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMw9Dc084724; Mon, 17 Aug 2020 23:00:31 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 32xsfr5b23-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Aug 2020 23:00:31 +0000 Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07HN0UNf015383; Mon, 17 Aug 2020 23:00:30 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Aug 2020 16:00:30 -0700 Subject: [PATCH 15/18] xfs_db: support printing time limits From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 17 Aug 2020 16:00:28 -0700 Message-ID: <159770522842.3958786.974580388335386010.stgit@magnolia> In-Reply-To: <159770513155.3958786.16108819726679724438.stgit@magnolia> References: <159770513155.3958786.16108819726679724438.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 spamscore=0 suspectscore=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 impostorscore=0 priorityscore=1501 adultscore=0 mlxscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 phishscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Support printing the minimum and maxium timestamp limits on this filesystem. Signed-off-by: Darrick J. Wong --- db/Makefile | 2 - db/command.c | 1 db/command.h | 1 db/timelimit.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++++++ man/man8/xfs_db.8 | 23 ++++++++ 5 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 db/timelimit.c diff --git a/db/Makefile b/db/Makefile index 9bd9bf514f5d..9d502bf0d0d6 100644 --- a/db/Makefile +++ b/db/Makefile @@ -14,7 +14,7 @@ HFILES = addr.h agf.h agfl.h agi.h attr.h attrshort.h bit.h block.h bmap.h \ io.h logformat.h malloc.h metadump.h output.h print.h quit.h sb.h \ sig.h strvec.h text.h type.h write.h attrset.h symlink.h fsmap.h \ fuzz.h -CFILES = $(HFILES:.h=.c) btdump.c btheight.c convert.c info.c +CFILES = $(HFILES:.h=.c) btdump.c btheight.c convert.c info.c timelimit.c LSRCFILES = xfs_admin.sh xfs_ncheck.sh xfs_metadump.sh LLDLIBS = $(LIBXFS) $(LIBXLOG) $(LIBFROG) $(LIBUUID) $(LIBRT) $(LIBPTHREAD) diff --git a/db/command.c b/db/command.c index 0fb44efaec59..438283699b2e 100644 --- a/db/command.c +++ b/db/command.c @@ -139,4 +139,5 @@ init_commands(void) write_init(); dquot_init(); fuzz_init(); + timelimit_init(); } diff --git a/db/command.h b/db/command.h index b8499de0be17..6913c8171fe1 100644 --- a/db/command.h +++ b/db/command.h @@ -32,3 +32,4 @@ extern void convert_init(void); extern void btdump_init(void); extern void info_init(void); extern void btheight_init(void); +extern void timelimit_init(void); diff --git a/db/timelimit.c b/db/timelimit.c new file mode 100644 index 000000000000..3cb24f563e3a --- /dev/null +++ b/db/timelimit.c @@ -0,0 +1,152 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2020 Oracle. All Rights Reserved. + * Author: Darrick J. Wong + */ +#include "libxfs.h" +#include "command.h" +#include "output.h" +#include "init.h" + +enum show_what { + SHOW_AUTO, + SHOW_CLASSIC, + SHOW_BIGTIME, +}; + + +enum print_how { + PRINT_RAW, + PRINT_PRETTY, + PRINT_COMPACT, +}; + +static void +show_limit( + const char *tag, + int64_t limit, + int how) +{ + time_t tt = limit; + char *c; + + if (how == PRINT_COMPACT) { + dbprintf("%" PRId64 " ", limit); + return; + } + + if (how == PRINT_RAW || limit > LONG_MAX) { + dbprintf("%s = %" PRId64 "\n", tag, limit); + return; + } + + c = ctime(&tt); + dbprintf("%s = %24.24s\n", tag, c); +} + +static void +show_limits( + int whatkind, + int how) +{ + int grace_how = how; + + switch (whatkind) { + case SHOW_AUTO: + /* should never get here */ + break; + case SHOW_CLASSIC: + show_limit("time.min", XFS_INO_TIME_MIN, how); + show_limit("time.max", XFS_INO_TIME_MAX, how); + show_limit("dqtimer.min", XFS_DQ_TIMEOUT_MIN, how); + show_limit("dqtimer.max", XFS_DQ_TIMEOUT_MAX, how); + break; + case SHOW_BIGTIME: + show_limit("time.min", XFS_INO_BIGTIME_MIN, how); + show_limit("time.max", XFS_INO_BIGTIME_MAX, how); + show_limit("dqtimer.min", XFS_DQ_BIGTIMEOUT_MIN, how); + show_limit("dqtimer.max", XFS_DQ_BIGTIMEOUT_MAX, how); + break; + } + + /* grace periods are always integers */ + if (grace_how != PRINT_COMPACT) + grace_how = PRINT_RAW; + show_limit("dqgrace.min", XFS_DQ_GRACE_MIN, grace_how); + show_limit("dqgrace.min", XFS_DQ_GRACE_MAX, grace_how); + + if (how == PRINT_COMPACT) + dbprintf("\n"); +} + +static int +timelimit_f( + int argc, + char **argv) +{ + int whatkind = SHOW_AUTO; + int how = PRINT_RAW; + int i; + + for (i = 1; i < argc; i++) { + if (!strcmp("--classic", argv[i])) + whatkind = SHOW_CLASSIC; + else if (!strcmp("--bigtime", argv[i])) + whatkind = SHOW_BIGTIME; + else if (!strcmp("--pretty", argv[i])) + how = PRINT_PRETTY; + else if (!strcmp("--compact", argv[i])) + how = PRINT_COMPACT; + else { + dbprintf(_("%s: bad option for timelimit command\n"), + argv[i]); + return 1; + } + } + + if (whatkind == SHOW_AUTO) { + if (xfs_sb_version_hasbigtime(&mp->m_sb)) + whatkind = SHOW_BIGTIME; + else + whatkind = SHOW_CLASSIC; + } + + show_limits(whatkind, how); + return 0; +} + +static void +timelimit_help(void) +{ + dbprintf(_( +"\n" +" Print the minimum and maximum supported values for inode timestamps,\n" +" disk quota expiration timers, and disk quota grace periods supported\n" +" by this filesystem.\n" +"\n" +" Options:\n" +" --classic -- Force printing of the classic time limits.\n" +" --bigtime -- Force printing of the bigtime limits.\n" +" --pretty -- Pretty-print the time limits.\n" +" --compact -- Print the limits in a single line.\n" +"\n" +)); + +} + +static const cmdinfo_t timelimit_cmd = { + .name = "timelimit", + .cfunc = timelimit_f, + .argmin = 0, + .argmax = -1, + .canpush = 0, + .args = N_("[--classic|--bigtime] [--pretty]"), + .oneline = N_("display timestamp limits"), + .help = timelimit_help, +}; + +void +timelimit_init(void) +{ + add_command(&timelimit_cmd); +} diff --git a/man/man8/xfs_db.8 b/man/man8/xfs_db.8 index 7f73d458cf76..55388be68b93 100644 --- a/man/man8/xfs_db.8 +++ b/man/man8/xfs_db.8 @@ -887,6 +887,29 @@ The possible data types are: .BR rtsummary ", " sb ", " symlink " and " text . See the TYPES section below for more information on these data types. .TP +.BI "timelimit [" OPTIONS ] +Print the minimum and maximum supported values for inode timestamps, +quota expiration timers, and quota grace periods supported by this +filesystem. +Options include: +.RS 1.0i +.TP 0.4i +.B \--bigtime +Print the time limits of an XFS filesystem with the +.B bigtime +feature enabled. +.TP 0.4i +.B \--classic +Print the time limits of a classic XFS filesystem. +.TP 0.4i +.B \--compact +Print all limits as raw values on a single line. +.TP 0.4i +.B \--pretty +Print the timestamps in the current locale's date and time format instead of +raw seconds since the Unix epoch. +.RE +.TP .BI "uuid [" uuid " | " generate " | " rewrite " | " restore ] Set the filesystem universally unique identifier (UUID). The filesystem UUID can be used by From patchwork Mon Aug 17 23:00:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11719583 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 934C6739 for ; Mon, 17 Aug 2020 23:00:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 787CB2063A for ; Mon, 17 Aug 2020 23:00:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="P1U5ULmq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726473AbgHQXAk (ORCPT ); Mon, 17 Aug 2020 19:00:40 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:36258 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726575AbgHQXAj (ORCPT ); Mon, 17 Aug 2020 19:00:39 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMwCxW164183; Mon, 17 Aug 2020 23:00:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=Ax4OqLGp10tExI9Izhe7aJt2YavfMu0WFzLxkSgjRIg=; b=P1U5ULmq40shk349MH6IiSA8UqFvbOvE5ZGKWY1AdmHnBsLNkchXtES78w79lKvPHNkj +atf8snVW2NlCIyj8fr+Ted1tCdN9QcnQUuXa+ro3rk9VCrzLwBKVpXb9juzhEdSVZ5D TSeFsh+lLEVh3n8e7bz9MOa2xu76uz/RCiJLHGpD4bTSoSsLXr4yk5jy2udjFnr/dgwR OqgjZ+LXLQzp4/3Rl9kBSCTUQciU8YupMVNPIowizIg5Rt23XbwWEigioA/UXh2C03gE B6S6jlP+mlnGbVfBnuqPeVUHmQiyEwcENp94bdzny20UiEKdHcoVkD6hQ7m0PqmAOYll 8Q== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 32x74r1mxn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Aug 2020 23:00:37 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMw9qf084620; Mon, 17 Aug 2020 23:00:37 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 32xsfr5b5t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Aug 2020 23:00:37 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07HN0aBr017902; Mon, 17 Aug 2020 23:00:37 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Aug 2020 16:00:36 -0700 Subject: [PATCH 16/18] xfs_db: add bigtime upgrade path From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 17 Aug 2020 16:00:35 -0700 Message-ID: <159770523573.3958786.6421311732799623643.stgit@magnolia> In-Reply-To: <159770513155.3958786.16108819726679724438.stgit@magnolia> References: <159770513155.3958786.16108819726679724438.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 spamscore=0 suspectscore=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=999 priorityscore=1501 phishscore=0 spamscore=0 mlxscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Enable users to upgrade their filesystems to bigtime support. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- db/sb.c | 13 +++++++++++++ man/man8/xfs_admin.8 | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/db/sb.c b/db/sb.c index c68bb9a958e7..4fb66dade2c2 100644 --- a/db/sb.c +++ b/db/sb.c @@ -778,6 +778,19 @@ version_f( } upgrade_ro_compat |= XFS_SB_FEAT_RO_COMPAT_INOBTCNT; + } else if (!strcasecmp(argv[1], "bigtime")) { + if (xfs_sb_version_hasbigtime(&mp->m_sb)) { + dbprintf( + _("bigtime feature is already enabled\n")); + return 0; + } + if (!xfs_sb_version_hascrc(&mp->m_sb)) { + dbprintf( + _("bigtime feature cannot be enabled on pre-V5 filesystems\n")); + return 0; + } + + upgrade_incompat |= XFS_SB_FEAT_INCOMPAT_BIGTIME; } else if (!strcasecmp(argv[1], "extflg")) { switch (XFS_SB_VERSION_NUM(&mp->m_sb)) { case XFS_SB_VERSION_1: diff --git a/man/man8/xfs_admin.8 b/man/man8/xfs_admin.8 index 65ca6afc1e12..c09fe62b6827 100644 --- a/man/man8/xfs_admin.8 +++ b/man/man8/xfs_admin.8 @@ -117,6 +117,11 @@ This reduces mount time by caching the size of the inode btrees in the allocation group metadata. Once enabled, the filesystem will not be writable by older kernels. The filesystem cannot be downgraded after this feature is enabled. +.TP +.B bigtime +Upgrade the filesystem to support larger timestamps up to the year 2486. +Once enabled, the filesystem will not be readable by older kernels. +The filesystem cannot be downgraded. .RE .TP .BI \-U " uuid" From patchwork Mon Aug 17 23:00:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11719585 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83351722 for ; Mon, 17 Aug 2020 23:00:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D6DF2072D for ; Mon, 17 Aug 2020 23:00:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="OziqLLc/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727776AbgHQXAs (ORCPT ); Mon, 17 Aug 2020 19:00:48 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:41884 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726482AbgHQXAq (ORCPT ); Mon, 17 Aug 2020 19:00:46 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMuu86136112; Mon, 17 Aug 2020 23:00:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=ZTwQTMn+bmKz2sa/ePtYNIFWWIfKQfsymsvGiSdvHSU=; b=OziqLLc/pXBcHnUudKjvG6AeA0uqB2NnzrW1aIXm1dPsO3yyVl/qlDgT2Chx2e5gAIZK 4R9L3MMo0+cICtHNQPXBoBtJAEH8US+C++wpMD/ihBQnmd5igffMV5oWcK4zH/gecftN vm1we+GV4qChRuvXoaJyMsHEu9MuApu9y5BeRsGAr4/6EVZRtoqoiK1YWqC3dfFawTL2 /JgEEiIoKalK5pcjQy3sxGxNSkSSEVvnhcc3WnF6Kh5JUjeDV4x+eep/UVV5al+Xxz0e 8l9wP0vhrh6c0qQeB2xa76vk8aC7apg6fLXc2688CA70dkoIl2Gb5PYv4VdNUjvJ5BCm wQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 32x8bn1g4s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Aug 2020 23:00:44 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMwthT113630; Mon, 17 Aug 2020 23:00:43 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 32xsmwgjkm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Aug 2020 23:00:43 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07HN0hd9018568; Mon, 17 Aug 2020 23:00:43 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Aug 2020 16:00:42 -0700 Subject: [PATCH 17/18] xfs_repair: support bigtime From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 17 Aug 2020 16:00:41 -0700 Message-ID: <159770524187.3958786.13522554876108493954.stgit@magnolia> In-Reply-To: <159770513155.3958786.16108819726679724438.stgit@magnolia> References: <159770513155.3958786.16108819726679724438.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 clxscore=1015 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Check the bigtime iflag in relation to the fs feature set. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- repair/dinode.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/repair/dinode.c b/repair/dinode.c index ad2f672d8703..3507cd06075d 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -2173,7 +2173,8 @@ check_nsec( union xfs_timestamp *t, int *dirty) { - if ((dip->di_flags2 & be64_to_cpu(XFS_DIFLAG2_BIGTIME)) || + if ((dip->di_version >= 3 && + (dip->di_flags2 & cpu_to_be64(XFS_DIFLAG2_BIGTIME))) || be32_to_cpu(t->t_nsec) < NSEC_PER_SEC) return; @@ -2601,6 +2602,16 @@ _("bad (negative) size %" PRId64 " on inode %" PRIu64 "\n"), flags2 &= ~XFS_DIFLAG2_COWEXTSIZE; } + if ((flags2 & XFS_DIFLAG2_BIGTIME) && + !xfs_sb_version_hasbigtime(&mp->m_sb)) { + if (!uncertain) { + do_warn( + _("inode %" PRIu64 " is marked bigtime but file system does not support large timestamps\n"), + lino); + } + flags2 &= ~XFS_DIFLAG2_BIGTIME; + } + if (!verify_mode && flags2 != be64_to_cpu(dino->di_flags2)) { if (!no_modify) { do_warn(_("fixing bad flags2.\n")); From patchwork Mon Aug 17 23:00:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11719591 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 614DB14F6 for ; Mon, 17 Aug 2020 23:00:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49B1620674 for ; Mon, 17 Aug 2020 23:00:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ULSEcyxp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726303AbgHQXA4 (ORCPT ); Mon, 17 Aug 2020 19:00:56 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:36350 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728168AbgHQXAx (ORCPT ); Mon, 17 Aug 2020 19:00:53 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMwCxX164183; Mon, 17 Aug 2020 23:00:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=Iuz9a7wR40ETUC1+oUndSlH4BlGONlpBt9hoDpeC0lU=; b=ULSEcyxpyzRQ5viBEWsgtz+El8Yc5uNLFOtIrEjxe8e2rA8ALna0fuBl0tuX6mKYGl3B TMaFsPj0FqAfu+qr7FJGeBgRvwW4Un0Xkx7hv3Xzh7TCzJApwLdlWi0z5J7zZlS3ddoy O5lb4YmxQn/kBuOWVg50Fj3VS/nZk1vb/F7kyi7uifYENBY55N3UC53PtdFAWVRkfo82 PzYEGPHoT0+GMpJYk1GiQvEFPLQAau+jPtJ3yN09lW9CYYYVA2STdaubcTIVTpP4EHiL zMV1y1Zp41RQirC/PI23EO5RThBQ4EVNhTSzcEj4onxsWVqnCJMlJLgW9TNi6l/ECJje FQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 32x74r1my7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Aug 2020 23:00:51 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07HMw7IN138964; Mon, 17 Aug 2020 23:00:50 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 32xs9ma1aa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Aug 2020 23:00:50 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07HN0n0H017951; Mon, 17 Aug 2020 23:00:49 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Aug 2020 16:00:48 -0700 Subject: [PATCH 18/18] mkfs: format bigtime filesystems From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 17 Aug 2020 16:00:48 -0700 Message-ID: <159770524797.3958786.6498012041319904192.stgit@magnolia> In-Reply-To: <159770513155.3958786.16108819726679724438.stgit@magnolia> References: <159770513155.3958786.16108819726679724438.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 adultscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9716 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=999 priorityscore=1501 phishscore=0 spamscore=0 mlxscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008170153 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Allow formatting with large timestamps. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- man/man8/mkfs.xfs.8 | 16 ++++++++++++++++ mkfs/xfs_mkfs.c | 24 +++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/man/man8/mkfs.xfs.8 b/man/man8/mkfs.xfs.8 index 082f3ab6c063..7434b9f2b4cd 100644 --- a/man/man8/mkfs.xfs.8 +++ b/man/man8/mkfs.xfs.8 @@ -154,6 +154,22 @@ valid are: .RS 1.2i .TP +.BI bigtime= value +This option enables filesystems that can handle inode timestamps from December +1901 to July 2486, and quota timer expirations from January 1970 to July 2486. +The value is either 0 to disable the feature, or 1 to enable large timestamps. +.IP +If this feature is not enabled, the filesystem can only handle timestamps from +December 1901 to January 2038, and quota timers from January 1970 to February +2106. +.IP +By default, +.B mkfs.xfs +will not enable this feature. +If the option +.B \-m crc=0 +is used, the large timestamp feature is not supported and is disabled. +.TP .BI crc= value This is used to create a filesystem which maintains and checks CRC information in all metadata objects on disk. The value is either 0 to disable the feature, diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 037246effd70..f9f78a020092 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -120,6 +120,7 @@ enum { M_RMAPBT, M_REFLINK, M_INOBTCNT, + M_BIGTIME, M_MAX_OPTS, }; @@ -667,6 +668,7 @@ static struct opt_params mopts = { [M_RMAPBT] = "rmapbt", [M_REFLINK] = "reflink", [M_INOBTCNT] = "inobtcount", + [M_BIGTIME] = "bigtime", }, .subopt_params = { { .index = M_CRC, @@ -703,6 +705,12 @@ static struct opt_params mopts = { .maxval = 1, .defaultval = 1, }, + { .index = M_BIGTIME, + .conflicts = { { NULL, LAST_CONFLICT } }, + .minval = 0, + .maxval = 1, + .defaultval = 1, + }, }, }; @@ -755,6 +763,7 @@ struct sb_feat_args { bool rmapbt; /* XFS_SB_FEAT_RO_COMPAT_RMAPBT */ bool reflink; /* XFS_SB_FEAT_RO_COMPAT_REFLINK */ bool inobtcnt; /* XFS_SB_FEAT_RO_COMPAT_INOBTCNT */ + bool bigtime; /* XFS_SB_FEAT_INCOMPAT_BIGTIME */ bool nodalign; bool nortalign; }; @@ -878,7 +887,7 @@ usage( void ) fprintf(stderr, _("Usage: %s\n\ /* blocksize */ [-b size=num]\n\ /* metadata */ [-m crc=0|1,finobt=0|1,uuid=xxx,rmapbt=0|1,reflink=0|1,\n\ - inobtcnt=0|1]\n\ + inobtcnt=0|1,bigtime=0|1]\n\ /* data subvol */ [-d agcount=n,agsize=n,file,name=xxx,size=num,\n\ (sunit=value,swidth=value|su=num,sw=num|noalign),\n\ sectsize=num\n\ @@ -1621,6 +1630,9 @@ meta_opts_parser( case M_INOBTCNT: cli->sb_feat.inobtcnt = getnum(value, opts, subopt); break; + case M_BIGTIME: + cli->sb_feat.bigtime = getnum(value, opts, subopt); + break; default: return -EINVAL; } @@ -2044,6 +2056,13 @@ _("reflink not supported without CRC support\n")); usage(); } cli->sb_feat.reflink = false; + + if (cli->sb_feat.bigtime) { + fprintf(stderr, +_("big timestamps not supported without CRC support\n")); + usage(); + } + cli->sb_feat.bigtime = false; } if (!cli->sb_feat.finobt) { @@ -3020,6 +3039,8 @@ sb_set_features( sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_REFLINK; if (fp->inobtcnt) sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_INOBTCNT; + if (fp->bigtime) + sbp->sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_BIGTIME; /* * Sparse inode chunk support has two main inode alignment requirements. @@ -3692,6 +3713,7 @@ main( .parent_pointers = false, .nodalign = false, .nortalign = false, + .bigtime = false, }, };