From patchwork Wed Jun 12 06:49:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10988659 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1162E14BB for ; Wed, 12 Jun 2019 06:49:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F03AD289A1 for ; Wed, 12 Jun 2019 06:49:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE934289AD; Wed, 12 Jun 2019 06:49:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41526289A6 for ; Wed, 12 Jun 2019 06:49:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731235AbfFLGtO (ORCPT ); Wed, 12 Jun 2019 02:49:14 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:34176 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726783AbfFLGtO (ORCPT ); Wed, 12 Jun 2019 02:49:14 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C6nDCa055593 for ; Wed, 12 Jun 2019 06:49: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-2018-07-02; bh=SrQnG+Dm9pCZMbtfZe9hvR9EGVQm90mR88dBVfh3FXs=; b=X9MQPyOpPpcwSA4nasXEr7zylOTH0dxUpmzDDeAMbiSCodqNXCl6IiqoHz8HAwYwbiK2 WOJMWaiYHLK9Sr8Rz0lWI6y+/OrQGJJ3XrcNXrdO9BBW5RQ0UnVUb0Tq0nrctDUcqgdR v9hB+aR+t7KvCOiH4kKB9RJRcoNrJ4+ZBgqbDgN1lTEaULO35Hjen1mUGBv1mzvmkcfb S0fWrgrq/l+rvE1l5ix4eobThpPjfsoLrRElyrDlPrS9qpzqrgOFc4X20Xn6e4NKs1NR 8+S2QjhIpa0yeKbgOL4F2cFejDhb0ucoxdS9sOzeGVK+a+kT9IKTtvS0x7S7/iBty/it qw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2t05nqsbun-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 Jun 2019 06:49:13 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C6msTS049361 for ; Wed, 12 Jun 2019 06:49:12 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2t04hyrwtr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 Jun 2019 06:49:12 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5C6nCw8019329 for ; Wed, 12 Jun 2019 06:49:12 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 11 Jun 2019 23:49:11 -0700 Subject: [PATCH 1/9] xfs: remove various bulk request typedef usage From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, allison.henderson@oracle.com Date: Tue, 11 Jun 2019 23:49:10 -0700 Message-ID: <156032215069.3774581.2889208827415117467.stgit@magnolia> In-Reply-To: <156032214432.3774581.1304900948974476604.stgit@magnolia> References: <156032214432.3774581.1304900948974476604.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120047 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120047 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Remove xfs_bstat_t, xfs_fsop_bulkreq_t, xfs_inogrp_t, and similarly named compat typedefs. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Collins --- fs/xfs/libxfs/xfs_fs.h | 16 ++++++++-------- fs/xfs/xfs_ioctl.c | 2 +- fs/xfs/xfs_ioctl32.c | 11 +++++++---- fs/xfs/xfs_ioctl32.h | 14 +++++++------- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index e7382c780ed7..ef0dce229fa4 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -97,7 +97,7 @@ struct getbmapx { * For use by backup and restore programs to set the XFS on-disk inode * fields di_dmevmask and di_dmstate. These must be set to exactly and * only values previously obtained via xfs_bulkstat! (Specifically the - * xfs_bstat_t fields bs_dmevmask and bs_dmstate.) + * struct xfs_bstat fields bs_dmevmask and bs_dmstate.) */ #ifndef HAVE_FSDMIDATA struct fsdmidata { @@ -328,7 +328,7 @@ typedef struct xfs_bstime { __s32 tv_nsec; /* and nanoseconds */ } xfs_bstime_t; -typedef struct xfs_bstat { +struct xfs_bstat { __u64 bs_ino; /* inode number */ __u16 bs_mode; /* type and mode */ __u16 bs_nlink; /* number of links */ @@ -356,7 +356,7 @@ typedef struct xfs_bstat { __u32 bs_dmevmask; /* DMIG event mask */ __u16 bs_dmstate; /* DMIG state info */ __u16 bs_aextents; /* attribute number of extents */ -} xfs_bstat_t; +}; /* bs_sick flags */ #define XFS_BS_SICK_INODE (1 << 0) /* inode core */ @@ -382,22 +382,22 @@ bstat_get_projid(struct xfs_bstat *bs) /* * The user-level BulkStat Request interface structure. */ -typedef struct xfs_fsop_bulkreq { +struct xfs_fsop_bulkreq { __u64 __user *lastip; /* last inode # pointer */ __s32 icount; /* count of entries in buffer */ void __user *ubuffer;/* user buffer for inode desc. */ __s32 __user *ocount; /* output count pointer */ -} xfs_fsop_bulkreq_t; +}; /* * Structures returned from xfs_inumbers routine (XFS_IOC_FSINUMBERS). */ -typedef struct xfs_inogrp { +struct xfs_inogrp { __u64 xi_startino; /* starting inode number */ __s32 xi_alloccount; /* # bits set in allocmask */ __u64 xi_allocmask; /* mask of allocated inodes */ -} xfs_inogrp_t; +}; /* @@ -529,7 +529,7 @@ typedef struct xfs_swapext xfs_off_t sx_offset; /* offset into file */ xfs_off_t sx_length; /* leng from offset */ char sx_pad[16]; /* pad space, unused */ - xfs_bstat_t sx_stat; /* stat of target b4 copy */ + struct xfs_bstat sx_stat; /* stat of target b4 copy */ } xfs_swapext_t; /* diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 04b661ff0799..34b38d8e8dc9 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -766,7 +766,7 @@ xfs_ioc_bulkstat( if (XFS_FORCED_SHUTDOWN(mp)) return -EIO; - if (copy_from_user(&bulkreq, arg, sizeof(xfs_fsop_bulkreq_t))) + if (copy_from_user(&bulkreq, arg, sizeof(struct xfs_fsop_bulkreq))) return -EFAULT; if (copy_from_user(&lastino, bulkreq.lastip, sizeof(__s64))) diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index 3ca8ff9d4ac7..d69bff304768 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c @@ -118,11 +118,14 @@ xfs_ioctl32_bstime_copyin( return 0; } -/* xfs_bstat_t has differing alignment on intel, & bstime_t sizes everywhere */ +/* + * struct xfs_bstat has differing alignment on intel, & bstime_t sizes + * everywhere + */ STATIC int xfs_ioctl32_bstat_copyin( - xfs_bstat_t *bstat, - compat_xfs_bstat_t __user *bstat32) + struct xfs_bstat *bstat, + struct compat_xfs_bstat __user *bstat32) { if (get_user(bstat->bs_ino, &bstat32->bs_ino) || get_user(bstat->bs_mode, &bstat32->bs_mode) || @@ -206,7 +209,7 @@ STATIC int xfs_compat_ioc_bulkstat( xfs_mount_t *mp, unsigned int cmd, - compat_xfs_fsop_bulkreq_t __user *p32) + struct compat_xfs_fsop_bulkreq __user *p32) { u32 addr; struct xfs_fsop_bulkreq bulkreq; diff --git a/fs/xfs/xfs_ioctl32.h b/fs/xfs/xfs_ioctl32.h index d28fa824284a..7985344d3aa6 100644 --- a/fs/xfs/xfs_ioctl32.h +++ b/fs/xfs/xfs_ioctl32.h @@ -36,7 +36,7 @@ typedef struct compat_xfs_bstime { __s32 tv_nsec; /* and nanoseconds */ } compat_xfs_bstime_t; -typedef struct compat_xfs_bstat { +struct compat_xfs_bstat { __u64 bs_ino; /* inode number */ __u16 bs_mode; /* type and mode */ __u16 bs_nlink; /* number of links */ @@ -61,14 +61,14 @@ typedef struct compat_xfs_bstat { __u32 bs_dmevmask; /* DMIG event mask */ __u16 bs_dmstate; /* DMIG state info */ __u16 bs_aextents; /* attribute number of extents */ -} __compat_packed compat_xfs_bstat_t; +} __compat_packed; -typedef struct compat_xfs_fsop_bulkreq { +struct compat_xfs_fsop_bulkreq { compat_uptr_t lastip; /* last inode # pointer */ __s32 icount; /* count of entries in buffer */ compat_uptr_t ubuffer; /* user buffer for inode desc. */ compat_uptr_t ocount; /* output count pointer */ -} compat_xfs_fsop_bulkreq_t; +}; #define XFS_IOC_FSBULKSTAT_32 \ _IOWR('X', 101, struct compat_xfs_fsop_bulkreq) @@ -106,7 +106,7 @@ typedef struct compat_xfs_swapext { xfs_off_t sx_offset; /* offset into file */ xfs_off_t sx_length; /* leng from offset */ char sx_pad[16]; /* pad space, unused */ - compat_xfs_bstat_t sx_stat; /* stat of target b4 copy */ + struct compat_xfs_bstat sx_stat; /* stat of target b4 copy */ } __compat_packed compat_xfs_swapext_t; #define XFS_IOC_SWAPEXT_32 _IOWR('X', 109, struct compat_xfs_swapext) @@ -201,11 +201,11 @@ typedef struct compat_xfs_fsop_geom_v1 { #define XFS_IOC_FSGEOMETRY_V1_32 \ _IOR('X', 100, struct compat_xfs_fsop_geom_v1) -typedef struct compat_xfs_inogrp { +struct compat_xfs_inogrp { __u64 xi_startino; /* starting inode number */ __s32 xi_alloccount; /* # bits set in allocmask */ __u64 xi_allocmask; /* mask of allocated inodes */ -} __attribute__((packed)) compat_xfs_inogrp_t; +} __attribute__((packed)); /* These growfs input structures have padding on the end, so must translate */ typedef struct compat_xfs_growfs_data { From patchwork Wed Jun 12 06:49:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10988663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CD6866C5 for ; Wed, 12 Jun 2019 06:49:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA337289A6 for ; Wed, 12 Jun 2019 06:49:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE288288C6; Wed, 12 Jun 2019 06:49:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E93D289A0 for ; Wed, 12 Jun 2019 06:49:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731280AbfFLGtV (ORCPT ); Wed, 12 Jun 2019 02:49:21 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:34322 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726783AbfFLGtV (ORCPT ); Wed, 12 Jun 2019 02:49:21 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C6nKaw055709 for ; Wed, 12 Jun 2019 06:49:20 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-2018-07-02; bh=rpBU/uqzQi6+m+C6wUD2RLcrLltEf+00110f4ptL+2g=; b=h4+PLPz/fskPcqLYbBnHZ3FVoYaivXpZXzWVQ6EVDDTIPPR4sv1D6gDPgB8UVDLh1krW m/swvd+egdms9vA7TrtCiJ5qw8kh6W7FbsmuNygK1iIXtuWI3ERnwaf+IWM+VTQfMkaO o6JOUrVb7Z/q7acFpAWSD3HZggSaSa2XLInpCXVJgNbLbW4k+CyzNIblg62bNgL5hSxX tWzsW34DEP+3fJx81/z7zsQjRYBK/o1EyTAR25T0RQ7pa52WnIPEOmxsiWFRuFDDzgFr A1T1mG9KNE/GW1+T7yF5Dx67XesLLnTkniARA0+8j+SNKqEh75iymamMiGyWiRplNCkj bg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2t05nqsbvb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 Jun 2019 06:49:20 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C6mg4b099172 for ; Wed, 12 Jun 2019 06:49:19 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2t0p9rq317-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 Jun 2019 06:49:19 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5C6nIWM030934 for ; Wed, 12 Jun 2019 06:49:18 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 11 Jun 2019 23:49:18 -0700 Subject: [PATCH 2/9] xfs: rename bulkstat functions From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, allison.henderson@oracle.com Date: Tue, 11 Jun 2019 23:49:17 -0700 Message-ID: <156032215702.3774581.162933705652978520.stgit@magnolia> In-Reply-To: <156032214432.3774581.1304900948974476604.stgit@magnolia> References: <156032214432.3774581.1304900948974476604.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120047 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120047 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Rename the bulkstat functions to 'fsbulkstat' so that they match the ioctl names. We will be introducing a new set of bulkstat/inumbers ioctls soon, and it will be important to keep the names straight. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Collins --- fs/xfs/xfs_ioctl.c | 14 +++++++------- fs/xfs/xfs_ioctl.h | 5 +++-- fs/xfs/xfs_ioctl32.c | 18 +++++++++--------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 34b38d8e8dc9..5e0476003763 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -724,7 +724,7 @@ xfs_ioc_space( /* Return 0 on success or positive error */ int -xfs_bulkstat_one_fmt( +xfs_fsbulkstat_one_fmt( struct xfs_ibulk *breq, const struct xfs_bstat *bstat) { @@ -734,7 +734,7 @@ xfs_bulkstat_one_fmt( } int -xfs_inumbers_fmt( +xfs_fsinumbers_fmt( struct xfs_ibulk *breq, const struct xfs_inogrp *igrp) { @@ -744,7 +744,7 @@ xfs_inumbers_fmt( } STATIC int -xfs_ioc_bulkstat( +xfs_ioc_fsbulkstat( xfs_mount_t *mp, unsigned int cmd, void __user *arg) @@ -794,16 +794,16 @@ xfs_ioc_bulkstat( */ if (cmd == XFS_IOC_FSINUMBERS) { breq.startino = lastino ? lastino + 1 : 0; - error = xfs_inumbers(&breq, xfs_inumbers_fmt); + error = xfs_inumbers(&breq, xfs_fsinumbers_fmt); lastino = breq.startino - 1; } else if (cmd == XFS_IOC_FSBULKSTAT_SINGLE) { breq.startino = lastino; breq.icount = 1; - error = xfs_bulkstat_one(&breq, xfs_bulkstat_one_fmt); + error = xfs_bulkstat_one(&breq, xfs_fsbulkstat_one_fmt); lastino = breq.startino; } else { /* XFS_IOC_FSBULKSTAT */ breq.startino = lastino ? lastino + 1 : 0; - error = xfs_bulkstat(&breq, xfs_bulkstat_one_fmt); + error = xfs_bulkstat(&breq, xfs_fsbulkstat_one_fmt); lastino = breq.startino - 1; } @@ -1983,7 +1983,7 @@ xfs_file_ioctl( case XFS_IOC_FSBULKSTAT_SINGLE: case XFS_IOC_FSBULKSTAT: case XFS_IOC_FSINUMBERS: - return xfs_ioc_bulkstat(mp, cmd, arg); + return xfs_ioc_fsbulkstat(mp, cmd, arg); case XFS_IOC_FSGEOMETRY_V1: return xfs_ioc_fsgeometry(mp, arg, 3); diff --git a/fs/xfs/xfs_ioctl.h b/fs/xfs/xfs_ioctl.h index fb303eaa8863..cb34bc821201 100644 --- a/fs/xfs/xfs_ioctl.h +++ b/fs/xfs/xfs_ioctl.h @@ -81,7 +81,8 @@ struct xfs_ibulk; struct xfs_bstat; struct xfs_inogrp; -int xfs_bulkstat_one_fmt(struct xfs_ibulk *breq, const struct xfs_bstat *bstat); -int xfs_inumbers_fmt(struct xfs_ibulk *breq, const struct xfs_inogrp *igrp); +int xfs_fsbulkstat_one_fmt(struct xfs_ibulk *breq, + const struct xfs_bstat *bstat); +int xfs_fsinumbers_fmt(struct xfs_ibulk *breq, const struct xfs_inogrp *igrp); #endif diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index d69bff304768..464114439a5d 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c @@ -86,7 +86,7 @@ xfs_compat_growfs_rt_copyin( } STATIC int -xfs_inumbers_fmt_compat( +xfs_fsinumbers_fmt_compat( struct xfs_ibulk *breq, const struct xfs_inogrp *igrp) { @@ -101,7 +101,7 @@ xfs_inumbers_fmt_compat( } #else -#define xfs_inumbers_fmt_compat xfs_inumbers_fmt +#define xfs_fsinumbers_fmt_compat xfs_fsinumbers_fmt #endif /* BROKEN_X86_ALIGNMENT */ STATIC int @@ -171,7 +171,7 @@ xfs_bstime_store_compat( /* Return 0 on success or positive error (to xfs_bulkstat()) */ STATIC int -xfs_bulkstat_one_fmt_compat( +xfs_fsbulkstat_one_fmt_compat( struct xfs_ibulk *breq, const struct xfs_bstat *buffer) { @@ -206,7 +206,7 @@ xfs_bulkstat_one_fmt_compat( /* copied from xfs_ioctl.c */ STATIC int -xfs_compat_ioc_bulkstat( +xfs_compat_ioc_fsbulkstat( xfs_mount_t *mp, unsigned int cmd, struct compat_xfs_fsop_bulkreq __user *p32) @@ -226,8 +226,8 @@ xfs_compat_ioc_bulkstat( * to userpace memory via bulkreq.ubuffer. Normally the compat * functions and structure size are the correct ones to use ... */ - inumbers_fmt_pf inumbers_func = xfs_inumbers_fmt_compat; - bulkstat_one_fmt_pf bs_one_func = xfs_bulkstat_one_fmt_compat; + inumbers_fmt_pf inumbers_func = xfs_fsinumbers_fmt_compat; + bulkstat_one_fmt_pf bs_one_func = xfs_fsbulkstat_one_fmt_compat; #ifdef CONFIG_X86_X32 if (in_x32_syscall()) { @@ -239,8 +239,8 @@ xfs_compat_ioc_bulkstat( * the data written out in compat layout will not match what * x32 userspace expects. */ - inumbers_func = xfs_inumbers_fmt; - bs_one_func = xfs_bulkstat_one_fmt; + inumbers_func = xfs_fsinumbers_fmt; + bs_one_func = xfs_fsbulkstat_one_fmt; } #endif @@ -670,7 +670,7 @@ xfs_file_compat_ioctl( case XFS_IOC_FSBULKSTAT_32: case XFS_IOC_FSBULKSTAT_SINGLE_32: case XFS_IOC_FSINUMBERS_32: - return xfs_compat_ioc_bulkstat(mp, cmd, arg); + return xfs_compat_ioc_fsbulkstat(mp, cmd, arg); case XFS_IOC_FD_TO_HANDLE_32: case XFS_IOC_PATH_TO_HANDLE_32: case XFS_IOC_PATH_TO_FSHANDLE_32: { From patchwork Wed Jun 12 06:49:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10988665 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 34B2B14BB for ; Wed, 12 Jun 2019 06:49:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F3392887E for ; Wed, 12 Jun 2019 06:49:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1307C289AB; Wed, 12 Jun 2019 06:49:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 165AC289B2 for ; Wed, 12 Jun 2019 06:49:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731281AbfFLGt2 (ORCPT ); Wed, 12 Jun 2019 02:49:28 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:53864 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726783AbfFLGt2 (ORCPT ); Wed, 12 Jun 2019 02:49:28 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C6mfrF066049 for ; Wed, 12 Jun 2019 06:49:25 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-2018-07-02; bh=ixfjfSM/qJmFH+dGwGC2iRKbnH+R9v1PXwT4G8cVNgk=; b=FXrIid/4mcJpdlSXFGUEkvnTGpznOmwSRLhNKVs2wyXnZD00k37Wj62h0jdp4X+xL8do 4UB6QiE1ZdudLXiNTJGHQjZDP+gIs1ctGYf5Us8MoN1sxEL4+dFjvlukM1GUIVlxkIc4 ln/PsNwaOn7AWyo38I7ktEavtZ0e7xLYtngIMJHHMWdvanjXNWd1CpFT/WpP0c0WwkMa HBXzX63sOXLtIjr4pFH2Jmayv4wI/mYMp6NI+1O7m01SAIW/XxB5RhCNNYO3jvl62aV7 ATpIsBSTpu+hjEwpiNac1x5bX+EhfHCmoN7lJuuqjLaLVYbrGGVM2TnP14VZ37mCJ4aG 6A== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 2t02hesk96-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 Jun 2019 06:49:25 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C6mIlA098605 for ; Wed, 12 Jun 2019 06:49:25 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2t0p9rq335-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 Jun 2019 06:49:25 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5C6nOG4014786 for ; Wed, 12 Jun 2019 06:49:24 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 11 Jun 2019 23:49:24 -0700 Subject: [PATCH 3/9] xfs: introduce new v5 bulkstat structure From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, allison.henderson@oracle.com Date: Tue, 11 Jun 2019 23:49:23 -0700 Message-ID: <156032216323.3774581.1704774190336020486.stgit@magnolia> In-Reply-To: <156032214432.3774581.1304900948974476604.stgit@magnolia> References: <156032214432.3774581.1304900948974476604.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120047 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120047 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Introduce a new version of the in-core bulkstat structure that supports our new v5 format features. This structure also fills the gaps in the previous structure. We leave wiring up the ioctls for the next patch. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Collins --- fs/xfs/libxfs/xfs_fs.h | 48 ++++++++++++++++++++++++++++++- fs/xfs/libxfs/xfs_health.h | 2 + fs/xfs/xfs_health.c | 2 + fs/xfs/xfs_ioctl.c | 9 ++++-- fs/xfs/xfs_ioctl.h | 2 + fs/xfs/xfs_ioctl32.c | 10 ++++-- fs/xfs/xfs_itable.c | 69 +++++++++++++++++++++++++++++++++----------- fs/xfs/xfs_itable.h | 4 ++- fs/xfs/xfs_ondisk.h | 2 + 9 files changed, 120 insertions(+), 28 deletions(-) diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index ef0dce229fa4..132e364eb141 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -358,6 +358,52 @@ struct xfs_bstat { __u16 bs_aextents; /* attribute number of extents */ }; +/* New bulkstat structure that reports v5 features and fixes padding issues */ +struct xfs_bulkstat { + uint64_t bs_ino; /* inode number */ + uint64_t bs_size; /* file size */ + + uint64_t bs_blocks; /* number of blocks */ + uint64_t bs_xflags; /* extended flags */ + + uint64_t bs_atime; /* access time, seconds */ + uint64_t bs_mtime; /* modify time, seconds */ + + uint64_t bs_ctime; /* inode change time, seconds */ + uint64_t bs_btime; /* creation time, seconds */ + + uint32_t bs_gen; /* generation count */ + uint32_t bs_uid; /* user id */ + uint32_t bs_gid; /* group id */ + uint32_t bs_projectid; /* project id */ + + uint32_t bs_atime_nsec; /* access time, nanoseconds */ + uint32_t bs_mtime_nsec; /* modify time, nanoseconds */ + uint32_t bs_ctime_nsec; /* inode change time, nanoseconds */ + uint32_t bs_btime_nsec; /* creation time, nanoseconds */ + + uint32_t bs_blksize; /* block size */ + uint32_t bs_rdev; /* device value */ + uint32_t bs_cowextsize_blks; /* cow extent size hint, blocks */ + uint32_t bs_extsize_blks; /* extent size hint, blocks */ + + uint32_t bs_nlink; /* number of links */ + uint32_t bs_extents; /* number of extents */ + uint32_t bs_aextents; /* attribute number of extents */ + uint16_t bs_version; /* structure version */ + uint16_t bs_forkoff; /* inode fork offset in bytes */ + + uint16_t bs_sick; /* sick inode metadata */ + uint16_t bs_checked; /* checked inode metadata */ + uint16_t bs_mode; /* type and mode */ + uint16_t bs_pad2; /* zeroed */ + + uint64_t bs_pad[7]; /* zeroed */ +}; + +#define XFS_BULKSTAT_VERSION_V1 (1) +#define XFS_BULKSTAT_VERSION_V5 (5) + /* bs_sick flags */ #define XFS_BS_SICK_INODE (1 << 0) /* inode core */ #define XFS_BS_SICK_BMBTD (1 << 1) /* data fork */ @@ -374,7 +420,7 @@ struct xfs_bstat { * to retain compatibility with "old" filesystems). */ static inline uint32_t -bstat_get_projid(struct xfs_bstat *bs) +bstat_get_projid(const struct xfs_bstat *bs) { return (uint32_t)bs->bs_projid_hi << 16 | bs->bs_projid_lo; } diff --git a/fs/xfs/libxfs/xfs_health.h b/fs/xfs/libxfs/xfs_health.h index 49ddfeac19f2..272005ac8c88 100644 --- a/fs/xfs/libxfs/xfs_health.h +++ b/fs/xfs/libxfs/xfs_health.h @@ -185,6 +185,6 @@ xfs_inode_is_healthy(struct xfs_inode *ip) void xfs_fsop_geom_health(struct xfs_mount *mp, struct xfs_fsop_geom *geo); void xfs_ag_geom_health(struct xfs_perag *pag, struct xfs_ag_geometry *ageo); -void xfs_bulkstat_health(struct xfs_inode *ip, struct xfs_bstat *bs); +void xfs_bulkstat_health(struct xfs_inode *ip, struct xfs_bulkstat *bs); #endif /* __XFS_HEALTH_H__ */ diff --git a/fs/xfs/xfs_health.c b/fs/xfs/xfs_health.c index 4c4929f9e7bf..e8ba6034b0db 100644 --- a/fs/xfs/xfs_health.c +++ b/fs/xfs/xfs_health.c @@ -373,7 +373,7 @@ static const struct ioctl_sick_map ino_map[] = { void xfs_bulkstat_health( struct xfs_inode *ip, - struct xfs_bstat *bs) + struct xfs_bulkstat *bs) { const struct ioctl_sick_map *m; unsigned int sick; diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 5e0476003763..0b8c631d53dd 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -725,10 +725,13 @@ xfs_ioc_space( /* Return 0 on success or positive error */ int xfs_fsbulkstat_one_fmt( - struct xfs_ibulk *breq, - const struct xfs_bstat *bstat) + struct xfs_ibulk *breq, + const struct xfs_bulkstat *bstat) { - if (copy_to_user(breq->ubuffer, bstat, sizeof(*bstat))) + struct xfs_bstat bs1; + + xfs_bulkstat_to_bstat(breq->mp, &bs1, bstat); + if (copy_to_user(breq->ubuffer, &bs1, sizeof(bs1))) return -EFAULT; return xfs_ibulk_advance(breq, sizeof(struct xfs_bstat)); } diff --git a/fs/xfs/xfs_ioctl.h b/fs/xfs/xfs_ioctl.h index cb34bc821201..514d3028a134 100644 --- a/fs/xfs/xfs_ioctl.h +++ b/fs/xfs/xfs_ioctl.h @@ -82,7 +82,7 @@ struct xfs_bstat; struct xfs_inogrp; int xfs_fsbulkstat_one_fmt(struct xfs_ibulk *breq, - const struct xfs_bstat *bstat); + const struct xfs_bulkstat *bstat); int xfs_fsinumbers_fmt(struct xfs_ibulk *breq, const struct xfs_inogrp *igrp); #endif diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index 464114439a5d..ecc8109a3e96 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c @@ -172,10 +172,14 @@ xfs_bstime_store_compat( /* Return 0 on success or positive error (to xfs_bulkstat()) */ STATIC int xfs_fsbulkstat_one_fmt_compat( - struct xfs_ibulk *breq, - const struct xfs_bstat *buffer) + struct xfs_ibulk *breq, + const struct xfs_bulkstat *bstat) { - struct compat_xfs_bstat __user *p32 = breq->ubuffer; + struct compat_xfs_bstat __user *p32 = breq->ubuffer; + struct xfs_bstat bs1; + struct xfs_bstat *buffer = &bs1; + + xfs_bulkstat_to_bstat(breq->mp, &bs1, bstat); if (put_user(buffer->bs_ino, &p32->bs_ino) || put_user(buffer->bs_mode, &p32->bs_mode) || diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c index b2f640ecb507..7993566bd4a1 100644 --- a/fs/xfs/xfs_itable.c +++ b/fs/xfs/xfs_itable.c @@ -25,7 +25,7 @@ * Bulk Stat * ========= * - * Use the inode walking functions to fill out struct xfs_bstat for every + * Use the inode walking functions to fill out struct xfs_bulkstat for every * allocated inode, then pass the stat information to some externally provided * iteration function. */ @@ -33,7 +33,7 @@ struct xfs_bstat_chunk { bulkstat_one_fmt_pf formatter; struct xfs_ibulk *breq; - struct xfs_bstat *buf; + struct xfs_bulkstat *buf; }; /* @@ -63,7 +63,7 @@ xfs_bulkstat_one_int( struct xfs_icdinode *dic; /* dinode core info pointer */ struct xfs_inode *ip; /* incore inode pointer */ struct inode *inode; - struct xfs_bstat *buf = bc->buf; + struct xfs_bulkstat *buf = bc->buf; int error = -EINVAL; if (xfs_internal_inum(mp, ino)) @@ -86,37 +86,35 @@ xfs_bulkstat_one_int( /* xfs_iget returns the following without needing * further change. */ - buf->bs_projid_lo = dic->di_projid_lo; - buf->bs_projid_hi = dic->di_projid_hi; + buf->bs_projectid = xfs_get_projid(ip); buf->bs_ino = ino; buf->bs_uid = dic->di_uid; buf->bs_gid = dic->di_gid; buf->bs_size = dic->di_size; buf->bs_nlink = inode->i_nlink; - buf->bs_atime.tv_sec = inode->i_atime.tv_sec; - buf->bs_atime.tv_nsec = inode->i_atime.tv_nsec; - buf->bs_mtime.tv_sec = inode->i_mtime.tv_sec; - buf->bs_mtime.tv_nsec = inode->i_mtime.tv_nsec; - buf->bs_ctime.tv_sec = inode->i_ctime.tv_sec; - buf->bs_ctime.tv_nsec = inode->i_ctime.tv_nsec; + buf->bs_atime = inode->i_atime.tv_sec; + buf->bs_atime_nsec = inode->i_atime.tv_nsec; + buf->bs_mtime = inode->i_mtime.tv_sec; + buf->bs_mtime_nsec = inode->i_mtime.tv_nsec; + buf->bs_ctime = inode->i_ctime.tv_sec; + buf->bs_ctime_nsec = inode->i_ctime.tv_nsec; + buf->bs_btime = dic->di_crtime.t_sec; + buf->bs_btime_nsec = dic->di_crtime.t_nsec; buf->bs_gen = inode->i_generation; buf->bs_mode = inode->i_mode; buf->bs_xflags = xfs_ip2xflags(ip); - buf->bs_extsize = dic->di_extsize << mp->m_sb.sb_blocklog; + buf->bs_extsize_blks = dic->di_extsize; buf->bs_extents = dic->di_nextents; - memset(buf->bs_pad, 0, sizeof(buf->bs_pad)); xfs_bulkstat_health(ip, buf); - buf->bs_dmevmask = dic->di_dmevmask; - buf->bs_dmstate = dic->di_dmstate; buf->bs_aextents = dic->di_anextents; buf->bs_forkoff = XFS_IFORK_BOFF(ip); + buf->bs_version = XFS_BULKSTAT_VERSION_V5; if (dic->di_version == 3) { if (dic->di_flags2 & XFS_DIFLAG2_COWEXTSIZE) - buf->bs_cowextsize = dic->di_cowextsize << - mp->m_sb.sb_blocklog; + buf->bs_cowextsize_blks = dic->di_cowextsize; } switch (dic->di_format) { @@ -269,6 +267,43 @@ xfs_bulkstat( return error; } +/* Convert bulkstat (v5) to bstat (v1). */ +void +xfs_bulkstat_to_bstat( + struct xfs_mount *mp, + struct xfs_bstat *bs1, + const struct xfs_bulkstat *bstat) +{ + bs1->bs_ino = bstat->bs_ino; + bs1->bs_mode = bstat->bs_mode; + bs1->bs_nlink = bstat->bs_nlink; + bs1->bs_uid = bstat->bs_uid; + bs1->bs_gid = bstat->bs_gid; + bs1->bs_rdev = bstat->bs_rdev; + bs1->bs_blksize = bstat->bs_blksize; + bs1->bs_size = bstat->bs_size; + bs1->bs_atime.tv_sec = bstat->bs_atime; + bs1->bs_mtime.tv_sec = bstat->bs_mtime; + bs1->bs_ctime.tv_sec = bstat->bs_ctime; + bs1->bs_atime.tv_nsec = bstat->bs_atime_nsec; + bs1->bs_mtime.tv_nsec = bstat->bs_mtime_nsec; + bs1->bs_ctime.tv_nsec = bstat->bs_ctime_nsec; + bs1->bs_blocks = bstat->bs_blocks; + bs1->bs_xflags = bstat->bs_xflags; + bs1->bs_extsize = bstat->bs_extsize_blks << mp->m_sb.sb_blocklog; + bs1->bs_extents = bstat->bs_extents; + bs1->bs_gen = bstat->bs_gen; + bs1->bs_projid_lo = bstat->bs_projectid & 0xFFFF; + bs1->bs_forkoff = bstat->bs_forkoff; + bs1->bs_projid_hi = bstat->bs_projectid >> 16; + bs1->bs_sick = bstat->bs_sick; + bs1->bs_checked = bstat->bs_checked; + bs1->bs_cowextsize = bstat->bs_cowextsize_blks << mp->m_sb.sb_blocklog; + bs1->bs_dmevmask = 0; + bs1->bs_dmstate = 0; + bs1->bs_aextents = bstat->bs_aextents; +} + struct xfs_inumbers_chunk { inumbers_fmt_pf formatter; struct xfs_ibulk *breq; diff --git a/fs/xfs/xfs_itable.h b/fs/xfs/xfs_itable.h index 1e1a5bb9fd9f..e2a448f69e24 100644 --- a/fs/xfs/xfs_itable.h +++ b/fs/xfs/xfs_itable.h @@ -41,10 +41,12 @@ xfs_ibulk_advance( */ typedef int (*bulkstat_one_fmt_pf)(struct xfs_ibulk *breq, - const struct xfs_bstat *bstat); + const struct xfs_bulkstat *bstat); int xfs_bulkstat_one(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter); int xfs_bulkstat(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter); +void xfs_bulkstat_to_bstat(struct xfs_mount *mp, struct xfs_bstat *bs1, + const struct xfs_bulkstat *bstat); typedef int (*inumbers_fmt_pf)(struct xfs_ibulk *breq, const struct xfs_inogrp *igrp); diff --git a/fs/xfs/xfs_ondisk.h b/fs/xfs/xfs_ondisk.h index c8ba98fae30a..0b4cdda68524 100644 --- a/fs/xfs/xfs_ondisk.h +++ b/fs/xfs/xfs_ondisk.h @@ -146,6 +146,8 @@ xfs_check_ondisk_structs(void) XFS_CHECK_OFFSET(struct xfs_dir3_data_hdr, hdr.magic, 0); XFS_CHECK_OFFSET(struct xfs_dir3_free, hdr.hdr.magic, 0); XFS_CHECK_OFFSET(struct xfs_attr3_leafblock, hdr.info.hdr, 0); + + XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat, 192); } #endif /* __XFS_ONDISK_H */ From patchwork Wed Jun 12 06:49:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10988667 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B95F114BB for ; Wed, 12 Jun 2019 06:49:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4D4228939 for ; Wed, 12 Jun 2019 06:49:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9932F289AF; Wed, 12 Jun 2019 06:49:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 019A228987 for ; Wed, 12 Jun 2019 06:49:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731282AbfFLGte (ORCPT ); Wed, 12 Jun 2019 02:49:34 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:34490 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726783AbfFLGte (ORCPT ); Wed, 12 Jun 2019 02:49:34 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C6miGZ055077 for ; Wed, 12 Jun 2019 06:49:33 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-2018-07-02; bh=CYSM4w3RAaLrOpYtqRJcmKMf9wwhk86lSCMVxdrxWBs=; b=wdpZJ5VueurIfk8ZIfatJc5tWCjx2oFsFFh+EQyoMN976YWRr4Ul3zk7sgliLKTghaw8 1rbbKJXwpi+8keGprMmzNJeoIs7VL1PyXfa4i8GkAn0hoH6fmlI1Ew4mW6Yp0V5nGL1i 64LX0EAzVmM4R45H/0dAbWzbW5JW5dsTop5JBx7b+DYUrm+EeByVa7u6jby6FCeociZJ VGMLvhgQbzAqVvFe1ylVrRAsyDPKHDjm3Qm0S5Hpba45Q15kMVjxJafSDcWMGts3jriw 8NI7tCIfiBFrSKSF8qpGt5Cx+5pYvPOe0UbFm/9gC6usWkxic+8G5GtEjhXzXl28MoZY /g== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2t05nqsbw9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 Jun 2019 06:49:33 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C6n5tW178668 for ; Wed, 12 Jun 2019 06:49:32 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2t1jphuw0q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 Jun 2019 06:49:32 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5C6nVOw014914 for ; Wed, 12 Jun 2019 06:49:31 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 11 Jun 2019 23:49:31 -0700 Subject: [PATCH 4/9] xfs: introduce v5 inode group structure From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, allison.henderson@oracle.com Date: Tue, 11 Jun 2019 23:49:29 -0700 Message-ID: <156032216980.3774581.8469638497602123307.stgit@magnolia> In-Reply-To: <156032214432.3774581.1304900948974476604.stgit@magnolia> References: <156032214432.3774581.1304900948974476604.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120047 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120047 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Introduce a new "v5" inode group structure that fixes the alignment and padding problems of the existing structure. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_fs.h | 11 +++++++++++ fs/xfs/xfs_ioctl.c | 9 ++++++--- fs/xfs/xfs_ioctl.h | 2 +- fs/xfs/xfs_ioctl32.c | 10 +++++++--- fs/xfs/xfs_itable.c | 14 +++++++++++++- fs/xfs/xfs_itable.h | 3 ++- fs/xfs/xfs_ondisk.h | 1 + 7 files changed, 41 insertions(+), 9 deletions(-) diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index 132e364eb141..8b8fe78511fb 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -445,6 +445,17 @@ struct xfs_inogrp { __u64 xi_allocmask; /* mask of allocated inodes */ }; +/* New inumbers structure that reports v5 features and fixes padding issues */ +struct xfs_inumbers { + uint64_t xi_startino; /* starting inode number */ + uint64_t xi_allocmask; /* mask of allocated inodes */ + uint8_t xi_alloccount; /* # bits set in allocmask */ + uint8_t xi_version; /* version */ + uint8_t xi_padding[6]; /* zero */ +}; + +#define XFS_INUMBERS_VERSION_V1 (1) +#define XFS_INUMBERS_VERSION_V5 (5) /* * Error injection. diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 0b8c631d53dd..47580762e154 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -738,10 +738,13 @@ xfs_fsbulkstat_one_fmt( int xfs_fsinumbers_fmt( - struct xfs_ibulk *breq, - const struct xfs_inogrp *igrp) + struct xfs_ibulk *breq, + const struct xfs_inumbers *igrp) { - if (copy_to_user(breq->ubuffer, igrp, sizeof(*igrp))) + struct xfs_inogrp ig1; + + xfs_inumbers_to_inogrp(&ig1, igrp); + if (copy_to_user(breq->ubuffer, &ig1, sizeof(struct xfs_inogrp))) return -EFAULT; return xfs_ibulk_advance(breq, sizeof(struct xfs_inogrp)); } diff --git a/fs/xfs/xfs_ioctl.h b/fs/xfs/xfs_ioctl.h index 514d3028a134..654c0bb1bcf8 100644 --- a/fs/xfs/xfs_ioctl.h +++ b/fs/xfs/xfs_ioctl.h @@ -83,6 +83,6 @@ struct xfs_inogrp; int xfs_fsbulkstat_one_fmt(struct xfs_ibulk *breq, const struct xfs_bulkstat *bstat); -int xfs_fsinumbers_fmt(struct xfs_ibulk *breq, const struct xfs_inogrp *igrp); +int xfs_fsinumbers_fmt(struct xfs_ibulk *breq, const struct xfs_inumbers *igrp); #endif diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index ecc8109a3e96..4c1fcf38a983 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c @@ -87,10 +87,14 @@ xfs_compat_growfs_rt_copyin( STATIC int xfs_fsinumbers_fmt_compat( - struct xfs_ibulk *breq, - const struct xfs_inogrp *igrp) + struct xfs_ibulk *breq, + const struct xfs_inumbers *ig) { - struct compat_xfs_inogrp __user *p32 = breq->ubuffer; + struct compat_xfs_inogrp __user *p32 = breq->ubuffer; + struct xfs_inogrp ig1; + struct xfs_inogrp *igrp = &ig1; + + xfs_inumbers_to_inogrp(&ig1, ig); if (put_user(igrp->xi_startino, &p32->xi_startino) || put_user(igrp->xi_alloccount, &p32->xi_alloccount) || diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c index 7993566bd4a1..1ff95bba971f 100644 --- a/fs/xfs/xfs_itable.c +++ b/fs/xfs/xfs_itable.c @@ -332,10 +332,11 @@ xfs_inumbers_walk( const struct xfs_inobt_rec_incore *irec, void *data) { - struct xfs_inogrp inogrp = { + struct xfs_inumbers inogrp = { .xi_startino = XFS_AGINO_TO_INO(mp, agno, irec->ir_startino), .xi_alloccount = irec->ir_count - irec->ir_freecount, .xi_allocmask = ~irec->ir_free, + .xi_version = XFS_INUMBERS_VERSION_V5, }; struct xfs_inumbers_chunk *ic = data; xfs_agino_t agino; @@ -384,3 +385,14 @@ xfs_inumbers( return error; } + +/* Convert an inumbers (v5) struct to a inogrp (v1) struct. */ +void +xfs_inumbers_to_inogrp( + struct xfs_inogrp *ig1, + const struct xfs_inumbers *ig) +{ + ig1->xi_startino = ig->xi_startino; + ig1->xi_alloccount = ig->xi_alloccount; + ig1->xi_allocmask = ig->xi_allocmask; +} diff --git a/fs/xfs/xfs_itable.h b/fs/xfs/xfs_itable.h index e2a448f69e24..d41a0a8a326c 100644 --- a/fs/xfs/xfs_itable.h +++ b/fs/xfs/xfs_itable.h @@ -49,8 +49,9 @@ void xfs_bulkstat_to_bstat(struct xfs_mount *mp, struct xfs_bstat *bs1, const struct xfs_bulkstat *bstat); typedef int (*inumbers_fmt_pf)(struct xfs_ibulk *breq, - const struct xfs_inogrp *igrp); + const struct xfs_inumbers *igrp); int xfs_inumbers(struct xfs_ibulk *breq, inumbers_fmt_pf formatter); +void xfs_inumbers_to_inogrp(struct xfs_inogrp *ig1, const struct xfs_inumbers *ig); #endif /* __XFS_ITABLE_H__ */ diff --git a/fs/xfs/xfs_ondisk.h b/fs/xfs/xfs_ondisk.h index 0b4cdda68524..d8f941b4d51c 100644 --- a/fs/xfs/xfs_ondisk.h +++ b/fs/xfs/xfs_ondisk.h @@ -148,6 +148,7 @@ xfs_check_ondisk_structs(void) XFS_CHECK_OFFSET(struct xfs_attr3_leafblock, hdr.info.hdr, 0); XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat, 192); + XFS_CHECK_STRUCT_SIZE(struct xfs_inumbers, 24); } #endif /* __XFS_ONDISK_H */ From patchwork Wed Jun 12 06:49:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10988685 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9143818A6 for ; Wed, 12 Jun 2019 06:51:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E90128999 for ; Wed, 12 Jun 2019 06:51:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D1D5289A2; Wed, 12 Jun 2019 06:51:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B1E828999 for ; Wed, 12 Jun 2019 06:51:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405148AbfFLGvl (ORCPT ); Wed, 12 Jun 2019 02:51:41 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:55668 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403835AbfFLGvl (ORCPT ); Wed, 12 Jun 2019 02:51:41 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C6mkt9066089 for ; Wed, 12 Jun 2019 06:51:39 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-2018-07-02; bh=7z0vUHEIJTuW41mYE9495NRWCGrmL48Ifl+7Y3fJKkU=; b=CVGTXNzkPpV8+9VWT9Ukc6WSIk8GYcbPxBAysIlrgDY8OXftSCLwqzUeMxulYViGOiI8 Szc7n4pYnSFwOPpIWHi9Pa6mFUJ2GaJKHVd4QcPiaA3CidZQAUH8QWHE0gVN/mgmRfC+ o6wGsP9GlrLEz41xJY/rbm3DYdciUkLAaBgfICjAfYI9EHh+EF4VlneRDpYYF2euaEgD sfxWpX9fRHOQP8kHaXapBOJPRpLURakvCKmdEEee3RJ4IE+1OI1Wp6uSUs5KxnqTSBGR +LyvaPBadxwxu0ZAghjytyyU/JfX/HBGWs/yvEZwiFQ1SjhM/bW7NVMgyZFO0bndQ5h0 hg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 2t02heskhq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 Jun 2019 06:51:39 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C6mImo098651 for ; Wed, 12 Jun 2019 06:49:39 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2t0p9rq360-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 Jun 2019 06:49:39 +0000 Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5C6ncSN031176 for ; Wed, 12 Jun 2019 06:49:38 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 11 Jun 2019 23:49:37 -0700 Subject: [PATCH 5/9] xfs: wire up new v5 bulkstat ioctls From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, allison.henderson@oracle.com Date: Tue, 11 Jun 2019 23:49:36 -0700 Message-ID: <156032217675.3774581.9929060870408261817.stgit@magnolia> In-Reply-To: <156032214432.3774581.1304900948974476604.stgit@magnolia> References: <156032214432.3774581.1304900948974476604.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=960 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120047 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120047 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Wire up the new v5 BULKSTAT ioctl and rename the old one to V1. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_fs.h | 24 +++++++++++- fs/xfs/xfs_ioctl.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_ioctl32.c | 1 fs/xfs/xfs_ondisk.h | 1 4 files changed, 123 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index 8b8fe78511fb..960f3542e207 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -435,7 +435,6 @@ struct xfs_fsop_bulkreq { __s32 __user *ocount; /* output count pointer */ }; - /* * Structures returned from xfs_inumbers routine (XFS_IOC_FSINUMBERS). */ @@ -457,6 +456,28 @@ struct xfs_inumbers { #define XFS_INUMBERS_VERSION_V1 (1) #define XFS_INUMBERS_VERSION_V5 (5) +/* Header for bulk inode requests. */ +struct xfs_bulk_ireq { + uint64_t ino; /* I/O: start with this inode */ + uint32_t flags; /* I/O: operation flags */ + uint32_t icount; /* I: count of entries in buffer */ + uint32_t ocount; /* O: count of entries filled out */ + uint32_t reserved32; /* must be zero */ + uint64_t reserved[5]; /* must be zero */ +}; + +#define XFS_BULK_IREQ_FLAGS_ALL (0) + +/* + * ioctl structures for v5 bulkstat and inumbers requests + */ +struct xfs_bulkstat_req { + struct xfs_bulk_ireq hdr; + struct xfs_bulkstat bulkstat[]; +}; +#define XFS_BULKSTAT_REQ_SIZE(nr) (sizeof(struct xfs_bulkstat_req) + \ + (nr) * sizeof(struct xfs_bulkstat)) + /* * Error injection. */ @@ -758,6 +779,7 @@ struct xfs_scrub_metadata { #define XFS_IOC_FSGEOMETRY_V4 _IOR ('X', 124, struct xfs_fsop_geom_v4) #define XFS_IOC_GOINGDOWN _IOR ('X', 125, uint32_t) #define XFS_IOC_FSGEOMETRY _IOR ('X', 126, struct xfs_fsop_geom) +#define XFS_IOC_BULKSTAT _IOR ('X', 127, struct xfs_bulkstat_req) /* XFS_IOC_GETFSUUID ---------- deprecated 140 */ diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 47580762e154..cf6a38c2a3ed 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -827,6 +827,101 @@ xfs_ioc_fsbulkstat( return 0; } +/* Return 0 on success or positive error */ +static int +xfs_bulkstat_fmt( + struct xfs_ibulk *breq, + const struct xfs_bulkstat *bstat) +{ + if (copy_to_user(breq->ubuffer, bstat, sizeof(struct xfs_bulkstat))) + return -EFAULT; + return xfs_ibulk_advance(breq, sizeof(struct xfs_bulkstat)); +} + +/* + * Check the incoming bulk request @hdr from userspace and initialize the + * internal @breq bulk request appropriately. Returns 0 if the bulk request + * should proceed; XFS_ITER_ABORT if there's nothing to do; or the usual + * negative error code. + */ +static int +xfs_bulk_ireq_setup( + struct xfs_mount *mp, + struct xfs_bulk_ireq *hdr, + struct xfs_ibulk *breq, + void __user *ubuffer) +{ + if (hdr->icount == 0 || + (hdr->flags & ~XFS_BULK_IREQ_FLAGS_ALL) || + hdr->reserved32 || + memchr_inv(hdr->reserved, 0, sizeof(hdr->reserved))) + return -EINVAL; + + breq->startino = hdr->ino; + breq->ubuffer = ubuffer; + breq->icount = hdr->icount; + breq->ocount = 0; + + /* Asking for an inode past the end of the FS? We're done! */ + if (XFS_INO_TO_AGNO(mp, breq->startino) >= mp->m_sb.sb_agcount) + return XFS_ITER_ABORT; + + return 0; +} + +/* + * Update the userspace bulk request @hdr to reflect the end state of the + * internal bulk request @breq. + */ +static void +xfs_bulk_ireq_teardown( + struct xfs_bulk_ireq *hdr, + struct xfs_ibulk *breq) +{ + hdr->ino = breq->startino; + hdr->ocount = breq->ocount; +} + +/* Handle the v5 bulkstat ioctl. */ +STATIC int +xfs_ioc_bulkstat( + struct xfs_mount *mp, + unsigned int cmd, + struct xfs_bulkstat_req __user *arg) +{ + struct xfs_bulk_ireq hdr; + struct xfs_ibulk breq = { + .mp = mp, + }; + int error; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + + if (XFS_FORCED_SHUTDOWN(mp)) + return -EIO; + + if (copy_from_user(&hdr, &arg->hdr, sizeof(hdr))) + return -EFAULT; + + error = xfs_bulk_ireq_setup(mp, &hdr, &breq, arg->bulkstat); + if (error == XFS_ITER_ABORT) + goto out_teardown; + if (error < 0) + return error; + + error = xfs_bulkstat(&breq, xfs_bulkstat_fmt); + if (error) + return error; + +out_teardown: + xfs_bulk_ireq_teardown(&hdr, &breq); + if (copy_to_user(&arg->hdr, &hdr, sizeof(hdr))) + return -EFAULT; + + return 0; +} + STATIC int xfs_ioc_fsgeometry( struct xfs_mount *mp, @@ -1991,6 +2086,9 @@ xfs_file_ioctl( case XFS_IOC_FSINUMBERS: return xfs_ioc_fsbulkstat(mp, cmd, arg); + case XFS_IOC_BULKSTAT: + return xfs_ioc_bulkstat(mp, cmd, arg); + case XFS_IOC_FSGEOMETRY_V1: return xfs_ioc_fsgeometry(mp, arg, 3); case XFS_IOC_FSGEOMETRY_V4: diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index 4c1fcf38a983..95cae33c961f 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c @@ -581,6 +581,7 @@ xfs_file_compat_ioctl( case XFS_IOC_ERROR_CLEARALL: case FS_IOC_GETFSMAP: case XFS_IOC_SCRUB_METADATA: + case XFS_IOC_BULKSTAT: return xfs_file_ioctl(filp, cmd, p); #if !defined(BROKEN_X86_ALIGNMENT) || defined(CONFIG_X86_X32) /* diff --git a/fs/xfs/xfs_ondisk.h b/fs/xfs/xfs_ondisk.h index d8f941b4d51c..954484c6eb96 100644 --- a/fs/xfs/xfs_ondisk.h +++ b/fs/xfs/xfs_ondisk.h @@ -149,6 +149,7 @@ xfs_check_ondisk_structs(void) XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat, 192); XFS_CHECK_STRUCT_SIZE(struct xfs_inumbers, 24); + XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat_req, 64); } #endif /* __XFS_ONDISK_H */ From patchwork Wed Jun 12 06:49:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10988669 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 213D26C5 for ; Wed, 12 Jun 2019 06:49:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D36B289AD for ; Wed, 12 Jun 2019 06:49:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BCC3289B4; Wed, 12 Jun 2019 06:49:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 710AE289AD for ; Wed, 12 Jun 2019 06:49:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391280AbfFLGtr (ORCPT ); Wed, 12 Jun 2019 02:49:47 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:34194 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390376AbfFLGtq (ORCPT ); Wed, 12 Jun 2019 02:49:46 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C6mvPr047840 for ; Wed, 12 Jun 2019 06:49:45 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-2018-07-02; bh=scTVRVgRK6nbDedgSD7y6p6v5n5DO5GZBHl0JbUld6s=; b=zHWaEZGE+EN6TpLEkWerz6wh5XfuQ1woZ1R678X9FPq/+gFWi/+t2kXolz3yJFHDg51l 2mDpfXMkcYCaVnhTx3PaVk1JgrYjYg3ifWfwjOvNX9tOl+20v2Jv4TubrU8idpucXB27 Rdm/XGsu+la8D5uBYrlZoM3K/tay2hRjLR9s3FkaOTJ6iSyC3vsxAvL211Gt54RCA582 Lh26NOLHnyXthK5CZzpBhqzXDatnZLbmYj9c/uaroiNuttXFPwq2SpjVQMmJ0Yeoz14x rPNsMdCZYyB15xZzuhvf53jCLeR0EfTpQnthi0G6uvYe4NVfK4gb+5VJdauUm8P7HRFe CQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2t04etsfx0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 Jun 2019 06:49:45 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C6mo9h178277 for ; Wed, 12 Jun 2019 06:49:45 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 2t1jphuw2v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 Jun 2019 06:49:44 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5C6niR7031199 for ; Wed, 12 Jun 2019 06:49:44 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 11 Jun 2019 23:49:44 -0700 Subject: [PATCH 6/9] xfs: wire up the new v5 bulkstat_single ioctl From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, allison.henderson@oracle.com Date: Tue, 11 Jun 2019 23:49:43 -0700 Message-ID: <156032218313.3774581.12164066844587307278.stgit@magnolia> In-Reply-To: <156032214432.3774581.1304900948974476604.stgit@magnolia> References: <156032214432.3774581.1304900948974476604.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120047 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120047 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Wire up the V5 BULKSTAT_SINGLE ioctl and rename the old one V1. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_fs.h | 16 ++++++++++ fs/xfs/xfs_ioctl.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_ioctl32.c | 1 + fs/xfs/xfs_ondisk.h | 1 + 4 files changed, 97 insertions(+) diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index 960f3542e207..95d0411dae9b 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -468,6 +468,16 @@ struct xfs_bulk_ireq { #define XFS_BULK_IREQ_FLAGS_ALL (0) +/* Header for a single inode request. */ +struct xfs_ireq { + uint64_t ino; /* I/O: start with this inode */ + uint32_t flags; /* I/O: operation flags */ + uint32_t reserved32; /* must be zero */ + uint64_t reserved[2]; /* must be zero */ +}; + +#define XFS_IREQ_FLAGS_ALL (0) + /* * ioctl structures for v5 bulkstat and inumbers requests */ @@ -478,6 +488,11 @@ struct xfs_bulkstat_req { #define XFS_BULKSTAT_REQ_SIZE(nr) (sizeof(struct xfs_bulkstat_req) + \ (nr) * sizeof(struct xfs_bulkstat)) +struct xfs_bulkstat_single_req { + struct xfs_ireq hdr; + struct xfs_bulkstat bulkstat; +}; + /* * Error injection. */ @@ -780,6 +795,7 @@ struct xfs_scrub_metadata { #define XFS_IOC_GOINGDOWN _IOR ('X', 125, uint32_t) #define XFS_IOC_FSGEOMETRY _IOR ('X', 126, struct xfs_fsop_geom) #define XFS_IOC_BULKSTAT _IOR ('X', 127, struct xfs_bulkstat_req) +#define XFS_IOC_BULKSTAT_SINGLE _IOR ('X', 128, struct xfs_bulkstat_single_req) /* XFS_IOC_GETFSUUID ---------- deprecated 140 */ diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index cf6a38c2a3ed..2c821fa601a4 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -922,6 +922,83 @@ xfs_ioc_bulkstat( return 0; } +/* + * Check the incoming singleton request @hdr from userspace and initialize the + * internal @breq bulk request appropriately. Returns 0 if the bulk request + * should proceed; or the usual negative error code. + */ +static int +xfs_ireq_setup( + struct xfs_mount *mp, + struct xfs_ireq *hdr, + struct xfs_ibulk *breq, + void __user *ubuffer) +{ + if ((hdr->flags & ~XFS_IREQ_FLAGS_ALL) || + hdr->reserved32 || + memchr_inv(hdr->reserved, 0, sizeof(hdr->reserved))) + return -EINVAL; + + if (XFS_INO_TO_AGNO(mp, hdr->ino) >= mp->m_sb.sb_agcount) + return -EINVAL; + + breq->ubuffer = ubuffer; + breq->icount = 1; + breq->startino = hdr->ino; + return 0; +} + +/* + * Update the userspace singleton request @hdr to reflect the end state of the + * internal bulk request @breq. If @error is negative then we return just + * that; otherwise we copy the state so that userspace can discover what + * happened. + */ +static void +xfs_ireq_teardown( + struct xfs_ireq *hdr, + struct xfs_ibulk *breq) +{ + hdr->ino = breq->startino; +} + +/* Handle the v5 bulkstat_single ioctl. */ +STATIC int +xfs_ioc_bulkstat_single( + struct xfs_mount *mp, + unsigned int cmd, + struct xfs_bulkstat_single_req __user *arg) +{ + struct xfs_ireq hdr; + struct xfs_ibulk breq = { + .mp = mp, + }; + int error; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + + if (XFS_FORCED_SHUTDOWN(mp)) + return -EIO; + + if (copy_from_user(&hdr, &arg->hdr, sizeof(hdr))) + return -EFAULT; + + error = xfs_ireq_setup(mp, &hdr, &breq, &arg->bulkstat); + if (error) + return error; + + error = xfs_bulkstat_one(&breq, xfs_bulkstat_fmt); + if (error) + return error; + + xfs_ireq_teardown(&hdr, &breq); + if (copy_to_user(&arg->hdr, &hdr, sizeof(hdr))) + return -EFAULT; + + return 0; +} + STATIC int xfs_ioc_fsgeometry( struct xfs_mount *mp, @@ -2088,6 +2165,8 @@ xfs_file_ioctl( case XFS_IOC_BULKSTAT: return xfs_ioc_bulkstat(mp, cmd, arg); + case XFS_IOC_BULKSTAT_SINGLE: + return xfs_ioc_bulkstat_single(mp, cmd, arg); case XFS_IOC_FSGEOMETRY_V1: return xfs_ioc_fsgeometry(mp, arg, 3); diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index 95cae33c961f..4152f68bfb5f 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c @@ -582,6 +582,7 @@ xfs_file_compat_ioctl( case FS_IOC_GETFSMAP: case XFS_IOC_SCRUB_METADATA: case XFS_IOC_BULKSTAT: + case XFS_IOC_BULKSTAT_SINGLE: return xfs_file_ioctl(filp, cmd, p); #if !defined(BROKEN_X86_ALIGNMENT) || defined(CONFIG_X86_X32) /* diff --git a/fs/xfs/xfs_ondisk.h b/fs/xfs/xfs_ondisk.h index 954484c6eb96..fa1252657b08 100644 --- a/fs/xfs/xfs_ondisk.h +++ b/fs/xfs/xfs_ondisk.h @@ -150,6 +150,7 @@ xfs_check_ondisk_structs(void) XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat, 192); XFS_CHECK_STRUCT_SIZE(struct xfs_inumbers, 24); XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat_req, 64); + XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat_single_req, 224); } #endif /* __XFS_ONDISK_H */ From patchwork Wed Jun 12 06:49:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10988671 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 52ECB14BB for ; Wed, 12 Jun 2019 06:49:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D53F288C6 for ; Wed, 12 Jun 2019 06:49:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3190C28987; Wed, 12 Jun 2019 06:49:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6C97289B2 for ; Wed, 12 Jun 2019 06:49:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391371AbfFLGtx (ORCPT ); Wed, 12 Jun 2019 02:49:53 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:54294 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390376AbfFLGtx (ORCPT ); Wed, 12 Jun 2019 02:49:53 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C6mjMv066082 for ; Wed, 12 Jun 2019 06:49: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-2018-07-02; bh=kC63O5A5GPfCx3AToZf7otmjXh8LcDRMYCOa1HGJ0qA=; b=cj3My7ThLqLhg/4cTQwcs3IsAMtannkMR37nOfoenUUsu2R22rAuj/Tx8FP88N2mqqaJ dXDore81OTGqQQY9fB1R/+4+twVQAWQJtqJy8BTfGAjk+SjAg1SgD2mBB4vw1bOfv0dX XWRQw2dght1FlHptT5PF0R2aNj5skCxM5UvtRIL7xtfr+KQEZpkHYmmh9ZVxtt8C5B3c 5D8662SWas7vG32Nl/NrVZPIcwFg8lbqBqjScW6kKaxsc5BZentKUbDmwU1jOES/RPme F7Q1dH6qez8Y+sMPNmCUXn+tnQSNEm7FJ1h8RjLtFvP7+ojhzfI65LXny2j63wDz4WpU 3g== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 2t02heskaq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 Jun 2019 06:49:51 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C6mukC049433 for ; Wed, 12 Jun 2019 06:49:50 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2t04hyrx2t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 Jun 2019 06:49:50 +0000 Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5C6no6p014988 for ; Wed, 12 Jun 2019 06:49:50 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 11 Jun 2019 23:49:50 -0700 Subject: [PATCH 7/9] xfs: wire up the v5 INUMBERS ioctl From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, allison.henderson@oracle.com Date: Tue, 11 Jun 2019 23:49:49 -0700 Message-ID: <156032218931.3774581.1709208162506188977.stgit@magnolia> In-Reply-To: <156032214432.3774581.1304900948974476604.stgit@magnolia> References: <156032214432.3774581.1304900948974476604.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120047 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120047 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Wire up the v5 INUMBERS ioctl and rename the old one to v1. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_fs.h | 8 +++++++ fs/xfs/xfs_ioctl.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_ioctl32.c | 1 + fs/xfs/xfs_ondisk.h | 1 + 4 files changed, 62 insertions(+) diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index 95d0411dae9b..f9f35139d4b7 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -493,6 +493,13 @@ struct xfs_bulkstat_single_req { struct xfs_bulkstat bulkstat; }; +struct xfs_inumbers_req { + struct xfs_bulk_ireq hdr; + struct xfs_inumbers inumbers[]; +}; +#define XFS_INUMBERS_REQ_SIZE(nr) (sizeof(struct xfs_inumbers_req) + \ + (nr) * sizeof(struct xfs_inumbers)) + /* * Error injection. */ @@ -796,6 +803,7 @@ struct xfs_scrub_metadata { #define XFS_IOC_FSGEOMETRY _IOR ('X', 126, struct xfs_fsop_geom) #define XFS_IOC_BULKSTAT _IOR ('X', 127, struct xfs_bulkstat_req) #define XFS_IOC_BULKSTAT_SINGLE _IOR ('X', 128, struct xfs_bulkstat_single_req) +#define XFS_IOC_INUMBERS _IOR ('X', 129, struct xfs_inumbers_req) /* XFS_IOC_GETFSUUID ---------- deprecated 140 */ diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 2c821fa601a4..2ac5e100b147 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -999,6 +999,56 @@ xfs_ioc_bulkstat_single( return 0; } +STATIC int +xfs_inumbers_fmt( + struct xfs_ibulk *breq, + const struct xfs_inumbers *igrp) +{ + if (copy_to_user(breq->ubuffer, igrp, sizeof(struct xfs_inumbers))) + return -EFAULT; + return xfs_ibulk_advance(breq, sizeof(struct xfs_inumbers)); +} + +/* Handle the v5 inumbers ioctl. */ +STATIC int +xfs_ioc_inumbers( + struct xfs_mount *mp, + unsigned int cmd, + struct xfs_inumbers_req __user *arg) +{ + struct xfs_bulk_ireq hdr; + struct xfs_ibulk breq = { + .mp = mp, + }; + int error; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + + if (XFS_FORCED_SHUTDOWN(mp)) + return -EIO; + + if (copy_from_user(&hdr, &arg->hdr, sizeof(hdr))) + return -EFAULT; + + error = xfs_bulk_ireq_setup(mp, &hdr, &breq, arg->inumbers); + if (error == XFS_ITER_ABORT) + goto out_teardown; + if (error < 0) + return error; + + error = xfs_inumbers(&breq, xfs_inumbers_fmt); + if (error) + return error; + +out_teardown: + xfs_bulk_ireq_teardown(&hdr, &breq); + if (copy_to_user(&arg->hdr, &hdr, sizeof(hdr))) + return -EFAULT; + + return 0; +} + STATIC int xfs_ioc_fsgeometry( struct xfs_mount *mp, @@ -2167,6 +2217,8 @@ xfs_file_ioctl( return xfs_ioc_bulkstat(mp, cmd, arg); case XFS_IOC_BULKSTAT_SINGLE: return xfs_ioc_bulkstat_single(mp, cmd, arg); + case XFS_IOC_INUMBERS: + return xfs_ioc_inumbers(mp, cmd, arg); case XFS_IOC_FSGEOMETRY_V1: return xfs_ioc_fsgeometry(mp, arg, 3); diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index 4152f68bfb5f..d7d6ca570089 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c @@ -583,6 +583,7 @@ xfs_file_compat_ioctl( case XFS_IOC_SCRUB_METADATA: case XFS_IOC_BULKSTAT: case XFS_IOC_BULKSTAT_SINGLE: + case XFS_IOC_INUMBERS: return xfs_file_ioctl(filp, cmd, p); #if !defined(BROKEN_X86_ALIGNMENT) || defined(CONFIG_X86_X32) /* diff --git a/fs/xfs/xfs_ondisk.h b/fs/xfs/xfs_ondisk.h index fa1252657b08..e390e65d2438 100644 --- a/fs/xfs/xfs_ondisk.h +++ b/fs/xfs/xfs_ondisk.h @@ -151,6 +151,7 @@ xfs_check_ondisk_structs(void) XFS_CHECK_STRUCT_SIZE(struct xfs_inumbers, 24); XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat_req, 64); XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat_single_req, 224); + XFS_CHECK_STRUCT_SIZE(struct xfs_inumbers_req, 64); } #endif /* __XFS_ONDISK_H */ From patchwork Wed Jun 12 06:49:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10988673 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E3A8014BB for ; Wed, 12 Jun 2019 06:50:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF140289AB for ; Wed, 12 Jun 2019 06:50:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD876289B4; Wed, 12 Jun 2019 06:50:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3A65289B5 for ; Wed, 12 Jun 2019 06:50:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391474AbfFLGuA (ORCPT ); Wed, 12 Jun 2019 02:50:00 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:54392 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390376AbfFLGuA (ORCPT ); Wed, 12 Jun 2019 02:50:00 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C6mfrI066049 for ; Wed, 12 Jun 2019 06:49:58 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-2018-07-02; bh=q/+8288epqj4z9wawXtiNfe4FGIwYwaAtyOXwoMVwCY=; b=nIgSZKTgOUNxsGfF1wltkYBFdAyP/8mRkWgHj+X5gT+WJOkfULYXYwBW8b2YnIouaiQG pONOUSvcB2GOzEUtmXUXLm5RDq/FuKSwApE4wcyLYz4GlyF0LLEPAkcDUc738dogvzeN 6htEYd+iOsUOZ9jQytQPJ4cATEolgg3aZehKSbPiTtdcZMO5R7l3k/v2ZexPIk2xINgj 3CXhrLllQzDqPc9c+Qvq7Xnrzf/Dz1jwDr8BZ5nJdzFYxNPxbWUSVXeN+DEuq5Mbq5Br pBb/MiblLzfODGFMv3IxtLn9g+jMTjaBGWqDx3NE3T9LKcHJtw4764MryHqaXxroKBTO Og== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 2t02heskb8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 Jun 2019 06:49:58 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C6nI97099799 for ; Wed, 12 Jun 2019 06:49:57 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2t024utj1b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 Jun 2019 06:49:57 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5C6nujX019825 for ; Wed, 12 Jun 2019 06:49:56 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 11 Jun 2019 23:49:56 -0700 Subject: [PATCH 8/9] xfs: specify AG in bulk req From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, allison.henderson@oracle.com Date: Tue, 11 Jun 2019 23:49:55 -0700 Message-ID: <156032219545.3774581.4885293947910469571.stgit@magnolia> In-Reply-To: <156032214432.3774581.1304900948974476604.stgit@magnolia> References: <156032214432.3774581.1304900948974476604.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120047 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120047 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Add a new xfs_bulk_ireq flag to constrain the iteration to a single AG. If the passed-in startino value is zero then we start with the first inode in the AG that the user passes in; otherwise, we iterate only within the same AG as the passed-in inode. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Collins --- fs/xfs/libxfs/xfs_fs.h | 10 ++++++++-- fs/xfs/xfs_ioctl.c | 25 ++++++++++++++++++++++++- fs/xfs/xfs_itable.c | 6 +++--- fs/xfs/xfs_itable.h | 4 ++++ fs/xfs/xfs_iwalk.c | 12 ++++++++++++ fs/xfs/xfs_iwalk.h | 22 +++++++++++++++++----- fs/xfs/xfs_qm.c | 3 ++- 7 files changed, 70 insertions(+), 12 deletions(-) diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index f9f35139d4b7..77c06850ac52 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -462,11 +462,17 @@ struct xfs_bulk_ireq { uint32_t flags; /* I/O: operation flags */ uint32_t icount; /* I: count of entries in buffer */ uint32_t ocount; /* O: count of entries filled out */ - uint32_t reserved32; /* must be zero */ + uint32_t agno; /* I: see comment for IREQ_AGNO */ uint64_t reserved[5]; /* must be zero */ }; -#define XFS_BULK_IREQ_FLAGS_ALL (0) +/* + * Only return results from the specified @agno. If @ino is zero, start + * with the first inode of @agno. + */ +#define XFS_BULK_IREQ_AGNO (1 << 0) + +#define XFS_BULK_IREQ_FLAGS_ALL (XFS_BULK_IREQ_AGNO) /* Header for a single inode request. */ struct xfs_ireq { diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 2ac5e100b147..f71341cd8340 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -853,7 +853,6 @@ xfs_bulk_ireq_setup( { if (hdr->icount == 0 || (hdr->flags & ~XFS_BULK_IREQ_FLAGS_ALL) || - hdr->reserved32 || memchr_inv(hdr->reserved, 0, sizeof(hdr->reserved))) return -EINVAL; @@ -861,6 +860,29 @@ xfs_bulk_ireq_setup( breq->ubuffer = ubuffer; breq->icount = hdr->icount; breq->ocount = 0; + breq->flags = 0; + + /* + * The IREQ_AGNO flag means that we only want results from a given AG. + * If @hdr->ino is zero, we start iterating in that AG. If @hdr->ino is + * beyond the specified AG then we return no results. + */ + if (hdr->flags & XFS_BULK_IREQ_AGNO) { + if (hdr->agno >= mp->m_sb.sb_agcount) + return -EINVAL; + + if (breq->startino == 0) + breq->startino = XFS_AGINO_TO_INO(mp, hdr->agno, 0); + else if (XFS_INO_TO_AGNO(mp, breq->startino) < hdr->agno) + return -EINVAL; + + breq->flags |= XFS_IBULK_SAME_AG; + + /* Asking for an inode past the end of the AG? We're done! */ + if (XFS_INO_TO_AGNO(mp, breq->startino) > hdr->agno) + return XFS_ITER_ABORT; + } else if (hdr->agno) + return -EINVAL; /* Asking for an inode past the end of the FS? We're done! */ if (XFS_INO_TO_AGNO(mp, breq->startino) >= mp->m_sb.sb_agcount) @@ -945,6 +967,7 @@ xfs_ireq_setup( breq->ubuffer = ubuffer; breq->icount = 1; breq->startino = hdr->ino; + breq->flags = 0; return 0; } diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c index 1ff95bba971f..553167d9c647 100644 --- a/fs/xfs/xfs_itable.c +++ b/fs/xfs/xfs_itable.c @@ -249,8 +249,8 @@ xfs_bulkstat( if (!bc.buf) return -ENOMEM; - error = xfs_iwalk(breq->mp, NULL, breq->startino, xfs_bulkstat_iwalk, - breq->icount, &bc); + error = xfs_iwalk(breq->mp, NULL, breq->startino, breq->flags, + xfs_bulkstat_iwalk, breq->icount, &bc); kmem_free(bc.buf); @@ -370,7 +370,7 @@ xfs_inumbers( if (xfs_bulkstat_already_done(breq->mp, breq->startino)) return 0; - error = xfs_inobt_walk(breq->mp, NULL, breq->startino, + error = xfs_inobt_walk(breq->mp, NULL, breq->startino, breq->flags, xfs_inumbers_walk, breq->icount, &ic); /* diff --git a/fs/xfs/xfs_itable.h b/fs/xfs/xfs_itable.h index d41a0a8a326c..d66ecb45ad60 100644 --- a/fs/xfs/xfs_itable.h +++ b/fs/xfs/xfs_itable.h @@ -12,8 +12,12 @@ struct xfs_ibulk { xfs_ino_t startino; /* start with this inode */ unsigned int icount; /* number of elements in ubuffer */ unsigned int ocount; /* number of records returned */ + unsigned int flags; /* see XFS_IBULK_FLAG_* */ }; +/* Only iterate within the same AG as startino */ +#define XFS_IBULK_SAME_AG (XFS_IWALK_SAME_AG) + /* Return value that means we want to abort the walk. */ #define XFS_IBULK_ABORT (XFS_IWALK_ABORT) diff --git a/fs/xfs/xfs_iwalk.c b/fs/xfs/xfs_iwalk.c index f10688cfb917..56e50480b496 100644 --- a/fs/xfs/xfs_iwalk.c +++ b/fs/xfs/xfs_iwalk.c @@ -506,6 +506,7 @@ xfs_iwalk( struct xfs_mount *mp, struct xfs_trans *tp, xfs_ino_t startino, + unsigned int flags, xfs_iwalk_fn iwalk_fn, unsigned int max_prefetch, void *data) @@ -524,6 +525,7 @@ xfs_iwalk( int error; ASSERT(agno < mp->m_sb.sb_agcount); + ASSERT(!(flags & ~XFS_IWALK_FLAGS_ALL)); xfs_iwalk_set_prefetch(&iwag, max_prefetch); error = xfs_iwalk_alloc(&iwag); @@ -535,6 +537,8 @@ xfs_iwalk( if (error) break; iwag.startino = XFS_AGINO_TO_INO(mp, agno + 1, 0); + if (flags & XFS_INOBT_WALK_SAME_AG) + break; } xfs_iwalk_free(&iwag); @@ -573,6 +577,7 @@ int xfs_iwalk_threaded( struct xfs_mount *mp, xfs_ino_t startino, + unsigned int flags, xfs_iwalk_fn iwalk_fn, unsigned int max_prefetch, bool polled, @@ -584,6 +589,7 @@ xfs_iwalk_threaded( int error; ASSERT(agno < mp->m_sb.sb_agcount); + ASSERT(!(flags & ~XFS_IWALK_FLAGS_ALL)); nr_threads = xfs_pwork_guess_datadev_parallelism(mp); error = xfs_pwork_init(mp, &pctl, xfs_iwalk_ag_work, "xfs_iwalk", @@ -605,6 +611,8 @@ xfs_iwalk_threaded( xfs_iwalk_set_prefetch(iwag, max_prefetch); xfs_pwork_queue(&pctl, &iwag->pwork); startino = XFS_AGINO_TO_INO(mp, agno + 1, 0); + if (flags & XFS_INOBT_WALK_SAME_AG) + break; } if (polled) @@ -623,6 +631,7 @@ xfs_inobt_walk( struct xfs_mount *mp, struct xfs_trans *tp, xfs_ino_t startino, + unsigned int flags, xfs_inobt_walk_fn inobt_walk_fn, unsigned int max_prefetch, void *data) @@ -639,6 +648,7 @@ xfs_inobt_walk( int error; ASSERT(agno < mp->m_sb.sb_agcount); + ASSERT(!(flags & ~XFS_INOBT_WALK_FLAGS_ALL)); /* Translate inumbers record count to inode count. */ xfs_iwalk_set_prefetch(&iwag, max_prefetch * XFS_INODES_PER_CHUNK); @@ -651,6 +661,8 @@ xfs_inobt_walk( if (error) break; iwag.startino = XFS_AGINO_TO_INO(mp, agno + 1, 0); + if (flags & XFS_INOBT_WALK_SAME_AG) + break; } xfs_iwalk_free(&iwag); diff --git a/fs/xfs/xfs_iwalk.h b/fs/xfs/xfs_iwalk.h index 202bca4c9c02..28e8257f9241 100644 --- a/fs/xfs/xfs_iwalk.h +++ b/fs/xfs/xfs_iwalk.h @@ -14,10 +14,16 @@ typedef int (*xfs_iwalk_fn)(struct xfs_mount *mp, struct xfs_trans *tp, #define XFS_IWALK_ABORT (XFS_ITER_ABORT) int xfs_iwalk(struct xfs_mount *mp, struct xfs_trans *tp, xfs_ino_t startino, - xfs_iwalk_fn iwalk_fn, unsigned int max_prefetch, void *data); + unsigned int flags, xfs_iwalk_fn iwalk_fn, + unsigned int max_prefetch, void *data); int xfs_iwalk_threaded(struct xfs_mount *mp, xfs_ino_t startino, - xfs_iwalk_fn iwalk_fn, unsigned int max_prefetch, bool poll, - void *data); + unsigned int flags, xfs_iwalk_fn iwalk_fn, + unsigned int max_prefetch, bool poll, void *data); + +/* Only iterate inodes within the same AG as @startino. */ +#define XFS_IWALK_SAME_AG (0x1) + +#define XFS_IWALK_FLAGS_ALL (XFS_IWALK_SAME_AG) /* Walk all inode btree records in the filesystem starting from @startino. */ typedef int (*xfs_inobt_walk_fn)(struct xfs_mount *mp, struct xfs_trans *tp, @@ -28,7 +34,13 @@ typedef int (*xfs_inobt_walk_fn)(struct xfs_mount *mp, struct xfs_trans *tp, #define XFS_INOBT_WALK_ABORT (XFS_IWALK_ABORT) int xfs_inobt_walk(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_ino_t startino, xfs_inobt_walk_fn inobt_walk_fn, - unsigned int max_prefetch, void *data); + xfs_ino_t startino, unsigned int flags, + xfs_inobt_walk_fn inobt_walk_fn, unsigned int max_prefetch, + void *data); + +/* Only iterate inobt records within the same AG as @startino. */ +#define XFS_INOBT_WALK_SAME_AG (XFS_IWALK_SAME_AG) + +#define XFS_INOBT_WALK_FLAGS_ALL (XFS_INOBT_WALK_SAME_AG) #endif /* __XFS_IWALK_H__ */ diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 8bb902125403..a526c28662ae 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -1304,7 +1304,8 @@ xfs_qm_quotacheck( flags |= XFS_PQUOTA_CHKD; } - error = xfs_iwalk_threaded(mp, 0, xfs_qm_dqusage_adjust, 0, true, NULL); + error = xfs_iwalk_threaded(mp, 0, 0, xfs_qm_dqusage_adjust, 0, true, + NULL); if (error) goto error_return; From patchwork Wed Jun 12 06:50:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10988675 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D688E14BB for ; Wed, 12 Jun 2019 06:50:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C309A289B6 for ; Wed, 12 Jun 2019 06:50:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B743828987; Wed, 12 Jun 2019 06:50:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 410E1289A2 for ; Wed, 12 Jun 2019 06:50:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391476AbfFLGuG (ORCPT ); Wed, 12 Jun 2019 02:50:06 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:34898 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390376AbfFLGuG (ORCPT ); Wed, 12 Jun 2019 02:50:06 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C6n0Gd055467 for ; Wed, 12 Jun 2019 06:50: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-2018-07-02; bh=l+OUXTuSZYJknKlChKmxP3SrJQwwHHx+UGEz7P1k8j8=; b=Jvp6JzLJNGF/MWcEqiFUwBK4ChFU008pvbjAJe2Y8NQGVEEeXY2juD62IMwoPJ2l+VPW rTYpOG3sPRmvkycRqovvYyTAdg5JQ+KblR3gmtDKw5psgx/eYZdTqTXfC0bL5MuLR6de CK3PmcH77iug03pPL/u4gS+zBOz98SyKCLalHNI+gYzyN5LZyZ2C2JOHMBFdPuBWTVn/ dTXNVRVq2JWnoUbRGMJdLM533BMArFJSBpTfSJBz1voKPiA4qJNTyuCgEGbvUpk/KRAL rdjsQlviVfp14d6tleUBA/o/ZCGz8iYfmuZNDvt2N371XyU0GZajOMNEFVzithdegpoK 8Q== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2t05nqsby8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 Jun 2019 06:50:05 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C6mdHu099116 for ; Wed, 12 Jun 2019 06:50:04 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2t0p9rq3a9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 Jun 2019 06:50:04 +0000 Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5C6o3D9007490 for ; Wed, 12 Jun 2019 06:50:03 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 11 Jun 2019 23:50:02 -0700 Subject: [PATCH 9/9] xfs: allow bulkstat_single of special inodes From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, allison.henderson@oracle.com Date: Tue, 11 Jun 2019 23:50:01 -0700 Message-ID: <156032220182.3774581.1524699549367116132.stgit@magnolia> In-Reply-To: <156032214432.3774581.1304900948974476604.stgit@magnolia> References: <156032214432.3774581.1304900948974476604.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=949 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120047 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=988 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120047 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Create a new ireq flag (for single bulkstats) that enables userspace to ask us for a special inode number instead of interpreting @ino as a literal inode number. This enables us to query the root inode easily. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Collins --- fs/xfs/libxfs/xfs_fs.h | 11 ++++++++++- fs/xfs/xfs_ioctl.c | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index 77c06850ac52..1489bce07d66 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -482,7 +482,16 @@ struct xfs_ireq { uint64_t reserved[2]; /* must be zero */ }; -#define XFS_IREQ_FLAGS_ALL (0) +/* + * The @ino value is a special value, not a literal inode number. See the + * XFS_IREQ_SPECIAL_* values below. + */ +#define XFS_IREQ_SPECIAL (1 << 0) + +#define XFS_IREQ_FLAGS_ALL (XFS_IREQ_SPECIAL) + +/* Operate on the root directory inode. */ +#define XFS_IREQ_SPECIAL_ROOT (1) /* * ioctl structures for v5 bulkstat and inumbers requests diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index f71341cd8340..3bb5f980fabf 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -961,6 +961,16 @@ xfs_ireq_setup( memchr_inv(hdr->reserved, 0, sizeof(hdr->reserved))) return -EINVAL; + if (hdr->flags & XFS_IREQ_SPECIAL) { + switch (hdr->ino) { + case XFS_IREQ_SPECIAL_ROOT: + hdr->ino = mp->m_sb.sb_rootino; + break; + default: + return -EINVAL; + } + } + if (XFS_INO_TO_AGNO(mp, hdr->ino) >= mp->m_sb.sb_agcount) return -EINVAL;