Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3012965iob; Sun, 1 May 2022 04:30:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFyI8aJQDtwLbKerLihwcEBeiN+IU6V52z2BJnYIJg6qT+5GCE5vszhA1V2v0EwlJ1JbIi X-Received: by 2002:a17:902:c403:b0:15e:8d3a:b018 with SMTP id k3-20020a170902c40300b0015e8d3ab018mr6765976plk.94.1651404600964; Sun, 01 May 2022 04:30:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651404600; cv=none; d=google.com; s=arc-20160816; b=FGOfONh8qpgkPXlxlEmWfg8gQK7VEalR6Murg0jubKScBqfBaHlvAaNuMmZVJpiRF4 H735FYHVcNI4aj4SJW8+Vc7s0brVesCOagicP8WO37SHlzTfoUC/r2e+NH1JJ7iayfQH KrS1Ii9y8ebGpXeYPRzVaLHnY/wJ9IQ9HheQfQpwnzwiv45h27UH8PNSj9ovzR9XruKA r+43je8K4kTz1Xvx9cUuyiDDVCkK7u9+M/5tU26/8QidbfSV3fbzU76dsZhBQ+md5NLD 4U0f62eHKGS5ODvUnNgQmKHStqAW9D9hakdl+i5d2NexWWxFfByp1CXzDupGqmvtzCzZ xmCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rUdrb/CntvSlKdZAI/upGsiwb/U7G/huTTSxLBm0x7I=; b=JKX1GTTDemy4dneGtpo8hN4HTgx8O3PZnX/njpmV7+4ma3F2L0/RW8yGU5G6UncFn2 Wan6oxcKrHwb4pANhsoSeM3HRA5DQjoQz1sbLmGlQJPfkbiK+3y1uPRNvlLMBaN4ctu7 AJL+PZq3//AraHvWjAM5HuFeMl9Ouql1wvmzESP6o3y92nlzQfM0Ik3otV5LuaMfOBt5 CGuGFbO0ysE7JrLWzEKp2elZNNKwoYgkxJeCAOvWAdP+gjXXn5J9H8h5oOg/o3sMbBuV xtB/zIzvfgPSDOm0UQx6SLRfT1W0sL57ID1/2D6sOhIamsc31A8pa2KI9/x1nt2/1l9U Hzpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=D7u8QCDn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e1-20020a656881000000b003ab6efc083csi11157987pgt.512.2022.05.01.04.29.46; Sun, 01 May 2022 04:30:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=D7u8QCDn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357845AbiD2KsW (ORCPT + 99 others); Fri, 29 Apr 2022 06:48:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357869AbiD2Krn (ORCPT ); Fri, 29 Apr 2022 06:47:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 933B1C9B70; Fri, 29 Apr 2022 03:43:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 30941B83406; Fri, 29 Apr 2022 10:43:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E615C385A4; Fri, 29 Apr 2022 10:43:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651228990; bh=5hML3BYk9jAqNKodacb7w/XigQeBkKDM22lvUbUubU4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D7u8QCDn9ArjvvMH5iFdvJ98N+nOHTJWcTnCRvnLmOm1esAFxrbjRU/JmAowGFnds QfpG/lsNAqLLMw2RMaU9cbvsblME3j9I2V3GZ/3L70r5vJvD7a8969JJULAEhUN9Ur ulKiNZs2zXH4OYGtCuU8ObIqWQqjKUJtSBnoJl+0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Andreas Gruenbacher , Anand Jain Subject: [PATCH 5.15 22/33] gfs2: Eliminate ip->i_gh Date: Fri, 29 Apr 2022 12:42:09 +0200 Message-Id: <20220429104052.982069766@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220429104052.345760505@linuxfoundation.org> References: <20220429104052.345760505@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andreas Gruenbacher commit 1b223f7065bc7d89c4677c27381817cc95b117a8 upstream Now that gfs2_file_buffered_write is the only remaining user of ip->i_gh, we can move the glock holder to the stack (or rather, use the one we already have on the stack); there is no need for keeping the holder in the inode anymore. This is slightly complicated by the fact that we're using ip->i_gh for the statfs inode in gfs2_file_buffered_write as well. Writing to the statfs inode isn't very common, so allocate the statfs holder dynamically when needed. Signed-off-by: Andreas Gruenbacher Signed-off-by: Anand Jain Signed-off-by: Greg Kroah-Hartman --- fs/gfs2/file.c | 34 +++++++++++++++++++++------------- fs/gfs2/incore.h | 3 +-- 2 files changed, 22 insertions(+), 15 deletions(-) --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -877,16 +877,25 @@ out_uninit: return written ? written : ret; } -static ssize_t gfs2_file_buffered_write(struct kiocb *iocb, struct iov_iter *from) +static ssize_t gfs2_file_buffered_write(struct kiocb *iocb, + struct iov_iter *from, + struct gfs2_holder *gh) { struct file *file = iocb->ki_filp; struct inode *inode = file_inode(file); struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_sbd *sdp = GFS2_SB(inode); + struct gfs2_holder *statfs_gh = NULL; ssize_t ret; - gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &ip->i_gh); - ret = gfs2_glock_nq(&ip->i_gh); + if (inode == sdp->sd_rindex) { + statfs_gh = kmalloc(sizeof(*statfs_gh), GFP_NOFS); + if (!statfs_gh) + return -ENOMEM; + } + + gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, gh); + ret = gfs2_glock_nq(gh); if (ret) goto out_uninit; @@ -894,7 +903,7 @@ static ssize_t gfs2_file_buffered_write( struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode); ret = gfs2_glock_nq_init(m_ip->i_gl, LM_ST_EXCLUSIVE, - GL_NOCACHE, &m_ip->i_gh); + GL_NOCACHE, statfs_gh); if (ret) goto out_unlock; } @@ -905,16 +914,15 @@ static ssize_t gfs2_file_buffered_write( if (ret > 0) iocb->ki_pos += ret; - if (inode == sdp->sd_rindex) { - struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode); - - gfs2_glock_dq_uninit(&m_ip->i_gh); - } + if (inode == sdp->sd_rindex) + gfs2_glock_dq_uninit(statfs_gh); out_unlock: - gfs2_glock_dq(&ip->i_gh); + gfs2_glock_dq(gh); out_uninit: - gfs2_holder_uninit(&ip->i_gh); + gfs2_holder_uninit(gh); + if (statfs_gh) + kfree(statfs_gh); return ret; } @@ -969,7 +977,7 @@ static ssize_t gfs2_file_write_iter(stru goto out_unlock; iocb->ki_flags |= IOCB_DSYNC; - buffered = gfs2_file_buffered_write(iocb, from); + buffered = gfs2_file_buffered_write(iocb, from, &gh); if (unlikely(buffered <= 0)) { if (!ret) ret = buffered; @@ -990,7 +998,7 @@ static ssize_t gfs2_file_write_iter(stru if (!ret || ret2 > 0) ret += ret2; } else { - ret = gfs2_file_buffered_write(iocb, from); + ret = gfs2_file_buffered_write(iocb, from, &gh); if (likely(ret > 0)) ret = generic_write_sync(iocb, ret); } --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -387,9 +387,8 @@ struct gfs2_inode { u64 i_generation; u64 i_eattr; unsigned long i_flags; /* GIF_... */ - struct gfs2_glock *i_gl; /* Move into i_gh? */ + struct gfs2_glock *i_gl; struct gfs2_holder i_iopen_gh; - struct gfs2_holder i_gh; /* for prepare/commit_write only */ struct gfs2_qadata *i_qadata; /* quota allocation data */ struct gfs2_holder i_rgd_gh; struct gfs2_blkreserv i_res; /* rgrp multi-block reservation */