From patchwork Tue Nov 12 05:43:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13871747 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0FFC1A3BDA for ; Tue, 12 Nov 2024 05:44:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731390252; cv=none; b=fvHwlo5YQzwQ65XZU6IravzAEfpdV7Vx7KxhQqTYzDgYcbu+8+fu8paLe4EByE0V+iv/LfuUyATI3HFnPee3+EZZ8Bm3zUd233+pn9ntva6TJhhLgS87iJabCClWodBYNPa63FTQOKSBb5C3WDDCupK3Lt4rH0cgKCYwOiKg2k4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731390252; c=relaxed/simple; bh=oMPqhiRxOS6+1RGsJhc1hEyHSZG1fleVLuk9IYZwgr0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NC80h7jSWRg0DLz0OEljF2h3nW8Yx178eHiSwPCpvQXyzRg2u7wojzyEGjDhsAyQQNBzI+AE1ZpyR1CM2BKTHekmHhMOKE95z4JnszCxhsZ4a2XDnC1kaF63YTao5VyO8XtkY6ZVjJra+Zbmji5x0MS4M4c4Djzh9KuRe4N35d4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=DKj5KCPi; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="DKj5KCPi" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=nhXVlUGnvwLlrdmqkdk2gIbhddPQXqFcNJvuAIHGsLY=; b=DKj5KCPi5dB8085dJkW77ag4zZ E5VRdp3+R0IwZB/a78rHnVJ8u03zqPm6TqPlKmDf1xtUml3mk1PwFusWc3zZB5EdPCxk4e4t7N8KG MVH9ewpfV1tZIv6zwfRLp/TUlQ1pxpbJcFHxsTuw4adXt8EcfGJGJ/FTIYkK//kv0bz5ub0hO1zVi +p0RKdbvFCoxTUrq/c7q+/rqqXKY0c8/lMbIg9id0AHmmHRFggePjyi620Nj7xDXwuf/Poj/jPh1E ydCEn37ck7Tne8CC/FYLWfuwUyr8UIkXEAVbhSI4I0v1Vpo0Vymjnj/4FHSnwyKIj+3018owibo4E HIDnfj4w==; Received: from 2a02-8389-2341-5b80-9a3d-4734-1162-bba0.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:9a3d:4734:1162:bba0] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tAjhC-00000002HQj-03Eh; Tue, 12 Nov 2024 05:44:10 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner , Jan Kara Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 1/2] writeback: add a __releases annoation to wbc_attach_and_unlock_inode Date: Tue, 12 Nov 2024 06:43:54 +0100 Message-ID: <20241112054403.1470586-2-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241112054403.1470586-1-hch@lst.de> References: <20241112054403.1470586-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html This shuts up a sparse lock context tracking warning. Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara --- fs/fs-writeback.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index d8bec3c1bb1f..3fb115ae44b1 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -733,6 +733,7 @@ bool cleanup_offline_cgwb(struct bdi_writeback *wb) */ void wbc_attach_and_unlock_inode(struct writeback_control *wbc, struct inode *inode) + __releases(&inode->i_lock) { if (!inode_cgwb_enabled(inode)) { spin_unlock(&inode->i_lock); From patchwork Tue Nov 12 05:43:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13871748 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DBED1A3BDA for ; Tue, 12 Nov 2024 05:44:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731390255; cv=none; b=Pzae1leDeCE+FSLYGzJLZb1yRQlsRTH7F3AapoqByy6oDL1bYp65rDP7Y+WiTsSTU+Y5aUXpRPhN69p6KeLy8B1131tbYPFEUVdo6nwvlRakJMHFfBs/ditMQDvPamq5uBnBCWC+xQHF7bQhvvYtCMRrNHqZ1CMXkT9RYkLVVjg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731390255; c=relaxed/simple; bh=BzajZdw0dc5wu6ieeytC+Fzpy7Z5dS+zIyU+UGYWXLA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pCDsLzcbGwvS8J65ei3YFidA7WULxSOZAq2ZiJBC2T5BYcgeRZFuvVKE3mqXWIfuS2QxSPjO6GKCj3Xyxr/1LAEwJfoVbbGAeFMlETR7LZAA7o4khaPLJY+JqmV7QTpp3JD2JH4HZql6xS3Hjb9flRrt7Ph1WJbp6sZPD1k2OKo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=Gy5uV//K; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Gy5uV//K" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=HjUCUl7Ss/IglFF+ockSljmczaHG7wCrwAO/DZwgkpM=; b=Gy5uV//Ks4p3yyBFt2RdMaNhfl fwXgtP3ORtuWThgrs2RMC4LNOg9dBwt2k7ZkUzt+xXI0itq0Ye0/pFMp/xx7sGkseyaGy6NcCV5he FvsgdJjb4tRobaGky4QAw+1+kSR4lmavHTp7L7emqH2oVshAoFF2zsMPk6MhhwNWWJEZXkWyqXQ3a nPh7O6OEAvtH0CfDfrgO2CI/y37WMvzHd5HhD8VXpSvN84WXfbJvaqsfOlREnkPwdjUaLKeMVvES5 e/E20h3zRqPj2cUrM133w9MjGEHIocL6g9oY6vO/3Ng0gF+onrtjli6S6USZFsndE1n3+TjRzF81W b/NTi6Ig==; Received: from 2a02-8389-2341-5b80-9a3d-4734-1162-bba0.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:9a3d:4734:1162:bba0] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tAjhF-00000002HQx-1eGF; Tue, 12 Nov 2024 05:44:14 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner , Jan Kara Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 2/2] writeback: wbc_attach_fdatawrite_inode out of line Date: Tue, 12 Nov 2024 06:43:55 +0100 Message-ID: <20241112054403.1470586-3-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241112054403.1470586-1-hch@lst.de> References: <20241112054403.1470586-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html This allows exporting this high-level interface only while keeping wbc_attach_and_unlock_inode private in fs-writeback.c and unexporting __inode_attach_wb. Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara --- fs/fs-writeback.c | 31 +++++++++++++++++++++++++++---- include/linux/writeback.h | 28 ++-------------------------- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 3fb115ae44b1..77db1f10023e 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -290,7 +290,6 @@ void __inode_attach_wb(struct inode *inode, struct folio *folio) if (unlikely(cmpxchg(&inode->i_wb, NULL, wb))) wb_put(wb); } -EXPORT_SYMBOL_GPL(__inode_attach_wb); /** * inode_cgwb_move_to_attached - put the inode onto wb->b_attached list @@ -731,8 +730,8 @@ bool cleanup_offline_cgwb(struct bdi_writeback *wb) * writeback completion, wbc_detach_inode() should be called. This is used * to track the cgroup writeback context. */ -void wbc_attach_and_unlock_inode(struct writeback_control *wbc, - struct inode *inode) +static void wbc_attach_and_unlock_inode(struct writeback_control *wbc, + struct inode *inode) __releases(&inode->i_lock) { if (!inode_cgwb_enabled(inode)) { @@ -763,7 +762,24 @@ void wbc_attach_and_unlock_inode(struct writeback_control *wbc, if (unlikely(wb_dying(wbc->wb) && !css_is_dying(wbc->wb->memcg_css))) inode_switch_wbs(inode, wbc->wb_id); } -EXPORT_SYMBOL_GPL(wbc_attach_and_unlock_inode); + +/** + * wbc_attach_fdatawrite_inode - associate wbc and inode for fdatawrite + * @wbc: writeback_control of interest + * @inode: target inode + * + * This function is to be used by __filemap_fdatawrite_range(), which is an + * alternative entry point into writeback code, and first ensures @inode is + * associated with a bdi_writeback and attaches it to @wbc. + */ +void wbc_attach_fdatawrite_inode(struct writeback_control *wbc, + struct inode *inode) +{ + spin_lock(&inode->i_lock); + inode_attach_wb(inode, NULL); + wbc_attach_and_unlock_inode(wbc, inode); +} +EXPORT_SYMBOL_GPL(wbc_attach_fdatawrite_inode); /** * wbc_detach_inode - disassociate wbc from inode and perform foreign detection @@ -1228,6 +1244,13 @@ static void bdi_split_work_to_wbs(struct backing_dev_info *bdi, } } +static inline void wbc_attach_and_unlock_inode(struct writeback_control *wbc, + struct inode *inode) + __releases(&inode->i_lock) +{ + spin_unlock(&inode->i_lock); +} + #endif /* CONFIG_CGROUP_WRITEBACK */ /* diff --git a/include/linux/writeback.h b/include/linux/writeback.h index d6db822e4bb3..aee3e1b4c50f 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -213,9 +213,6 @@ static inline void wait_on_inode(struct inode *inode) #include void __inode_attach_wb(struct inode *inode, struct folio *folio); -void wbc_attach_and_unlock_inode(struct writeback_control *wbc, - struct inode *inode) - __releases(&inode->i_lock); void wbc_detach_inode(struct writeback_control *wbc); void wbc_account_cgroup_owner(struct writeback_control *wbc, struct page *page, size_t bytes); @@ -254,22 +251,8 @@ static inline void inode_detach_wb(struct inode *inode) } } -/** - * wbc_attach_fdatawrite_inode - associate wbc and inode for fdatawrite - * @wbc: writeback_control of interest - * @inode: target inode - * - * This function is to be used by __filemap_fdatawrite_range(), which is an - * alternative entry point into writeback code, and first ensures @inode is - * associated with a bdi_writeback and attaches it to @wbc. - */ -static inline void wbc_attach_fdatawrite_inode(struct writeback_control *wbc, - struct inode *inode) -{ - spin_lock(&inode->i_lock); - inode_attach_wb(inode, NULL); - wbc_attach_and_unlock_inode(wbc, inode); -} +void wbc_attach_fdatawrite_inode(struct writeback_control *wbc, + struct inode *inode); /** * wbc_init_bio - writeback specific initializtion of bio @@ -303,13 +286,6 @@ static inline void inode_detach_wb(struct inode *inode) { } -static inline void wbc_attach_and_unlock_inode(struct writeback_control *wbc, - struct inode *inode) - __releases(&inode->i_lock) -{ - spin_unlock(&inode->i_lock); -} - static inline void wbc_attach_fdatawrite_inode(struct writeback_control *wbc, struct inode *inode) {