From patchwork Mon Jan 18 08:36:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gao Xiang X-Patchwork-Id: 12026763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07378C433DB for ; Mon, 18 Jan 2021 08:39:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B32F9229C6 for ; Mon, 18 Jan 2021 08:39:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387862AbhARIjU (ORCPT ); Mon, 18 Jan 2021 03:39:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20818 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387627AbhARIjT (ORCPT ); Mon, 18 Jan 2021 03:39:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610959073; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yj/GOWRwBDw0c1+mW/E8aP8Mn2Emy0ggtn2GQGWqU6A=; b=FPnttXL1fATAemWJBM5OC6Xcy0a0hBBms7wAIAPg3qFiyeQJpx7Apf4Zc/cqUaaL9/2buE ponzkH4MoLn+ktZ5UxTS3oTLroYkKvDznTHqSIHw3fz/tXYxSSsGuN3w1uVQoeErZAiXsY BmJNRwBHR+KVJqVPiU3xyin6dYtfHDE= Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-343-yxhAiaLIOOqHxKuGRgZI6Q-1; Mon, 18 Jan 2021 03:37:51 -0500 X-MC-Unique: yxhAiaLIOOqHxKuGRgZI6Q-1 Received: by mail-pl1-f198.google.com with SMTP id e3so6639011pls.7 for ; Mon, 18 Jan 2021 00:37:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Yj/GOWRwBDw0c1+mW/E8aP8Mn2Emy0ggtn2GQGWqU6A=; b=udSdhiyly0p2SCtqYuOFgb7EzZzZDcFPCjtt/PaC3I+04tF5Fdo/r3G9vX6r48QHXf RFOtJfIiU3GRBvzd/ETAcLgzjtOOdqiQz1Yy3mMpHD8ww18Xhm+GpEYrlmM/l+nPt/rd /OyZfnQyeVUZqJtC53dDcf54fC8aIGzRCjNJF42Y/xYVu4zURCHE8HHdskZsdS79ZafN I0/jiW64InbzKMIXP1zz3y4RPEdyTSLY89etZe+aQ+TecV5AF9wUqH/FqAenHbJVTS0i kp6P1fIwwDJHQBoUrOXTs0WwT1lpXbOyAIgj4e/a/GpjbQPb39doRHV9tnq24jYaO5Jk IXpg== X-Gm-Message-State: AOAM532We9lwsejhaBdAM+Nng+1X16znDgadoo0xy+w2AuCzPjYvCLm8 Rw3kDdos8B+JtGyWByWMh2G+uHvw0zFrEFsI32vsSHZbePTazzpP/FTq6LiUpRIfERJHVpW1wKw e3iizb1FvWbOW03oAacBIuarbW9d85Z0sSuSNBHh59ELib0QYhBPAN2YJA4QOGz1ODpdPjaTDUg == X-Received: by 2002:a62:25c7:0:b029:156:72a3:b0c0 with SMTP id l190-20020a6225c70000b029015672a3b0c0mr24586675pfl.59.1610959070383; Mon, 18 Jan 2021 00:37:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdiCwVvwWfgiqy5d6iHZETktn3ZvZFkKjUr1h9YvnRs/2pzNHnpKNl6patl2l6l048aobFkQ== X-Received: by 2002:a62:25c7:0:b029:156:72a3:b0c0 with SMTP id l190-20020a6225c70000b029015672a3b0c0mr24586645pfl.59.1610959070006; Mon, 18 Jan 2021 00:37:50 -0800 (PST) Received: from xiangao.remote.csb ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id e5sm16293916pjs.0.2021.01.18.00.37.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jan 2021 00:37:49 -0800 (PST) From: Gao Xiang To: linux-xfs@vger.kernel.org Cc: "Darrick J. Wong" , Brian Foster , Eric Sandeen , Dave Chinner , Christoph Hellwig , Gao Xiang Subject: [PATCH v5 1/5] xfs: rename `new' to `delta' in xfs_growfs_data_private() Date: Mon, 18 Jan 2021 16:36:56 +0800 Message-Id: <20210118083700.2384277-2-hsiangkao@redhat.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210118083700.2384277-1-hsiangkao@redhat.com> References: <20210118083700.2384277-1-hsiangkao@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org It actually means the delta block count of growfs. Rename it in order to make it clear. Also introduce nb_div to avoid reusing `delta`. Reviewed-by: Darrick J. Wong Signed-off-by: Gao Xiang --- fs/xfs/xfs_fsops.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index 5870db855e8b..6ad31e6b4a04 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c @@ -32,8 +32,8 @@ xfs_growfs_data_private( int error; xfs_agnumber_t nagcount; xfs_agnumber_t nagimax = 0; - xfs_rfsblock_t nb, nb_mod; - xfs_rfsblock_t new; + xfs_rfsblock_t nb, nb_div, nb_mod; + xfs_rfsblock_t delta; xfs_agnumber_t oagcount; xfs_trans_t *tp; struct aghdr_init_data id = {}; @@ -50,16 +50,16 @@ xfs_growfs_data_private( return error; xfs_buf_relse(bp); - new = nb; /* use new as a temporary here */ - nb_mod = do_div(new, mp->m_sb.sb_agblocks); - nagcount = new + (nb_mod != 0); + nb_div = nb; + nb_mod = do_div(nb_div, mp->m_sb.sb_agblocks); + nagcount = nb_div + (nb_mod != 0); if (nb_mod && nb_mod < XFS_MIN_AG_BLOCKS) { nagcount--; nb = (xfs_rfsblock_t)nagcount * mp->m_sb.sb_agblocks; if (nb < mp->m_sb.sb_dblocks) return -EINVAL; } - new = nb - mp->m_sb.sb_dblocks; + delta = nb - mp->m_sb.sb_dblocks; oagcount = mp->m_sb.sb_agcount; /* allocate the new per-ag structures */ @@ -89,7 +89,7 @@ xfs_growfs_data_private( INIT_LIST_HEAD(&id.buffer_list); for (id.agno = nagcount - 1; id.agno >= oagcount; - id.agno--, new -= id.agsize) { + id.agno--, delta -= id.agsize) { if (id.agno == nagcount - 1) id.agsize = nb - @@ -110,8 +110,8 @@ xfs_growfs_data_private( xfs_trans_agblocks_delta(tp, id.nfree); /* If there are new blocks in the old last AG, extend it. */ - if (new) { - error = xfs_ag_extend_space(mp, tp, &id, new); + if (delta) { + error = xfs_ag_extend_space(mp, tp, &id, delta); if (error) goto out_trans_cancel; } @@ -143,7 +143,7 @@ xfs_growfs_data_private( * If we expanded the last AG, free the per-AG reservation * so we can reinitialize it with the new size. */ - if (new) { + if (delta) { struct xfs_perag *pag; pag = xfs_perag_get(mp, id.agno); From patchwork Mon Jan 18 08:36:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gao Xiang X-Patchwork-Id: 12026765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1784BC433E0 for ; Mon, 18 Jan 2021 08:39:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B0BF8205CA for ; Mon, 18 Jan 2021 08:39:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387752AbhARIjb (ORCPT ); Mon, 18 Jan 2021 03:39:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:30208 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387627AbhARIj2 (ORCPT ); Mon, 18 Jan 2021 03:39:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610959079; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PZvpmG5or3JBdwdJ/ieTMuoFTtfP6U9OT9Q2X/rBLzA=; b=CARi2ToCT8TQ9+ry+6g9kDY2srm0ibKAqlNFRUY7xIfOLT5zrdr1RvTcfbw/X1xc2369zy bxYvlqYJuujrhdxfxvGOJCfYxkmkhri0G4cw88hW/Xm65cJNduKI2VSm3pXHmj5PKFgRmU Qije41Z7GUBLQZUT+i4oU2wnVojn0D4= Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-508-Mr7BC0m2O0aerD1-tBFkOg-1; Mon, 18 Jan 2021 03:37:57 -0500 X-MC-Unique: Mr7BC0m2O0aerD1-tBFkOg-1 Received: by mail-pl1-f199.google.com with SMTP id 32so10968253plf.3 for ; Mon, 18 Jan 2021 00:37:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PZvpmG5or3JBdwdJ/ieTMuoFTtfP6U9OT9Q2X/rBLzA=; b=W6EsWDeI3tXaQniFc5Zkyd8ZSOUE2qVAIaQaU2mgeGHsQMj4UVg45U7haSuoRvwDLE 34m5yhDjhWlQS7aftKOP5ye+3FeJm5egzV1SbfHwClwIDSOrZ3u7cqzLPMxLMiLux+WF u+acMLionI4z1LsAAkM3b+0jxZqb5JY5TI9a7pq5/51E0ab9KpIwA3m2tP8BcOQ19gX+ Mm5MvR3Ab8P8ydR4AKcdCB+p3/ei1RytgRgnP/aReFfbIWyyCFArkQb2tO+/1/5468Mp CXEcRvQcfP/YmPctTBhswb+hFurX1tHYAp+2hLgJt2upIRXIyA+ceyic6mXZPWCwn6Wz IDng== X-Gm-Message-State: AOAM531UujICkUp6NssPxjIJElPoWdTd1yY2p7FSNFUm03JCi8GRCjo9 /0SekFF6krTdX9prD5xQBTKJOeXnwptXoZm5ilnO0j5VT6XtbpDR84E7k3vaghCBO1mrzBY+hJf WlFEryxszJ5VPpBuCmu5Z+1ZXeXdEXkYkmq5CbtbclrRFizT1h3Hobhlf3+TcWXMbEkG9nAEJNg == X-Received: by 2002:a17:90b:d92:: with SMTP id bg18mr25236678pjb.66.1610959076223; Mon, 18 Jan 2021 00:37:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPQKfILAc7VJdzzE2yPLctZ/iVHr+8AADUMdOPNqTMG5rOVNQ1npsegOeYT5UF/9ZtyusWhA== X-Received: by 2002:a17:90b:d92:: with SMTP id bg18mr25236648pjb.66.1610959076017; Mon, 18 Jan 2021 00:37:56 -0800 (PST) Received: from xiangao.remote.csb ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id e5sm16293916pjs.0.2021.01.18.00.37.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jan 2021 00:37:55 -0800 (PST) From: Gao Xiang To: linux-xfs@vger.kernel.org Cc: "Darrick J. Wong" , Brian Foster , Eric Sandeen , Dave Chinner , Christoph Hellwig , Gao Xiang , Eric Sandeen Subject: [PATCH v5 2/5] xfs: get rid of xfs_growfs_{data,log}_t Date: Mon, 18 Jan 2021 16:36:57 +0800 Message-Id: <20210118083700.2384277-3-hsiangkao@redhat.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210118083700.2384277-1-hsiangkao@redhat.com> References: <20210118083700.2384277-1-hsiangkao@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Such usage isn't encouraged by the kernel coding style. Leave the definitions alone in case of userspace users. Reviewed-by: Darrick J. Wong Reviewed-by: Eric Sandeen Signed-off-by: Gao Xiang --- fs/xfs/xfs_fsops.c | 12 ++++++------ fs/xfs/xfs_fsops.h | 4 ++-- fs/xfs/xfs_ioctl.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index 6ad31e6b4a04..0bc9c5ebd199 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c @@ -25,8 +25,8 @@ */ static int xfs_growfs_data_private( - xfs_mount_t *mp, /* mount point for filesystem */ - xfs_growfs_data_t *in) /* growfs data input struct */ + struct xfs_mount *mp, /* mount point for filesystem */ + struct xfs_growfs_data *in) /* growfs data input struct */ { struct xfs_buf *bp; int error; @@ -35,7 +35,7 @@ xfs_growfs_data_private( xfs_rfsblock_t nb, nb_div, nb_mod; xfs_rfsblock_t delta; xfs_agnumber_t oagcount; - xfs_trans_t *tp; + struct xfs_trans *tp; struct aghdr_init_data id = {}; nb = in->newblocks; @@ -170,8 +170,8 @@ xfs_growfs_data_private( static int xfs_growfs_log_private( - xfs_mount_t *mp, /* mount point for filesystem */ - xfs_growfs_log_t *in) /* growfs log input struct */ + struct xfs_mount *mp, /* mount point for filesystem */ + struct xfs_growfs_log *in) /* growfs log input struct */ { xfs_extlen_t nb; @@ -268,7 +268,7 @@ xfs_growfs_data( int xfs_growfs_log( xfs_mount_t *mp, - xfs_growfs_log_t *in) + struct xfs_growfs_log *in) { int error; diff --git a/fs/xfs/xfs_fsops.h b/fs/xfs/xfs_fsops.h index 92869f6ec8d3..2cffe51a31e8 100644 --- a/fs/xfs/xfs_fsops.h +++ b/fs/xfs/xfs_fsops.h @@ -6,8 +6,8 @@ #ifndef __XFS_FSOPS_H__ #define __XFS_FSOPS_H__ -extern int xfs_growfs_data(xfs_mount_t *mp, xfs_growfs_data_t *in); -extern int xfs_growfs_log(xfs_mount_t *mp, xfs_growfs_log_t *in); +extern int xfs_growfs_data(struct xfs_mount *mp, struct xfs_growfs_data *in); +extern int xfs_growfs_log(struct xfs_mount *mp, struct xfs_growfs_log *in); extern void xfs_fs_counts(xfs_mount_t *mp, xfs_fsop_counts_t *cnt); extern int xfs_reserve_blocks(xfs_mount_t *mp, uint64_t *inval, xfs_fsop_resblks_t *outval); diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 3fbd98f61ea5..a62520f49ec5 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -2260,7 +2260,7 @@ xfs_file_ioctl( } case XFS_IOC_FSGROWFSDATA: { - xfs_growfs_data_t in; + struct xfs_growfs_data in; if (copy_from_user(&in, arg, sizeof(in))) return -EFAULT; @@ -2274,7 +2274,7 @@ xfs_file_ioctl( } case XFS_IOC_FSGROWFSLOG: { - xfs_growfs_log_t in; + struct xfs_growfs_log in; if (copy_from_user(&in, arg, sizeof(in))) return -EFAULT; From patchwork Mon Jan 18 08:36:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gao Xiang X-Patchwork-Id: 12026767 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D323C433DB for ; Mon, 18 Jan 2021 08:39:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 25E0420E65 for ; Mon, 18 Jan 2021 08:39:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387627AbhARIjb (ORCPT ); Mon, 18 Jan 2021 03:39:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25737 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387846AbhARIja (ORCPT ); Mon, 18 Jan 2021 03:39:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610959083; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wz17+lHWN5pIm7OBmFtmHLkQz3yGLrNrOnlyhJyqqAg=; b=MUjhcNWCczP8Ex39YST/9SCys/KsFXHHZQQMhV7EadAEx4Sg65Hzz5kCDxAyS0QXt9g0g8 frQR156ftYgMrnOk1Mj2n/HVS1JMZsVnYYmHuK0nAzhjoRIYVH/oJdHb8MuIaCkpv0Z1F+ AlMOYKjIL3CHfrhSzLgHmxYkrNzgO98= Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-575-F4Bx60H0NVOfZ-LKDLZYgg-1; Mon, 18 Jan 2021 03:38:02 -0500 X-MC-Unique: F4Bx60H0NVOfZ-LKDLZYgg-1 Received: by mail-pf1-f197.google.com with SMTP id v26so10503428pff.23 for ; Mon, 18 Jan 2021 00:38:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wz17+lHWN5pIm7OBmFtmHLkQz3yGLrNrOnlyhJyqqAg=; b=HTMv5L2nFTTzkUxjejk8R2IJ+NfVkYhBrXY3lulBXBVSMDHdNGmG8zm7GhkZNPyWDH XDZagV+VPTxULW6Wk1n8Kk/+5xXOOBctBElJhI7PbKfNbnhqjRqmsFwi5MxfE8SAHC4e ITkHoSBin3/KQ/cR6898r+P4Xo9/PbYJxGOLjM73BzyJaK/Oti9Y49GXjMJbPNSNHVlK U3htCFNnDR70zH+eu3Vk5cU44xea5uskGBl0LaBVF9V02nxtPCRTes3L1wbtmz3ojPmD t+hTAPCDFFA72Kq/Jd5NXZAg5wrB4hQsZW9AAertQn82yYrpTNXyQ6q56gYr95WUKcAV OCAA== X-Gm-Message-State: AOAM532K7hKfZvb7QgLPqu6XlbkRg8A5dnJTBiRzpQsaxy+WrJAxZchq NE3hEp8T8E7WPw7rdmke4tx/ALXGiFYSgwWb47gRO/LcEOPaorQ+NoTzVQEx3OIvCB3smFFLhTw lNHjAXj7gTJOjG0r2EXSxl8EOtJjskGEX5b68EBw6tTj27SNumC6tnZoKq8nn+Rv5l6OkYl+xTQ == X-Received: by 2002:a63:ec4f:: with SMTP id r15mr25041936pgj.344.1610959080789; Mon, 18 Jan 2021 00:38:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJxLuvbKoqzN+jhwYRd47cTVMevyzUu+VqA/XP9uR8ZeeC1WKM5Uv3bPgUPapay2hqxYZdHnGw== X-Received: by 2002:a63:ec4f:: with SMTP id r15mr25041920pgj.344.1610959080525; Mon, 18 Jan 2021 00:38:00 -0800 (PST) Received: from xiangao.remote.csb ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id e5sm16293916pjs.0.2021.01.18.00.37.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jan 2021 00:38:00 -0800 (PST) From: Gao Xiang To: linux-xfs@vger.kernel.org Cc: "Darrick J. Wong" , Brian Foster , Eric Sandeen , Dave Chinner , Christoph Hellwig , Gao Xiang Subject: [PATCH v5 3/5] xfs: hoist out xfs_resizefs_init_new_ags() Date: Mon, 18 Jan 2021 16:36:58 +0800 Message-Id: <20210118083700.2384277-4-hsiangkao@redhat.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210118083700.2384277-1-hsiangkao@redhat.com> References: <20210118083700.2384277-1-hsiangkao@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Move out related logic for initializing new added AGs to a new helper in preparation for shrinking. No logic changes. Reviewed-by: Darrick J. Wong Signed-off-by: Gao Xiang --- fs/xfs/xfs_fsops.c | 74 +++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index 0bc9c5ebd199..db6ed354c465 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c @@ -20,6 +20,49 @@ #include "xfs_ag.h" #include "xfs_ag_resv.h" +/* + * Write new AG headers to disk. Non-transactional, but need to be + * written and completed prior to the growfs transaction being logged. + * To do this, we use a delayed write buffer list and wait for + * submission and IO completion of the list as a whole. This allows the + * IO subsystem to merge all the AG headers in a single AG into a single + * IO and hide most of the latency of the IO from us. + * + * This also means that if we get an error whilst building the buffer + * list to write, we can cancel the entire list without having written + * anything. + */ +static int +xfs_resizefs_init_new_ags( + struct xfs_mount *mp, + struct aghdr_init_data *id, + xfs_agnumber_t oagcount, + xfs_agnumber_t nagcount, + xfs_rfsblock_t *delta) +{ + xfs_rfsblock_t nb = mp->m_sb.sb_dblocks + *delta; + int error; + + INIT_LIST_HEAD(&id->buffer_list); + for (id->agno = nagcount - 1; + id->agno >= oagcount; + id->agno--, *delta -= id->agsize) { + + if (id->agno == nagcount - 1) + id->agsize = nb - (id->agno * + (xfs_rfsblock_t)mp->m_sb.sb_agblocks); + else + id->agsize = mp->m_sb.sb_agblocks; + + error = xfs_ag_init_headers(mp, id); + if (error) { + xfs_buf_delwri_cancel(&id->buffer_list); + return error; + } + } + return xfs_buf_delwri_submit(&id->buffer_list); +} + /* * growfs operations */ @@ -74,36 +117,7 @@ xfs_growfs_data_private( if (error) return error; - /* - * Write new AG headers to disk. Non-transactional, but need to be - * written and completed prior to the growfs transaction being logged. - * To do this, we use a delayed write buffer list and wait for - * submission and IO completion of the list as a whole. This allows the - * IO subsystem to merge all the AG headers in a single AG into a single - * IO and hide most of the latency of the IO from us. - * - * This also means that if we get an error whilst building the buffer - * list to write, we can cancel the entire list without having written - * anything. - */ - INIT_LIST_HEAD(&id.buffer_list); - for (id.agno = nagcount - 1; - id.agno >= oagcount; - id.agno--, delta -= id.agsize) { - - if (id.agno == nagcount - 1) - id.agsize = nb - - (id.agno * (xfs_rfsblock_t)mp->m_sb.sb_agblocks); - else - id.agsize = mp->m_sb.sb_agblocks; - - error = xfs_ag_init_headers(mp, &id); - if (error) { - xfs_buf_delwri_cancel(&id.buffer_list); - goto out_trans_cancel; - } - } - error = xfs_buf_delwri_submit(&id.buffer_list); + error = xfs_resizefs_init_new_ags(mp, &id, oagcount, nagcount, &delta); if (error) goto out_trans_cancel; From patchwork Mon Jan 18 08:36:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gao Xiang X-Patchwork-Id: 12026769 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C584FC433DB for ; Mon, 18 Jan 2021 08:39:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 81271206F8 for ; Mon, 18 Jan 2021 08:39:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387876AbhARIjg (ORCPT ); Mon, 18 Jan 2021 03:39:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:31378 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387863AbhARIjf (ORCPT ); Mon, 18 Jan 2021 03:39:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610959088; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y3envSSRZYzU9hytgEjJuRSixnSNcyfdmD8FtxcTSV0=; b=UfvIeNUomvDX61m4lxTlWr67cS/LQkAnQWdEqw31eHPwTGbQGdptt8HyfiYF9274azMbpx DmK1AD8PyEDwVD/t0yTTZAPqVX/m5UKSVWXwu8R7G55bITwUZYaQLpMMJQt69/EtCPrIgy 5wwp8/PK6DzA6ArxXNYgx/MA300BCBM= Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-570-rLS-qtWqPlyzekhtanlusA-1; Mon, 18 Jan 2021 03:38:07 -0500 X-MC-Unique: rLS-qtWqPlyzekhtanlusA-1 Received: by mail-pg1-f197.google.com with SMTP id n2so12750069pgj.12 for ; Mon, 18 Jan 2021 00:38:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y3envSSRZYzU9hytgEjJuRSixnSNcyfdmD8FtxcTSV0=; b=V2ABP94Ks60pTDArVflF3ZIjtCHOzquif38L+tfgTZ38ZPaVXoddOxJE9cgWC2/DBK jsDGd8L7ZLwW8fP51LqMZdRl3pb3Gk1FWzX1R4ILO44dzvi+VtXNX+HReCTMHwvL2EF6 4XomfThCbcV6ONVTsHow3qKM1+P6R5Zwq43DD2YaQyObfo9o5+Ne14YijpxA+Nx60Oqn thtqORBg3DZgRbZVijNMCyOzs0s6tBUvDrd8ZLF9u03JGz61ZfsT58um2wkOXPmxj1wX JNI6P/9J8sOe++6orqZrCarrZW3fs9Nj7NR3R44NmzoSbHQZ72BJYwVRz9iB/a2SkT12 7jMQ== X-Gm-Message-State: AOAM532r7hUrETfRO7PvKY6jiPngnqDPhteuLQZ0S+3XAQGv7pTDLZTv cqL5lVcw1JkwGPqBNypwatsz2ftce4yorBGCcXpsaZIDh78pBNcsFOyr+T37RnmuN8ETlT/Fhdr pl0GrdGCRUU9RGa0t0VYNublZUmChUxlqMRlqW+1Fwgp35n8etYpJnnQG48l0l8hrOYlYFQkkVg == X-Received: by 2002:aa7:95a4:0:b029:1a5:b7a4:9aa1 with SMTP id a4-20020aa795a40000b02901a5b7a49aa1mr24920793pfk.53.1610959085405; Mon, 18 Jan 2021 00:38:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJfyMgkb7rFWi4JDtQWCMBftyuZc0PQEBi/ba4yXHd6yTMgOm3GuHFJ9V8OIVg7sHgnUaMlA== X-Received: by 2002:aa7:95a4:0:b029:1a5:b7a4:9aa1 with SMTP id a4-20020aa795a40000b02901a5b7a49aa1mr24920768pfk.53.1610959085025; Mon, 18 Jan 2021 00:38:05 -0800 (PST) Received: from xiangao.remote.csb ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id e5sm16293916pjs.0.2021.01.18.00.38.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jan 2021 00:38:04 -0800 (PST) From: Gao Xiang To: linux-xfs@vger.kernel.org Cc: "Darrick J. Wong" , Brian Foster , Eric Sandeen , Dave Chinner , Christoph Hellwig , Gao Xiang Subject: [PATCH v5 4/5] xfs: support shrinking unused space in the last AG Date: Mon, 18 Jan 2021 16:36:59 +0800 Message-Id: <20210118083700.2384277-5-hsiangkao@redhat.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210118083700.2384277-1-hsiangkao@redhat.com> References: <20210118083700.2384277-1-hsiangkao@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org As the first step of shrinking, this attempts to enable shrinking unused space in the last allocation group by fixing up freespace btree, agi, agf and adjusting super block and introduce a helper xfs_ag_shrink_space() to fixup the last AG. This can be all done in one transaction for now, so I think no additional protection is needed. Signed-off-by: Gao Xiang --- fs/xfs/libxfs/xfs_ag.c | 88 ++++++++++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_ag.h | 2 + fs/xfs/xfs_fsops.c | 77 ++++++++++++++++++++++++++---------- fs/xfs/xfs_trans.c | 1 - 4 files changed, 146 insertions(+), 22 deletions(-) diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c index 9331f3516afa..04a7c9b20470 100644 --- a/fs/xfs/libxfs/xfs_ag.c +++ b/fs/xfs/libxfs/xfs_ag.c @@ -22,6 +22,8 @@ #include "xfs_ag.h" #include "xfs_ag_resv.h" #include "xfs_health.h" +#include "xfs_error.h" +#include "xfs_bmap.h" static int xfs_get_aghdr_buf( @@ -485,6 +487,92 @@ xfs_ag_init_headers( return error; } +int +xfs_ag_shrink_space( + struct xfs_mount *mp, + struct xfs_trans *tp, + struct aghdr_init_data *id, + xfs_extlen_t len) +{ + struct xfs_alloc_arg args = { + .tp = tp, + .mp = mp, + .type = XFS_ALLOCTYPE_THIS_BNO, + .minlen = len, + .maxlen = len, + .oinfo = XFS_RMAP_OINFO_SKIP_UPDATE, + .resv = XFS_AG_RESV_NONE, + .prod = 1 + }; + struct xfs_buf *agibp, *agfbp; + struct xfs_agi *agi; + struct xfs_agf *agf; + int error, err2; + + ASSERT(id->agno == mp->m_sb.sb_agcount - 1); + error = xfs_ialloc_read_agi(mp, tp, id->agno, &agibp); + if (error) + return error; + + agi = agibp->b_addr; + + error = xfs_alloc_read_agf(mp, tp, id->agno, 0, &agfbp); + if (error) + return error; + + agf = agfbp->b_addr; + if (XFS_IS_CORRUPT(mp, agf->agf_length != agi->agi_length)) + return -EFSCORRUPTED; + + args.fsbno = XFS_AGB_TO_FSB(mp, id->agno, + be32_to_cpu(agi->agi_length) - len); + + /* remove the preallocations before allocation and re-establish then */ + error = xfs_ag_resv_free(agibp->b_pag); + if (error) + return error; + + /* internal log shouldn't also show up in the free space btrees */ + error = xfs_alloc_vextent(&args); + if (!error && args.agbno == NULLAGBLOCK) + error = -ENOSPC; + + if (error) { + err2 = xfs_ag_resv_init(agibp->b_pag, tp); + if (err2) + goto resv_err; + return error; + } + + /* + * if successfully deleted from freespace btrees, need to confirm + * per-AG reservation works as expected. + */ + be32_add_cpu(&agi->agi_length, -len); + be32_add_cpu(&agf->agf_length, -len); + + err2 = xfs_ag_resv_init(agibp->b_pag, tp); + if (err2) { + be32_add_cpu(&agi->agi_length, len); + be32_add_cpu(&agf->agf_length, len); + if (err2 != -ENOSPC) + goto resv_err; + + __xfs_bmap_add_free(tp, args.fsbno, len, + &XFS_RMAP_OINFO_SKIP_UPDATE, true); + return err2; + } + xfs_ialloc_log_agi(tp, agibp, XFS_AGI_LENGTH); + xfs_alloc_log_agf(tp, agfbp, XFS_AGF_LENGTH); + return 0; + +resv_err: + xfs_warn(mp, +"Error %d reserving per-AG metadata reserve pool.", err2); + xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); + return err2; +} + /* * Extent the AG indicated by the @id by the length passed in */ diff --git a/fs/xfs/libxfs/xfs_ag.h b/fs/xfs/libxfs/xfs_ag.h index 5166322807e7..f3b5bbfeadce 100644 --- a/fs/xfs/libxfs/xfs_ag.h +++ b/fs/xfs/libxfs/xfs_ag.h @@ -24,6 +24,8 @@ struct aghdr_init_data { }; int xfs_ag_init_headers(struct xfs_mount *mp, struct aghdr_init_data *id); +int xfs_ag_shrink_space(struct xfs_mount *mp, struct xfs_trans *tp, + struct aghdr_init_data *id, xfs_extlen_t len); int xfs_ag_extend_space(struct xfs_mount *mp, struct xfs_trans *tp, struct aghdr_init_data *id, xfs_extlen_t len); int xfs_ag_get_geometry(struct xfs_mount *mp, xfs_agnumber_t agno, diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index db6ed354c465..2ae4f33b42c9 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c @@ -38,7 +38,7 @@ xfs_resizefs_init_new_ags( struct aghdr_init_data *id, xfs_agnumber_t oagcount, xfs_agnumber_t nagcount, - xfs_rfsblock_t *delta) + int64_t *delta) { xfs_rfsblock_t nb = mp->m_sb.sb_dblocks + *delta; int error; @@ -76,33 +76,41 @@ xfs_growfs_data_private( xfs_agnumber_t nagcount; xfs_agnumber_t nagimax = 0; xfs_rfsblock_t nb, nb_div, nb_mod; - xfs_rfsblock_t delta; + int64_t delta; xfs_agnumber_t oagcount; struct xfs_trans *tp; + bool extend; struct aghdr_init_data id = {}; nb = in->newblocks; - if (nb < mp->m_sb.sb_dblocks) - return -EINVAL; - if ((error = xfs_sb_validate_fsb_count(&mp->m_sb, nb))) + if (nb == mp->m_sb.sb_dblocks) + return 0; + + error = xfs_sb_validate_fsb_count(&mp->m_sb, nb); + if (error) return error; - error = xfs_buf_read_uncached(mp->m_ddev_targp, + + if (nb > mp->m_sb.sb_dblocks) { + error = xfs_buf_read_uncached(mp->m_ddev_targp, XFS_FSB_TO_BB(mp, nb) - XFS_FSS_TO_BB(mp, 1), XFS_FSS_TO_BB(mp, 1), 0, &bp, NULL); - if (error) - return error; - xfs_buf_relse(bp); + if (error) + return error; + xfs_buf_relse(bp); + } nb_div = nb; nb_mod = do_div(nb_div, mp->m_sb.sb_agblocks); nagcount = nb_div + (nb_mod != 0); if (nb_mod && nb_mod < XFS_MIN_AG_BLOCKS) { nagcount--; - nb = (xfs_rfsblock_t)nagcount * mp->m_sb.sb_agblocks; - if (nb < mp->m_sb.sb_dblocks) + if (nagcount < 2) return -EINVAL; + nb = (xfs_rfsblock_t)nagcount * mp->m_sb.sb_agblocks; } + delta = nb - mp->m_sb.sb_dblocks; + extend = (delta > 0); oagcount = mp->m_sb.sb_agcount; /* allocate the new per-ag structures */ @@ -110,22 +118,34 @@ xfs_growfs_data_private( error = xfs_initialize_perag(mp, nagcount, &nagimax); if (error) return error; + } else if (nagcount != oagcount) { + /* TODO: shrinking the entire AGs hasn't yet completed */ + return -EINVAL; } error = xfs_trans_alloc(mp, &M_RES(mp)->tr_growdata, - XFS_GROWFS_SPACE_RES(mp), 0, XFS_TRANS_RESERVE, &tp); + (extend ? XFS_GROWFS_SPACE_RES(mp) : -delta), 0, + XFS_TRANS_RESERVE, &tp); if (error) return error; - error = xfs_resizefs_init_new_ags(mp, &id, oagcount, nagcount, &delta); - if (error) - goto out_trans_cancel; - + if (extend) { + error = xfs_resizefs_init_new_ags(mp, &id, oagcount, + nagcount, &delta); + if (error) + goto out_trans_cancel; + } xfs_trans_agblocks_delta(tp, id.nfree); - /* If there are new blocks in the old last AG, extend it. */ + /* If there are some blocks in the last AG, resize it. */ if (delta) { - error = xfs_ag_extend_space(mp, tp, &id, delta); + if (extend) { + error = xfs_ag_extend_space(mp, tp, &id, delta); + } else { + id.agno = nagcount - 1; + error = xfs_ag_shrink_space(mp, tp, &id, -delta); + } + if (error) goto out_trans_cancel; } @@ -137,11 +157,19 @@ xfs_growfs_data_private( */ if (nagcount > oagcount) xfs_trans_mod_sb(tp, XFS_TRANS_SB_AGCOUNT, nagcount - oagcount); - if (nb > mp->m_sb.sb_dblocks) + if (nb != mp->m_sb.sb_dblocks) xfs_trans_mod_sb(tp, XFS_TRANS_SB_DBLOCKS, nb - mp->m_sb.sb_dblocks); if (id.nfree) xfs_trans_mod_sb(tp, XFS_TRANS_SB_FDBLOCKS, id.nfree); + + /* + * update in-core counters (especially sb_fdblocks) now + * so xfs_validate_sb_write() can pass. + */ + if (xfs_sb_version_haslazysbcount(&mp->m_sb)) + xfs_log_sb(tp); + xfs_trans_set_sync(tp); error = xfs_trans_commit(tp); if (error) @@ -157,7 +185,7 @@ xfs_growfs_data_private( * If we expanded the last AG, free the per-AG reservation * so we can reinitialize it with the new size. */ - if (delta) { + if (delta > 0) { struct xfs_perag *pag; pag = xfs_perag_get(mp, id.agno); @@ -178,7 +206,14 @@ xfs_growfs_data_private( return error; out_trans_cancel: - xfs_trans_cancel(tp); + /* + * AGFL fixup can dirty the transaction, so it needs committing anyway. + */ + if (!extend && ((tp->t_flags & XFS_TRANS_DIRTY) || + !list_empty(&tp->t_dfops))) + xfs_trans_commit(tp); + else + xfs_trans_cancel(tp); return error; } diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index e72730f85af1..fd2cbf414b80 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -419,7 +419,6 @@ xfs_trans_mod_sb( tp->t_res_frextents_delta += delta; break; case XFS_TRANS_SB_DBLOCKS: - ASSERT(delta > 0); tp->t_dblocks_delta += delta; break; case XFS_TRANS_SB_AGCOUNT: From patchwork Mon Jan 18 08:37:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gao Xiang X-Patchwork-Id: 12026771 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9094EC433DB for ; Mon, 18 Jan 2021 08:39:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5508E206F8 for ; Mon, 18 Jan 2021 08:39:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387740AbhARIjm (ORCPT ); Mon, 18 Jan 2021 03:39:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23166 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387863AbhARIjj (ORCPT ); Mon, 18 Jan 2021 03:39:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610959092; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k+4ebVbzIC2903900vS2HKtvzDcl5o1uQkx3GT9HNAQ=; b=i7zgPOMru6zUAuciQmYumoX5SBgWOypDLWpFTm+Hp1P4AUjUuMs0j3156PZ5CY0m5gO+NU /AA+DLeTHIMPQ5zmShG4Lru7yIgM88+Ghm9lZiQmR6JczRJwkVSAPkgGESrSrYZTfmfSek CE8QMwiB2XFF/1JBiE4S/mPYWLeeEAo= Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-519-zJH998UqPSqBU2c5mZMayQ-1; Mon, 18 Jan 2021 03:38:11 -0500 X-MC-Unique: zJH998UqPSqBU2c5mZMayQ-1 Received: by mail-pg1-f199.google.com with SMTP id y2so12750996pgq.23 for ; Mon, 18 Jan 2021 00:38:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k+4ebVbzIC2903900vS2HKtvzDcl5o1uQkx3GT9HNAQ=; b=E2lET8XbAOyundH7yMxgyFhvTSsz73jO3cDNN/+t/NFSEoW/K3eB2YaTNdV/pFCiDv 0/SH4muKHkItAmIXLcK4AGV0D8e6nRkru95Cpi8C+SQRQaU9uhS+ojMQDX5Jxe09NHiE ZvV0HU9nvdjQJWOA7RfvTozYUF6um7r1TOKx/PWp07XsbQlkMIi3lIyRAa/9w2AOSj+6 Y+ajD3WEvzespqL8Jb6VwIPZhlqc/TNpIqs9VUZ3ITcCfFy+mgAAP/fsWkqmQgJk4pVg hVzczHFEGL396qyQRSfTzvD22cPi/0JwoRH+kWyHwGr7UGTBFyX5YVVf2p1cc1rgjdyb BekA== X-Gm-Message-State: AOAM530dzcb0Xl6SSLRfwXBAZGH+R+HfopCdDYeuYqdrI8KBEZ/sCYVT hbLdZU0HKt4sMEKoRvv44uZvMoIrattQgnWUosfYw95oNVE66itD+OXQcIs2ektumGz1mcXzILZ dIvOizRlZyjDVVZ3lDPRpiL07g5E+vQEOB3fiV/EonWjp6puS5+vdp7dGs4TCXWRsU8w1cSNyNg == X-Received: by 2002:aa7:83c2:0:b029:1a5:daa9:f22f with SMTP id j2-20020aa783c20000b02901a5daa9f22fmr24666336pfn.48.1610959089846; Mon, 18 Jan 2021 00:38:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJynbiHAjClSsa2FlQp1L/DAhNhJZyZUWSTTlKoyUg7WdYsJM7VUygLGW7dOWvgUb0txfeTQoQ== X-Received: by 2002:aa7:83c2:0:b029:1a5:daa9:f22f with SMTP id j2-20020aa783c20000b02901a5daa9f22fmr24666296pfn.48.1610959089420; Mon, 18 Jan 2021 00:38:09 -0800 (PST) Received: from xiangao.remote.csb ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id e5sm16293916pjs.0.2021.01.18.00.38.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jan 2021 00:38:09 -0800 (PST) From: Gao Xiang To: linux-xfs@vger.kernel.org Cc: "Darrick J. Wong" , Brian Foster , Eric Sandeen , Dave Chinner , Christoph Hellwig , Gao Xiang Subject: [PATCH v5 5/5] xfs: add error injection for per-AG resv failure when shrinkfs Date: Mon, 18 Jan 2021 16:37:00 +0800 Message-Id: <20210118083700.2384277-6-hsiangkao@redhat.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210118083700.2384277-1-hsiangkao@redhat.com> References: <20210118083700.2384277-1-hsiangkao@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org per-AG resv failure after fixing up freespace is hard to test in an effective way, so directly add an error injection path to observe such error handling path works as expected. Signed-off-by: Gao Xiang Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_ag.c | 5 +++++ fs/xfs/libxfs/xfs_errortag.h | 2 ++ fs/xfs/xfs_error.c | 2 ++ 3 files changed, 9 insertions(+) diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c index 04a7c9b20470..65e8e07f179b 100644 --- a/fs/xfs/libxfs/xfs_ag.c +++ b/fs/xfs/libxfs/xfs_ag.c @@ -23,6 +23,7 @@ #include "xfs_ag_resv.h" #include "xfs_health.h" #include "xfs_error.h" +#include "xfs_errortag.h" #include "xfs_bmap.h" static int @@ -552,6 +553,10 @@ xfs_ag_shrink_space( be32_add_cpu(&agf->agf_length, -len); err2 = xfs_ag_resv_init(agibp->b_pag, tp); + + if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_SHRINKFS_AG_RESV_FAIL)) + err2 = -ENOSPC; + if (err2) { be32_add_cpu(&agi->agi_length, len); be32_add_cpu(&agf->agf_length, len); diff --git a/fs/xfs/libxfs/xfs_errortag.h b/fs/xfs/libxfs/xfs_errortag.h index 53b305dea381..89da08a451cf 100644 --- a/fs/xfs/libxfs/xfs_errortag.h +++ b/fs/xfs/libxfs/xfs_errortag.h @@ -40,6 +40,8 @@ #define XFS_ERRTAG_REFCOUNT_FINISH_ONE 25 #define XFS_ERRTAG_BMAP_FINISH_ONE 26 #define XFS_ERRTAG_AG_RESV_CRITICAL 27 +#define XFS_ERRTAG_SHRINKFS_AG_RESV_FAIL 28 + /* * DEBUG mode instrumentation to test and/or trigger delayed allocation * block killing in the event of failed writes. When enabled, all diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index 7f6e20899473..c864451ba7d0 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c @@ -164,6 +164,7 @@ XFS_ERRORTAG_ATTR_RW(force_repair, XFS_ERRTAG_FORCE_SCRUB_REPAIR); XFS_ERRORTAG_ATTR_RW(bad_summary, XFS_ERRTAG_FORCE_SUMMARY_RECALC); XFS_ERRORTAG_ATTR_RW(iunlink_fallback, XFS_ERRTAG_IUNLINK_FALLBACK); XFS_ERRORTAG_ATTR_RW(buf_ioerror, XFS_ERRTAG_BUF_IOERROR); +XFS_ERRORTAG_ATTR_RW(shrinkfs_ag_resv_fail, XFS_ERRTAG_SHRINKFS_AG_RESV_FAIL); static struct attribute *xfs_errortag_attrs[] = { XFS_ERRORTAG_ATTR_LIST(noerror), @@ -202,6 +203,7 @@ static struct attribute *xfs_errortag_attrs[] = { XFS_ERRORTAG_ATTR_LIST(bad_summary), XFS_ERRORTAG_ATTR_LIST(iunlink_fallback), XFS_ERRORTAG_ATTR_LIST(buf_ioerror), + XFS_ERRORTAG_ATTR_LIST(shrinkfs_ag_resv_fail), NULL, };